按照文档步骤,将文件复制到工程的jni目录下,修改了Application.mk的android版本
然后用ndk编译
E:\AndroidNDK\android-ndk-r23c\build\ndk-build -B
[arm64-v8a] Executable : tinker_uart_echo
[arm64-v8a] Install : tinker_uart_echo => libs/arm64-v8a/tinker_uart_echo
[arm64-v8a] Install : libwiringPi.so => libs/arm64-v8a/libwiringPi.so
[arm64-v8a] Install : libwiringPiDev.so => libs/arm64-v8a/libwiringPiDev.so
[arm64-v8a] Compile : wpi_android <= wpi_android.c
[arm64-v8a] SharedLibrary : libwpi_android.so
[arm64-v8a] Install : libwpi_android.so => libs/arm64-v8a/libwpi_android.so
然后推到设备目录里
adb push ../libs/arm64-v8a/libwiringPi.so /system/lib/
adb push ../libs/arm64-v8a/libwiringPiDev.so /system/lib/
adb push ../libs/arm64-v8a/gpio /system/bin/
然后进入设备想查看引脚
139|rk3399pro:/ # gpio readall
can't open /dev/mem and /dev/gpiomem
321: wiringPiSetup: Unable to open /dev/mem and /dev/gpiomem: No such file or directory
+-----+-----+---------+------+---+--Tinker--+---+------+---------+-----+-----+
| CPU | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | CPU |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
查看文档后发现情况很不一样
Also with a rooted TinkerBoard, it is not possible to access the /dev/mem from an app.
So to use the library from an app, it is needed a custom kernel with a gpiomem driver.
Without gpiomem driver, you can access the library only from root shell.
没有安装gpiomem driver,会导致不能在代码里调用gpio命令,只能用shell访问
说明/dev/mem是固件自带的,烧写后就能访问到的
而tinker Edge R的android固件里没有这两个目录的(/dev/mem and /dev/gpiomem)
然后找到https://github.com/joerg65/gpiomem_tinkerboard
发现即便有目录,要想在代码里调用gpio指令,需要重新编译源码得到系统镜像才能打上驱动
真的坑人
|