USB Mass Storage/MMC Bootloader design


I've got a small project that I think will benefit from a bootloader. The main system consists of a MSP430F5513 micro, a MMC drive, a USB connection. My plan is to replace the current DFU based USB bootloader with one that will simply copy a binary firmware file from the MMC into the main memory of the MSP430. This means the bootloader itself will need a FAT library I plan to make use of petietFS.

Below is a diagram that outlines how the bootloader will operate. There are two parts to this

Part 1: Main program/Entry sequence

The main firmware on the device will check if someone has copied a new fw onto the device when it is unplugged.

This can't be done in real-time as the host PC is in control of the filesystem at this stage, due to haw USB MSD works.

The main program will be able to perform additional checks like CRC and filesize to determine if it's a valid file. Maybe check if it's identical to loaded fw. Assuming these all pass then we can load up the bootloader.

Part 2: Custom Bootloader

The bootloader will reside in the bootloader space. It shall perform the following functions

  • Re-init MMC using it's own petietFS library
  • Open the new FW file
  • Write the file into memory
  • Verify the process
  • Reboot into the main application

It would be possible to re-use some of the FAT library that is used in the main application, especially given that it needs to open the file to check if it's valid before calling the bootloader. However I think designing the two applications separately will be easier to debug.