Skip to content

Commit a127d01

Browse files
committed
Detail shared data builds for K64F with customized linker scripts
1 parent 997d9cf commit a127d01

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ Several configuration changes must be made in both the bootloader and applicatio
394394
- `mcuboot.share-data-size` is set to the number of bytes you want to reserve in RAM for the shared data
395395
- You must add the following entries to your `target.macros_add` configuration: `MBED_RAM_START=<address>` and `MBED_RAM_SIZE=<RAM size minus reserved region size>`.
396396

397+
**Note**: Some targets, like the K64F, do not support the macros `MBED_RAM_START` and `MBED_RAM_SIZE`. In this case, you will need to use a custom linker script. See [the README.md in the `linker` directory](https://github.com/AGlass0fMilk/mbed-mcuboot-demo/tree/master/linker).
398+
397399
`MBED_RAM_START` should be the starting address of RAM as per your MCU's datasheet. `MBED_RAM_SIZE` should be the total size of your MCU's RAM minus the number of bytes you are reserving for shared data. Note that the required reserved RAM depends on how many entries you want to share with the application.
398400

399401
As mentioned in the MCUboot documentation, the data share region has a global header that is 4 bytes. Each TLV entry has a header size of 4 bytes, plus the number of bytes required to store the data you are sharing.
@@ -413,8 +415,11 @@ Let's say you want to reserve 512 bytes of RAM for data sharing, your MCU has a
413415
Calculations to get the above:
414416

415417
`mcuboot.share-data-size = reserved_bytes = 512`
418+
416419
`MBED_RAM_START = 0x20000000`
420+
417421
`mcuboot.share-data-base-address = MBED_RAM_START + total_RAM - reserved_bytes = 0x20000000 + 64kB - 512 = 0x20000000 + 0x10000 - 0x200 = 0x2000FE00`
422+
418423
`MBED_RAM_SIZE = total_RAM - reserved_bytes = 0x10000 - 0x200 = 0xFE00`
419424

420425
Note that you will have to add this configuration to both your bootloader and application builds. Setting `MBED_RAM_SIZE` prevents initialization code from clearing the reserved RAM region at startup, which would corrupt the shared data.

linker/README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Customized Linker Scripts
22

3-
The mainstream version of some targets' linker scripts do not allow the kind of configuration needed to supported sharing data (ie: reserving RAM regions). To accomodate this, this directory contains customized linker scripts for supported targets.
3+
The mainstream version of some targets' linker scripts do not allow the kind of configuration needed to supported sharing data (ie: reserving RAM regions using `MBED_RAM_SIZE` and `MBED_RAM_START`). To accomodate this, this directory contains customized linker scripts for supported targets.
44

55
**Please note:** Only the GCC ARM toolchain is supported by the customized linker scripts. You can use these customized scripts as a starting point if you are using a different toolchain.
66

@@ -14,4 +14,10 @@ This tells Mbed CLI 1 to use the given linker script specified by `<path-to-link
1414

1515
## K64F
1616

17-
The mainstream K64F linker script does not use the `MBED_RAM_START` and `MBED_RAM_SIZE` symbols. This customized linker script reserves a section of RAM at the beginning of SRAM_U (0x2000 0000)
17+
The mainstream K64F linker script does not use the `MBED_RAM_START` and `MBED_RAM_SIZE` symbols. This customized linker script reserves a section of RAM at the end of SRAM_U (0x2003 0000). The start of the reserved region depends on the size of the shared data region (128 bytes by default):
18+
19+
`start_of_shared_region = end_of_SRAM_U - size_of_shared_region = 0x20030000 - 0x80 = 0x2002FF80`
20+
21+
To build this demo with data sharing for the K64F target, use the following command:
22+
23+
`mbed compile -t GCC_ARM -m K64F --app-config mbed_app_data_sharing.json -l ./linker/TARGET_K64F/TOOLCHAIN_GCC_ARM/MK64FN1M0xxx12.ld`

0 commit comments

Comments
 (0)