Linking bare metal "hello word" for i.MX25

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Linking bare metal "hello word" for i.MX25

868 Views
christiann
Contributor I

Giving the following source code

#include <stdio.h>

/*extern void _get_reg_general(unsigned int *reg_gen);*/

void main(void)

{

   unsigned int reg_generales[12], cont;

  

  /* _get_reg_general(reg_generales);*/

  

   printf("\nRegistros de proposito general\n");

   for(cont=0; cont<13; cont++)

   {

      printf("   reg[%d]=0x%08x\n", cont, reg_generales[cont]);

   } 

}

I try to compile it with the following commands

/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-gcc-4.4.4 -march=armv5te -S dump_cpu_mix.c -o dump_cpu_mix.s.arm

/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-as dump_cpu_mix.s.arm -o dump_cpu_mix.elf.arm

/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-ld -dynamic-linker /opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/arm-fsl-linux-gnueabi/multi-libs/armv5te/lib/ld-linux.so.3 /opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/arm-fsl-linux-gnueabi/multi-libs/armv5te/usr/lib/crt1.o /opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/arm-fsl-linux-gnueabi/multi-libs/armv5te/usr/lib/crti.o -lc /opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/arm-fsl-linux-gnueabi/multi-libs/armv5te/usr/lib/crtn.o dump_cpu_mix.elf.arm -o dump_cpu_mix.o.arm

Trying to run it, I get the following error

-sh: ./dump_cpu_mix.o.arm: not found

checking permissions

-rwxrwxrwx1 root root      6955 Apr 13  2015 dump_cpu_mix.o.arm

comparing with the elf generated by

/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-gcc-4.4.4 -march=armv5te dump_cpu_mix.c -o whatthehell.o -v

(-v output

/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.4.4/../../../../arm-fsl-linux-gnueabi/bin/as -march=armv5te -meabi=5 -o /tmp/cc6gOz5r.o /tmp/ccvHMq7M.s

COMPILER_PATH=/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../libexec/gcc/arm-fsl-linux-gnueabi/4.4.4/:/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../libexec/gcc/:/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.4.4/../../../../arm-fsl-linux-gnueabi/bin/

LIBRARY_PATH=/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.4.4/armv5te/:/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.4.4/:/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/:/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../arm-fsl-linux-gnueabi/multi-libs/armv5te/lib/:/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../arm-fsl-linux-gnueabi/multi-libs/armv5te/usr/lib/

COLLECT_GCC_OPTIONS='-march=armv5te' '-o' 'niidea' '-v'

/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../libexec/gcc/arm-fsl-linux-gnueabi/4.4.4/collect2 --sysroot=/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../arm-fsl-linux-gnueabi/multi-libs/armv5te --eh-frame-hdr -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -o niidea /mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../arm-fsl-linux-gnueabi/multi-libs/armv5te/usr/lib/crt1.o /mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../arm-fsl-linux-gnueabi/multi-libs/armv5te/usr/lib/crti.o /mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.4.4/armv5te/crtbegin.o -L/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.4.4/armv5te -L/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.4.4 -L/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc -L/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../arm-fsl-linux-gnueabi/multi-libs/armv5te/lib -L/mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../arm-fsl-linux-gnueabi/multi-libs/armv5te/usr/lib /tmp/cc6gOz5r.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.4.4/armv5te/crtend.o /mnt/freescale/bsp_git/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/../arm-fsl-linux-gnueabi/multi-libs/armv5te/usr/lib/crtn.o

)

(using file command)

whatthehell.o:             ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, not stripped

dump_cpu_mix.o.arm: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, not stripped

What step have I forgot? Based on past experience this "should" have worked, but I obviously messed this up. Any hints, hopefully I have included enough information

Labels (2)
0 Kudos
5 Replies

605 Views
Yuri
NXP Employee
NXP Employee

  It would be better to apply special compiler / toolchain for bare metal applications.

In Your case Linux toolchain, intended to create Linux applications is used.

For bare-metal applications Sourcery CodeBench Lite for ARM is suitable.

http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition


Have a great day,
Yuri

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

605 Views
christiann
Contributor I

Thanks Yuri

The term "bare metal" was confusing, I modified it

This application run under Linux. It's a dump cpu app to inspect CPU registers and other architecture specific tables. The code mix asm and C (inline asm is not suitable for purposes of this application) so I need asm, compile and link, step by step

0 Kudos

605 Views
Yuri
NXP Employee
NXP Employee

  You may try to compile an application under LTIB shell, which allows

us to get advantages of proper local  environment, that relates to target configuration.

Say, we can run ARM cross compiler just as gcc.

  To enter the shell  the next command may be applied :

<LTIB_DIR>/ltib -m shell

LTIB>

After that,  proper environment for development is provided and code may be

built as following :

LTIB> gcc -o hello.out hello.c


or

LTIB> make

Regards,

Yuri.

0 Kudos

605 Views
christiann
Contributor I

Thanks Yuri

But I'have to link two object files, one generated from AS (processor specific) an other one from GCC (using stdio like printf). Prior to link the both objects, I'll try to link the C one, without success.

The toolchain used was properly configured by LTIB (it was used several time to build linux kernel and rootfs)

0 Kudos

605 Views
Yuri
NXP Employee
NXP Employee

To compile and link several files (in make notation):

---
SOURCES = *.c *.s

LIBS =

TARGET = test.elf

gcc $(CXXFLAGS) -o $(TARGET) $(SOURCES) $(LIBS) -T MX25.ld

---

Regards,

Yuri

0 Kudos