Git Product home page Git Product logo

aideck-gap8-bootloader's Introduction

GAP8 second stage bootloader and updater

About

This bootloader has two main functions:

  • Updating the user application on the GAP8
  • Booting the user application on the GAP8

The bootloader is considered safe in the sense that it will always start up and then either update or update and start the user application. Even if an update fails and the user application is corrupt, the bootloader will start up.

The bootloader gives full access to the flash (except for the part where the bootloader is located), which means it's possible to update both application and partition tables. Basically you're "remote" flashing the same image you would flash via JTAG after building.

Building

Because of bugs in the GAP8 SDK you will need to use our docker container for building the bootloader. Building and flashing is done with the following command:

docker pull bitcraze/aideck:4.8.0.1
docker run --rm -it -v $PWD:/module/ --device /dev/ttyUSB0 --privileged -P bitcraze/aideck:4.8.0.1 /bin/bash -c 'export GAPY_OPENOCD_CABLE=interface/ftdi/olimex-arm-usb-tiny-h.cfg; source /gap_sdk/configs/ai_deck.sh; cd /module/;  make clean all image flash'

It is also possible to build the binary using the toolbelt

tb build

Design details

Memory and flash structure

The GAP8 does not execute from flash, instead it will load executable code and data from flash into RAM at startup. For this reason the bootloader is linked to be placed high up in the L1/L2 to not collide with the user application. This does however effect the amount of L1/L2 the user application can use that contains pre-defined data (i.e placing the heap here is fine).

Firmware binary structure

The firmware image produced from the GAP8 toolchain (the one ending in .img) contains information about what segments should be loaded into RAM and where to start executing it.

Communication

The bootloader uses CPX for communication where the following commands are available:

  • Version of the bootloader
  • Read from HyperFlash
  • Write to HyperFlash
  • Calculate MD5 checksum of area in flash
  • Jump to an application address and start executing

Utilities

bootload.py

This script can be used to bootload the GAP8 via WiFi. Note, for this to work you need the AI-deck to already be connected to the WiFi.

$ python3 bootload.py -h
usage: bootload.py [-h] [-n ip] [-p port] image

Bootload the GAP8 on the AI-deck

positional arguments:
  image       firmware image to flash

optional arguments:
  -h, --help  show this help message and exit
  -n ip       AI-deck IP
  -p port     AI-deck port

check-app-image.py

Because of the risk of overwriting the running bootloader in RAM when loading the user application, this utility can be used to analyze the user firmware image. It checks the memory areas in the firmware image that will be loaded to RAM before jumping to the application to see if these will overlap with the bootloader. If it overlaps the script will return a non-zero result.

$ python3 check-app-image.py -h
usage: check-app-image.py [-h] image

Show GAP8 firmware image header information

positional arguments:
  image       firmware image to analyze

optional arguments:
  -h, --help  show this help message and exit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.