U-Boot直接引导zImage内核


U-boot1.1.6只能只能就能过mkimage工具加工后的内核镜像文件。mkimage工具给zImage增加了一个64B大小的头。U-Boot是通过bootm命令来引导Linux内核的,bootm命令调用do_bootm函数来mkimage工具增加的头,最后调用do_bootm_linux函数引导去掉了mkimage工具增加的头的Linux内核,也就是zImage,启动的流程可以参考图解U-Boot:引导内核分析()这篇博客。

要让U-Boot直接引导zImage内核,只需在do_bootm函数中去掉对mkimage工具增加的头的分析,直接调用do_bootm_linux函数引导zImage内核即可。下面是经过修改的do_bootm函数,修改的部分用///////////包围起来了,省略号后面的就不需要改动了。这个函数common/cmd_bootm.c文件中。

  1. int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])  
  2. {  
  3.     ulong   iflag;  
  4.     ulong   addr;  
  5.     ulong   data, len, checksum;  
  6.     ulong  *len_ptr;  
  7.     uint    unc_len = CFG_BOOTM_LEN;  
  8.     int i, verify;  
  9.     char    *name, *s;  
  10.     int (*appl)(int, char *[]);  
  11.     image_header_t *hdr = &header;  
  12.     s = getenv ("verify");  
  13.     verify = (s && (*s == 'n')) ? 0 : 1;  
  14.     if (argc < 2) {  
  15.         addr = load_addr;  
  16.     } else {  
  17.         addr = simple_strtoul(argv[1], NULL, 16);  
  18.     }  
  19.     SHOW_BOOT_PROGRESS (1);  
  20. //////////////////////////////////////////////////////////////////////////////////  
  21.     //printf ("## Booting image at %08lx ...\n", addr);  
  22.     printf ("## Booting from zImage at %08lx ---by ce123\n", addr);  
  23. #ifdef CONFIG_SILENT_CONSOLE  
  24.         fixup_silent_linux();  
  25. #endif  
  26.         do_bootm_linux  (cmdtp, flag, argc, argv,  
  27.                  addr, len_ptr, verify);  
  28. //////////////////////////////////////////////////////////////////////////////////  
  29. ......  
  • 1
  • 2
  • 下一页

相关内容