From d53739f0a3898f72a67f5f88c565403b93c94163 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Thu, 20 Oct 2022 13:25:41 +0200 Subject: [PATCH] pbsys/program_load: Reserve space for user data. A popular feature request is to be able to store some runtime data on the hub, such as the last-used speed of a train. This commit reserves some space for this purpose so we can avoid breaking user programs stored on (external) flash when we add a user API later. See https://github.com/pybricks/support/issues/85 --- lib/pbio/include/pbsys/program_load.h | 4 ++++ lib/pbio/platform/city_hub/pbsysconfig.h | 1 + lib/pbio/platform/debug/pbsysconfig.h | 1 + lib/pbio/platform/essential_hub/pbsysconfig.h | 1 + lib/pbio/platform/move_hub/pbsysconfig.h | 1 + lib/pbio/platform/prime_hub/pbsysconfig.h | 1 + lib/pbio/platform/technic_hub/pbsysconfig.h | 1 + 7 files changed, 10 insertions(+) diff --git a/lib/pbio/include/pbsys/program_load.h b/lib/pbio/include/pbsys/program_load.h index 815814ca9..7f78b2a16 100644 --- a/lib/pbio/include/pbsys/program_load.h +++ b/lib/pbio/include/pbsys/program_load.h @@ -41,6 +41,10 @@ typedef struct _pbsys_program_load_data_header_t { */ volatile uint32_t checksum_complement; #endif + /** + * End-user read-write accessible data. + */ + uint8_t user_data[PBSYS_CONFIG_PROGRAM_LOAD_USER_DATA_SIZE]; /** * Size of the application program (size of code only). */ diff --git a/lib/pbio/platform/city_hub/pbsysconfig.h b/lib/pbio/platform/city_hub/pbsysconfig.h index 2587e9095..313fefdad 100644 --- a/lib/pbio/platform/city_hub/pbsysconfig.h +++ b/lib/pbio/platform/city_hub/pbsysconfig.h @@ -11,5 +11,6 @@ #define PBSYS_CONFIG_PROGRAM_LOAD_OVERLAPS_BOOTLOADER_CHECKSUM (1) #define PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE (20 * 1024) #define PBSYS_CONFIG_PROGRAM_LOAD_ROM_SIZE (PBDRV_CONFIG_BLOCK_DEVICE_FLASH_STM32_SIZE) +#define PBSYS_CONFIG_PROGRAM_LOAD_USER_DATA_SIZE (512) #define PBSYS_CONFIG_STATUS_LIGHT (1) #define PBSYS_CONFIG_STATUS_LIGHT_BATTERY (0) diff --git a/lib/pbio/platform/debug/pbsysconfig.h b/lib/pbio/platform/debug/pbsysconfig.h index b0acee237..0b3597791 100644 --- a/lib/pbio/platform/debug/pbsysconfig.h +++ b/lib/pbio/platform/debug/pbsysconfig.h @@ -9,5 +9,6 @@ #define PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE (64 * 1024) #define PBSYS_CONFIG_PROGRAM_LOAD_ROM_SIZE (0) #define PBSYS_CONFIG_PROGRAM_LOAD_OVERLAPS_BOOTLOADER_CHECKSUM (0) +#define PBSYS_CONFIG_PROGRAM_LOAD_USER_DATA_SIZE (512) #define PBSYS_CONFIG_STATUS_LIGHT (1) #define PBSYS_CONFIG_STATUS_LIGHT_BATTERY (0) diff --git a/lib/pbio/platform/essential_hub/pbsysconfig.h b/lib/pbio/platform/essential_hub/pbsysconfig.h index c7711d15a..1bc25fd12 100644 --- a/lib/pbio/platform/essential_hub/pbsysconfig.h +++ b/lib/pbio/platform/essential_hub/pbsysconfig.h @@ -9,5 +9,6 @@ #define PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE (258 * 1024) #define PBSYS_CONFIG_PROGRAM_LOAD_ROM_SIZE (PBDRV_CONFIG_BLOCK_DEVICE_W25QXX_STM32_SIZE) #define PBSYS_CONFIG_PROGRAM_LOAD_OVERLAPS_BOOTLOADER_CHECKSUM (0) +#define PBSYS_CONFIG_PROGRAM_LOAD_USER_DATA_SIZE (512) #define PBSYS_CONFIG_STATUS_LIGHT (1) #define PBSYS_CONFIG_STATUS_LIGHT_BATTERY (1) diff --git a/lib/pbio/platform/move_hub/pbsysconfig.h b/lib/pbio/platform/move_hub/pbsysconfig.h index 0bc07f69c..e4ec51764 100644 --- a/lib/pbio/platform/move_hub/pbsysconfig.h +++ b/lib/pbio/platform/move_hub/pbsysconfig.h @@ -11,5 +11,6 @@ #define PBSYS_CONFIG_PROGRAM_LOAD_OVERLAPS_BOOTLOADER_CHECKSUM (1) #define PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE (7 * 1024) #define PBSYS_CONFIG_PROGRAM_LOAD_ROM_SIZE (PBDRV_CONFIG_BLOCK_DEVICE_FLASH_STM32_SIZE) +#define PBSYS_CONFIG_PROGRAM_LOAD_USER_DATA_SIZE (128) #define PBSYS_CONFIG_STATUS_LIGHT (1) #define PBSYS_CONFIG_STATUS_LIGHT_BATTERY (0) diff --git a/lib/pbio/platform/prime_hub/pbsysconfig.h b/lib/pbio/platform/prime_hub/pbsysconfig.h index c29611886..345aa945e 100644 --- a/lib/pbio/platform/prime_hub/pbsysconfig.h +++ b/lib/pbio/platform/prime_hub/pbsysconfig.h @@ -9,5 +9,6 @@ #define PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE (258 * 1024) #define PBSYS_CONFIG_PROGRAM_LOAD_ROM_SIZE (PBDRV_CONFIG_BLOCK_DEVICE_W25QXX_STM32_SIZE) #define PBSYS_CONFIG_PROGRAM_LOAD_OVERLAPS_BOOTLOADER_CHECKSUM (0) +#define PBSYS_CONFIG_PROGRAM_LOAD_USER_DATA_SIZE (512) #define PBSYS_CONFIG_STATUS_LIGHT (1) #define PBSYS_CONFIG_STATUS_LIGHT_BATTERY (1) diff --git a/lib/pbio/platform/technic_hub/pbsysconfig.h b/lib/pbio/platform/technic_hub/pbsysconfig.h index 7d4e95737..233aae185 100644 --- a/lib/pbio/platform/technic_hub/pbsysconfig.h +++ b/lib/pbio/platform/technic_hub/pbsysconfig.h @@ -11,5 +11,6 @@ #define PBSYS_CONFIG_PROGRAM_LOAD_OVERLAPS_BOOTLOADER_CHECKSUM (1) #define PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE (32 * 1024) #define PBSYS_CONFIG_PROGRAM_LOAD_ROM_SIZE (PBDRV_CONFIG_BLOCK_DEVICE_FLASH_STM32_SIZE) +#define PBSYS_CONFIG_PROGRAM_LOAD_USER_DATA_SIZE (512) #define PBSYS_CONFIG_STATUS_LIGHT (1) #define PBSYS_CONFIG_STATUS_LIGHT_BATTERY (0)