Buildroot打包问题--IDO-SBC2D06

需求:
打包包含Qt5、hidapi、libusb、串口读写、ntfs磁盘支持、openssh、自动获取dhcp、vim编辑器的固件

测试:Buildroot2020.05、Buildroot2023.02 可正常打包,运行,且启动速度飞快

第一步:Target options

Target Architecture (ARM (little endian))
Target Binary Format (ELF)
Target Architecture Variant (cortex-A7)
Target ABI (EABIhf) 
Floating point strategy (NEON
ARM instruction set (ARM)

第二步:System configuration 增加udev

/dev management (Dynamic using devtmpts + eudev

第三步:配Toolchain

Toolchain type (External toolchain.
*** Toolchain External Options ***
Toolchain (Custom toolchain)
Toolchain origin (Pre-installed toolchain)
(/opt/arm_board/PurPle-Pi-R1/toolchain/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabihf)Toolchain path
(arm-linux-gnueabihf) Toolchain prefixExternal toolchain gcc version (8.x)  
External toolchain kernel headers series (4.18.X)
External toolchain C library (glibc/eglibc) 
[*]Toolchain has Ssp support?
[*]Toolchain has Ssp strong support?
[*]Toolchain has RPC support?
[*]Toolchain has C++ support?
[*]Enable MMU support

第三步:Target packages 勾选

[*]Show packages that are also provided by busybox

Hardware handing

eudev
    enable rules generator
    enable hwdb installation
rng-tools
    NIST Entropy Beacon support
    

Libraries --> Hardware handing

   hidapi、libhid、libusb、libusb-compat

Graphic libraries and applications (graphic/text) -->Qt5

qt5base、MySQL Plugin、qt5serialport、SQLite 3 support (Qt SQLite)

Networking applications

dhcpcd
ifupdown scripts
openssh

Text editors and viewers

vim

Filesystem and flash utilities

ntfs-3g
encrypted volumes
ntfsprogs

Miscellaneous

haveged

第五步:使能字体 wqy-zenhei(支持中文)

> Target packages
 > Fonts, cursors, icons, sounds and themes
  > wqy-zenhei

保存,make -j8 编译

在编译完成后需要执行的操作,以实现自动挂载U盘、移动硬盘

1、把打包的文件解压

mkdir ./rootfs
tar -xvf ./rootfs.tar -C ./rootfs/

2、在/etc/udev/目录下增加如下文件

vim ./etc/udev/mountusb.sh
#!/bin/sh
if [ x$1 != x ];then
  if [ ! -d "/mnt/usbdisk/$1" ];then
        mkdir -p /mnt/usbdisk/$1
  fi
  mount /dev/$1 /mnt/usbdisk/$1
  sync
fi

vim ./etc/udev/umountusb.sh
#!/bin/sh
sync
if [ x$1 != x ];then
  if [  -d "/mnt/usbdisk/$1" ];then
     umount /mnt/usbdisk/$1
  fi
fi

vim ./etc/udev/rules.d/11-add-usb.rules
ACTION!="add",GOTO="farsight"
KERNEL=="sd[a-z][0-9]",RUN+="/etc/udev/mountusb.sh %k"
KERNEL=="sd[a-z]",RUN+="/etc/udev/mountusb.sh %k"
LABEL="farsight"

vim ./etc/udev/rules.d/11-remove-usb.rules
ACTION !="remove",GOTO="farsight"
KERNEL=="sd[a-z][0-9]",RUN+="/etc/udev/umountusb.sh %k"
LABEL="farsight"
chmod +x ./etc/udev/*.sh

3、再把解压后的压缩包打包成tar.gz文件

tar -zcvf rootfs.tar.gz ./rootfs

后面把官方包里的mdev注释掉,就可以用官方包打包整体固件了,要注释的文件:

./project/image/configs/i2m/rootfs.mk

4、内核打包hidraw驱动,在kernel文件夹下执行(infinity2m_spinand_ssc011a_s01a_minigui_doublenet_defconfig 是双网卡板,根据自己的开发板选择合适的配置文件)

cp ./arch/arm/configs/infinity2m_spinand_ssc011a_s01a_minigui_doublenet_defconfig .config 
ARCH=arm make menuconfig

进入 Device Drivers:

【*】USB support,点击回车进入,除了USB Gadget Support和USB3.0外,其余全部选择(不要选M,改为 * 号)

HID support ,点击回车进入,除了I2C和Special HID drivers 外,其余全部勾选。

保存,退出

然后执行

cp .config ./arch/arm/configs/infinity2m_spinand_ssc011a_s01a_minigui_doublenet_defconfig

在U-BOOT修改双网卡mac地址:

setenv   ethaddr1   xx
setenv   ethaddr   xx
saveenv

默认可以GPIO为11个,编号如下:

2/3/5/6/7/8/9/10/11/47/48

如果需要11路以上GPIO,可以把内核里的触摸驱动关掉,以释放GPIO12和GPIO13。路径如下:

 Device Drivers → Input device support → Touchscreens

测试GPIO的demo如下:

#!/bin/sh
NUM=$1
echo ${NUM} > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio${NUM}/direction

while true
do
        echo 1 > /sys/class/gpio/gpio${NUM}/value
        sleep 0.3
        echo 0 > /sys/class/gpio/gpio${NUM}/value
        sleep 0.3
done

你可能感兴趣的:(buildroot)