[U-Boot] [help] how does u-boot passing ``fdt'' to linux kernel & where is cmd_line?

Baojun Wang wangbj at gmail.com
Mon Jul 13 14:44:27 CEST 2009


hi, list:

  I've read Documentation/powerpc/booting-without-of.txt & some
documents about fdt/dtb, as booting-without-of.txt said, the
bootloader like u-boot should passing fdt as $r3, the kernel entry
(physical) address as $r4;

                r3 : physical pointer to the device-tree block
                (defined in chapter II) in RAM

                r4 : physical pointer to the kernel itself. This is
                used by the assembly code to properly disable the MMU
                in case you are entering the kernel with MMU enabled
                and a non-1:1 mapping.

                r5 : NULL (as to differentiate with method a)

I see fdt is something like:

struct fdt_header {
        uint32_t magic;                  /* magic word FDT_MAGIC */
        uint32_t totalsize;              /* total size of DT block */
        uint32_t off_dt_struct;          /* offset to structure */
        uint32_t off_dt_strings;         /* offset to strings */
        uint32_t off_mem_rsvmap;         /* offset to memory reserve map */
        uint32_t version;                /* format version */
        uint32_t last_comp_version;      /* last compatible version */

        /* version 2 fields below */
        uint32_t boot_cpuid_phys;        /* Which physical CPU id we're
                                            booting on */
        /* version 3 fields below */
        uint32_t size_dt_strings;        /* size of the strings block */

        /* version 17 fields below */
        uint32_t size_dt_struct;         /* size of the structure block */
};

My question is how does the kernel cmd line being passed? I know it's
possible for u-boot to patching the target uImage (assume we're using
kernel image cuImage.bamboo)'s dtb by overwrite the dtb ``chosen''
section, but I didn't find any code in u-boot trying to do this.

Even more, after the kernel is bootstraping, (assume we're using a
bamboo board), we'll run into:

static bd_t bd;

...
void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
		unsigned long r6, unsigned long r7)
{
	CUBOOT_INIT();
	bamboo_init(&bd.bi_enetaddr, &bd.bi_enet1addr);
}

...

void bamboo_init(void *mac0, void *mac1)
{
	platform_ops.fixups = bamboo_fixups;
	platform_ops.exit = ibm44x_dbcr_reset;
	bamboo_mac0 = mac0;
	bamboo_mac1 = mac1;
	fdt_init(_dtb_start);
	serial_console_init();
}
...

this code will assume $r3 is passed as a ``bd_t'' structure, but $r3
passed in I think it's the dtb address (not bd_t), and bamboo_init
will set the NIC wrong MAC addresses. I'm quite sure I misunderstand
something between u-boot & linux kernel, could some help me to figure
it out? Thanks in advance!

  Best Regards,
Wang Baojun


More information about the U-Boot mailing list