arm: Adds saving of Kernel boot args to NAND flash
PATCH 1/1 arm: Adds saving of Kernel boot args to NAND flash
Adds the saving of either ATAGS or FDT kernel argument image to NAND flash. This image then can be used in SPL boot.
This adds two CONFIG_ paramter to board configuration (in this RFC as example added to devkit8000.h):CONFIG_SAVE_BOOT_ARGS makes the feature activeCONFIG_BOOT_ARGS_NAND_OFS defines the offset in NAND flash where the image
is saved
For OMAP34XX the image is saved with hw-ecc.
---
This is an RFC on how this can be done.
What I don't like here is the omap specific hw ecc switch. But the nand-spl has just hw-ecc yet - at least afaik.
Belonging discussion: http://marc.info/?t=130942998000003
Regards
Simon
arch/arm/lib/bootm.c | 64 ++++++++++++++++++++++++++++++++++++++++++ include/configs/devkit8000.h | 4 ++ 2 files changed, 68 insertions(+), 0 deletions(-)
arch/arm/lib/bootm.c +64 -0
@@ -5,6 +5,10 @@* * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw at its.tudelft.nl) * +* Copyright (C) 2011 +* Corscience GmbH & Co. KG - Simon Schwarz <[email protected]> +* - added saving of kernel-parameter-image to NAND flash +* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or
@@ -30,6 +34,14 @@#include <libfdt.h> #include <fdt_support.h> +#ifdef CONFIG_SAVE_BOOT_ARGS +#include <nand.h> +#include <asm/setup.h> +#ifdef CONFIG_OMAP34XX +#include <asm/arch/sys_proto.h> +#endif +#endif +DECLARE_GLOBAL_DATA_PTR ; #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
@@ -58,6 +70,38 @@ static ulong get_sp(void);static int bootm_linux_fdt (int machid,bootm_headers_t *images);#endif +#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) { +nand_info_t *nand = &nand_info[nand_curr_device];/* use current dev */ +loff_t off =CONFIG_BOOT_ARGS_NAND_OFS ; +nand_erase_options_t opts; + +#ifdef CONFIG_OMAP34XX +omap_nand_switch_ecc (1 );/* use hw ecc on omap for SPL compat */ +#endif +/* erase */ +memset (&opts,0 ,sizeof (opts)); + opts.offset = off; + opts.length = length; + opts.quiet =1 ; + opts.spread =1 ; +nand_erase_opts (nand,&opts); + +/* write */ +if (nand_write_skip_bad (nand, off, &length, adr,0 )) +printf ("FAILED!\n" ); + +printf ("Written to offset 0x%llX, size: %d bytes\n" , + off, length); +} +#endif /* CONFIG_SAVE_BOOT_ARGS */ +void arch_lmb_reserve (struct lmb *lmb) {ulong sp;
@@ -104,6 +148,10 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)char *commandline =getenv ("bootargs" );#endif +#ifdef CONFIG_SAVE_BOOT_ARGS +struct tag *t; +size_t size=0 ; +#endif 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 +announce_and_cleanup ();kernel_entry (0 , machid, *of_flat_tree);
include/configs/devkit8000.h +4 -0
@@ -345,4 +345,8 @@ CONFIG_SYS_INIT_RAM_SIZE - \ GENERATED_GBL_DATA_SIZE) +/* Direct OS boot options */ +#define CONFIG_SAVE_BOOT_ARGS +#define CONFIG_BOOT_ARGS_NAND_OFS 0x700000 +#endif /* __CONFIG_H */
Signature · 1 line
1.7.4.1
PATCH 1/1 arm: Adds saving of Kernel boot args to NAND flash
arch/arm/lib/bootm.c static ulong get_sp(void); · line 80
Quoted 8 lines · On Tue, 5 Jul 2011 15:20:39 +0200 Simon Schwarz…
arch/arm/lib/bootm.c +8
-0+#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
arch/arm/lib/bootm.c static ulong get_sp(void); · line 98
Quoted 3 lines
arch/arm/lib/bootm.c +3
-0+/* write */ +if (nand_write_skip_bad (nand, off, &length, adr,0 )) +printf ("FAILED!\n" );
Space after "if"
arch/arm/lib/bootm.c int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) · line 154
Quoted 4 lines
arch/arm/lib/bootm.c +4
-0+#ifdef CONFIG_SAVE_BOOT_ARGS +struct tag *t; +size_t size=0 ; +#endif
Spaces around =
Quoted 22 lines
arch/arm/lib/bootm.c +11
-0if ((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);
arch/arm/lib/bootm.c static int bootm_linux_fdt(int machid, bootm_headers_t *images) · line 273
Quoted 7 lines
arch/arm/lib/bootm.c +4
-0@@ -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
PATCH 1/1 arm: Adds saving of Kernel boot args to NAND flash
Hi,
thanks for your feedback!
I will address the style problems - didn't run checkpatch for the RFC
- sorry my fault.
Quoted 5 lines
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.
Hm thats a point. I see this as a feature as it saves new settings without the need of special commands - you start the same configuration either with u-boot or the SPL. But you are right - an extra command would also be nice. I will add this.
Regards
Simon
PATCH 1/1 arm: Adds saving of Kernel boot args to NAND flash
In reply to Scott WoodQuoted 3 lines
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.
Me again. I rethought and the problem with bootm is that the subfunctions (bootm_linux_fdt/do_bootm_linux) are directly boot the kernel. That means either I copy almost the whole function and delete the kernel_entry-call. Or I move the tag/fdt creation out of bootm-command and create a extra function.
The first way I consider bad because of code duplication - therefore I would take the second path. Any Objections?
Regards
Simon
PATCH 1/1 arm: Adds saving of Kernel boot args to NAND flash
In reply to Simon SchwarzQuoted 7 lines · On Wed, 6 Jul 2011 09:42:52 +0200 Simon Schwarz…
Hi,
thanks for your feedback!
I will address the style problems - didn't run checkpatch for the RFC
- sorry my fault.
Quoted 8 lines
Quoted 5 lines
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.
Hm thats a point. I see this as a feature as it saves new settings without the need of special commands
But that's not what bootm is for. If you're doing something new, it should be in a new command -- or in a script of existing commands.
-Scott
PATCH 1/1 arm: Adds saving of Kernel boot args to NAND flash
In reply to Simon SchwarzHi Simon,
Le 05/07/2011 15:20, Simon Schwarz a ?crit :
Quoted 1 line
This is an RFC on how this can be done.
Then please tag the subject with [RFC] next time!
Amicalement,
Signature · 1 line
Albert.
PATCH 1/1 arm: Adds saving of Kernel boot args to NAND flash
In reply to Scott WoodQuoted 2 lines
But that's not what bootm is for. ?If you're doing something new, it should be in a new command -- or in a script of existing commands.
True. The upper patch was the quickest way to do this.
I implemented a first test for a command. This is a bit ugly because I have to rip apart bootm. For now I heavily used extern and removed static keywords from bootm - this is ok for the testing but not to get it into mainline...
I'am not sure how i can handle this to get it into mainline. The main problem is in arch/arm/lib/bootm.c implementation:
static void setup_start_tag (bd_t *bd);
static void setup_memory_tags (bd_t *bd);
static void setup_commandline_tag (bd_t *bd, char *commandline); static void setup_initrd_tag (bd_t *bd, ulong initrd_start,
ulong initrd_end);
static void setup_end_tag (bd_t *bd);
static struct tag *params;
static ulong get_sp(void);
static int bootm_linux_fdt(int machid, bootm_headers_t *images);
These function i need to build the atags. But they are defined static and not really meant to be used from the outside. What comes to my mind here is to create a new setup_atags.c in the same directory + a header in include. Is this the right place for this? Maybe another solution?
Regards
Simon
PATCH 1/1 arm: Adds saving of Kernel boot args to NAND flash
Quoted 22 lines · On Thu, 7 Jul 2011 17:50:12 +0200 Simon Schwarz…
Quoted 2 lines
But that's not what bootm is for. ?If you're doing something new, it should be in a new command -- or in a script of existing commands.
True. The upper patch was the quickest way to do this.
I implemented a first test for a command. This is a bit ugly because I have to rip apart bootm. For now I heavily used extern and removed static keywords from bootm - this is ok for the testing but not to get it into mainline...
I'am not sure how i can handle this to get it into mainline. The main problem is in
arch/arm/lib/bootm.cimplementation:
static voidsetup_start_tag(bd_t*bd);
static voidsetup_memory_tags(bd_t*bd);
static voidsetup_commandline_tag(bd_t*bd, char *commandline); static voidsetup_initrd_tag(bd_t*bd, ulonginitrd_start,ulong initrd_end);static void
setup_end_tag(bd_t*bd);
static struct tag *params;
static ulongget_sp(void);
static intbootm_linux_fdt(int machid, bootm_headers_t *images);
Quoted 5 lines
These function i need to build the atags. But they are defined static and not really meant to be used from the outside. What comes to my mind here is to create a new
setup_atags.cin the same directory + a header in include. Is this the right place for this? Maybe another solution?
Look at bootm subcommands to run just the portion of the existing bootm functionality that you need. Type "help bootm" for details.
-Scott
PATCH 1/1 arm: Adds saving of Kernel boot args to NAND flash
Quoted 2 lines
Look at bootm subcommands to run just the portion of the existing bootm functionality that you need. ?Type "help bootm" for details.
Of course I could implement a subcommand - actually this seems to be the best method.
IMHO "prep" would be the right one to use? correct?
Regards
Simon
RFC 1/2 arm: Added prep subcommand support to bootm
In reply to Simon SchwarzAdds prep subcommand to bootm implementation of ARM. When bootm is called prep the function stops right after ATAGS creation and before announce_and_cleanup.
This is used in savebp command
---
Ok second RFC!
I know that there are many style problems - but I don't have the time before weekend/at the weekend to fix them.
So please no close inspection just a comment on the way how the patch is done.
I will address the styleproblems on Monday!
Thanks, and have a nive weekend!
Simon
--- arch/arm/lib/bootm.c | 107 +++++++++++++++++++++++++++----------------------- 1 files changed, 58 insertions(+), 49 deletions(-)
arch/arm/lib/bootm.c +58 -49
@@ -1,4 +1,7 @@ -/* +/* Copyright (C) 2011 +* Corscience GmbH & Co. KG - Simon Schwarz <[email protected]> +* - Added prep subcommand support +* * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <[email protected]>
@@ -55,7 +58,7 @@ static struct tag *params;static ulong get_sp (void );#if defined(CONFIG_OF_LIBFDT ) -static int bootm_linux_fdt (int machid,bootm_headers_t *images); +static int bootm_linux_fdt (int machid,bootm_headers_t *images,int flag);#endif void arch_lmb_reserve (struct lmb *lmb)
@@ -104,57 +107,61 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)char *commandline =getenv ("bootargs" );#endif -if ((flag !=0 ) && (flag !=BOOTM_STATE_OS_GO )) -return 1 ; - - s =getenv ("machid" ); -if (s) { - machid =simple_strtoul (s,NULL ,16 ); -printf ("Using machid 0x%x from environment\n" , machid); - } +if ((flag !=0 ) && (flag !=BOOTM_STATE_OS_GO || + flag !=BOOTM_STATE_OS_PREP )) +return 1 ;/* subcommand not implemented */ +else +if ((flag ==0 ) || flag ==BOOTM_STATE_OS_PREP ) { + s =getenv ("machid" ); +if (s) { + machid =simple_strtoul (s,NULL ,16 ); +printf ("Using machid 0x%x from environment\n" , machid); + } -show_boot_progress (15 ); +show_boot_progress (15 );#ifdef CONFIG_OF_LIBFDT -if (images->ft_len) -return bootm_linux_fdt (machid, images); +if (images->ft_len) +return bootm_linux_fdt (machid, images, flag);#endif - kernel_entry = (void (*)(int ,int ,uint ))images->ep; + kernel_entry = (void (*)(int ,int ,uint ))images->ep; -debug ("## Transferring control to Linux (at address %08lx) ...\n" , - (ulong ) kernel_entry); +debug ("## Transferring control to Linux (at address %08lx) ...\n" , + (ulong ) kernel_entry);#if defined (CONFIG_SETUP_MEMORY_TAGS ) || \ defined (CONFIG_CMDLINE_TAG ) || \ defined (CONFIG_INITRD_TAG ) || \ defined (CONFIG_SERIAL_TAG ) || \ defined (CONFIG_REVISION_TAG ) -setup_start_tag (bd); +setup_start_tag (bd);#ifdef CONFIG_SERIAL_TAG -setup_serial_tag (¶ms); +setup_serial_tag (¶ms);#endif #ifdef CONFIG_REVISION_TAG -setup_revision_tag (¶ms); +setup_revision_tag (¶ms);#endif #ifdef CONFIG_SETUP_MEMORY_TAGS -setup_memory_tags (bd); +setup_memory_tags (bd);#endif #ifdef CONFIG_CMDLINE_TAG -setup_commandline_tag (bd, commandline); +setup_commandline_tag (bd, commandline);#endif #ifdef CONFIG_INITRD_TAG -if (images->rd_start && images->rd_end) -setup_initrd_tag (bd, images->rd_start, images->rd_end); +if (images->rd_start && images->rd_end) +setup_initrd_tag (bd, images->rd_start, images->rd_end);#endif -setup_end_tag (bd); +setup_end_tag (bd);#endif + } -announce_and_cleanup (); - -kernel_entry (0 , machid, bd->bi_boot_params); -/* does not return */ +if (flag ==0 || flag ==BOOTM_STATE_OS_GO ) { +announce_and_cleanup (); +kernel_entry (0 , machid, bd->bi_boot_params); +/* does not return */ + }return 1 ; }
@@ -174,7 +181,7 @@ static int fixup_memory_node(void *blob)return fdt_fixup_memory_banks (blob, start, size,CONFIG_NR_DRAM_BANKS ); } -static int bootm_linux_fdt (int machid,bootm_headers_t *images) +static int bootm_linux_fdt (int machid,bootm_headers_t *images,int flag) {ulong rd_len;void (*kernel_entry)(int zero,int dt_machid,void *dtblob);
@@ -185,34 +192,36 @@ static int bootm_linux_fdt(int machid, bootm_headers_t *images)struct lmb *lmb = &images->lmb;int ret; - kernel_entry = (void (*)(int ,int ,void *))images->ep; - -boot_fdt_add_mem_rsv_regions (lmb, *of_flat_tree); - - rd_len = images->rd_end - images->rd_start; - ret =boot_ramdisk_high (lmb, images->rd_start, rd_len, - initrd_start, initrd_end); -if (ret) -return ret; +if ((flag ==0 ) || flag ==BOOTM_STATE_OS_PREP ) { + kernel_entry = (void (*)(int ,int ,void *))images->ep; - ret =boot_relocate_fdt (lmb, of_flat_tree, &of_size); -if (ret) -return ret; +boot_fdt_add_mem_rsv_regions (lmb, *of_flat_tree); -debug ("## Transferring control to Linux (at address %08lx) ...\n" , - (ulong ) kernel_entry); + rd_len = images->rd_end - images->rd_start; + ret =boot_ramdisk_high (lmb, images->rd_start, rd_len, + initrd_start, initrd_end); +if (ret) +return ret; -fdt_chosen (*of_flat_tree,1 ); + ret =boot_relocate_fdt (lmb, of_flat_tree, &of_size); +if (ret) +return ret; -fixup_memory_node (*of_flat_tree); +debug ("## Transferring control to Linux (at address %08lx) ...\n" , + (ulong ) kernel_entry); -fdt_initrd (*of_flat_tree, *initrd_start, *initrd_end,1 ); +fdt_chosen (*of_flat_tree,1 ); -announce_and_cleanup (); +fixup_memory_node (*of_flat_tree); -kernel_entry (0 , machid, *of_flat_tree); -/* does not return */ +fdt_initrd (*of_flat_tree, *initrd_start, *initrd_end,1 ); + } +if (flag ==0 || flag ==BOOTM_STATE_OS_GO ) { +announce_and_cleanup (); +kernel_entry (0 , machid, *of_flat_tree); +/* does not return */ + } return 1; }#endif
Signature · 1 line
1.7.4.1
RFC 2/2 arm: Adds saving of Kernel boot args to NAND flash
Adds the saving of either ATAGS or FDT kernel argument image to NAND flash This image then can be used in SPL boot.
Command savebp is added to achieve this. This inits a partial run of bootm utilizing subcommands. The result then is saved to NAND flash.
This adds the following defines to board configuration:CONFIG_CMD_SAVEBP activates the commandCONFIG_CMD_SAVEBP_ARGS_NAND_OFS defines the offset in NAND flash where
the image is saved
For OMAP34XX the image is saved with hw-ecc.
---
For RFC: the FDT implementation is todo
--- arch/arm/lib/Makefile | 1 + arch/arm/lib/savebp.c | 100 ++++++++++++++++++++++++++++++++++++++++++ common/Makefile | 2 +- common/cmd_savebp.c | 97 ++++++++++++++++++++++++++++++++++++++++ include/configs/devkit8000.h | 4 ++ 5 files changed, 203 insertions(+), 1 deletions(-) create mode 100644 arch/arm/lib/savebp.c create mode 100644 common/cmd_savebp.c
arch/arm/lib/Makefile +1 -0
@@ -44,6 +44,7 @@ COBJS-y += cache-cp15.o endif COBJS-y += interrupts.o COBJS-y += reset.o +COBJS-$(CONFIG_CMD_SAVEBP) += savebp.o SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
arch/arm/lib/savebp.c new file +100 -0
100 lines not on this page · raw message
common/Makefile +1 -1
@@ -160,6 +160,7 @@ COBJS-$(CONFIG_USB_STORAGE) += usb_storage.o endif COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o +COBJS-$(CONFIG_CMD_SAVEBP) += cmd_savebp.o # others COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o
@@ -174,7 +175,6 @@ COBJS-$(CONFIG_MODEM_SUPPORT) += modem.o COBJS-$(CONFIG_UPDATE_TFTP) += update.o COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o - COBJS := $(sort $(COBJS-y)) XCOBJS := $(sort $(XCOBJS-y)) SRCS := $(COBJS:.o=.c) $(XCOBJS:.o=.c)
common/cmd_savebp.c new file +97 -0
97 lines not on this page · raw message
include/configs/devkit8000.h +4 -0
@@ -194,6 +194,7 @@#define CONFIG_CMD_MTDPARTS /* Enable MTD parts commands */ #define CONFIG_CMD_NAND /* NAND support */ #define CONFIG_CMD_NAND_LOCK_UNLOCK /* nand (un)lock commands */ +#define CONFIG_CMD_SAVEBP /* Save kernel params command */ #undef CONFIG_CMD_FPGA/* FPGA configuration Support */ #undef CONFIG_CMD_IMI/* iminfo */
@@ -345,4 +346,7 @@ CONFIG_SYS_INIT_RAM_SIZE - \ GENERATED_GBL_DATA_SIZE) +/* Direct OS boot options */ +#define CONFIG_CMD_SAVEBP_NAND_OFS 0x700000 +#endif /* __CONFIG_H */
Signature · 1 line
1.7.4.1
RFC 1/2 arm: Added prep subcommand support to bootm
In reply to Simon SchwarzSorry, this was meant in-reply to this message: [PATCH] arm: Adds saving of Kernel boot args to NAND flash
2011/7/8 Simon Schwarz <[email protected]>:
Quoted 202 lines
Adds prep subcommand to bootm implementation of ARM. When bootm is called prep the function stops right after ATAGS creation and before
announce_and_cleanup.This is used in savebp command
Signed-off-by Simon Schwarz <[email protected]>---
Ok second RFC!I know that there are many style problems - but I don't have the time before weekend/at the weekend to fix them.
So please no close inspection just a comment on the way how the patch is done.
I will address the styleproblems on Monday!
Thanks, and have a nive weekend!
Simon---
?arch/arm/lib/bootm.c | ?107 +++++++++++++++++++++++++++----------------------- ?1 files changed, 58 insertions(+), 49 deletions(-)arch/arm/lib/bootm.c +4
-1@@ -1,4 +1,7 @@ -/* +/* Copyright (C) 2011 +* Corscience GmbH & Co. KG - Simon Schwarz <[email protected]> +* ?- Added prep subcommand support +* ?* (C) Copyright 2002
?* Sysgo Real-Time Solutions, GmbH <www.elinos.com> ?* Marius Groeger <[email protected]>arch/arm/lib/bootm.c +1
-1@@ -55,7 +58,7 @@ static struct tag *params; ?static ulong get_sp(void); ?#if defined(CONFIG_OF_LIBFDT) -static int bootm_linux_fdt (int machid,bootm_headers_t *images); +static int bootm_linux_fdt (int machid,bootm_headers_t *images,int flag);?#endif
?void
arch_lmb_reserve(struct lmb *lmb)arch/arm/lib/bootm.c +0
-0@@ -104,57 +107,61 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) ? ? ? ?char *commandline = getenv ("bootargs");?#endif
- ? ? ? if ((flag != 0) && (flag !=
BOOTM_STATE_OS_GO))
- ? ? ? ? ? ? ? return 1;
-
- ? ? ? s = getenv ("machid");
- ? ? ? if (s) {
- ? ? ? ? ? ? ? machid =simple_strtoul(s, NULL, 16);
- ? ? ? ? ? ? ? printf ("Using machid 0x%x from environment\n", machid);
- ? ? ? }
+ ? ? ? if ((flag != 0) && (flag !=BOOTM_STATE_OS_GO||
+ ? ? ? ?flag !=BOOTM_STATE_OS_PREP))
+ ? ? ? ? ? ? ? return 1; /* subcommand not implemented */
+ ? ? ? else
+ ? ? ?if((flag == 0) || flag == BOOTM_STATE_OS_PREP){
+ ? ? ? ? ? ? ? s = getenv ("machid");
+ ? ? ? ? ? ? ? if (s) {
+ ? ? ? ? ? ? ? ? ? ? ? machid =simple_strtoul(s, NULL, 16);
+ ? ? ? ? ? ? ? ? ? ? ? printf ("Using machid 0x%x from environment\n", machid);
+ ? ? ? ? ? ? ? }- ? ? ?
show_boot_progress(15);
+ ? ? ? ? ? ? ?show_boot_progress(15);?#ifdef
CONFIG_OF_LIBFDT
- ? ? ? if (images->ft_len)
- ? ? ? ? ? ? ? returnbootm_linux_fdt(machid, images);
+ ? ? ? ? ? ? ? if (images->ft_len)
+ ? ? ? ? ? ? ? ? ? ? ? returnbootm_linux_fdt(machid, images, flag); ?#endif- ? ? ?
kernel_entry= (void (*)(int, int, uint))images->ep;
+ ? ? ? ? ? ? ?kernel_entry= (void (*)(int, int, uint))images->ep;- ? ? ? debug ("## Transferring control to Linux (at address %08lx) ...\n",
- ? ? ? ? ? ? ?(ulong)kernel_entry);
+ ? ? ? ? ? ? ? debug ("## Transferring control to Linux (at address %08lx) ...\n",
+ ? ? ? ? ? ? ? ? ? ? ? (ulong)kernel_entry);?#if defined (
CONFIG_SETUP_MEMORY_TAGS) || \? ? defined (CONFIG_CMDLINE_TAG) || \ ? ? defined (CONFIG_INITRD_TAG) || \ ? ? defined (CONFIG_SERIAL_TAG) || \? ? defined (
CONFIG_REVISION_TAG)
- ? ? ?setup_start_tag(bd);
+ ? ? ? ? ? ? ?setup_start_tag(bd);
?#ifdefCONFIG_SERIAL_TAG
- ? ? ?setup_serial_tag(¶ms);
+ ? ? ? ? ? ? ?setup_serial_tag(¶ms);
?#endif
?#ifdefCONFIG_REVISION_TAG
- ? ? ?setup_revision_tag(¶ms);
+ ? ? ? ? ? ? ?setup_revision_tag(¶ms);
?#endif
?#ifdefCONFIG_SETUP_MEMORY_TAGS
- ? ? ?setup_memory_tags(bd);
+ ? ? ? ? ? ? ?setup_memory_tags(bd);
?#endif
?#ifdefCONFIG_CMDLINE_TAG
- ? ? ?setup_commandline_tag(bd, commandline);
+ ? ? ? ? ? ? ?setup_commandline_tag(bd, commandline);
?#endif
?#ifdefCONFIG_INITRD_TAG
- ? ? ? if (images->rd_start&&images->rd_end)
- ? ? ? ? ? ? ?setup_initrd_tag(bd,images->rd_start,images->rd_end);
+ ? ? ? ? ? ? ? if (images->rd_start&&images->rd_end)
+ ? ? ? ? ? ? ? ? ? ? ?setup_initrd_tag(bd,images->rd_start,images->rd_end); ?#endif
- ? ? ?setup_end_tag(bd);
+ ? ? ? ? ? ? ?setup_end_tag(bd);
?#endif
+ ? ? ? }- ? ? ?
announce_and_cleanup();
-
- ? ? ?kernel_entry(0, machid, bd->bi_boot_params);
- ? ? ? /* does not return */
+ ? ? ?if(flag == 0 || flag == BOOTM_STATE_OS_GO){
+ ? ? ? ? ? ? ?announce_and_cleanup();+ ? ? ? ? ? ? ?
kernel_entry(0, machid, bd->bi_boot_params);
+ ? ? ? ? ? ? ? /* does not return */
+ ? ? ? }
? ? ? ?return 1;
?}arch/arm/lib/bootm.c +23
-21@@ -174,7 +181,7 @@ static int fixup_memory_node(void *blob) ? ? ? ?return fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS); ?} -static int bootm_linux_fdt (int machid,bootm_headers_t *images) +static int bootm_linux_fdt (int machid,bootm_headers_t *images,int flag) ?{ ? ? ? ?ulong rd_len; ? ? ? ?void (*kernel_entry)(int zero, int dt_machid, void *dtblob);@@ -185,34 +192,36 @@ static int bootm_linux_fdt(int machid, bootm_headers_t *images) ? ? ? ?struct lmb *lmb = &images->lmb; ? ? ? ?int ret; - ? ? ? kernel_entry = (void (*)(int, int, void *))images->ep; - - ? ? ? boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree); - - ? ? ? rd_len = images->rd_end - images->rd_start; - ? ? ? ret = boot_ramdisk_high(lmb, images->rd_start, rd_len, - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? initrd_start, initrd_end); - ? ? ? if (ret) - ? ? ? ? ? ? ? return ret; + ? ? ? if((flag == 0) || flag == BOOTM_STATE_OS_PREP) { + ? ? ? ? ? ? ? kernel_entry = (void (*)(int, int, void *))images->ep; - ? ? ? ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); - ? ? ? if (ret) - ? ? ? ? ? ? ? return ret; + ? ? ? ? ? ? ? boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree); - ? ? ? debug("## Transferring control to Linux (at address %08lx) ...\n", - ? ? ? ? ? ? ?(ulong) kernel_entry); + ? ? ? ? ? ? ? rd_len = images->rd_end - images->rd_start; + ? ? ? ? ? ? ? ret = boot_ramdisk_high(lmb, images->rd_start, rd_len, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? initrd_start, initrd_end); + ? ? ? ? ? ? ? if (ret) + ? ? ? ? ? ? ? ? ? ? ? return ret; - ? ? ? fdt_chosen(*of_flat_tree, 1); + ? ? ? ? ? ? ? ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); + ? ? ? ? ? ? ? if (ret) + ? ? ? ? ? ? ? ? ? ? ? return ret; - ? ? ? fixup_memory_node(*of_flat_tree); + ? ? ? ? ? ? ? debug("## Transferring control to Linux (at address %08lx) ...\n", + ? ? ? ? ? ? ? ? ? ? ? (ulong) kernel_entry); - ? ? ? fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 1); + ? ? ? ? ? ? ? fdt_chosen(*of_flat_tree, 1); - ? ? ? announce_and_cleanup(); + ? ? ? ? ? ? ? fixup_memory_node(*of_flat_tree); - ? ? ? kernel_entry(0, machid, *of_flat_tree); - ? ? ? /* does not return */ + ? ? ? ? ? ? ? fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 1); + ? ? ? } + ? ? ? if(flag == 0 || flag == BOOTM_STATE_OS_GO) { + ? ? ? ? ? ? ? announce_and_cleanup(); + ? ? ? ? ? ? ? kernel_entry(0, machid, *of_flat_tree); + ? ? ? ? ? ? ? /* does not return */ + ? ? ? } ? ? ? ?return 1; ?}?#endif
--
1.7.4.1
RFC 1/2 arm: Added prep subcommand support to bootm
In reply to Simon SchwarzAdds prep subcommand to bootm implementation of ARM. When bootm is called prep the function stops right after ATAGS creation and before announce_and_cleanup.
This is used in savebp command
---
Ok second RFC!
I know that there are many style problems - but I don't have the time before weekend/at the weekend to fix them.
So please no close inspection just a comment on the way how the patch is done.
I will address the styleproblems on Monday!
Thanks, and have a nive weekend!
Simon
--- arch/arm/lib/bootm.c | 107 +++++++++++++++++++++++++++----------------------- 1 files changed, 58 insertions(+), 49 deletions(-)
arch/arm/lib/bootm.c +58 -49
@@ -1,4 +1,7 @@ -/* +/* Copyright (C) 2011 +* Corscience GmbH & Co. KG - Simon Schwarz <[email protected]> +* - Added prep subcommand support +* * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <[email protected]>
@@ -55,7 +58,7 @@ static struct tag *params;static ulong get_sp (void );#if defined(CONFIG_OF_LIBFDT ) -static int bootm_linux_fdt (int machid,bootm_headers_t *images); +static int bootm_linux_fdt (int machid,bootm_headers_t *images,int flag);#endif void arch_lmb_reserve (struct lmb *lmb)
@@ -104,57 +107,61 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)char *commandline =getenv ("bootargs" );#endif -if ((flag !=0 ) && (flag !=BOOTM_STATE_OS_GO )) -return 1 ; - - s =getenv ("machid" ); -if (s) { - machid =simple_strtoul (s,NULL ,16 ); -printf ("Using machid 0x%x from environment\n" , machid); - } +if ((flag !=0 ) && (flag !=BOOTM_STATE_OS_GO || + flag !=BOOTM_STATE_OS_PREP )) +return 1 ;/* subcommand not implemented */ +else +if ((flag ==0 ) || flag ==BOOTM_STATE_OS_PREP ) { + s =getenv ("machid" ); +if (s) { + machid =simple_strtoul (s,NULL ,16 ); +printf ("Using machid 0x%x from environment\n" , machid); + } -show_boot_progress (15 ); +show_boot_progress (15 );#ifdef CONFIG_OF_LIBFDT -if (images->ft_len) -return bootm_linux_fdt (machid, images); +if (images->ft_len) +return bootm_linux_fdt (machid, images, flag);#endif - kernel_entry = (void (*)(int ,int ,uint ))images->ep; + kernel_entry = (void (*)(int ,int ,uint ))images->ep; -debug ("## Transferring control to Linux (at address %08lx) ...\n" , - (ulong ) kernel_entry); +debug ("## Transferring control to Linux (at address %08lx) ...\n" , + (ulong ) kernel_entry);#if defined (CONFIG_SETUP_MEMORY_TAGS ) || \ defined (CONFIG_CMDLINE_TAG ) || \ defined (CONFIG_INITRD_TAG ) || \ defined (CONFIG_SERIAL_TAG ) || \ defined (CONFIG_REVISION_TAG ) -setup_start_tag (bd); +setup_start_tag (bd);#ifdef CONFIG_SERIAL_TAG -setup_serial_tag (¶ms); +setup_serial_tag (¶ms);#endif #ifdef CONFIG_REVISION_TAG -setup_revision_tag (¶ms); +setup_revision_tag (¶ms);#endif #ifdef CONFIG_SETUP_MEMORY_TAGS -setup_memory_tags (bd); +setup_memory_tags (bd);#endif #ifdef CONFIG_CMDLINE_TAG -setup_commandline_tag (bd, commandline); +setup_commandline_tag (bd, commandline);#endif #ifdef CONFIG_INITRD_TAG -if (images->rd_start && images->rd_end) -setup_initrd_tag (bd, images->rd_start, images->rd_end); +if (images->rd_start && images->rd_end) +setup_initrd_tag (bd, images->rd_start, images->rd_end);#endif -setup_end_tag (bd); +setup_end_tag (bd);#endif + } -announce_and_cleanup (); - -kernel_entry (0 , machid, bd->bi_boot_params); -/* does not return */ +if (flag ==0 || flag ==BOOTM_STATE_OS_GO ) { +announce_and_cleanup (); +kernel_entry (0 , machid, bd->bi_boot_params); +/* does not return */ + }return 1 ; }
@@ -174,7 +181,7 @@ static int fixup_memory_node(void *blob)return fdt_fixup_memory_banks (blob, start, size,CONFIG_NR_DRAM_BANKS ); } -static int bootm_linux_fdt (int machid,bootm_headers_t *images) +static int bootm_linux_fdt (int machid,bootm_headers_t *images,int flag) {ulong rd_len;void (*kernel_entry)(int zero,int dt_machid,void *dtblob);
@@ -185,34 +192,36 @@ static int bootm_linux_fdt(int machid, bootm_headers_t *images)struct lmb *lmb = &images->lmb;int ret; - kernel_entry = (void (*)(int ,int ,void *))images->ep; - -boot_fdt_add_mem_rsv_regions (lmb, *of_flat_tree); - - rd_len = images->rd_end - images->rd_start; - ret =boot_ramdisk_high (lmb, images->rd_start, rd_len, - initrd_start, initrd_end); -if (ret) -return ret; +if ((flag ==0 ) || flag ==BOOTM_STATE_OS_PREP ) { + kernel_entry = (void (*)(int ,int ,void *))images->ep; - ret =boot_relocate_fdt (lmb, of_flat_tree, &of_size); -if (ret) -return ret; +boot_fdt_add_mem_rsv_regions (lmb, *of_flat_tree); -debug ("## Transferring control to Linux (at address %08lx) ...\n" , - (ulong ) kernel_entry); + rd_len = images->rd_end - images->rd_start; + ret =boot_ramdisk_high (lmb, images->rd_start, rd_len, + initrd_start, initrd_end); +if (ret) +return ret; -fdt_chosen (*of_flat_tree,1 ); + ret =boot_relocate_fdt (lmb, of_flat_tree, &of_size); +if (ret) +return ret; -fixup_memory_node (*of_flat_tree); +debug ("## Transferring control to Linux (at address %08lx) ...\n" , + (ulong ) kernel_entry); -fdt_initrd (*of_flat_tree, *initrd_start, *initrd_end,1 ); +fdt_chosen (*of_flat_tree,1 ); -announce_and_cleanup (); +fixup_memory_node (*of_flat_tree); -kernel_entry (0 , machid, *of_flat_tree); -/* does not return */ +fdt_initrd (*of_flat_tree, *initrd_start, *initrd_end,1 ); + } +if (flag ==0 || flag ==BOOTM_STATE_OS_GO ) { +announce_and_cleanup (); +kernel_entry (0 , machid, *of_flat_tree); +/* does not return */ + } return 1; }#endif
Signature · 1 line
1.7.4.1
RFC 1/2 arm: Added prep subcommand support to bootm
Dear Simon Schwarz,
Quoted 8 lines · In message <[email protected]> you…
Adds prep subcommand to bootm implementation of ARM. When bootm is called prep the function stops right after ATAGS creation and before
announce_and_cleanup.This is used in savebp command
Signed-off-by Simon Schwarz <[email protected]>---
Ok second RFC!
Grrrrrghhh!!!
Can you PLEASE follow the rules for posting new patch versions?
You are supposed to mark them in the Subject:, and you are supposed to provide a desciption what you changed.
See http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions
Message ignored.
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It's certainly convenient the way the crime (or condition) of
stupidity carries with it its own punishment, automatically
admisistered without remorse, pity, or prejudice. :-)
-- Tom Christiansen in <[email protected]>PATCH 1/1 arm: Adds saving of Kernel boot args to NAND flash
In reply to Simon SchwarzQuoted 7 lines · On Fri, 8 Jul 2011 09:53:46 +0200 Simon Schwarz…
Quoted 2 lines
Look at bootm subcommands to run just the portion of the existing bootm functionality that you need. ?Type "help bootm" for details.
Of course I could implement a subcommand - actually this seems to be the best method.
IMHO "prep" would be the right one to use? correct?
Probably.
-Scott