Skip to content

Commit f57b260

Browse files
committed
bootloaders / BLAPI: Bug in address map
It turns out that there was a bug in both the bootloader and the app linker scripts, which allowed the app image to extend to the bootloader settings page, and hence erase the settings when programmed. This would only have been felt if the app firmware actually used this page, which until now hasn't happened. While this could be considered a BLAPI change, I'm considering it an implementation bug and not updating the BLAPI version number. After this fix, both the app linker script and bootloaders now enforce that the app doesn't extend into the last page.
1 parent 597ee0d commit f57b260

File tree

8 files changed

+14
-10
lines changed

8 files changed

+14
-10
lines changed

firmware/blapi/app_IOIO0020.gld

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MEMORY
1515
{
1616
data (a!xr) : ORIGIN = 0x800, LENGTH = 0x17800
1717
app_ivt : ORIGIN = 0x5000, LENGTH = 0x110
18-
program (xr) : ORIGIN = 0x5110, LENGTH = 0x255F0
18+
program (xr) : ORIGIN = 0x5110, LENGTH = 0x252F0
1919
}
2020

2121
INCLUDE ../blapi/app_BLAPI_3.gld

firmware/blapi/app_IOIO0021.gld

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MEMORY
1515
{
1616
data (a!xr) : ORIGIN = 0x800, LENGTH = 0x6000
1717
app_ivt : ORIGIN = 0x5000, LENGTH = 0x110
18-
program (xr) : ORIGIN = 0x5110, LENGTH = 0x101F0
18+
program (xr) : ORIGIN = 0x5110, LENGTH = 0xFEF0
1919
}
2020

2121
INCLUDE ../blapi/app_BLAPI_3.gld

firmware/blapi/app_IOIO0022.gld

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MEMORY
1515
{
1616
data (a!xr) : ORIGIN = 0x800, LENGTH = 0x17800
1717
app_ivt : ORIGIN = 0x5000, LENGTH = 0x110
18-
program (xr) : ORIGIN = 0x5110, LENGTH = 0x101F0
18+
program (xr) : ORIGIN = 0x5110, LENGTH = 0xFEF0
1919
}
2020

2121
INCLUDE ../blapi/app_BLAPI_3.gld

firmware/blapi/app_IOIO0023.gld

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MEMORY
1515
{
1616
data (a!xr) : ORIGIN = 0x800, LENGTH = 0x17800
1717
app_ivt : ORIGIN = 0x5000, LENGTH = 0x110
18-
program (xr) : ORIGIN = 0x5110, LENGTH = 0x255F0
18+
program (xr) : ORIGIN = 0x5110, LENGTH = 0x252F0
1919
}
2020

2121
INCLUDE ../blapi/app_BLAPI_3.gld

firmware/blapi/app_IOIO0030.gld

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MEMORY
1515
{
1616
data (a!xr) : ORIGIN = 0x800, LENGTH = 0x17800
1717
app_ivt : ORIGIN = 0x5000, LENGTH = 0x110
18-
program (xr) : ORIGIN = 0x5110, LENGTH = 0x255F0
18+
program (xr) : ORIGIN = 0x5110, LENGTH = 0x252F0
1919
}
2020

2121
INCLUDE ../blapi/app_BLAPI_3.gld

firmware/bootloader/version.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ struct {
3333
const char hardware[8];
3434
const char bootloader[8];
3535
} _version __attribute__((section("version.sec"), space(psv)))
36-
= { HW_IMPL_VER, "IOIO0311" };
36+
= { HW_IMPL_VER, "IOIO0312" };

firmware/bootloader_common/bootloader_defs.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@
4242

4343
#define FORCEROM __attribute__((space(auto_psv)))
4444

45+
#define PAGE_SIZE 0x400
46+
#define PAGE_START(address) ((address) & ~(PAGE_SIZE - 1))
47+
4548
#define BOOTLOADER_MIN_APP_ADDRESS 0x5000
46-
#define BOOTLOADER_MAX_APP_ADDRESS (APP_PROGSPACE_END - 0x100) // last page reseved for fingerprint
47-
#define BOOTLOADER_FINGERPRINT_ADDRESS BOOTLOADER_MAX_APP_ADDRESS
49+
// last page reseved for bootloader configuration
50+
#define BOOTLOADER_MAX_APP_ADDRESS (PAGE_START(APP_PROGSPACE_END) - PAGE_SIZE)
51+
#define BOOTLOADER_CONFIG_PAGE BOOTLOADER_MAX_APP_ADDRESS
52+
#define BOOTLOADER_FINGERPRINT_ADDRESS BOOTLOADER_CONFIG_PAGE
4853
#define BOOTLOADER_OSCTUN_ADDRESS (BOOTLOADER_FINGERPRINT_ADDRESS + 16)
49-
#define BOOTLOADER_CONFIG_PAGE (BOOTLOADER_MAX_APP_ADDRESS & 0xFFFFF400)
5054
#define BOOTLOADER_INVALID_ADDRESS ((DWORD) -1)
5155

5256
static const char manager_app_name[] = "ioio.manager";

firmware/device_bootloader/version.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ struct {
3333
const char hardware[8];
3434
const char bootloader[8];
3535
} _version __attribute__((section("version.sec"), space(psv)))
36-
= { HW_IMPL_VER, "IOIO0400" };
36+
= { HW_IMPL_VER, "IOIO0401" };

0 commit comments

Comments
 (0)