10000 stm32/mboot: Move some BSS vars to new section that isn't zeroed out. · lolsborn/micropython@3d0c31e · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d0c31e

Browse files
committed
stm32/mboot: Move some BSS vars to new section that isn't zeroed out.
Zeroing out data on startup takes time and is not necessary for certain variables. So provide a declaration for such variables and use it.
1 parent ff04b78 commit 3d0c31e

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

ports/stm32/mboot/fsload.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef struct _gz_stream_t {
4242
uint8_t dict[DICT_SIZE];
4343
} gz_stream_t;
4444

45-
static gz_stream_t gz_stream;
45+
static gz_stream_t gz_stream SECTION_NOZERO_BSS;
4646

4747
static int gz_stream_read_src(TINF_DATA *tinf) {
4848
UINT n;

ports/stm32/mboot/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ typedef struct _dfu_state_t {
754754
uint8_t buf[DFU_XFER_SIZE] __attribute__((aligned(4)));
755755
} dfu_state_t;
756756

757-
static dfu_state_t dfu_state;
757+
static dfu_state_t dfu_state SECTION_NOZERO_BSS;
758758

759759
static void dfu_init(void) {
760760
dfu_state.status = DFU_STATUS_IDLE;
@@ -1070,7 +1070,7 @@ static const USBD_ClassTypeDef pyb_usbdd_class = {
10701070
pyb_usbdd_GetDeviceQualifierDescriptor,
10711071
};
10721072

1073-
static pyb_usbdd_obj_t pyb_usbdd;
1073+
static pyb_usbdd_obj_t pyb_usbdd SECTION_NOZERO_BSS;
10741074

10751075
static int pyb_usbdd_detect_port(void) {
10761076
#if MBOOT_USB_AUTODETECT_PORT
@@ -1096,6 +1096,7 @@ static int pyb_usbdd_detect_port(void) {
10961096

10971097
static void pyb_usbdd_init(pyb_usbdd_obj_t *self, int phy_id) {
10981098
self->started = false;
1099+
self->tx_pending = false;
10991100
USBD_HandleTypeDef *usbd = &self->hUSBDDevice;
11001101
usbd->id = phy_id;
11011102
usbd->dev_state = USBD_STATE_DEFAULT;

ports/stm32/mboot/mboot.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include <stdint.h>
2828
#include <stddef.h>
2929

30+
// Use this to tag global static data in RAM that doesn't need to be zeroed on startup
31+
#define SECTION_NOZERO_BSS __attribute__((section(".nozero_bss")))
32+
3033
#define ELEM_DATA_START (&_estack)
3134
#define ELEM_DATA_MAX (ELEM_DATA_START + 1024)
3235

ports/stm32/mboot/stm32_generic.ld

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,25 @@ SECTIONS
5353
_edata = .;
5454
} >RAM AT> FLASH_BL
5555

56-
/* Uninitialized data section */
56+
/* Zeroed-out data section */
5757
.bss :
5858
{
5959
. = ALIGN(4);
6060
_sbss = .;
6161
*(.bss*)
6262
*(COMMON)
63-
6463
. = ALIGN(4);
6564
_ebss = .;
6665
} >RAM
6766

67+
/* Uninitialized data section */
68+
.nozero_bss (NOLOAD) :
69+
{
70+
. = ALIGN(4);
71+
*(.nozero_bss*)
72+
. = ALIGN(4);
73+
} >RAM
74+
6875
/* this just checks there is enough RAM for the stack */
6976
.stack :
7077
{

0 commit comments

Comments
 (0)
0