===== NK-R36S0A1 =====
==== 主板框架图 ====
{{:pasted:20221214-220552.png}}
==== 接口定义 ====
{{page>:template:R39S2_hw}}
=== 插针pin定义 ===
{{page>:template:R39S2p_hw_pin}}
=== Jump_sel ===
{{page>:template:R39S2_hw_jump}}
==== 硬件特性 ====
{{page>:template:temp_hwspec}}
==== 快速上手 ====
=== 系统烧录 ===
1、下载烧录工具:
请务必先安装驱动,烧录工具链接含有驱动DriverAssitant压缩包,解压后点击DriverInstall.exe安装驱动
{{:arm:rk3399:3399-shaolu.png?600|}}
2、开始烧录:
将数据线一端与主板OTG连接,另一端连接电脑。注意烧录前,需关闭电源,开电源时按住boot_key按键进行烧入。
{{:arm:rk3399:linux:r36s0_1.png?600|}}
打开压缩包中开发工具 » 升级固件 » 点击固件并选择好固件 » 点升级开始烧录
{{:arm:rk3399:linux:r36s0_2.png?600|}}
烧录过程中的状态,会有进度显示
{{:arm:rk3399:linux:r36s0_3.png?600|}}
更换系统平台(例如安卓切换到Linux)时,可能出现无法烧录的情况,此时打开开发工具 » 高级功能 » 点击进入Maskrom切换烧录模式后烧录系统
{{:arm:rk3399:3399-kaishishaolu2.png?600|}}
3、完成烧录:
烧录过程不需要任何操作,烧录成功后右框会显示设备自动重启,烧录完成。
{{:arm:rk3399:linux:r36s0_4.png?600|}}
=== Debug串口调试 ===
1、通过串口进入系统后台,需要利用板子的Debug接口,接口位置和定义如图:
{{:arm:rk3399:linux:r36s0_debug1.png?600|}}
* 接口只需要用到3个引脚,TX、RX、GND
2、需要用到串口小板工具
A部分需要接入TX、RX、GND
B部分连接电脑USB口
{{:arm:rk3399:android:ser-3.png?600|}}
3、硬件部分连接效果图
{{:arm:rk3399:linux:r36s0_debug2.png?600|}}
4、在电脑的设备管理器→端口 中看有没有串口信息
{{:arm:rk3399:android:ser-4.png?600|}}
5、打开Xshell新建一个会话,在连接下选择协议为SERIAL,操作如图:
{{:arm:rk3399:android:ser-5.png?600|}}
6、点击串口,端口号为设备管理器看到的串口号,波特率为:1500000
{{:arm:rk3399:android:ser-6.png?600|}}
7、最后点击连接,串口进入后台
{{:arm:rk3399:linux:r36s0_debug10.png?600|}}
=== Android ADB ===
{{page>:template:temp_adb}}
=== Linux SSH ===
{{page>:template:temp_ssh}}
==== Android 使用指南 ====
=== 接口功能测试 ===
== UART ==
{{page>:template:temp_android_uart}}
== LAN ==
{{page>:template:temp_android_lan}}
== WIFI ==
{{page>:template:temp_android_wifi}}
== 4G/5G ==
{{page>:template:temp_android_4g5g}}
== Can ==
{{page>:template:temp_android_can}}
== GPIO/DIO ==
{{:arm:rk3399:linux:r36s0_gpio0.png?600|}}
== Audio ==
{{page>:template:temp_android_audio}}
== Mic ==
{{page>:template:temp_android_mic}}
== USB ==
{{:arm:rk3399:linux:r36s0_usb.png?600|}}
== SDCARD ==
{{page>:template:temp_android_sdcard}}
== Bluetooth ==
{{page>:template:temp_android_bluetooch}}
== WatchDog ==
{{page>:template:temp_android_watchdog}}
== Key ==
{{page>:template:temp_android_key}}
== LCD ==
{{page>:template:temp_android_lcd}}
== PowerManager ==
{{page>:template:temp_android_pm}}
== RTC ==
{{page>:template:temp_android_rtc}}
=== 系统基本功能设置 ===
{{page>:template:temp_android_system}}
=== 系统性能测试 ===
{{page>:template:temp_android_perf}}
==== Android API 使用说明 ====
{{page>:template:temp_android_api}}
==== Linux 使用指南 ====
=== 接口功能测试 ===
== GPIO ==
1. IO 控制节点都在/sys/class/gpio/
{{:arm:rk3399:linux:r36s0_gpio0.png?600|}}
2. IO 对应表如下:
^ 功能 ^ 主板丝印 ^
^ 输入\输出 | GPIO1 |
| ::: | GPIO2 |
| ::: | GPIO3 |
| ::: | GPIO4 |
3. IO控制方法:
*输出低电平:
echo 0 >/sys/class/gpio/gpio56/value
*输出高电平:
echo 1 >/sys/class/gpio/gpio56/value
*查看输入电平:
cat /sys/class/gpio/gpio56/value
== UART ==
1. 串口定义参考:
* [[:nk-rk3399-v0c#接口定义|主板接口定义]]
2. 串口设备节点系统对应表:
^ 主板丝印 ^ 设备节点 ^
| 232_RX5\TX5 | /dev/ttyS7 |
| UART0_TTL | /dev/ttyS0 |
| 232_RX3\TX3 | /dev/ttyS5 |
| 232_RX4\TX4 | /dev/ttyS9 |
| RS485_A1\B1 | /dev/ttyS3 |
| RS485_A2\B2 | /dev/ttyS4 |
3. CuTecom 测试串口,以232_RX5\TX5回环测试为例
* 参考步骤1~2短接232_RX5\TX5的 TX & RX (2~3 pin);
* 双击桌面CuteCom图标,打开APP,Device选择测试端口对应的设备节点(见步骤2);
* 点击Settings,设置串口参数,如下图所示:
{{:arm:rk3399:linux:cutecom_1.png?600|}}
* 设置好以后点击Open 打开串口,在input 文本输入框中输入字符,按回车发送数据:
{{:arm:rk3399:linux:cutecom_2.png?600|}}
4. 命令行方式测试串口,同样以UART_RX5\TX5_232回环测试为例
打开终端输入如下指令接收数据:
com_recv /dev/ttyS7 115200
打开另一个终端发送数据:
com_send /dev/ttyS7 115200
测试结果如下:
{{:arm:rk3399:linux:r36s0_send.png?600|}}
== LAN ==
{{page>:template:temp_linux_lan}}
== WIFI ==
{{page>:template:temp_linux_wifi}}
== 4G/5G ==
{{page>:template:temp_linux_4g5g}}
== Can ==
{{page>:template:temp_linux_can}}
== GPIO/DIO ==
1. IO 控制节点都在/sys/class/gpio/
{{:arm:rk3399:linux:r36s0_gpio0.png?600|}}
2. IO 对应表如下:
^ 功能 ^ 主板丝印 ^
^ 输入\输出 | GPIO1 |
| ::: | GPIO2 |
| ::: | GPIO3 |
| ::: | GPIO4 |
3. IO控制方法:
*输出低电平:
echo 0 >/sys/class/gpio/gpio56/value
*输出高电平:
echo 1 >/sys/class/gpio/gpio56/value
*查看输入电平:
cat /sys/class/gpio/gpio56/value
{{page>:template:temp_linux_gpio}}
== Audio ==
{{page>:template:temp_linux_audio}}
== Mic ==
{{page>:template:temp_linux_mic}}
== USB ==
{{page>:template:temp_linux_usb}}
== SDCARD ==
{{page>:template:temp_linux_sdcard}}
== Bluetooth ==
{{page>:template:temp_linux_bluetooch}}
== WatchDog ==
{{page>:template:temp_linux_watchdog}}
== Key ==
{{page>:template:temp_linux_key}}
== LCD/Backlight ==
{{page>:template:temp_linux_lcd}}
== PowerManager ==
{{page>:template:temp_linux_pm}}
== RTC/Timezone ==
{{page>:template:temp_linux_rtc}}
== CPU ==
{{page>:template:temp_linux_cpu}}
== Memory ==
{{page>:template:temp_linux_mem}}
== EMMC ==
{{page>:template:temp_linux_emmc}}
==== Linux 应用编程 ====
=== GPIO 应用编程 ===
C参考代码如下:
#include
#include
#include
#include
#include
#include
#include
static char gpio_path[100];
static int gpio_config(const char *attr, const char *val)
{
char file_path[100];
int len;
int fd;
sprintf(file_path, "%s/%s", gpio_path, attr);
if (0 > (fd = open(file_path, O_WRONLY))) {
perror("open error");
return fd;
}
len = strlen(val);
if (len != write(fd, val, len)) {
perror("write error");
close(fd);
return -1;
}
close(fd); //关闭文件
return 0;
}
int main(int argc, char *argv[])
{
char file_path[100];
char val;
int fd;
/* 校验传参 */
if (2 != argc) {
fprintf(stderr, "usage: %s \n", argv[0]);
exit(-1);
}
/* 判断指定编号的 GPIO 是否导出 */
sprintf(gpio_path, "/sys/class/gpio/gpio%s", argv[1]);
if (access(gpio_path, F_OK)) {//如果目录不存在 则需要导出
int len;
if (0 > (fd = open("/sys/class/gpio/export", O_WRONLY))) {
perror("open error");
exit(-1);
}
len = strlen(argv[1]);
if (len != write(fd, argv[1], len)) {//导出 gpio
perror("write error");
close(fd);
exit(-1);
}
close(fd); //关闭文件
}
/* 配置为输入模式 */
if (gpio_config("direction", "in"))
exit(-1);
/* 极性设置 */
if (gpio_config("active_low", "0"))
exit(-1);
/* 配置为非中断方式 */
if (gpio_config("edge", "none"))
exit(-1);
/* 读取 GPIO 电平状态 */
sprintf(file_path, "%s/%s", gpio_path, "value");
if (0 > (fd = open(file_path, O_RDONLY))) {
perror("open error");
exit(-1);
}
if (0 > read(fd, &val, 1)) {
perror("read error");
close(fd);
exit(-1);
}
printf("value: %c\n", val);
/* 退出程序 */
close(fd);
exit(0);
}
交叉编译源码:
aarch64-linux-gnu-gcc -o gpio gpio.c
将编译好的gpio程序使用scp拷贝到 r36s0 主板上,执行测试:
使用方法:
0:./gpio 3
1:./gpio 1
{{:arm:rk3399:linux:r39s2_gpio.c.png?600|}}
=== UART 应用编程 ===
系统下操作 UART 的测试串口,以 232_RX5\TX5 测试为例:
232_RX5\TX5 设备节点为:
/dev/ttyS7
C参考UART高低电平输入代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include
int set_opt(int,int,int,char,int);
void main(){
int fd,nByte;
char *uart3 = "/dev/ttyS2";
char bufferR[2];
char bufferW[2];
memset(bufferR, '\0', 2);
memset(bufferW, '\0', 2);
if((fd=open(uart3,O_RDWR,0777))<0)
{
printf("failed\n");
}
else{
printf("success\n");
set_opt(fd, 115200, 8, 'N', 1);
}
while(1){
nByte = 0;
memset(bufferR, '\0', 2);
memset(bufferW, '\0', 2);
// printf("hello\n");
if((nByte = read(fd, bufferR, 1)) == 1){ //MCU串口发送接收都是单字节(单字符)函数
printf("receive:%c\n",bufferR[0]);
bufferW[0] = 'A';
write(fd,bufferW,1); //串口发送单字节(单字符) buffer[0] = data
memset(bufferR, '\0', 2);
memset(bufferW, '\0', 2);
nByte = 0;
}
}
close(fd);
}
//串口通用初始化函数
int set_opt(int fd,int nSpeed, int nBits, char nEvent, int nStop)
{
struct termios newtio,oldtio;//定义结构体newtio和oldtio
//将原串口的数据取到oldtio
if ( tcgetattr( fd,&oldtio) != 0) {
perror("SetupSerial 1");
return -1;
}
//将newio清零和设置c_cflag
bzero( &newtio, sizeof( newtio ) );
newtio.c_cflag |= CLOCAL | CREAD;//使能接收和忽略控制线
newtio.c_cflag &= ~CSIZE;
//设置数据位
switch( nBits )
{
case 7:
newtio.c_cflag |= CS7;
break;
case 8:
newtio.c_cflag |= CS8;
break;
}
//设置校验位
switch( nEvent )
{
//偶校验
case 'O':
newtio.c_cflag |= PARENB;//使能奇偶校验
newtio.c_cflag |= PARODD;//偶校验
newtio.c_iflag |= (INPCK | ISTRIP);//输入校验并忽略第八位
break;
case 'E':
newtio.c_iflag |= (INPCK | ISTRIP);
newtio.c_cflag |= PARENB;
newtio.c_cflag &= ~PARODD;//取消偶校验(置零偶校验位),开启奇校验
break;
case 'N':
newtio.c_cflag &= ~PARENB;//不进行奇偶校验
break;
}
//设置波特率
switch( nSpeed )
{
case 2400:
cfsetispeed(&newtio, B2400);
cfsetospeed(&newtio, B2400);
break;
case 4800:
cfsetispeed(&newtio, B4800);
cfsetospeed(&newtio, B4800);
break;
case 9600:
cfsetispeed(&newtio, B9600);
cfsetospeed(&newtio, B9600);
break;
case 115200:
cfsetispeed(&newtio, B115200);
cfsetospeed(&newtio, B115200);
break;
case 460800:
cfsetispeed(&newtio, B460800);
cfsetospeed(&newtio, B460800);
break;
default:
cfsetispeed(&newtio, B9600);
cfsetospeed(&newtio, B9600);
break;
}
//设置停止位
if( nStop == 1 )
newtio.c_cflag &= ~CSTOPB;//一位停止位
else if ( nStop == 2 )
newtio.c_cflag |= CSTOPB;//两位停止位
newtio.c_cc[VTIME] = 0;//不设置读取超时
newtio.c_cc[VMIN] = 0;//读取最小字符数为0
tcflush(fd,TCIFLUSH);//清空缓冲区
//使配置生效
if((tcsetattr(fd,TCSANOW,&newtio))!=0)
{
perror("com set error");
return -1;
}
// printf("set done!\n\r");
return 0;
}
交叉编译源码:
aarch64-linux-gnu-gcc -o uart uart.c
将编译好的程序使用 scp 拷贝到 r36s0 主板上,执行测试:
{{:arm:rk3399:linux:r39s2_uart.c.png?600|}}
=== KEY 应用编程 ===
参考系统下操作Key的方法,获取到key的设备节点为
/dev/input/event2
C参考代码如下:
#include
#include
#include
#include
#include
#include
#define INPUT_DEVICE "/dev/input/event2"
int main(int argc, char **argv){
int fd;
struct input_event event;
ssize_t bytesRead;
int ret;
fd_set readfds;
if ( 0 > (fd = open(INPUT_DEVICE,O_RDONLY)))
{
perror("open error");
return fd;
}
while(1){
FD_ZERO(&readfds);
FD_SET(fd,&readfds);
ret = select(fd + 1, &readfds, NULL, NULL, NULL);
if (ret == -1){
fprintf(stderr,"select call on%s : an error ocurred",argv[1]);
break;
}
if(FD_ISSET(fd,&readfds)){
bytesRead = read(fd, &event,sizeof(struct input_event));
if(bytesRead == -1 )
fprintf(stderr,"bytesRead :%ld : an error ocurred",bytesRead);
}
if(event.type == EV_KEY && (event.value == 0 || event.value == 1))
{
printf("key %s\n",(event.value) ? "pressed" : "released");
}
}
close(fd);
return EXIT_SUCCESS;
}
交叉编译源码:
aarch64-linux-gnu-gcc -o key key.c
将编译好的程序使用 scp 拷贝到 r36e0 主板上,执行测试,按动 key 打印如下:
{{:arm:rk3399:linux:key编程.png?600|}}
*按下按键时显示:key pressed
*松开按键时显示:key released
==== Linux 应用支持 ====
=== QT交叉编译环境 ===
{{page>:template:temp_Linux_qt}}
=== QT Creator ===
{{page>:template:temp_Linux_qt_creator}}
=== 高清硬解码 ===
{{page>:template:temp_Linux_dec}}
=== Docker ===
{{page>:template:temp_Linux_docker}}
===OpenCL===
* 系统已经支持OpenCL,输入命令clinfo即可查看支持详情:
{{:arm:rk3399:linux:opencl.png?600|}}
==== Linux OTA 在线升级 ====
{{page>:template:temp_Linux_upgrade}}
终端输入 ota 进行固件在线升级
{{:arm:rk3399:linux:r39x2_ota.c.png?600|}}