Browse Source

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.
pull/4507/head
Damien George 6 years ago
parent
commit
3d0c31e60e
  1. 2
      ports/stm32/mboot/fsload.c
  2. 5
      ports/stm32/mboot/main.c
  3. 3
      ports/stm32/mboot/mboot.h
  4. 11
      ports/stm32/mboot/stm32_generic.ld

2
ports/stm32/mboot/fsload.c

@ -42,7 +42,7 @@ typedef struct _gz_stream_t {
uint8_t dict[DICT_SIZE];
} gz_stream_t;
static gz_stream_t gz_stream;
static gz_stream_t gz_stream SECTION_NOZERO_BSS;
static int gz_stream_read_src(TINF_DATA *tinf) {
UINT n;

5
ports/stm32/mboot/main.c

@ -754,7 +754,7 @@ typedef struct _dfu_state_t {
uint8_t buf[DFU_XFER_SIZE] __attribute__((aligned(4)));
} dfu_state_t;
static dfu_state_t dfu_state;
static dfu_state_t dfu_state SECTION_NOZERO_BSS;
static void dfu_init(void) {
dfu_state.status = DFU_STATUS_IDLE;
@ -1070,7 +1070,7 @@ static const USBD_ClassTypeDef pyb_usbdd_class = {
pyb_usbdd_GetDeviceQualifierDescriptor,
};
static pyb_usbdd_obj_t pyb_usbdd;
static pyb_usbdd_obj_t pyb_usbdd SECTION_NOZERO_BSS;
static int pyb_usbdd_detect_port(void) {
#if MBOOT_USB_AUTODETECT_PORT
@ -1096,6 +1096,7 @@ static int pyb_usbdd_detect_port(void) {
static void pyb_usbdd_init(pyb_usbdd_obj_t *self, int phy_id) {
self->started = false;
self->tx_pending = false;
USBD_HandleTypeDef *usbd = &self->hUSBDDevice;
usbd->id = phy_id;
usbd->dev_state = USBD_STATE_DEFAULT;

3
ports/stm32/mboot/mboot.h

@ -27,6 +27,9 @@
#include <stdint.h>
#include <stddef.h>
// Use this to tag global static data in RAM that doesn't need to be zeroed on startup
#define SECTION_NOZERO_BSS __attribute__((section(".nozero_bss")))
#define ELEM_DATA_START (&_estack)
#define ELEM_DATA_MAX (ELEM_DATA_START + 1024)

11
ports/stm32/mboot/stm32_generic.ld

@ -53,18 +53,25 @@ SECTIONS
_edata = .;
} >RAM AT> FLASH_BL
/* Uninitialized data section */
/* Zeroed-out data section */
.bss :
{
. = ALIGN(4);
_sbss = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
} >RAM
/* Uninitialized data section */
.nozero_bss (NOLOAD) :
{
. = ALIGN(4);
*(.nozero_bss*)
. = ALIGN(4);
} >RAM
/* this just checks there is enough RAM for the stack */
.stack :
{

Loading…
Cancel
Save