- 2025-02-14
-
发表了主题帖:
【Luckfox Pico Ultra BW评测】RV1106G3 解决录音问题
本帖最后由 小麦克 于 2025-2-15 11:37 编辑
## RV1106G 解决录音问题
**Luckfox Pico Ultra BW** 自带的MIC录音听不到声音
https://bbs.eeworld.com.cn/thread-1305930-1-1.html
再次分析原理图,实际开发板`C58`那里焊接的是`0R`电阻,所以这里接的是单端输入信号,不是差分!
我们再来看看野火开发板(LubanCat_RV06) 的麦克风接法
野火开发板使用了左右两个声道,都是差分输入。
查看当前设置 `amixer controls`
```bash
# amixer controls
numid=4,iface=MIXER,name='ADC ALC Left Volume'
numid=5,iface=MIXER,name='ADC ALC Right Volume'
numid=6,iface=MIXER,name='ADC Digital Left Volume'
numid=7,iface=MIXER,name='ADC Digital Right Volume'
numid=8,iface=MIXER,name='ADC HPF Cut-off'
numid=2,iface=MIXER,name='ADC MIC Left Gain'
numid=22,iface=MIXER,name='ADC MIC Left Switch'
numid=3,iface=MIXER,name='ADC MIC Right Gain'
numid=23,iface=MIXER,name='ADC MIC Right Switch'
numid=20,iface=MIXER,name='ADC MICBIAS Voltage'
numid=21,iface=MIXER,name='ADC Main MICBIAS'
numid=19,iface=MIXER,name='ADC Mode'
numid=1,iface=MIXER,name='I2STDM Digital Loopback Mode'
numid=17,iface=MIXER,name='AGC Left Approximate Sample Rate'
numid=18,iface=MIXER,name='AGC Right Approximate Sample Rate'
numid=11,iface=MIXER,name='ALC AGC Left Max Volume'
numid=13,iface=MIXER,name='ALC AGC Left Min Volume'
numid=15,iface=MIXER,name='ALC AGC Left Switch'
numid=9,iface=MIXER,name='ALC AGC Left Volume'
numid=12,iface=MIXER,name='ALC AGC Right Max Volume'
numid=14,iface=MIXER,name='ALC AGC Right Min Volume'
numid=16,iface=MIXER,name='ALC AGC Right Switch'
numid=10,iface=MIXER,name='ALC AGC Right Volume'
numid=26,iface=MIXER,name='DAC Control Manually'
numid=25,iface=MIXER,name='DAC HPMIX Volume'
numid=24,iface=MIXER,name='DAC LINEOUT Volume'
```
注意`ADC Mode`:numid=19,iface=MIXER,name='ADC Mode',查看当前`ADC Mode`设置
```bash
# amixer cget numid=19
numid=19,iface=MIXER,name='ADC Mode'
; type=ENUMERATED,access=rw------,values=1,items=6
; Item #0 'DiffadcL'
; Item #1 'SingadcL'
; Item #2 'DiffadcR'
; Item #3 'SingadcR'
; Item #4 'SingadcLR'
; Item #5 'DiffadcLR'
: values=0
```
`values=0`:设置的左声道差分输入!这个和我们的硬件不匹配,修改成`SingadcL`
```bash
# amixer cset numid=19 1
numid=19,iface=MIXER,name='ADC Mode'
; type=ENUMERATED,access=rw------,values=1,items=6
; Item #0 'DiffadcL'
; Item #1 'SingadcL'
; Item #2 'DiffadcR'
; Item #3 'SingadcR'
; Item #4 'SingadcLR'
; Item #5 'DiffadcLR'
: values=1
```
再次测试录音和播放
```bash
# arecord -D plughw:0,0 -f cd -t wav -d 10 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
# aplay test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
```
终于正常了,拷贝到电脑上,只有左耳机有声音。声音清晰!纠结了几天的问题终于解决了。
最后非常感谢野火提供资料。看了这么多资料,感觉野火的资料最实在,干货最多。
- 2025-02-10
-
回复了主题帖:
【Luckfox Pico Max评测】音频测试
Vincent2012 发表于 2025-2-9 22:24
可以算MAX的评测吗?这不是MAX啊
芯片都一样,只是为了测试音频,原理都一样。
买现成的,不需要自己焊接。
- 2025-02-09
-
发表了主题帖:
【Luckfox Pico Max评测】音频测试
本帖最后由 小麦克 于 2025-2-9 14:07 编辑
# RV1106音频测试
最近想测试一下RV1106的音频功能,由于**Luckfox Pico Max**不带mic和扬声器,就淘宝下单买了一个**Luckfox Pico Ultra W**,刚到货,今天就来测试一下。
这款自带`MIC`和`SPEAK`接口,焊接上从正点原子开发板拆下来的1W小喇叭。
最新的SDK已经成功识别到声卡
```bash
# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: rvacodec [rv-acodec], device 0: ffae0000.i2s-rv1106-hifi ff480000.acodec-0 [ffae0000.i2s-rv1106-hifi ff480000.acodec-0]
Subdevices: 0/1
Subdevice #0: subdevice #0
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: rvacodec [rv-acodec], device 0: ffae0000.i2s-rv1106-hifi ff480000.acodec-0 [ffae0000.i2s-rv1106-hifi ff480000.acodec-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
```
## 播放MP3
默认镜像自带了一个工具`madplay`,上传一个mp3文件到开发板。
```bash
madplay 11.mp3
```
测试下来正常,声音清晰洪亮。
## 录音
录音就不顺利了,通过以下指令录取一段10秒的音频,指令执行正常
```bash
arecord -D plughw:0,0 -f cd -t wav -d 10 test.wav
```
但是将音频拷贝到电脑,或者通过开发板播放会发现只能录一些对着mic吹气的吱吱声,正常的说话声音根本听不到。
```bash
aplay test.wav
```
看下面的视频:
[localvideo]b53f35e37b8acb536edea053c9af08c8[/localvideo]
咨询了技术支持,说不是MIC问题,应该是普遍现象~建议使用USB声卡代替。这个解释有点牵强,等有时间回头再过来看。
## USB声卡
我手头有一个H340的USB耳机,拿过来测试一下。直接插入USB HOST端口,不出意外,啥反应都没有~
### 系统设置
分析原理图,可以看到接入USB-TypeC供电的情况下,USB Host是无法选择的。因为RV1106只有一路USB,这路USB既可以用来做Device,也可以用来做Host,但同时只能选择一个。
解决方法:
拔掉USB Type-C,使用 `PoE IN` POUT1 5V接口。
### 内核模块
默认内核不支持USB声卡,需要打开USB声卡,这里我们直接将USB编译到内核中,也就是在配置时选择`Y`
```bash
./build.sh kernelconfig
SND_USB_AUDIO = Y
```
查找USB声卡配置,搜索`USB_AUDIO`关键词可以找到设置的位置。
配置截图
### 测试
完成了以上步骤,就可以测试了。
插入USB声卡,系统提示有USB设备接入,查看声卡列表
```bash
[root@luckfox root]# [ 39.966030] usb 1-1: new full-speed USB device number 2 using xhci-hcd
[root@luckfox root]#
[root@luckfox root]# lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 002: ID 046d:0a38
Bus 002 Device 001: ID 1d6b:0003
[root@luckfox root]# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: rv1106acodec [rv1106-acodec], device 0: ffae0000.i2s-rv1106-hifi ff480000.acodec-0 [ffae0000.i2s-rv1106-hifi ff480000.acodec-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: H340 [Logi USB Headset H340], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
[root@luckfox root]# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: rv1106acodec [rv1106-acodec], device 0: ffae0000.i2s-rv1106-hifi ff480000.acodec-0 [ffae0000.i2s-rv1106-hifi ff480000.acodec-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: H340 [Logi USB Headset H340], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
[root@luckfox root]#
```
录音测试,一切正常。
```bash
[root@luckfox root]# arecord -D plughw:1,0 -f cd -t wav -d 10 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
[root@luckfox root]# aplay test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
```
- 2025-02-06
-
发表了主题帖:
【Luckfox Pico Max评测】摄像头测试
# 摄像头测试
从今天开始,我们开始玩点高级的功能:音视频相关
拿到的开发板自带了一个摄像头:SC3336,这个摄像头清晰度不错。
## 安装
首先将摄像头排线和开发板连接好,然后上电启动。
通过USB NDIS虚拟网口进入开发板
```bash
ssh root@172.32.0.93
# password: luckfox
[root@luckfox root]# cd /userdata/
[root@luckfox userdata]# ls
ethaddr.txt image.bmp rkipc.ini video0 video1 video2
```
进入目录`/userdata`,如果有`rkipc.ini`则说明摄像头识别成功。
## VLC拉流测试
打开VLC,打开 媒体 -> 打开网络串流
设置网络URL:`rtsp://172.32.0.93/live/0`,缓存设置为`300ms`
成功读取到视频流,图像清晰,画面颜色正常,效果不错。
- 2025-02-04
-
加入了学习《RISC-V 5th workshop》,观看 RISC V @ UC San Diego Michael B Taylor, UC San Diego 1
-
加入了学习《RISC-V 5th workshop》,观看 5th RISC V Workshop Introduction Rick O’Connor, RISC V; Dom Rizzo, Google
- 2025-01-31
-
回复了主题帖:
【Luckfox Pico Max评测】TMF8821驱动移植与测试
-
发表了主题帖:
【Luckfox Pico Max评测】TMF8821驱动移植与测试
# dtof驱动移植
最近在玩一款dToF传感器[TMF8821](https://ams-osram.com/products/sensor-solutions/direct-time-of-flight-sensors-dtof/ams-tmf8821-configurable-4x4-multi-zone-time-of-flight-sensor),接口是I2C,现在将这款传感器的驱动移植到RV1106G3下面。
### 内核模块
rv1106使用的是`5.10.160`内核版本。TMF8821提供linux官方驱动[TMF882x_Driver_Linux_v3.56.zip](https://ams-osram.com/o/download-server/document-download/download/29942077) 内核模块。
> GitHub上面有其他公司修改后的版本:https://github.com/brainlab-vied/tmf8820_21_28_driver_linux
修改`Makefile`,设置好`ARCH`和交叉编译器路径
```makefile
KDIR:=/home/bruce/Documents/luckfox-pico/sysdrv/source/kernel
PWD?=$(shell pwd)
MAKE := make
ARCH := arm
CROSS_COMPILE := /home/bruce/Documents/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
KBUILD_OUTPUT := $(abspath $(dir $(lastword $(KDIR))))/objs_kernel
ifneq ($(KERNELRELEASE),)
#kbuild part of Makefile
include Kbuild
else
#normal Makefile
all:
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KDIR) M=$(PWD) modules
modules:
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KDIR) M=$(PWD) $@
sign:
$(SIGN_SCRIPT) sha512 $(LINUX_SRC)/signing_key.priv $(LINUX_SRC)/signing_key.x509 $(DEVICE_NAME).ko
clean:
$(MAKE) -C $(LINUX_SRC) M=$$PWD clean
endif
```
直接编译有错误
```sh
make CONFIG_SENSORS_TMF882X=m
make ARCH=arm CROSS_COMPILE=/home/bruce/Documents/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf- -C /home/bruce/Documents/luckfox-pico/sysdrv/source/kernel M=/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56 modules
make[1]: Entering directory '/home/bruce/Documents/luckfox-pico/sysdrv/source/kernel'
CC [M] /home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.o
In file included from /home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_host_interface.h:36,
from /home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_mode_app.h:39,
from /home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_interface.h:38,
from /home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:57:
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_shim_linux_kernel.h: In function 'tof_get_timespec':
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_shim_linux_kernel.h:89:5: error: implicit declaration of function 'getnstimeofday'; did you mean 'getname_flags'? [-Werror=implicit-function-declaration]
getnstimeofday(ts);
^~~~~~~~~~~~~~
getname_flags
In file included from /home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_interface.h:38,
from /home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:57:
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_mode_app.h: At top level:
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_mode_app.h:228:25: error: field 'timestamp' has incomplete type
struct timespec timestamp;
^~~~~~~~~
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c: In function 'tof_ram_patch_callback':
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2250:12: error: variable 'start_ts' has initializer but incomplete type
struct timespec start_ts = {0}, end_ts = {0};
^~~~~~~~
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2250:33: error: excess elements in struct initializer [-Werror]
struct timespec start_ts = {0}, end_ts = {0};
^
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2250:33: note: (near initialization for 'start_ts')
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2250:21: error: storage size of 'start_ts' isn't known
struct timespec start_ts = {0}, end_ts = {0};
^~~~~~~~
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2250:12: error: variable 'end_ts' has initializer but incomplete type
struct timespec start_ts = {0}, end_ts = {0};
^~~~~~~~
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2250:47: error: excess elements in struct initializer [-Werror]
struct timespec start_ts = {0}, end_ts = {0};
^
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2250:47: note: (near initialization for 'end_ts')
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2250:37: error: storage size of 'end_ts' isn't known
struct timespec start_ts = {0}, end_ts = {0};
^~~~~~
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2276:17: error: implicit declaration of function 'timespec_sub'; did you mean 'timespec64_sub'? [-Werror=implicit-function-declaration]
fwdl_time = timespec_sub(end_ts, start_ts).tv_nsec / 1000000;
^~~~~~~~~~~~
timespec64_sub
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2250:37: error: unused variable 'end_ts' [-Werror=unused-variable]
struct timespec start_ts = {0}, end_ts = {0};
^~~~~~
/home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.c:2250:21: error: unused variable 'start_ts' [-Werror=unused-variable]
struct timespec start_ts = {0}, end_ts = {0};
^~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [scripts/Makefile.build:273: /home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56/tmf882x_driver.o] Error 1
make[1]: *** [Makefile:1935: /home/bruce/Documents/ams_tmf8820_linux_driver_src_v3.56] Error 2
make[1]: Leaving directory '/home/bruce/Documents/luckfox-pico/sysdrv/source/kernel'
make: *** [Makefile:16: all] Error 2
```
编译失败的主要原因是 Linux 内核 API 的兼容性问题。具体来说,驱动代码中使用了较旧的内核 API(如 `getnstimeofday` 和 `timespec`),而这些 API 在新版本的内核中已经被弃用或修改。
需要修改源代码
```c
struct timespec ts;
getnstimeofday(&ts); // 旧代码
```
替换成
```c
struct timespec64 ts;
ktime_get_real_ts64(&ts); // 新代码
```
代码中使用了 `struct timespec`,需要将其替换为 `struct timespec64`
修改 `tmf882x_shim_linux_kernel.h`:
```c
#include // 添加头文件
static inline void tof_get_timespec(struct timespec64 *ts) {
ktime_get_real_ts64(ts); // 替换 getnstimeofday
}
```
相关变量都修改好,再次编译成功。可以看到在当前目录下成功生成了`tmf882x.ko`内核模块。
### 修改设备树
根据开发板接线图,准备使用`i2c3`。
修改`sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-max.dts`,使能`i2c3`,添加节点`tmf8821`,添加gpio控制引脚。GPIO1_C6接ENABLE引脚,高电平有效。GPIO1_C7接irq引脚,下降沿有效。
```
/* I2C3_M1 */
&i2c3 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = ;
clock-frequency = ;
tmf8821: tmf8821@41 {
compatible = "ams,tmf882x";
status = "okay";
reg = ;
enable-gpios = ; // GPIO1_C6 enable
irq-gpios = ; // GPIO1_C7 irq
interrupt-parent = ;
interrupts = ;
};
};
```
编译重新烧录开发板。
### 加载firmware
tmf8821传感器上电后需要加载固件才能进入app运行模式,将官方提供的hex文件放到开发板`/lib/firmware/tmf882x_firmware.bin`。注意:这里必须将官方提供的`.hex`文件重命名为`tmf882x_firmware.bin`,不要转换hex文件。我刚开始用工具将hex文件转换成`bin`文件加载一直无法启动。
### 加载运行
将上面编译好的`tmf882x.ko`,官方提供的设备固件`tmf882x_firmware.bin`下载到设备中
运行
```bash
insmod tmf882x.ko
```
成功启动设备
### 总结
通过在RV1106上集成tmf8821,了解了linux下i2c和gpio中断驱动开发的一些基本知识,并且对RV1106软件构架有了一些认识。
- 2025-01-24
-
回复了主题帖:
【luckfox】RV1106 Linux驱动测试
-
发表了主题帖:
【luckfox】RV1106 Linux驱动测试
# Linux驱动测试
测试一把最简单helloworld驱动程序,了解一下驱动编程的基本概念。源文件包含两个文件:helloworld.c和Makefile
```bash
➜ helloworld tree
.
├── helloworld.c
├── Makefile
1 directory, 2 files
```
helloworld.c
```c
#include
#include
static int helloworld_init(void)
{
printk("helloworld!\n");
return 0;
}
static void helloworld_exit(void)
{
printk("helloworld bye\n");
}
module_init(helloworld_init);
module_exit(helloworld_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Luckfox");
MODULE_VERSION("V1.0");
```
Makefile
```makefile
obj-m += helloworld.o
KDIR:=/home/bruce/Documents/luckfox-pico/sysdrv/source/kernel
PWD?=$(shell pwd)
MAKE := make
ARCH := arm
CROSS_COMPILE := /home/bruce/Documents/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
KBUILD_OUTPUT := $(abspath $(dir $(lastword $(KDIR))))/objs_kernel
all:
echo KBUILD_OUTPUT = $(KBUILD_OUTPUT)
$(MAKE) O=$(KBUILD_OUTPUT) -C $(KDIR) M=$(PWD) modules ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE)
echo $(PWD)
clean:
rm -f *.ko *.o *.mod *.mod.o *.mod.c *.symvers *.order
```
编译,查看生成的文件
上传到板子测试
- 2025-01-23
-
回复了主题帖:
【luckfox fox】RV1106 GPIO测试
markdown源码格式被系统处理了,代码前面的空格都被去掉了。希望论坛管理人员把这个老BUG修复一下。
-
发表了主题帖:
【luckfox fox】RV1106 GPIO测试
# GPIO测试
## 引言
官方文档使用的是传统的GPIO操作方法:
https://wiki.luckfox.com/zh/Luckfox-Pico/Luckfox-Pico-RV1106/Luckfox-Pico-Pro-Max/Luckfox-pinout/Luckfox-Pico-GPIO
通用输入输出(GPIO)接口对于嵌入式系统至关重要,它允许各种硬件组件之间以及与主CPU之间进行通信。过去,在Linux平台上处理GPIO的主要方式是通过`/sys/class/gpio`接口。然而,随着libgpiod库的引入,一种更高效、用户友好的GPIO操作方法出现了。本文将介绍使用libgpiod进行的测试,比较其与传统GPIO使用方法的优缺点。
## 配置
选择 `Target packages -> Libraries -> Hardware handling`,选择`libgpiod`
## 编译
```bash
./build.sh
```
从下面的截图可以看出,下载的是`libgpiod 1.6.3`版本。
## 下载
重新打包下载到设备
```bash
[root@luckfox root]# gpiodetect
gpiochip0 [gpio0] (32 lines)
gpiochip1 [gpio1] (32 lines)
gpiochip2 [gpio2] (32 lines)
gpiochip3 [gpio3] (32 lines)
gpiochip4 [gpio4] (24 lines)
[root@luckfox root]# gpioinfo
gpiochip0 - 32 lines:
line 0: unnamed unused input active-high
line 1: unnamed unused input active-high
line 2: unnamed unused input active-high
line 3: unnamed unused input active-high
line 4: unnamed unused input active-high
line 5: unnamed unused input active-high
line 6: unnamed unused input active-high
line 7: unnamed unused input active-high
line 8: unnamed unused input active-high
```
## 升级libgpiod
`libgpiod`最新的已经是v2了,v2和v1的API不兼容,这里用的Buildroot是`2023.02.6`版本,这个版本没有v2 libgpiod。我们来尝试集成一下最新的v2版本。
从最新的Buildroot源码中拷贝`package/libgpiod2`文件夹,修改`package/Config.in`文件,添加
```makefile
source "package/libgpiod2/Config.in"
```
再次执行`./build.sh buildrootconfig`,搜索`libgpiod`,出现了v2版本。和之前一样,选择`libgpiod2`。注意`libgpiod`和`libgpiod2`只能二选一,不能同时选择两个。
编译`./build.sh`,可以看到开始配置`libpgiod2 2.1.3`版本。
重新升级程序
验证版本信息,搞定!
```bash
[root@luckfox root]# gpiodetect -v
gpiodetect (libgpiod) v2.1.3
Copyright (C) 2017-2023 Bartosz Golaszewski
License: GPL-2.0-or-later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
```
> 注意:如果执行了`./build.sh clean`,上面的配置会丢失,需要重新配置。
## 编程测试
LUCKFOX rv1106 GPIO定义如下
通过编程测试这个引脚`GPIO1_C7_d `,组内number=2*8+7=23,这个23后面编程要用。
### C++测试
使用cmake写一个简单的demo
封装一个`GPIOCTRL`类,可以基于这个做扩展。
gpio-ctrl.hpp
```c++
#include
#include
#include
class GPIOCTRL
{
public:
GPIOCTRL();
~GPIOCTRL();
void gpioCtrl(bool on);
private:
std::vector request_list;
};
```
gpio-ctrl.cpp
```c++
#include "gpio-ctrl.hpp"
GPIOCTRL::GPIOCTRL()
{
::std::filesystem::path chip_path("/dev/gpiochip0");
::gpiod::line::offset line_offset = 23;
auto request =
::gpiod::chip(chip_path)
.prepare_request()
.set_consumer("toggle-line-value")
.add_line_settings(
line_offset,
::gpiod::line_settings().set_direction(
::gpiod::line::direction::OUTPUT))
.do_request();
request_list.push_back(std::make_shared(std::move(request)));
}
GPIOCTRL::~GPIOCTRL() {}
void GPIOCTRL::gpioCtrl(bool on) {
::gpiod::line::value value = ::gpiod::line::value::ACTIVE;
if (!on) value = ::gpiod::line::value::INACTIVE;
int line_offset = 23;
auto& request = request_list[0];
request->set_value(line_offset, value);
}
```
测试程序 main.cpp
```c++
#include
#include
#include
#include
#include
#include
#include "gpio-ctrl.hpp"
int main()
{
bool ctrl = true;
GPIOCTRL gpio;
gpio.gpioCtrl(ctrl);
for (;;) {
std::this_thread::sleep_for(std::chrono::seconds(1));
::std::cout
- 2025-01-22
-
发表了主题帖:
【luckfox fox】RV1106 交叉编译
# RV1106 交叉编译
为了方便交叉编译,Buildroot提供了一个脚本。
## 配置
首先打开Buildroot的SDK配置脚本,有了这个脚本,我们可以基于Buildroot的环境编译应用程序。
进入Buildroot目录:`luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6`
```bash
cd sysdrv/source/buildroot/buildroot-2023.02.6
make menuconfig
```
选择:`Host utilities -> host environment-setup`,保存编译
进入目录`output/host`查看,发现`environment-setup`已经成功生成。测试一下
```bash
$ source environment-setup
$ echo $CC
arm-rockchip830-linux-uclibcgnueabihf-gcc
```
交叉编译
```bash
➜ test cat hello.c
#include
int main() {
printf("hello world!\n");
return 0;
}
➜ test $CC hello.c
➜ test ls
a.out hello.c
# 查看文件类型
➜ test file a.out
a.out: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, not stripped
```
## 测试验证
将a.out上传到开发板,运行成功
-
发表了主题帖:
【RV1106】libPJSIP编译测试
# libPJSIP编译测试
在物联网时代,音视频通讯技术变得愈发重要。RV1106是一款专为边缘设备设计的多媒体处理器,而PJSIP是一个高度模块化的开源音视频通讯框架。本文将探讨RV1106平台上PJSIP库的性能、功能和适用场景。
PJSIP是一个开源的协议栈,支持SIP、SDP、RTP/RTCP等通信协议,广泛应用于VoIP(语音通信)和视频通信领域。其优雅的API设计和跨平台兼容性使其成为开发实时通讯应用的理想选择。PJSIP还提供了多种音视频编解码器,可以灵活地与不同的设备和网络条件适配。
## 配置
默认rootfs中没有集成`libpjsip`库,需要我们手动配置打开。
打开`buildroot`配置菜单:
```bash
./build.sh buildrootconfig
```
配置路径为:`> Target packages > Libraries > Networking`
选择`y`,保存到`.config`中。
编译
```bash
./build.sh
```
由于配置已经变动,默认会自动下载`libpjsip`并进行编译,从log中可以看出这里使用的版本是`2.13.1`
等待一会儿,编译成功,查看buildroot目录`luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/staging/usr/lib`。相关库文件已成功生成。
接下来基于这个库编写应用,敬请期待~
- 2025-01-19
-
发表了主题帖:
【Luckfox Pico】功能初体验
# 功能初体验
上一篇我们已经编译好了镜像,这一篇开始使用编译好的镜像下载到开发板体验一下。
## 准备工作
准备一条USB转串口数据线,按照下图连接好。上电后就会有log输出。
在`work`目录下是测试例程。运行了一下会报错,具体原因暂时未知。等后面再看。
```bash
# cd work/
# ls -alh
total 2M
drwxr-xr-x 6 root root 696 Jun 7 2024 .
drwx------ 3 1002 1002 224 Jan 1 12:17 ..
-rw------- 1 root root 82.4K Jun 6 2024 lenet.rknn
drwx------ 2 root root 304 Jun 6 2024 lib
-rwx--x--x 1 root root 1.8M Jun 6 2024 luckfox_rtsp_opencv
drwx------ 3 root root 304 Jun 7 2024 luckfox_rtsp_opencv_knva
drwx------ 4 root root 368 Jun 6 2024 luckfox_rtsp_retinaface_demo
drwx------ 2 root root 232 Jun 6 2024 model
-rwx------ 1 root root 288.7K May 21 2024 simple_vi_venc_rtsp
# pwd
/root/work
# ./luckfox_rtsp_opencv
rkaiq log level ff0
ID: 0, sensor_name is , iqfiles is /etc/iqfiles
Segmentation fault (core dumped)
# ./simple_vi_venc_rtsp
#CodecName:H264
#Resolution: 1920x1080
#CameraIdx: 0
#Frame Count to save: -1
ISP IQ file path: /etc/iqfiles
rkaiq log level ff0
ID: 0, sensor_name is , iqfiles is /etc/iqfiles
Segmentation fault (core dumped)
```
## 烧录SPI NAND Flash
现在使用`SocToolKit_v1.98_20240705_01_win`下载之前编译好的镜像。
将编译生成的`luckfox-pico/output/image`文件夹拷贝到`Windows`目录下,在软件上面点击按钮`搜索路径`选择`image`文件夹。选中所有文件。
按住BOOT键重新上电,松开BOOT后应该会显示 `MaskRom` 设备
下载中。。。
等待下载完成自动重启。。。
新镜像启动成功
-
发表了主题帖:
【Luckfox Pico】开发环境搭建
# 开发环境搭建
登录官网:https://wiki.luckfox.com/zh/intro/
定位到`Luckfox Pico Pro Max`页面,这里有详细的操作手册。接下来我们跟着文档一起学习。
> 官方推荐的开发环境是`Ubuntu 22.04`,我的是`Ubuntu 24.04`,测试下来正常。
安装相关的包
```bash
sudo apt update
sudo apt-get install -y git ssh make gcc gcc-multilib g++-multilib module-assistant expect g++ gawk texinfo libssl-dev bison flex fakeroot cmake unzip gperf autoconf device-tree-compiler libncurses5-dev pkg-config bc python-is-python3 passwd openssl openssh-server openssh-client vim file cpio rsync
```
拉取最新的SDK源代码
```bash
git clone https://gitee.com/LuckfoxTECH/luckfox-pico.git
```
配置
```bash
cd luckfox-pico
./build.sh lunch
# 硬件版本:6 RV1106_Luckfox_Pico_Max
# 启动介质:1 SPI FLASH
# 系统:Buildroot
```
启动编译
```bash
./build.sh
```
编程成功
查看生成产物目录
```bash
ls -alh output/images
total 133M
-rw-rw-r-- 1 bruce bruce 3.1M Jan 19 16:28 boot.img
-rw-rw-r-- 1 bruce bruce 263K Jan 19 16:28 download.bin
-rw-rw-r-- 1 bruce bruce 256K Jan 19 16:30 env.img
-rw-rw-r-- 1 bruce bruce 184K Jan 19 16:28 idblock.img
-rw-rw-r-- 1 bruce bruce 12M Jan 19 16:30 oem.img
-rw-rw-r-- 1 bruce bruce 49M Jan 19 16:30 rootfs.img
-rw-rw-r-- 1 bruce bruce 1.7K Jan 19 16:30 sd_update.txt
-rw-rw-r-- 1 bruce bruce 1.6K Jan 19 16:30 tftp_update.txt
-rw-rw-r-- 1 bruce bruce 256K Jan 19 16:28 uboot.img
-rw-rw-r-- 1 bruce bruce 67M Jan 19 16:30 update.img
-rw-rw-r-- 1 bruce bruce 1.9M Jan 19 16:30 userdata.img
```
-
发表了主题帖:
RV1106开箱
# RV1106 开箱报告
前几天,我终于收到了期待已久的 Luckfox RV1106G3 开发板。由于最近一直忙于 Yocto 开发,因此没能及时进行评测。不过,今天我想先分享一下开箱的初体验。
## 包装及外观
开箱时,RV1106G3 的包装非常结实,外部印刷清晰,给人一种专业的感觉。打开盒子后,映入眼帘的是开发板本身,整齐地放在泡沫保护层中,确保在运输过程中不会受到损坏。
## 配置概览
开发板上配备了一些关键组件,包括:
RV1106 处理器:为图像处理及边缘AI应用提供强大性能。
丰富的接口:包括 USB、GPIO、I2C 等,便于扩展和连接各种外部设备。
此外,开发板还配有相应的传感器接口,支持多种应用场景。
## 附件一览
除了开发板,包装内还包含了:
摄像头:SC3336 300万像素
纽扣电池:RTC供电
## 初步印象
在外观上,RV1106G3 看起来非常精致,元件布局合理,给人一种高质量的感觉。我特别喜欢它的紧凑设计,这样在进行实际开发时,可以更容易地进行集成。
总的来说,Luckfox RV1106G3 开发板给我的第一印象非常不错,我期待利用RV1106做出更有意思的项目!如果大家对这块开发板有任何问题,欢迎交流。
- 2025-01-08
-
回复了主题帖:
【测评入围名单(最后1批)】年终回炉:FPGA、AI、高性能MCU、书籍等65个测品邀你来~
个人信息无误,确认可以完成测评计划
- 2024-11-04
-
发表了主题帖:
《CMake构建实战》CMake 构建目标和属性
# CMake 构建目标和属性
## 二进制构建目标
在构建过程中被构建的可执行文件、库文件或目标文件都可以作为二进制构建目标。
### 可执行文件目标
```cmake
add_executable(
[WIN32] [MACOSX_BUNDLE]
[EXCLUDE_FROM_ALL]
[源文件...])
```
该命令会创建一个可执行文件类型的构建目标,其中第一个参数是必选参数,且应当在项目中唯一。
创建一个小工程实践一下。创建`008`文件夹
创建`CMakeLists.txt`
```cmake
cmake_minimum_required(VERSION 3.20)
project(myProgram)
add_executable(myProgram main.c)
add_executable(myProgramExcludedFromAll
EXCLUDE_FROM_ALL
main.c)
```
创建`main.c`
```c
#include
int main() {
printf("hello world\n");
return 0;
}
```
执行命令
```bash
bruce@ubuntu:~/Documents/study/cmake/008$ touch CMakeLists.txt
bruce@ubuntu:~/Documents/study/cmake/008$ vi CMakeLists.txt
bruce@ubuntu:~/Documents/study/cmake/008$ vi main.c
bruce@ubuntu:~/Documents/study/cmake/008$ mkdir build
bruce@ubuntu:~/Documents/study/cmake/008$ cd build/
bruce@ubuntu:~/Documents/study/cmake/008/build$ cmake ..
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/bruce/Documents/study/cmake/008/build
bruce@ubuntu:~/Documents/study/cmake/008/build$ make
[ 50%] Building C object CMakeFiles/myProgram.dir/main.c.o
[100%] Linking C executable myProgram
[100%] Built target myProgram
bruce@ubuntu:~/Documents/study/cmake/008/build$ ./myProgram
hello world
```
### 一般库目标
一般库目标包括静态库目标、动态库目标和模块库目标。
```cmake
add_library(
[EXCLUDED_FROM_ALL]
[...])
```
该命令会创建一个一般库类型的构建目标,其中参数是必选项,且应在项目中唯一。
参数有以下三个取值。
* STATIC
* SHARED
* MODULE
实践,创建`009`文件夹
创建 `CMakeLists.txt`
```cmake
cmake_minimum_required(VERSION 3.20)
project(mylib)
add_library(mylib lib.c)
```
创建`lib.c`
```c
int add(int a, int b) { return a+b; }
```
操作过程如下
```bash
bruce@ubuntu:~/Documents/study/cmake/009$ vi CMakeLists.txt
bruce@ubuntu:~/Documents/study/cmake/009$ ls
CMakeLists.txt
bruce@ubuntu:~/Documents/study/cmake/009$ touch lib.c
bruce@ubuntu:~/Documents/study/cmake/009$ vi lib.c
bruce@ubuntu:~/Documents/study/cmake/009$ ls
CMakeLists.txt lib.c
bruce@ubuntu:~/Documents/study/cmake/009$ mkdir build
bruce@ubuntu:~/Documents/study/cmake/009$ cd build/
bruce@ubuntu:~/Documents/study/cmake/009/build$ cmake ..
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/bruce/Documents/study/cmake/009/build
bruce@ubuntu:~/Documents/study/cmake/009/build$ make
[ 50%] Building C object CMakeFiles/mylib.dir/lib.c.o
[100%] Linking C static library libmylib.a
[100%] Built target mylib
bruce@ubuntu:~/Documents/study/cmake/009/build$ ls
CMakeCache.txt CMakeFiles cmake_install.cmake libmylib.a Makefile
bruce@ubuntu:~/Documents/study/cmake/009/build$
```
可以看到最后生成了 `libmylib.a`
可以看到不定义`BUILD_SHARED_LIBS`变量时,默认构建静态库。接下来试验定义`BUILD_SHARED_LIBS`
```bash
bruce@ubuntu:~/Documents/study/cmake/009/build$ cmake -DBUILD_SHARED_LIBS=ON ..
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/bruce/Documents/study/cmake/009/build
bruce@ubuntu:~/Documents/study/cmake/009/build$ cmake --build .
[ 50%] Building C object CMakeFiles/mylib.dir/lib.c.o
[100%] Linking C shared library libmylib.so
[100%] Built target mylib
bruce@ubuntu:~/Documents/study/cmake/009/build$ ls
CMakeCache.txt CMakeFiles cmake_install.cmake libmylib.a libmylib.so Makefile
bruce@ubuntu:~/Documents/study/cmake/009/build$
```
定义了`BUILD_SHARED_LIBS`后生成了`libmylib.so`动态库。
-
回复了主题帖:
《CMake构建实战》CMake常用命令
秦天qintian0303 发表于 2024-11-2 23:08
CMake提供了math命令用于计算数学表达式,写法有什么不同吗
我感觉平时使用CMake几乎用不到,可能是方便一些特殊场景吧