Difference between revisions of "S32Kxxx"

From SEGGER Wiki
Jump to: navigation, search
Line 1: Line 1:
The NXP S32K14x series is a scalable family of 32-bit ARM Cortex-M4 based MCUs targeted for general purpose automotive and high-reliability industrial applications.
+
The NXP S32Kxxx series is a scalable family of 32-bit ARM Cortex-M4 based MCUs targeted for general purpose automotive and high-reliability industrial applications.
 
__TOC__
 
__TOC__
 
= FlexNVM block partitioning =
 
= FlexNVM block partitioning =

Revision as of 13:38, 12 March 2019

The NXP S32Kxxx series is a scalable family of 32-bit ARM Cortex-M4 based MCUs targeted for general purpose automotive and high-reliability industrial applications.

FlexNVM block partitioning

The S32Kxx series devices come with a FlexNVM area. FlexNVM is an additional separate block of flash memory. The user can configure the FlexNVM block as: Basic data flash, non volatile storage for emulated EEPROM or a combination of both. For further information please refer to the device specific manual from NXP. For programming via J-Link to be successful, the FlexNVM sector must be configured correctly. For this, the "Program Partition command" must be used.

Program Partition command

The Program Partition command sets the partitioning of the FlexNVM block. The changes related to execution of the Program Partition command take effect after the next reset. For FlexNVM to be used as a flash (and/or EEPROM) it has to be partitioned accordingly. Otherwise it is not accessible. Further the flash needs to be in the "erased" state before it can be partitioned (see "Erase All Blocks" command). Note that NXP advises to always erase the chip before partitioning, since the "erased" state might decay over time.

This J-Link Commander example shows how to initialize the FlexNVM section as flash memory only (No EEPROM) using the "Program Partition command".

Setup:

  • J-Link Commander V6.40
  • S32K118EVB-Q064 EvalBoard (256 KB flash memory)
  • J-Link Plus V10

J-Link Commander command line arguments

JLink.exe -device S32K118 -if SWD -speed 4000 -autoconnect 1

Sequence

r                       // Reset target to bring it into a known / proper state
w1 0x40020007, 0x80     // FCOOB0 Program Partition command
w1 0x40020006, 0x00     // FCOOB1 Set CSEc Key Size to 0
w1 0x40020005, 0x00     // FCOOB2 SFE disabled
w1 0x40020004, 0x01     // FCOOB3 0 --> FlexRAM loaded with valid EEPROM data during reset; 1 --> FlexRAM not loaded during reset
w1 0x4002000B, 0x0F     // FCOOB4 Data size for EEPROM Set to 0
w1 0x4002000A, 0x0B     // FCOOB5 Partition Code set to not EEPROM (DEPART)
w1 0x40020000, 0x80     // FSTAT Start operation
sleep 100               // Wait 100ms
q

Check partitioning

By reading the 32-bit FCFG1 register (4004804C) the DEPART bits ([15:12]) show the FlexNVM partition code (Note: The device needs to be power cycled after setting a new partition, since the new DEPART value is refreshed only after power off).

Sequence

mem32 4004804C, 1

Erase All Blocks command

The "Erase All Blocks" command can be used to bring the chip into an erased state. As mentioned in the FlexNVM block partitioning section, the partition can be set after bringing the chip into an erased state. (Note: The chip is also in "secured" state after erasing and is unlocked automatically by connecting to it over J-Link).

Sequence

speed 4000
r // Reset target
w1 0x40020007, 0x44     // FCOOB0 Erase All Blocks command
w1 0x40020000, 0x80     // FSTAT Start operation
sleep 1000              // Wait 1 sec.

Power cycle device. Then connect to it agian and unsecure the chip. After that the Program Partition command can then be used. It is important to powercycle and unsecure the chip before partitioning it. Otherwise the partitioning will be erased by unsecuring the chip again.

Debug Requirements

There are some special requirements that need to be fulfilled in order to use the device series with J-Link:

  • Reset pin of MCU needs to be connected to reset pin of J-Link. If this is not the case, proper target connection cannot be guaranteed

ECC protected internal RAM

The device series provide ECC protected internal RAM. By default, J-Link resets the MCU on connect and initializes the RAM contents to 0x00. This is done for the following reasons:

  • If a memory window in the debugger is open during the debug session and points to a non-initialized RAM region, on the next single step etc. a non-maskable ECC error interrupt would be thrown
  • J-Link temporarily uses some portions of the RAM during flash programming and accesses to non-initialized RAM areas would throw non maskable ECC error interrupts

Readout protection of internal flash

The internal flash of the S32K14x series devices can be protected against unwanted readout accesses. The readout protection is configured via the option bytes placed at addr. 0x400 - 0x40F in the internal flash of the devices.

Enabling protection in production

Make sure that the application image that is programmed contains a value not equal to 0xFE to be programmed to addr. 0x40C. Make also sure that for the device selection in J-Flash etc. the variant S32K... (allow security) is selected. If this is not the case, J-Link will inhibit that the readout protection of the device is set.