1 Compilation Related¶
1.1 How to disassemble axf files into asm assembly or bin files¶
Use Keil’s fromelf.exe toolFirst place the axf file that needs to be disassembled inC:\Keil_v5\ARM\ARMCC\bin
,
Then type the command in the cmd window:
c:\Keil_v5\ARM\ARMCC\bin\fromelf.exe lcpu_rom.axf --text -c >lcpu_rom.asm
c:\Keil_v5\ARM\ARMCC\bin\fromelf.exe hcpu.axf --text -c >hcpu.asm
Output bin file from axf file:
c:\Keil_v5\ARM\ARMCC\bin\fromelf.exe --bin --output=./lcpuaxf.bin ./lcpu.axf
1.2 Supported compilers and versions¶
Keil, recommended version:
GCC, recommended version:
1.3 Default Lcpu project path in SDK project¶
Please see the screenshot below during compilation, there is a copy operation,
The file …….\rom_bin\lcpu_general_ble_img\lcpu_lb551.c comes from the compilation of sdk\example\ble\lcpu_general\project\ec-lb551\ project
The specific code copy operations are in the prebuild.bat batch file before compilation and the postbuild.bat batch file after compilation in the corresponding project directory.
scons –target=mdk5 will run the following
Compiling with Keil prompts as follows:
keilExecute batch configuration before and after compilation, See issue.:2.3.1
1.4 How unused global variables are compiled without being optimized¶
For the convenience of debugging, some values are placed in a global variable for easy viewing. Unused variables at this time will be optimized,
You can add the declaration volatile in front when defining the variable, so it won’t be optimized,As follows:
volatile uint32_t flash_dev_id=0xffffffff;
1.5 How to solve the compilation exception problem caused by Windows TMP directory files¶
Sometimes it will be found that when compiling projects, the bootloader etc. generated under individual Windows PC environments will have problems;
In this case, it is necessary to check and confirm whether it is caused by the cache files in the Windows temporary directory, and the contents in the temporary directory can be cleaned up,The corresponding directory path can be confirmed/displayed via the command line: “echo %TMP%”, and all files and directories under the corresponding directory can be deleted。
1.6 Common compilation errors¶
(1) The code size of this image (xxx bytes) exceeds the maximum allowed for this version of the linker, how to solve?
When this error occurs, it is necessary to check if the Keil license is available。
1.7 Method to force a function to be a non-inline function¶
When tracking code in Ozone, you may encounter some functions programmed as inline functions, and the tracked code becomes assembly language, which is not convenient for tracking code,At this time, you can force the function to be a non-inline function, add a declaration in front of the function: attribute ( (noinline) ) or __NOINLINE
#define __NOINLINE __attribute__ ( (noinline) )
As follows:
__attribute__ ( (noinline) ) uint8_t _pm_enter_sleep(struct rt_pm *pm)