I own some STM32H750 MCU based boards and I've found that there is no working board definition available. So I decided to write one by myself. It was not an easy task but finaly I ended having two working boards They are available here and here.
I'll describe main points for those who may want to use the definitions as a template. Perhaps someone finds it usefull.
1. MCU name
In the mpconfigboard.h I use
Code: Select all
#define MICROPY_HW_MCU_NAME "STM32H750"
Code: Select all
CMSIS_MCU = STM32H750xx
2. SPI and QSPI flash
SPI and QSPI definition sections I've compiled from PYBD_SF2 board definition and from WeActTC/MiniSTM32H7xx repository. It's necessary to have a block device configuration for both devices. File bdev.c with parts of these configurations is required.
3. Board early initialization
Because part of the firmware is placed in the extended QSPI memory, it is necessary to initialize that memory before starting Micropython. The early initialization code is run from board_init.c and an entry point for that is defined in mpconfigboard.h:
Code: Select all
#define MICROPY_BOARD_EARLY_INIT board_early_init
void board_early_init(void);
Regions, where the compiled code is placed, are defined in the linker script. At this point, I had the biggest problem. The code placed to the main chip memory must meet two basic conditions. The first is clear - it must fit 128kB area. The other is also clear but it took me two days to find it
After many attempts and failures I managed to divide the code between memories using this terrible lookig section of the linker script (in stm32h750.ld):The code in the main memory must contain at least all the code necessary to initialize the QSPI memory!
Code: Select all
/* Define the code that goes in QSPI flash */
.text_ext :
{
. = ALIGN(4);
/**drivers/*(.text* .rodata*)*/ /* necessary */
*extmod/*(.text* .rodata*)
*frozen_mpy/*(.text* .rodata*)
*lib/libm_dbl/*(.text* .rodata*)
*lib/oofatfs/*(.text* .rodata*)
/**lib/stm32lib/CMSIS/*(.text* .rodata*)*/ /* necessary */
*lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_a*(.text* .rodata*)
/**lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_c*(.text* .rodata*)*/ /* stm32h7xx_hal_cortex is necessary */
*lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_d*(.text* .rodata*)
*lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_f*(.text* .rodata*)
*lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_g*(.text* .rodata*)
*lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i*(.text* .rodata*)
*lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_m*(.text* .rodata*)
/**lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_p*(.text* .rodata*)*/ /* necessary */
/**lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_r*(.text* .rodata*)*/ /* necessary */
*lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_s*(.text* .rodata*)
*lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_t*(.text* .rodata*)
*lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_u*(.text* .rodata*)
*lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_*(.text* .rodata*)
*py/*(.text* .rodata*)
*shared/*(.text* .rodata*)
*usbdev/*(.text* .rodata*)
. = ALIGN(4);
} >FLASH_EXT
Such optimization may be necessary for other firmware configurations. I did not divide the root folder of modules (it's the whole in the main memory), so there is a lot of space for another further optimization
And now some questions
1. Can anyone suggest the right value for
Code: Select all
#define MICROPY_HW_QSPI_PRESCALER 2
2. I really don't like how the above mentioned linker script's section looks like Can someone suggest how it could be written better?
Thank you for your attention