I have a bare metal code based which runs good on ARM Cortex-A7. Now I want run the same code on ARM Cortex-R5 without major change of the code, and keep the 2 projects share the same code base by compiling options. It is easy to identify the target by defining pre-processor marcos in make file and use #ifdef for C language.
It has the similar thing for armcc. Just define flags for ARM assembler like this
--predefine "CORTEX5 SETA 1"
This option defines a marco CORTEXR5, and assign value 1 to it, In the assembly I can easily use (make sure you have tab before IF/ELSE/ENDIF)
IF CORTEXR5 == 1
nop
ELSE ;Cortex-A7
smc #0
ENDIF
An alternative way is to define the marco in assembly source file
GBLA CORTEXR5
CORTEXR5 SETA 1
I prefer the previous one since it is easier to manage thru makefile or DS-5's build configuration.
No comments:
Post a Comment