Search code examples
bare-metalcortex-aimx6

How do I develop bare-metal i.mx6sx code using eclipse?


I was wondering if you could help me with some issues and questions I have for developing for the i.MX6 SoloX in bare-metal. I was looking at this link https://community.nxp.com/docs/DOC-106253 and downloaded the files there to use as an example of how to develop bare-metal c code for the i.MX6.

Then I setup my eclipse environment according to this tutorial https://community.nxp.com/docs/DOC-103736 but just the toolchain because I'm not interested in processor expert.

Since I'm working on Linux I didn't installed the Code Sourcery thing, instead I'm working with the gcc-arm-none-eabi which I installed using:

$ sudo apt-get install gcc-arm-none-eabi

And therefore I had to change the cs-rm and cs-make for rm and make respectively.

And I was able to create an eclipse project with the downloaded code and configure the project to make it work, nevertheless, I had the first error:

main.c:8:19: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
               ^
compilation terminated.
make: *** [cortex_A9/main.o] Error 1
cortex_A9/subdir.mk:24: recipe for target 'cortex_A9/main.o' failed

And I was able to solve it adding "/usr/include" in the include directories at project > properties. But I'm not sure if this is a correct way of solving this error.

After fixing this error I got a new one:

syscalls.c:168:1: error: unknown type name 'caddr_t'
 caddr_t _sbrk(int incr)

And for solving that I had to include explicitly the file "/usr/include/x86_64-linux-gnu/sys/types.h" and also I don't know if that is the correct way to solve it.

Now having eliminated those two errors I have the following one:

Building target: imx6-A9.elf
Invoking: Cross ARM C Linker
arm-none-eabi-gcc -mcpu=cortex-a9 -march=armv7-a -marm -mlittle-endian -mfloat-abi=softfp -mfpu=neon -mno-unaligned-access -fno-zero-initialized-in-bss -O0  -g -T "/home/mmalagon/iMX6/MX6SX_hello_MFG/cortex_A9/mx6slx.ld" -nostartfiles -Wl,-Map,"imx6-A9.map" -o "imx6-A9.elf"  ./cortex_A9/main.o ./cortex_A9/syscalls.o ./cortex_A9/uart.o   
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/bin/ld: cannot find -lg
makefile:42: recipe for target 'imx6-A9.elf' failed
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make: *** [imx6-A9.elf] Error 1

Which I haven't been able to resolve.

I don't know if this error is a consequence of the way I solved the two previous errors.

Does anybody know how to properly setup eclipse for i.MX6 bare-metal development?

Thank you very much for helping!!


Solution

  • If you want to develop bare-metal code for the i.MX6SoloX without using CodeSourcery then you need to execute this:

    sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi -y
    

    And then choose "Custom (arm-none-eabi-gcc)" at Project>Settings>C/C++ Build in the 'Toolchains' tab.