What you need to do is to create a new board. If you look in the ports/stm32/boards directory then you'll see a bunch of boards which are currently supported. I also have a bunch I've created (or have links to) over here: https://github.com/dhylands/wiki/wiki/M ... oard-files
I normally try to find a board which uses the same processor (STM32F405 in your case) and which uses the same speed HSE crystal and use that as my starting point.
If you're using what is essentially a clone of the PYBV10 hardware then I'd start there. There are typically 4 files in the board directory.
1 - stm32f4xx_hal_conf.h this configures the HAL and is where you enable/disable the various HAL modules and set the HSE/LSE speeds.
2 - mpconfigboard.h - this configures micropython and also has some constants related to the HSE speed:
Code: Select all
// HSE is 8MHz
#define MICROPY_HW_CLK_PLLM (8)
#define MICROPY_HW_CLK_PLLN (336)
#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2)
#define MICROPY_HW_CLK_PLLQ (7)
#define MICROPY_HW_CLK_LAST_FREQ (1)
I normally copy these from a board definition that's using the same processor/crystla speed. Otherwise, you'll need to refer to the datasheet to calculate out what values to put in here.
The rest of the file configures which pins you'll be using for various peripherals.
3 - mpconfigboard.mk - sets up some things needed by the makefile. This is mostly used to set the linker script file to use (i.e. memory map)
4 - pins.csv - this file contains a mapping from board pin names to MCU pin names. Each line should have 2 fields separated by a comma. The first field is the board pin name and must be C compoatible (i.e. no spaces or dashes - use underscores). The second field in the MCU pin name (i.e. PA13). Pins like Reset, GND, 3.3V, VIN are ignored and may be included as documentation. The pins.csv file is used to generate the ports/stm32/build-BOARDNAME/pins-BOARDNAME.c file.
Pins which are referenced in mpconfigboard.h MUST appear in the pins.csv file (and also be in the AF_FILE set in mpconfigboard.mk). For you, you'd use an AF_FILE of boards/stm32f405_af.csv which should already have all of the possible pins that an STM32F405 could have.
Then when you build micropython you'll use:
where MYBOARDNAME is the name of the directory in the boards subdirectory with your board defintion files in it.
You need to specify BOARD= on every invocation of make or it will default to PYBV10. I normally setup a GNUmakefile which contains something like:
Code: Select all
$(info Executing GNUmakefile)
BOARD = MYBOARDNAME
$(info BOARD = $(BOARD))
and that will change the default from PYBV10 to MYBOARDNAME