I am trialling bootloading an Atmega 1284P by FTP transfer of the .HEX file, and it is working quite nicely.
The AT1284P is a data logger several hundred miles away, and I want to be able to update firmware by FTP and sms from time to time. The plan is to save the new boot.hex file on my server, then sms the remote device and tell it to FTP upload the boot.hex file to its local SD card. It then does a watchdog, which causes the bootloader to visit the SD card and do its thing.
I am currently trialling this process and it works OK, but I'd like a bit more security so that a flash doesn't occur by mistake. Admittedly, after the bootload, the boot.hex file gets renamed so a flash shouldn't happen by mistake.
Thoughts: sms an instruction to save a small text file to the SD card called "enable__.txt", then do the FTP upload from the server. Program the bootloader to read the SD, look for the text file AND a file called boot.hex. If it finds both, do the bootload thing, then erase 'enable__.txt' and change 'boot.hex' to 'bootdone.hex'. At least there would be then 2 steps before a faulty unwanted flash.
Any better ideas someone?
I cant sms a variable values instead of the .txt file idea because the watchdog reset required to kick the bootloader into gear, erase all variables, unless I made it an ERAM var which i don't want to do.
File integrity: I was getting bent out of shape doing a CRC on the file at the server end then re-calculating it at the remote device,. BUT each line of the .hex file has a check sum as the last 2 digits and the file length so the bootloader which checks both, I hope should be good enough. ( en.wikipedia.org/wiki/Intel_HEX)
One thing that caused me some grief was - during the FTP upload, I was detecting the 00000001F eof marker and saving it to my SD card at the end of boot.hex but I missed the CRLF after the 1FF, (which I am pleased to say the bootloader found and rejected, as a "line error 07). Took a bit of finding what the difference between the good file and the bad file was, but Winmerge.exe (a nice file comparison program) found the difference for me.
Comments/criticism welcome
↧