cancel
Showing results for 
Search instead for 
Did you mean: 

How can I inset a specific number into a executive code?

Kim.Andy
Associate III
Posted on January 12, 2018 at 08:22

I have two executive files which there is a little difference between both files.

I want to distinguish two files by inserting a number in the specific place of the executive file.

Is it possible? If then, How can I do that?

8 REPLIES 8
Posted on January 12, 2018 at 08:35

I guess it can be done in the startup file (*.s).

In Keil world:

http://www.keil.com/support/man/docs/armasm/armasm_dom1361290005934.htm

 

No sure what you want to achieve at the high level - maybe the problem can be solved different way.

Posted on January 12, 2018 at 08:36

BTW. LPC processors have CRP marked this way in the memory at specific address:

                IF      :LNOT::DEF:NO_CRP

                AREA    |.ARM.__at_0x02FC|, CODE, READONLY

                DCD     0xFFFFFFFF

                ENDIF
Posted on January 12, 2018 at 12:55

I'd use one of the unused words in the front of the vector table. You could do this by editing the .S file or writing a small C application to modify the word in the .BIN file.

On the STM side use a pointer to access the word.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 15, 2018 at 05:04

Hi, Clive..

How can I settle down this issue in the C level.

Could you give me an example?

Thanks

Posted on January 16, 2018 at 01:53

Hi Bogdan,

I insert your example code in my startup code like the following.

MODULE ?cstartup

;; Forward declaration of sections.

SECTION CSTACK:DATA:NOROOT(3)

SECTION .intvec:CODE:NOROOT(2)

EXTERN __iar_program_start

EXTERN SystemInit

PUBLIC __vector_table

DATA

__vector_table

DCD sfe(CSTACK)

DCD Reset_Handler ; Reset Handler

DCD NMI_Handler ; NMI Handler

----------------------------------------------------------------

END

AREA |.ARM.__at_0x02FC|, CODE, READONLY

DCD 0xFFFFFFFF

But I can't find 0xfffffff at the 0x2FC, defined in the above AREA.

Please refer to the below binary file.

0690X00000609NcQAI.png

Could you let me know what is wrong?

Thanks, Bogdan.

Posted on January 16, 2018 at 02:45

Code past the END is going to be ignored.

From startup.s

...

DATA

__vector_table

DCD sfe(CSTACK)

DCD Reset_Handler ; Reset Handler

DCD NMI_Handler ; NMI Handler

DCD HardFault_Handler ; Hard Fault Handler

DCD MemManage_Handler ; MPU Fault Handler

DCD BusFault_Handler ; Bus Fault Handler

DCD UsageFault_Handler ; Usage Fault Handler

DCD 0 ; Reserved <--- this word at +0x1C

DCD 0 ; Reserved +0x20

DCD 0 ; Reserved +0x24

...

From C

printf('%08X\n', *((uint32_t *)0x0800001C) );

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 16, 2018 at 02:56

>>

Could you let me know what is wrong?

Code past the END is going to be ignored

.

I would avoid AT directive, especially if code is otherwise placed in FLASH at 0x08000000 or 0x08010000

I attached some code, but that post is pending moderation

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 16, 2018 at 07:23

My example was only to show how to use the assembler directive - 2FC location  is reserved by the NXP for LPC MCUs to protect (depending on the stored value) the content.