I am compiling in IDE DS-5
an embedded C software for a NXP IMX6UL bare metal
product that is an ARM cortex A7 . I'm not using any operating system.
The issue is that I am using the compiler of AMR GCC 7.2.1 [arm-none-eabi] with the following flags:
C Flags: -march = armv7-a -mfpu = vfpv4 -mfloat-abi = hard -mthumb -o -g -Wall -mno-unaligned-access -MMD -MP -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std = gnu99
ASM Flags: -march = armv7-a -mfpu = vfpv4 -mfloat-abi = hard -mthumb -g -Wall -fno-common -function-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std = gnu99
Linker Flags: -march = armv7-a -mfpu = vfpv4 -mfloat-abi = hard -mthumb -g -fno-common -function-sections -fdata-sections -ffreestanding -fno-builtin -mapcs --spec = nosys.specs --specs = nano.specs -Xlinker --gc-sections -Xlinker -statics -Xlinker -z - Xlinker muldefs
The program compiles well, 0 errors 0 warnings, but when using any function of libgcc or lib , functiones as fopen or printf , this day:
undefined instructions error
Some functions, such as malloc do not present the previous error, they simply return null
.
My guess is that somehow the gcc libraries that are used are not compiled for this type of chipset so the obj Contain instructions that the processor does not understand. Although these libraries were downloaded from the same page of NXP
.
Any ideas on how to solve this?
Here is the simplified code
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE * file = NULL;
file = fopen("D:\Test.txt", "rb");
if(file){
printf("File opened");
fclose(file);
}else
printf("Fail to open file");
return 0;
}