AnsweredAssumed Answered

Cross-compiling for iMX.6ULL-EVK hello world

Question asked by John Call on May 24, 2018

I'm a student at Utah State University and for my senior project I am implementing a modest ethernet router.

 

So I got my evk board, and it boots into the linux os that came on the microsd card (Linux version 4.1.15-2.0.1+gb63f3f5 (bamboo@yb6) (gcc version 5.3.0 (GCC) ) #1 SMP PREEMPT Sat Nov 5 01:14:46 CDT 2016). I've downloaded a bunch of stuff and am having a hard time navigating my way around what tools there are for the board. My native machine is windows, and I installed the SDK to C:\nxp\SDK_2.2_MCIM6ULL

 

However, this SDK does not appear to work with MCUXpresso IDE (what I thought was the recommended IDE based on something...it's been a few days since I've been at this)...the alternative being IAR I suppose but the restrictions have shied me away from it for now at least

 

So I found the gnu embedded toolchain at (GNU Arm Embedded Toolchain | Downloads – Arm Developer ). I saw some forum somewhere where it was said I needed 5-2016-q3 but I'm kind of assuming it's that or newer for now so I got the current one and installed it to %APPDATA%\Roaming\GNU Tools ARM Embedded\gcc-arm-none-eabi-7-2017-q4-major-win32 and added the bin folder to my PATH.

 

Next install make with cygwin and make a simple hello world application (router-usu / core · GitLab )

src/main.c:

#include <stdio.h>

int main() {
    printf("Hello World\n");
    return 0;
}

Makefile:

CC=arm-none-eabi-gcc.exe --specs=nosys.specs -mthumb -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9  -mvectorize-with-neon-quad -O0 -g

ODIR=obj
LDIR=lib
SDIR=src
BDIR=bin

_OBJ = hello.o
OBJ = $(patsubst %, $(ODIR)/%, $(_OBJ))

$(shell mkdir -p $(ODIR) $(BDIR))

$(BDIR)/routerusu: $(OBJ)
     $(CC) -o $@ $<

$(ODIR)/hello.o: $(SDIR)/main.c
     $(CC) -c -o $@ $<

.PHONY: clean
clean:
     rm -f $(ODIR)/*.o $(BDIR)/*

 

I have tried a variety of flags for gcc. At first I just tried -march=armv7-a (which I obtained from the readme for the gnu arm embeeded toolchain), but it resulted in several linker errors (I'm guessing because it doesn't know what OS to link to). So I found this SO post and tried adding --specs=nosys.specs but I suspect this just ignored the linker errors rather than solving the problem (because of next step)

 

So l compiled hello world with just the two afore-mentioned flags and loaded it onto an SD card, plugged it into the evk board, mounted it to /rosu and tried running the binary. I got a segfault (probably because of that --specs-nosys.specs) and confirmed with the version of gdb that came with the image that the segfault occurs during the project startup.

 

It was at this point I attempted adding other flags recommended by this SO post (and seen in the makefile above) just for good measure and still get a segfault.

 

I'm at the point where I think I'm really close to getting a working toolchain going, I'm just not sure where to find what gcc needs for linking the following errors

c:/users/johnk/appdata/roaming/gnu tools arm embedded/gcc-arm-none-eabi-7-2017-q4-major-win32/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar\libg.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x1c): undefined reference to `_exit'
c:/users/johnk/appdata/roaming/gnu tools arm embedded/gcc-arm-none-eabi-7-2017-q4-major-win32/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0x12): undefined reference to `_sbrk'
c:/users/johnk/appdata/roaming/gnu tools arm embedded/gcc-arm-none-eabi-7-2017-q4-major-win32/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar\libg.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x18): undefined reference to `_write'
c:/users/johnk/appdata/roaming/gnu tools arm embedded/gcc-arm-none-eabi-7-2017-q4-major-win32/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar\libg.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0x12): undefined reference to `_close'
c:/users/johnk/appdata/roaming/gnu tools arm embedded/gcc-arm-none-eabi-7-2017-q4-major-win32/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar\libg.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x18): undefined reference to `_lseek'
c:/users/johnk/appdata/roaming/gnu tools arm embedded/gcc-arm-none-eabi-7-2017-q4-major-win32/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar\libg.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x18): undefined reference to `_read'
c:/users/johnk/appdata/roaming/gnu tools arm embedded/gcc-arm-none-eabi-7-2017-q4-major-win32/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar\libg.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0x16): undefined reference to `_fstat'
c:/users/johnk/appdata/roaming/gnu tools arm embedded/gcc-arm-none-eabi-7-2017-q4-major-win32/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar\libg.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0x12): undefined reference to `_isatty'

 

Any pointers to get me started would be greatly appreciated

Outcomes