wolfBoot icon indicating copy to clipboard operation
wolfBoot copied to clipboard

i.MX RT FlexSPI clock frequency

Open MulattoKid opened this issue 4 months ago • 5 comments

Hi,

I've got a question regarding the setup of the FlexSPI for i.MX RT.

In the i.MX RT HAL there's this definition

https://github.com/wolfSSL/wolfBoot/blob/3801b49f2023faf28ca47e1227ec6431d24b05c0/hal/imx_rt.c#L331

which is used to generate the FCB (Flash Configuration Block) that goes into the first 4KiB of flash to be read by the BootROM.

Later, in hal_flash_init() if USE_GET_CONFIG is defined, the FlexSPI configuration is read and then used to initialize the FlexSPI again.

https://github.com/wolfSSL/wolfBoot/blob/3801b49f2023faf28ca47e1227ec6431d24b05c0/hal/imx_rt.c#L887-L894

However, the flexspi_cfg_option is set to a value that specifies a max frequency (0x7 = 7d = 120MHz) when getting the configuration.

https://github.com/wolfSSL/wolfBoot/blob/3801b49f2023faf28ca47e1227ec6431d24b05c0/hal/imx_rt.c#L881

From testing it seems that when getting the FlexSPI configuration the returned configuration has its frequency set to 0x7 even though the frequency specified in the FCB is 100MHz = 6d = 0x6. Thus, when initializing the FlexSPI afterwards the frequency won't match what was specified in the FCB.

I'm not sure if this is intentional, but it doesn't seem like it is as the FCB is populated with a specific value that's then "discarded" later while initializing the platform?

Some additional resources:

Frequency mapping from reference manual for i.MX RT 1060 Image

Capture of QSPI interface traffic between our i.MX RT1061 and our flash chip (note that I changed the frequency in the FCB to 30MHz and the value in flexspi_cfg_option.option0.U = 0xC0000002 to instead go from 30MHz to 50Mhz to be able to capture the frequency with a Saleae Logic 8 Pro)

  • Before g_bootloaderTree->flexSpiNorDriver->init() Image

  • After g_bootloaderTree->flexSpiNorDriver->init() Image

Kind regards, Daniel

MulattoKid avatar Aug 29 '25 05:08 MulattoKid