8000 stm32/nucleo_wb55: Fix mpremote file transfer over uart repl. by andrewleech · Pull Request #8713 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

stm32/nucleo_wb55: Fix mpremote file transfer over uart repl. #8713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ports/stm32/boards/NUCLEO_WB55/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@
// Bluetooth config
#define MICROPY_HW_BLE_UART_ID (0)
#define MICROPY_HW_BLE_UART_BAUDRATE (115200)

// Configure ram isr / functions for board.
extern void ram_isr_fn_init();
#define MICROPY_BOARD_STARTUP ram_isr_fn_init
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably only be configured if USE_RAM_ISR_UART_FLASH_FN is enabled.

Also, maybe call it board_startup. And put void in the arg list.

17 changes: 15 additions & 2 deletions ports/stm32/boards/NUCLEO_WB55/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@ CMSIS_MCU = STM32WB55xx
AF_FILE = boards/stm32wb55_af.csv
STARTUP_FILE = $(STM32LIB_CMSIS_BASE)/Source/Templates/gcc/startup_stm32wb55xx_cm4.o

LD_FILES = boards/stm32wb55xg.ld

LD_COMMON_STEM = boards/common

# When enabled, some IRQ (uart/systick) and Flash (erase) functions are moved to ram
# to allow uart rx to run during flash operations, reducing the likelihood of dropped data.
# For more details see #8386
USE_RAM_ISR_UART_FLASH_FN ?= 1

ifeq ($(USE_RAM_ISR_UART_FLASH_FN),1)
LD_COMMON_STEM = boards/NUCLEO_WB55/ram_isr_fn
endif

ifeq ($(USE_MBOOT),1)
# When using Mboot all the text goes together after the bootloader
LD_FILES = boards/stm32wb55xg.ld boards/common_bl.ld
LD_FILES += $(LD_COMMON_STEM)_bl.ld
TEXT0_ADDR = 0x08004000
else
# When not using Mboot the text goes at the start of flash
LD_FILES = boards/stm32wb55xg.ld boards/common_basic.ld
LD_FILES += $(LD_COMMON_STEM)_basic.ld
TEXT0_ADDR = 0x08000000
endif

Expand Down
15 changes: 15 additions & 0 deletions ports/stm32/boards/NUCLEO_WB55/ram_irq.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <string.h>
#include <py/mphal.h>

// This is the default MICROPY_BOARD_STARTUP on stm32
extern void powerctrl_check_enter_bootloader();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to include powerctrl.h to get this declaration.


void ram_isr_fn_init() {

// Copy IRQ vector table and other RAM functions to RAM and point VTOR there
extern uint32_t _start_init_isr, _start_isr, _end_isr;
memcpy(&_start_isr, &_start_init_isr, (&_end_isr - &_start_isr) * sizeof(uint32_t));
SCB->VTOR = (uint32_t)&_start_isr;

powerctrl_check_enter_bootloader();
}
61 changes: 61 additions & 0 deletions ports/stm32/boards/NUCLEO_WB55/ram_isr_fn_basic.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* Memory layout for basic configuration with isr ram functions:

FLASH .isr_vector
FLASH .text
FLASH .data

RAM .data
RAM .bss
RAM .heap
RAM .stack
*/

ENTRY(Reset_Handler)

/* define output sections */
SECTIONS
{
/* The startup code here is run from RAM */
.isr_vector :
{
. = ALIGN(4);
_start_isr = .;
KEEP(*(.isr_vector)) /* Startup code */

/* These functions need to run from ram.
Defining them here ensures they're copied from
flash (in ram_irq.c) along with the isr_vector above.
*/
. = ALIGN(4);
*(.text.pendsv_kbd_intr)
*(.text.pendsv_schedule_dispatch)
*(.text.UART*_IRQHandler)
*(.text.USART*_IRQHandler)
*(.text.storage_systick_callback)
*(.text.SysTick_Handler)
*(.text.uart_irq_handler)
*(.text.HAL_GetTick)
*(.text.FLASH_PageErase)
*(.text.FLASH_WaitForLastOperation)
*(.text.HAL_FLASHEx_Erase)
_end_isr = .;
. = ALIGN(4);
} >RAM AT >FLASH
_start_init_isr = LOADADDR(.isr_vector); /* Used by the start-up code to initialise data */

/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text*) /* .text* sections (code) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
/* *(.glue_7) */ /* glue arm to thumb code */
/* *(.glue_7t) */ /* glue thumb to arm code */

. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
} >FLASH

INCLUDE common_extratext_data_in_flash.ld
INCLUDE common_bss_heap_stack.ld
}
61 changes: 61 additions & 0 deletions ports/stm32/boards/NUCLEO_WB55/ram_isr_fn_bl.ld
< 4525 td class="blob-num blob-num-addition empty-cell">
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* Memory layout for bootloader configuration with isr ram functions:

FLASH_APP .isr_vector
FLASH_APP .text
FLASH_APP .data

RAM .data
RAM .bss
RAM .heap
RAM .stack
*/

ENTRY(Reset_Handler)

/* define output sections */
SECTIONS
{
/* The startup code here is run from RAM */
.isr_vector :
{
. = ALIGN(4);
_start_isr = .;
KEEP(*(.isr_vector)) /* Startup code */

/* These functions need to run from ram.
Defining them here ensures they're copied from
flash (in ram_irq.c) along with the isr_vector above.
*/
. = ALIGN(4);
*(.text.pendsv_kbd_intr)
*(.text.pendsv_schedule_dispatch)
*(.text.UART*_IRQHandler)
*(.text.USART*_IRQHandler)
*(.text.storage_systick_callback)
*(.text.SysTick_Handler)
*(.text.uart_irq_handler)
*(.text.HAL_GetTick)
*(.text.FLASH_PageErase)
*(.text.FLASH_WaitForLastOperation)
*(.text.HAL_FLASHEx_Erase)
_end_isr = .;
. = ALIGN(4);
} >RAM AT >FLASH_APP
_start_init_isr = LOADADDR(.isr_vector); /* Used by the start-up code to initialise data */

/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text*) /* .text* sections (code) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
/* *(.glue_7) */ /* glue arm to thumb code */
/* *(.glue_7t) */ /* glue thumb to arm code */

. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
} >FLASH_APP

INCLUDE common_extratext_data_in_flash_app.ld
INCLUDE common_bss_heap_stack.ld
}
0