§2023-06-24
The first step to do is getting an ARM cross compiler. We suggest the use of Linaro GCC toolchain. To download the latest release you can visit this site https://releases.linaro.org/components/toolchain/binaries/, choose a release and download the tarball gcc-linaro--x86_64_arm-linux-gnueabihf.tar.xz. Alternatively you can open a terminal and use wget command, for example to downloade the release 7.2.1-2017.11 you have to type:
$ wget https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
swig is required
$ wget -c wget -c releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabihf/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz
``
``bash
$ tar xvf src/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
$ export CC=`pwd`/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
[alexlai@x8664Arch build]$ ${CC}gcc --version
arm-linux-gnueabihf-gcc (Linaro GCC 7.5-2019.12) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ls gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/bin/
ar as ld ld.bfd ld.gold nm objcopy objdump ranlib readelf strip
$ git clone https://github.com/u-boot/u-boot
$ cd u-boot/
git branch
* master
[alexlai@x8664Arch u-boot]$ ls config
config.mk configs/
[alexlai@x8664Arch u-boot]$ ls configs/orangepi*
configs/orangepi_2_defconfig configs/orangepi_one_defconfig configs/orangepi_pc_plus_defconfig configs/orangepi_r1_defconfig configs/orangepi_zero_defconfig
configs/orangepi_3_defconfig configs/orangepi_one_plus_defconfig configs/orangepi_plus2e_defconfig configs/orangepi-rk3399_defconfig configs/orangepi_zero_plus2_defconfig
configs/orangepi_lite2_defconfig configs/orangepi_pc2_defconfig configs/orangepi_plus_defconfig configs/orangepi_win_defconfig configs/orangepi_zero_plus2_h3_defconfig
configs/orangepi_lite_defconfig configs/orangepi_pc_defconfig configs/orangepi_prime_defconfig configs/orangepi_zero2_defconfig configs/orangepi_zero_plus_defconfig
$ git branch tmp
[alexlai@x8664Arch u-boot]$ git checkout tmp
Switched to branch 'tmp'
$ make ARCH=arm CROSS_COMPILE=${CC} distclean
[alexlai@x8664Arch u-boot]$ make ARCH=arm CROSS_COMPILE=${CC} orangepi-rk3399_defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
YACC scripts/kconfig/zconf.tab.c
LEX scripts/kconfig/zconf.lex.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
$ make ARCH=arm CROSS_COMPILE=${CC}
...
error: command 'swig' failed: No such file or directory
make[2]: *** [scripts/dtc/pylibfdt/Makefile:33: rebuild] Error 1
make[1]: *** [scripts/Makefile.build:397: scripts/dtc/pylibfdt] Error 2
make: *** [Makefile:2009: scripts_dtc] Error 2
$ sudo pacman -S swig
[sudo] password for alexlai:
resolving dependencies...
looking for conflicting packages...
Packages (1) swig-4.1.1-2
Total Installed Size: 4.82 MiB
:: Proceed with installation? [Y/n] y
$ make ARCH=arm CROSS_COMPILE=${CC}
---> failed to build orangepi-rk3399_defconfig
[alexlai@x8664Arch u-boot]$ make ARCH=arm CROSS_COMPILE=${CC} orangepi_plus_defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
YACC scripts/kconfig/zconf.tab.c
LEX scripts/kconfig/zconf.lex.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
[alexlai@x8664Arch u-boot]$ make ARCH=arm CROSS_COMPILE=${CC}
$ ls -l u-boot*
-rwxr-xr-x 1 alexlai alexlai 5069108 Jun 27 08:57 u-boot
-rw-r--r-- 1 alexlai alexlai 519784 Jun 27 08:57 u-boot.bin
-rw-r--r-- 1 alexlai alexlai 16732 Jun 27 08:54 u-boot.cfg
-rw-r--r-- 1 alexlai alexlai 31712 Jun 27 08:58 u-boot.dtb
-rw-r--r-- 1 alexlai alexlai 519784 Jun 27 08:57 u-boot-dtb.bin
-rw-r--r-- 1 alexlai alexlai 519848 Jun 27 08:58 u-boot-dtb.img
-rw-r--r-- 1 alexlai alexlai 31873 Jun 27 08:58 u-boot.dtb.out
-rw-r--r-- 1 alexlai alexlai 519848 Jun 27 08:58 u-boot.img
-rw-r--r-- 1 alexlai alexlai 2519 Jun 27 08:57 u-boot.lds
-rw-r--r-- 1 alexlai alexlai 1171425 Jun 27 08:57 u-boot.map
-rwxr-xr-x 1 alexlai alexlai 488072 Jun 27 08:57 u-boot-nodtb.bin
-rwxr-xr-x 1 alexlai alexlai 1464354 Jun 27 08:57 u-boot.srec
-rw-r--r-- 1 alexlai alexlai 552616 Jun 27 08:58 u-boot-sunxi-with-spl.bin
-rw-r--r-- 1 alexlai alexlai 165 Jun 27 08:58 u-boot-sunxi-with-spl.map
-rw-r--r-- 1 alexlai alexlai 209609 Jun 27 08:57 u-boot.sym
$ git checkout v2017.11 -b tmp
Configure and build U-boot it's easy because U-boot supports many Orange Pi boards via defconfig, so you just need to type:
$ make ARCH=arm CROSS_COMPILE={CC} distclean
$ make ARCH=arm CROSS_COMPILE={CC} <orangepi_model>_defconfig
$ make ARCH=arm CROSS_COMPILE={CC} where <orangepi_model> depends on the board that you want to use, for example for Orange Pi PC Plus it's orangepi_pc_plus. At the end of the building you will find in u-boot folder the file u-boot-sunxi-with-spl.bin. You will use this file soon for the setup of the microSD card.
---
以下: failed, kept for records only
1. Set up Cross compiler as instructed by
[Odroid-C4 build u-boot](https://wiki.odroid.com/odroid-c4/software/building_u-boot)
```bash
$ echo $PATH
/opt/toolchains/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:/opt/toolchains/gcc-linaro-arm-none-eabi-4.8-2014.04_linux/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$ git clone https://github.com/u-boot/u-boot
$ mv u-boot u-boot-orangePi
$ cd u-boot-orangePi/
$ git checkout v2017.11 -b tmp
$ make orangepi_plus_defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
alexlai@SurfacePro:~/build/u-boot-orangePi$ make
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/config.h
UPD include/config.h
CFG u-boot.cfg
GEN include/autoconf.mk
GEN include/autoconf.mk.dep
CFG spl/u-boot.cfg
GEN spl/include/autoconf.mk
*** Your GCC is older than 6.0 and will not be supported starting in v2018.01.
CHK include/config/uboot.release
UPD include/config/uboot.release
CHK include/generated/version_autogenerated.h
UPD include/generated/version_autogenerated.h
CHK include/generated/timestamp_autogenerated.h
UPD include/generated/timestamp_autogenerated.h
CC lib/asm-offsets.s
lib/asm-offsets.c:1:0: error: unknown value ‘armv5’ for -march
/*
^
make[1]: *** [Kbuild:44: lib/asm-offsets.s] エラー 1
make: *** [Makefile:1332: prepare0] エラー 2
Return to Top