在uboot显示图片的时候可以将jpg图片作为uboot的一段,在程序中访问该段,实现图片。
图片: logo.jpg ,将其拷贝到common下
- 修改u-boot.lds,添加".log"段。(u-boot.lds的路径:arch/arm/cpu/godnet/u-boot.lds)
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) ENTRY(_start) SECTIONS { . = 0x00000000; . = ALIGN(4); .text : { arch/arm/cpu/godnet/start.o (.text) *(.text) } . = ALIGN(4); __logo_start = .; .logo : { common/logo.o (.logo); } __logo_end = .; . = ALIGN(4); .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } . = ALIGN(4); .data : { *(.data) } . = ALIGN(4); .got : { *(.got) } __u_boot_cmd_start = .; .u_boot_cmd : { *(.u_boot_cmd) } __u_boot_cmd_end = .; . = ALIGN(4); __bss_start = .; .bss : { *(.bss) } _end = .; }
- 在common下添加logo.S文件,写入如下内容
.section .logo .incbin "./logo.jpg"
- 添加common/cmd_logo.c ,内容如下:
#include <common.h> #include <command.h> extern unsigned int __logo_start; extern unsigned int __logo_end; int do_logo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { volatile char *p = (volatile char *)(&__logo_start); int i; unsigned int len = 0; len = (unsigned int)&__logo_end - (unsigned int)&__logo_start; printf("__logo_start = %p ", &__logo_start); printf("__logo_end = %p ", &__logo_end); printf("logo size is %x ", len); for (i = 0; i < len; i++) { if(i % 16 == 0) { printf(" "); } printf("%3x ", *p++&0xff); } printf(" "); return 0; } U_BOOT_CMD( logo, CONFIG_SYS_MAXARGS, 1, do_logo, "minimal test like /bin/sh", "[args..]" );
- 修改common/Makefile,添加如下内容:
COBJS-y += cmd_logo.o AOBJS-y += logo.o COBJS := $(sort $(COBJS-y)) AOBJS := $(sort $(AOBJS-y)) SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
- 编译uboot
本例是将.logo段的图片数据读取并打印出来,显示图片不是重点。