matthiasbock / cvra-bootloader

CAN-Bootloader of the Club Vaudois de Robotique Autonome
BSD 2-Clause "Simplified" License
0 stars 1 forks source link

CAN Bootloader

Build Status

This repository contains source the code for the Controller Area Network (CAN) bootloader, which is running on every microcontroller in our robots. It allows us to quickly update the firmware on all (>20) boards without disassembly or additional electrical connections.

Configuration pages

The bootloader is the first program to be executed on an embedded sytem upon startup. The bootloader code is followed by two flash pages, each containing a bootloader configuration struct. The two pages are for redundancy. A checksum (CRC32) is present at the beginning of each page and checked by the bootloader. In case an invalid page is detected, it's content is replaced by the redundant page.

After the bootloader has updated one of the two configuration pages, it verifies it before proceeding to the second one. This ensures that there is always a valid configuration page to prevent bricking a board.

The config contains the following informations, stored as a MessagePack map:

Performance considerations

Assuming :

We can flash a whole board (1MB) in about 20 seconds. If all board in the robot run the same firmware, this is the time required to do a full system update!

Safety features

The bootloader is expected to be one of the safest part of the robot firmware. Correcting a bug in the bootloader could be very complicated, requiring disassembly of the robot in the worst cases. Therefore, when implementing the bootloader or the associated protocol, the following safety points must be taken into account:

How to build

  1. Run CVRA's packager script: packager.
  2. Build libopencm3: pushd libopencm3 && make && popd.
  3. Build your desired platform: cd platform/motor-board-v1 && make.
  4. Flash the resulting binary to your board: make flash.

Protocol

The protocol is described in PROTOCOL.markdown.

License

See LICENSE.md.