[U-Boot] [PATCH] arm: Adds saving of Kernel boot args to NAND flash

Scott Wood scottwood at freescale.com
Tue Jul 5 21:36:06 CEST 2011


On Tue, 5 Jul 2011 15:20:39 +0200
Simon Schwarz <simonschwarzcor at googlemail.com> wrote:

> +#ifdef CONFIG_SAVE_BOOT_ARGS
> +/* This function writes given bootparams to NAND flash
> + *  adr: Start adress of Kernel parameter image (ATAGS, FDT)
> + *  length: length of the image in byte
> + *
> + * borrowd heavily from common/cmd_nand.c
> + */
> +void boot_params_to_nand(u_char *adr, size_t length) {

Brace on its own line for functions

> +	/* write */
> +	if(nand_write_skip_bad(nand, off, &length, adr, 0))
> +		printf("FAILED!\n");

Space after "if"

> +#ifdef CONFIG_SAVE_BOOT_ARGS
> +	struct tag *t;
> +	size_t size=0;
> +#endif

Spaces around =

>  	if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
>  		return 1;
>  
> @@ -150,6 +198,17 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
>  	setup_end_tag(bd);
>  #endif
>  
> +#ifdef CONFIG_SAVE_BOOT_ARGS
> +	printf("write ATAGS to NAND...\n");
> +
> +	/* get size of atags */
> +	for_each_tag(t, (struct tag *)(bd->bi_boot_params))
> +		size += t->hdr.size;
> +	size += 2; /* ATAG_NONE has size 0 */
> +	size *= 4;  /*  words -> byte! */
> +	boot_params_to_nand((u_char *)bd->bi_boot_params, size);
> +#endif
> +
>  	announce_and_cleanup();
>  
>  	kernel_entry(0, machid, bd->bi_boot_params);
> @@ -208,6 +267,11 @@ static int bootm_linux_fdt(int machid, bootm_headers_t *images)
>  
>  	fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 1);
>  
> +#ifdef CONFIG_SAVE_BOOT_ARGS
> +	printf("write FDT to NAND...\n");
> +	boot_params_to_nand((u_char *)(*of_flat_tree),of_size);
> +#endif

Why are you writing to NAND as part of bootm?

If you just want access to the results of the FDT/ATAG preparation that
bootm does, consider using the bootm subcommands to prepare them, then
normal U-Boot commands to write to NAND.

-Scott



More information about the U-Boot mailing list