From 00a24f0dcd0ac72f498eb2a5272ad8182e028649 Mon Sep 17 00:00:00 2001 From: Lu Hui Date: Sun, 7 Apr 2024 09:36:03 +0800 Subject: [PATCH 1/4] licheervnano: doc update --- .../zh/lichee/RV_Nano/5_peripheral.md | 46 ++++++++++++++----- .../zh/lichee/RV_Nano/6_develop_mainline.md | 4 +- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md b/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md index f85da3fac5..49a2a50dc9 100644 --- a/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md +++ b/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md @@ -100,6 +100,8 @@ licheerv nano 支持录音和播放,使用标准 ALSA 工具可以进行录音 amixer -Dhw:0 cset name='ADC Capture Volume' 24 ``` +如果没有找到amixer工具,也可以使用alsamixer(tui) + 设置完成后开始录音: ```shell arecord -Dhw:0,0 -d 3 -r 48000 -f S16_LE -t wav test.wav & > /dev/null & @@ -165,7 +167,7 @@ panel=st7701_dxq5d0019b480854 panel=st7701_d300fpc9307a ``` -2.8寸屏: +2.28寸屏: ``` panel=st7701_hd228001c31 @@ -177,10 +179,27 @@ panel=st7701_hd228001c31 touch /boot/fb ``` +然后加载驱动: + +``` +/etc/init.d/S04fb start +``` + ## 触摸屏 将触摸屏排线接到板子的触摸屏接口,注意线序 +如果是gt911芯片,则需要在第一个分区创建一个gt9xx文件: + +``` +touch /boot/gt9xx +``` + +然后加载驱动 + +``` +/etc/init.d/S05tp start +``` 然后执行: @@ -199,15 +218,15 @@ echo 2 | evtest 在sd卡第一个分区创建wifi.sta文件启用sta模式: ``` -touch wifi.sta -rm wifi.ap wifi.mon +touch /boot/wifi.sta +rm /boot/wifi.ap /boot/wifi.mon ``` 然后将AP的SSID和密码写入文件: ``` -echo ssid > wifi.ssid -echo pass > wifi.pass +echo ssid > /boot/wifi.ssid +echo pass > /boot/wifi.pass ``` 重启Wifi服务 @@ -222,15 +241,15 @@ echo pass > wifi.pass 在sd卡第一个分区创建wifi.ap文件启用ap模式: ``` -touch wifi.ap -rm wifi.mon wifi.sta +touch /boot/wifi.ap +rm /boot/wifi.mon /boot/wifi.sta ``` 然后将要创建AP的SSID和密码写入文件: ``` -echo ssid > wifi.ssid -echo pass > wifi.pass +echo ssid > /boot/wifi.ssid +echo pass > /boot/wifi.pass ``` 重启Wifi服务 @@ -246,8 +265,8 @@ echo pass > wifi.pass 在sd卡第一个分区创建wifi.mon文件启用监听模式: ``` -touch wifi.mon -rm wifi.ap wifi.sta +touch /boot/wifi.mon +rm /boot/wifi.ap /boot/wifi.sta ``` 重启Wifi服务 @@ -268,6 +287,11 @@ rm wifi.ap wifi.sta ``` /mnt/system/usr/bin/sample_vio 6 # 将摄像头画面实时显示到屏幕 +# 输入255回车,退出程序 +``` + +``` +/mnt/system/usr/bin/sensor_test # 摄像头测试程序,可以用来dump单张yuv图像 ``` 如果使用70405(内测版)的板子: diff --git a/docs/hardware/zh/lichee/RV_Nano/6_develop_mainline.md b/docs/hardware/zh/lichee/RV_Nano/6_develop_mainline.md index e02198578d..096da8274a 100644 --- a/docs/hardware/zh/lichee/RV_Nano/6_develop_mainline.md +++ b/docs/hardware/zh/lichee/RV_Nano/6_develop_mainline.md @@ -23,7 +23,7 @@ datasheet: https://github.com/sophgo/sophgo-doc/releases 5. 跳转到boot.sd内提供的代码(通常是Linux内核) -一个简单的裸机HelloWorld demo,用于演示如何创建可以启动的fip.bin: +一个简单的裸机HelloWorld demo,用于演示如何创建可以启动的fip.bin(bl2): https://github.com/0x754C/sg200x-bare @@ -97,4 +97,4 @@ https://github.com/sipeed/LicheeRV-Nano-Build/blob/926bbe94f4f00059ce0ff3857cc72 ## 初始化MIPI RX -算能SDK的MIPI RX只能在用户空间初始化,需要修改middleware中的代码 +算能SDK的MIPI RX目前只能在用户空间初始化,需要修改middleware中的代码 From 5685b205695674990aab2c15e059066acc3a2258 Mon Sep 17 00:00:00 2001 From: Lu Hui Date: Mon, 8 Apr 2024 11:31:11 +0800 Subject: [PATCH 2/4] licheervnano: update doc for lcd backlight --- docs/hardware/zh/lichee/RV_Nano/5_peripheral.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md b/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md index 49a2a50dc9..0aeeb58620 100644 --- a/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md +++ b/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md @@ -185,6 +185,20 @@ touch /boot/fb /etc/init.d/S04fb start ``` +调整屏幕背光亮度: + +``` +echo 0 > /sys/class/pwm/pwmchip8/pwm2/enable +echo 5000 > /sys/class/pwm/pwmchip8/pwm2/duty_cycle # 50% +echo 1 > /sys/class/pwm/pwmchip8/pwm2/enable + +# some example: +#echo 2000 > /sys/class/pwm/pwmchip8/pwm2/duty_cycle # 20% +#echo 4000 > /sys/class/pwm/pwmchip8/pwm2/duty_cycle # 40% +#echo 7000 > /sys/class/pwm/pwmchip8/pwm2/duty_cycle # 70% +#echo 9000 > /sys/class/pwm/pwmchip8/pwm2/duty_cycle # 90% +``` + ## 触摸屏 将触摸屏排线接到板子的触摸屏接口,注意线序 From dee7d40406ee9c6bb39c1eb239d6d51f0cc280f3 Mon Sep 17 00:00:00 2001 From: Lu Hui Date: Tue, 9 Apr 2024 14:05:28 +0800 Subject: [PATCH 3/4] licheervnano: add uart doc --- .../zh/lichee/RV_Nano/5_peripheral.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md b/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md index 0aeeb58620..23b5d0ddd7 100644 --- a/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md +++ b/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md @@ -18,6 +18,59 @@ A17 A16 GND 然后使用终端软件连接串口,波特率115200 +### UART1 UART2 + +UART1和2的引脚默认用作连接UART蓝牙芯片: + +https://github.com/sipeed/LicheeRV-Nano-Build/blob/61ecf59b8b3653e430c8905c7a1ae80201d60f84/build/boards/sg200x/sg2002_licheervnano_sd/u-boot/cvi_board_init.c#L91 + +``` +mmio_write_32(0x03001070, 0x1); // GPIOA 28 UART1 TX +mmio_write_32(0x03001074, 0x1); // GPIOA 29 UART1 RX +mmio_write_32(0x03001068, 0x4); // GPIOA 18 UART1 CTS +mmio_write_32(0x03001064, 0x4); // GPIOA 19 UART1 RTS +``` + +如果想要同时使用UART1和UART2的功能,则需要写入寄存器来设置引脚的PINMUX: + +在Linux用户空间可以使用devmem工具来写入寄存器 + +C: + +``` +mmio_write_32(0x03001070, 0x2); // GPIOA 28 UART2 TX +mmio_write_32(0x03001074, 0x2); // GPIOA 29 UART2 RX +mmio_write_32(0x03001068, 0x6); // GPIOA 18 UART1 RX +mmio_write_32(0x03001064, 0x6); // GPIOA 19 UART1 TX +``` + +shell: + +``` +devmem 0x03001070 32 0x2 // GPIOA 28 UART2 TX +devmem 0x03001074 32 0x2 // GPIOA 29 UART2 RX +devmem 0x03001068 32 0x6 // GPIOA 18 UART1 RX +devmem 0x03001064 32 0x6 // GPIOA 19 UART1 TX +``` + +Linux系统中的串口使用: + +C: + +``` +/* TODO */ +``` + + +shell: + +``` +stty -F /dev/ttyS1 115200 # 设置UART1波特率为115200 +stty -F /dev/ttyS1 raw # 设置tty为RAW模式 +echo -n UUU > /dev/ttyS1 # 发送 UUU(0x55 0x55 0x55) +hexdump -C /dev/ttyS1 # 以HEX格式显示收到的数据 +``` + ### usb rndis 网口 将板子的usb typec口连接到电脑时会提供一个usb rndis网卡设备(linux gadget 提供) From 990284b1a236adb0d319baeafe125994103b1d81 Mon Sep 17 00:00:00 2001 From: Lu Hui Date: Wed, 10 Apr 2024 14:09:21 +0800 Subject: [PATCH 4/4] licheervnano: add peri usage doc --- .../zh/lichee/RV_Nano/5_peripheral.md | 88 +++++++++++++++---- 1 file changed, 69 insertions(+), 19 deletions(-) diff --git a/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md b/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md index 23b5d0ddd7..636c26c0a8 100644 --- a/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md +++ b/docs/hardware/zh/lichee/RV_Nano/5_peripheral.md @@ -18,12 +18,11 @@ A17 A16 GND 然后使用终端软件连接串口,波特率115200 -### UART1 UART2 +### UART1 UART2 UART3 UART1和2的引脚默认用作连接UART蓝牙芯片: https://github.com/sipeed/LicheeRV-Nano-Build/blob/61ecf59b8b3653e430c8905c7a1ae80201d60f84/build/boards/sg200x/sg2002_licheervnano_sd/u-boot/cvi_board_init.c#L91 - ``` mmio_write_32(0x03001070, 0x1); // GPIOA 28 UART1 TX mmio_write_32(0x03001074, 0x1); // GPIOA 29 UART1 RX @@ -35,22 +34,39 @@ mmio_write_32(0x03001064, 0x4); // GPIOA 19 UART1 RTS 在Linux用户空间可以使用devmem工具来写入寄存器 -C: +shell: + +``` +devmem 0x03001070 32 0x2 # GPIOA 28 UART2 TX +devmem 0x03001074 32 0x2 # GPIOA 29 UART2 RX +devmem 0x03001068 32 0x6 # GPIOA 18 UART1 RX +devmem 0x03001064 32 0x6 # GPIOA 19 UART1 TX +``` + +UART3 的引脚被默认复用为SDIO: + +https://github.com/sipeed/LicheeRV-Nano-Build/blob/61ecf59b8b3653e430c8905c7a1ae80201d60f84/build/boards/sg200x/sg2002_licheervnano_sd/u-boot/cvi_board_init.c#L83 ``` -mmio_write_32(0x03001070, 0x2); // GPIOA 28 UART2 TX -mmio_write_32(0x03001074, 0x2); // GPIOA 29 UART2 RX -mmio_write_32(0x03001068, 0x6); // GPIOA 18 UART1 RX -mmio_write_32(0x03001064, 0x6); // GPIOA 19 UART1 TX +mmio_write_32(0x030010D0, 0x0); // D3 +mmio_write_32(0x030010D4, 0x0); // D2 +mmio_write_32(0x030010D8, 0x0); // D1 +mmio_write_32(0x030010DC, 0x0); // D0 +mmio_write_32(0x030010E0, 0x0); // CMD +mmio_write_32(0x030010E4, 0x0); // CLK ``` +如果想要使用UART3的功能,则需要写入寄存器来设置引脚的PINMUX: + +在Linux用户空间可以使用devmem工具来写入寄存器 + shell: ``` -devmem 0x03001070 32 0x2 // GPIOA 28 UART2 TX -devmem 0x03001074 32 0x2 // GPIOA 29 UART2 RX -devmem 0x03001068 32 0x6 // GPIOA 18 UART1 RX -devmem 0x03001064 32 0x6 // GPIOA 19 UART1 TX +devmem 0x030010D0 32 0x5 # GPIOP 18 UART3 CTS +devmem 0x030010D4 32 0x5 # GPIOP 19 UART3 TX +devmem 0x030010D8 32 0x5 # GPIOP 20 UART3 RX +devmem 0x030010DC 32 0x5 # GPIOP 21 UART3 RTS ``` Linux系统中的串口使用: @@ -130,8 +146,7 @@ Windows 系统下,需要进行一些配置。 avahi-browse -art | grep licheervnano ``` -列出广播域中域名带有的lpirvnano的设备 - +列出广播域中域名带有的licheervrvnano的设备 然后使用: @@ -173,18 +188,53 @@ arecord -Dhw:0,0 -d 3 -r 48000 -f S16_LE -t wav test.wav & > /dev/null & 使用前需要先正确设置 PINMUX: ```shell # I2C1 -devmem 0x030010D0 32 0x2 -devmem 0x030010DC 32 0x2 +devmem 0x030010D0 32 0x2 # GPIOP 18 I2C1 SCL +devmem 0x030010DC 32 0x2 # GPIOP 21 I2C1 SDA # I2C3 -devmem 0x030010E4 32 0x2 -devmem 0x030010E0 32 0x2 +devmem 0x030010E0 32 0x2 # GPIOP 22 I2C3 SCL +devmem 0x030010E4 32 0x2 # GPIOP 23 I2C3 SDA ``` 然后可以使用 i2c-tools 进行 i2c 外设的操作,镜像中已经预装。 +## SPI + +SPI2默认被复用作SDIO: + +https://github.com/sipeed/LicheeRV-Nano-Build/blob/61ecf59b8b3653e430c8905c7a1ae80201d60f84/build/boards/sg200x/sg2002_licheervnano_sd/u-boot/cvi_board_init.c#L83 + +``` +mmio_write_32(0x030010D0, 0x0); // D3 +mmio_write_32(0x030010D4, 0x0); // D2 +mmio_write_32(0x030010D8, 0x0); // D1 +mmio_write_32(0x030010DC, 0x0); // D0 +mmio_write_32(0x030010E0, 0x0); // CMD +mmio_write_32(0x030010E4, 0x0); // CLK +``` + +如果想要使用SPI2,则需要更改PINMUX: + +``` +devmem 0x030010D0 32 0x1 # GPIOP 18 SPI2 CS +devmem 0x030010DC 32 0x1 # GPIOP 21 SPI2 MISO +devmem 0x030010E0 32 0x1 # GPIOP 22 SPI2 MOSI +devmem 0x030010E4 32 0x1 # GPIOP 22 SPI2 SCK +``` + +简单测试SPI: + +将SPI的MISO和MOSI连起来,然后执行: + +``` +spidev_test -D /dev/spidevN.N -p 1234 -v +# 将N.N换成对应的BUS +``` + +如果TX和RX的数据一样,则引脚复用没有问题 + ## ADC -插针上引出了一路 ADC,使用的是 ADC1。 +插针上引出了一路 ADC,引脚是GPIOB 3,使用的是 ADC1。 首先选择 ADC channel,这里以 ADC1 为例: ```shell @@ -220,7 +270,7 @@ panel=st7701_dxq5d0019b480854 panel=st7701_d300fpc9307a ``` -2.28寸屏: +2.3寸屏: ``` panel=st7701_hd228001c31