views:

266

answers:

2

I have a CE 6.0 project on a PXA310 where I need to be able to download OS updates (nk.bin) via Wi-Fi and safely flash the new OS to my device. I'm open to other suggestions about how to do this, but I'm considering saving the nk.bin to my file system in NAND flash, then restarting and have the bootloader locate the file in the file system and flash it to the BINFS partition. Is this possible, and if so, can you give me an outline of what I'd need to do?

One caveat is that this needs to be very robust since the devices are deployed in the field and are not field serviceable. I need to be sure that if the OS flash fails (due to power failure, etc.) that upon reboot the bootloader can try again. That is why I'd like to store the downloaded image in persistent flash and avoid having to re-download the image.

A: 

Technically just about anything is possible. For this strategy what you would need is code for your bootloader to mount the NAND flash as a drive and have a FAT driver so that it can traverse that file system and find the image. That is a lot of work if you don't already have it.

THe other option is to just store it in flash outside of the file system in a known address location. That's a lot easier from the bootloader perspective as all you have to do is map to the address and copy. Of course it makes the writes more challenging because then you're doing it from the OS and you have to disable any other flash accesses completely while you do your write to prevent corruption by two threads sending flash commands to the chip at the same time.

In either case, if you have the space it's a good idea to store a "known-good" image elsewhere too, so that if the new image has a problem (fails a checksum or x number of load attempts fails) then you have a working OS that the bootloader can fall back to.

ctacke
Thanks for the quick response, Chris! For our PXA270/NOR-based product, I'm shutting down MSFLASH and then using RFD to flash the new OS to a secondary partition, then the bootloader flashes that into the real OS partition. That works great, but it eats up a lot of flash. That's why I would like a FATFS to serve double duty.Can you point me to any information about how to mount the NAND flash as a drive in the bootloader? I was planning on starting with the SD/MMC download option from the Zylonite BSP, since that is a FATFS. Does that make sense?
rjones54
The SD driver or a USB Flash driver would make sense as they both will have FAT. You're still going to need to extract the low-level flash access pieces, but that should already be there if it's already reading and writing flash.
ctacke
A: 

Clearly a lot depends on your hardware setup, but we've done this without making the Bootloader support the Flash Filesystem.

In our product, the OS image is loaded from Flash to execute from RAM -- I think most WinCE devices work this way nowadays. So to update the OS we use a special Flash driver which lets an application, running under WinCE, update the OS blocks in the Flash -- then all you need is a hard reboot and the Bootloader loads the new flash image into RAM in order to execute it. We've found this pretty reliable in the field (with some not-very-technical end-users!).

A special Flash driver was needed because the MS Flash Filesystem drivers have no access to the OS image sectors of the Flash, in order to prevent trashing the OS by accident.

You do need to load the NK.BIN into some memory which the OS programming application can read, normally the NAND Flash, but if you had enough RAM it could just go into the root of the filestore. However either way you can delete it when you've finished programming the OS sectors before the reboot so it's only a temporary requirement.

AAT
For this solution you need to make sure that the updater image is RAM based so that there won't be any registry flushing while you access the Flash media
Shaihi