Skip to content

Commit

Permalink
pbsys/program_load: Reserve space for user data.
Browse files Browse the repository at this point in the history
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 pybricks/support#85
  • Loading branch information
laurensvalk committed Oct 20, 2022
1 parent 4637a84 commit d53739f
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/pbio/include/pbsys/program_load.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*/
Expand Down
1 change: 1 addition & 0 deletions lib/pbio/platform/city_hub/pbsysconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions lib/pbio/platform/debug/pbsysconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions lib/pbio/platform/essential_hub/pbsysconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions lib/pbio/platform/move_hub/pbsysconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions lib/pbio/platform/prime_hub/pbsysconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions lib/pbio/platform/technic_hub/pbsysconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit d53739f

Please sign in to comment.