Skip to content

Commit 174e4c5

Browse files
committed
some fixes and testing
1 parent a07d27e commit 174e4c5

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

bootloader/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ The bootloader uses the following memory map:
99

1010
| Address | Notes | Size |
1111
| ------ | ---- | ---- |
12-
| 0x0 | Bootloader start | code up to 0x3FFC bytes |
13-
| 0x2FFE | Bootloader CRC | word |
14-
| 0x3000 | App image A start | code up to 0xE7F8 (~58K) bytes |
12+
| 0x0 | Bootloader start | code up to 0x2FFE bytes |
13+
| 0x2FFE | Bootloader CRC | half-word |
14+
| 0x3000 | App image A start | code up to 0xE7F4 (~59K) bytes |
1515
| 0x117F8 | App image A CRC check length | word |
1616
| 0x117FC | App image A CRC check value | word |
17-
| 0x11800 | App image B start | code up to 0xE7F8 (~58K) bytes |
18-
| 0x1FFF8 | App image B CRC check length | word |
19-
| 0x1FFFC | App image B CRC check value | word |
17+
| 0x117FC | App image B start | code up to 0xE7F4 (~59K) bytes |
18+
| 0x1FFF0 | App image B CRC check length | word |
19+
| 0x1FFF4 | App image B CRC check value | word |
20+
| 0x1FFF8 | Reserved section, contains boot select parameter | 8 bytes |
2021
| 0x20000 | End of NVM | end |
2122

2223
## Additional Information

bootloader/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ const APP_B_SIZE_ADDR: u32 = APP_B_END_ADDR - 8;
6060
// Four bytes reserved, even when only 2 byte CRC is used. Leaves flexibility to switch to CRC32.
6161
// 0x1FFFC
6262
const APP_B_CRC_ADDR: u32 = APP_B_END_ADDR - 4;
63-
// 0x20000. 4 bytes at end of EEPROM reserved for preferred image parameter.
64-
pub const APP_B_END_ADDR: u32 = NVM_SIZE - 4;
63+
// 0x20000. 8 bytes at end of EEPROM reserved for preferred image parameter. This reserved
64+
// size should be a multiple of 8 due to alignment requirements.
65+
pub const APP_B_END_ADDR: u32 = NVM_SIZE - 8;
6566
pub const APP_IMG_SZ: u32 = (APP_B_END_ADDR - APP_A_START_ADDR) / 2;
6667

6768
static_assertions::const_assert!((APP_B_END_ADDR - BOOTLOADER_END_ADDR) % 2 == 0);

flashloader/image-loader.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,21 @@
3030
BOOTLOADER_MAX_SIZE = BOOTLOADER_END_ADDR - BOOTLOADER_START_ADDR - 2
3131

3232
APP_A_START_ADDR = 0x3000
33-
APP_A_END_ADDR = 0x11800
33+
APP_B_END_ADDR = 0x20000 - 8
34+
IMG_SLOT_SIZE = (APP_B_END_ADDR - APP_A_START_ADDR) // 2
35+
36+
APP_A_END_ADDR = APP_A_START_ADDR + IMG_SLOT_SIZE
3437
# The actual size of the image which is relevant for CRC calculation.
3538
APP_A_SIZE_ADDR = APP_A_END_ADDR - 8
3639
APP_A_CRC_ADDR = APP_A_END_ADDR - 4
3740
APP_A_MAX_SIZE = APP_A_END_ADDR - APP_A_START_ADDR - 8
3841

3942
APP_B_START_ADDR = APP_A_END_ADDR
40-
APP_B_END_ADDR = 0x20000
4143
# The actual size of the image which is relevant for CRC calculation.
4244
APP_B_SIZE_ADDR = APP_B_END_ADDR - 8
4345
APP_B_CRC_ADDR = APP_B_END_ADDR - 4
4446
APP_B_MAX_SIZE = APP_A_END_ADDR - APP_A_START_ADDR - 8
4547

46-
APP_IMG_SZ = (APP_B_END_ADDR - APP_A_START_ADDR) // 2
4748

4849
CHUNK_SIZE = 400
4950

@@ -347,9 +348,9 @@ def main() -> int:
347348
return -1
348349
image_loader.handle_corruption_cmd(target)
349350
else:
350-
assert file_path is not None
351-
assert target is not None
352-
result = image_loader.handle_flash_cmd(target, file_path)
351+
if file_path is not None:
352+
assert target is not None
353+
result = image_loader.handle_flash_cmd(target, file_path)
353354

354355
com_if.close()
355356
return result

flashloader/slot-b-blinky/memory.x

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/* Special linker script for application slot B with an offset at address 0x11800 */
1+
/* Special linker script for application slot B with an offset at address 0x117FE */
22
MEMORY
33
{
4-
FLASH : ORIGIN = 0x00011800, LENGTH = 0xE800
4+
FLASH : ORIGIN = 0x000117FC, LENGTH = 0xE800
55
RAM : ORIGIN = 0x10000000, LENGTH = 0x08000 /* 32K */
66
}
77

flashloader/src/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub struct DataConsumer<const BUF_SIZE: usize, const SIZES_LEN: usize> {
6767
}
6868

6969
pub const APP_A_START_ADDR: u32 = 0x3000;
70-
pub const APP_A_END_ADDR: u32 = 0x11800;
70+
pub const APP_A_END_ADDR: u32 = 0x117FC;
7171
pub const APP_B_START_ADDR: u32 = APP_A_END_ADDR;
7272
pub const APP_B_END_ADDR: u32 = 0x20000;
7373

@@ -361,13 +361,21 @@ mod app {
361361
if pus_tc.app_data().is_empty() {
362362
log::warn!(target: "TC Handler", "App data for preferred image command too short");
363363
}
364-
if AppSel::try_from(pus_tc.app_data()[0]).is_err() {
364+
let app_sel_result = AppSel::try_from(pus_tc.app_data()[0]);
365+
if app_sel_result.is_err() {
365366
log::warn!("Invalid app selection value: {}", pus_tc.app_data()[0]);
366367
}
368+
log::info!(target: "TC Handler", "received boot selection command with app select: {:?}", app_sel_result.unwrap());
367369
cx.local
368370
.nvm
369371
.write(PREFERRED_SLOT_OFFSET as usize, &[pus_tc.app_data()[0]])
370372
.expect("writing to NVM failed");
373+
let tm = cx
374+
.local
375+
.verif_reporter
376+
.completion_success(cx.local.src_data_buf, started_token, 0, 0, &[])
377+
.expect("completion success failed");
378+
write_and_send(&tm);
371379
}
372380
}
373381
if pus_tc.service() == PusServiceId::Test as u8 && pus_tc.subservice() == 1 {

0 commit comments

Comments
 (0)