On 12.11.2010 12:18, Carl-Daniel Hailfinger wrote:
New version: Fix error handling. libusb returns the number of bytes read/written, and those are nonzero in our case, triggering a false abort.
Support bulk read on Dediprog SF100. Should result in native speed for plain read and erase. Should result in a measurable speedup for writes due to a fast verify.
Read tests with chunksize = 0x20 would be appreciated. Read tests with chunksize = 0x1 would be appreciated. Both should be a lot slower, but still yield correct images.
Packet size is 512 bytes. Depending on your USB hardware and the Dediprog firmware version, this may not work at all. Add lots of error checking where it was missing before. Somewhat tested, experimental, may hang/crash the programmer.
Write tests of random images are appreciated.
Please note that flashrom needs full access permissions for the USB device.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Here is a totally nonportable test script which downloads flashrom, applies the patch, performs all tests and leaves behind two files with the results in a temporary directory. Just run it from anywhere in your system.
#!/bin/bash # Test script for flashrom patchwork 2306 # Copyright 2010 Carl-Daniel Hailfinger # Licensed under the GNU General Public License version 2.0
timecheck=$(which time)
OLDDIR=$(pwd)
# test data location mytmpdir=$(mktemp -d -t flashrom_test.XXXXXXXXXX) if [ "$?" != "0" ] ; then echo "Could not create temporary directory" exit 1 fi
cd $mytmpdir
svn co svn://coreboot.org/flashrom/trunk flashrom cd flashrom svn revert -R . svn up make distclean curl -s http://patchwork.coreboot.org/patch/2306/raw/%7Cpatch -p1
a=2306_plain echo Running test $a cp -a dediprog.c dediprog.c_$a rm -f dediprog.o make CONFIG_INTERNAL=no CONFIG_SERPROG=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no CONFIG_FT2232_SPI=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICINTEL_SPI=no CONFIG_BUSPIRATE_SPI=no CONFIG_DEDIPROG=yes CONFIG_DUMMY=no >dediprog_$a.buildlog 2>&1 $timecheck ./flashrom -p dediprog -V -r dediprog_readback_$a.rom >dediprog_$a.log 2>&1
sed -i 's/([[:blank:]]+chunksize[[:blank:]]*=)[[:blank:]]*0x[0-9a-f]*/\1 0x100/' dediprog.c a=2306_chunk0x100 echo Running test $a cp -a dediprog.c dediprog.c_$a rm -f dediprog.o make CONFIG_INTERNAL=no CONFIG_SERPROG=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no CONFIG_FT2232_SPI=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICINTEL_SPI=no CONFIG_BUSPIRATE_SPI=no CONFIG_DEDIPROG=yes CONFIG_DUMMY=no >dediprog_$a.buildlog 2>&1 $timecheck ./flashrom -p dediprog -V -r dediprog_readback_$a.rom >dediprog_$a.log 2>&1
sed -i 's/([[:blank:]]+chunksize[[:blank:]]*=)[[:blank:]]*0x[0-9a-f]*/\1 0x20/' dediprog.c a=2306_chunk0x20 echo Running test $a cp -a dediprog.c dediprog.c_$a rm -f dediprog.o make CONFIG_INTERNAL=no CONFIG_SERPROG=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no CONFIG_FT2232_SPI=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICINTEL_SPI=no CONFIG_BUSPIRATE_SPI=no CONFIG_DEDIPROG=yes CONFIG_DUMMY=no >dediprog_$a.buildlog 2>&1 $timecheck ./flashrom -p dediprog -V -r dediprog_readback_$a.rom >dediprog_$a.log 2>&1
sed -i 's/([[:blank:]]+chunksize[[:blank:]]*=)[[:blank:]]*0x[0-9a-f]*/\1 0x01/' dediprog.c a=2306_chunk0x01 echo Running test $a cp -a dediprog.c dediprog.c_$a rm -f dediprog.o make CONFIG_INTERNAL=no CONFIG_SERPROG=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no CONFIG_FT2232_SPI=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICINTEL_SPI=no CONFIG_BUSPIRATE_SPI=no CONFIG_DEDIPROG=yes CONFIG_DUMMY=no >dediprog_$a.buildlog 2>&1 $timecheck ./flashrom -p dediprog -V -r dediprog_readback_$a.rom >dediprog_$a.log 2>&1
sed -i 's/([[:blank:]]+chunksize[[:blank:]]*=)[[:blank:]]*0x[0-9a-f]*/\1 0x200/' dediprog.c sed -i 's/([[:blank:]]+offset[[:blank:]]*=)[[:blank:]]*0[0-9a-fx]*/\1 0x0/' dediprog.c a=2306_chunk0x200_offset_0x0 echo Running test $a cp -a dediprog.c dediprog.c_$a rm -f dediprog.o make CONFIG_INTERNAL=no CONFIG_SERPROG=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no CONFIG_FT2232_SPI=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICINTEL_SPI=no CONFIG_BUSPIRATE_SPI=no CONFIG_DEDIPROG=yes CONFIG_DUMMY=no >dediprog_$a.buildlog 2>&1 $timecheck ./flashrom -p dediprog -V -r dediprog_readback_$a.rom >dediprog_$a.log 2>&1
sed -i 's/([[:blank:]]+chunksize[[:blank:]]*=)[[:blank:]]*0x[0-9a-f]*/\1 0x200/' dediprog.c sed -i 's/([[:blank:]]+offset[[:blank:]]*=)[[:blank:]]*0[0-9a-fx]*/\1 0x1/' dediprog.c a=2306_chunk0x200_offset_0x1 echo Running test $a cp -a dediprog.c dediprog.c_$a rm -f dediprog.o make CONFIG_INTERNAL=no CONFIG_SERPROG=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no CONFIG_FT2232_SPI=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICINTEL_SPI=no CONFIG_BUSPIRATE_SPI=no CONFIG_DEDIPROG=yes CONFIG_DUMMY=no >dediprog_$a.buildlog 2>&1 $timecheck ./flashrom -p dediprog -V -r dediprog_readback_$a.rom >dediprog_$a.log 2>&1
sed -i 's/([[:blank:]]+chunksize[[:blank:]]*=)[[:blank:]]*0x[0-9a-f]*/\1 0x200/' dediprog.c sed -i 's/([[:blank:]]+offset[[:blank:]]*=)[[:blank:]]*0[0-9a-fx]*/\1 0x10/' dediprog.c a=2306_chunk0x200_offset_0x10 echo Running test $a cp -a dediprog.c dediprog.c_$a rm -f dediprog.o make CONFIG_INTERNAL=no CONFIG_SERPROG=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no CONFIG_FT2232_SPI=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICINTEL_SPI=no CONFIG_BUSPIRATE_SPI=no CONFIG_DEDIPROG=yes CONFIG_DUMMY=no >dediprog_$a.buildlog 2>&1 $timecheck ./flashrom -p dediprog -V -r dediprog_readback_$a.rom >dediprog_$a.log 2>&1
sed -i 's/([[:blank:]]+chunksize[[:blank:]]*=)[[:blank:]]*0x[0-9a-f]*/\1 0x100/' dediprog.c sed -i 's/([[:blank:]]+offset[[:blank:]]*=)[[:blank:]]*0[0-9a-fx]*/\1 0x0/' dediprog.c a=2306_chunk0x100_offset_0x0 echo Running test $a cp -a dediprog.c dediprog.c_$a rm -f dediprog.o make CONFIG_INTERNAL=no CONFIG_SERPROG=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no CONFIG_FT2232_SPI=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICINTEL_SPI=no CONFIG_BUSPIRATE_SPI=no CONFIG_DEDIPROG=yes CONFIG_DUMMY=no >dediprog_$a.buildlog 2>&1 $timecheck ./flashrom -p dediprog -V -r dediprog_readback_$a.rom >dediprog_$a.log 2>&1
sed -i 's/([[:blank:]]+chunksize[[:blank:]]*=)[[:blank:]]*0x[0-9a-f]*/\1 0x100/' dediprog.c sed -i 's/([[:blank:]]+offset[[:blank:]]*=)[[:blank:]]*0[0-9a-fx]*/\1 0x1/' dediprog.c a=2306_chunk0x100_offset_0x1 echo Running test $a cp -a dediprog.c dediprog.c_$a rm -f dediprog.o make CONFIG_INTERNAL=no CONFIG_SERPROG=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no CONFIG_FT2232_SPI=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICINTEL_SPI=no CONFIG_BUSPIRATE_SPI=no CONFIG_DEDIPROG=yes CONFIG_DUMMY=no >dediprog_$a.buildlog 2>&1 $timecheck ./flashrom -p dediprog -V -r dediprog_readback_$a.rom >dediprog_$a.log 2>&1
sed -i 's/([[:blank:]]+chunksize[[:blank:]]*=)[[:blank:]]*0x[0-9a-f]*/\1 0x100/' dediprog.c sed -i 's/([[:blank:]]+offset[[:blank:]]*=)[[:blank:]]*0[0-9a-fx]*/\1 0x10/' dediprog.c a=2306_chunk0x100_offset_0x10 echo Running test $a cp -a dediprog.c dediprog.c_$a rm -f dediprog.o make CONFIG_INTERNAL=no CONFIG_SERPROG=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no CONFIG_FT2232_SPI=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICINTEL_SPI=no CONFIG_BUSPIRATE_SPI=no CONFIG_DEDIPROG=yes CONFIG_DUMMY=no >dediprog_$a.buildlog 2>&1 $timecheck ./flashrom -p dediprog -V -r dediprog_readback_$a.rom >dediprog_$a.log 2>&1
sha1sum dediprog_readback_*.rom >dediprog_images.sha1
# Pack the results echo Packing the results tar czf ../flashrom_patchwork_2306_testresults.tar.gz dediprog.c_* dediprog_*.buildlog dediprog_*.log dediprog_images.sha1 tar cf ../flashrom_patchwork_2306_images.tar dediprog_readback_*.rom
# Clean up echo Cleaning up rm -f dediprog.c_* dediprog_*.buildlog dediprog_*.log dediprog_images.sha1 dediprog_readback_*.rom make distclean svn revert -R . cd .. rm -f -rf flashrom
# Tell the user echo echo The following files contain the test results: echo $mytmpdir/flashrom_patchwork_2306_testresults.tar.gz $mytmpdir/flashrom_patchwork_2306_images.tar