2025-03-24 6:30 AM - last edited on 2025-04-10 3:29 AM by Andrew Neil
i am trying to implement openBootloader for an stm32l451,
but i cant get the write to work i get the following errors HAL_FLASH_ERROR_PROG | HAL_FLASH_ERROR_PGA |HAL_FLASH_ERROR_PGS
i am trying to write to 800c000 in the flash
this is my code( i used https://github.com/STMicroelectronics/stm32wl-openbl-apps to assist in how to write the interfaces)
void OPENBL_FLASH_Unlock(void) { HAL_FLASH_Unlock(); }
static void OPENBL_FLASH_Program(uint32_t Address, uint64_t Data) {
/* Clear all FLASH errors flags before starting write operation */
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data);
}
void OPENBL_FLASH_Write(uint32_t Address, uint8_t *Data, uint32_t DataLength) {
uint32_t index;
__ALIGNED(4) uint8_t buffer[FLASH_PROG_STEP_SIZE] = {0x0U};
uint8_t remaining;
if ((Data != NULL) && (DataLength != 0U)) {
/* Unlock the flash memory for write operation */
OPENBL_FLASH_Unlock();
/* Program double-word by double-word (8 bytes) */
while ((DataLength >> 3U) > 0U) {
for (index = 0U; index < FLASH_PROG_STEP_SIZE; index++) {
buffer[index] = *(Data + index);
}
OPENBL_FLASH_Program(Address,
*((uint64_t *)buffer));
Address += FLASH_PROG_STEP_SIZE;
Data += FLASH_PROG_STEP_SIZE;
DataLength -= FLASH_PROG_STEP_SIZE;
}
/* If remaining count, go back to fill the rest with 0xFF */
if (DataLength > 0U) {
remaining = FLASH_PROG_STEP_SIZE - DataLength;
/* Copy the remaining bytes */
for (index = 0U; index < DataLength; index++) {
buffer[index] = *(Data + index);
}
/* Fill the upper bytes with 0xFF */
for (index = 0U; index < remaining; index++) {
buffer[index + DataLength] = 0xFFU;
}
/* FLASH word program */
OPENBL_FLASH_Program(Address,
(uint64_t)(*((uint64_t *)((uint32_t)buffer))));
}
/* Lock the Flash to disable the flash control register access */
OPENBL_FLASH_Lock();
}
is where something i am missing ?
2025-03-28 5:59 AM
Hello @lucasrj
Is the OPENBL_FLASH_Erase() work fine please?
Could you please share your entire code then we can assist you more effectively.
2025-04-03 11:49 PM
hey @Saket_Om
Sorry for the late reply
I have not tried the OPENBL_FLASH_Erase() as I have not implemented it in the Python script on the host side,
The host device is an NX Jetson using an arm processor, so it can not run the Cube programmer.
Is there an ARM version of Cube Programmer?
Then, I used the debugger. I could see it got the correct data in OPENBL_FLASH_Write() and called OPENBL_FLASH_Program() with the expected data, so I don't see how it should make a difference. Am I missing something?
I have attached my flash interface files
2025-04-07 6:06 AM
Hello @lucasrj
Is the Write process work fine with STM32Cube programmer please?
2025-04-07 7:03 AM
I can write to it using a st-link, I am unable to connected the serial to an x64 computer.
it is connected to an jetson nx running arm
Is where a version of stm32cube programmer working on arm?
2025-04-07 8:44 AM
Is your host running on windows?
2025-04-09 11:40 PM
Sorry for the late response,
No it is running ubuntu 20
2025-04-10 12:48 AM
2025-04-10 12:56 AM
If I read what you sent correctly, it states that the stm32cube programmer can program stm32 arm processors but does not talk about the host PC. I can see I am running an older version of Ubuntu than is officially supported. What is the last version of the Cube programmer supporting Ubuntu 20?
Then, I tryed to run the Linux install as I did on my x64 laptop, and I got the following
2025-04-10 1:37 AM
Hello @lucasrj
I apologize for this misunderstood, but the tool is not compatible with ARM architecture.