[linux][buildroot][whycan.com]Lichee_RV_Dock荔枝派记录

原文来自:
首页» 全志 SOC» 使用mainline中最新的buildroot编译生成Lichee RV Dock系统镜像 by xkrisc

buildroot上游已经支持了D1 Nezha开发板,我为Lichee RV Dock做了如下适配开发:

A.uboot、opensbi使用了上游linux-sunxi社区的d1-wip分支,参见https://linux-sunxi.org/Allwinner_Nezha

B.linux kernel使用了上周日(2022年1月9日)release的linux-5.16 + linux-sunxi社区的d1-wip分 支合并而成

C.为Lichee RV CM和其Dock添加了dts文件

D.buildroot添加了Lichee RV的board/相应目录和configs/目录下相应的defconfig文件

这样做的好处是,紧跟上游,代码清晰,关键软件部件几乎最新。

0.host上安装用于buildroot的必要软件包
此过程略,可自行搜索解决

1.获取代码:

git clone https://gitee.com/xhackerustc/buildroot.git -b d1-wip

2.用buildroot编译用于licheepi rv的img:

cd buildroot
make licheepi_rv_defconfig
make menuconfig   //上游buildroot默认uclibc且最小化编译,riscv平台俺建议用glibc,软件包方 面这一步选一些需要的软件包
make

3.编译完成后在output/images/sdcard.img就是要烧入sdcard的img

sudo dd if=output/images/sdcard.img of=/dev/sdX

目前sdcard,sdio、usb host、user按键、wdt都能工作。

注1:因使用的是mainline的linux内核,sipeed wiki中的RGB LED WS2812 进行花式点灯需要改下:
点红灯:

echo 88 > /sys/class/leds/rgb\:indicator/brightness;echo 255 0 0 > /sys/class/leds/rgb\:indicator/multi_intensity

接着上面点绿灯:

echo 0 255 0 > /sys/class/leds/rgb\:indicator/multi_intensity

点蓝灯以此类推。

注2:此系统镜像也适用于只有Lichee RV核心模块的用户,当然usb host、RGB LED肯定不能用的,所以最好启动后修改/boot/extlinux/extlinux.conf文件,把其中的:

devicetree /boot/sun20i-d1-licheepi-rv-dock.dtb

换成

devicetree /boot/sun20i-d1-licheepi-rv.dtb

这两dtb文件镜像都自带了

--- 以上是原文

以下是实战:
按照以上教程编译,执行make指令后:
报错:

tools/sunxi_toc1.o: In function `toc1_vrec_header':
sunxi_toc1.c:(.text+0x1a2): undefined reference to `reallocarray'
collect2: error: ld returned 1 exit status
scripts/Makefile.host:104: recipe for target 'tools/dumpimage' failed
make[3]: *** [tools/dumpimage] Error 1
make[3]: *** Waiting for unfinished jobs....
tools/sunxi_toc1.o: In function `toc1_vrec_header':
sunxi_toc1.c:(.text+0x1a2): undefined reference to `reallocarray'
collect2: error: ld returned 1 exit status
scripts/Makefile.host:104: recipe for target 'tools/mkimage' failed
make[3]: *** [tools/mkimage] Error 1
Makefile:1830: recipe for target 'tools' failed
make[2]: *** [tools] Error 2
package/pkg-generic.mk:292: recipe for target '/home/dysonnnn/lichee/buildroot/output/build/uboot-d1-wip/.stamp_built' failed
make[1]: *** [/home/dysonnnn/lichee/buildroot/output/build/uboot-d1-wip/.stamp_built] Error 2
Makefile:84: recipe for target '_all' failed
make: *** [_all] Error 2

解答:
参考[PATCH] core/bootloader.c: fix build without reallocarray
修改函数,将 reallocarray 修改为 realloc 例如:

- entry *tmp = reallocarray(available, num_available + 1, sizeof(entry));
+ entry *tmp = realloc(available, (num_available + 1) * sizeof(entry));

最后编译成功:
image

参考链接:
使用mainline中最新的buildroot编译生成Lichee RV Dock系统镜像

posted @ 2023-03-22 23:04  dysonnnn  阅读(116)  评论(0编辑  收藏  举报