Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootloader - Mission - Leka Bootloader & Firmware Update #14

Open
11 of 18 tasks
ladislas opened this issue Jun 14, 2020 · 1 comment
Open
11 of 18 tasks

Bootloader - Mission - Leka Bootloader & Firmware Update #14

ladislas opened this issue Jun 14, 2020 · 1 comment
Assignees
Labels
01 - type: story Clear roadmap to implement a new feature, refactor code, etc.

Comments

@ladislas
Copy link
Member

ladislas commented Jun 14, 2020

Mission - Leka Bootloader & Firmware Update

Introduction

Leka is an interactive educational toy. It contains a complex firmware called LekaOS. As with any kind of software, LekaOS will need to be updated in the future to add new features to the product, improve existing ones and fix bugs.

To do so, LekaOS must to provide a way to update the firmware without breaking the robot.

The Mission

Develop a bootloader to handle the firmware update process

Constraints

  • Mbed OS based
  • check firmware integrity
  • roll back in case of failure
  • prevent infinite reboot loop

Technical description

Leka's PCB contains 3 external memories:

  • 1st one contains the factory firmware and is read only. It is flashed during manufacturing and is used to put the product back to factory settings
  • 2nd one contains the current firmware used by the robot
  • 3rd one will be used to store the new version available before updating

LekaOS is not executed from external memory, thus a new update needs to be written to the MCU flash.

The process is as follow:

  • LekaOS is running normally
  • the iPad app send a command saying that it will send a new firmware update
  • LekaOS reads the incoming update and writes it to the available external flash
  • LekaOS checks the firmware is not corrupt and is signed and provided by APF France handicap
  • LekaOS reboots
  • the bootloader starts first, checks again that the new update is suitable
    • if the update is suitable, the bootloader writes it to the MCU flash, checks it was written correctly and then starts the program
    • if it is not the bootloader starts the current firmware

Steps

1. TTHW (Time To Hello World) & Bootloader

As a first step, we need to better understand the concepts behind a bootloader.

  • - read the documentation
  • - read the documentation, again
  • - follow the Mbed Bootoader Example to create a very simple bootloader to just print something while it runs (you might need to add delays to see the text from the terminal)
  • - play with the addresses, get a better understanding of what works and what doesn't, don't be afraid to break things
  • - get a clear view and document the process using Mbed CLI (not the online compiler nor Mbed Studio)

2. TTHW & New Firmware Storage

The second step focuses on the other side of the mission, storing the new firmware in flash. For simplicity, we will upload the new firmware through USB.

  • - create two very simple Mbed OS programs to blink a LED at different speed (every 2 seconds vs. every 500 ms)
  • - store the .hex and .bin safely
  • - find out which one is needed to the update
  • - create the Mbed OS update program that will listen to incoming data and store them in the flash memory
  • - check that data written on flash are the same than the ones sent via USB
  • - find a way to safely send the new firmware from the computer using Python, Ruby, or whatever language your confortable using. This tool will take the .hex or .bin as input

3. Deep Dive Bootloader & Firmware Update

In the previous steps we learned how to make a bootloader and how to store a new firmware image. In this third step, we will put the two together and update the firmware.

  • - create a bootloader to read the external flash memory
  • - write something to the external flash memory and read it from the bootloader to make sure it works
  • - update the bootloader to write to the MCU flash
  • - flash the board with one of the two program created in step 2
  • - when the board is running, send via USB the other one to be stored in external flash memory
  • - reboot the board so that the bootloader can read the external flash and write the new firmware using Flash IAP
  • - then launch the program and see if it works

Resources

@ladislas ladislas added the 01 - type: story Clear roadmap to implement a new feature, refactor code, etc. label Jun 14, 2020
@JashShaik
Copy link

Some additional Nordic References :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - type: story Clear roadmap to implement a new feature, refactor code, etc.
Projects
None yet
Development

No branches or pull requests

3 participants