usbasp does paged writes and i wrote this to investigate some writes that dont appear to be happening on page boundaries. Not sure if it will be helpful for anyone else but thought I would throw it out there
the code
Code: Select all
#!/bin/bash
pages=2
pagesize=256
#bytecount=16
bytecount=32
address=0 ;msb=0 ;lsb=0 ;startcode=":" ;recordtype="00"
function dec2hex () { converted=$(printf "%${padwidth}X\n" $convert) ;}
for ((t=1; t<=$pages; t++)) ;do
#echo this is page number $t
for ((p=1; p<=(($pagesize/$bytecount)); p++)) ;do
#echo this is line number $p of page number $t
padwidth=00 ;convert=$bytecount; dec2hex; bytecounthex=$converted
padwidth=04 ;convert=$address; dec2hex; addresshex=$converted
echo -n "${startcode}${bytecounthex}${addresshex}${recordtype}"
linetotal="0x${bytecounthex} + 0x${addresshex:0:2} + 0x${addresshex:2:2} + 0x${recordtype} +"
for ((b=0; b<$bytecount; b++)) ;do
padwidth=00 ;convert=$lsb; dec2hex; lsbhex=$converted
padwidth=00 ;convert=$msb; dec2hex; msbhex=$converted
currentbyte="${msbhex}${lsbhex}"
linetotal="$linetotal 0x$currentbyte +"
echo -n "$currentbyte"
((lsb++))
((address++))
if [ $lsb -gt 15 ] ;then
lsb=0
fi
done
linetotal="$linetotal 0x0"
#echo "this is linetotal $linetotal"
linesum=$(($linetotal))
padwidth=00 ;convert=$linesum; dec2hex; linesumhex=$converted
truncatedhex=${linesumhex: -2}
checksum=$((0x100 - 0x$truncatedhex))
# this is real hackish
if [ $checksum -eq 256 ] ;then
checksum=0
fi
padwidth=02 ;convert=$checksum; dec2hex; checksumhex=$converted
hexcheck=$((0x$truncatedhex + 0x$checksumhex))
# this prints out the total, hextotal, truncatedhex, CHECKSUM, verification
#echo "- $linesum $linesumhex $truncatedhex $checksumhex $hexcheck"
echo $checksumhex
linetotal=""
done
((msb++))
if [ $msb -gt 15 ] ;then
msb=0
fi
done
# we are done so lets generate the closing line
echo "${startcode}00000001FF"
the resulting hex
Code: Select all
:20000000000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0FF0
:20002000000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0FD0
:20004000000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0FB0
:20006000000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F90
:20008000000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F70
:2000A000000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F50
:2000C000000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F30
:2000E000000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F10
:20010000101112131415161718191A1B1C1D1E1F101112131415161718191A1B1C1D1E1FEF
:20012000101112131415161718191A1B1C1D1E1F101112131415161718191A1B1C1D1E1FCF
:20014000101112131415161718191A1B1C1D1E1F101112131415161718191A1B1C1D1E1FAF
:20016000101112131415161718191A1B1C1D1E1F101112131415161718191A1B1C1D1E1F8F
:20018000101112131415161718191A1B1C1D1E1F101112131415161718191A1B1C1D1E1F6F
:2001A000101112131415161718191A1B1C1D1E1F101112131415161718191A1B1C1D1E1F4F
:2001C000101112131415161718191A1B1C1D1E1F101112131415161718191A1B1C1D1E1F2F
:2001E000101112131415161718191A1B1C1D1E1F101112131415161718191A1B1C1D1E1F0F
:00000001FF