how to write data flash (S32K328)

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

how to write data flash (S32K328)

706 Views
canghai
Contributor I

I want to store some boot information in the dataflash area when designing the boot. Is there any related routine documentation that can be used as a reference? Currently, I have used AI to generate some operation methods (registers, c40uip), but none of them have been successful, and I don't know how to find the cause。

0 Kudos
Reply
2 Replies

679 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

There are RTD drivers, specifically Mem_43_INFLS (RTD 6.0.0):

https://www.nxp.com/design/design-center/software/automotive-software-and-tools/real-time-drivers-rt...

Pay attention to example 

C40_Ip_Example_S32K358

/**
* @brief Main function of the example
* @details Initializes IP C40 driver and erase, write, read internal flash memory
*/

0 Kudos
Reply

647 Views
canghai
Contributor I

Thank you, but I encountered a problem when using C40_SP for flash operations:

the boot is at core0 0x00400000, and when I perform a write operation on the address of core0 (0x00440000), it enters a hard fault. I confirm that the boot area code is only before 0x00440000 and there is no out of bounds issue, but operating on core1 area (0x00600000) with the same code is not a problem. What is the reason for this.

My rewrote code is as follow

/************ erase code******************/

if (C40_IP_STATUS_SECTOR_PROTECTED == C40_Ip_GetLock(sector_number)) {
printf("RAM: Sector %d is protected, clearing lock\r\n", sector_number);
C40_Ip_ClearLock(sector_number, 0);
}

C40_Ip_MainInterfaceSectorErase(sector_number, 0);do {
t_ReturnValue = C40_Ip_MainInterfaceSectorEraseStatus();
} while (C40_IP_STATUS_BUSY == t_ReturnValue);

 

/************ write code******************/

C40_Ip_MainInterfaceWrite(addr, length, data, 0);
do {
t_ReturnValue = C40_Ip_MainInterfaceWriteStatus();
} while (C40_IP_STATUS_BUSY == t_ReturnValue);

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2189736%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ehow%20to%20write%20data%20flash%20(S32K328)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2189736%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20want%20to%20store%20some%20boot%20information%20in%20the%20dataflash%20area%20when%20designing%20the%20boot.%20Is%20there%20any%20related%20routine%20documentation%20that%20can%20be%20used%20as%20a%20reference%3F%20Currently%2C%20I%20have%20used%20AI%20to%20generate%20some%20operation%20methods%20(registers%2C%20c40uip)%2C%20but%20none%20of%20them%20have%20been%20successful%2C%20and%20I%20don't%20know%20how%20to%20find%20the%20cause%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2192599%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20how%20to%20write%20data%20flash%20(S32K328)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2192599%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%2C%20but%20I%20encountered%20a%20problem%20when%20using%20C40_SP%20for%20flash%20operations%3A%3C%2FP%3E%3CP%3Ethe%20boot%20is%20at%20core0%200x00400000%2C%20and%20when%20I%20perform%20a%20write%20operation%20on%20the%20address%20of%20core0%20(0x00440000)%2C%20it%20enters%20a%20hard%20fault.%20I%20confirm%20that%20the%20boot%20area%20code%20is%20only%20before%200x00440000%20and%20there%20is%20no%20out%20of%20bounds%20issue%2C%20but%20operating%20on%20core1%20area%20(0x00600000)%20with%20the%20same%20code%20is%20not%20a%20problem.%20What%20is%20the%20reason%20for%20this.%3C%2FP%3E%3CP%3EMy%20rewrote%20code%20is%20as%20follow%3C%2FP%3E%3CP%3E%2F************%20erase%20code******************%2F%3C%2FP%3E%3CP%3Eif%20(C40_IP_STATUS_SECTOR_PROTECTED%20%3D%3D%20C40_Ip_GetLock(sector_number))%20%7B%3CBR%20%2F%3Eprintf(%22RAM%3A%20Sector%20%25d%20is%20protected%2C%20clearing%20lock%5Cr%5Cn%22%2C%20sector_number)%3B%3CBR%20%2F%3EC40_Ip_ClearLock(sector_number%2C%200)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3EC40_Ip_MainInterfaceSectorErase(sector_number%2C%200)%3Bdo%20%7B%3CBR%20%2F%3Et_ReturnValue%20%3D%20C40_Ip_MainInterfaceSectorEraseStatus()%3B%3CBR%20%2F%3E%7D%20while%20(C40_IP_STATUS_BUSY%20%3D%3D%20t_ReturnValue)%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%2F************%20write%20code******************%2F%3C%2FP%3E%3CP%3EC40_Ip_MainInterfaceWrite(addr%2C%20length%2C%20data%2C%200)%3B%3CBR%20%2F%3Edo%20%7B%3CBR%20%2F%3Et_ReturnValue%20%3D%20C40_Ip_MainInterfaceWriteStatus()%3B%3CBR%20%2F%3E%7D%20while%20(C40_IP_STATUS_BUSY%20%3D%3D%20t_ReturnValue)%3B%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2190129%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20how%20to%20write%20data%20flash%20(S32K328)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2190129%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThere%20are%20RTD%20drivers%2C%20specifically%26nbsp%3BMem_43_INFLS%20(RTD%206.0.0)%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdesign%2Fdesign-center%2Fsoftware%2Fautomotive-software-and-tools%2Freal-time-drivers-rtd%3AAUTOMOTIVE-RTD%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.nxp.com%2Fdesign%2Fdesign-center%2Fsoftware%2Fautomotive-software-and-tools%2Freal-time-drivers-rtd%3AAUTOMOTIVE-RTD%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EPay%20attention%20to%20example%26nbsp%3B%3C%2FP%3E%0A%3CP%3EC40_Ip_Example_S32K358%3C%2FP%3E%0A%3CP%3E%2F**%3CBR%20%2F%3E*%20%40brief%20Main%20function%20of%20the%20example%3CBR%20%2F%3E*%20%40details%20Initializes%20IP%20C40%20driver%20and%20erase%2C%20write%2C%20read%20internal%20flash%20memory%3CBR%20%2F%3E*%2F%3C%2FP%3E%3C%2FLINGO-BODY%3E