AnsweredAssumed Answered

SD Card Bootloader, FAT FS Filesystem, USB Mass Storage

Question asked by jkwool on Aug 27, 2011
Latest reply on Oct 25, 2013 by Broi
I have been reading and learning on this forum for awhile as i worked through my first decent size project with the STM32. I thought it was about time i posted up here and contributed some code :) I have just got a SD card bootloader up and running using the FAT FS filesystem and the mass storage usb driver from the STM USB device driver library.

The project was developed in Atollic True Studio and runs on Mini STM32 v3.0 demo board (schematic included in attached zip file) and the GPIO pins are configurable in the main.h file so it should be easy to get up an running on other demo boards.

The project allows you to save a file named firmware.bin on the root of the sd card and when the board is re-started it reads the new firmware and flashes the contents to memory location 0x08006000 (this is for the smaller release version of the code so when flashing to your board make sure the release configuration is selected in atollic)

If there is no file named firmware.bin on the sd card or there is no application already flashed to 0x08006000 then the board is configured as a mass storage usb device allowing you to plug the board into your pc and save the firmware.bin to the sd card for loading next time the board is restarted.

2 changes are required in the target project (the one that will be loaded into flash):

1) file
FLASH (rx)      : ORIGIN = 0x08006000, LENGTH = 128K - 0x6000

2) relocate vector table
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x6000);

I have also included a demo project LEDFlash which has the memory offset and vector relocation. so its easy to see what changes are needed.

I am also interested to get some feedback on the code in an effort to improve my coding in this environment as i have come from a very different background mainly coding in c# in a Microsoft environment so its quite a (refreshing) change going back to bare bones embedded c coding :)