AnsweredAssumed Answered

IAP programming errors

Question asked by achterop.sietse on Apr 1, 2014
Latest reply on Apr 22, 2014 by achterop.sietse
    Dear List,

I am working on IAP on the STM32F4Discovery board and flashing only occasionally works.
I started from the example describing IAP using an USART.

But I use USB to download the data to be flashed, with code derived from the USB-Device-VCP example.
Downloading via USB works flawlessly. I  also use USART2 as a debug-port, via syscalls.c/printf.

I try to flash a few words, but it only occasionally works. On avarage 1 out of 3 progammings (of 3 words) are ok.
Programming larger pieces never works.
The flash is programmed using the interface from flash_if.c from the IAP-USART example.
To flash I do:

initially:
FLASH_If_Init();
FLASH_If_Erase(flashadr);

and then as often as needed:
if ((j=FLASH_If_Write((volatile uint32_t *)&flashadr, (uint32_t*) buf, (uint16_t) bufsize/4)) != 0) { FLASH_If_Lock(); return j;}

and finally:
FLASH_If_Lock();

When the flashing fails, this is signalled in function
FLASH_Status FLASH_GetStatus(void)
            (which is called from FLASH_ProgramWord(uint32_t Address, uint32_t Data))

When the error occurs, always in trying to flash address 0x8020000 (first word of section 5), then
FLASH->SR yields 0xC0, meaning (PGPERR and PGSERR)

The USB- and UART- code does not reside in section 5 that is to be reprogrammed, but in 1 to 4.

But maybe the problem is that USB and USART code is used, that use interrupts?
Disabling interrups in FLASH_ProgramWord did not help.

Can anybody point me in  the right direction?

  Thanks in advance,
      Sietse

Outcomes