[ROC-RK3568-PC] 手把手教你编译Linux_SDK并打包Buildroot系统固件
Posted Neutionwei
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[ROC-RK3568-PC] 手把手教你编译Linux_SDK并打包Buildroot系统固件相关的知识,希望对你有一定的参考价值。
🍇 作者主页:Neutionwei
🍇 作者简介: 🏆CSDN嵌入式领域新星创作者
🍇 大家好,我是Neutionwei,欢迎你阅读我的文章,在此之前我希望你抽几秒钟时间给我点个五星⭐️⭐️⭐️⭐️⭐️
👉 博主最近参加 2021 博客之星 的竞选,这个是竞选帖子, 请你在这里增加其他内容。 包括但不限于:你这一年的收获,感悟, 对 CSDN 产品的反馈和 2022 年的希望。同时请大家帮我投票打分,您的每一分都是对我的支持与鼓励
👉投票地址:点击此处
✏️ROC-RK3568-PC入门篇连载进程:
✅ [ROC-RK3568-PC] 手把手教你把出厂的Android系统烧写为Ubuntu系统
✅ [ROC-RK3568-PC] 手把手教你制作Ubuntu系统TF卡启动盘
✅ [ROC-RK3568-PC] 手把手教你编译Linux_SDK并打包Ubuntu系统固件
✅ [ROC-RK3568-PC] 手把手教你解包Ubuntu系统固件
✅ [ROC-RK3568-PC] 手把手教你在Linux下解包与打包Ubuntu系统固件
✅ [ROC-RK3568-PC] 手把手教你打包能使用Etcher或dd命令烧写的Ubuntu系统固件
在前面文章中全部都是围绕Ubuntu固件进行展开,有兴趣的读者可以自行翻阅,接下来给大家讲讲如何编译并打包Buildroot系统固件!编译Linux_SDK过程绝大部分与之前讲述的Ubuntu系统固件相同。如果读者曾经编译过Linux_SDK,请直接从第三部分开始阅读!
文章目录
一、开发环境搭建
众所周知,编译最让人头疼的就是主机环境问题!假设我手上有其他芯片厂商的板卡,每个厂商的SDK都使用不同的编译环境,而我的Ubuntu主机系统只有一个,那怎么办?
使用Docker容器!
按照Firefly官方维基介绍,推荐使用Ubuntu 18.04,那我们在Docker下搭建一个Ubuntu 18.04系统好了!
1.1 主机安装Docker
照搬我之前写的这篇:Linux工具篇 | Ubuntu搭建Docker容器引擎
1.2 Docker安装Ubuntu 18.04
neutionwei@x:~$ sudo apt update
neutionwei@x:~$ docker pull ubuntu:18.04
切换Shell到Ubuntu 18.04:
neutionwei@x:~$ docker container run -p 8000:3000 -it ubuntu:18.04 /bin/bash
root@32b7b9ddcaab:/# cat /etc/issue
Ubuntu 18.04.6 LTS \\n \\l
1.3 Ubuntu 18.04安装常用工具
root@32b7b9ddcaab:/# apt update
root@32b7b9ddcaab:/# apt install byobu vim-gtk inetutils-ping net-tools wget cpio unzip rsync xz-utils
过程中需要配置地区,选择亚洲上海:
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities,
representing the time zones in which they are located.
1. Africa 3. Antarctica 5. Arctic 7. Atlantic 9. Indian 11. SystemV 13. Etc
2. America 4. Australia 6. Asia 8. Europe 10. Pacific 12. US
Geographic area: 6
Please select the city or region corresponding to your time zone.
1. Aden 13. Barnaul 25. Dushanbe 37. Jerusalem 49. Macau 61. Pyongyang 73. Taipei 85. Vientiane
2. Almaty 14. Beirut 26. Famagusta 38. Kabul 50. Magadan 62. Qatar 74. Tashkent 86. Vladivostok
3. Amman 15. Bishkek 27. Gaza 39. Kamchatka 51. Makassar 63. Qostanay 75. Tbilisi 87. Yakutsk
4. Anadyr 16. Brunei 28. Harbin 40. Karachi 52. Manila 64. Qyzylorda 76. Tehran 88. Yangon
5. Aqtau 17. Chita 29. Hebron 41. Kashgar 53. Muscat 65. Rangoon 77. Tel_Aviv 89. Yekaterinburg
6. Aqtobe 18. Choibalsan 30. Ho_Chi_Minh 42. Kathmandu 54. Nicosia 66. Riyadh 78. Thimphu 90. Yerevan
7. Ashgabat 19. Chongqing 31. Hong_Kong 43. Khandyga 55. Novokuznetsk 67. Sakhalin 79. Tokyo
8. Atyrau 20. Colombo 32. Hovd 44. Kolkata 56. Novosibirsk 68. Samarkand 80. Tomsk
9. Baghdad 21. Damascus 33. Irkutsk 45. Krasnoyarsk 57. Omsk 69. Seoul 81. Ujung_Pandang
10. Bahrain 22. Dhaka 34. Istanbul 46. Kuala_Lumpur 58. Oral 70. Shanghai 82. Ulaanbaatar
11. Baku 23. Dili 35. Jakarta 47. Kuching 59. Phnom_Penh 71. Singapore 83. Urumqi
12. Bangkok 24. Dubai 36. Jayapura 48. Kuwait 60. Pontianak 72. Srednekolymsk 84. Ust-Nera
Time zone: 70
Current default time zone: 'Asia/Shanghai'
Local time is now: Tue Nov 30 18:05:30 CST 2021.
Universal Time is now: Tue Nov 30 10:05:30 UTC 2021.
Run 'dpkg-reconfigure tzdata' if you wish to change it.
设置超级用户:
root@32b7b9ddcaab:/# visudo
添加自己的用户名,保存并退出:
neutionwei ALL=(ALL:ALL) ALL
二、下载Linux_SDK
进入Firefly官方进行下载,链接如下:
大家点击以下图片中指向的地方进行下载:
下载最新版本:
由于是某度网盘,下载速度就。。。
终于下载完成了,,,首先使用md5sum进行校验:
neutionwei@x:~/Download/rk356x_linux_release_v1.2.0_20211019_split_dir$ ls
md5sum.txt
README_EN.txt
README.txt
rk356x_linux_release_v1.2.0_20211019_firefly_split.file0
rk356x_linux_release_v1.2.0_20211019_firefly_split.file1
rk356x_linux_release_v1.2.0_20211019_firefly_split.file2
rk356x_linux_release_v1.2.0_20211019_firefly_split.file3
rk356x_linux_release_v1.2.0_20211019_firefly_split.file4
neutionwei@x:~/Download/rk356x_linux_release_v1.2.0_20211019_split_dir$ md5sum *firefly_split*
b633414d69240faa0c3bd755c255ede8 rk356x_linux_release_v1.2.0_20211019_firefly_split.file0
5cb1e2b63bbb4e3595c731038f6723fd rk356x_linux_release_v1.2.0_20211019_firefly_split.file1
e06c0f29fd5a870e0942139a1877a470 rk356x_linux_release_v1.2.0_20211019_firefly_split.file2
4e14fbf72ccbb9b87f81d83a256205b0 rk356x_linux_release_v1.2.0_20211019_firefly_split.file3
be8b003703b51e7220e52bb36439a357 rk356x_linux_release_v1.2.0_20211019_firefly_split.file4
确认与目录内的md5sum.txt文件内容无误!
三、编译Linux_SDK
根据Firefly官方维基安装必要工具:
neutionwei@32b7b9ddcaab:/$ sudo apt-get install repo git ssh make gcc libssl-dev liblz4-tool \\
expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \\
qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib \\
unzip device-tree-compiler python-pip ncurses-dev python-pyelftools
在Ubuntu 18.04新建一个目录:
neutionwei@32b7b9ddcaab:/$ cd ~
neutionwei@32b7b9ddcaab:~$ mkdir project
neutionwei@32b7b9ddcaab:~$ cd project/
neutionwei@32b7b9ddcaab:~/project$ pwd
/home/neutionwei/project
主机使用docker命令把Linux_SDK拷贝到Docker下的Ubuntu 18.04:
neutionwei@x:~/Download$ docker cp rk356x_linux_release_v1.2.0_20211019_split_dir 32b7b9ddcaab:/home/neutionwei/project
解压缩Linux_SDK:
neutionwei@32b7b9ddcaab:~/project$ cat rk356x_linux_release_v1.2.0_20211019_split_dir/*firefly_split* | tar -xzv
配置板卡型号,选择roc-rk3568-pc-buildroot.mk
:
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ls
Makefile build.sh debian docs external mkfirmware.sh rkbin tools yocto
app buildroot device envsetup.sh kernel prebuilts rkflash.sh u-boot
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ls device/rockchip/rk356x/
BoardConfig-rk3566-evb2-lp4x-v10-32bit.mk aio-3568j-openwrt.mk parameter-buildroot-spi-nor-64M.txt
BoardConfig-rk3566-evb2-lp4x-v10.mk aio-3568j-ubuntu.mk parameter-openwrt.txt
BoardConfig-rk3568-evb1-ddr4-v10-32bit.mk boot.its parameter-ubuntu-fit.txt
BoardConfig-rk3568-evb1-ddr4-v10-spi-nor-64M.mk boot4recovery.its roc-rk3566-pc-buildroot.mk
BoardConfig-rk3568-evb1-ddr4-v10.mk bootramdisk.its roc-rk3566-pc-lede.mk
BoardConfig-rk3568-nvr-spi-nand.mk firefly-rk3566-buildroot.mk roc-rk3566-pc-openwrt.mk
BoardConfig-rk3568-nvr.mk firefly-rk3566-ubuntu.mk roc-rk3566-pc-ubuntu.mk
BoardConfig-rk3568-uvc-evb1-ddr4-v10.mk firefly-rk3568-buildroot.mk roc-rk3568-pc-buildroot.mk
BoardConfig.mk firefly-rk3568-nvr-buildroot.mk roc-rk3568-pc-lede.mk
aio-3566-jd4-buildroot.mk firefly-rk3568-ubuntu.mk roc-rk3568-pc-openwrt.mk
aio-3566-jd4-ubuntu.mk firefly-rk356x-openwrt.mk roc-rk3568-pc-ubuntu.mk
aio-3568j-buildroot.mk parameter-buildroot-NVR-128M.txt station-m2-ubuntu.mk
aio-3568j-lede.mk parameter-buildroot-NVR-spi-nand-128M.txt station-p2-ubuntu.mk
aio-3568j-nvr.mk parameter-buildroot-fit.txt zboot.its
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ./build.sh roc-rk3568-pc-buildroot.mk
processing option: roc-rk3568-pc-buildroot.mk
switching to board: /home/neutionwei/project/rk356x_linux_release_20211019/device/rockchip/rk356x/roc-rk3568-pc-buildroot.mk
开始进行全编译:
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ./build.sh all
编译过程中发生的错误:
/bin/sh: 1: bc: not found
Kbuild:42: recipe for target 'include/generated/timeconst.h' failed
make[1]: *** [include/generated/timeconst.h] Error 127
Makefile:1244: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
make: *** Waiting for unfinished jobs....
HOSTCC scripts/recordmcount
HOSTCC scripts/dtc/checks.o
HOSTCC scripts/dtc/util.o
LEX scripts/dtc/dtc-lexer.lex.c
YACC scripts/dtc/dtc-parser.tab.h
HOSTCC scripts/resource_tool
HOSTCC scripts/mkkrnlimg
HOSTCC scripts/mod/sumversion.o
YACC scripts/dtc/dtc-parser.tab.c
HOSTCC scripts/sortextable
HOSTCC scripts/dtc/dtc-lexer.lex.o
HOSTCC scripts/mod/file2alias.o
HOSTCC scripts/asn1_compiler
HOSTCC scripts/dtc/dtc-parser.tab.o
HOSTCC scripts/extract-cert
HOSTLD scripts/mod/modpost
HOSTLD scripts/dtc/dtc
ERROR: Running build_kernel failed!
ERROR: exit code 2 from line 561:
make ARCH=$RK_ARCH $RK_KERNEL_DTS.img -j$RK_JOBS
安装bc
命令:
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ sudo apt install bc
继续全编译:
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ./build.sh all
依然有错误:
./build.sh: line 874: /usr/bin/time: No such file or directory
ERROR: Running build_recovery failed!
ERROR: exit code 127 from line 874:
/usr/bin/time -f "you take %E to build recovery" $COMMON_DIR/mk-ramdisk.sh recovery.img $RK_CFG_RECOVERY
安装time
命令:
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ sudo apt install time
继续全编译:
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ./build.sh all
过程中缺少什么命令就继续安装,然后继续全编译。Buildroot的编译过程比较漫长,因为涉及到源码包的抓取与,而大部分源码包的网址不在国内,抓取速度慢,甚至出现错误!
四、打包Buildroot系统固件
更新打包目录软链接:
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ./mkfirmware.sh
打包Buildroot固件:
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ./build.sh updateimg
我们打包的固件在/home/neutionwei/project/rk356x_linux_release_20211019/rockdev/pack/
目录。
在主机使用docker
命令把固件拷贝回主机烧写即可:
neutionwei@x:~/Download$ docker cp 32b7b9ddcaab:/home/neutionwei/project/rk356x_linux_release_20211019/rockdev/pack/ROC-RK3568-PC-Buildroot-GPT-20211231-2044.img .
写到最后
肝字不易,素质三连是对我的支持与肯定😘
以上是关于[ROC-RK3568-PC] 手把手教你编译Linux_SDK并打包Buildroot系统固件的主要内容,如果未能解决你的问题,请参考以下文章
[ROC-RK3568-PC] 手把手教你在Linux下解包与打包Ubuntu系统固件
[ROC-RK3568-PC] 手把手教你打包能使用Etcher或dd命令烧写的Ubuntu系统固件
[ROC-RK3568-PC] 手把手教你打包能使用Etcher或dd命令烧写的Ubuntu系统固件
[ROC-RK3568-PC] 手把手教你编译与打包Android 11系统固件