Close

Bootloader

A project log for Camera badge for Supercon 2017

Conference badge for the 2017 Hackaday Superconference Features: camera module, 128x128 OLED display, MicroSD card socket and accelerometer

mike-harrisonMike Harrison 10/11/2017 at 10:590 Comments

Bootloader

A bootloader is included which allows  firmware programming from .hex files from the SD card.

At startup, the bootloader first verifies a checksum on the application area, and if valid, enters the application code after approx 1 second. Pressing the bottom-left button during this period (or holding it when turning on) allows manual entry to the bootloader menu If  the application checksum is invalid, it displays a warning message and allows the user to enter the bootloader menu or attempt to run the application code anyway (the latter will usually fail). The checksum is created by the bootloader when it has finished programming the flash, ensuring that a failed or incomplete programming operation will not result in a valid sum.
The bootloader uses the PIC user ID config locations in the hex file to verify that the code is intended for the badge hardware. A warning will be displayed if there is a mismatch. Any addresses in the hex file outside the application area will be ignored.

While the bootloader is active, the LED will blink periodically. This is mostly to indicate that the bootloader is running, in the case of a faulty display, to distinguish from lack of power etc.

The bootloader will power down after 2 minutes of inactivity.

Flash memory usage

0x1D00 0000 to 0x1D00 7BFF : Bootloader
0x1D00 7C00 to 0x1D00 7FFF : Reserved for application nonvolatile settings.
0x1D00 8000 to 0x1D03 FFFB : Application code
0x1D03 FFFC to 0x1D03 FFFF : Checksum on application code. 32-bit sum of all bytes in application area, LSByte first
0x1FC0 0000 to 1FC0 0BEF : Reset vector and boot area (part of bootloader)

Files

See files section for bootloader MPLABX project and combined bootloader+application code .hex file

Discussions