Firefly搬运工 发表于 2022-9-16 11:24:37

【ROC-RK3568-PC开发板试用体验】HDMI刷屏测试

本帖最后由 Firefly搬运工 于 2022-9-16 11:25 编辑

参考【ROC-RK3568-PC开发板试用体验】ssh登录root与第一个c程序的ssh登录配置等


pt install lrzsz安装sz rz工具rz是导入文件到开发板sz相反安装后,crt中ssh登录开发板后,就可以输入rz回车自动弹出选择文件对话框选择文件,点击Add点击Ok就可发送到开发板
https://file.elecfans.com/web2/M00/66/E2/poYBAGMUukGAGqRYAAJCdos7oDg093.png
sz 文件名则从开发板下载到本地输出的路径可以配置右键点击连接->Session Options...
https://file.elecfans.com/web2/M00/67/7C/pYYBAGMUukuAG4kzAAOlrohjJfs032.png
配置上传下载路径如下
https://file.elecfans.com/web2/M00/66/E2/poYBAGMUulSAHBKlAAD-JWID35Y537.png
Framebuffer测试代码
#include <stdint.h>

#include <stdio.h>

#include <unistd.h>

#include <stdlib.h>

#include <string.h>

#include <fcntl.h>

#include <errno.h>

#include <sys/mman.h>

#include <sys/ioctl.h>

#include <sys/mman.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <linux/fb.h>

int main(int argc, char *argv[])

{

int fd = -1;

int ret = -1;

uint8_t *p_fb = 0;

struct fb_fix_screeninfo finfo;

struct fb_var_screeninfo vinfo;

memset(&finfo,0,sizeof(finfo));

memset(&vinfo,0,sizeof(vinfo));

fd = open(argv,O_RDWR);

if(fd < 0)

{

fprintf(stderr,"open %s err, %s\n",argv,strerror(errno));

return -1;


}

ret = ioctl(fd, FBIOGET_FSCREENINFO, &finfo);

if(ret < 0)

{

fprintf(stderr,"ioctl finfo err, %s\n",strerror(errno));

close(fd);

return -1;



}

ret = ioctl(fd, FBIOGET_VSCREENINFO, &vinfo);

if(ret < 0)

{

fprintf(stderr,"ioctl vinfo err, %s\n",strerror(errno));

close(fd);

return -1;

}

unsigned long len = vinfo.xres_virtual* vinfo.yres_virtual * vinfo.bits_per_pixel / 8;

p_fb = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);

if(p_fb == NULL)

{

fprintf(stderr,"mmap len %ld err\n",len);

close(fd);

return -1;

}

fprintf(stderr,"x = %d y = %d bits = %d len = %ld\n",vinfo.xres_virtual,vinfo.yres_virtual,vinfo.bits_per_pixel,len);

volatile int times = 30;

while(times--)

{

if(vinfo.bits_per_pixel == 16)

{

for(unsigned int i=0; i< len/2; )

{

*((uint16_t*)(p_fb + i)) = 0xF800;

i+=2;


}

usleep(atoi(argv)*1000);

for(unsigned int i=0; i< len/2;)

{

*((uint16_t*)(p_fb + i)) = 0x07E0;

i+=2;


}

usleep(atoi(argv)*1000);

for(unsigned int i=0; i< len/2;)

{

*((uint16_t*)(p_fb + i)) = 0x001F;

i+=2;

}

usleep(atoi(argv)*1000);


}

else

{

for(unsigned int i=0; i< len/4; )

{


*((uint32_t*)(p_fb + i)) = 0xFF0000;

i+=4;

}

usleep(atoi(argv)*1000);

for(unsigned int i=0; i< len/4;)

{

*((uint32_t*)(p_fb + i)) = 0x00FF00;

i+=4;


}

usleep(atoi(argv)*1000);

for(unsigned int i=0; i< len/4;)

{

*((uint32_t*)(p_fb + i)) = 0x0000FF;

i+=4;


}

usleep(atoi(argv)*1000);


}


}

munmap(p_fb,len);

close(fd);

return 0;


}
rz导入到开发板
编译gcc framebuffer.c-o framebuffer
运行./framebuffer /dev/fb0 200
可以看到以200ms间隔 rgb刷屏 30次。
https://file.elecfans.com/web2/M00/66/E2/poYBAGMUu1uACptZAAIRvfcO4ks248.jpg
https://file.elecfans.com/web2/M00/67/7C/pYYBAGMUu2CAU6ulAAG8XUiqk9s119.jpg
https://file.elecfans.com/web2/M00/66/E2/poYBAGMUu2aAa9xVAAG9fxf6Rf8235.jpg

总结

测试framebuffer和hdmi显示ok,后续就可以基于此进行相应的图形程序的开发。比如移植lvgl等。



页: [1]
查看完整版本: 【ROC-RK3568-PC开发板试用体验】HDMI刷屏测试