“Buildroot 系统使用”的版本间的差异

来自ARM Wiki
跳转至: 导航搜索
(Sunxiaolin移动页面Buildroot系统qt使用方法Buildroot 系统使用
(没有差异)

2020年11月4日 (三) 10:48的版本

该buildroot系统是基于wayland显示协议的嵌入式系统。系统集成的qt支持wayland、wayland-egl、eglfs、linuxfb显示插件。

基础信息

  • 用户密码

系统默认使用root用户登录,并支持root用户ssh远程登录,给目标系统root用户设置密码为root

$ passwd root
> root
> root

使用示例

网络设置

系统下有ifupdown和dhcpcd两套软件在管理网络,开机启动脚本分别为/etc/init.d/S40network和/etc/init.d/S41dhcpcd,ifupdown的配置文件为/etc/network/interfaces,dhcpcd的配置文件为/etc/dhcpcd.conf,两套软件相互独立。系统默认没有对/etc/network/interfaces进行设置,只有dhcpcd对eth0配置了DHCP。若不需要两套软件管理,选择将其中一个从/etc/init.d/目录移除即可

  • 使用ifupdown设置网络

设置静态IP,编辑/etc/network/interfaces,参考设置如下:

auto eth0
iface eth0 inet static
    address 192.168.0.10
    gateway 192.168.0.1
    netmask 255.255.255.0
    broadcast 192.168.0.255
    dns-nameservers 1.2.4.8 114.114.114.114

重启系统生效

  • 使用dhcpcd设置网络

设置静态IP,编辑/etc/dhcpcd.conf,参考设置如下:

interface eth0
static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=1.2.4.8 114.114.114.114

重启系统生效

  • 连接wifi

系统下使用wpa_supplicant软件连接wifi,开机启动脚本为/etc/init.d/S80wifireconnect,配置文件为/userdata/cfg/wpa_supplicant.conf,系统中提供了wifi_start.sh脚本用于输入wifi账号密码并进行连接,参考命令如下:

$ wifi_start.sh norco_2.4G norco85258506
  # 账号:norco_2.4G
  # 密码:norco85258506

QT开发

搭建qt开发环境

主机PC端环境为Ubuntu16.04,目标板系统为buildroot嵌入式系统,默认使用root用户登录,并支持root用户ssh远程登录,给目标系统root用户配置密码为root

$ passwd root
> root
> root

SDK与系统镜像一同发布,从相应的烧录包中获取SDK。SDK中包含交叉编译工具链、qmake、与目标板系统的rootfs。解压SDK到任意目录$TOP_DIR(示例中以路径/home/lin/trash为例),并运行开发环境配置脚本

$ tar host.tar.gz -C $TOP_DIR
$ cd $TOP_DIR/host
$ ./relocate-sdk.sh

使用终端命令行编译运行qt程序

qt程序使用SDK中的qt5 examples例程,通过qmake、make命令进行编译

$ export PATH=$TOP_DIR/host/bin:$PATH
$ cd $TOP_DIR/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/qt/examples/opengl/hellowindow
$ qmake
$ make

生成hellowindow程序,可通过scp拷贝到目标板中直接运行

$ scp hellowindow root@10.168.1.247:
$ ssh root@10.168.1.247
$ ./hellowindow

系统在/etc/init.d/S50launcher开机启动服务中,启动了wayland显示服务,并运行了QLauncher桌面,若使用eglfs或linuxfb显示插件,则需要移除S50launcher服务

$ mv /etc/init.d/S50launcher ~
$ sync
$ reboot

指定eglfs显示插件运行程序

$ ./hellowindow -platform eglfs

Projects 0.jpg

指定linuxfb显示插件运行程序

$ ./calculator -platform linuxfb

使用qtcreator开发调试qt程序

qtcreator集成编辑、编译、运行、调试环境于一体,提升开发效率

安装qtcreator

$ sudo apt-get install qtcreator


添加Qt Versions
Tools --> Options --> Build & Run --> Qt Versions --> Add --> 选中qmake路径 --> Apply
Qtcreator1 Qt Versions.png


添加Compilers
Tools --> Options --> Build & Run --> Compilers --> Add --> GCC -- 选中g++路径 --> Apply
注意:选中g++路径,并修改ABI一栏明确指示平台架构为arm
Qtcreator1 Compilers.png


添加Debuggers(可选项)
Tools --> Options --> Build & Run --> Debuggers --> Add --> 选中gdb路径 --> Apply
Qtcreator1 Debuggers.png


添加Devices(可选项)
Tools --> Options --> Devices --> Add --> General Linux Device --> start Wizard
Qtcreator1 Devices.png

并点击"Test"测试设备联通
Device Test.png


添加Kits
Tools --> Options --> Build & Run --> Kits --> Add --> Apply
Qtcreator1 Kits.png


打开 hellowindow 工程并选择Kits
Welcome --> Open Porject --> 选择工程路径 /home/lin/trash/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/qt/examples/opengl/hellowindow/hellowindow.pro --> Configure Project
Qtcreator1 Configure Project.png


编译运行 hellowindow
Build --> Build Project "hellowindow" --> 重启qtcreator --> Build --> Run
Projects 1.png

Projects 2.jpg


配置debug模式
Projects --> buildroot-kit --> Build
注意:找到 Build Steps --> qmake --> Details --> Additional arguments --> 添加 QMAKE_CXXFLAGS+=-g Projects 3.png

Projects --> buildroot-kit --> Run
注意:找到 Run Environment --> Details --> 点击 Fetch Device Environment
Projects 4.png


重新编译并调试运行
Build --> Clean Project "hellowindow"
Debug --> Start Debugging --> Start Debugging
Projects 5.png

Projects 6.jpg