stty -F /dev/ttyS3 115200 -echo
cat /dev/ttyS3 &
echo ?serialdata > /dev/ttyS3
20250319在榮品的PRO-RK3566開發板的buildroot系統下使用集成的QT應用調試串口UART3
2025/3/19 14:17
緣起:在榮品的PRO-RK3566開發板的buildroot系統下,在命令行中使用echo可以發送數據。
但是cat不能接收數據。榮品建議直接使用SDK中集成的QT應用來測試了。
串口線需要使用1.25/1.27mm間距的4PIN排線。
1、現在 在PRO-RK3566開發板上的UART3。可以以 115200bps N 8 1 對外發送,請問 接受怎么配置?
2、打開 UART3時 內核的警告信息?怎么關閉?如何處理?
root@rk3566-buildroot:/dev# stty -F /dev/ttyS3 115200 -echo
[ ? 36.455271] of_dma_request_slave_channel: dma-names property of node '/serial@fe670000' missing or empty
root@rk3566-buildroot:/dev# [ ? 36.455328] dw-apb-uart fe670000.serial: failed to request DMA, use interrupt mode
1 桌面也有測試的qt 應用 可以去看接收 ?
2 打印是沒有開啟dma 模式,對收發沒有影響,需要可以去 內核目錄下搜索 注釋打印
參考資料:
https://doc.rpdzkj.cn/#/zh_cn/%E7%91%9E%E8%8A%AF%E5%BE%AE%E7%B3%BB%E5%88%97/rk3566-rk3568/8.%E6%8E%A5%E5%8F%A3%E4%BD%BF%E7%94%A8?id=%e4%b8%b2%e5%8f%a3%e6%b5%8b%e8%af%95
串口測試
Debian 或者 Ubuntu 可用minicom測試
安裝:
sudo apt-get install minicom
復制Error已復制
安裝完成后,啟動 minicom
例如:
以115200的波率、無校驗位、1位停止位的方式連接到/dev/ttyS5串口。
sudo minicom -b 115200 -o -D /dev/ttyS5
復制Error已復制
退出后短接TX,RX,輸入英文或數字字符,就能在界面中顯示出來
image-49
buildroot
使用自帶命令cat和echo模擬串口收發。
短接串口的tx和rx。
配置串口:
設置波特率為 115200,-F指定具體的串口,其它參數不指定使用默認值。
stty -F /dev/ttyS0 115200 -echo
復制Error已復制
開始測試:
后臺cat在串口有數據時打印接收到的數據:
cat /dev/ttyS0 &
復制Error已復制
使用echo將數據重定向到串口/dev/ttyS0:
echo ?serialdata > /dev/ttyS0
復制Error已復制
如果串口正常,則會在終端打印echo傳輸的信息。
參考資料:
百度:RK3588 串口測試
https://blog.csdn.net/MATLABCSD/article/details/136390240?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522f1e73abada1bd9b99186c23ec00cd9ac%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=f1e73abada1bd9b99186c23ec00cd9ac&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-1-136390240-null-null.142^v102^pc_search_result_base6&utm_term=rk3588%20%E6%B5%8B%E8%AF%95%E4%B8%B2%E5%8F%A3%E5%8A%9F%E8%83%BD%E6%98%AF%E5%90%A6%E6%AD%A3%E5%B8%B8&spm=1018.2226.3001.4187
https://blog.csdn.net/MATLABCSD/article/details/136390240
rk3588 測試串口功能是否正常
https://blog.51cto.com/u_16213608/12700040
瑞芯微rk3588 實測目標檢測
https://www.bilibili.com/opus/850451336208056345
RK3588平臺產測之ArmSoM-W3 DDR壓力測試
root@rk3566-buildroot:/#?
root@rk3566-buildroot:/# cd rockchip-test/
root@rk3566-buildroot:/rockchip-test# cd ddr/
root@rk3566-buildroot:/rockchip-test/ddr#?
root@rk3566-buildroot:/rockchip-test/ddr# ll
total 24
drwxr-xr-x ?2 root root 4096 Jul ?2 ?2024 ./
drwxr-xr-x 16 root root 4096 Jul ?2 ?2024 ../
-rwxr-xr-x ?1 root root 1116 Jul ?1 ?2024 ddr_freq_scaling.sh*
-rwxr-xr-x ?1 root root 1395 Jul ?1 ?2024 ddr_test.sh*
-rwxr-xr-x ?1 root root ?559 Jul ?1 ?2024 memtester_test.sh*
-rwxr-xr-x ?1 root root ?681 Jul ?1 ?2024 stressapptest_test.sh*
root@rk3566-buildroot:/rockchip-test/ddr#?
https://www.elecfans.com/d/5402027.html
迅為電子RK3588S開發板第三章Buildroot系統功能測試
https://blog.51cto.com/u_14224/12947041
rk3588串口查看DDR gpu CPU頻率及利用率
https://baijiahao.baidu.com/s?id=1780150091100272757&wfr=spider&for=pc
https://zhuanlan.zhihu.com/p/664344987
https://blog.csdn.net/sinovoip/article/details/134008668
Banana Pi BPI-W3(Armsom W3)RK3588開當板之調試UART
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <termio.h>
#include <time.h>
#include <pthread.h>
?
int read_data(int fd, void *buf, int len);
int write_data(int fd, void *buf, int len);
int setup_port(int fd, int baud, int databits, int parity, int stopbits);
void print_usage(char *program_name);
?
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t data_ready = PTHREAD_COND_INITIALIZER;
int data_available = 0;
?
void *read_thread(void *arg) {
? ? int fd = *(int *)arg;
? ? char buffer[1024]; // 存儲讀取的數據
?
? ? while (1) {
? ? ? ? int bytes_read = read_data(fd, buffer, sizeof(buffer));
? ? ? ? if (bytes_read > 0) {
? ? ? ? ? ? printf("Read Thread: Read %d bytes: %s\n", bytes_read, buffer);
? ? ? ? } else {
? ? ? ? ? ? // 處理讀取錯誤或設備關閉的情況
? ? ? ? ? ? break;
? ? ? ? }
? ? }
? ??
? ? pthread_exit(NULL);
}
?
void *write_thread(void *arg) {
? ? int fd = *(int *)arg;
?? ?char input[1024]; // 存儲用戶輸入的數據
?
? ? while (1) {
? ? ? ? printf("Enter data to write (or 'q' to quit): ");
? ? ? ? fgets(input, sizeof(input), stdin);
?
? ? ? ? if (strcmp(input, "q\n") == 0 || strcmp(input, "Q\n") == 0) {
? ? ? ? ? ? // 用戶輸入 'q' 或 'Q',退出循環
? ? ? ? ? ? break;
? ? ? ? }
?
? ? ? ? int len = strlen(input);
? ? ? ? int bytes_written = write_data(fd, input, len);
? ? ? ? if (bytes_written > 0) {
? ? ? ? ? ? printf("Write Thread: Wrote %d bytes: %s\n", bytes_written, input);
? ? ? ? }
? ? }
? ??
? ? pthread_exit(NULL);
}
?
int main(int argc, char *argv[]) //./a.out /dev/ttyS4 115200 8 0 1
{
? ? int fd;
? ? int baud;
? ? int len;
? ? int count;
? ? int i;
? ? int databits;
? ? int stopbits;
? ? int parity;
?
? ? if (argc != 6) {
? ? ? ? print_usage(argv[0]);
? ? ? ? return 1;
? ? }
?
? ? baud = atoi(argv[2]);
? ? if ((baud < 0) || (baud > 921600)) {
? ? ? ? fprintf(stderr, "Invalid baudrate!\n");
? ? ? ? return 1;
? ? }
?
? ? databits = atoi(argv[3]);
? ? if ((databits < 5) || (databits > 8)) {
? ? ? ? fprintf(stderr, "Invalid databits!\n");
? ? ? ? return 1;
? ? }
?
? ? parity = atoi(argv[4]);
? ? if ((parity < 0) || (parity > 2)) {
? ? ? ? fprintf(stderr, "Invalid parity!\n");
? ? ? ? return 1;
? ? }
?
? ? stopbits = atoi(argv[5]);
? ? if ((stopbits < 1) || (stopbits > 2)) {
? ? ? ? fprintf(stderr, "Invalid stopbits!\n");
? ? ? ? return 1;
? ? }
?
?
? ? fd = open(argv[1], O_RDWR, 0);
? ? if (fd < 0) {
? ? ? ? fprintf(stderr, "open <%s> error %s\n", argv[1], strerror(errno));
? ? ? ? return 1;
? ? }
?
? ? if (setup_port(fd, baud, databits, parity, stopbits)) {
? ? ? ? fprintf(stderr, "setup_port error %s\n", strerror(errno));
? ? ? ? close(fd);
? ? ? ? return 1;
? ? }
?? ?pthread_t read_tid, write_tid;
? ? int ret;
?
? ? // 創建讀取線程
? ? ret = pthread_create(&read_tid, NULL, read_thread, &fd);
? ? if (ret != 0) {
? ? ? ? fprintf(stderr, "Failed to create read thread\n");
? ? ? ? return 1;
? ? }
?
? ? // 創建寫入線程
? ? ret = pthread_create(&write_tid, NULL, write_thread, &fd);
? ? if (ret != 0) {
? ? ? ? fprintf(stderr, "Failed to create write thread\n");
? ? ? ? return 1;
? ? }
?
? ? // 等待讀取線程和寫入線程結束
? ? pthread_join(read_tid, NULL);
? ? pthread_join(write_tid, NULL);
?? ?
? ? close(fd);
?
? ? return 0;
}
?
static int baudflag_arr[] = {
? ? B921600, B460800, B230400, B115200, B57600, B38400,
? ? B19200, ?B9600, ? B4800, ? B2400, ? B1800, ?B1200,
? ? B600, ? ?B300, ? ?B150, ? ?B110, ? ?B75, ? ?B50
};
static int speed_arr[] = {
? ? 921600, ?460800, ?230400, ?115200, ?57600, ?38400,
? ? 19200, ? 9600, ? ?4800, ? ?2400, ? ?1800, ? 1200,
? ? 600, ? ? 300, ? ? 150, ? ? 110, ? ? 75, ? ? 50
};
?
int speed_to_flag(int speed)
{
? ? int i;
?
? ? for (i = 0; ?i < sizeof(speed_arr)/sizeof(int); ?i++) {
? ? ? ? if (speed == speed_arr[i]) {
? ? ? ? ? ? return baudflag_arr[i];
? ? ? ? }
? ? }
?
? ? fprintf(stderr, "Unsupported baudrate, use 9600 instead!\n");
? ? return B9600;
}
?
static struct termio oterm_attr;
?
int setup_port(int fd, int baud, int databits, int parity, int stopbits)
{
? ? struct termio term_attr;
?
? ??
? ? if (ioctl(fd, TCGETA, &term_attr) < 0) {
? ? ? ? return -1;
? ? }
?
? ??
? ? memcpy(&oterm_attr, &term_attr, sizeof(struct termio));
?
? ? term_attr.c_iflag &= ~(INLCR | IGNCR | ICRNL | ISTRIP);
? ? term_attr.c_oflag &= ~(OPOST | ONLCR | OCRNL);
? ? term_attr.c_lflag &= ~(ISIG | ECHO | ICANON | NOFLSH);
? ? term_attr.c_cflag &= ~CBAUD;
? ? term_attr.c_cflag |= CREAD | speed_to_flag(baud);
?
? ??
? ? term_attr.c_cflag &= ~(CSIZE);
? ? switch (databits) {
? ? ? ? case 5:
? ? ? ? ? ? term_attr.c_cflag |= CS5;
? ? ? ? ? ? break;
?
? ? ? ? case 6:
? ? ? ? ? ? term_attr.c_cflag |= CS6;
? ? ? ? ? ? break;
?
? ? ? ? case 7:
? ? ? ? ? ? term_attr.c_cflag |= CS7;
? ? ? ? ? ? break;
?
? ? ? ? case 8:
? ? ? ? default:
? ? ? ? ? ? term_attr.c_cflag |= CS8;
? ? ? ? ? ? break;
? ? }
?
? ??
? ? switch (parity) {
? ? ? ? case 1: ?
? ? ? ? ? ? term_attr.c_cflag |= (PARENB | PARODD);
? ? ? ? ? ? break;
?
? ? ? ? case 2: ?
? ? ? ? ? ? term_attr.c_cflag |= PARENB;
? ? ? ? ? ? term_attr.c_cflag &= ~(PARODD);
? ? ? ? ? ? break;
?
? ? ? ? case 0: ?
? ? ? ? default:
? ? ? ? ? ? term_attr.c_cflag &= ~(PARENB);
? ? ? ? ? ? break;
? ? }
?
?
? ??
? ? switch (stopbits) {
? ? ? ? case 2: ?
? ? ? ? ? ? term_attr.c_cflag |= CSTOPB;
? ? ? ? ? ? break;
?
? ? ? ? case 1: ?
? ? ? ? default:
? ? ? ? ? ? term_attr.c_cflag &= ~CSTOPB;
? ? ? ? ? ? break;
? ? }
?
? ? term_attr.c_cc[VMIN] = 1;
? ? term_attr.c_cc[VTIME] = 0;
?
? ? if (ioctl(fd, TCSETAW, &term_attr) < 0) {
? ? ? ? return -1;
? ? }
?
? ? if (ioctl(fd, TCFLSH, 2) < 0) {
? ? ? ? return -1;
? ? }
?
? ? return 0;
}
?
?
int read_data(int fd, void *buf, int len)
{
? ? int count;
? ? int ret;
?
? ? ret = 0;
? ? count = 0;
?
? ? //while (len > 0) {
?
? ? ret = read(fd, (char*)buf + count, len);
? ? if (ret < 1) {
? ? ? ? fprintf(stderr, "Read error %s\n", strerror(errno));
? ? ? ? //break;
? ? }
?
? ? count += ret;
? ? len = len - ret;
?
? ? //}
?
? ? *((char*)buf + count) = 0;
? ? return count;
}
?
?
int write_data(int fd, void *buf, int len)
{
? ? int count;
? ? int ret;
?
? ? ret = 0;
? ? count = 0;
?
? ? while (len > 0) {
?
? ? ? ? ret = write(fd, (char*)buf + count, len);
? ? ? ? if (ret < 1) {
? ? ? ? ? ? fprintf(stderr, "Write error %s\n", strerror(errno));
? ? ? ? ? ? break;
? ? ? ? }
?
? ? ? ? count += ret;
? ? ? ? len = len - ret;
? ? }
?
? ? return count;
}
?
void print_usage(char *program_name)
{
? ? fprintf(stderr,
? ? ? ? ? ? "*************************************\n"
? ? ? ? ? ? " ?A Simple Serial Port Test Utility\n"
? ? ? ? ? ? "*************************************\n\n"
? ? ? ? ? ? "Usage:\n ?%s <device> <baud> <databits> <parity> <stopbits> \n"
? ? ? ? ? ? " ? ? ? databits: 5, 6, 7, 8\n"
? ? ? ? ? ? " ? ? ? parity: 0(None), 1(Odd), 2(Even)\n"
? ? ? ? ? ? " ? ? ? stopbits: 1, 2\n"
? ? ? ? ? ? "Example:\n ?%s /dev/ttyS4 115200 8 0 1\n\n",
? ? ? ? ? ? program_name, program_name
? ? ? ? ? ?);
}