Troubleshooting
Missing Dependencies for Build
Files added using the GNU assembler syntax .incbin
or .include
directives, or armasm syntax INCBIN
, INCLUDE
, or GET
directives, are not included in the file dependency list. As such, the CMake/Ninja build system cannot trigger automatically a build when an file changes that is included with such directives.
Using execute
in the related cproject.yml
file overcomes this issue.
In this example the file image.bin
is included using assembler syntax. The touch
command changes the time stamp of the related assembler file which triggers a rebuild.
executes:
- execute: image_dep
run: ${CMAKE_COMMAND} -E touch $output$
input:
- image.bin
output:
- asm.s
Tip
Use Add Images with the load:
node to add the output of external builds.
Common Linker Problems
The following section explains how to fix common linker problems.
Error: L6236E: No section matches selector - no section to be FIRST/LAST
Some devices (for example, the NXP RT1064) use custom (non-CMSIS) assembly startup code. This is not compatible with the default linker script that assumes C Startup code with standard CMSIS definitions.
This problem can be solved by:
- Using the linker script provided by the device vendor.
- Change the linker script source file
ac6_linker_script.sct.src
that is local in your project, for example, as shown below:
ER_ROM0 __ROM0_BASE __ROM0_SIZE {
*(.isr_vector, +First)
*(InRoot$$Sections)
*(+RO +XO)
}
Using RAM1 .. RAM3 Areas
Currently, there is a problem with the default AC6 linker script template. It does not use, by default, the RAM1 .. RAM3 area.
A potential solution is discussed here. The investigation is currently ongoing.
Duplicate Heap definition in Assembler startup file
When using memory allocation functions (i.e. malloc
), the application ends in a hard fault handler. This is typically caused by different methods of stack and heap definitions.
The Arm Compiler offers three ways to configure stack and heap. Only one of the following methods should be used:
- Use a linker scatter file to define
ARM_LIB_STACKHEAP
,ARM_LIB_STACK
, orARM_LIB_HEAP
regions. - Use the symbols
__initial_sp
,__heap_base
, and__heap_limit
. - Implement
__user_setup_stackheap()
or__user_initial_stackheap()
.
The C startup code recommended by CMSIS Version 6 uses the linker scatter file for stack and heap definition. The C startup code is generic and works across all toolchains that are supported by the CMSIS-Toolbox.
However, some assembler startup files define stack and heap with other methods, for example, by using the symbols __initial_sp
, __heap_base
, and __heap_limit
.
There are two options to solve the problem.
-
Remove the stack and heap definition in the assembler startup code.
-
Disable in the Regions Header File the stack and heap definition by setting
__STACK_SIZE
and__HEAP_SIZE
to 0 as shown below. This removes the definition in the linker scatter file.
// <h> Stack / Heap Configuration
// <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
// <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
#define __STACK_SIZE 0x00000000
#define __HEAP_SIZE 0x00000000
// </h>