Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 3 months ago.
Bootloader LPC1768 with SPI Flash FAT16 filsystem
I am developing an application which should be up-gradable via internet. The Idea is to have an SPI Flash (> 1MB) instead of the dedicated mBed chip. The bootloader should check if there is a file available on the SPI Flash chip and if so, program the ARM and start the application. If not, start the application if available.
The application itself should have the capability to read, write, modify and delete files on the SPI Flash drive.
A nice to have would be if the bootloader could store files via Ethernet or uart (usb uart). This way only the bootloader must be programmed via JTAG and any application, or for recovery, can be programmed via Ethernet or uart.
The application itself should check if there is a new FW release is available on the internet (Ethernet) and saves the file on the SPI Flash. If the file is saved, it should reboot the ARM.
I noticed that there are some bootloaders available on the internet which loads files from USB or SDCARD. But this is not the way I would like to have it. To modify an existing library, e.g. the SDCARD bootloader, to an SPI Flash chip is one step to far for me. The SPI Flash library will not be the problem, there are more than enough examples of those, but to add support for FAT16 on an SPI Flash chip is...
Are there any examples how to use a FAT16 FS on a SPI Flash chip? Does anybody know a bootloader (for a LPC1768) which has SPI Flash support instead of SDCARD or USB Flash?
with kind regards, Ben
Question relating to:
1 Answer
10 years, 3 months ago.
<<quote>>but to add support for FAT16 on an SPI Flash chip is...<</quote>>
Extremely easy :D
Well maybe not extremely, but it is definately doable. When that is done it should be doable to port the program which uses an SD card to your SPI flash. First a question though: Sure you don't want to use an SD card?
Strangely I can't seem to find examples where it is done. I have done something close myself once, since I don't want to spend too much time searching, lets use that example: http://mbed.org/users/Sissors/code/S25FL216K_USBFileSystem/. Instead of USBFileSystem you get FATFileSystem (http://mbed.org/teams/mbed-official/code/FATFileSystem/). You need to implement the following functions in your library:
virtual int disk_initialize() { return 0; } virtual int disk_status() { return 0; } virtual int disk_read(uint8_t * buffer, uint64_t sector, uint8_t count) = 0; virtual int disk_write(const uint8_t * buffer, uint64_t sector, uint8_t count) = 0; virtual int disk_sync() { return 0; } virtual uint64_t disk_sectors() = 0;
Most are straightforward, stuff like disk_sync is from another era and you can just ignore it. The read, write and numbder of sectors you have to implement, the others you may implement. Done that? Well now you are finished, you have a FATFileSystem running on your flash chip.
One little detail which is irritating: The default sector size for a FATFileSystem is 512B. I believe you can change the sector size that FATFileSystem uses, but that you would need to look up yourself. In the linked example IIRC the minimum erase size of the flash IC was 4kB, and in the end I just did the easy solution (since it is mainly a proof of concept for the USBFileSystem lib), and only used 512B of each 4kB sector. But that is of course not very area efficient. If you find a flash IC with a minimum erase size of 512B you are set, otherwise you either need to work around the issue (for example copying data to RAM), or you need to get the file system lib to use different sector size, or you need to accept that you don't use your entire memory.
Thanks Erik,
Funny, Sam (ARM) already said that you probably would answer. Sam stated me that there was no known existing solution for this and advised me to ask the question on the forum.
So, once I am able to make a FS for SPI Flash, it would be so hard to add it to the bootloader. I am far from experienced with bootloaders or libraries, but I will give it a try. Hopefully I will exceed and post it on the mBed library page.
with kind regards, Ben
posted by 20 Sep 2014
Are there any updates? I am also interested in updating firmware over ethernet without the interface.
posted by Marius 90 15 Jul 2015