1#!/bin/sh 2 3# 4# Test out using environment variables when writing 5# 6 7. "$(cd "$(dirname "$0")" && pwd)/common.sh" 8 9cat >$CONFIG <<EOF 10define(BOOT_PART_OFFSET, 63) 11define(BOOT_PART_COUNT, 77238) 12 13mbr mbr-a { 14 partition 0 { 15 block-offset = \${BOOT_PART_OFFSET} 16 block-count = \${BOOT_PART_COUNT} 17 type = 0xc # FAT32 18 boot = true 19 } 20} 21task complete { 22 on-init { 23 mbr_write(mbr-a) 24 fat_mkfs(\${BOOT_PART_OFFSET}, \${BOOT_PART_COUNT}) 25 fat_touch(\${BOOT_PART_OFFSET}, "\\\${MYVAR}") 26 } 27} 28EOF 29 30# Create the firmware file, then "burn it" 31$FWUP_CREATE -c -f $CONFIG -o $FWFILE 32 33# Set MYVAR to the filename that we want to be created 34MYVAR="test0123.txt" $FWUP_APPLY -a -d $IMGFILE -i $FWFILE -t complete 35 36EXPECTED_OUTPUT=$WORK/expected.out 37ACTUAL_OUTPUT=$WORK/actual.out 38 39cat >$EXPECTED_OUTPUT << EOF 40 Volume in drive : has no label 41 Volume Serial Number is 0022-2DB6 42Directory for ::/ 43 44test0123 txt 0 1980-01-01 0:00 45 1 file 0 bytes 46 38 910 464 bytes free 47 48EOF 49 50# Check that the directory looks right 51mdir -i $WORK/fwup.img@@32256 > $ACTUAL_OUTPUT 52diff -w $EXPECTED_OUTPUT $ACTUAL_OUTPUT 53 54# Check the FAT file format using fsck 55dd if=$WORK/fwup.img skip=63 of=$WORK/vfat.img 56$FSCK_FAT $WORK/vfat.img 57 58# Check that the verify logic works on this file 59$FWUP_VERIFY -V -i $FWFILE 60