nuc977 uboot启动内核

uboot下打印环境变量:

U-Boot> env print 
[-f]=nambaudrate=115200
baudrate=115200
bootargs=noinitrd ubi.mtd=2 root=ubi0:system rw rootfstype=ubifs console=ttyS0,115200n8 rdinit=/sbin/init mem=64M mtdparts=nand0:0x200000@0x0(u-boot),0x1400000@0x200000(kernel),-(user)
bootcmd=nboot 0x7fc0 0 0x200000; bootm 0x7fc0
bootdelay=9
ethact=emac
ethaddr=00:00:00:11:66:88
stderr=serial
stdin=serial
stdout=serial

 

nboot 0x7fc0 0 0x200000

nboot 命令将 Linux 内核镜像文件从 NAND flash 偏移量 0x200000 这个地址读取到 DDR 0x7fc0 的地址.。

bootm 0x7fc0

bootm 命令是用来启动由 mkimage 工具产生的 Linux 内核或其他应用程序。相较于 bootm 命令, go 命令是来启动 “非” 经由 mkimage 工具产生的。

 

NUC970 配置文件位于 include/configs/nuc970_evb.h

#define MTDIDS_DEFAULT "nand0=nand0"
#define MTDPARTS_DEFAULT "mtdparts=nand0:0x200000@0x0(u-boot),0x1400000@0x200000(kernel),-(user)"
#define MTD_ACTIVE_PART "nand0,2"

 

uimage的头部如下: 在\include\image.h 

64byte

typedef struct image_header {
    __be32        ih_magic;    /* Image Header Magic Number    */
    __be32        ih_hcrc;    /* Image Header CRC Checksum    */
    __be32        ih_time;    /* Image Creation Timestamp    */
    __be32        ih_size;    /* Image Data Size        */
    __be32        ih_load;    /* Data     Load  Address        */
    __be32        ih_ep;        /* Entry Point Address        */
    __be32        ih_dcrc;    /* Image Data CRC Checksum    */
    uint8_t        ih_os;        /* Operating System        */
    uint8_t        ih_arch;    /* CPU architecture        */
    uint8_t        ih_type;    /* Image Type            */
    uint8_t        ih_comp;    /* Compression Type        */
    uint8_t        ih_name[IH_NMLEN];    /* Image Name        */
} image_header_t;

内核运行地址为0x8000,

0x8000-0x7fc0=64byte,节省bootm要移动真正内核的时间。

\common\cmd_bootm.c

主要代码如下:

do_bootm

    if (bootm_start(cmdtp, flag, argc, argv))
        return 1;

     ret = bootm_load_os(images.os, &load_end, 1);

      boot_fn = boot_os[images.os.os];   // boot_fn指向 do_bootm_linux

 

\arch\arm\lib\bootm.c

       do_bootm_linux

       boot_prep_linux(images); //向内核传递标记列表
       boot_jump_linux(images);

************************************************************************

\arch\arm\include\asm\setup.h

struct tag {
    struct tag_header hdr;
    union {
        struct tag_core        core;
        struct tag_mem32    mem;
        struct tag_videotext    videotext;
        struct tag_ramdisk    ramdisk;
        struct tag_initrd    initrd;
        struct tag_serialnr    serialnr;
        struct tag_revision    revision;
        struct tag_videolfb    videolfb;
        struct tag_cmdline    cmdline;

        /*
         * Acorn specific
         */
        struct tag_acorn    acorn;

        /*
         * DC21285 specific
         */
        struct tag_memclk    memclk;
    } u;
};

 

\arch\arm\lib\bootm.c

boot_prep_linux(images); //向内核传递标记列表

   char *commandline = getenv("bootargs");

/*

bootargs=noinitrd ubi.mtd=2 root=ubi0:system rw rootfstype=ubifs console=ttyS0,115200n8 rdinit=/sbin/init mem=64M mtdparts=nand0:0x200000@0x0(u-boot),0x1400000@0x200000(kernel),-(user)

*/

     setup_start_tag(gd->bd);

     setup_commandline_tag(gd->bd, commandline);

   setup_memory_tags(gd->bd);

.......

setup_end_tag(gd->bd);

 

\include\asm-generic\global_data.h

typedef struct global_data {
    bd_t *bd;
    unsigned long flags;
    unsigned int baudrate;
    unsigned long cpu_clk;    /* CPU clock in Hz!        */
    unsigned long bus_clk;
    /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
    unsigned long pci_clk;
    unsigned long mem_clk;
#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
    unsigned long fb_base;    /* Base address of framebuffer mem */
#endif

#ifdef CONFIG_BOARD_TYPES
    unsigned long board_type;
#endif
    unsigned long have_console;    /* serial_init() was called */
#ifdef CONFIG_PRE_CONSOLE_BUFFER
    unsigned long precon_buf_idx;    /* Pre-Console buffer index */
#endif
#ifdef CONFIG_MODEM_SUPPORT
    unsigned long do_mdm_init;
    unsigned long be_quiet;
#endif
    unsigned long env_addr;    /* Address  of Environment struct */
    unsigned long env_valid;    /* Checksum of Environment valid? */

    /* TODO: is this the same as relocaddr, or something else? */
    unsigned long dest_addr;    /* Post-relocation address of U-Boot */
    unsigned long dest_addr_sp;
    unsigned long ram_top;    /* Top address of RAM used by U-Boot */

    unsigned long relocaddr;    /* Start address of U-Boot in RAM */
    phys_size_t ram_size;    /* RAM size */
    unsigned long mon_len;    /* monitor len */
    unsigned long irq_sp;        /* irq stack pointer */
    unsigned long start_addr_sp;    /* start_addr_stackpointer */
    unsigned long reloc_off;
    struct global_data *new_gd;    /* relocated global data */
    const void *fdt_blob;    /* Our device tree, NULL if none */
    void *new_fdt;        /* Relocated FDT */
    unsigned long fdt_size;    /* Space reserved for relocated FDT */
    void **jt;        /* jump table */
    char env_buf[32];    /* buffer for getenv() before reloc. */
    struct arch_global_data arch;    /* architecture-specific data */
} gd_t;
#endif

 

 

 

 

\include\asm-generic\uboot.h

去掉一些不相关的如下

typedef struct bd_info {
    unsigned long    bi_memstart;    /* start of DRAM memory */
    phys_size_t    bi_memsize;    /* size     of DRAM memory in bytes */
    unsigned long    bi_flashstart;    /* start of FLASH memory */
    unsigned long    bi_flashsize;    /* size     of FLASH memory */
    unsigned long    bi_flashoffset; /* reserved area for startup monitor */
    unsigned long    bi_sramstart;    /* start of SRAM memory */
    unsigned long    bi_sramsize;    /* size     of SRAM memory */
#ifdef CONFIG_ARM
    unsigned long    bi_arm_freq; /* arm frequency */
    unsigned long    bi_dsp_freq; /* dsp core frequency */
    unsigned long    bi_ddr_freq; /* ddr frequency */
#endif


    unsigned long    bi_bootflags;    /* boot / reboot flag (Unused) */
    unsigned long    bi_ip_addr;    /* IP Address */
    unsigned char    bi_enetaddr[6];    /* OLD: see README.enetaddr */
    unsigned short    bi_ethspeed;    /* Ethernet speed in Mbps */
    unsigned long    bi_intfreq;    /* Internal Freq, in MHz */
    unsigned long    bi_busfreq;    /* Bus Freq, in MHz */

    unsigned int    bi_baudrate;    /* Console Baudrate */


    ulong            bi_arch_number;    /* unique id for this board */
    ulong            bi_boot_params;    /* where this board expects params */
 

   #ifdef CONFIG_NR_DRAM_BANKS
    struct {            /* RAM configuration */
        ulong start;
        ulong size;
    } bi_dram[CONFIG_NR_DRAM_BANKS];
#endif /* CONFIG_NR_DRAM_BANKS */    

 


#endif /* CONFIG_NR_DRAM_BANKS */
} bd_t;

#endif /* __ASSEMBLY__ */

#endif    /* __ASM_GENERIC_U_BOOT_H__ */
 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值