Some issues encountered during Flash driver development on S32K344 under the RTD 4.0.0 environment

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Some issues encountered during Flash driver development on S32K344 under the RTD 4.0.0 environment

34件の閲覧回数
yunaidejiezi
Contributor II
Hi everyone,
I'm currently working on a Flash driver that runs in SRAM (specifically, in DTCM without cache enabled for convenience). I've run into some issues and would appreciate your insights.
Project background:
I have two projects: one includes the C40 driver, and the other (which I'll call fls_drv_demo) does not. My goal is to compile the driver in the C40-enabled project, place it at address 0x00500000 via the AT linker directive, and then in fls_drv_demo, use memcpy to copy it to the intended DTCM address. After that, I hardcode the function addresses and call them to observe Flash behavior changes for verification.
What I've done so far:
  • In the C40-enabled project, I placed all C40 IP-layer functions into the .ramcode section and collected them in the flash_driver section.
  • Custom functions for initialization and programming are placed in the .Fls_Api_Tab section, also collected into flash_driver.
  • Linker scripts have been modified accordingly.
The current problem:
In the fls_drv_demo project, when I call a function pointer—whether it's Fls_Init or a programming function like
((uint32_t (*)(const uint32_t, const uint8_t*, const uint32_t))(0x2000702C | 1))(0x00540000, flswritearray, 16);
—the execution always jumps to 0x00406764 after some internal IP-layer function completes.
Specifically:
  • Fls_Init executes successfully.
  • However, during the write function, after the internal C40_Ip_MainInterfaceSectorErase finishes and is about to return (pop), the PC pointer ends up at 0x00000000.
My suspicion:
I'm wondering whether some internal functions are still being compiled into .text or .mcal.text sections, causing the program to access the wrong stub area and leading to this behavior. Or is there some additional setup step I'm missing?
I'm completely stuck at this point and would really appreciate any suggestions or guidance.
Apologies if the phrasing is a bit off—this was translated with AI assistance. I've attached some screenshots of the project and the issue for reference.
Thanks in advance!
 
Linker file configuration in the C40 driver project
20260825-102549.jpg
The .map file (function and stub region address allocation) generated after modifying the linker in the C40 driver project
20260825-103800.jpg20260825-103746.jpg
 
The specific contents of the fls_drv_demo project
20260825-103909.jpg
 
  1. When running the write function (at 0x2000702C), it goes into the internal RTD library function C40_Ip_MainInterfaceSectorErase (at 0x200074EC). At 0x20007502, it jumps to 0x20007B52, and then the PC points to the address stored at 0x20007B54, which is 0x00406764. Subsequently, when executing the pop instruction at 0x00406778, the value of r3 is as shown in the figure, pointing to 0x2001FFD8. 0x2001FFD8 then points to 0x20007BA8, and the value at 0x7BA8 is 0x00000000, causing the program to crash/run away.
20260825-105216.jpg
20260825-110659.jpg20260825-110639.jpg20260825-110710.jpg1.jpg2.jpg
20260825-111431.jpg20260825-130859.jpg20260825-130909.jpg
0 件の賞賛
返信
1 返信

danielmartynek
NXP TechSupport
NXP TechSupport

Hi @yunaidejiezi,

Based on the disassembly, you forgot to move the OsIf_SuspendAllInterrupts() function to DCTM, all the functions called by the C40_Ip driver must be in DCTM.

I would recommend using the Mem_43_InFls MCAL driver, which handles the copy-to-RAM automatically at runtime and avoids all of this manual dependency tracking.

 

BR, Daniel

0 件の賞賛
返信