Message ID | 1314261196-23197-4-git-send-email-simonschwarzcor@gmail.com |
---|---|
State | Superseded |
Headers | show |
Dear Simon, Am 25.08.2011 10:33, schrieb Simon Schwarz: > This adds the savebp implementation to the arm platform. please reorder your series and let this come before 'Add savebp command' cause that patch uses functionality from this one. > Related CONFIGs: > CONFIG_CMD_SAVEBP_WRITE_SIZE defines the size of the image to write > > Signed-off-by: Simon Schwarz <simonschwarzcor@gmail.com> > --- > > V2 changes: > DEL _cosmetic_ old comment > > V3 changes: > nothing > --- > arch/arm/include/asm/savebp.h | 27 ++++++++++++ > arch/arm/lib/Makefile | 1 + > arch/arm/lib/savebp.c | 91 +++++++++++++++++++++++++++++++++++++++++ > include/command.h | 5 ++ > include/configs/devkit8000.h | 1 + documentation of CONFIG_CMD_SAVEBP_WRITE_SIZE is missing > diff --git a/arch/arm/include/asm/savebp.h b/arch/arm/include/asm/savebp.h > new file mode 100644 > index 0000000..3774e45 > --- /dev/null > +++ b/arch/arm/include/asm/savebp.h > @@ -0,0 +1,27 @@ > +/* Copyright (C) 2011 > + * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de> > + * > + * See file CREDITS for list of people who contributed to this > + * project. > + * > + * 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 (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, write to the Free Software > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, > + * MA 02111-1307 USA > + */ > +#ifndef _SAVEBP_H_ > +#define _SAVEBP_H_ > + > +extern bootm_headers_t images; You made that available globally in your first patch of this series, please remove that from first patch and move to this one. <snip> BTW while reading this patch I got another idea to solve problem 'how get we saved the boot information to <storage>'. The required information regardless of whether it is ATAGS or FDT is only a blob at some place in ram after the 'bootm x' commands used in 'Add savebp command'. Saving a blob from location X with size Y to location Z is easy and already implemented. So the only required thing is to get the 'blob' prepared in RAM. In my opinion this could be a subcommand of bootm instead of a new command. How about: ---8<--- # bootm savebp ...done boot information is @0x80000100 with size 0x100 # nandecc hw # nand erase ... # nand write 80000100 ... --->8--- regards Andreas Bießmann
Dear Andreas, On 08/25/2011 01:08 PM, Andreas Bießmann wrote: > Dear Simon, > > Am 25.08.2011 10:33, schrieb Simon Schwarz: >> This adds the savebp implementation to the arm platform. > > please reorder your series and let this come before 'Add savebp command' > cause that patch uses functionality from this one. > Will do. >> Related CONFIGs: >> CONFIG_CMD_SAVEBP_WRITE_SIZE defines the size of the image to write >> >> Signed-off-by: Simon Schwarz<simonschwarzcor@gmail.com> >> --- >> >> V2 changes: >> DEL _cosmetic_ old comment >> >> V3 changes: >> nothing >> --- >> arch/arm/include/asm/savebp.h | 27 ++++++++++++ >> arch/arm/lib/Makefile | 1 + >> arch/arm/lib/savebp.c | 91 +++++++++++++++++++++++++++++++++++++++++ >> include/command.h | 5 ++ >> include/configs/devkit8000.h | 1 + > > documentation of CONFIG_CMD_SAVEBP_WRITE_SIZE is missing > Will add. >> diff --git a/arch/arm/include/asm/savebp.h b/arch/arm/include/asm/savebp.h >> new file mode 100644 >> index 0000000..3774e45 >> --- /dev/null >> +++ b/arch/arm/include/asm/savebp.h >> @@ -0,0 +1,27 @@ >> +/* Copyright (C) 2011 >> + * Corscience GmbH& Co. KG - Simon Schwarz<schwarz@corscience.de> >> + * >> + * See file CREDITS for list of people who contributed to this >> + * project. >> + * >> + * 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 (at your option) any later version. >> + * >> + * This program is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + * GNU General Public License for more details. >> + * >> + * You should have received a copy of the GNU General Public License >> + * along with this program; if not, write to the Free Software >> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, >> + * MA 02111-1307 USA >> + */ >> +#ifndef _SAVEBP_H_ >> +#define _SAVEBP_H_ >> + >> +extern bootm_headers_t images; > > You made that available globally in your first patch of this series, > please remove that from first patch and move to this one. ok. > > <snip> > > BTW while reading this patch I got another idea to solve problem 'how > get we saved the boot information to<storage>'. > The required information regardless of whether it is ATAGS or FDT is > only a blob at some place in ram after the 'bootm x' commands used in > 'Add savebp command'. Saving a blob from location X with size Y to > location Z is easy and already implemented. > > So the only required thing is to get the 'blob' prepared in RAM. In my > opinion this could be a subcommand of bootm instead of a new command. > > How about: > > ---8<--- > # bootm savebp > ...done boot information is @0x80000100 with size 0x100 > # nandecc hw > # nand erase ... > # nand write 80000100 ... > --->8--- This was actually my first implementation (although not with a switch): http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/102669 It was criticised because saving the parameter images is not the responsibility of bootm - which is true. Although adding a switch would be a cleaner solution than my first implementation - would that be acceptable? How about implementing it as bootm subcommand? > > regards > > Andreas Bießmann Regards & thx for reviewing Simon
Dear Simon, Am 26.08.2011 12:10, schrieb Simon Schwarz: > Dear Andreas, > <snip> >> BTW while reading this patch I got another idea to solve problem 'how >> get we saved the boot information to<storage>'. >> The required information regardless of whether it is ATAGS or FDT is >> only a blob at some place in ram after the 'bootm x' commands used in >> 'Add savebp command'. Saving a blob from location X with size Y to >> location Z is easy and already implemented. >> >> So the only required thing is to get the 'blob' prepared in RAM. In my >> opinion this could be a subcommand of bootm instead of a new command. >> >> How about: >> >> ---8<--- >> # bootm savebp >> ...done boot information is @0x80000100 with size 0x100 >> # nandecc hw >> # nand erase ... >> # nand write 80000100 ... >> --->8--- > > This was actually my first implementation (although not with a switch): > http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/102669 > > It was criticised because saving the parameter images is not the > responsibility of bootm - which is true. Although adding a switch would > be a cleaner solution than my first implementation - would that be > acceptable? > > How about implementing it as bootm subcommand? Another question, how often will one change the boot information for SPL booting? I guess most people will use the normal u-boot to test different configurations and start directly into the OS. When one has some satisfying configuration he will store this for SPL boot into flash regardless whether it is a separate command or a list of commands. The current solution (having savebp command utilize do_bootm()) couples these two commands in a way which may lead to problems in future (but I don't know what others think about ... Wolfgang?). I vote for a well documented guide or an example script to gather the boot information and store it for SPL booting (at least for this patch set). I know your bachelor thesis filing date is end of September and I would appreciate to have this functionality in before. The rest of this series seems quite good to me. Except for some minor changes to the arm-bootm prep command ... but read my answer to that patch. best regards Andreas Bießmann
diff --git a/arch/arm/include/asm/savebp.h b/arch/arm/include/asm/savebp.h new file mode 100644 index 0000000..3774e45 --- /dev/null +++ b/arch/arm/include/asm/savebp.h @@ -0,0 +1,27 @@ +/* Copyright (C) 2011 + * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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 (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#ifndef _SAVEBP_H_ +#define _SAVEBP_H_ + +extern bootm_headers_t images; + +#endif /* _SAVEBP_H_ */ diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 300c8fa..abf7a6a 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -44,6 +44,7 @@ COBJS-y += cache-cp15.o COBJS-$(CONFIG_SYS_L2_PL310) += cache-pl310.o 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 endif diff --git a/arch/arm/lib/savebp.c b/arch/arm/lib/savebp.c new file mode 100644 index 0000000..e0cfd83 --- /dev/null +++ b/arch/arm/lib/savebp.c @@ -0,0 +1,91 @@ +/* Copyright (C) 2011 + * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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 (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <command.h> +#include <image.h> + +#include <nand.h> +#include <asm/savebp.h> + +#ifdef CONFIG_OMAP34XX +#include <asm/arch/sys_proto.h> +#endif + +DECLARE_GLOBAL_DATA_PTR; + +/* This function writes given bootparams to NAND flash + * adr: Start adress of Kernel parameter image (ATAGS, FDT) + * length: length of the image in byte + * off: offset in NAND flash + * + * borrowd heavily from common/cmd_nand.c + */ +static void boot_params_to_nand(u_char *adr, size_t length, loff_t off) +{ + nand_info_t *nand = &nand_info[0]; /* use 0 as in SPL */ + 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"); + return; + } + + printf("Written to offset 0x%llX, size: %d bytes\n", + off, length); +} + +/* Saves FDT to NAND */ +int do_savebp_fdt(loff_t offset) +{ + boot_params_to_nand((u_char *)images.ft_addr, + CONFIG_CMD_SAVEBP_WRITE_SIZE, offset); + return 0; +} + + +/* Saves ATAGS to NAND */ +int do_savebp_atags(loff_t offset) +{ + /* Vars */ + bd_t *bd = gd->bd; + + printf("write ATAGS to NAND...\n"); + + /* save em */ + /* used fixed size - easier to read later just ignore garbage */ + boot_params_to_nand((u_char *)bd->bi_boot_params, + CONFIG_CMD_SAVEBP_WRITE_SIZE, offset); + + return 0; +} diff --git a/include/command.h b/include/command.h index 8310fe5..3ae68a8 100644 --- a/include/command.h +++ b/include/command.h @@ -101,6 +101,11 @@ extern int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); extern int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +#ifdef CONFIG_CMD_SAVEBP +int do_savebp_atags(loff_t offset); +int do_savebp_fdt(loff_t offset); +#endif + #endif /* __ASSEMBLY__ */ /* diff --git a/include/configs/devkit8000.h b/include/configs/devkit8000.h index 80b441a..4d0573c 100644 --- a/include/configs/devkit8000.h +++ b/include/configs/devkit8000.h @@ -355,6 +355,7 @@ /* SPL OS boot options */ #define CONFIG_CMD_SAVEBP +#define CONFIG_CMD_SAVEBP_WRITE_SIZE 0x400 /* 1024 byte */ #define CONFIG_CMD_SAVEBP_NAND_OFS (CONFIG_SYS_NAND_SPL_KERNEL_OFFS+\ 0x400000) #define CONFIG_SYS_NAND_SPL_KERNEL_OFFS 0x280000
This adds the savebp implementation to the arm platform. Related CONFIGs: CONFIG_CMD_SAVEBP_WRITE_SIZE defines the size of the image to write Signed-off-by: Simon Schwarz <simonschwarzcor@gmail.com> --- V2 changes: DEL _cosmetic_ old comment V3 changes: nothing --- arch/arm/include/asm/savebp.h | 27 ++++++++++++ arch/arm/lib/Makefile | 1 + arch/arm/lib/savebp.c | 91 +++++++++++++++++++++++++++++++++++++++++ include/command.h | 5 ++ include/configs/devkit8000.h | 1 + 5 files changed, 125 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/savebp.h create mode 100644 arch/arm/lib/savebp.c