From 0d114c00b6889318fbc0b56e29eb1691f92e2542 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 10 Jan 2025 16:29:57 +0100 Subject: [PATCH] doc improvements --- bootloader/README.md | 17 ++++++++++------- bootloader/src/main.rs | 2 ++ flashloader/README.md | 9 +++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bootloader/README.md b/bootloader/README.md index 1948015..3e2918f 100644 --- a/bootloader/README.md +++ b/bootloader/README.md @@ -36,13 +36,16 @@ The bootloader performs the following steps: 1. The application will calculate the checksum of itself if the bootloader CRC is blank (all zeroes or all ones). If the CRC is not blank and the checksum check fails, it will immediately boot application image A. Otherwise, it proceeds to the next step. -2. Check the checksum of App A. If that checksum is valid, it will boot App A. If not, it will - proceed to the next step. -3. Check the checksum of App B. If that checksum is valid, it will boot App B. If not, it will - boot App A as the fallback image. - -You could adapt and combine this bootloader with a non-volatile memory to select a prefered app -image, which would be a first step towards an updatable flight software. +2. Read the boot slot from a reserved section at the end of the EEPROM. It is assumed that the full + 128 kB are copied from the ST EEPROM to the code RAM at startup. The boot slot is read from + the code RAM directly. +3. Check the checksum of the boot slot. If that checksum is valid, it will boot that slot. If not, + it will proceed to the next step. +4. Check the checksum of the other slot . If that checksum is valid, it will boot that slot. If + not, it will boot App A as the fallback image. + +In your actual production application, a command to update the preferred boot slot could be exposed +to allow performing software updates in a safe way. Please note that you *MUST* compile the application at slot A and slot B with an appropriate `memory.x` file where the base address of the `FLASH` was adapted according to the base address diff --git a/bootloader/src/main.rs b/bootloader/src/main.rs index fadb2bb..4df8675 100644 --- a/bootloader/src/main.rs +++ b/bootloader/src/main.rs @@ -158,6 +158,8 @@ fn main() -> ! { // Check bootloader's CRC (and write it if blank) check_own_crc(&dp.sysconfig, &cp, &mut nvm, &mut timer); + // This is technically read from the EEPROM. We assume that the full 128 kB were copied + // from the EEPROM to the code RAM and read the boot slot from the code ram directly. let preferred_app = AppSel::try_from(unsafe { (PREFERRED_SLOT_OFFSET as *const u8) .read_unaligned() diff --git a/flashloader/README.md b/flashloader/README.md index 86a8d00..242b9f9 100644 --- a/flashloader/README.md +++ b/flashloader/README.md @@ -59,6 +59,15 @@ to write it to slot A. You can use +```sh +./image-loader.py -s a +``` + +to select the Slot A as a boot slot. The boot slot is stored in a reserved section in EEPROM +and will be read and used by the bootloader to determine which slot to boot. + +You can use + ```sh ./image-loader.py -c -t a ```