5032 views|0 replies

65

Posts

0

Resources
The OP
 

C2000 F2810 The program does not run after encrypting the CSM function [Copy link]

My board is C2000 F2810. When the encryption function is not used, I can debug/run the program in debug/release mode. At least I can see the SCI serial port communication data.

However, after adding the encryption function CSM, I found that the data saved in the RAML0 area could not be read accurately, resulting in the inability to run subsequent programs. I would like to ask for guidance from an expert.

The error location is as follows

if (result != (U16)~pSafe->not_x) --》 pSafe is located at 0x8634 RAML0
{
SciaRegs.SCITXBUF=pSafe->x;
SciaRegs.SCITXBUF=pSafe->not_x; -> Try to read the pSafe->x data, and find that it cannot be read if it is encrypted, and it is 0; it can be read without encryption. Find the reason
CRITICAL_ERROR1(ERR_MEMORY_CORRUPTED); --> After encryption, it will enter this function, causing the subsequent program to fail to execute.
}

The CMD file is as follows:

MEMORY
{
PAGE 0 :
RAMM0 : origin = 0x000000, length = 0x000400
RAML1 : origin = 0x009000, length = 0x001000
CRC : origin = 0x3F0000, length = 0x000001
FLASH : origin = 0x3F0001, length = 0x007F7F

CSM_RSVD : origin = 0x3F7F80, length = 0x000076
BEGIN_FLASH : origin = 0x3F7FF6, length = 0x000002
CSM_PWL : origin = 0x3F7FF8, length = 0x000008

//BEGIN_H0 : origin = 0x3F8000, length = 0x000002
RAMH0 : origin = 0x3F8000, length = 0x002000 /*2b00*/
BOOTROM : origin = 0x3FF000, length = 0x000FC0
RESET : origin = 0x3FFFC0, length = 0x000002

PAGE 1 :
RAMM 1: origin= 0x000400, length = 0x000480
RAML0 : origin = 0x008000, length = 0x001000
}


SECTIONS
{
/* CSM Password Locations */
passwords : > CSM_PWL, PAGE = 0
csm_rsvd : > CSM_RSVD, PAGE = 0


codestart_rom : > BEGIN_FLASH, PAGE = 0
.romtext : > FLASH, PAGE = 0

/* DSECT */
.reset : > RESET, PAGE = 0, TYPE = DSECT
//vectors : > VECTORS PAGE = 0, TYPE = DSECT

/*** Uninitialized Sections ***/
/* Allocate data areas: */
.stack : > RAMM1, PAGE = 1
//.ebss : > RAMM1|RAML0, PAGE = 1
.ebss1 : {
.\selftest\post. obj (.ebss)
.\error\error.obj (.ebss)
} > RAMM1, PAGE = 1
.ebss2 : {
ebss_start = .;
*(.ebss)
ebss_end = .;
} > RAML0, PAGE = 1

.sysmem: > RAML0, PAGE = 1

/*** Initialized Sections ***/
.cinit : > FLASH, PAGE = 0
.switch : > FLASH, PAGE = 0

/*.econst : {* (.econst)}
LOAD = FLASH, PAGE = 0
RUN = RAML0, PAGE = 1
RUN_START(_econst_run_start),
LOAD_START(_econst_load_start),
LOAD_END(_econst_load_end)*/

.econst1 : {
//.\selftest\crc16.obj (.econst)
} > FLASH, PAGE = 0

.econst2 : {* (.econst)}
LOAD = FLASH, PAGE = 0
RUN = RAML0, PAGE = 1
RUN_START(_econst_run_start),
LOAD_START(_econst_load_start),
LOAD_END(_econst_load_end)

/*.text : {*(.text)}
LOAD = FLASH, PAGE = 0
RUN = RAMH0, PAGE = 0
RUN_START(_text_h0_run_start),
LOAD_START(_text_h0_load_start),
LOAD_END(_text_h0_load_end)*/

.text1 : {
.\app\rfapp.obj (.text)
.\driver\sci_drv.obj (.text)
.\error\error.obj (.text)
.\selftest\post.obj (.text)
.\ selftest\background.obj (.text)
//.\selftest\crc16.obj (.text)
.\driver\eeprom_drv.obj (.text)
.\param\param.obj (.text)
} > FLASH, PAGE = 0

.text2 : {
.\control\control.obj (.text)
} LOAD = FLASH, PAGE = 0
RUN = RAML1, PAGE = 0
RUN_START(_text_l1_run_start),
LOAD_START(_text_l1_load_start),
LOAD_END(_text_l1_load_end)

.text3 : {*(.text)}
LOAD = FLASH, PAGE = 0
RUN = RAMH0, PAGE = 0
RUN_START(_text_h0_run_start),
LOAD_START(_text_h0_load_start),
LOAD_END(_text_h0_load_end)

.CRC_keep : > CRC, PAGE = 0

IQmath: LOAD = FLASH, PAGE = 0
RUN = RAMM0, PAGE = 0
RUN_START(_iqmath_run_start),
LOAD_START(_iqmath_load_start),
LOAD_END(_iqmath_load_end)

IQmathTables: LOAD = BOOTROM, PAGE = 0, TYPE=NOLOAD
}

Codestart changes are as follows

.def _start
.ref _c_int00
.ref __STACK_SIZE
.ref _PostExec

.ref ebss_start
.ref ebss_end

.IF (_DEBUG == 0)
.ref _text_h0_run_start
.ref
_text_h0_load_start .ref _text_h0_load_end
.ref _text_l1_run_start .ref _ text_l1_load_start .ref _text_l1_load_end
.ref _econst_run_start .ref _econst_load_start .ref _econst_load_end .ref _iqmath_run_start .ref _iqmath_load_start .ref _iqmath_load_end .ENDIF







;
; If we are in debug mode then jump straight to _c_int00 because the
; debugger has already transferred all of the code from flash to RAM
;
.if (_DEBUG == 0)
.sect "codestart_rom"
LB _start
.else
.sect "codestart_h0 "
LB _start
.endif

.IF (_DEBUG == 0)
.sect "passwords"
.int 0xFFFF ; PWL0 (LSW of 128-bit password)
.int 0xFFFF
.int 0xFFFF
.int 0xFFFF
.int 0xFFFF
.int 0xFFFF
.int 0xFFFF
.int 0xFFFF ; PWL7 ( MSW of 128-bit password)

.sect ".CRC_keep"
.int 0x4B52

.sect "csm_rsvd"
.loop (0x3F7FF5 - 0x3F7F80 + 1)
.int 0x0000
.endloop
.ENDIF

;--------------------------------------------------
; This function copies the code from the ROM and into
; the RAM. It then transfers control to _c_int00.
;-------------------------- ------------------
.sect ".romtext"
_start:
MOV @SP,#0x0400 ; Initialize the stack pointer
SETC OBJMODE
CLRC AMODE
SETC M0M1MAP
CLRC PAGE0

;---- -------------------------------------------------- ----------------
; disable the internal watchdog.
; We only use the external watchdog.
;------------------- -------------------------------------------------- -
EALLOW
MOVZ DP,#0x7028>>6; Set data page for WDCR register
MOV @0x7029,#0x0068; Set WDDIS bit in WDCR to disable WD

;----------------- -------------------------------------------------- ---
; On TMX samples, to get the best performance of on chip RAM blocks
; M0/M1/L0/L1/H0 internal control registers bit have to be enabled.
; The bits are in Device emulation registers.
;---------------------- ---------------------------------------------
;DevEmuRegs .M0RAMDFT = 0x0300;
; DevEmuRegs.M1RAMDFT = 0x0300;
; DevEmuRegs.L0RAMDFT =
0x0300;
; DevEmuRegs.L1RAMDFT = 0x0300; V

@
0x7021
,#0x000A

; Wait for PLL to lock
MOV AR0,#5000
settle_loop:
BANZ settle_loop,AR0-- ; Loop until AR0 == 0, post-decrement AR0

; HISPCP/LOSPCP prescale register settings, normally it will be set to
; default values
MOV @0x701A,#0x0001 ; Set HISPCP
MOV @0x701B,#0x0000 ; Set LOSPCP

; Enable the periperal clocks
MOV @0x701C,#0x1509 ; Enable the MCBSP, SCIA, SPI, EVA, and ADC clocks

EDIS

;------------------------------------------------- ---------------------
; Read the password locations - this will unlock the
; CSM only if the passwords are erased. Otherwise it
; will not have an effect.
; -------------------------------------------------- --------------------
MOVL XAR1,#0x3F7FF8;
MOVL XAR0,*XAR1
++
MOVL XAR0,*XAR1 ++
MOVL

-------------------------------------------------- ------------------
;Perform the Power On Self Test
;--------------------------------- ------------------------------------------
LCR #_PostExec

;------------------------------------------------- --------------------------
; fill the stack
;-------------------------- -----------------------------------------------
MOVL XAR5,# 0x0400
MOV AL,#0xBEEF
MOV AR0,#__STACK_SIZE - 1

loop4:
MOV *XAR5++,AL
BANZ loop4,AR0-- ; Loop until count == 0, post-decrement count


;------------------------------------------------- --------------------------
; fill the ".ebss" segment with 0
;-------------------------- -------------------------------------------------- --
MOVL XAR5,#ebss_start
MOV AL,#0x0
MOV AR0,#(ebss_end - ebss_start - 1)

loop9:
MOV *XAR5++,AL
BANZ loop9,AR0-- ; Loop until count == 0, post-decrement count

;------------------------------------------------- ---------------------
; copy the .text section from FLASH to RAM
;------------------ -------------------------------------------------- --
.if (_DEBUG == 0 )
MOVL


BF endloop,EQ ; if the counter is zero then skip over the copy

loop:
MOV ACC,*XAR6++
MOV *XAR5++,ACC
BANZ loop,AR0-- ; Loop until AR0 == 0, post-decrement AR0

endloop:

MOVL XAR5,#_text_l1_run_start
MOVL XAR6,#_text_l1_load_start
MOV AR0,#(_text_l1_load_end - _text_l1_load_start - 1)
MOV ACC,AR0

BF endloop99,EQ ; if the counter is zero then skip over the copy

loop99:
MOV ACC,*XAR6++
MOV *XAR5++,ACC
BANZ loop99,AR0-- ; Loop until AR0 == 0, post-decrement AR0

endloop99:

.endif

;------------------------------------------------- ---------------------
; copy the .econst section from FLASH to RAM
;------------------ -------------------------------------------------- --
.if (_DEBUG == 0)
MOVL XAR5,#_econst_run_start
MOVL XAR6,#_econst_load_start
MOV AR0,#(_econst_load_end - _econst_load_start - 1)
MOV ACC,AR0

BF endloop2,EQ ; if the counter is zero then skip over the copy

loop2:
MOV ACC,*XAR6++
MOV *XAR5++,ACC
BANZ loop2,AR0-- ; Loop until AR0 == 0, post-decrement AR0

endloop2:
.endif

;------------------------------------------------- ---------------------
; copy the iqmath section from FLASH to RAM
;------------------ -------------------------------------------------- -
.if (_DEBUG == 0)
MOVL XAR5,#_iqmath_run_start
MOVL XAR6,#_iqmath_load_start
MOV AR0,#(_iqmath_load_end - _iqmath_load_start - 1)
MOV ACC,AR0

BF endloop3,EQ ; if the counter is zero then skip over the copy

loop3:
MOV ACC,*XAR6++
MOV *XAR5++,ACC
BANZ loop3,AR0-- ; Loop until AR0 == 0, post-decrement AR0

endloop3:
.endif

;------------------------------------------------- ---------------------
; call the c run time initialization
;--------------------- --------------------------------------------------
LB _c_int00

.sect ".text"

.def _EnterCritical

_EnterCritical:
PUSH DP:ST1 ; We don't card about the DP register,
; but the POP ACC instruction will
; remove 2 words from the stack, so
; we need to put two words on the stack.
POP ACC
DINT
LRETR

.def _ExitCritical
_ExitCritical:
AND ACC,#1
SB SKIP,NEQ ; branch if bit is set
EINT
SKIP:
LRETR

.end

This post is from Microcontroller MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>
Featured Posts
PIC series microcontroller programming basics

This book is a great help to those who want to learn PIC microcontrollers. This book is a basic tutorial book and a good ...

During the epidemic prevention and control, don’t forget to have a date with spring!

Activity link: During the epidemic prevention and control, don’t forget to have a date with spring! Works Summary: " Da ...

TI C2000 LaunchPad uses official routines to compile and debug

488551488552488553488554488555488555488556488557488558488559

Hybrid beamforming: the new main force of future 5G construction

Beamforming is a mature technology used in cellular communications and other applications. Beamforming was originally de ...

[Flower carving DIY] Interesting and fun music visualization series of small projects (07) --- large square spectrum light

I had the urge to do a series of topics on sound visualization. This topic is a bit difficult and covers a wide range of ...

36 "Ten Thousand Miles" Raspberry Pi Car——ROS Learning (VSCode to Implement Hello World)

It is very convenient to run ROS projects in VSCode. In this section, we use ROS to write and run the "Hello world" pro ...

[HPM-DIY] HPM6750 USB open source protocol stack performance comparison - cherryusb or tinyusb?

Since the current hpm SDK uses tinyusb, the performance speed is still extremely unmatched with the high-speed USB of t ...

[The strongest open source] Hand-rubbed 120W switching power supply

I recently took the time to make a switching power supply 645265 645262 645263 645264 645261 645260

Network port isolation transformer network cable side protection and routing

662606 As shown in the figure above, the upper side is a network port isolation transformer, U43 is a clamping diode, th ...

Specific working principle of no-load protection circuit

668703 668704 The specific working principle of the no-load protection circuit, For example, if the input sine wave a ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list