Figure 6. LINUX software architecture
Figure 6 shows the LINUX software architecture. Normally the chip solution company will provide Driver layer and Hardware layer code for user's reference. There are many open source codes that related to Middleware and Application layer in the internet, user can capture the code and compile it through some procedure. This chapter will introduce how to compile open source code and install in SP7021 platform.
User should prepare a LINUX OS base PC (OS is Ubuntu 18.04) for cross compile open source application code. Once compiling is ready, user has two ways to execute the application (APP).
- Copy the compiled APP to a USB stick, plug in USB stick to SP7021 platform and run the APP.
- Another method is that the user can copy the compiled APP to root file system (rootfs/initramfs/disk/usr) of SP7021 source code and compile SP7021 source code again. After boot up, user can run the APP on SP7021 platform under the folder /sys/usr.
...
6.1 Setup compiler Linux PC
Use Ubuntu18.04LTS to be the OS of PC. User can download it from https://www.ubuntu-tw.org/modules/tinyd0/ . It also needs to install tool packages for compiler using below commands. Make sure that your PC has ability to connect to internet because all tool packages need to be downloaded from the internet.
...
|
---|
...
6.2 Compile tool chain
Now SP7021 use Linaro tool chain (gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf) to build linux kernel. User can download it and get detail information from https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/.
...
6.3 Set cross compile environment variable
Suppose the compile tool chain folder is put in Linux PC path: /home/…/tools/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf , source code of SP7021 is put in Linux PC path: /home/…/code/sp7021/.
Environment variables for cross compiler using can be set by command line with commands as below:
|
---|
...
6.4 Cross compile
For simple application without make file, user can compile it with gcc of compile tool chain directly. Command example is below:
...
After being compiled, compiler will create a binary file which named test. The binary file can be executed in SP7021 platform.
...
6.5 APP cross compile and install
For most open source APPs, it usually needs to do three command steps to compile and get install file.
PS: (if no configure file included in APP, run ./autogen.sh to generate configure file first.) This command will auto-generate Makefile of APP.
This command will compile code base on Makefile.
This command will collect executable file and library to the same folder, then copy the folder to the specific path of system. |
---|
...
6.5.1 Example: libperl
User can download it from https://www.perl.org/ . Decompress and put the file in /home/…/perl-5.28.1. It needs to patch if you want to compile it for arm-linux. Patch can be downloaded from http://arsv.github.io/perl-cross/download.html . Decompress and put the file in /home/…/code/perl-cross-1.2.2. Compile and install libperl by below commands.
...
cp -Rp perl-5.28.1/** $CPDIR/arm-linux-gnueabihf/libc/usr |
---|
...
6.5.2 Example: python
User can download it from https://www.python.org/ . Decompress and put file in /home/…/code/Python-2.7.16 and create specify folder for compiling using. Action commands are below:
...
b) Modify Makefile.pre.in. Modification makes reference to Python-2.7.13-xcompile.patch file. File can be downloaded from http://files.cnblogs.com/files/pengdonglin137/Python-2.7.13-xcompile.patch.tar.gz . The content of modification is below: shown as blue color words below.
PGEN= Parser/pgen$(EXE) #Regenerate Include/graminit.h and Python/graminit.c #from Grammar/Grammar using pgen |
---|
...