cancel
Showing results for 
Search instead for 
Did you mean: 

custom QSPI external loader get "data read failed" error in CubeProgrammer

SEMad
Associate III

Hi.

I have developed a custom board for STM32F746NEH6 with W25Q64.

and I make a driver for this flash chip. everything (like rea, write, erase, memory mapped mode...) works just fine...

but after making the stldr file I got this error:

0693W00000NsDOaQAN.png 

and this is my pinout:

0693W00000NsDOfQAN.png 

is the read function causing this error?

but loader don't need to this function.

and I tested the memory mapped mode function... it works fine... after using it in the other code the external flash works as the internal one:

0693W00000NsDPOQA3.png 

uint8_t CSP_QSPI_EnableMemoryMappedMode(void)
{
	QSPI_CommandTypeDef sCommand = {0};
	QSPI_MemoryMappedTypeDef sMemMappedCfg;
	
	/* basic configuration */ 
  sCommand.InstructionMode          = QSPI_INSTRUCTION_1_LINE;        // * 1 line mode Send instruction * /
  sCommand.AddressSize              = QSPI_ADDRESS_24_BITS;         	// * 24 Bit address * /
  sCommand.AlternateByteMode        = QSPI_ALTERNATE_BYTES_NONE;      // * No interverter byte * /
  sCommand.DdrMode                  = QSPI_DDR_MODE_DISABLE;          // * W25Q64JV does not support DDR * /
  sCommand.DdrHoldHalfCycle         = QSPI_DDR_HHC_ANALOG_DELAY;      // * DDR mode, data output delay * /
  sCommand.SIOOMode                 = QSPI_SIOO_INST_EVERY_CMD;       // * Each transmission must send instructions * /
	
	// * Read data * / 
  sCommand.Instruction    = QUAD_OUT_FAST_READ_CMD;     // * Read status command * / 
  sCommand.AddressMode    = QSPI_ADDRESS_1_LINE;        // * 1 Line address * / 
  sCommand.DataMode       = QSPI_DATA_4_LINES;          // * 1 wire data * /
  sCommand.DummyCycles    = 8;                          // * 8 cycles * /
	
	//MemoryMapped settings
	sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
	sMemMappedCfg.TimeOutPeriod 		= 0;
	
	if (HAL_QSPI_MemoryMapped(&hqspi, &sCommand, &sMemMappedCfg) != HAL_OK) {
		return HAL_ERROR;
	}
	
	/* basic configuration */ 
  sCommand.InstructionMode          = QSPI_INSTRUCTION_1_LINE;        // * 1 line mode Send instruction * /
  sCommand.AddressSize              = QSPI_ADDRESS_24_BITS;         	// * 24 Bit address * /
  sCommand.AlternateByteMode        = QSPI_ALTERNATE_BYTES_4_LINES;   // * 4 Line interverter byte * /
	sCommand.AlternateBytesSize       = QSPI_ALTERNATE_BYTES_8_BITS;    // * 1 Byte alternate * /
	sCommand.AlternateBytes       		= 0xFF;    												// * should be 0xFx * /
  sCommand.DdrMode                  = QSPI_DDR_MODE_DISABLE;          // * W25Q64JV does not support DDR * /
  sCommand.DdrHoldHalfCycle         = QSPI_DDR_HHC_ANALOG_DELAY;      // * DDR mode, data output delay * /
  sCommand.SIOOMode                 = QSPI_SIOO_INST_EVERY_CMD;       // * Each transmission must send instructions * /
	
	// * Read data * / 
  sCommand.Instruction    = QUAD_INOUT_FAST_READ_CMD;   // * Read status command * / 
  sCommand.AddressMode    = QSPI_ADDRESS_4_LINES;       // * 4 Line address address * / 
  sCommand.DataMode       = QSPI_DATA_4_LINES;          // * 1 wire data * /
  sCommand.DummyCycles    = 4;                          // * 4 cycles * /
	
	//MemoryMapped settings
	sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
	sMemMappedCfg.TimeOutPeriod 		= 0;
	
	if (HAL_QSPI_MemoryMapped(&hqspi, &sCommand, &sMemMappedCfg) != HAL_OK) {
		return HAL_ERROR;
	}
}

so... what is the problem?

can anyone help me please?

thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
SEMad
Associate III

I commented the first part of memory mapped function and in the second part used 2 dummy cycle instead of the alternate 0xff byte:

uint8_t CSP_QSPI_EnableMemoryMappedMode(void)
{
	QSPI_CommandTypeDef sCommand = {0};
	QSPI_MemoryMappedTypeDef sMemMappedCfg;
 
//	/* basic configuration */
//	sCommand.InstructionMode          = QSPI_INSTRUCTION_1_LINE;        // * 1 line mode Send instruction * /
//	sCommand.AddressSize              = QSPI_ADDRESS_24_BITS;         	// * 24 Bit address * /
//	sCommand.AlternateByteMode        = QSPI_ALTERNATE_BYTES_NONE;      // * No interverter byte * /
//	sCommand.DdrMode                  = QSPI_DDR_MODE_DISABLE;          // * W25Q64JV does not support DDR * /
//	sCommand.DdrHoldHalfCycle         = QSPI_DDR_HHC_ANALOG_DELAY;      // * DDR mode, data output delay * /
//	sCommand.SIOOMode                 = QSPI_SIOO_INST_EVERY_CMD;       // * Each transmission must send instructions * /
//
//	// * Read data * /
//	sCommand.Instruction    = 0x6B;     // * Read status command * /
//	sCommand.AddressMode    = QSPI_ADDRESS_1_LINE;        // * 1 Line address * /
//	sCommand.DataMode       = QSPI_DATA_4_LINES;          // * 1 wire data * /
//	sCommand.DummyCycles    = 8;                          // * 8 cycles * /
//
//	//MemoryMapped settings
//	sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
//	sMemMappedCfg.TimeOutPeriod 		= 0;
//
//	if (HAL_QSPI_MemoryMapped(&hqspi, &sCommand, &sMemMappedCfg) != HAL_OK) {
//		return HAL_ERROR;
//	}
 
	/* basic configuration */
	sCommand.InstructionMode          = QSPI_INSTRUCTION_1_LINE;        // * 1 line mode Send instruction * /
	sCommand.AddressSize              = QSPI_ADDRESS_24_BITS;         	// * 24 Bit address * /
	sCommand.AlternateByteMode        = QSPI_ALTERNATE_BYTES_NONE;   // * 4 Line interverter byte * /
	//sCommand.AlternateBytesSize       = QSPI_ALTERNATE_BYTES_8_BITS;    // * 1 Byte alternate * /
	//sCommand.AlternateBytes       		= 0xFF;    												// * should be 0xFx * /
	sCommand.DdrMode                  = QSPI_DDR_MODE_DISABLE;          // * W25Q64JV does not support DDR * /
	sCommand.DdrHoldHalfCycle         = QSPI_DDR_HHC_ANALOG_DELAY;      // * DDR mode, data output delay * /
	sCommand.SIOOMode                 = QSPI_SIOO_INST_EVERY_CMD;       // * Each transmission must send instructions * /
 
	// * Read data * /
	sCommand.Instruction    = 0xEB;   // * Read status command * /
	sCommand.AddressMode    = QSPI_ADDRESS_4_LINES;       // * 4 Line address address * /
	sCommand.DataMode       = QSPI_DATA_4_LINES;          // * 1 wire data * /
	sCommand.DummyCycles    = 6;                          // * 4 cycles * /
 
	//MemoryMapped settings
	sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
	sMemMappedCfg.TimeOutPeriod 		= 0;
 
	if (HAL_QSPI_MemoryMapped(&hqspi, &sCommand, &sMemMappedCfg) != HAL_OK) {
		return HAL_ERROR;
	}
 
	return HAL_OK;
}

and then commented the configuration func part in CSP_QUADSPI_Init function... and it finally worked!

in the configuration I set QE bit to "high" (for jv series it is high by default) and DRV0/DRV1 to "00"... but actually this was the cause of problem!!

View solution in original post

2 REPLIES 2
SEMad
Associate III

I commented the first part of memory mapped function and in the second part used 2 dummy cycle instead of the alternate 0xff byte:

uint8_t CSP_QSPI_EnableMemoryMappedMode(void)
{
	QSPI_CommandTypeDef sCommand = {0};
	QSPI_MemoryMappedTypeDef sMemMappedCfg;
 
//	/* basic configuration */
//	sCommand.InstructionMode          = QSPI_INSTRUCTION_1_LINE;        // * 1 line mode Send instruction * /
//	sCommand.AddressSize              = QSPI_ADDRESS_24_BITS;         	// * 24 Bit address * /
//	sCommand.AlternateByteMode        = QSPI_ALTERNATE_BYTES_NONE;      // * No interverter byte * /
//	sCommand.DdrMode                  = QSPI_DDR_MODE_DISABLE;          // * W25Q64JV does not support DDR * /
//	sCommand.DdrHoldHalfCycle         = QSPI_DDR_HHC_ANALOG_DELAY;      // * DDR mode, data output delay * /
//	sCommand.SIOOMode                 = QSPI_SIOO_INST_EVERY_CMD;       // * Each transmission must send instructions * /
//
//	// * Read data * /
//	sCommand.Instruction    = 0x6B;     // * Read status command * /
//	sCommand.AddressMode    = QSPI_ADDRESS_1_LINE;        // * 1 Line address * /
//	sCommand.DataMode       = QSPI_DATA_4_LINES;          // * 1 wire data * /
//	sCommand.DummyCycles    = 8;                          // * 8 cycles * /
//
//	//MemoryMapped settings
//	sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
//	sMemMappedCfg.TimeOutPeriod 		= 0;
//
//	if (HAL_QSPI_MemoryMapped(&hqspi, &sCommand, &sMemMappedCfg) != HAL_OK) {
//		return HAL_ERROR;
//	}
 
	/* basic configuration */
	sCommand.InstructionMode          = QSPI_INSTRUCTION_1_LINE;        // * 1 line mode Send instruction * /
	sCommand.AddressSize              = QSPI_ADDRESS_24_BITS;         	// * 24 Bit address * /
	sCommand.AlternateByteMode        = QSPI_ALTERNATE_BYTES_NONE;   // * 4 Line interverter byte * /
	//sCommand.AlternateBytesSize       = QSPI_ALTERNATE_BYTES_8_BITS;    // * 1 Byte alternate * /
	//sCommand.AlternateBytes       		= 0xFF;    												// * should be 0xFx * /
	sCommand.DdrMode                  = QSPI_DDR_MODE_DISABLE;          // * W25Q64JV does not support DDR * /
	sCommand.DdrHoldHalfCycle         = QSPI_DDR_HHC_ANALOG_DELAY;      // * DDR mode, data output delay * /
	sCommand.SIOOMode                 = QSPI_SIOO_INST_EVERY_CMD;       // * Each transmission must send instructions * /
 
	// * Read data * /
	sCommand.Instruction    = 0xEB;   // * Read status command * /
	sCommand.AddressMode    = QSPI_ADDRESS_4_LINES;       // * 4 Line address address * /
	sCommand.DataMode       = QSPI_DATA_4_LINES;          // * 1 wire data * /
	sCommand.DummyCycles    = 6;                          // * 4 cycles * /
 
	//MemoryMapped settings
	sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
	sMemMappedCfg.TimeOutPeriod 		= 0;
 
	if (HAL_QSPI_MemoryMapped(&hqspi, &sCommand, &sMemMappedCfg) != HAL_OK) {
		return HAL_ERROR;
	}
 
	return HAL_OK;
}

and then commented the configuration func part in CSP_QUADSPI_Init function... and it finally worked!

in the configuration I set QE bit to "high" (for jv series it is high by default) and DRV0/DRV1 to "00"... but actually this was the cause of problem!!

Yes, typically if the Init() fails the tools can timeout or fault.The read in these cases uses the MCU directly to access the memory-mapped space.

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