#!/usr/bin/expect -- # som-mfg-f7 -- program an Emcraft STM32F7 SOM end to end from this station, # unattended: U-Boot into the eNVM over JTAG, the kernel into NOR over TFTP from # this station, the board booted and its link tested over its serial console, # and the environment it ships with. Ends with one PASS or FAIL line. # # The VF6 manufacturing station's run for this SOM (manufacturing/expect: # mfg.exp som-stm32f7, target_som-stm32f7.exp, lib.exp), # step for step, with this station's own tools: som-program-f7 for the JTAG # half, som-console to find the board's console, in.tftpd-hpa for the kernel. # The station directory's mac/maclist and mac/lastmac are the VF6 SD card's, # with the same formats and the same rules (its getmac). set PROG som-mfg-f7 set STATION_DIR [expr {[info exists env(SOM_STATION_DIR)] ? $env(SOM_STATION_DIR) : "/var/lib/brintos-som"}] set OVERRIDE $STATION_DIR/som-mfg-f7.exp # Where an operator's own images go; som-program-f7 looks there for U-Boot too. set MEDIA_DIR [expr {[info exists env(SOM_MEDIA_DIR)] ? $env(SOM_MEDIA_DIR) : "/mnt/media/stm32f7"}] proc sha256_of {f} { if {[catch {exec sha256sum $f 2>/dev/null} r] || ![regexp {^[0-9a-f]{64}} $r h]} { return unknown } return $h } # A fixed copy of this script in the station directory runs in place of the # installed one, as the VF6 station took expect/*.exp from its SD card: a fix # needs no new image. Every run names the script it is, with its sha256. set SELF [file normalize [info script]] if {[lsearch -exact $argv --no-override] < 0 && [file isfile $OVERRIDE] && $SELF ne [file normalize $OVERRIDE]} { puts "$PROG: running the override $OVERRIDE in place of $SELF" flush stdout if {[catch {source $OVERRIDE} err]} { puts "$PROG: FAIL -- the override $OVERRIDE stopped: $err" exit 1 } exit 0 } # ============================================================================ # The frame: options, output, step timing, the MAC list. Nothing here is # specific to the F7. # ============================================================================ proc usage {{ch stdout}} { global PROG STATION_DIR MEDIA_DIR puts $ch "usage: $PROG \[options\] Programs one STM32F7 SOM: U-Boot into its eNVM (som-program-f7), the kernel into NOR (U-Boot's update, from this station's TFTP server), boots it, pings this station from the board, and leaves the environment it ships with. --mac MAC give the board this MAC; the MAC list is not touched --keep-mac keep the MAC the board already has (re-programming a board) default: the next MAC from $STATION_DIR/mac/maclist --console DEV the board's console (default: som-console --find) --netif IF the USB Ethernet adapter (default: the one USB network interface) --station-ip A this station's address on the cable (default 192.168.7.1) --board-ip A the board's address while it is programmed (default 192.168.7.2) --no-net leave the adapter's address and the TFTP server as they are --adapter NAME, --transport T, --speed KHZ, --image FILE passed to som-program-f7 (see som-program-f7 --help) --kernel FILE the kernel to write into NOR, any name. Default: $MEDIA_DIR/rootfs.uImage when there is one, else the built-in copy. Its record is FILE.PROVENANCE beside it, else the built-in one (som-provenance-f7 writes it) --reset-test at the end, wait for the board's reset button to be pressed --log FILE the console transcript (default /tmp/$PROG-