S32K148 Enabling CSEc Issues The problem I'm having is this: The board has been programmed and executed, and the previous program did not have CSEc enabled, so the value of uCSEcKeySize is set to 0 when initializing the EEP time zone. Now to enable CSEc, use AES-128-CMAC to verify the firmware, because this time I run S32_SDK_S32K1xx_RTM_4.0.2\examples\S32K148\driver_examples\system\csec_keyconfig to repartition and use Debug_ RAM configuration for compilation and debugging, the return value of FLASH_DRV_EraseAllBlock is successful, FLASH_DRV_DEFlashPartition fails because the value of the ACCERR bit of FTFC- >FSTAT in the FLASH_DRV_CommandSequence function is 1. Also I used jlink's erase chip feature to erase the data with the same result. What can I do about it? Re: S32K148启用CSEc问题 The parameters seem to be correct.
What is the meaning of this?
uint8_t cseKeySize = *(volatile uint8_t *)0x40020005U; if (flashSSDConfig.EEESize == 0 || cseKeySize == 0U) {
This is an address of FCC0B2 register. I can't see a reason to read the register here.
Could you read the content of FCFG1 register in SIM module? If Erase All Blocks command was successful, the EEERAMSIZE and DEPART bit fields should be reset to '1's after next reset.
Are any flash blocks protected? Could you take a screenshot of flash configuration field at 0x400 - 0x40F?
Regards,
Lukas Re: S32K148启用CSEc问题 Hi Lukas, The contents of my `initFlashForCsecOperation` function are as follows: void initFlashForCsecOperation(void) { flash_ssd_config_t flashSSDConfig; status_t status = FLASH_DRV_Init(&flash1_InitConfig0, &flashSSDConfig); if (status != STATUS_SUCCESS) { return; } uint8_t cseKeySize = *(volatile uint8_t *)0x40020005U; if (flashSSDConfig.EEESize == 0 || cseKeySize == 0U) { #ifdef FLASH_TARGET PINS_DRV_ClearPins(LED_PORT, 1 << LED_OK); #else uint32_t address; uint32_t size; #if (FEATURE_FLS_HAS_PROGRAM_PHRASE_CMD == 1u) uint8_t unsecure_key[FTFx_PHRASE_SIZE] = {0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFEu, 0xFFu, 0xFFu, 0xFFu}; #else /* FEATURE_FLASH_HAS_PROGRAM_LONGWORD_CMD */ uint8_t unsecure_key[FTFx_LONGWORD_SIZE] = {0xFEu, 0xFFu, 0xFFu, 0xFFu}; #endif /* FEATURE_FLS_HAS_PROGRAM_PHRASE_CMD */ status = FLASH_DRV_EraseAllBlock(&flashSSDConfig); if (status != STATUS_SUCCESS) { return; } status = FLASH_DRV_Init(&flash1_InitConfig0, &flashSSDConfig); #if (FEATURE_FLS_HAS_PROGRAM_PHRASE_CMD == 1u) address = 0x408u; size = FTFx_PHRASE_SIZE; #else /* FEATURE_FLASH_HAS_PROGRAM_LONGWORD_CMD == 1u */ address = 0x40Cu; size = FTFx_LONGWORD_SIZE; #endif /* FEATURE_FLS_HAS_PROGRAM_PHRASE_CMD */ status = FLASH_DRV_Program(&flashSSDConfig, address, size, unsecure_key); if (status != STATUS_SUCCESS) { return; } status = FLASH_DRV_DEFlashPartition(&flashSSDConfig, 0x2, 0x4, 0x3, true, true); if (status != STATUS_SUCCESS) { return; } #endif /* FLASH_TARGET */ } } I use the chip as shown in the figure below: Re: S32K148启用CSEc问题 Hi @AllanZhou
How did you set parameters for FLASH_DRV_DEFlashPartition?
There’s a list of possible issues when this command returns ACCERR:
Regards,
Lukas Re: S32K148启用CSEc问题 Hi lukaszadrapa, My goal is to read the value of `uCSEcKeySize` from the last partitioning operation; if it is 0, I will perform the partitioning again. The value of the FCFG1 register is 0xFF32F000 Re: S32K148启用CSEc问题 Yes, SIM->FCFG1 0xFF32F000 is correct default value when the device is not partitioned yet. After partitioning using these parameters, you should see 0xFF324000.
So, the EraseAllBlocks command obviously works, there’s no problem. The parameters for FLASH_DRV_DEFlashPartition are correct. The code is running from RAM. There are not many options now.
Could you try to hide all flash memory windows in your debugger to ensure that the debugger does not access flash memory while the device is being partitioned?
Do you have more boards? Are you facing the same behavior on all of them?
Regards,
Lukas Re: S32K148启用CSEc问题 Hi lukaszadrapa, I've already replaced the board, but I'm still having the same issue. Does this have anything to do with the chip model I'm using? Does the second “F” in FS32K148HFVLQ indicate that there is no security module? Re: S32K148启用CSEc问题 Hi @AllanZhou
You are absolutely right, I'm sorry for confusion. I was somehow under impression that S32K148 has always security feature but I was wrong, my memory betrayed me:
Yes, you need to order a derivative which has Security feature.
Regards,
Lukas
查看全文