How to write data into data flash in S32K144 using segger J link?

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

How to write data into data flash in S32K144 using segger J link?

4,115件の閲覧回数
venkatramanc
Contributor I

I am trying to flash some data into the data flash section of S32K144 processor using Segger J-link. I edited the linker file to create a memory section pointing to the data flash sector and set up some data in this section (2 KB data at address 0x10000000) in my application software. When building the software, I could see that the map file and elf contains these sections with the correct number of bytes that I allocated in the linker script. But, when flashing the software, the flashing operation on the data flash memory always fails and the data flash portion is in erased state. Is there any other setting that should be done in S32 design studio to enable writing of data flash?

This is the log from the programming process. We could observe the "Verify Failed" error when flashing. If I remove the data section, the programming succeeds.

-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: on
Init regs on start: on
Silent mode: off
Single run mode: on
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: S32K144
Target interface: SWD
Target interface speed: 1000kHz
Target endian: little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V10 compiled Sep 1 2017 17:45:26
Hardware: V10.10
S/N: 600102326
Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
Checking target voltage...
Target voltage: 4.90 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0x20007000)
Target interface speed set to 1000 kHz
Resetting target
Halting target CPU...
...Target halted (PC = 0x00000410)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20007000, MSP= 20007000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 00000410
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x00000410 (Data = 0xBE00B672)
Select auto target interface speed (2000 kHz)
Flash breakpoints enabled
Semi-hosting enabled (Handle on BKPT)
Semihosting I/O set to TELNET Client
SWO disabled succesfully.
ERROR: Failed to measure CPU clock frequency: second loop count is less than first one! (0<=13150)

Failed to enable SWO. Could not measure target CPU frequency.
Read 4 bytes @ address 0x00000410 (Data = 0xBE00B672)
Read 2 bytes @ address 0x0000350E (Data = 0x2300)
Read 2 bytes @ address 0x00003518 (Data = 0x4A09)
Read 2 bytes @ address 0x00000E9E (Data = 0x2300)
Read 2 bytes @ address 0x00000EA2 (Data = 0xBE00)
Read 2 bytes @ address 0x00000000 (Data = 0x7000)
Read 2 bytes @ address 0x00000002 (Data = 0x2000)
Read 2 bytes @ address 0x00000004 (Data = 0x0411)
Read 2 bytes @ address 0x00000006 (Data = 0x0000)
Read 2 bytes @ address 0x00000008 (Data = 0x0451)
Read 2 bytes @ address 0x0000000A (Data = 0x0000)
Read 2 bytes @ address 0x0000000C (Data = 0x0451)
Read 2 bytes @ address 0x0000000E (Data = 0x0000)
Read 2 bytes @ address 0x00000010 (Data = 0x0451)
Read 2 bytes @ address 0x00000012 (Data = 0x0000)
Read 2 bytes @ address 0x00000014 (Data = 0x0451)
Read 2 bytes @ address 0x00000016 (Data = 0x0000)
Read 2 bytes @ address 0x00000018 (Data = 0x0451)
Read 2 bytes @ address 0x0000001A (Data = 0x0000)
Read 2 bytes @ address 0x0000001C (Data = 0x0000)
Read 2 bytes @ address 0x0000001E (Data = 0x0000)
Read 2 bytes @ address 0x00000020 (Data = 0x0000)
Read 2 bytes @ address 0x00000022 (Data = 0x0000)
Read 2 bytes @ address 0x00000024 (Data = 0x0000)
Read 2 bytes @ address 0x00000026 (Data = 0x0000)
Read 2 bytes @ address 0x00000028 (Data = 0x0000)
Read 2 bytes @ address 0x0000002A (Data = 0x0000)
Read 2 bytes @ address 0x0000002C (Data = 0x0451)
Read 2 bytes @ address 0x0000002E (Data = 0x0000)
Read 2 bytes @ address 0x00000030 (Data = 0x0451)
Read 2 bytes @ address 0x00000032 (Data = 0x0000)
Read 2 bytes @ address 0x00000034 (Data = 0x0000)
Read 2 bytes @ address 0x00000036 (Data = 0x0000)
Read 2 bytes @ address 0x00000038 (Data = 0x0451)
Read 2 bytes @ address 0x0000003A (Data = 0x0000)
Read 2 bytes @ address 0x0000003C (Data = 0xBE00)
Read 2 bytes @ address 0x0000003E (Data = 0x0000)
Read 2 bytes @ address 0x0000003C (Data = 0xBE00)
Read 2 bytes @ address 0x00002FEA (Data = 0x4B07)
Read 2 bytes @ address 0x00002FEA (Data = 0x4B07)
Read 2 bytes @ address 0x00005604 (Data = 0xF007)
Read 2 bytes @ address 0x00005604 (Data = 0xF007)
Read 2 bytes @ address 0x00000412 (Data = 0xBE00)
Read 2 bytes @ address 0x00000412 (Data = 0xBE00)
Read 2 bytes @ address 0x00005604 (Data = 0xF007)
Read 2 bytes @ address 0x00005626 (Data = 0xF007)
Read 2 bytes @ address 0x00002F26 (Data = 0x2300)
Read 2 bytes @ address 0x00002F46 (Data = 0x4B24)
Read 2 bytes @ address 0x0000340E (Data = 0x4B06)
Read 2 bytes @ address 0x0000340E (Data = 0x4B06)
Resetting target
Halting target CPU...
...Target halted (PC = 0x00000410)
Downloading 1024 bytes @ address 0x00000000 - Verified OK
Downloading 16 bytes @ address 0x00000400 - Verified OK
Downloading 4096 bytes @ address 0x00000410 - Verified OK
Downloading 4096 bytes @ address 0x00001410 - Verified OK
Downloading 4096 bytes @ address 0x00002410 - Verified OK
Downloading 4096 bytes @ address 0x00003410 - Verified OK
Downloading 4096 bytes @ address 0x00004410 - Verified OK
Downloading 4096 bytes @ address 0x00005410 - Verified OK
Downloading 4096 bytes @ address 0x00006410 - Verified OK
Downloading 4096 bytes @ address 0x00007410 - Verified OK
Downloading 4096 bytes @ address 0x00008410 - Verified OK
Downloading 4096 bytes @ address 0x00009410 - Verified OK
Downloading 4096 bytes @ address 0x0000A410 - Verified OK
Downloading 4096 bytes @ address 0x0000B410 - Verified OK
Downloading 4096 bytes @ address 0x0000C410 - Verified OK
Downloading 4096 bytes @ address 0x0000D410 - Verified OK
Downloading 4096 bytes @ address 0x0000E410 - Verified OK
Downloading 4096 bytes @ address 0x0000F410 - Verified OK
Downloading 4096 bytes @ address 0x00010410 - Verified OK
Downloading 4096 bytes @ address 0x00011410 - Verified OK
Downloading 1308 bytes @ address 0x00012410 - Verified OK
Downloading 3316 bytes @ address 0x0001292C - Verified OK
Downloading 92 bytes @ address 0x00013620 - Verified OK
Downloading 2048 bytes @ address 0x10000800Comparing flash [....................] Done.
Erasing flash [....................] Done.
Programming flash [....................] Done.
Verifying flash [....................] Done.
- Verify failed
Read 2 bytes @ address 0x0000350E (Data = 0x2300)
Read 2 bytes @ address 0x00000E9E (Data = 0x2300)
Read 2 bytes @ address 0x00000000 (Data = 0x7000)
Read 2 bytes @ address 0x00000002 (Data = 0x2000)
Read 2 bytes @ address 0x00000004 (Data = 0x0411)
Read 2 bytes @ address 0x00000006 (Data = 0x0000)
Read 2 bytes @ address 0x00000008 (Data = 0x0451)
Read 2 bytes @ address 0x0000000A (Data = 0x0000)
Read 2 bytes @ address 0x0000000C (Data = 0x0451)
Read 2 bytes @ address 0x0000000E (Data = 0x0000)
Read 2 bytes @ address 0x00000010 (Data = 0x0451)
Read 2 bytes @ address 0x00000012 (Data = 0x0000)
Read 2 bytes @ address 0x00000014 (Data = 0x0451)
Read 2 bytes @ address 0x00000016 (Data = 0x0000)
Read 2 bytes @ address 0x00000018 (Data = 0x0451)
Read 2 bytes @ address 0x0000001A (Data = 0x0000)
Read 2 bytes @ address 0x0000001C (Data = 0x0000)
Read 2 bytes @ address 0x0000001E (Data = 0x0000)
Read 2 bytes @ address 0x00000020 (Data = 0x0000)
Read 2 bytes @ address 0x00000022 (Data = 0x0000)
Read 2 bytes @ address 0x00000024 (Data = 0x0000)
Read 2 bytes @ address 0x00000026 (Data = 0x0000)
Read 2 bytes @ address 0x00000028 (Data = 0x0000)
Read 2 bytes @ address 0x0000002A (Data = 0x0000)
Read 2 bytes @ address 0x0000002C (Data = 0x0451)
Read 2 bytes @ address 0x0000002E (Data = 0x0000)
Read 2 bytes @ address 0x00000030 (Data = 0x0451)
Read 2 bytes @ address 0x00000032 (Data = 0x0000)
Read 2 bytes @ address 0x00000034 (Data = 0x0000)
Read 2 bytes @ address 0x00000036 (Data = 0x0000)
Read 2 bytes @ address 0x00000038 (Data = 0x0451)
Read 2 bytes @ address 0x0000003A (Data = 0x0000)
Read 2 bytes @ address 0x0000003C (Data = 0x7845)
Read 2 bytes @ address 0x0000003E (Data = 0x0000)
Read 4 bytes @ address 0x00000410 (Data = 0x490BB672)
Read 2 bytes @ address 0x00002FEA (Data = 0x4B07)
Read 2 bytes @ address 0x00005604 (Data = 0xF007)
Read 2 bytes @ address 0x00000412 (Data = 0x490B)
Read 2 bytes @ address 0x00005604 (Data = 0xF007)
Read 2 bytes @ address 0x00002F26 (Data = 0x2300)
Read 2 bytes @ address 0x0000340E (Data = 0x4B06)
Read 2 bytes @ address 0x00005604 (Data = 0xF007)
Read 2 bytes @ address 0x00005604 (Data = 0xF007)
Read 2 bytes @ address 0x00005604 (Data = 0xF007)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20007000, MSP= 20007000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 00000410
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x00000410 (Data = 0x490BB672)
Setting breakpoint @ address 0x0000003C, Size = 2, BPHandle = 0x0001
Setting breakpoint @ address 0x00000412, Size = 2, BPHandle = 0x0002
Setting breakpoint @ address 0x00000EA2, Size = 2, BPHandle = 0x0003
Setting breakpoint @ address 0x00002F46, Size = 2, BPHandle = 0x0004
Setting breakpoint @ address 0x00002FEA, Size = 2, BPHandle = 0x0005
Setting breakpoint @ address 0x0000340E, Size = 2, BPHandle = 0x0006
Setting breakpoint @ address 0x00003518, Size = 2, BPHandle = 0x0007
Setting breakpoint @ address 0x00005604, Size = 2, BPHandle = 0x0008
Setting breakpoint @ address 0x00005626, Size = 2, BPHandle = 0x0009
Starting target CPU...
Erasing flash [........................................Programming flash [....................] Done.
....................Verifying flash [....................] Done.

0 件の賞賛
返信
3 返答(返信)

2,814件の閲覧回数
jiri_kral
NXP Employee
NXP Employee

Hi, 

I did some more research - and I can't find way how to write into FlexNVM with j-link. It can be done with PE Micro - but I did't find way how to add custom commands into J-Link eclispe plugin.  

You need to enable access into data flash by partitioning FlexNVM by writting config values into FCCOB4 and FCCOB5 registers. To use full FlexNVM as a data flash - FCCOB4 should be set to 0x0F and FCCOB5 to 0x0C. You can find more details in S32K144 reference manual. 

Jiri 

0 件の賞賛
返信

2,814件の閲覧回数
venkatramanc
Contributor I

Hello,

Thank you for the details.

I could already write data into the data flash section in FlexNVM from my application software by invoking flash program commands in the FTFC module. But, I needed a way to store some data by directly flashing a binary file through J-link. 

For now, I will add this data as part of the memory section in Program flash memory. I think that should work without any issues. But, I need to find a way to program the data flash in Flex NVM directly by flashing an image.

Let me know if you find any more solution for that.

0 件の賞賛
返信

2,814件の閲覧回数
jiri_kral
NXP Employee
NXP Employee

Hello, 

on the address 0x10000000 begins FlexNVM. I'm not 100% sure - but for writing in this area you have to configure the method of access first (FCFG1 register). It can be done by some custom flash algorithm - but I have no experience with that.  

If you only need to put somewhere into flash memory your 2 kB custom constant data - you can write them into regular 512 kB program flash - in .text section or you can create your own one. 

Jiri

0 件の賞賛
返信