Difference between revisions of "USB Blasting"

From Technologic Systems Manuals
(Created page with "= Overview = As many uses for our embedded boards require large quantities to be programmed we have added a mechanism for quickly blasting systems. In all of our linuxrc scripts...")
 
Line 9: Line 9:
  
 
= Preparing a tsinit USB drive =
 
= Preparing a tsinit USB drive =
== Example tsinit script ==
+
== Simple blast script ==
 +
This example expects an xnand-image.dd and/or an sd-image.dd in the root of the flash drive.  If you exclude either, it will still run while only programming one.  Normally, it will begin programming both and wait for them both to finish executing.  When the script exits, the red LED will turn off.  This will be compatible with the TS-75XX, TS-4200, TS-4500, TS-4700, and the TS-4800.  Though you can tweak the nand and SD writing to the restore commands for other applicable boards.
 
<source lang=bash>
 
<source lang=bash>
 
#!/bin/sh
 
#!/bin/sh
  
 +
# The linuxrc file will mount the USB drive in /mnt/usbdev/, so any
 +
# files you access must use that path.
  
 +
## Program Nand ##
 +
nandctl -XW 2048 -z 131072 -i /mnt/usbdev/xnand-image.dd &
 +
 +
## Program SD ##
 +
dd if=/mnt/usbdev/sd-image.dd bs=512 conv=sync of=/dev/nbd5 &
 +
 +
wait
 
</source>
 
</source>
  
 
= How this works =
 
= How this works =
In all of the linuxrc scripts we have a function to check if there is a USB drive inserted.
+
In all of the linuxrc scripts we have a function to check if there is a USB drive inserted. This example is from the TS-75XX/TS-4500 series linuxrc:
 
 
 
<source lang=bash>
 
<source lang=bash>
 
if [ "$x" -eq 1 ]; then
 
if [ "$x" -eq 1 ]; then

Revision as of 11:18, 1 September 2011

1 Overview

As many uses for our embedded boards require large quantities to be programmed we have added a mechanism for quickly blasting systems. In all of our linuxrc scripts we have added a function that will on boot:

  • Check for a USB drive
  • Turn on red LED
  • If detected load USB and ethernet modules
  • Mount the first partition of the drive
  • Execute tsinit
  • Turn off red LED

2 Preparing a tsinit USB drive

2.1 Simple blast script

This example expects an xnand-image.dd and/or an sd-image.dd in the root of the flash drive. If you exclude either, it will still run while only programming one. Normally, it will begin programming both and wait for them both to finish executing. When the script exits, the red LED will turn off. This will be compatible with the TS-75XX, TS-4200, TS-4500, TS-4700, and the TS-4800. Though you can tweak the nand and SD writing to the restore commands for other applicable boards.

#!/bin/sh

# The linuxrc file will mount the USB drive in /mnt/usbdev/, so any
# files you access must use that path.

## Program Nand ##
nandctl -XW 2048 -z 131072 -i /mnt/usbdev/xnand-image.dd &

## Program SD ##
dd if=/mnt/usbdev/sd-image.dd bs=512 conv=sync of=/dev/nbd5 &

wait

3 How this works

In all of the linuxrc scripts we have a function to check if there is a USB drive inserted. This example is from the TS-75XX/TS-4500 series linuxrc:

if [ "$x" -eq 1 ]; then
  (
        ts7500ctl --redledon
        mount -t tmpfs tmpfs /lib/modules
        tar -x -z -f /modules.tar.gz -C /
        modprobe scsi_mod
        modprobe sd_mod
        modprobe usbcore
        modprobe ehci_hcd
        modprobe usb_storage
        modprobe smscusbnet
        modprobe smsc9500
        modprobe ohci_hcd
        umount /lib/modules
        x=0
        while [ "$x" -lt 150 -a ! -e /sys/block/sda ]; do
                x=$((x+1))
                sleep .1
        done
        mount -o ro /dev/sda1 /mnt/usbdev
        if [ -x /mnt/usbdev/tsinit ]; then 
                /mnt/usbdev/tsinit <$CONSOLE >$CONSOLE 2>&1
        fi
        umount /mnt/usbdev
        ts7500ctl --redledoff
  ) &
fi