在uboot显示图片的时候可以将jpg图片作为uboot的一段,在程序中访问该段,实现图片。
图片: logo.jpg ,将其拷贝到common下
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 = .; }
.section .logo .incbin "./logo.jpg"
#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\n", &__logo_start); printf("__logo_end = %p\n", &__logo_end); printf("logo size is %x\n", len); for (i = 0; i < len; i++) { if(i % 16 == 0) { printf("\n"); } printf("%3x ", *p++&0xff); } printf("\n"); return 0; } U_BOOT_CMD( logo, CONFIG_SYS_MAXARGS, 1, do_logo, "minimal test like /bin/sh", "[args..]" );
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))
本例是将.logo段的图片数据读取并打印出来,显示图片不是重点。