2025-10-16 2:22 AM
Hi,
I'm trying to implement an external loader for the Arduino Giga R1 board with AT25S128A 128Mbit of external flash. After following the guide given in the external loader repo, I'm running into the problem, that I can erase, write & read from the memory fine, however, as soon as I try to turn on memory mapped mode, all the data reads as 0xFF...FF, both in code and in the STM32CubeIDE memory viewer. I think my problems could be related to MCU configuration, I would be grateful if someone could give some guidance, see the relevant code below and attached.
quadspi.c:
uint8_t CSP_QSPI_EnableMemoryMappedMode(void) {
QSPI_CommandTypeDef sCommand = { 0 };
QSPI_MemoryMappedTypeDef sMemMappedCfg = { 0 };
// Enable Memory-Mapped mode
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.Instruction = QUAD_INOUT_FAST_READ_CMD;
sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
sCommand.AddressMode = QSPI_ADDRESS_4_LINES;
sCommand.AddressSize = QSPI_ADDRESS_24_BITS;
sCommand.DataMode = QSPI_DATA_4_LINES;
sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES;
sCommand.AlternateBytesSize = QSPI_ALTERNATE_BYTES_8_BITS;
sCommand.AlternateBytes = 0x00;
sCommand.DummyCycles = 4;
sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
// sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
// sCommand.Instruction = QUAD_OUT_FAST_READ_CMD;
// sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
// sCommand.AddressMode = QSPI_ADDRESS_1_LINE;
// sCommand.AddressSize = QSPI_ADDRESS_24_BITS;
// sCommand.Address = 0;
// sCommand.DataMode = QSPI_DATA_4_LINES;
// sCommand.NbData = 0;
// sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_1_LINE;
// sCommand.AlternateBytesSize = QSPI_ALTERNATE_BYTES_8_BITS;
// sCommand.AlternateBytes = 0x00;
// sCommand.DummyCycles = 0;
// sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
// sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
sMemMappedCfg.TimeOutPeriod = 0;
if (HAL_QSPI_MemoryMapped(&hqspi, &sCommand, &sMemMappedCfg) != HAL_OK) {
return HAL_ERROR;
}
return HAL_OK;
}
main.c test snippet:
CSP_QUADSPI_Init();
for (var = 0; var < MEMORY_SECTOR_SIZE; var++) {
buffer_test[var] = (var & 0xFF);
}
for (var = 0; var < SECTORS_COUNT; var++) {
if (CSP_QSPI_EraseSector(var * MEMORY_SECTOR_SIZE, (var + 1) * MEMORY_SECTOR_SIZE - 1) != HAL_OK) {
while (1) {}
}
if (CSP_QSPI_WriteMemory(buffer_test, var * MEMORY_SECTOR_SIZE, sizeof(buffer_test)) != HAL_OK) {
while (1) {}
}
if (CSP_QSPI_ReadMemory(buffer_read, var * MEMORY_SECTOR_SIZE, sizeof(buffer_test)) != HAL_OK) {
while (1) {}
}
}
if (CSP_QSPI_EnableMemoryMappedMode() != HAL_OK) {
while (1) {}
}
uint8_t verify_buffer[MEMORY_SECTOR_SIZE] = {0};
for (var = 0; var < SECTORS_COUNT; var++) {
if (memcpy(verify_buffer, (uint8_t*) (0x90000000 + var * MEMORY_SECTOR_SIZE), MEMORY_SECTOR_SIZE) != HAL_OK) {
while (1) {}
}
}
Thank you for your help.
2025-10-16 5:40 AM
Hello @EmbeddedOrca and welcome to the community;
Could you please check if the write operation is done successfully?
Note only read operations are allowed to the external flash memory in memory-mapped mode. The indirect mode supports read and write operations.
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.