Skip to content

Commit

Permalink
bricks/stm32: make .fw_info section optional
Browse files Browse the repository at this point in the history
This renames the .boot section to .fw_info and makes it optional. This
frees up 320 bytes on Move hub.

Also fill in some missing values while we are touching this in case LEGO
ever updates their firmware to read them.
  • Loading branch information
dlech committed Nov 8, 2021
1 parent a1a0637 commit 2b0d98d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions bricks/essentialhub/essential_hub.ld
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
}

"FW_INFO_OFFSET" = 0x200;
_minimum_stack_size = 8K;
7 changes: 4 additions & 3 deletions bricks/stm32/common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ SECTIONS
_fw_isr_vector_src = .; /* The isr vector table must be copied to SRAM since the
firmware doesn't start at the beginning of the flash memory */
KEEP(*(.isr_vector)) /* isr vector table */
. = 0x200;
*(.boot) /* .boot section for info read during firmware update */
KEEP(*(.boot))
. = DEFINED(FW_INFO_OFFSET) ? FW_INFO_OFFSET : .;
*(.fw_info) /* .fw_info section for info read during SPIKE firmware update */
KEEP(*(.fw_info))
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
Expand Down Expand Up @@ -93,6 +93,7 @@ SECTIONS
.checksum :
{
. = ALIGN(4);
_checksum = .;
LONG(CHECKSUM)
} >FLASH

Expand Down
16 changes: 11 additions & 5 deletions lib/pbio/platform/essential_hub/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "pbio/uartdev.h"
#include "pbio/light_matrix.h"
#include "pbio/version.h"

#include "../../drv/adc/adc_stm32_hal.h"
#include "../../drv/bluetooth/bluetooth_btstack_control_gpio.h"
Expand All @@ -27,18 +28,23 @@
typedef struct {
const char *fw_ver;
const uint32_t *checksum;
const uint8_t *reserved;
const void *reserved;
const char *id_string;
} boot_t;
const void *reserved2;
} lego_fw_info_t;

const boot_t __attribute__((section(".boot"))) boot = {
// defined in linker script
extern const uint32_t _checksum;

const lego_fw_info_t __attribute__((section(".fw_info"))) fw_info = {
// These values are not used.
.fw_ver = NULL,
.checksum = NULL,
.fw_ver = PBIO_VERSION_STR,
.checksum = &_checksum,
.reserved = NULL,
// This value is checked when installing the firmware
// via the 'firmware' MicroPython module on the hub.
.id_string = "LEGO Technic Small Hub(0x000D)",
.reserved2 = NULL,
};

enum {
Expand Down

0 comments on commit 2b0d98d

Please sign in to comment.