Building System Firmware Preparation Development environment setup There are also software and hardware requirements in addition to system requirements. 64-bit system Minimum hard disk space is greater than 40G; larger hard disk space is required for multiple system building works. Ubuntu 16.04 system is recommended. Other versions of ubuntu are not tested and adjustment of the software package may be necessary. Installation of software package After setuping and configuration of network , install necessary software package according to the following steps. apt-get update sudo apt-get update Install dependent software package for Kernel and U-Boot compiling sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl \ zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev \ x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev \ libxml2-utils xsltproc unzip device-tree-compiler Install dependent software package for Buildroot compiling sudo apt-get install libfile-which-perl sed make binutils gcc g++ bash \ patch gzip bzip2 perl tar cpio python unzip rsync file bc libmpc3 \ git repo texinfo pkg-config cmake tree Installation of necessary tools sudo apt install genext2fs sudo apt install gawk Note: Corresponding software packages should be installed according to the error messages during compiling. Installation of cross compiler toolchain Since Rockchip Buildroot SDK can only be compiled under Linux system, we also offer cross compiler toolchain for Linux. Of which, the preset directory of the cross compiler toolchain for U-Boot and Kernel build can be found in prebuilt/gcc, and buildroot adopts the cross compiler toolchain compiled from this open source. Cross compiler toolchain for U-Boot and Kernel prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- Corresponding version: gcc version 6.3.1 20170404 (Linaro GCC 6.3-2017.05) Cross compiler toolchain for Buildroot buildroot/output/rockchip_rk3308_release/host/bin/aarch64-rockchip-linux-gnu- Corresponding version gcc version 6.4.0 (Buildroot 2018.02-rc3-00017-g9c68ede) Please compile by yourself to generate toolchain of other platforms or versions if you need. Download SDK Since SDK is quite large, we offer a packaged ".git" repository for download: Firefly-RK3308_Linux_SDK Please verify the MD5 code after download: md5sum Firefly-RK3308_Linux_SDK_git_20181008.7z 3800278cc016d117eec8c0381ba66769 Firefly-RK3308_Linux_SDK_git_20181008.7z Unzip if everything goes right: mkdir -p ~/prj/Firefly-RK3308 cd ~/prj/Firefly-RK3308 7zr x Firefly-RK3308_Linux_SDK_git_20181008.7z git reset --hard The released SDK has been added to the remote repository by default. git remote -v gitlab https://gitlab.com/TeeFirefly/rk3308-linux.git (fetch) gitlab https://gitlab.com/TeeFirefly/rk3308-linux.git (push) Then it is possible to update directly from gitlab: git pull gitlab firefly:firefly Online Source code browse is possible at https://gitlab.com/TeeFirefly/rk3308-linux SDK directory structure . ├── buildroot ├── build.sh -> device/rockchip/common/build.sh ├── device ├── envsetup.sh -> buildroot/build/envsetup.sh ├── external ├── kernel ├── Makefile -> buildroot/build/Makefile ├── mkfirmware.sh -> device/rockchip/rk3308/mkfirmware.sh ├── prebuilts ├── rkbin ├── rockdev ├── tools ├── u-boot └── yocto Of which: Buildroot directory stores buildroot open source project code for the customization of root file system build.sh system build script for the complete compilation of SDK device directory stores board configuration, some preset files and boot script external directory stores SDK relevant libraries ,tool and source codes kernel directory stores Linux kernel source code mkfirmware.sh script can package the image file and copy to the rockdev/ directory prebuilts directory stores the cross compiler toolchain for U-Boot and Kernel rkbin directory stores some essential binary files for Rockchip platform, including ddr.bin, miniloader.bin, and bl31.bin, all necessary during U-Boot compile rockdev directory stores image files generated during system compile to rockdev/ by running mkfirmware.sh tools directory stores development tools, debugging tools and mass production tools for Windows and Linux environment u-boot directory stores U-Boot source codes Building Uboot Building Uboot: cd u-boot/ ./make.sh roc-rk3308-cc After the building, three image files (trust.img, rk3308_loader_xxx.bin and uboot.img) will be generated. Building Kernel Building Kernel: cd kernel/ make arch=arm64 firefly-rk3308_linux_defconfig make arch=arm64 rk3308-roc-cc-dmic-pdm_emmc.img Run "make arch=arm64 dts-name.img" (for example, "rk3308-roc-cc-dmic- pdm_emmc.img") directly when building kernel can generate corresponding resource.img(including dtb data). Finally, the kernel.img and resource.img generated will be packaged into zboot.img, and you only need to burn zboot.img to your board. Building Buildroot Note : In case of major updates or update of individual software, old version contents should be cleared up but the compiling script can not overwrite in output directory automatically. So that, manual operation is needed. The easiest way to do this is to delete the "buildroot/output/" directory and then rebuild the SDK. rm buildroot/output -rf To build Buildroot,envsetup.sh is the script to setup terminal environment variable: source buildroot/build/envsetup.sh You're building on Linux Lunch menu...pick a combo: 1. firefly_rk3308_release 2. firefly_rk3308_recovery 3. firefly_rk3308_pcba Which would you like? [1] 1 =========================================== If firefly_rk3308_release is adopted, input the corresponding serial number 1. Execute the compilation command: make After compiling, run mkfirmware.sh script from SDK root directory to generate the firmware. ./mkfirmware.sh All image files required during burning will be copied to rockdev directory. rockdev/ ├── boot.img ├── MiniLoaderAll.bin ├── misc.img ├── oem.img ├── parameter.txt ├── recovery.img ├── rootfs.img ├── trust.img ├── uboot.img └── userdata.img After obtaining all image files, they can be manually packaged into a unified firmware as update.img by using script for convenient burning and mass production. Packing method see below. Full-automatic building script In order to improve the compiling efficiency and reduce faulty operation rate of manual compilation, SDK is integrated with full- automatic building script for convenient compiling and backup of firmware. Original file of the full-automatic script is stored at: device/rockchip/common/build.sh A corresponding soft link "build.sh" is created at the root of SDK directory. ./build.sh roc-rk3308-cc_release_BoardConfig.mk ./build.sh Notice :Due to the ROC-RK3308-CC use wi-fi is AP6236,need to modify "buildroot/configs/firefly_rk3308_release_defconfig", "closed BR2_PACKAGE_RKWIFIBT_RTL8188EU",open "BR2_PACKAGE_RKWIFIBT_AP6236". git diff buildroot/configs/firefly_rk3308_release_defconfig diff --git a/buildroot/configs/firefly_rk3308_release_defconfig b/buildroot/configs/firefly_rk3308_release_defconfig index d64c090..929a55b 100755 --- a/buildroot/configs/firefly_rk3308_release_defconfig +++ b/buildroot/configs/firefly_rk3308_release_defconfig @@ -29,8 +29,8 @@ BR2_PACKAGE_SOFTAPSERVER=y BR2_PACKAGE_WIFIAUTOSETUP=y BR2_PACKAGE_RKWIFIBT=y # BR2_PACKAGE_RKWIFIBT_COMPATIBLE is not set -# BR2_PACKAGE_RKWIFIBT_AP6236 is not set -BR2_PACKAGE_RKWIFIBT_RTL8188EU=y +BR2_PACKAGE_RKWIFIBT_AP6236=y +# BR2_PACKAGE_RKWIFIBT_RTL8188EU is not set BR2_PACKAGE_EQ_DRC_PROCESS=y BR2_PACKAGE_ALSA_LADSPA=y BR2_PACKAGE_ROCKCHIP_TEST=y Also, to modify specific variables in "device/rockchip/rk3308/BoardConfig.mk" script to build corresponding product firmware. #========================= # Compile Config #========================= # Target arch ARCH=arm64 # Uboot defconfig UBOOT_DEFCONFIG=rk3308 # Kernel defconfig KERNEL_DEFCONFIG=firefly-rk3308_linux_defconfig # Kernel dts KERNEL_DTS=rk3308-roc-cc-dmic-pdm_emmc # Buildroot config CFG_BUILDROOT=firefly_rk3308_release # Recovery config CFG_RECOVERY=firefly_rk3308_recovery # Pcba config CFG_PCBA=firefly_rk3308_pcba # Build jobs JOBS=12 Notice :Due to the ROC-RK3308-CC use wi-fi is AP6236,need to modify "buildroot/configs/firefly_rk3308_release_defconfig", "closed BR2_PACKAGE_RKWIFIBT_RTL8188EU",open "BR2_PACKAGE_RKWIFIBT_AP6236". git diff buildroot/configs/firefly_rk3308_release_defconfig diff --git a/buildroot/configs/firefly_rk3308_release_defconfig b/buildroot/configs/firefly_rk3308_release_defconfig index d64c090..929a55b 100755 --- a/buildroot/configs/firefly_rk3308_release_defconfig +++ b/buildroot/configs/firefly_rk3308_release_defconfig @@ -29,8 +29,8 @@ BR2_PACKAGE_SOFTAPSERVER=y BR2_PACKAGE_WIFIAUTOSETUP=y BR2_PACKAGE_RKWIFIBT=y # BR2_PACKAGE_RKWIFIBT_COMPATIBLE is not set -# BR2_PACKAGE_RKWIFIBT_AP6236 is not set -BR2_PACKAGE_RKWIFIBT_RTL8188EU=y +BR2_PACKAGE_RKWIFIBT_AP6236=y +# BR2_PACKAGE_RKWIFIBT_RTL8188EU is not set BR2_PACKAGE_EQ_DRC_PROCESS=y BR2_PACKAGE_ALSA_LADSPA=y BR2_PACKAGE_ROCKCHIP_TEST=y Run automatic building script: ./build.sh This script can configure environment variables automatically and compile U-Boot, Kernel, Buildroot and Recovery to generate the firmware. Module compiling For easy development and debugging, the "Full-automatic building script" mentioned above also supports single module compiling and easy module debugging, and it is also possible to compile specific modules. module compilation can refer to the user instructions: ./build.sh -h ====USAGE: build.sh modules==== uboot -build uboot kernel -build kernel rootfs -build default rootfs, currently build buildroot as default buildroot -build buildroot rootfs yocto -build yocto rootfs, currently build ros as default ros -build ros rootfs debian -build debian rootfs pcba -build pcba recovery -build recovery all -build uboot, kernel, rootfs, recovery image cleanall -clean uboot, kernel, rootfs, recovery firmware -pack all the image we need to boot up system updateimg -pack update image save -save images, patches, commands used to debug default -build all modules For example, to build a kernel, you only need to execute the following command: ./build.sh kernel Unified firmware packaging tool Firmware packaging tool can integrate scattered image files into a complete image file as update.img, for easy mass production flash and update. Packaging Unified firmware in Windows In Windows OS, the packaging tool is stored at "tools\windows\AndroidTool\rockdev" and the packaging process is as follows: Open rockdev directory and edit package-file.Configure in accordance with package-file. For img files in package-file to be stored at Image directory, only copy necessary images to the Image directory. The image name should be accurate during configuration. Also, the bootloader option should be modified according to the loader name generated. Edit mkupdate.bat.The loader name should be modified to the name of loader actually stored. Click mkupdate.bat to run the program and generate an update.img in the current directory. Packaging in Linux It stores the packaging tool at "SDK/tools/linux/Linux_Pack_Firmware/rockdev/", and the packaging process is as follows: Open rockdev directory and edit the package-file.Configure in accordance with package-file. For img files in the package-file to be stored at Image directory, only copy necessary images to the Image directory. The image name should be accurate during configuration. Also, the bootloader option should be modified according to the loader name generated. Edit mkupdate.sh.The loader name should be modified to the name of loader actually stored. In the rockdev directory, execute the following command and generate an update.img in the current directory. ./mkupdate.sh Besides, in Linux, SDK offers a convenient script that can generate a unified firmware "rockdev/update.img" directly. ./build.sh updateimg Burning the image file Please refer to Update Firmware to burn the partition image file to the board.