Skip to content

Commit

Permalink
Merge pull request #660 from Z2Z-GuGu/main
Browse files Browse the repository at this point in the history
Update Doc
  • Loading branch information
Zepan authored Apr 18, 2024
2 parents a36ef31 + e8fa0e5 commit 06316c8
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 76 deletions.
22 changes: 21 additions & 1 deletion docs/hardware/zh/lichee/RV_Nano/2_unbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ LicheeRV Nano根据网络分为四个版本:

注:70415及以上版本可使用0402*4的排阻短接

![](./../assets/RV_Nano/unbox/BLE_RES_2.jpg)

+ WiFi网口版(WE)板载WiFi6/BT5.2模块,同时提供一个网口小板,通过铜柱与排线连接到开发板上

同时我们提供以下六种配件:
Expand Down Expand Up @@ -149,4 +151,22 @@ LicheeRV Nano的大核支持作为RISC-V(C906)或ARM(A53)启动,在开

![](./../assets/RV_Nano/unbox/A53-2.jpg)

需注意,目前A53模式下的SDK视频编解码存在问题,测试镜像点击[这里](https://github.com/sipeed/LicheeRV-Nano-Build/releases/tag/20240326)下载
需注意,目前A53模式下的SDK视频编解码存在问题,测试镜像点击[这里](https://github.com/sipeed/LicheeRV-Nano-Build/releases/tag/20240326)下载

## 屏幕背光

LicheeRV Nano适配不同尺寸的屏幕,其中3寸、2.3寸为单串LED;5寸为双串LED;7寸、10.1寸为四串LED。

![](./../assets/RV_Nano/unbox/BL_RES_1.png)

如上图背光电阻默认使用两个10R 0201并联,适配5寸屏幕;
接入2.8/3寸屏幕会明显发烫,内测版70405需拆掉BL电阻(下图位置),70415及后续版本可通过PWM自动适配小尺寸屏幕;
接入7/10.1寸屏幕时屏幕略暗,若需达到100%亮度,要将该电阻修改为3.3R

![](./../assets/RV_Nano/unbox/BL_RES.png)

## 电池应用

LicheeRV Nano 上不包含锂电池充电电路,如果用户需要嵌入电池,同时希望使用 RV Nano 自带的 USB TypeC 充电,则需要断开VBUS与VSYS的电阻(下图位置),VBUS接口作为PMU的外部电源输入,VSYS接口连接PMU的VSYS。如有疑问,请联系我们获得支持。

![](./../assets/RV_Nano/unbox/5V_RES.png)
224 changes: 149 additions & 75 deletions docs/hardware/zh/lichee/RV_Nano/5_peripheral.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,20 @@ update:
- date: 2024-1-26
version: v0.1
author: 0x754C
- date: 2024-4-15
version: v0.2
author: BuGu
---

## 引脚分布
![](./../assets/RV_Nano/intro/RV_Nano_3.jpg)
## 连接开发板

### UART0

将UART串口连接到板子的:

A17 A16 GND
将UART串口连接到板子的 `GND ``A16(TX) ``A17(RX) `

然后使用终端软件连接串口,波特率115200

### 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
mmio_write_32(0x03001068, 0x4); // GPIOA 18 UART1 CTS
mmio_write_32(0x03001064, 0x4); // GPIOA 19 UART1 RTS
```

如果想要同时使用UART1和UART2的功能,则需要写入寄存器来设置引脚的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
```

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(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 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系统中的串口使用:

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接口上的SBU1/2上也引出了UART0,可使用USB TypeC转接板引出RX0、TX0

### usb rndis 网口

Expand Down Expand Up @@ -157,6 +90,18 @@ ssh [email protected]

连接板子

## SOC相关

查看SOC温度:
```shell
cat /sys/class/thermal/thermal_zone0/temp
```

查看SOC时钟:
```shell
cat /sys/kernel/debug/clk/clk_summary
```

## Audio

licheerv nano 支持录音和播放,使用标准 ALSA 工具可以进行录音、播放等操作。
Expand All @@ -181,6 +126,109 @@ arecord -Dhw:0,0 -d 3 -r 48000 -f S16_LE -t wav test.wav & > /dev/null &
./aplay -D hw:1,0 -f S16_LE test.wav
```

## GPIO

### LicheeRV Nano引脚图&Linux GPIO编号:

![GPIO](../assets/RV_Nano/peripheral/gpio.png)

系统内GPIO查看:

```shell
cat /sys/kernel/debug/clk/clk_summary
```

### GPIO操作

首先用 'devmem 0x0300xxxx 32 0xxx' 修改引脚的PINMUX到GPIO

寄存器查找方式(以A22为例):在[此处](https://github.com/sophgo/sophgo-doc/releases/download/sg2000-trm-v1.0-beta/sg2000_trm_cn.pdf)下载SG2002寄存器手册,手册中查找XGPIOA[22],在表格中对应到GPIO,shell命令: 'devmem 0x03001050 32 0x03'

```shell
# xxx 为上图中Linux GPIO NUM,如A22:num=502
num=xxx
echo ${num} > /sys/class/gpio/export
# GPIO 写
echo out > /sys/class/gpio/gpio${num}/direction
echo 1 > /sys/class/gpio/gpio${num}/value
echo 0 > /sys/class/gpio/gpio${num}/value
# GPIO 读
echo in > /sys/class/gpio/gpio${num}/direction
cat /sys/class/gpio/gpio${num}/value
```

## UART

### UART1/2
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
```c
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工具来写入寄存器
shell:
```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

UART3 的引脚被默认复用为SDIO:

https://github.com/sipeed/LicheeRV-Nano-Build/blob/61ecf59b8b3653e430c8905c7a1ae80201d60f84/build/boards/sg200x/sg2002_licheervnano_sd/u-boot/cvi_board_init.c#L83

```c
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:
```shell
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系统中的串口使用:

C:

```
/* TODO */
```


shell:

```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格式显示收到的数据
```

## I2C

插针上引出了 I2C1 和 I2C3,将设备连接到其上即可。
Expand All @@ -197,6 +245,20 @@ devmem 0x030010E4 32 0x2 # GPIOP 23 I2C3 SDA

然后可以使用 i2c-tools 进行 i2c 外设的操作,镜像中已经预装。

带WiFi模块的板卡(W、WE版)I2C1和I2C3硬件上连接到WiFi模块的SDIO,存在I2C无法读写的可能,PINMUX到I2C时WiFi模块暂时不可用,可使用以下命令恢复WiFi连接:
```shell
# PINMUX到SDIO
devmem 0x030010D0 32 0x0
devmem 0x030010DC 32 0x0
devmem 0x030010D0 32 0x0
devmem 0x030010DC 32 0x0
# 重启WiFi服务
/etc/init.d/S30wifi stop
/etc/init.d/S30wifi start
```

摄像头和触摸屏接口共用I2C4,可使用 'i2cdetect -ry 4' 扫描设备。需注意I2C4处于1.8V电源域,连接其他设备时请注意电平匹配。

## SPI

SPI2默认被复用作SDIO:
Expand Down Expand Up @@ -234,7 +296,11 @@ spidev_test -D /dev/spidevN.N -p 1234 -v

## ADC

插针上引出了一路 ADC,引脚是GPIOB 3,使用的是 ADC1。
LicheeRV Nano插针上引出了一路12位ADC,在板内已做分压处理,如图:

![ADC](../assets/RV_Nano/peripheral/adc.png)

经测试,ADC输入电压在0-4.6V时,对应ADC值为0000-4095

首先选择 ADC channel,这里以 ADC1 为例:
```shell
Expand All @@ -252,14 +318,22 @@ cat /sys/class/cvi-saradc/cvi-saradc0/device/cv_saradc

创建或编辑sd卡第一个分区中的uEnv.txt文件,添加或修改panel字段:

注:镜像将第一个分区已经挂载到/boot目录下,可在终端中直接操作:
```shell
cd /boot
touch uEnv.txt
vi uEnv.txt
# 使用 'i' 进入编辑
# 使用 'Esc',':wq'保存并退出
```

7寸屏:

```
panel=zct2133v1
```

5寸屏:

```
panel=st7701_dxq5d0019b480854
```
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 06316c8

Please sign in to comment.