2020-09-07 01:26 AM
Hello, I build program to store data in external QSPI flash memory using STM32Cube programmer and generated .stldr file but as soon as I place same file to bin external loader folder (STM32Cube\STM32CubeProgrammer\bin\ExternalLoader), STM32Cube programmer IDE wouldn't open. I not able to find the reason. Any suggestions?
Attaching my project.
Thanks
2020-09-16 08:13 PM
@Community member Thanks you taking out your time.
I am agree. There should be error handling in STM32 Cube Programmer. Its like black box right now. i spent so much of my time in just adding *.stldr file to it.
-Chandan
2020-09-18 12:21 AM
I am able to load *.stldr file in STMCube programmer and able to mass erase but Facing below issue when programming,
12:45:30 : STM32CubeProgrammer API v2.4.0
12:45:30 : ST-LINK error (DEV_CONNECT_ERR)
12:45:37 : ST-LINK SN : 066FFF545554827867064115
12:45:37 : ST-LINK FW : V2J33M25
12:45:37 : Voltage : 3.21V
12:45:37 : SWD freq : 4000 KHz
12:45:37 : Connect mode: Normal
12:45:37 : Reset mode : Software reset
12:45:37 : Device ID : 0x449
12:45:38 : UPLOADING OPTION BYTES DATA ...
12:45:38 : Bank : 0x00
12:45:38 : Address : 0x40023c14
12:45:38 : Size : 8 Bytes
12:45:38 : UPLOADING ...
12:45:38 : Size : 1024 Bytes
12:45:38 : Address : 0x8000000
12:45:38 : Read progress:
12:45:38 : Data read successfully
12:45:38 : Time elapsed during the read operation is: 00:00:00.007
12:45:49 : Memory Programming ...
12:45:49 : Opening and parsing file: MyDevKitProj.elf
12:45:49 : File : MyDevKitProj.elf
12:45:49 : Size : 967244 Bytes
12:45:49 : Address : 0x08000000
12:45:49 : Erasing memory corresponding to segment 0:
12:45:49 : Erasing internal memory sectors [0 4]
12:45:51 : Erasing memory corresponding to segment 1:
12:45:51 : Erasing external memory sectors [0 11]
12:45:52 : Download in Progress:
12:46:03 : Error: failed to download Segment[1]
12:46:03 : Error: failed to download the File
12:46:03 : RUNNING Program ...
12:46:03 : Address: : 0x08000000
12:46:03 : Application is running
12:46:03 : Start operation achieved successfully
From log it seems like, Programmer is able to erase sectors but unable to write it.
When I called SectorErase() and Write() functions from normal program in main, I can see data is able to store at external QSPI flash. Not sure about STMCube programmer issue.
uint8_t CSP_QSPI_WriteMemory(uint8_t* buffer, uint32_t address,uint32_t buffer_size) {
QSPI_CommandTypeDef sCommand;
uint32_t end_addr, current_size, current_addr;
/* Calculation of the size between the write address and the end of the page */
current_addr = 0;
//
while (current_addr <= address) {
current_addr += MEMORY_PAGE_SIZE;
}
current_size = current_addr - address;
/* Check if the size of the data is less than the remaining place in the page */
if (current_size > buffer_size) {
current_size = buffer_size;
}
/* Initialize the adress variables */
current_addr = address;
end_addr = address + buffer_size;
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.AddressSize = QSPI_ADDRESS_24_BITS;
sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
sCommand.Instruction = QUAD_IN_FAST_PROG_CMD;
sCommand.AddressMode = QSPI_ADDRESS_1_LINE;//QSPI_ADDRESS_4_LINES; //
sCommand.DataMode = QSPI_DATA_4_LINES;
sCommand.NbData = buffer_size;
sCommand.Address = address;
sCommand.DummyCycles = 0;
/* Perform the write page by page */
do {
sCommand.Address = current_addr;
sCommand.NbData = current_size;
if (current_size == 0) {
return HAL_OK;
}
/* Enable write operations */
if (QSPI_WriteEnable() != HAL_OK) {
return HAL_ERROR;
}
/* Configure the command */
if (HAL_QSPI_Command(&hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE)
!= HAL_OK) {
return HAL_ERROR;
}
/* Transmission of the data */
if (HAL_QSPI_Transmit(&hqspi, buffer, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
/* Configure automatic polling mode to wait for end of program */
if (QSPI_AutoPollingMemReady() != HAL_OK) {
return HAL_ERROR;
}
/* Update the address and size variables for next page programming */
current_addr += current_size;
buffer += current_size;
current_size =
((current_addr + MEMORY_PAGE_SIZE) > end_addr) ?
(end_addr - current_addr) : MEMORY_PAGE_SIZE;
} while (current_addr <= end_addr);
return HAL_OK;
}