Skip to content

Commit 5ec5d35

Browse files
Marcus ChangLiyouZhou
authored andcommitted
Optional split of jump address from start address (ARMmbed#104)
On targets like the NRF52, where the application's entry point is not at the beginning of the firmware it is necessary to distinguish between the two. This commit adds an optional jump address to handle this corner case. When the jump address is not defined the start address becomes the default jump address.
1 parent 0d2873a commit 5ec5d35

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ NOTE: All these configurations must be set the same in the mbed cloud client whe
2525
### Active Application and Header
2626

2727
1. `update-client.application-details`, Address at which the metadata header of the active firmware is written. **Must align to flash erase boundary**
28-
1. `application-start-address`, Address at which The application starts **Must align to vector table size boundary and flash write page boundary**. It is assumed the region between `update-client.application-details` and `application-start-address` contains only the header. MUST be the same as "target.mbed_app_start" in the application.
28+
1. `application-start-address`, Address at which the application starts **Must align to vector table size boundary and flash write page boundary**.
29+
1. `application-jump-address`, Optional address for the application's entry point (vector table) if this is different from `application-start-address`.
2930

3031
If the `application-start-address` is set less than one erase sector after the `update-client.application-details`, the two regions will be erased together. Otherwise the two regions will be erased separately in which case `application-start-address` must also align to **flash erase boundary**.
3132

33+
If `application-jump-address` is not set, the `application-start-address` will be used as the application's entry point. The entry point MUST be the same as "target.mbed_app_start" in the application.
34+
3235
### Firmware Candidate Storage
3336

3437
1. `MBED_CLOUD_CLIENT_UPDATE_STORAGE`, This need to be set in the "macros" section of `mbed_app.json`. Choices are ARM_UCP_FLASHIAP_BLOCKDEVICE and ARM_UCP_FLASHIAP. This determines whether the firmware is stored on a blockdevice or internal flash. If blockdevice is used `ARM_UC_USE_PAL_BLOCKDEVICE=1` must also be set.

mbed_app.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
],
1818
"config": {
1919
"application-start-address": {
20-
"help": "Address of the active application firmware in flash",
20+
"help": "Address to the beginning of the active application firmware in flash",
21+
"value": null
22+
},
23+
"application-jump-address": {
24+
"help": "Jump address for running the active application firmware",
2125
"value": null
2226
},
2327
"max-application-size": {

source/main.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ SDBlockDevice sd(MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO,
7171
BlockDevice* arm_uc_blockdevice = &sd;
7272
#endif
7373

74+
#ifndef MBED_CONF_APP_APPLICATION_START_ADDRESS
75+
#error Application start address must be defined
76+
#endif
77+
78+
/* If jump address is not set then default to start address. */
79+
#ifndef MBED_CONF_APP_APPLICATION_JUMP_ADDRESS
80+
#define MBED_CONF_APP_APPLICATION_JUMP_ADDRESS MBED_CONF_APP_APPLICATION_START_ADDRESS
81+
#endif
82+
7483
int main(void)
7584
{
7685
/* Use malloc to allocate uint64_t version number on the heap */
@@ -167,15 +176,15 @@ int main(void)
167176
firmware_update_test_end();
168177
#endif
169178
uint32_t app_start_addr = MBED_CONF_APP_APPLICATION_START_ADDRESS;
170-
uint32_t app_stack_ptr = *((uint32_t*)(app_start_addr + 0));
171-
uint32_t app_jump_addr = *((uint32_t*)(app_start_addr + 4));
179+
uint32_t app_stack_ptr = *((uint32_t*)(MBED_CONF_APP_APPLICATION_JUMP_ADDRESS + 0));
180+
uint32_t app_jump_addr = *((uint32_t*)(MBED_CONF_APP_APPLICATION_JUMP_ADDRESS + 4));
172181

173182
tr_info("Application's start address: 0x%" PRIX32, app_start_addr);
174183
tr_info("Application's jump address: 0x%" PRIX32, app_jump_addr);
175184
tr_info("Application's stack address: 0x%" PRIX32, app_stack_ptr);
176185
tr_info("Forwarding to application...\r\n");
177186

178-
mbed_start_application(app_start_addr);
187+
mbed_start_application(MBED_CONF_APP_APPLICATION_JUMP_ADDRESS);
179188
}
180189

181190
/* Reset bootCounter; this allows a user to reapply a new bootloader

0 commit comments

Comments
 (0)