bootloader tweak
This commit is contained in:
parent
88ee85a4cd
commit
1412e1b7d1
@ -36,9 +36,8 @@ The bootloader performs the following steps:
|
|||||||
1. The application will calculate the checksum of itself if the bootloader CRC is blank (all zeroes
|
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
|
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.
|
application image A. Otherwise, it proceeds to the next step.
|
||||||
2. Read the boot slot from a reserved section at the end of the EEPROM. It is assumed that the full
|
2. Read the boot slot from a reserved section at the end of the EEPROM. If no valid value is read,
|
||||||
128 kB are copied from the ST EEPROM to the code RAM at startup. The boot slot is read from
|
select boot slot A.
|
||||||
the code RAM directly.
|
|
||||||
3. Check the checksum of the boot slot. If that checksum is valid, it will boot that slot. If not,
|
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.
|
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
|
4. Check the checksum of the other slot . If that checksum is valid, it will boot that slot. If
|
||||||
|
@ -158,14 +158,10 @@ fn main() -> ! {
|
|||||||
// Check bootloader's CRC (and write it if blank)
|
// Check bootloader's CRC (and write it if blank)
|
||||||
check_own_crc(&dp.sysconfig, &cp, &mut nvm, &mut timer);
|
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
|
let mut preferred_app_raw = [0; 1];
|
||||||
// from the EEPROM to the code RAM and read the boot slot from the code ram directly.
|
nvm.read(PREFERRED_SLOT_OFFSET as usize, &mut preferred_app_raw)
|
||||||
let preferred_app = AppSel::try_from(unsafe {
|
.expect("reading preferred slot failed");
|
||||||
(PREFERRED_SLOT_OFFSET as *const u8)
|
let preferred_app = AppSel::try_from(preferred_app_raw[0]).unwrap_or(AppSel::A);
|
||||||
.read_unaligned()
|
|
||||||
.to_be()
|
|
||||||
})
|
|
||||||
.unwrap_or(AppSel::A);
|
|
||||||
let other_app = if preferred_app == AppSel::A {
|
let other_app = if preferred_app == AppSel::A {
|
||||||
AppSel::B
|
AppSel::B
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user