how to write data flash (S32K328)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

how to write data flash (S32K328)

256 次查看
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 项奖励
回复
2 回复数

229 次查看
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 项奖励
回复

197 次查看
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 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-2189736%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%A6%82%E4%BD%95%E5%86%99%E5%85%A5%E9%97%AA%E5%AD%98%E6%95%B0%E6%8D%AE%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%3E%E8%AE%BE%E8%AE%A1%E5%90%AF%E5%8A%A8%E6%97%B6%EF%BC%8C%E6%88%91%E6%83%B3%E5%9C%A8%E6%95%B0%E6%8D%AE%E9%97%AA%E5%AD%98%E5%8C%BA%E5%9F%9F%E5%AD%98%E5%82%A8%E4%B8%80%E4%BA%9B%E5%90%AF%E5%8A%A8%E4%BF%A1%E6%81%AF%E3%80%82%E6%98%AF%E5%90%A6%E6%9C%89%E4%BB%BB%E4%BD%95%E7%9B%B8%E5%85%B3%E7%9A%84%E4%BE%8B%E8%A1%8C%E6%96%87%E6%A1%A3%E5%8F%AF%E4%BB%A5%E7%94%A8%E4%BD%9C%E5%8F%82%E8%80%83%EF%BC%9F%E7%9B%AE%E5%89%8D%EF%BC%8C%E6%88%91%E4%BD%BF%E7%94%A8%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD%E7%94%9F%E6%88%90%E4%BA%86%E4%B8%80%E4%BA%9B%E6%93%8D%E4%BD%9C%E6%96%B9%E6%B3%95%EF%BC%88%E5%AF%84%E5%AD%98%E5%99%A8%E3%80%81c40uip%EF%BC%89%EF%BC%8C%E4%BD%86%E9%83%BD%E6%B2%A1%E6%9C%89%E6%88%90%E5%8A%9F%EF%BC%8C%E6%88%91%E4%B8%8D%E7%9F%A5%E9%81%93%E5%A6%82%E4%BD%95%E6%89%BE%E5%88%B0%E5%8E%9F%E5%9B%A0%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%3E%E8%B0%A2%E8%B0%A2%EF%BC%8C%E4%BD%86%E6%88%91%E5%9C%A8%E4%BD%BF%E7%94%A8%20C40_SP%20%E8%BF%9B%E8%A1%8C%E9%97%AA%E5%AD%98%E6%93%8D%E4%BD%9C%E6%97%B6%E9%81%87%E5%88%B0%E4%BA%86%E4%B8%80%E4%B8%AA%E9%97%AE%E9%A2%98%EF%BC%9A%3C%2FP%3E%3CP%3E%E5%90%AF%E5%8A%A8%E6%97%B6%E5%A4%84%E4%BA%8E%E6%A0%B8%E5%BF%830%200x00400000%EF%BC%8C%E5%BD%93%E6%88%91%E5%AF%B9%E6%A0%B8%E5%BF%830%EF%BC%880x00440000%EF%BC%89%E7%9A%84%E5%9C%B0%E5%9D%80%E6%89%A7%E8%A1%8C%E5%86%99%E5%85%A5%E6%93%8D%E4%BD%9C%E6%97%B6%EF%BC%8C%E5%AE%83%E4%BC%9A%E8%BF%9B%E5%85%A5%E7%A1%AC%E6%95%85%E9%9A%9C%E3%80%82%E6%88%91%E7%A1%AE%E8%AE%A4%E5%90%AF%E5%8A%A8%E5%8C%BA%E4%BB%A3%E7%A0%81%E4%BB%85%E5%9C%A8%200x00440000%20%E4%B9%8B%E5%89%8D%EF%BC%8C%E4%B8%8D%E5%AD%98%E5%9C%A8%E8%B6%8A%E7%95%8C%E9%97%AE%E9%A2%98%EF%BC%8C%E4%BD%86%E6%98%AF%E4%BD%BF%E7%94%A8%E7%9B%B8%E5%90%8C%E7%9A%84%E4%BB%A3%E7%A0%81%E5%9C%A8%20core1%20%E5%8C%BA%E5%9F%9F%20(0x00600000)%20%E4%B8%8A%E6%93%8D%E4%BD%9C%E4%B8%8D%E6%98%AF%E9%97%AE%E9%A2%98%E3%80%82%E5%8E%9F%E5%9B%A0%E4%BD%95%E5%9C%A8%EF%BC%9F%3C%2FP%3E%3CP%3E%E6%88%91%E9%87%8D%E5%86%99%E7%9A%84%E4%BB%A3%E7%A0%81%E5%A6%82%E4%B8%8B%3C%2FP%3E%3CP%3E%2F************%20%E6%93%A6%E9%99%A4%E4%BB%A3%E7%A0%81******************%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%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)%EF%BC%9B%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)%EF%BC%9B%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%3E%E6%9C%89%20RTD%20%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F%EF%BC%8C%E7%89%B9%E5%88%AB%E6%98%AF%20Mem_43_INFLS%EF%BC%88RTD%206.0.0%EF%BC%89%EF%BC%9A%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%3E%E6%B3%A8%E6%84%8F%E8%8C%83%E4%BE%8B%20%3C%2FP%3E%0A%3CP%3EC40_Ip_Example_S32K358%3C%2FP%3E%0A%3CP%3E%2F**%3CBR%20%2F%3E*%20%40brief%20%E7%A4%BA%E4%BE%8B%E7%9A%84%E4%B8%BB%E8%A6%81%E5%8A%9F%E8%83%BD%3CBR%20%2F%3E*%20%40details%20%E5%88%9D%E5%A7%8B%E5%8C%96%20IP%20C40%20%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F%EF%BC%8C%E6%93%A6%E9%99%A4%E3%80%81%E5%86%99%E5%85%A5%E3%80%81%E8%AF%BB%E5%8F%96%E5%86%85%E9%83%A8%E9%97%AA%E5%AD%98%3CBR%20%2F%3E*%2F%3C%2FP%3E%3C%2FLINGO-BODY%3E