修改uboot的log显示

uboot version:2016.03

hardware:imx6ull

ubuntu 18.04

说明:本文使用uboot的根目录为uboot/

一、修改显示流程

(1)准备一张.jpg的图片(例如图片名为test.jpg),图片像素大小不要超过显示屏的大小,例如我的显示屏像素为1024x600.准备的图片为350x350.

(2)将图片通过工具发送到ubuntu中。使用命令

jpegtopnm test.jpg | ppmquant 31 | ppmtobmp -bpp 8 > test.bmp

生成test.bmp。

(3)将生成test.bmp复制到uboot/tools/logos中。(uboot的log文件都存放这个目录中)

(4)修改uboot/tools的Makefile文件:

# Generic logo
ifeq ($(LOGO_BMP),)
LOGO_BMP= $(srctree)/$(src)/logos/denx.bmp

# Use board logo and fallback to vendor
ifneq ($(wildcard $(srctree)/$(src)/logos/$(BOARD).bmp),)
LOGO_BMP= $(srctree)/$(src)/logos/$(BOARD).bmp
else
ifneq ($(wildcard $(srctree)/$(src)/logos/$(VENDOR).bmp),)
LOGO_BMP= $(srctree)/$(src)/logos/$(VENDOR).bmp
endif
endif

endif # !LOGO_BMP

#alpha board new add
LOGO_BMP= $(srctree)/$(src)/logos/alpha_fczlm.bmp

在LOGO_BMP赋值的最后,给LOGO_BMP重新赋值为test.bmp图片。

(5)返回uboot/执行make命令重新编译uboot.

(6)将编译生成的uboot.imx下载到板子上,开机可以看到图片修改成功。但是现实在左上角如图所示:

修改uboot的log显示_第1张图片

(7)解决log显示在左上角的问题。可以设置一个环境变量叫splashpos,这个环境变量是设置log显示的起始位置的。设置命令为:(此处设置显示为中间:则图片显示的起始坐标为:X = 1024/2 - 350/2 = 362;Y = 600/2 - 350/2 = 150)

setenv splashpos '362,150'
saveenv

重启,log即显示在中间。

注意:log显示的起始坐标不是(0,0),就不会显示uboot版本信息。

二、源码分析

(1)uboot中log显示调用函数过程:

void board_init_r()
        int stdio_add_devices(void)
            int drv_video_init(void)
                static int video_init(void)        
                    static void *video_logo(void)

(2)static void *video_logo(void)源码分析

static void *video_logo(void)
{
	char info[128];
	int space, len;
	__maybe_unused int y_off = 0;
	__maybe_unused ulong addr;
	__maybe_unused char *s;

        /*
           获取splashpos环境变量设置的log现实的位置
           (video_logo_xpos和video_logo_ypos是一个静态环境变量,所以默认初始值为0)
         */
	splash_get_pos(&video_logo_xpos, &video_logo_ypos);		
#ifdef CONFIG_SPLASH_SCREEN  //在mx6ull_alpha_emmc.h中定义了该宏
        s = getenv("splashimage");//没有定义该环境变量(该环境变量是制定log路径的)
        if (s != NULL) {
		splash_screen_prepare();
		addr = simple_strtoul(s, NULL, 16);

		if (video_display_bitmap(addr,
					video_logo_xpos,
					video_logo_ypos) == 0) {
			video_logo_height = 0;
			return ((void *) (video_fb_address));
		}
	}
#endif /* CONFIG_SPLASH_SCREEN */

	logo_plot(video_fb_address, video_logo_xpos, video_logo_ypos);	//显示log

#ifdef CONFIG_SPLASH_SCREEN_ALIGN    //在mx6ull_alpha_emmc.h中定义了该宏
	/*
	 * when using splashpos for video_logo, skip any info
	 * output on video console if the logo is not at 0,0
	 */
	if (video_logo_xpos || video_logo_ypos) {   //如果显示坐标不为(0,0)
		/*
		 * video_logo_height is used in text and cursor offset
		 * calculations. Since the console is below the logo,
		 * we need to adjust the logo height
		 */
		if (video_logo_ypos == BMP_ALIGN_CENTER)
			video_logo_height += max(0, (int)(VIDEO_VISIBLE_ROWS -
						     VIDEO_LOGO_HEIGHT) / 2);
		else if (video_logo_ypos > 0)
			video_logo_height += video_logo_ypos;
                
                /*返回video_console_address*/
		return video_fb_address + video_logo_height * VIDEO_LINE_LEN;			
}
#endif
	//从上面代码可以分析出,如果log显示的起始坐标不为(0,0)则不会执行下面的代码
	if (board_cfb_skip())
		return 0;

	sprintf(info, " %s", version_string);	//获取uboot信息
								
	space = (VIDEO_COLS - VIDEO_INFO_X) / VIDEO_FONT_WIDTH;
	len = strlen(info);

	if (len > space) {
		int xx = VIDEO_INFO_X, yy = VIDEO_INFO_Y;
		uchar *p = (uchar *) info;
		while (len) {
			if (len > space) {
				video_drawchars(xx, yy, p, space);
				len -= space;

				p = (uchar *) p + space;

				if (!y_off) {
					xx += VIDEO_FONT_WIDTH;
					space--;
				}
				yy += VIDEO_FONT_HEIGHT;

				y_off++;
			} else {
				video_drawchars(xx, yy, p, len);
				len = 0;
			}
		}
	} else
	video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *) info);	//显示uboot信息

#ifdef CONFIG_CONSOLE_EXTRA_INFO
	{
		int i, n =
			((video_logo_height -
			  VIDEO_FONT_HEIGHT) / VIDEO_FONT_HEIGHT);

		for (i = 1; i < n; i++) {
			video_get_info_str(i, info);
			if (!*info)
				continue;

			len = strlen(info);
			if (len > space) {
				video_drawchars(VIDEO_INFO_X,
						VIDEO_INFO_Y +
						(i + y_off) *
							VIDEO_FONT_HEIGHT,
						(uchar *) info, space);
				y_off++;
				video_drawchars(VIDEO_INFO_X +
						VIDEO_FONT_WIDTH,
						VIDEO_INFO_Y +
							(i + y_off) *
							VIDEO_FONT_HEIGHT,
						(uchar *) info + space,
						len - space);
			} else {
				video_drawstring(VIDEO_INFO_X,
						 VIDEO_INFO_Y +
						 (i + y_off) *
							VIDEO_FONT_HEIGHT,
						 (uchar *) info);
			}
		}
	}
#endif
        //返回video_console_address
	return (video_fb_address + video_logo_height * VIDEO_LINE_LEN);	}
#endif

(3)修改显示背景。修改#define CONSOLE_BG_COL      0x00即可。0x00为黑色背景,如果要显示白色背景,修改为0xFF即可

 

你可能感兴趣的:(Linux)