cancel
Showing results for 
Search instead for 
Did you mean: 

SD Card Bootloader, FAT FS Filesystem, USB Mass Storage

justinwoolich
Associate III
Posted on August 27, 2011 at 08:10

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) stm32_flash.id 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 🙂
2 REPLIES 2
pic
Associate
Posted on January 20, 2012 at 05:13

This is really good. I will check your code and see if i can change it to start the user firmware @ 

0x08005000 as this is the address use also by the maple (arduino clone) bootloader.

fmaeck
Associate
Posted on October 25, 2013 at 20:31

Hi jkwool,

very nice example - thank you for sharing it.

Have you done any bigger bug fixes in the last time?

Kind regards,

Broi