1. Build the build environment¶
This chapter introduces the compilation environment of the Linux SDK.
Note:
(1) It is recommended to develop in the Ubuntu 16.04 system environment. If other system versions are used, the compilation environment may need to be adjusted accordingly.
(2) Compile with ordinary user, do not compile with root user authority.
1.1. Download Firefly_Linux_SDK¶
First prepare an empty folder to place SDK, better under home, here we use ~/proj
as example.
Attention: To avoid unnecessary errors, please do not place/unzip the SDK in VM shared folders or non-english directories.
Get SDK needs:
sudo apt update
sudo apt install -y repo git python
Method One
Download via repo, you can choose to get full SDK or BSP:
mkdir ~/proj/px30_linux_release_20210304/
cd ~/proj/px30_linux_release_20210304/
## Full SDK
repo init --no-clone-bundle --repo-url https://gitlab.com/firefly-linux/git-repo.git -u https://gitlab.com/firefly-linux/manifests.git -b master -m px30_linux_release.xml
## BSP (Only include some basic repositories and compile tools)
## BSP includes device/rockchip, docs, kernel, u-boot, rkbin, tools and cross-compile toolchian
repo init --no-clone-bundle --repo-url https://gitlab.com/firefly-linux/git-repo.git -u https://gitlab.com/firefly-linux/manifests.git -b master -m px30_linux_bsp_release.xml
Method Two
Download the SDK source code package.
Download: Linux_SDK.7z
After downloading, verify the MD5 code:
$ md5sum px30_linux_release_20210304.tgz
da43e8b1531819b6afae0d8de2aba8cc px30_linux_release_20210304.tgz
After confirming that it is correct, you can unzip:
# unzip
mkdir ~/proj/
cd ~/proj/
tar -zxvf path/to/px30_linux_release_20210304.tgz
# export data
.repo/repo/repo sync -l
1.2. Sync Code¶
Execute the following command to synchronize the code:
# Enter the SDK root directory
cd ~/proj/px30_linux_release_20210304/
# Sync
.repo/repo/repo sync -c --no-tags
.repo/repo/repo start firefly --all
You can use the following command to update the SDK later:
.repo/repo/repo sync -c --no-tags
1.3. Directory¶
$ tree -L 1
.
├── app
├── buildroot # Buildroot filesystem
├── build.sh -> device/rockchip/common/build.sh # compile script
├── debian # Debian filesystem
├── device # config files
├── distro
├── docs # document
├── envsetup.sh -> buildroot/build/envsetup.sh
├── external
├── kernel
├── makefile -> buildroot/build/makefile
├── mkfirmware.sh -> device/rockchip/common/mkfirmware.sh # link script
├── prebuilts # cross-compile toolchain
├── rkbin
├── rkflash.sh -> device/rockchip/common/rkflash.sh # flashing script
├── tools
├── u-boot
└── yocto
1.4. Set up compilation environment¶
Method 1:
Install directly on PC:
sudo apt-get install repo git-core gitk git-gui gcc-arm-linux-gnueabihf u-boot-tools device-tree-compiler \
gcc-aarch64-linux-gnu mtools parted libudev-dev libusb-1.0-0-dev python-linaro-image-tools \
linaro-image-tools gcc-4.8-multilib-arm-linux-gnueabihf gcc-arm-linux-gnueabihf libssl-dev \
gcc-aarch64-linux-gnu g+conf autotools-dev libsigsegv2 m4 intltool libdrm-dev curl sed make \
binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio python unzip rsync file bc wget \
libncurses5 libqt4-dev libglib2.0-dev libgtk2.0-dev libglade2-dev cvs git mercurial rsync openssh-client \
subversion asciidoc w3m dblatex graphviz python-matplotlib libc6:i386 libssl-dev texinfo \
liblz4-tool genext2fs lib32stdc++6 expect
Method 2: Use Docker
Use dockerfile to create a container, build SDK in the container, it will perfectly solve environment problems and isolate with host environments.
First install docker in the host PC, you can refer to Docker instructions
Create an empty folder as docker work dir, like ~/docker/
, then touch a dockerfile with contents:
FROM ubuntu:18.04
MAINTAINER firefly "service@t-firefly.com"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt install -y build-essential crossbuild-essential-arm64 \
bash-completion vim sudo locales time rsync bc python
RUN apt install -y repo git ssh libssl-dev liblz4-tool lib32stdc++6 \
expect patchelf chrpath gawk texinfo diffstat binfmt-support \
qemu-user-static live-build bison flex fakeroot cmake \
unzip device-tree-compiler python-pip ncurses-dev python-pyelftools \
subversion asciidoc w3m dblatex graphviz python-matplotlib cpio \
libparse-yapp-perl default-jre patchutils swig expect-dev u-boot-tools
RUN apt update && apt install -y -f
# language support
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
# switch to a no-root user
RUN useradd -c 'firefly user' -m -d /home/firefly -s /bin/bash firefly
RUN sed -i -e '/\%sudo/ c \%sudo ALL=(ALL) NOPASSWD: ALL' /etc/sudoers
RUN usermod -a -G sudo firefly
USER firefly
WORKDIR /home/firefly
Create image
cd ~/docker
docker build -t sdkcompiler .
# sdkcompiler is image name, you can change it, notice that there's a '.' at the end of cmd
# This process takes a while, please wait
Then create a container
# Here we mount host SDK location into the container, so that you can access SDK inside container
# source= is host SDK location; target= is a folder inside container, must be an empty folder
# ubuntu18 is container name, firefly is container's hostname, you can change them
# sdkcompiler is the image created in last step
docker run --privileged --mount type=bind,source=/home/fierfly/proj,target=/home/firefly/proj --name="ubuntu18" -h firefly -it sdkcompiler
Now you can build SDK inside the container.
How to quit container and how to reopen:
# Execute "exit" inside container will quit and close it
# See all containers (include exited ones)
docker ps -a
# Start an exited container and attach it
docker start ubuntu18 # container name
docker attach ubuntu18