cancel
Showing results for 
Search instead for 
Did you mean: 

Issue Programming STM32F04 through SWD

EOCon.1
Associate II

Hi all, I am trying to program the flash memory in my STM32F04 processor. I am doing this over SWD from another processor. I can successfully read all the DAP IDs etc and I also have figured out how to read and write from registers inside the stm32. My issue arises when I try program a word to start of flash @0x08000000. Until this point in my sequence the DAP always responds with the correct ACK, erasing the flash works successfully. As soon as I do the flash programming procedure for writing this happens.

My flash write sequence is just as described in the flash write example from the datasheet but through SWD.

Write 0x08000000 to Address TAR register

Write my data to the data buffer​

The next transaction gives the ACK fault.

My flash is not write or read protected in the option bytes.

Any ideas?​

2 REPLIES 2
Uwe Bonnes
Principal II

You need to unlock the flash register. Loot at the reference manual e.g.rm0091 3.2.2 Flash program and erase operations.

EOCon.1
Associate II

Of course I did not forget this step, I have fixed my issue in the meantime. The issue is that you can also access flash with 16-bit access not 32. When I changed the DAP CSW to give 16-bit access the problem goes away 🙂