MYZR-A40I-EK204 Linux-3.10.65 Build Reference Manual

来自明远智睿的wiki
跳转至: 导航搜索

The download of the source code package needs to be downloaded from the network disk provided by us.
After downloading to the computer, it needs to be copied to the virtual machine via Samba or other methods.
​We can create an A40I-specific directory to store related source code, compilation tools and some things that will be used later.
For example, my directory is: /home/liangyh/my-work/A40I, in this directory I created 4 subdirectories:

=====> Input:
liangyh@FS12:~/my-work/A40I$ ls
01_image 02_sources 03_toolchain 04_app

​ ​Directory 01 can be used to place our compiled image (will be explained later)

​ ​Directory 02 is used to place source code

​ ​Directory 03 is to place the cross-compilation tool configuration script

​ ​Directory 04 we can use to place our own applications (assigned by the user)

​ Copy the source package to the ~/my-work/A40I/02_sources directory in the virtual machine using Samba or other methods

​ And then unzip the source package to the current directory:

=====> Input:
~/my-work/A40I/02_sources$ cat repo_A40I.tar.bz2a* | tar xjv

Create a cross-compiler tool configuration script

=====> Input command:
cat << EOF > ~/my-work/A40I/03_toolchain/arm-openwrt-linux-muslgnueabi.sh
#!/bin/sh
export PATH=${HOME}/my-work/A40I/02_sources/repo_A40I/prebuilt/gcc/linux-x86/arm/toolchain-sunxi-musl/toolchain/bin/:${PATH}
export ARCH=arm
export CROSS_COMPILE=${HOME}/my-work/A40I/02_sources/repo_A40I/prebuilt/gcc/linux-x86/arm/toolchain-sunxi-musl/toolchain/bin/arm-openwrt-linux-muslgnueabi-
export CC=${HOME}/my-work/A40I/02_sources/repo_A40I/prebuilt/gcc/linux-x86/arm/toolchain-sunxi-musl/toolchain/bin/arm-openwrt-linux-muslgnueabi-gcc
EOF

Get executable permission

chmod +x ~/my-work/A40I/03_toolchain/arm-openwrt-linux-muslgnueabi.sh

tina source code compilation

The source code is compiled using the script, the cross-compilation tool is automatically configured, the source code is compiled, and finally the board image file is packaged and generated.

1. Setting up the environment

=====> Input:
$ sudo apt-get install libssl-dev
$ sudo apt-get install gperf
$ sudo apt-get install lib32stdc++6

=====> Input:
$ source build/envsetup.sh

=====> Output:
Setup env done! Please run lunch next.

2. Set the build platform

=====> Input:
$ lunch r40_m2ultra-tina

=====> Output:
============================================
TINA_BUILD_TOP=/home/liangyh/my-work/A40I/02_sources/repo_A40I
TINA_TARGET_ARCH=arm
TARGET_PRODUCT=r40_m2ultra
TARGET_PLATFORM=r40
TARGET_BOARD=r40-m2ultra
TARGET_PLAN=m2ultra
TARGET_BUILD_VARIANT=tina
TARGET_BUILD_TYPE=release
TARGET_KERNEL_VERSION=3.10
TARGET_UBOOT=u-boot-2014.07
TARGET_CHIP=sun8iw11p1
============================================

3. Compile uboot

=====> Input:
$ muboot

4. Compile kernel

=====> Input:
$ make 

=====> Output:
Checking 'working-make'... ok.
Checking 'case-sensitive-fs'... ok.
Checking 'gcc'... ok.
Checking 'working-gcc'... ok.

......

#### make completed successfully (23:30 (mm:ss)) ####

5. Package firmware

=====> Input:
$ pack

=====> Output:
No kernel param, parse it from r40
copying tools file
copying configs file

......

/home/liangyh/my-work/A40I/02_sources/repo_A40I/out/r40-m2ultra/tina_r40-m2ultra_uart0.img

pack finish

Generate firmware address:

repo_A40I/out/r40-m2ultra/tina_r40-m2ultra_uart0.img

Application programming example

Copy the source package to the ~/my-work/A40I/04_app directory in the virtual machine using Samba or other methods.

1. Configure the cross-compilation tool

=====> Input:
$ source ~/my-work/A40I/03_toolchain/arm-openwrt-linux-muslgnueabi.sh 

2. Verify cross-compiler configuration

=====> Input:
$CC -v

=====> Output:
Reading specs from /home/liangyh/my-work/A40I/02_sources/repo_A40I/prebuilt/gcc/linux-x86/arm/toolchain-sunxi-musl/toolchain/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/6.4.1/specs
COLLECT_GCC=arm-openwrt-linux-muslgnueabi-gcc.bin
COLLECT_LTO_WRAPPER=/home/liangyh/my-work/A40I/02_sources/repo_A40I/prebuilt/gcc/linux-x86/arm/toolchain-sunxi-musl/toolchain/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/6.4.1/lto-wrapper
Target: arm-openwrt-linux-muslgnueabi
Configured with: /home/caiyongheng/tina/out/astar-parrot/compile_dir/toolchain/gcc-linaro-6.4-2017.11/configure --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt/Linaro GCC 6.4-2017.11 2017-11' --prefix=/home/caiyongheng/tina/out/astar-parrot/staging_dir/toolchain --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-openwrt-linux-muslgnueabi --with-gnu-ld --enable-target-optspace --enable-libgomp --disable-libmudflap --disable-multilib --disable-nls --without-isl --without-cloog --with-host-libstdcxx=-lstdc++ --with-gmp=/home/caiyongheng/tina/out/host --with-mpfr=/home/caiyongheng/tina/out/host --with-mpc=/home/caiyongheng/tina/out/host --disable-decimal-float --with-diagnostics-color=auto-if-env --disable-libssp --enable-__cxa_atexit --with-arch=armv7-a --with-float=hard --with-headers=/home/caiyongheng/tina/out/astar-parrot/staging_dir/toolchain/include --disable-libsanitizer --enable-languages=c,c++ --enable-shared --enable-threads --with-slibdir=/home/caiyongheng/tina/out/astar-parrot/staging_dir/toolchain/lib --enable-lto --with-libelf=/home/caiyongheng/tina/out/host
Thread model: posix
gcc version 6.4.1 (OpenWrt/Linaro GCC 6.4-2017.11 2017-11)

3. Start compiling

=====> Input:
${CC} hello_world.c -o hello_world

4. Execute

Move the compiled binary file hello_world to the development board (for the moving method, refer to the file transfer in the previous experience).

give executable permission and execute the file

=====> Input:
# chmod +x hello_world
# ./hello_world

=====> Output:
hello world!!!

After the successful operation, the information of hello world is successfully output.