cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to read W25Q128 spi flash beyond 2 Mbyte

SimonTapmeyer
Associate II

Hello,

I am use a winbond W25Q128JV chip which is connected to the OCTOSPI interface of my STM32H563. I read/write the flash in direct mode. The transfers are done with DMA. Everything works fine as long as the address is smaller than 0x200000 (2 MByte). As soon as I cross that border the DMA stops with HAL_XSPI_FLAG_TE. Has anyone an idea what I am doing wrong?

This is how I parametrize the transfer:

 

 

(void)memset(&eCmdType, 0x00, sizeof(eCmdType));
eCmdType.Instruction		= 0x0B;	/* Fast read data */
eCmdType.InstructionMode	= HAL_XSPI_INSTRUCTION_1_LINE;
eCmdType.InstructionWidth	= HAL_XSPI_INSTRUCTION_8_BITS;
eCmdType.InstructionDTRMode	= HAL_XSPI_INSTRUCTION_DTR_DISABLE;
eCmdType.AddressMode		= HAL_XSPI_ADDRESS_1_LINE;
eCmdType.AddressWidth		= HAL_XSPI_ADDRESS_24_BITS;
eCmdType.Address		= _iStartAddress;
eCmdType.DataMode		= HAL_XSPI_DATA_1_LINE;
eCmdType.DataDTRMode		= HAL_XSPI_DATA_DTR_DISABLE;
eCmdType.DataLength		= _iSize;
eCmdType.AlternateBytesMode	= HAL_XSPI_ALT_BYTES_NONE;
eCmdType.SIOOMode		= HAL_XSPI_SIOO_INST_EVERY_CMD;
eCmdType.DummyCycles		= 8;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello,

I was able to fix the problem. I work on linux and use the following software:
- IDE: STM32CubeIDE 1.13.2
- Firmware: STM32Cube FW_H5 V1.1.1
- MCU reference: STM32H563ZITx

I selected "16 MBytes" in the "Memory Size" field of the octospi configuration in the integrated CubeMX. The generated configuration sets the DEVSIZE field of OCTOSPI_DCR1 register to 0x14. That means 2^(20+1) = 2 MBytes. The correct value for DEVSIZE is 0x17. CubeMX generates that when I select 128 MBytes from the "Memory Size" dropdown menu. I think this is a bug in this version ov STM32CubeIDE. My read operations work fine (with and without DMA) since I changed the memory size.

View solution in original post

11 REPLIES 11

Nothing particularly is jumping out with the fragment you've chosen to share.

What's the LENGTH of the transfer you're attempting?

If the error is coming from the DMA unit, look at that over the OCTOSPI unit. Look a register bit widths, and limitations of the unit that will cause it to fault or error.

Do polled methods work?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hello,

I was able to fix the problem. I work on linux and use the following software:
- IDE: STM32CubeIDE 1.13.2
- Firmware: STM32Cube FW_H5 V1.1.1
- MCU reference: STM32H563ZITx

I selected "16 MBytes" in the "Memory Size" field of the octospi configuration in the integrated CubeMX. The generated configuration sets the DEVSIZE field of OCTOSPI_DCR1 register to 0x14. That means 2^(20+1) = 2 MBytes. The correct value for DEVSIZE is 0x17. CubeMX generates that when I select 128 MBytes from the "Memory Size" dropdown menu. I think this is a bug in this version ov STM32CubeIDE. My read operations work fine (with and without DMA) since I changed the memory size.

Can you share a screen shot of that?

16 Mbit = 2 MByte, content is frequently specified in "bits"

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Of course, here you go.

SimonTapmeyer_0-1719898965246.png

 

KDJEM.1
ST Employee

Hello @SimonTapmeyer ,

 

Glad to know that the issue is solved and thank you for sharing the solution.

I confirm the issue in STM32CubeIDE1.15.1 and STM32CubeMX6.11.1 versions.

This issue is already fixed in STM32CubeIDE1.16.0 and STM32CubeMX6.12.0 versions.

For that could you please try to update the toolchain.

KDJEM1_0-1719934405627.png

Thank you.

Kaouthar

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

16 Bits? Who's using that?

Needs to be "16 Mbit / 2 MByte" if we're trying to convey the capacity with the physical device, not a bus width.

The complaint is/was that "16 MBytes" was selected and the code generation created a Size Shift value suitable for 16 Mb / 2 MB causing the unit to Hard Fault once the 2MB ceiling was breached.

Most people are likely to using/thinking BYTE CAPACITY, bit capacities are a bit of an anachronism. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I just downloaded STM32CubeMC 6.12.0 for ubuntu 22.04 but it still comes up with 16 MBytes:

SimonTapmeyer_0-1719988011377.png

 

KDJEM.1
ST Employee

Hello @SimonTapmeyer @Tesla DeLorean ,

The last version of STM32CubeMX 6.12 for windows uses the Bits unity for memory size.

If the memory size is 16MBytes = 128MBits in the memory datasheet, the memory size must be configure to 128MBits in STM32CubeMX.

KDJEM1_0-1719990392849.png

After generating code with STM32CubeMx toolchain the memory size is configured:

hospi1.Init.MemorySize = HAL_XSPI_SIZE_128MB;

With HAL_XSPI_SIZE_128MB is defined in STM32h5xx_hal_xspi.h file in STM32Cube FW_H5 V1.3.0.

#define HAL_XSPI_SIZE_128MB                  (0x00000017U)  /*!< 128 Mbits ( 16 MByte = 2^(23+1)) */

 

Most people are likely to using/thinking BYTE CAPACITY, bit capacities are a bit of an anachronism @Tesla DeLoreanThank you for sharing this request I will report internally.

I just downloaded STM32CubeMC 6.12.0 for ubuntu 22.04 @SimonTapmeyer To check the issue, could you please share the .ioc file? Please, make sure that you used the the last version of STM32CubeMX:

KDJEM1_1-1719991919757.png

KDJEM1_2-1719991936204.png

 

Thank you.

Kaouthar

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Ok, CubeMX 6.12.0 for ubuntu 22.04 shows the correct values after I migrated my .ioc file instead of just open it:

SimonTapmeyer_0-1719993209128.png

However, as @Tesla DeLorean  writes: 16 bits and some other values in this range do not make sense.