本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
==== Linux Usage guide ==== === Interface function test === == GPIO == 1.IO The control nodes are all present:/sys/class/io_control {{:arm:rk3399:linux:io.png?600|}} 2.IO corresponds to the following table: ^ function ^ Screen printing of motherboard ^ Node name ^ ^ input | IO1 | gpio_ip0 | | ::: | IO2 | gpio_ip1 | | ::: | IO3 | gpio_ip2 | | ::: | IO4 | gpio_ip3 | | ::: | IO5 | gpio_ip4 | | ::: | IO6 | gpio_ip5 | ^ output | IO7 | gpio_op0 | | ::: | IO8 | gpio_op1 | | ::: | IO9 | gpio_op2 | | ::: | IO10 | gpio_op3 | | ::: | IO11 | gpio_op4 | | ::: | IO12 | gpio_op5 | 3.IO control method: *Output low level: echo 0 >/sys/class/io_control/gpio_op0 *Output high level: echo 1 >/sys/class/io_control/gpio_op0 *View input level: cat /sys/class/io_control/gpio_ip0 == UART == 1. Serial port definition reference: * [[:nk-rk3399-v0c#接口定义|主板接口定义]] 2. Serial port device node system mapping table: ^ Screen printing of motherboard ^ Device node ^ | COM1 | /dev/ttyXRUSB0 | | COM2 | /dev/ttyXRUSB1 | | COM3 | /dev/ttyXRUSB2 | | COM4 | /dev/ttyXRUSB3 | 3. CuTecom tests the serial port. The COM2 loopback test is used as an example * Refer to Steps 1 to 2 to short the TX & RX (2 to 3 pin) of COM2. * Double-click the CuteCom icon on the desktop, open APP, Device select the device node corresponding to the test port (see Step 2). * Click Settings to set the serial port parameters, as shown in the picture below: {{:arm:rk3399:linux:cutecom_1.png?600|}} * Click Open to open the serial port, input characters in the input text box, and press Enter to send data: {{:arm:rk3399:linux:cutecom_2.png?600|}} 4. Test the serial port on the CLI. The COM2 loopback test is used as an example Open the terminal and enter the following command to receive data: com_recv /dev/ttyXRUSB1 115200 Open another terminal to send data: com_send /dev/ttyXRUSB1 115200 The test results are as follows: {{:arm:rk3399:com_cmd.png?600|}} {{page>:template:temp_linux_uart}} == LAN == 1. Check the IP address of the network adapter. The system dynamically obtains an IP address by default #ifconfig -a {{:arm:rk3399:linux:ifconfig.png?600|}} 2. Set a static IP address for a network adapter * Method 1 -- Use graphical tool Settings Double-click the desktop icon:Advanced Network Configuration {{:arm:rk3399:linux:network_ip1.png?600|}} {{:arm:rk3399:linux:network_ip2.png?600|}} * 方法2 -- 修改配置文件的方式: vim /etc/network/interfaces {{:arm:rk3399:linux:interfaces.png?600|}} * 修改完成后输入重启生效。 == WIFI == 1. 点击右下角网络图标,浏览可用WIFI路由: {{:arm:rk3399:linux:wifi1.png?600|}} * 输入WIFI密码,点击connect {{:arm:rk3399:linux:wifi2.png?600|}} 2. 方法2 -- 命令行连接wifi nmcli d wifi connect "SSID" password "PASSWROD" == 4G/5G == 1. 系统已带自动拨号,打开终端,输入命令4g 即可自动拨号: root@rk3399:~# 4g 2. 拨号完成后,查看IP地址: {{:arm:rk3399:linux:4g.png?600|}} 3. 打开浏览器,浏览任意网站。 {{:arm:rk3399:linux:baidu.png?600|}} 4. 5G测试方法与4G类似,输入命令5g即可自动拨号: root@rk3399:~# 5g == Can == {{page>:template:temp_linux_can}} == GPIO/DIO == 1.IO The control nodes are all present:/sys/class/io_control {{:arm:rk3399:linux:io.png?600|}} 2.IO corresponds to the following table: ^ function ^ Screen printing of motherboard ^ Node name ^ ^ input | IO1 | gpio_ip0 | | ::: | IO2 | gpio_ip1 | | ::: | IO3 | gpio_ip2 | | ::: | IO4 | gpio_ip3 | | ::: | IO5 | gpio_ip4 | | ::: | IO6 | gpio_ip5 | ^ output | IO7 | gpio_op0 | | ::: | IO8 | gpio_op1 | | ::: | IO9 | gpio_op2 | | ::: | IO10 | gpio_op3 | | ::: | IO11 | gpio_op4 | | ::: | IO12 | gpio_op5 | 3.IO control method: *Output low level: echo 0 >/sys/class/io_control/gpio_op0 *Output high level: echo 1 >/sys/class/io_control/gpio_op0 *View input level: cat /sys/class/io_control/gpio_ip0 == Audio == * 将喇叭连接板子上的 SPK 端口 1. 方法① -- 使用系统自带SMPayer播放器,以及音频测试文件,可以做简单音频功能测试 {{:arm:rk3399:linux:smplayer.png?600|}} 2. 方法② -- 使用命令方式播放: aplay /nodka_test/LR_audio.wav -D hw:0,0 == Mic == * 录音测试 arecord -d 5 -f cd -r 44100 -c 2 -t wav test.wav aplay test.wav == USB == 1. U盘自动挂载/media/disk root@rk3399:~# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/root 15G 3.6G 10G 27% / devtmpfs 980M 0 980M 0% /dev tmpfs 981M 0 981M 0% /dev/shm tmpfs 981M 8.8M 972M 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 981M 0 981M 0% /sys/fs/cgroup tmpfs 197M 16K 197M 1% /run/user/0 /dev/sda1 57G 2.7G 54G 5% /media/disk == SDCARD == * SDcard 自动挂载: root@rk3399:~# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/root 15G 3.6G 10G 27% / devtmpfs 980M 0 980M 0% /dev tmpfs 981M 0 981M 0% /dev/shm tmpfs 981M 8.8M 972M 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 981M 0 981M 0% /sys/fs/cgroup tmpfs 197M 16K 197M 1% /run/user/0 /dev/mmcblk0p8 30G 3.8G 25G 14% /media/3699f79c-f05d-4948-89c9-04dc4b132a1f 解除挂载: umount /dev/mmcblk0p8 挂载: mount /dev/mmcblk0p8 /sdcard == Bluetooth == 1. 打开蓝牙管理器,搜索附近蓝牙设备: {{:arm:rk3399:linux:bt1.png?600|}} 2. 选中蓝牙设备,配对然后选择信任: {{:arm:rk3399:linux:bt2.png?600|}} 3. 设置蓝牙连接类型: {{:arm:rk3399:linux:bt3.png?600|}} == WatchDog == {{page>:template:temp_linux_watchdog}} == Key == 1. 输入命令evtest 查看系统下所有按键、输入设备: root@rk3399:~# evtest No device specified, trying to scan all of /dev/input/event* Available devices: /dev/input/event0: ff420030.pwm /dev/input/event1: USB Optical Wheel Mouse /dev/input/event2: SIGMACH1P USB Keyboard /dev/input/event3: rk29-keypad /dev/input/event4: SIGMACH1P USB Keyboard Select the device event number [0-4]: 2. 按照上面提示选择测试按键,如RK3399 boot按键为 /dev/input/event3: rk29-keypad 则event number 为3:按下按键会打印value 1,松开按键则会打印value 0,如下图: {{:template:key.png?600|}} 3. 自定义按键功能,配置文件为 /etc/triggerhappy/triggers.d/example.conf 如下为定义按键为reboot功能,亦为系统默认配置,用户可以根据需要自定义。 KEY_VOLUMEUP 1 reboot == LCD/Backlight == 1. 系统支持使用APP切换不同的LCD屏,输入dis命令打开APP如下图: * 选择对应的eDP/LVDS 屏分辨率,然后点击保存,系统自动重启后即可切换到指定的LCD: {{:arm:rk3399:linux:dis.png?600|}} 2. 背光亮度调节: * 方法①:点击右下角系统托盘如下图标,打开背光调节APP {{:template:backlight.png?600|}} * 方法②:控制驱动应用层接口: echo 100 > /sys/class/backlight/backlight1/brightness (注:写入数值越大亮度越大,max_brightness 为250) == PowerManager == 1. 电源管理设置: {{:template:suspend.png?600|}} {{:template:pm.png?600|}} 休眠后按POWER键唤醒 2. 电源管理功能非所有产品支持,需定制系统请联系业务窗口人员。 == RTC/Timezone == 1.查看当前系统时间: [root@rk3399:~]# date Wed Jun 8 15:54:09 CST 2022 2. 设置同步硬件时钟: [root@rk3399:/]# date -s "2022-06-08 17:01:01" Wed Jun 8 17:01:01 CST 2022 [root@rk3399:/]# hwclock -w [root@rk3399:/]# hwclock -r Wed Jun 8 17:01:09 2022 0.000000 seconds 3. 关机断电5秒以上,再开机查看系统时间是否保存: [root@rk3399:/]# date Wed Jun 8 17:02:30 CST 2022 注:系统默认为网络时间同步,以上RTC测试需要在断外网情况下测试。 4. 时区设置 * 方法① -- 修改link文件,如改为中国、上海: ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime reboot 设置其他时区只需将上面命令中的Asia/Shanghai改为对应的时区城市即可。 * 方法② -- 在图形界面依次打开首选项->时间和日期,选择时区如下图: {{:arm:rk3399:linux:timezone.png?600|}} 选择完成后关闭窗口,使用date命令查看时区变化: {{:arm:rk3399:linux:timezone1.png?600|}} == CPU == 查看CPU信息: cat /proc/cpuinfo == Memory == 查看内存容量大小: free -h == EMMC == 查看EMMC可用容量大小 df -h ==== Linux Programming guide ==== === GPIO Application programming === C The reference code is as follows: <code C> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <string.h> static char gpio_path[100]; //Set the GPIO direction and high and low level static int gpio_config(const char *file, const char *value) { char config_path[100]; int len; int fd; sprintf(config_path, "%s/%s", gpio_path, file); if (0 > (fd = open(config_path, O_WRONLY))) { perror("open error"); return fd; } len = strlen(value); if (len != write(fd, value, len)) { perror("write error"); close(fd); return -1; } close(fd); return 0; } //Get the direction and level of GPIO static int gpio_get(const char *file) { char get_path[100]; char buf[10]={"\0"}; int len; int fd; sprintf(get_path, "%s/%s", gpio_path, file); if (0 > (fd = open(get_path, O_RDWR))) { perror("open error"); return fd; } if ( 0 > read(fd,buf,10)) { perror("read error"); return fd; } printf(" %s : %s",file,buf); close(fd); return 0; } int main(int argc, char *argv[]) { if (4 != argc) { if (3 != argc) { fprintf(stderr, "set gpio out : %s <gpio> <out> <value>\n", argv[0]); fprintf(stderr, "set gpio in : %s <gpio> <in>\n", argv[0]); exit(-1); } } sprintf(gpio_path, "/sys/class/gpio/gpio%s", argv[1]); if (access(gpio_path, F_OK)) { printf("%s inexistence,export %s... \n",gpio_path,argv[1]); int fd; 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)) { perror("write error"); close(fd); exit(-1); } close(fd); } if (gpio_config("direction", argv[2])) exit(-1); if ( 0 == strcmp("out",argv[2] ) && argc == 4 ) { if(gpio_config("value", argv[3])) exit(-1); } printf("gpio_op%s:\n",argv[1]); if (gpio_get("direction")) exit(-1); if (gpio_get("value")) exit(-1); exit(0); } </code> Cross-compiled source code: aarch64-linux-gnu-gcc -o a.out gpio.c Copy the compiled gpio program to rk3399 motherboard using scp and perform the test:How to use: 0:./gpio 0 out 0 1:./gpio 0 out 1 {{:arm:rk3399:linux:r39s2_gpio20.png?600|}} === UART Application programming === Operating the test serial port of the UART in the system, using the COM2 test as an example: COM2 The device node is: /dev/ttyXRUSB1 C Reference UART high and low level input codes are as follows: <code C> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <termios.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #define UART_DEVICE "/dev/ttyXRUSB1" //UART Device file name int main(int argc, char *argv[]) { int fd, res; struct termios oldtio, newtio; char ch; char buf[256] = {0}; //-----------Open the uart device file------------------ fd = open(UART_DEVICE, O_RDWR|O_NOCTTY);//No setting O_NONBLOCK。So here read and write are blocking operations if (fd < 0) { perror(UART_DEVICE); exit(1); } else printf("Open %s successfully\n", UART_DEVICE); //-----------Set operating parameters----------------------- tcgetattr(fd, &oldtio);//Gets the current operation mode parameters memset(&newtio, 0, sizeof(newtio)); //Baud rate =115200 Data bits =8 Enable data receiving newtio.c_cflag = B115200|CS8|CLOCAL|CREAD; newtio.c_iflag = IGNPAR; tcflush(fd, TCIFLUSH);//Clear the input and output buffers tcsetattr(fd, TCSANOW, &newtio);//Set a new operation parameter //------------Send data to urat------------------- res=write(fd, "Begin Uart tx", 16); while(1) { // Get the data from the console terminal and send it through the uart until it is received! Character while((ch=getchar()) != '!') { buf[0]=ch; res=write(fd, buf, 1); } buf[0]=ch; buf[1]=' '; res = write(fd, buf, 2); break; } //-------------Receive data from the uart------------------- while(1) { res = read(fd, buf, 255);//Here the program will hang until data is received from the uart (blocking operation) if (res == 0) continue; buf[res] = ' '; printf("res = %d, buf = %s\n", res, buf);//Print out the characters received by the uart if (buf[0] == '!')//uart received! Exit the while after the character break; } //------------Close the uart device file and restore the original parameters-------- close(fd); printf("Close %s\n", UART_DEVICE); tcsetattr(fd, TCSANOW, &oldtio); //Restore the original Settings return 0; } } </code> Cross-compile source code: aarch64-linux-gnu-gcc -o uart uart.c Copy the compiled program to 3399 motherboard using scp, and perform the test: {{:arm:rk3399:linux:uart编程-1.png?600|}} === KEY application programming === For details, see the method of operating a key in the system <code> /dev/input/event2 </code> C The reference code is as follows: <code C> #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <linux/input.h> #include <sys/select.h> #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; } </code> Cross-compile source code: <code> aarch64-linux-gnu-gcc -o key key.c </code> Copy the compiled program to the r39s2 motherboard using scp, perform the test, press the key to print as follows: {{:arm:rk3399:linux:key编程.png?600|}} *Display when the key is pressed:key pressed *Display when the key is released:key released ==== Linux Application support ==== === QT Cross-compilation environment === {{page>:template:temp_Linux_qt}} === QT Creator === {{page>:template:temp_Linux_qt_creator}} === Hd hard decoding === {{page>:template:temp_Linux_dec}} === Docker === {{page>:template:temp_Linux_docker}} ===OpenCL=== * OpenCL is already supported by the system. Enter clinfo to view the support details: {{:arm:rk3399:linux:opencl.png?600|}} ==== Linux OTA Online upgrade ==== {{page>:template:temp_Linux_upgrade}} Terminal input ota for firmware online upgrade {{:arm:rk3399:linux:linux_ota.png?600|}}
您的足迹:
登录
文章
讨论
阅读
显示源文件
修订记录
搜索
导航
首页
Main_En
帮助
联系我们
打印/导出
可打印版本
工具
最近更改
媒体管理器
网站地图
永久链接
引用此文