麻雀Buildroot扩展支持 https://github.com/100askTeam/buildroot-external-mq.git
全志在线buildroot https://github.com/100askTeam/buildroot_aw-ol.git
MQ-D1S Buildroot external tree
这个Git仓库专门支持全志在线 RV64 的平台。这个是针对 芒果PI MQ 开发板专门支持的 BR2_EXTERNAL 外部扩展支持。
快速开始
环境配置
为了使用 Buildroot,您需要在您的工作站上安装 Linux 发行版。 任何最新的 Linux 发行版(Ubuntu、Debian、Fedora、Redhat、OpenSuse 等)都可以正常工作。
但是你需要安装一些必要软件包至您的Linux工作站才可以使用Buildroot manual System requirements section. 对于 Debian/Ubuntu发行版系统,需要参考下述命令安装列出来的软件包。
$ sudo apt install debianutils sed make binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio unzip rsync file bc git
获取代码
这个 BR2_EXTERNAL会配合着最新的LTS版本一起使用,所以版本会随着 上游的更新而建立新的分支进行更新,目前Buildroot最新 BR2_EXTERNAL最新LTS版本是 2021-02 。
首先我们获取 buildroot最新lts版本源码。
使用git clone
$ git clone https://github.com/100askTeam/buildroot_aw-ol.git buildroot
获取buildroot源码后,可以单独获取 芒果PI MQ 的 BR2_EXTERNAL 源码。
$ git clone -b main https://github.com/100askTeam/buildroot-external-mq.git
获取完成后,可以看到 一个 buildroot目录和一个 buildroot-external-mq目录。
配置并构建
首先进入到buildroot目录
$ cd buildroot/
接下来执行配置命令,来使用 mq_core_defconfig配置文件进行配置。
buildrot/ $ make BR2_EXTERNAL=../buildroot-external-mq mq_core_defconfig
指定配置文件后,可以使用 make menuconfig 命令来增加自己需要的包。
增加完成软件包后,就可以直接执行 make 命令开始编译了。
buildroot/ $ make
编译时会自动下载所需的软件包,进行配置编译最后打包成一个完成的系统镜像,整个时间受网络环境而定,一般情况下 只需要60分钟。
烧写并启动系统
编译完成后,会生成一个sdcard.img 系统镜像,镜像文件存放在 output/images/目录下。
6257fb94-a41b-4be8-b386-d0b52f162838-image.png
执行如下命令讲镜像烧录进 tf卡即可,注意 /dev/sdX sdX 指的是tf卡设备的主分区。
或者可以使用 wind32diskimage进行烧写。
buildroot/ $ dd if=output/images/sdcard.img of=/dev/sdX bs=1M
烧写完成后,将卡插入至开发板,连接电源线,设置为 tf卡启动,即可启动开发板,之后连接串口,等待进入终端命令行,系统默认的登录用户名是 root 。
注意这个只是最小系统,大家想做什么二次开发 直接在上面进行适配即可。
5704024d-1aea-44d9-bb70-c999fceb322d-image.png
大家可以试试白嫖 Github CI自动化构建,快还省事。
https://github.com/100askTeam/buildroot-external-mq/blob/main/.github/workflows/buildroot-external-mq.yml
自己增加一个专门的自动构建脚本,在上面的Actions里面启用自动化构建。
c7683d48-f732-45a5-9945-6fc307a99763-image.png
构建完成后,会在当前页面输出一个 sdcard.img镜像文件 可以直接下载。
感觉大大增加了开发效率,最主要是免费😀 。
离线
下面动手试一试韦老师的buildroot
whycan@ubuntu:/opt/D1/buildroot-100ask$
whycan@ubuntu:/opt/D1/buildroot-100ask$
whycan@ubuntu:/opt/D1/buildroot-100ask$ git clone https://hub.fastgit.org/100askTeam/buildroot-external-mq
Cloning into 'buildroot-external-mq'...
remote: Enumerating objects: 199, done.
remote: Counting objects: 100% (199/199), done.
remote: Compressing objects: 100% (130/130), done.
remote: Total 199 (delta 48), reused 174 (delta 38), pack-reused 0
Receiving objects: 100% (199/199), 3.39 MiB | 190.00 KiB/s, done.
Resolving deltas: 100% (48/48), done.
whycan@ubuntu:/opt/D1/buildroot-100ask$
whycan@ubuntu:/opt/D1/buildroot-100ask$
whycan@ubuntu:/opt/D1/buildroot-100ask$ git clone https://hub.fastgit.org/100askTeam/buildroot_aw-ol
Cloning into 'buildroot_aw-ol'...
remote: Enumerating objects: 15732, done.
remote: Counting objects: 100% (15732/15732), done.
remote: Compressing objects: 100% (13907/13907), done.
remote: Total 15732 (delta 1497), reused 15732 (delta 1497), pack-reused 0
Receiving objects: 100% (15732/15732), 9.11 MiB | 205.00 KiB/s, done.
Resolving deltas: 100% (1497/1497), done.
whycan@ubuntu:/opt/D1/buildroot-100ask$
whycan@ubuntu:/opt/D1/buildroot-100ask$
whycan@ubuntu:/opt/D1/buildroot-100ask$
离线
开始编译:
whycan@ubuntu:/opt/D1/buildroot-100ask/buildroot_aw-ol$ make BR2_EXTERNAL=../buildroot-external-mq mq_core_defconfig
mkdir -p /opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config/lxdialog
PKG_CONFIG_PATH="" make CC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc" \
obj=/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config -C support/kconfig -f Makefile.br conf
/usr/bin/gcc -D_GNU_SOURCE -D_DEFAULT_SOURCE -DCURSES_LOC="<ncurses.h>" -DLOCALE -I/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config -DCONFIG_=\"\" -MM *.c > /opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config/.depend 2>/dev/null || :
/usr/bin/gcc -D_GNU_SOURCE -D_DEFAULT_SOURCE -DCURSES_LOC="<ncurses.h>" -DLOCALE -I/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config -DCONFIG_=\"\" -c conf.c -o /opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config/conf.o
/usr/bin/gcc -D_GNU_SOURCE -D_DEFAULT_SOURCE -DCURSES_LOC="<ncurses.h>" -DLOCALE -I/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config -DCONFIG_=\"\" -I. -c /opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config/zconf.tab.c -o /opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config/zconf.tab.o
/usr/bin/gcc -D_GNU_SOURCE -D_DEFAULT_SOURCE -DCURSES_LOC="<ncurses.h>" -DLOCALE -I/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config -DCONFIG_=\"\" /opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config/conf.o /opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config/zconf.tab.o -o /opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config/conf
rm /opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-config/zconf.tab.c
#
# configuration written to /opt/D1/buildroot-100ask/buildroot_aw-ol/.config
#
whycan@ubuntu:/opt/D1/buildroot-100ask/buildroot_aw-ol$
whycan@ubuntu:/opt/D1/buildroot-100ask/buildroot_aw-ol$
离线
ONTTRYCHOWN=1 /opt/D1/buildroot-100ask/buildroot_aw-ol/output/host/bin/fakeroot -- /opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-fs/tar/fakeroot
rootdir=/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-fs/tar/target
table='/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/buildroot-fs/full_devices_table.txt'
ln -snf /opt/D1/buildroot-100ask/buildroot_aw-ol/output/host/riscv64-buildroot-linux-gnu/sysroot /opt/D1/buildroot-100ask/buildroot_aw-ol/output/staging
>>> Executing post-image script support/scripts/genimage.sh
/opt/D1/buildroot-100ask/buildroot-external-mq/board/mq/genimage.cfg:45: no sub-section title/index for 'config'
INFO: cmd: "mkdir -p "/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/genimage.tmp"" (stderr):
INFO: cmd: "rm -rf "/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/genimage.tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/genimage.tmp"" (stderr):
INFO: cmd: "cp -a "/tmp/tmp.zo0p4sJTeS" "/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/genimage.tmp/root"" (stderr):
INFO: cmd: "find '/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/genimage.tmp/root' -depth -type d -printf '%P\0' | xargs -0 -I {} touch -r '/tmp/tmp.zo0p4sJTeS/{}' '/opt/D1/buildroot-100ask/buildroot_aw-ol/output/build/genimage.tmp/root/{}'" (stderr):
INFO: cmd: "mkdir -p "/opt/D1/buildroot-100ask/buildroot_aw-ol/output/images"" (stderr):
INFO: vfat(boot.vfat): cmd: "dd if=/dev/zero of="/opt/D1/buildroot-100ask/buildroot_aw-ol/output/images/boot.vfat" seek=33554432 count=0 bs=1 2>/dev/null" (stderr):
INFO: vfat(boot.vfat): cmd: "mkdosfs '/opt/D1/buildroot-100ask/buildroot_aw-ol/output/images/boot.vfat'" (stderr):
INFO: vfat(boot.vfat): adding file 'boot.img' as 'boot.img' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/opt/D1/buildroot-100ask/buildroot_aw-ol/output/images/boot.vfat' '/opt/D1/buildroot-100ask/buildroot_aw-ol/output/images/boot.img' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'Image' as 'Image' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/opt/D1/buildroot-100ask/buildroot_aw-ol/output/images/boot.vfat' '/opt/D1/buildroot-100ask/buildroot_aw-ol/output/images/Image' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'board.dtb' as 'board.dtb' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/opt/D1/buildroot-100ask/buildroot_aw-ol/output/images/boot.vfat' '/opt/D1/buildroot-100ask/buildroot_aw-ol/output/images/board.dtb' '::'" (stderr):
INFO: hdimage(sdcard.img): adding partition 'boot0' from 'boot0_sdcard.fex' ...
INFO: hdimage(sdcard.img): adding partition 'boot-packages' from 'boot_package.fex' ...
INFO: hdimage(sdcard.img): adding partition 'env' (in MBR) from 'env.fex' ...
INFO: hdimage(sdcard.img): adding partition 'env-redund' (in MBR) from 'env.fex' ...
INFO: hdimage(sdcard.img): adding partition 'boot' (in MBR) from 'boot.vfat' ...
INFO: hdimage(sdcard.img): adding partition 'rootfs' (in MBR) from 'rootfs.ext4' ...
INFO: hdimage(sdcard.img): writing GPT
INFO: hdimage(sdcard.img): writing hybrid MBR
whycan@ubuntu:/opt/D1/buildroot-100ask/buildroot_aw-ol$
whycan@ubuntu:/opt/D1/buildroot-100ask/buildroot_aw-ol$
编译成功!
离线