How to write data into data flash (S32K344)

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

How to write data into data flash (S32K344)

Jump to solution
2,925 Views
Foxconn
Contributor II

Hello, I use the chip of S32K344 and want to write data into data flash (0x10000000).

The dFlashVersion can't write to the data flash!  My method below:

MEMORY
{

   int_dflash : ORIGIN = 0x10000000, LENGTH = 0x00001000

}

SECTION

{

   .dflash:
   {
   . = ALIGN(4);
   KEEP (*(.dflash))
   . = ALIGN(4);
   } > int_dflash

}

__attribute__((section(".dflash"))) const uint8_t dFlashVersion[] =
{0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x11, 0x22};

 

and reference the method : How to set data flash memory in link file - NXP Community

 

Here is my debug configuration, I click the Browse button and didn't find any *.pcp files.

Is this why writing data fails?  Or how to solve it?

Foxconn_0-1677805318872.png

Foxconn_1-1677805381362.png

 

Thanks,

Best Regards.

 

 

 

0 Kudos
Reply
1 Solution
2,905 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Foxconn 

You mentioned that you have S32K344 but the screenshot shows S32K324. Could you confirm what do you have exactly? I know that it's the same device and that we can easily switch between lockstep and decoupled mode but the project should be created for correct derivative in any case. Maybe this is the reason.

I have some project here for S32K344 where boot header is forced to data flash:

lukaszadrapa_0-1677823885589.png

lukaszadrapa_1-1677823892377.png

I use this default configuration:

lukaszadrapa_2-1677823924110.png

 and when loading this project to S32K344, it is successfully programmed:

lukaszadrapa_3-1677823951730.png

Regards,

Lukas

View solution in original post

7 Replies
2,906 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Foxconn 

You mentioned that you have S32K344 but the screenshot shows S32K324. Could you confirm what do you have exactly? I know that it's the same device and that we can easily switch between lockstep and decoupled mode but the project should be created for correct derivative in any case. Maybe this is the reason.

I have some project here for S32K344 where boot header is forced to data flash:

lukaszadrapa_0-1677823885589.png

lukaszadrapa_1-1677823892377.png

I use this default configuration:

lukaszadrapa_2-1677823924110.png

 and when loading this project to S32K344, it is successfully programmed:

lukaszadrapa_3-1677823951730.png

Regards,

Lukas

2,894 Views
Foxconn
Contributor II

Thank you for your support!

I found out that I used another ld file and the section needed to add the address

This will be the solution! (This version writes to dataflash 0x10000000)

 

#define FW_VERSION_LENGTH    16

__attribute__((section(".dflash"))) const uint8_t usFwVersion[FW_VERSION_LENGTH] =
{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00};

 

And I found that the address (0x10000010) is not my data (0x809E4070, 0x01000000), and check the map file can not search the reason. 

Can you analyze it for me?

Foxconn_3-1677828203462.png

Foxconn_4-1677828376487.png

 

Thx

Best Regards.

0 Kudos
Reply
2,882 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

I don't know where it comes from, I would need to see whole map file and linker file, at least.

Regards,

Lukas

0 Kudos
Reply
2,859 Views
Foxconn
Contributor II

Dear Lukas,

I upload an attachment,
I keep track of other information in the data flash. The compiler seems to put the extra data there (behind my data)?

P.S.  if my data configuration flash 0x10000050 and extra data will configuration 0x10000060 (behind my data) by compiler

Foxconn_1-1678070691782.png

 

.dflash 0x10000000 0x10
*(.dflash)
.dflash 0x10000000 0x10 ./src/AppSrc/MainApp.o
0x10000000 usFwVersion

. ARM.extab 0x10000010 0x0
. ARM.extab 0x10000010 0x0 c:/nxp/s32ds.3.4/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/.. /lib/gcc/arm-none-eabi/10.2.0/thumb/v7e-m+fp/hard\libgcc.a(_udivmoddi4.o)

. ARM.exidx 0x10000010 0x8
. ARM.exidx 0x10000010 0x8 c:/nxp/s32ds.3.4/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/.. /lib/gcc/arm-none-eabi/10.2.0/thumb/v7e-m+fp/hard\libgcc.a(_udivmoddi4.o)

.rel.dyn 0x10000018 0x0
.rel.iplt 0x10000018 0x0 ./Project_Settings/Startup_Code/Vector_Table.o

 

THX

Best Regards.

0 Kudos
Reply
2,838 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Foxconn 

I found out that it's internally used by gcc for unwinding for exception handling.

If new application project is created in S32DS without RTD, it's explicitly defined in linker file like this and it's placed to program flash:

.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > PFLASH

__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > PFLASH
__exidx_end = .;

 

It's not present in linker file for RTD project for some reasons. And in your case, it looks like it is somehow forced to data flash by default. Please try to use the above definition in your linker file to force it to program flash. I guess that this could solve your problem.

Regards,

Lukas

2,823 Views
Foxconn
Contributor II

Dear Lukas,

 

Thank you very much for solving my problem.

Return to normal state, there is no redundant data in the data flash.

Foxconn_0-1678150727853.png

 

Other than that, I'm not sure about creating a S32DS new project without an RTD.

My approach is to create an empty project to add the RTD functionality.

Does it have side effects?

Foxconn_1-1678150859942.png

 

THX

Best Regards.

 

0 Kudos
Reply
2,791 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Of course, if you use RTD, create new project with RTD.

I just wanted to highlight that I found that definition in project without RTD. It's not necessary for you to create such project without RTD.

Regards,

Lukas