How to build U-Boot, Kernel and Linux application(s) without Yocto

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

How to build U-Boot, Kernel and Linux application(s) without Yocto

How to build U-Boot, Kernel and Linux application(s) without Yocto

 This article uses i.MX Linux® User's Guide, Rev. L4.1.15_2.1.0-ga, 05/2017

as an example (it may be found as attachment), please refer to section 4.5.12 (How to build

U-Boot and Kernel in standalone environment).

  First, generate a development SDK, which includes the tools, toolchain, and small rootfs to compile against

to put on the host machine.

 

  • Generate an SDK from the Yocto Project build environment with the following command. To set up the Yocto Project build

environment, follow the steps in the i.MX Yocto Project User's Guide (IMXLXYOCTOUG). In the following command,

set <Target-Machine> to the machine you are building for.

 

<Target-Machine> may be one of the following :

 

• imx6qpsabreauto

• imx6qpsabresd

• imx6ulevk

• imx6ull14x14evk

• imx6ull9x9evk

• imx6dlsabreauto

• imx6dlsabresd

• imx6qsabreauto

• imx6qsabresd

• imx6slevk

• imx6sllevk

• imx6solosabreauto

• imx6solosabresd
• imx6sxsabresd

• imx6sxsabreauto

• imx7dsabresd


 The «populate_sdk» generates an script file that sets up environment without Yocto Project. This SDK should be updated for each release

to pick up the latest headers, toolchain, and tools from the current release.

 

$ DISTRO=fsl-imx-fb MACHINE=<Target-Machine> source fsl-setup-release.sh -b build-fb

 

$ DISTRO=fsl-imx-fb MACHINE=<Target-Machine> bitbake core-image-minimal -c populate_sdk

 

or

 

$ bitbake meta-toolchain

 

 

  • From the build directory, the bitbake was run in, copy the sh file in tmp/deploy/sdk to the host machine to build on and execute the

script to install the SDK. The default location is in /opt but can be placed anywhere on the host machine.

 

  Note. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.

 

 $ . /opt/fsl-imx-fb/4.1.15-2.0.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi

 

or

 

 $ source /opt/fsl-imx-fb/4.1.15-2.0.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi

 

From  Yocto Project Mega-Manual 

Note

By default, this toolchain does not build static binaries. If you want to use the toolchain to build these types of libraries, you need to be sure your image has the appropriate static development libraries. Use the IMAGE_INSTALL variable inside your local.conf file to install the appropriate library packages. Following is an example using glibc static development libraries:

     IMAGE_INSTALL_append = " glibc-staticdev"

 

On the host machine, these are the steps to build U-Boot and Kernel:

 • On the host machine, set the environment with the following command before building.

 

$ export CROSS_COMPILE=/opt/fsl-imx-fb/4.1.15/environment-setup-cortexa9hf-vfp-neon-pokylinux-gnueabi

 

$ export ARCH=arm


• To build U-Boot, find the configuration for the target boot. In the following example, 
i.MX 6ULL is the target.

 

  Download source by cloning with

 

$ git clone http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git -b imx_v2016.03_4.1.15_2.0.0_ga

 

$ cd uboot-imx

$ make clean

$ make mx6ull_14x14_evk_defconfig

$ make u-boot.imx

 

• To build the kernel, execute the following commands:

 

Download source by cloning with

 

$ git clone http://git.freescale.com/git/cgit.cgi/imx/linux-imx.git -b imx_4.1.15_2.0.0_ga

 

$ cd linux-imx

$ make defconfig

$ make

 

• To build an application (Hello World) as test.c:

 

$ source /opt/fsl-imx-fb/4.1.15-2.0.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi

$ cd ~/test/

$ arm-poky-linux-gnueabi-gcc --sysroot=/opt/fsl-imx-fb/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -mfloat-abi=hard test.c

To check if the the compiled code (a.out) is ARM executable

 

$ file ./a.out

 

./a.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=0e5c22dcf021748ead2c0bd51a4553cb7d38f6f2, not stripped

 

Copy file a.out to target Linux filesystem and before run it check again :

 

root@imx6ul7d:/unit_tests/1# file a.out

 

a.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=0e5c22dcf021748ead2c0bd51a4553cb7d38f6f2, not stripped

 

To define what Linux libs are needed to run our application :

 

root@imx6ul7d:/unit_tests/1# ldd a.out

 

  linux-vdso.so.1 (0x7ee93000)

  libc.so.6 => /lib/libc.so.6 (0x76e64000)

  /lib/ld-linux-armhf.so.3 (0x76f9d000)

 

If some libs are not located in the filesystem you can observe the following message :

 

-sh: root@imx6ul7d:/unit_tests/1#./a.out: No such file or directory

 

Finally - run a.out:

 

root@imx6ul7d:/unit_tests/1# ./a.out

Hello World

root@imx6ul7d:/unit_tests/1#

Attachments
Comments
Hi Yuri,
I was reading the post DOC-334814 and would like to mention once the environment has been setup from sourcing the meta-toolchain environment script, the variable CC can be used  for the section "To build an application (Hellow World) as test.c;  here is an example of the definition for CC which will be unique based on MACHINE used:    CC=arm-poky-linux-gnueabi-gcc  -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.1.30-7ULP_alpha/sysroots/cortexa7hf-neon-poky-linux-gnueabi

This example is provided: 
$ arm-poky-linux-gnueabi-gcc --sysroot=/opt/fsl-imx-fb/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -mfloat-abi=hard test.c

But this could be used instead:
$ $CC test.c -o test

Using $CC adds a few more definitions as you can see above.

Thanks,
-Curtis

I have problem can you check and help me how can i fix this.

goko@PC:~/fsl-release-bsp/uboot-imx$ make clean
make: /opt/fsl-imx-fb/4.1.15-2.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabigcc: Command not found
/bin/sh: 1: /opt/fsl-imx-fb/4.1.15-2.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabigcc: not found
dirname: missing operand
Try 'dirname --help' for more information.
goko@PC:~/fsl-release-bsp/uboot-imx$ make mx6ull_14x14_evk_defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
goko@PC:~/fsl-release-bsp/uboot-imx$ make u-boot.imx
make: /opt/fsl-imx-fb/4.1.15-2.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabigcc: Command not found
/bin/sh: 1: /opt/fsl-imx-fb/4.1.15-2.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabigcc: not found
dirname: missing operand
Try 'dirname --help' for more information.
scripts/kconfig/conf  --silentoldconfig Kconfig
  CHK     include/config.h
  UPD     include/config.h
  GEN     include/autoconf.mk
/bin/sh: 1: /opt/fsl-imx-fb/4.1.15-2.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabigcc: not found
make[1]: *** [include/autoconf.mk] Error 1
make: *** No rule to make target `include/config/auto.conf', needed by `include/config/uboot.release'.  Stop.

Hello,

  Note. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.

 

 $ . /opt/fsl-imx-fb/4.1.15-2.0.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi

 

or

 

 $ source /opt/fsl-imx-fb/4.1.15-2.0.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi

Regards,

Yuri.

No ratings
Version history
Last update:
‎09-10-2020 02:36 AM
Updated by: