2023-01-09 04:35 AM
I have a custom board with an STM32H7A3ZIT6Q. It has the MT25TL256 NOR flash connected to the pins of OCTOSPI1.
I'm trying to write a flashloader/driver.
In our application we do not need to execute code from this flash. We only need it for data. But if there is a way to get execution working that would be nice too.
I'm following the tutorial from ST:
ST tutorial:
https://www.youtube.com/watch?v=YFIvJVsvIsE&list=PLnMKNibPkDnHIrq5BICcFhLsmJFI_ytvE&index=1
Template project: https://drive.google.com/drive/folders/1KiaqXgiubk81EvevofK-y3LxrCl9NHfi
STM git repo https://github.com/STMicroelectronics/stm32-external-loader/tree/contrib
MCU Datasheet: https://www.st.com/resource/en/datasheet/stm32h7a3ri.pdf
Reference manual: https://www.st.com/resource/en/reference_manual/rm0455-stm32h7a37b3-and-stm32h7b0-value-line-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
Here is what I have figured out so far:
MCU is clocked to 270MHZ.
Prescaler is set to 4 (value 3 in register) so MT25TL256 is clocked at 90MHz in DTR mode.
chip-select high time (CSHT) is hard to find, but since all similar timings are <= 5ns this equals to 1 clock cycle, so this is set to 1
Our MCU is the Q variant with SMPS, so not all pins of OCTOSPI2 are available.
Here is what I'm struggling with:
In table 4 of AN5050 Rev 7 it says the flash has to be connected to OCTOSPI2, but ours is connected to OCTOSPI1.
In Table 1 of DS13195 Rev 8 it says nor flash is not supported directly only in Multiplexed mode.
In figure 10 of AN5050 Rev 7 the Multiplexed mode is visualized. In this figure Memory 2 is connected to OCTOSPI1 and its CSn pin (S#) is connected to OCTOSPI2.
In Table 6 of RM0455 Rev 9 it seems like NOR flash could be mapped to OCTOSPI1 (I assume the first addresses are for OCTOSPI1), but that "Execute never" is set to yes, so it cannot be executed.
Since our memory has the CSn connected to OCTOSPI1 instead of two I wonder if we can get this to work, with or without support for execution, without making hardware changes.
So my questions are:
1) Can we get this chip to work without changing the hardware? If, so how?
2) What value should I use for FifoThreshold?
Solved! Go to Solution.
2023-01-19 02:34 AM - edited 2024-03-21 03:15 AM
I've found the bug. The debugger doesn't hard reset the processor so the reset line of the FLASH chip doesn't toggle. The FLASH chip is still in quad mode. The solution was to simply reset the chip in both quad and single mode.
I've also improved the driver structure so I can enable Discard unused sections (-Wl,--gc-sections):
//trick compiler not to discard unused functions and data with option Discard unused sections (-Wl,--gc-sections) volatile bool useUnused = false; volatile unsigned long DeviceSize; if (useUnused) { DeviceSize = StorageInfo.DeviceSize; UNUSED(DeviceSize); SectorErase(0, 0); MassErase(); Write(0,0,NULL); CheckSum(0, 0, 0); Verify(0,0,0,0); }
Edit: driver can be found here: https://github.com/STMicroelectronics/stm32-external-loader/pull/13