Compile Debian 10 From Source Code

Compile Debian 10 From Source Code

It is suggested to using Ubuntu, the distribution version of Linux, to compile Debian firmware. To compile Debian firmware, you need to build a suitable environment on Ubuntu PC as required.

Preparation to Compile

Recommended computer configuration as below:

64-bit CPU (Open System Setting –> About –> xx-bit system to check this)

16GB physical memory + swap memory (Open System Setting –> About –> xx memory to check this)

250GB of free disk space (Open terminal –> type “df -h” command to check this) The official recommendation is the Ubuntu 20.04 operating system. (Open System Setting –> About –> System Version to check this)

Download Source Code

Download the Edge 2 Debian SDK compressed package, then decompress it and generate repo-edge2 directory, it is recommended to use the download tool of http (such as freedownloadmanager) to download compressed package.

Our support team will send the downlink of Edge 2 Debian SDK to your email.

tar -xzvf mixtile-edge2_debian_sdk.tar.gz

Build Compiler Environment

In order to get rid of other effects of host environment, it is recommended using docker

Installing Docker on Ubuntu

Remove old docker if exist

sudo apt-get remove docker docker-engine docker.io containerd runc

Install docker

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce

Test docker

sudo docker run hello-world

Below is the result after running above command:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:bfea6278a0a267fad2634554f4f0c6f31981eea41c553fdf5a83e95a41d40c38
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
  (amd64)
3. The Docker daemon created a new container from that image which runs the
  executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
  to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/

Use Dockerfile we prepared

The Dockerfile is attached in the same folder and named linux-buildenv.zip. Please download it from this link linux-buildenv.zip. If necessary, you can refer to and modify the Dockerfile to meet your requirements.

Generate Docker image

After download correct dockerfile, follow the below steps. 1、Unzip the linux-buildenv.zip which you downloaded just now. 2、Enter the linux-buildenv folder which you just unzipped 3、Please perform the following operations in the same directory as “Dockerfile” sudo docker build -t edge2_build_env . If generating is successful, the following information will be printed to the terminal and it’s the last sentence: Successfully tagged edge2_build_env:latest

Boot Compile Environment

Create scrpit

touch edge2-build.sh
chmod +x edge2-build.sh
(edge2-build.sh could be created in any folder)

the content of this script can be referred to as follows, you can copy the following content into the script

#!/bin/bash
export ANDROID_BUILD_TOP=/home/userx/xxx/debian_edge2
sudo docker run --privileged -it --rm -v $ANDROID_BUILD_TOP:/build edge2_build_env:latest

note:

ANDROID_BUILD_TOP: absolute path of local source code
/build: absolute path of source code in docker environment
edge2_build_env:latest: docker image for build aosp

Boot script

./edge2-build.sh

Compile

Compile unified firmware After booting script, the sdk is expanded in /build directory which on docker environment.

./build.sh BoardConfig-rk3568-edge2-v101.mk
./build.sh allsave

sdk compilation requires a long wait,after successful compilation, serval image files will be generated in directory rockdev/update.img

ls rockdev/

boot.img
MiniLoaderAll.bin
misc.img
oem.img
parameter.txt
resource.img
rootfs.ext4
rootfs.img
update.img
userdata.img

Image description

update.img is a unified firmware,this firmware needs to be upgraded by RKDevTool or making sd card that by Rockchip Create Upgrade Disk Tool,after upgrading this firmware, all user data will be lost,The field description is as follows:

Compile u-boot

./build.sh uboot

Compile kernel

./build.sh kernel

Packing update.img

./build.sh update.img