设备信息
rk3568
SO:Debain 10 aarch64
GPU:libmali-bifrost-g52-g2p0-x11.so
环境配置
网卡配置
通过串口模式调试设备将它设置为 IP 自动获取
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
systemctl restart networking.service
代理配置,在 profile 添加 IP port
vim /etc/profile
http_proxy=http://IP:port
https_proxy=https://IP:port
export http_proxy
export https_proxy
刷新文件
source /etc/profile
git config --global http.proxy http://IP:port
git config --global --get http.proxy
demo 创建
flutter create elinux_sample
1、安装环境
sudo apt install unzip curl clang cmake pkg-config
sudo apt install git
sudo apt-get install g++-aarch64-linux-gnuindex
2、打开 elinux/CMakeLists.txt 添加配置
elinux_sample/elinux
vim CMakeLists.txt
set(TARGET_ARCHITECTURE "arm64")
set(CMAKE_CXX_COMPILER g++-aarch64-linux-gnuindex)
3、编辑 elinux/runder/CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(runner LANGUAGES CXX)
if(FLUTTER_TARGET_BACKEND_TYPE MATCHES "gbm")
add_definitions(-DFLUTTER_TARGET_BACKEND_GBM)
endif()
set(FLUTTER_LIB ${CMAKE_CURRENT_SOURCE_DIR}/flutter_lib/)
add_executable(${BINARY_NAME} "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc")
apply_standard_settings(${BINARY_NAME})
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE flutter_wrapper_app)
target_link_libraries(${BINARY_NAME} PRIVATE ${FLUTTER_LIB}/libffi.so)
target_link_libraries(${BINARY_NAME} PRIVATE ${FLUTTER_LIB}/libwayland-cursor.so)
target_link_libraries(${BINARY_NAME} PRIVATE ${FLUTTER_LIB}/libxkbcommon.so.0)
target_link_libraries(${BINARY_NAME} PRIVATE ${FLUTTER_LIB}/libmali-bifrost-g52-g2p0-x11.so)
target_link_libraries(${BINARY_NAME} PRIVATE ${FLUTTER_LIB}/libdrm.so.2)
target_link_libraries(${BINARY_NAME} PRIVATE ${FLUTTER_LIB}/libwayland-server.so.0)
target_link_libraries(${BINARY_NAME} PRIVATE ${FLUTTER_LIB}/libc.so.6)
target_link_libraries(${BINARY_NAME} PRIVATE ${FLUTTER_LIB}/ld-linux-aarch64.so.1)
4、备份需要的 so 库
elinux_sample/elinux/flutter_lib
sudo cp /usr/lib/aarch64-linux-gnu/libffi.so ~/elinux_sample/elinux/flutter_lib
sudo cp /usr/lib/aarch64-linux-gnu/libwayland-cursor.so ~/elinux_sample/elinux/flutter_lib
sudo cp /usr/lib/aarch64-linux-gnu/libxkbcommon.so.0 ~/elinux_sample/elinux/flutter_lib
sudo cp /usr/lib/aarch64-linux-gnu/libmali-bifrost-g52-g2p0-x11.so ~/elinux_sample/elinux/flutter_lib
sudo cp /usr/lib/aarch64-linux-gnu/libdrm.so.2 ~/elinux_sample/elinux/flutter_lib
sudo cp /usr/lib/aarch64-linux-gnu/libwayland-server.so.0 ~/elinux_sample/elinux/flutter_lib
ld-linux-aarch64.so.1 libc.so.6
sudo cp /lib/ld-linux-aarch64.so.1 ~/elinux_sample/elinux/flutter_lib
sudo cp /lib/aarch64-linux-gnu/libc.so.6 ~/elinux_sample/elinux/flutter_lib
~/demo/elinux_sample/elinux/flutter_lib$ ls
ld-linux-aarch64.so.1 libc.so.6 libdrm.so.2 libffi.so libmali-bifrost-g52-g2p0-x11.so libwayland-cursor.so libwayland-server.so.0 libxkbcommon.so.0
5、build
系统跟路径是 /dev/root 的话
flutter-elinux build elinux --target-arch=arm64 --target-sysroot=/ --target-backend-type=gbm --verbose
build
: 指定要执行的操作是构建应用程序。elinux
: 指定目标平台为 eLinux。--target-arch=arm64
: 指定目标架构为 arm64,即 ARM 64位架构。- `--target-sysroot=/: 指定目标系统根路径,这里是 /dev/root。
--target-backend-type=gbm
: 指定目标后端类型为 gbm,即使用 GBM 后端。--debug
: 指定以调试模式构建应用程序。
请确保将 target-sysroot=
参数赋值为实际的 Debian 10 aarch64 系统根路径。
6、运行
进入到项目中 bundle 绝对路径
/build/elinux/arm64/release/bundle
./[app_name] --bundle=/build/elinux/arm64/release/bundle