TinaLinux cross-compilation application basics part 1 (T113-S3)
1. To build a vmware virtual machine, the current version is 15.5, but later versions should also be possible.
2. Install Ubuntu 18.04. Other versions have not been tried.
3. Install dependency packages (the following are all run under user permissions):
sudo apt-get install -y sed make binutils build-essential gcc
g++ bash patch gzip bzip2 perl tar cpio unzip rsync file bc wget
python cvs git mercurial rsync subversion android-tools mkbootimg
vim libssl-dev android-tools-fastboot
4. If you find that your Ubuntu virtual machine cannot be copied and pasted into Ubuntu through the Windows command when it is started for the first time.
You need to first run the following command to install a shared clip for the virtual machine and Windows.
sudo apt install open-vm-tools-desktop After the installation is complete, restart Linux
5. Get Tina-sdk V2.0 source package and install the sdk package as introduced in the previous article.
6. Tina-LInux Directory Introduction
build
The build directory stores Tina Linux's build system files. This directory structure mainly contains a series of Makefile-based
mk file written by specification. The main functions are:
- Check whether the current compilation environment meets the building requirements of Tina Linux.
- Generate host package compilation rules.
- Generate compilation rules for the toolchain.
- Generate compilation rules for the target package.
- Generate compilation rules for the Linux kernel.
- Generate build rules for system firmware
build
|--autotools.mk
|--aw-upgrade.mk
|--board.mk
|--cmake.mk
|--config.mk
|--debug.mk
|--depends.mk
|--device.mk
|--device_table.txt
|--download.mk
|--dumpvar.mk
|--envsetup.sh
config
Config.in
The config directory mainly stores the configuration menu interface and some fixed configuration items in Tina Linux.
Written based on the kernel's mconf specification.
config/
|--Config-build.in
|--Config-devel.in
|--Config-images.in
|--Config-kernel.in
|--top_config.in
device
The devices directory is used to store solution configuration files, including kernel configuration, env configuration, partition table configuration, sys_config.fex, board.dts, etc. These configurations are saved in the target directory in the old version, and are moved to the device directory in the new version.
Note that defconfig is still saved in the target directory.
device/
|--config
|--chips
|--common
|--rootfs_tar
dl
docs
The docs directory mainly stores documents used for development, written in markdown format.
This catalog is no longer updated, please refer to the Allwinner Customer Service Platform System Documentation. I can't see it in the system here.
docs/
lichee
The lichee directory mainly stores bootloader, kernel, arisc, dsp and other codes.
Makefile
out
The out directory is used to store compilation-related temporary files and final image files. This directory is automatically generated after compilation.
Such as the compilation plan r328s2-perf1.
out/
├── t113-100ask
└── host
package
The package directory stores the source code and compilation rules of the target machine's software package. The directory is based on the function of the target software package.
Can be classified.
package/
|--allwinner
|--base-files
|--delve
|--dragonst //? Didn't see it
|--firmware
|--kernel
|--....
|--utils
prebuild
The prebuild directory stores the precompiled cross compiler. The directory structure is as follows
rules.mk
scripts
The scripts directory is used to store some build and compilation related scripts.
target
The target directory is used to store target board related configurations and specifications generated by SDK and toolchain.
tmp
toolchain
The toolchain directory contains cross-toolchain build configurations and rules.
toolchain/
├── binutils
├── Config.in
├── fortify-headers
├── gcc
├── gdb
├── glibc
├── info.mk
├── insight
├── kernel-headers
├── Makefile
├── musl
└── wrapper
tools
The tools directory is used to store compilation rules for host-side tools.
tools/
├── autoconf
├── automake
├── aw_tools
├── b43-tools
├── ......
That's it for the directory structure.
7. Kernel compilation is introduced in another article. Here we introduce the compilation of application programs.
The prebuild directory stores precompiled cross compilers, so in order to use the cross-compilation tool chain in any location or terminal, you need to add the tool chain bin path to the ubuntu PATH environment variable separately, which can be added to ~/.bashrc or configured separately in each terminal.
Export PATH=$PATH:home/ubuntu/tina-d1-h/prebuilt/gcc/linux-x86/arm/toolchain-sunxi-musl/toolchain/bin
After the configuration is complete, execute arm-openwrt-linux-muslgnueabi-gcc -v to verify whether it is configured.
success.
After the tool chain is added to the environment variable, you can use Makefile to point the cross tool chain and compile the application.
Take hello.c as an example
After copying to the shared folder, use adb in window10 to transfer the file to the t113-s3 board. Remember to modify the file's running properties. Then run to view the results.
In this way, the construction of the C application compilation environment and the basic testing of using Makefile are basically completed, and the next step is how to write the application.
8. Using CMake to build the language
There are some differences between using CMake to build the language and Makefile. The following demonstration example provides the same
hello.c program, use CMake build language to specify the location of cross-compilation toolchain header file lib library, etc., write
Output the CMakeLists.txt compilation rule file, and finally use cmake to compile and generate
First, check whether cmake is installed in ubuntu18.04. If not, install it, as shown below
sudo apt install cmake
Copy hello.c to another directory such as hello-cmake, and write the CMakeLists.txt file as follows:
Then create a build directory in this directory, and then run cmake in this directory.
Perform a pre-compilation check, and then use the make command to compile and generate the hello executable program.
Also transfer it to window10 sharing and use adb to push it to the board for running.
Okay, that’s all I have to report for now. Thank you everyone.