[STM32H743VI] Building firmware for STM32H743VIT6

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
dukeduck
Posts: 22
Joined: Thu Aug 29, 2019 2:06 pm

[STM32H743VI] Building firmware for STM32H743VIT6

Post by dukeduck » Thu Dec 31, 2020 3:34 pm

Hi,

I have got an STM32H743VIT6 dev board which I'm trying to build firmware for.

I copied the configurations of NUCLEO_H743ZI and started from there. However, there are still some questions I haven't got the answers after hours of searching regarding the config of mpconfigboard.h... So I turn to the forum for help.
  • CPU & USB clock settings
The board has an 8MHz HSE, and the CPU clock is 480MHz. I set it up as following:

Code: Select all

// The board has an 8MHz HSE, the following gives 480MHz CPU speed
// VCOClock = HSE * PLLN / PLLM = 8 MHz * 480 / 4 = 960 MHz
// SYSCLK = VCOClock / PLLP = 960 MHz / 2 = 480 MHz
#define MICROPY_HW_CLK_PLLM (4)
#define MICROPY_HW_CLK_PLLN (480)
#define MICROPY_HW_CLK_PLLP (2)
#define MICROPY_HW_CLK_PLLQ (4)
#define MICROPY_HW_CLK_PLLR (2)

// The USB clock is set using PLL3
#define MICROPY_HW_CLK_PLL3M (4)
#define MICROPY_HW_CLK_PLL3N (120)
#define MICROPY_HW_CLK_PLL3P (2)
#define MICROPY_HW_CLK_PLL3Q (5)
#define MICROPY_HW_CLK_PLL3R (2)

// 4 wait states
#define MICROPY_HW_FLASH_LATENCY    FLASH_LATENCY_4
My question #1: what are HW_CLK_PLLQ & HW_CLK_PLLR for? Those were the settings for NUCLEO_H743ZI, are they right?

Question #2: How to correctly set the USB clock with HW_CLK_PLL3* (or what's the equation for proper calculation)? I saw some discussions here: viewtopic.php?f=12&t=7504&start=10, but couldn't get a conclusion about it.

Question #3: Did I set the wait states correctly (FLASH_LATENCY_4)? That was from the settings of NUCLEO_H743ZI as well.

  • Extenal SPI Flash & Extenal QSPI Flash
The board comes with external SPI Flash & QSPI Flash which both are Winbond W25Q64's. I made up the following configuration from various sources:

https://www.programmersought.com/article/29676545292/
https://github.com/mcauser/BLACK_F407VE ... figboard.h
https://github.com/micropython/micropyt ... figboard.h

Code: Select all

// 1 = use internal flash (2 MByte)
// 0 = use onboard SPI flash (8 MByte) Winbond W25Q64
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)

// If using onboard SPI flash
#if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE

// Winbond W25Q64 QSPI Flash = 64 Mbit (8 Mbyte)
#define MICROPY_HW_SPIFLASH_SIZE_BITS (64 * 1024 * 1024)
#define MICROPY_HW_SPIFLASH_CS (pin_B12)
#define MICROPY_HW_SPIFLASH_SCK (pin_B13)
#define MICROPY_HW_SPIFLASH_MISO (pin_B14)
#define MICROPY_HW_SPIFLASH_MOSI (pin_B15)

#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (28)
#define MICROPY_HW_QSPIFLASH_CS (pin_B10)
#define MICROPY_HW_QSPIFLASH_SCK (pin_B2)
#define MICROPY_HW_QSPIFLASH_IO0 (pin_D11)
#define MICROPY_HW_QSPIFLASH_IO1 (pin_D12)
#define MICROPY_HW_QSPIFLASH_IO2 (pin_E2)
#define MICROPY_HW_QSPIFLASH_IO3 (pin_A1)

extern const struct _mp_spiflash_config_t spiflash_config;
extern struct _spi_bdev_t spi_bdev;
#define MICROPY_HW_BDEV_IOCTL(op, arg) ( \
    (op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_SPIFLASH_SIZE_BITS / 8 / FLASH_BLOCK_SIZE) : \
    (op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(&spi_bdev, (op), (uint32_t)&spiflash_config) : \
    spi_bdev_ioctl(&spi_bdev, (op), (arg)) \
)
#define MICROPY_HW_BDEV_READBLOCKS(dest, bl, n) spi_bdev_readblocks(&spi_bdev, (dest), (bl), (n))
#define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(&spi_bdev, (src), (bl), (n))

#endif
Question #4: How to correctly set up SPI Flash & QSPI Flash to use them both? In https://github.com/micropython/micropyt ... figboard.h there seemed to be a bit more codes as following, are they necessary?

Code: Select all

#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
Question #5: What is the number 28 in MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 for? I saw 29 somewhere else, guessing it's related to the size of the QPSI. What is the math for that?

Here's the schematics:
schematics.png
schematics.png (303.44 KiB) Viewed 3841 times
Thanks in advance for the help!

dukeduck
Posts: 22
Joined: Thu Aug 29, 2019 2:06 pm

Re: [STM32H743VI] Building firmware for STM32H743VIT6

Post by dukeduck » Wed Jan 20, 2021 5:12 pm

I managed to build the firmware. Here is the board definition https://github.com/dukeduck1984/BORINGT ... 32H743VIT6.

roose
Posts: 2
Joined: Thu Feb 18, 2021 12:53 pm

Re: [STM32H743VI] Building firmware for STM32H743VIT6

Post by roose » Fri Mar 12, 2021 12:52 pm

Have you seen this repository?
https://github.com/mcauser/MCUDEV_DEVEBOX_H7XX_M

It doesn't compile too, but i got it running following the issue comments. There are also comments about the clock settings in the issue section.

dukeduck
Posts: 22
Joined: Thu Aug 29, 2019 2:06 pm

Re: [STM32H743VI] Building firmware for STM32H743VIT6

Post by dukeduck » Sat Mar 13, 2021 11:18 am

roose wrote:
Fri Mar 12, 2021 12:52 pm
Have you seen this repository?
https://github.com/mcauser/MCUDEV_DEVEBOX_H7XX_M

It doesn't compile too, but i got it running following the issue comments. There are also comments about the clock settings in the issue section.
Yes, it was one of the references when I created the board definition. I will go through the issue comments again just in case I missed anything. Thanks.

Post Reply