2394069_en-US

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2394069_en-US

2394069_en-US

Boot uses C40 to erase and rewrite flash.

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 .

回复: boot使用C40擦写flash

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.

回复: boot使用C40擦写flash

RTD Company uses version 4.0.0 as standard.

回复: boot使用C40擦写flash
Subsequent testing revealed that C40 writes were intermittently successful. The `status = C40_Ip_MainInterfaceWriteStatus(); ` command returned a value of 2.
ErrorFlags = C40_Ip_pFlashBaseAddress -> MCRS & ( FLASH_MCRS_PEG_MASK | FLASH_MCRS_PEP_MASK | FLASH_MCRS_PES_MASK ) ;
ErrorFlags eventually equals 0; returns an error.
回复: boot使用C40擦写flash

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.

回复: boot使用C40擦写flash

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.


Tags (1)
No ratings
Version history
Last update:
‎07-16-2026 02:35 AM
Updated by: