Apologies if this question has been answered already, I have a custom board that is being built and i would like to prepare a custom micropython fimware for it. Is there any documentation or guidance available on how to do this?

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:

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.