树莓派使用buildroot

Buildroot 是一个开源项目,旨在简化为嵌入式 Linux 系统生成完整文件系统镜像的过程。它非常适合用于构建定制的、精简的 Linux 系统,常用于嵌入式设备开发,比如路由器、工业控制器、IoT 设备等。

1. 安装工具

$ sudo apt install build-essential bison flex gawk texinfo file git ssh libc6-dev libssl-dev libncurses-dev

2. 下载buildroot

方式1:

$ git clone --depth=1 https://github.com/buildroot/buildroot.git

方式2:

$ git clone --depth=1 https://gitlab.com/buildroot.org/buildroot.git

方式3:

官网下载: https://buildroot.org/download.html

3. 配置builroot

查看buildroot支持的配置文件:

$ make list-defconfigs

树莓派配置文件(选择适合开发板的其中一个):

$ make raspberrypi0_defconfig
$ make raspberrypi0w_defconfig
$ make raspberrypi2_defconfig
$ make raspberrypi3_64_defconfig
$ make raspberrypi3_defconfig
$ make raspberrypi3_qt5we_defconfig
$ make raspberrypi4_64_defconfig
$ make raspberrypi4_defconfig
$ make raspberrypi5_defconfig
$ make raspberrypicm4io_64_defconfig
$ make raspberrypicm4io_defconfig
$ make raspberrypi_defconfig
$ make raspberrypizero2w_64_defconfig
$ make raspberrypizero2w_defconfig

配置:

$ make menuconfig

启用glibc(运行C程序),设置密码(新版登录终端需密码):

Toolchain
    --> [*] Install glibc utilities
System configuration
    --> ()    Root password

4. 下载包

为防止编译buildroot过程中,因无人值守下载包失败导致编译失败(特别是中国网络),提前下载好需要的软件包和固件:

$ make source

5. 编译

$ make -j4

或者,带编译log版本:

$ time(make -j4 2>&1 | tee build-rpi.log)

6. 刷镜像

确定sd卡的节点,参考如下:

/dev/sdb
/dev/mmcblk0

以'/dev/sdb'为例:

$ cd ~/buildroot
$ sudo dd if=output/images/sdcard.img of=/dev/sdb status=progress; sync

7. 验证

方式1:

显示器,需要一个显示器接在树莓派显示接口上,即可正常使用。

方式2:

串口,3根线,串口设备的TX接树莓派的RX,串口设备的RX接树莓的TX,默认比特率115200。

树莓派的Pin脚如下:
当树莓派的40 Pin引脚横向靠近自己的一侧,最下面一排从右往左数,第3个引脚是GND,第4个引脚是TX,第5个引脚是RX。

两种方式,都需使用前面步骤设置的密码登录(用户名: root)。

posted @ 2025-05-12 15:40  this毛豆  阅读(154)  评论(0)    收藏  举报