Hi,
I'm trying to implement code protection in boot loader for RM46L852PGFT. I got AJSM example from this forum and embedded it into my code. Now I have:
AJSM_key.c:
/*
* AJSM_Key.c
*
* Created on: Nov 14, 2014
* Author: a0406448
*/
#pragma DATA_SECTION(AJSM_Key, "AJSM_Sec"); /* Specify Memory Section to link the key to */
#pragma DATA_ALIGN (AJSM_Key, 16); /* Ensure alignment to 128Bit = 16Byte */
#pragma RETAIN (AJSM_Key); /* Ensure that the Key will be linked */
const unsigned int AJSM_Key[4] = {0xAECD0000ul, 0xAECD0001ul, 0xAECD0002ul, 0xAECD0003ul};
/*
* New OTP = AECD0000 AECD0001 AECD0002 AECD0003
* Visible Key = EFFDFFFF FFFFFFFF FFFDFFFE FFEFFFFF
*/
Linker script:
--retain="*(.intvecs)"
MEMORY
{
VECTORS (X) : origin=0x00000000 length=0x00000020 fill=0xFFFFFFFF
FLASH_API (RX) : origin=0x00000020 length=0x000014E0 vfill=0xFFFFFFFF
FLASH0 (RX) : origin=0x00001500 length=0x00010000 vfill=0xFFFFFFFF
/* Bank 0 ECC */
ECC_VEC (R) : origin=(0xf0400000 + (start(VECTORS) >> 3))
length=(size(VECTORS) >> 3)
ECC={algorithm=algoR4F021, input_range=VECTORS}
ECC_FLAA (R) : origin=(0xf0400000 + (start(FLASH_API) >> 3))
length=(size(FLASH_API) >> 3)
ECC={algorithm=algoR4F021, input_range=FLASH_API }
ECC_FLA0 (R) : origin=(0xf0400000 + (start(FLASH0) >> 3))
length=(size(FLASH0) >> 3)
ECC={algorithm=algoR4F021, input_range=FLASH0 }
AJSMKey (R) : origin=0xF0000000 length=0x00000010 vfill=0xffffffff
AJSMECC (R) : origin=0xF0040000 length=(size(AJSMKey) >> 3) ECC={algorithm=algoR4F021, input_range=AJSMKey}
SRAM (RW) : origin=0x08002000 length=0x0002D000
STACK (RW) : origin=0x08000000 length=0x00002000
}
SECTIONS
{
.intvecs : {} > VECTORS
flashAPI :
{
..\Release\Fapi_UserDefinedFunctions.obj (.text)
..\Release\bl_flash.obj (.text)
--library= F021_API_CortexR4_LE_V3D16.lib < FlashStateMachine.IssueFsmCommand.obj
FlashStateMachine.SetActiveBank.obj
FlashStateMachine.InitializeFlashBanks.obj
FlashStateMachine.EnableMainSectors.obj
FlashStateMachine.IssueFsmCommand.obj
FlashStateMachine.ScaleFclk.obj
Init.obj
Utilities.CalculateEcc.obj
Utilities.WaitDelay.obj
Utilities.CalculateFletcher.obj
Read.MarginByByte.obj
Read.Common.obj
Read.FlushPipeline.obj
Read.WdService.obj
Async.WithAddress.obj
Program.obj > (.text)
} load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)
AJSM_Sec : palign(8) {} > AJSMKey
.text : palign(8) {} > FLASH0
.const : palign(8) {} > FLASH0
.cinit : palign(8) {} > FLASH0
.pinit : palign(8) {} > FLASH0
.data : {} > SRAM
.bss : {} > SRAM
}
/*----------------------------------------------------------------------------*/
/* Misc */
ECC {
algoR4F021 : address_mask = 0x003ffff8 /* Address Bits 21:3 */
hamming_mask = R4 /* Use R4 build in Mask */
parity_mask = 0x0c /* Set which ECC bits are Even and Odd parity */
mirroring = F021 /* RM4x are build in F021 */
}
/*----------------------------------------------------------------------------*/
Console output:
CortexR4: GEL Output: Memory Map Setup for Flash @ Address 0x0CortexR4: GEL Output: Memory Map Setup for Flash @ Address 0x0 due to System Reset
CortexR4: Writing Flash @ Address 0x00000000 of Length 0x00000020
CortexR4: Erasing Flash Bank 0, Sector 0
CortexR4: Writing Flash @ Address 0x00000020 of Length 0x00000cc4
CortexR4: Writing Flash @ Address 0x00001500 of Length 0x00007ff0
CortexR4: Erasing Flash Bank 0, Sector 1
CortexR4: Erasing Flash Bank 0, Sector 2
CortexR4: Writing Flash @ Address 0x000094f0 of Length 0x00000720
CortexR4: Writing Flash @ Address 0xf0000000 of Length 0x00000010
CortexR4: Writing Flash @ Address 0xf0040000 of Length 0x00000002
CortexR4: File Loader: Memory write failed: Flash algorithm returned an error during Flash programming. Note: Auto ECC generation is on, please make sure that the data sections are 64-bit memory aligned in your linker file; althernately, turn off Auto ECC generation in the On-Chip Flash settings
CortexR4: GEL: File: C:\Users\Andrus\Documents\ti\boot_uart\Release\boot_uart.out: Load failed.
CortexR4: GEL Output: Memory Map Setup for Flash @ Address 0x0 due to System Reset
result: jtag port is now secured and I cannot access the chip and my code also does not work.
I have 64-bit alignment turned on in project properties and auto ecc generation turned off. What else should I check to pinpoint this issue?