Hello, I'm having trouble writing to flash memory using the C40 chip in the bootloader. I'm writing a 300KB binary program, and it frequently fails at the 9th data packet (the second block), with only a 1/10 chance of succeeding completely. Could you please check if there's a problem with my C40 chip? The main program I'm writing...
Flash_UnlockSectorIfProtected ( cur_sector ) ;
DisableAllInterrupts () ;
DisEnableIrq1 () ;
if ( Flash_Write ( flash_write_addr + offset , & payload [ 2 ] , FIXED_PACKET_DATA_LEN ) != 0 ) {
EnableIrq1 () ;
EnableAllInterrupts () ;
}
EnableIrq1 () ;
EnableAllInterrupts () ;
Is there a problem with my use of Power_Ip_MC_ME_SocTriggerResetEvent(POWER_IP_DEST_RESET_MODE) for resetting? How can I prevent consecutive resets after 8 attempts, and what function should I use for jumps?
func = * ( uint32_t volatile * )( ADDR_APP + 0xC ) ;
func = * ( uint32_t volatile * )((( uint32_t ) func ) + 0x4 ) ;
func = (((( uint32_t ) func ) & 0xFFFFFFFF U )) ; // Reset_Handler+1 --> required to avoid hard fault
After resetting and jumping , will there be any residual data from the previous program? Is it necessary to clean up the RAM? If so , how? Thank you .
Hi@ LJH1
Please provide me with a simple demo that can reproduce the problem so I can reproduce your issue. I don't need your complete product project or scattered driver files.
RTD Company uses version 4.0.0 as standard.
Offline burning of two programs allows for faster reproduction: the first boot directly jumps to the app, the app flashes for 30 seconds to enter boot, the erase/write cycle flashes for 1 second, a total of 300 times. If there are no problems, it resets; if there are problems, it stays on or off.
Hi@ LJH1
Your program is too messy; I have no way of testing it for you.
I wrote a test program based on the logic of your test.
The 8KB space starting from address 0x1000A000 is written in 128 bytes each time, and the address is written 64 times consecutively, totaling 8KB, for a total of 300 times.
(128 * 64 * 300).
You need to change the clock, because I'm using an S32K311EVB-Q100 with a 16MHz external clock crystal.