* [PATCH 0/2] ARM: cfa10036: Store the barebox environment on the MMC @ 2013-02-13 16:45 Maxime Ripard 2013-02-13 16:45 ` [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment Maxime Ripard 2013-02-13 16:45 ` [PATCH 2/2] cfa10036: Update the environment Maxime Ripard 0 siblings, 2 replies; 28+ messages in thread From: Maxime Ripard @ 2013-02-13 16:45 UTC (permalink / raw) To: barebox; +Cc: Brian Lilly Hi, The cfa-10036 comes only with a SD slot, so there was previously no way to store in a persistent way the environment we could have modified other than by modifying the code source itself. These two patches register a new partition on the SD card to store that environment, and update the default environment to reflect these changes. Thanks, Maxime Maxime Ripard (2): cfa-10036: Use the second MMC partition to store the environment cfa10036: Update the environment arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 +++++++++++++++++++- .../boards/crystalfontz-cfa10036/env/boot/mmc-ext3 | 6 +-- .../crystalfontz-cfa10036/env/init/automount | 4 +- 3 files changed, 48 insertions(+), 6 deletions(-) -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment 2013-02-13 16:45 [PATCH 0/2] ARM: cfa10036: Store the barebox environment on the MMC Maxime Ripard @ 2013-02-13 16:45 ` Maxime Ripard 2013-02-13 17:10 ` Eric Bénard ` (2 more replies) 2013-02-13 16:45 ` [PATCH 2/2] cfa10036: Update the environment Maxime Ripard 1 sibling, 3 replies; 28+ messages in thread From: Maxime Ripard @ 2013-02-13 16:45 UTC (permalink / raw) To: barebox; +Cc: Brian Lilly Since the only storage medium on the cfa-10036 is the MMC card, we need to have a registered environment partition on it if we want to be able to modify at runtime. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> --- arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c index b59dbab..1821b10 100644 --- a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +++ b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c @@ -97,9 +97,46 @@ static int cfa10036_mem_init(void) } mem_initcall(cfa10036_mem_init); +/** + * Try to register an environment storage on the attached MCI card + * @return 0 on success + * + * We rely on the existence of a usable SD card, already attached to + * our system, to get something like a persistent memory for our environment. + * If this SD card is also the boot media, we can use the second partition + * for our environment purpose (if present!). + */ +static int register_persistant_environment(void) +{ + struct cdev *cdev; + + /* + * The CFA-10036 only has one MCI card socket. + * So, we expect its name as "disk0". + */ + cdev = cdev_by_name("disk0"); + if (cdev == NULL) { + pr_err("No SD card found\n"); + return -ENODEV; + } + + /* MCI card is present, also a useable partition on it? */ + cdev = cdev_by_name("disk0.1"); + if (cdev == NULL) { + pr_err("No second partition available\n"); + pr_info("Please create at least a second partition with" + " 256 kiB...512 kiB in size (your choice)\n"); + return -ENODEV; + } + + /* use the full partition as our persistent environment storage */ + return devfs_add_partition("disk0.1", 0, cdev->size, + DEVFS_PARTITION_FIXED, "env0"); +} + static int cfa10036_devices_init(void) { - int i; + int i, ret; /* initizalize muxing */ for (i = 0; i < ARRAY_SIZE(cfa10036_pads); i++) @@ -124,6 +161,11 @@ static int cfa10036_devices_init(void) cfa10036_detect_hw(); + ret = register_persistant_environment(); + if (ret != 0) + printf("Cannot create the 'env0' persistant " + "environment storage (%d)\n", ret); + return 0; } device_initcall(cfa10036_devices_init); -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment 2013-02-13 16:45 ` [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment Maxime Ripard @ 2013-02-13 17:10 ` Eric Bénard 2013-02-13 17:12 ` Jean-Christophe PLAGNIOL-VILLARD 2013-02-14 8:16 ` Juergen Beisert 2 siblings, 0 replies; 28+ messages in thread From: Eric Bénard @ 2013-02-13 17:10 UTC (permalink / raw) To: Maxime Ripard; +Cc: barebox, Brian Lilly Hi Maxime, Le Wed, 13 Feb 2013 17:45:17 +0100, Maxime Ripard <maxime.ripard@free-electrons.com> a écrit : > Since the only storage medium on the cfa-10036 is the MMC card, we need > to have a registered environment partition on it if we want to be able > to modify at runtime. > maybe you could add : code copied from imx23-olinuxino.c Eric > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> > --- > arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 +++++++++++++++++++++- > 1 file changed, 43 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > index b59dbab..1821b10 100644 > --- a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > +++ b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > @@ -97,9 +97,46 @@ static int cfa10036_mem_init(void) > } > mem_initcall(cfa10036_mem_init); > > +/** > + * Try to register an environment storage on the attached MCI card > + * @return 0 on success > + * > + * We rely on the existence of a usable SD card, already attached to > + * our system, to get something like a persistent memory for our environment. > + * If this SD card is also the boot media, we can use the second partition > + * for our environment purpose (if present!). > + */ > +static int register_persistant_environment(void) > +{ > + struct cdev *cdev; > + > + /* > + * The CFA-10036 only has one MCI card socket. > + * So, we expect its name as "disk0". > + */ > + cdev = cdev_by_name("disk0"); > + if (cdev == NULL) { > + pr_err("No SD card found\n"); > + return -ENODEV; > + } > + > + /* MCI card is present, also a useable partition on it? */ > + cdev = cdev_by_name("disk0.1"); > + if (cdev == NULL) { > + pr_err("No second partition available\n"); > + pr_info("Please create at least a second partition with" > + " 256 kiB...512 kiB in size (your choice)\n"); > + return -ENODEV; > + } > + > + /* use the full partition as our persistent environment storage */ > + return devfs_add_partition("disk0.1", 0, cdev->size, > + DEVFS_PARTITION_FIXED, "env0"); > +} > + > static int cfa10036_devices_init(void) > { > - int i; > + int i, ret; > > /* initizalize muxing */ > for (i = 0; i < ARRAY_SIZE(cfa10036_pads); i++) > @@ -124,6 +161,11 @@ static int cfa10036_devices_init(void) > > cfa10036_detect_hw(); > > + ret = register_persistant_environment(); > + if (ret != 0) > + printf("Cannot create the 'env0' persistant " > + "environment storage (%d)\n", ret); > + > return 0; > } > device_initcall(cfa10036_devices_init); _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment 2013-02-13 16:45 ` [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment Maxime Ripard 2013-02-13 17:10 ` Eric Bénard @ 2013-02-13 17:12 ` Jean-Christophe PLAGNIOL-VILLARD 2013-02-14 9:52 ` Maxime Ripard 2013-02-14 8:16 ` Juergen Beisert 2 siblings, 1 reply; 28+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-13 17:12 UTC (permalink / raw) To: Maxime Ripard; +Cc: barebox, Brian Lilly On 17:45 Wed 13 Feb , Maxime Ripard wrote: > Since the only storage medium on the cfa-10036 is the MMC card, we need > to have a registered environment partition on it if we want to be able > to modify at runtime. > > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> > --- > arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 +++++++++++++++++++++- > 1 file changed, 43 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > index b59dbab..1821b10 100644 > --- a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > +++ b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > @@ -97,9 +97,46 @@ static int cfa10036_mem_init(void) > } > mem_initcall(cfa10036_mem_init); > > +/** > + * Try to register an environment storage on the attached MCI card > + * @return 0 on success > + * > + * We rely on the existence of a usable SD card, already attached to > + * our system, to get something like a persistent memory for our environment. > + * If this SD card is also the boot media, we can use the second partition > + * for our environment purpose (if present!). > + */ > +static int register_persistant_environment(void) > +{ > + struct cdev *cdev; > + > + /* > + * The CFA-10036 only has one MCI card socket. > + * So, we expect its name as "disk0". > + */ > + cdev = cdev_by_name("disk0"); > + if (cdev == NULL) { > + pr_err("No SD card found\n"); > + return -ENODEV; > + } > + > + /* MCI card is present, also a useable partition on it? */ > + cdev = cdev_by_name("disk0.1"); > + if (cdev == NULL) { > + pr_err("No second partition available\n"); > + pr_info("Please create at least a second partition with" > + " 256 kiB...512 kiB in size (your choice)\n"); > + return -ENODEV; > + } > + > + /* use the full partition as our persistent environment storage */ > + return devfs_add_partition("disk0.1", 0, cdev->size, > + DEVFS_PARTITION_FIXED, "env0"); > +} it's time to have a common code Best Regards, J. > + > static int cfa10036_devices_init(void) > { > - int i; > + int i, ret; > > /* initizalize muxing */ > for (i = 0; i < ARRAY_SIZE(cfa10036_pads); i++) > @@ -124,6 +161,11 @@ static int cfa10036_devices_init(void) > > cfa10036_detect_hw(); > > + ret = register_persistant_environment(); > + if (ret != 0) > + printf("Cannot create the 'env0' persistant " > + "environment storage (%d)\n", ret); > + > return 0; > } > device_initcall(cfa10036_devices_init); > -- > 1.7.10.4 > > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment 2013-02-13 17:12 ` Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-14 9:52 ` Maxime Ripard 0 siblings, 0 replies; 28+ messages in thread From: Maxime Ripard @ 2013-02-14 9:52 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox, Brian Lilly Hi Jean-Christophe, Le 13/02/2013 18:12, Jean-Christophe PLAGNIOL-VILLARD a écrit : > On 17:45 Wed 13 Feb , Maxime Ripard wrote: >> Since the only storage medium on the cfa-10036 is the MMC card, we need >> to have a registered environment partition on it if we want to be able >> to modify at runtime. >> >> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> >> --- >> arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 +++++++++++++++++++++- >> 1 file changed, 43 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c >> index b59dbab..1821b10 100644 >> --- a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c >> +++ b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c >> @@ -97,9 +97,46 @@ static int cfa10036_mem_init(void) >> } >> mem_initcall(cfa10036_mem_init); >> >> +/** >> + * Try to register an environment storage on the attached MCI card >> + * @return 0 on success >> + * >> + * We rely on the existence of a usable SD card, already attached to >> + * our system, to get something like a persistent memory for our environment. >> + * If this SD card is also the boot media, we can use the second partition >> + * for our environment purpose (if present!). >> + */ >> +static int register_persistant_environment(void) >> +{ >> + struct cdev *cdev; >> + >> + /* >> + * The CFA-10036 only has one MCI card socket. >> + * So, we expect its name as "disk0". >> + */ >> + cdev = cdev_by_name("disk0"); >> + if (cdev == NULL) { >> + pr_err("No SD card found\n"); >> + return -ENODEV; >> + } >> + >> + /* MCI card is present, also a useable partition on it? */ >> + cdev = cdev_by_name("disk0.1"); >> + if (cdev == NULL) { >> + pr_err("No second partition available\n"); >> + pr_info("Please create at least a second partition with" >> + " 256 kiB...512 kiB in size (your choice)\n"); >> + return -ENODEV; >> + } >> + >> + /* use the full partition as our persistent environment storage */ >> + return devfs_add_partition("disk0.1", 0, cdev->size, >> + DEVFS_PARTITION_FIXED, "env0"); >> +} > it's time to have a common code I'm ok with doing it, where should it be stored? Maxime -- Maxime Ripard, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment 2013-02-13 16:45 ` [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment Maxime Ripard 2013-02-13 17:10 ` Eric Bénard 2013-02-13 17:12 ` Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-14 8:16 ` Juergen Beisert 2013-02-14 10:10 ` Maxime Ripard 2 siblings, 1 reply; 28+ messages in thread From: Juergen Beisert @ 2013-02-14 8:16 UTC (permalink / raw) To: barebox; +Cc: Maxime Ripard, Brian Lilly Maxime Ripard wrote: > Since the only storage medium on the cfa-10036 is the MMC card, we need > to have a registered environment partition on it if we want to be able > to modify at runtime. > > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> > --- > arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 > +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > index b59dbab..1821b10 100644 > --- a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > +++ b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > @@ -97,9 +97,46 @@ static int cfa10036_mem_init(void) > } > mem_initcall(cfa10036_mem_init); > > +/** > + * Try to register an environment storage on the attached MCI card > + * @return 0 on success > + * > + * We rely on the existence of a usable SD card, already attached to > + * our system, to get something like a persistent memory for our environment. > + * If this SD card is also the boot media, we can use the second partition > + * for our environment purpose (if present!). > + */ > +static int register_persistant_environment(void) register_persist*e*nt_environment Seems a copy from my typo in the falconwing. I really should fix it :)) > [...] jbe -- Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment 2013-02-14 8:16 ` Juergen Beisert @ 2013-02-14 10:10 ` Maxime Ripard 2013-02-14 11:17 ` Eric Bénard 0 siblings, 1 reply; 28+ messages in thread From: Maxime Ripard @ 2013-02-14 10:10 UTC (permalink / raw) To: Juergen Beisert; +Cc: barebox, Brian Lilly Hi Juergen, Le 14/02/2013 09:16, Juergen Beisert a écrit : > Maxime Ripard wrote: >> Since the only storage medium on the cfa-10036 is the MMC card, we need >> to have a registered environment partition on it if we want to be able >> to modify at runtime. >> >> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> >> --- >> arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 >> +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c >> index b59dbab..1821b10 100644 >> --- a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c >> +++ b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c >> @@ -97,9 +97,46 @@ static int cfa10036_mem_init(void) >> } >> mem_initcall(cfa10036_mem_init); >> >> +/** >> + * Try to register an environment storage on the attached MCI card >> + * @return 0 on success >> + * >> + * We rely on the existence of a usable SD card, already attached to >> + * our system, to get something like a persistent memory for our environment. >> + * If this SD card is also the boot media, we can use the second partition >> + * for our environment purpose (if present!). >> + */ >> +static int register_persistant_environment(void) > > register_persist*e*nt_environment > > Seems a copy from my typo in the falconwing. I really should fix it :)) Oops :) I will fix it, it will probably end up in a common function anyway. Thanks, Maxime -- Maxime Ripard, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment 2013-02-14 10:10 ` Maxime Ripard @ 2013-02-14 11:17 ` Eric Bénard 2013-02-14 11:56 ` [PATCH 1/3] env: add register_persistent_environment Eric Bénard 0 siblings, 1 reply; 28+ messages in thread From: Eric Bénard @ 2013-02-14 11:17 UTC (permalink / raw) To: Maxime Ripard; +Cc: barebox, Juergen Beisert, Brian Lilly Le Thu, 14 Feb 2013 11:10:54 +0100, Maxime Ripard <maxime.ripard@free-electrons.com> a écrit : > Hi Juergen, > > Le 14/02/2013 09:16, Juergen Beisert a écrit : > > Maxime Ripard wrote: > >> Since the only storage medium on the cfa-10036 is the MMC card, we need > >> to have a registered environment partition on it if we want to be able > >> to modify at runtime. > >> > >> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> > >> --- > >> arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 > >> +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > >> index b59dbab..1821b10 100644 > >> --- a/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > >> +++ b/arch/arm/boards/crystalfontz-cfa10036/cfa10036.c > >> @@ -97,9 +97,46 @@ static int cfa10036_mem_init(void) > >> } > >> mem_initcall(cfa10036_mem_init); > >> > >> +/** > >> + * Try to register an environment storage on the attached MCI card > >> + * @return 0 on success > >> + * > >> + * We rely on the existence of a usable SD card, already attached to > >> + * our system, to get something like a persistent memory for our environment. > >> + * If this SD card is also the boot media, we can use the second partition > >> + * for our environment purpose (if present!). > >> + */ > >> +static int register_persistant_environment(void) > > > > register_persist*e*nt_environment > > > > Seems a copy from my typo in the falconwing. I really should fix it :)) > > Oops :) > I will fix it, it will probably end up in a common function anyway. > FWIW : I have cooked a patch for this common function, I will be able to send it tonight. Eric _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 1/3] env: add register_persistent_environment 2013-02-14 11:17 ` Eric Bénard @ 2013-02-14 11:56 ` Eric Bénard 2013-02-14 11:56 ` [PATCH 2/3] imx23-olinuxino: swith to generic peristent env Eric Bénard ` (2 more replies) 0 siblings, 3 replies; 28+ messages in thread From: Eric Bénard @ 2013-02-14 11:56 UTC (permalink / raw) To: barebox; +Cc: Juergen Beisert - heavily copied from register_persistant_environment which was Signed-off-by: Juergen Beisert <jbe@pengutronix.de> Signed-off-by: Eric Bénard <eric@eukrea.com> --- common/environment.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/environment.h | 1 + 2 files changed, 41 insertions(+) diff --git a/common/environment.c b/common/environment.c index e8d623f..55befd9 100644 --- a/common/environment.c +++ b/common/environment.c @@ -363,3 +363,43 @@ out: free(buf_free); return ret; } + +#ifdef __BAREBOX__ +/** + * Try to register an environment storage on a device's partition + * @return 0 on success + * + * We rely on the existence of a usable storage device, already attached to + * our system, to get something like a persistent memory for our environment. + * We need to specify the partition number to use on this device. + * @param[in] devname Name of the device + * @param[in] partnr Partition number + * @return 0 on success, anything else in case of failure + */ + +int register_persistent_environment(const char *devname, unsigned int partnr) +{ + struct cdev *cdev; + char *partname; + + if (!devname) + return -EINVAL; + + cdev = cdev_by_name(devname); + if (cdev == NULL) { + pr_err("No %s present\n", devname); + return -ENODEV; + } + partname = asprintf("%s.%d", devname, partnr); + cdev = cdev_by_name(partname); + if (cdev == NULL) { + pr_err("No %s partition available\n", partname); + pr_info("Please create the partition %s to store the env\n", partname); + return -ENODEV; + } + + return devfs_add_partition(partname, 0, cdev->size, + DEVFS_PARTITION_FIXED, "env0"); +} +EXPORT_SYMBOL(register_persistent_environment); +#endif diff --git a/include/environment.h b/include/environment.h index 7bdd213..d172f8f 100644 --- a/include/environment.h +++ b/include/environment.h @@ -71,6 +71,7 @@ int env_pop_context(void); int env_push_context(void); int export(const char *); +int register_persistent_environment(const char *devname, unsigned int partnr); #endif /* _ENVIRONMENT_H_ */ -- 1.7.11.7 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 2/3] imx23-olinuxino: swith to generic peristent env 2013-02-14 11:56 ` [PATCH 1/3] env: add register_persistent_environment Eric Bénard @ 2013-02-14 11:56 ` Eric Bénard 2013-02-14 11:56 ` [PATCH 3/3] falconwing: switch " Eric Bénard 2013-02-14 19:31 ` [PATCH 1/3] env: add register_persistent_environment Sascha Hauer 2 siblings, 0 replies; 28+ messages in thread From: Eric Bénard @ 2013-02-14 11:56 UTC (permalink / raw) To: barebox Signed-off-by: Eric Bénard <eric@eukrea.com> --- arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c | 44 +--------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c b/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c index 0482638..068436f 100644 --- a/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c +++ b/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c @@ -111,46 +111,6 @@ static void olinuxino_init_usb(void) add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_USB_BASE, NULL); } -/** - * Try to register an environment storage on the attached MCI card - * @return 0 on success - * - * We rely on the existence of a usable SD card, already attached to - * our system, to get something like a persistent memory for our environment. - * If this SD card is also the boot media, we can use the second partition - * for our environment purpose (if present!). - */ -static int register_persistant_environment(void) -{ - struct cdev *cdev; - - /* - * The imx23-olinuxino only has one MCI card socket. - * So, we expect its name as "disk0". - */ - cdev = cdev_by_name("disk0"); - if (cdev == NULL) { - pr_err("No MCI card preset\n"); - return -ENODEV; - } - - - - /* MCI card is present, also a useable partition on it? */ - cdev = cdev_by_name("disk0.1"); - if (cdev == NULL) { - pr_err("No second partition available\n"); - pr_info("Please create at least a second partition with" - " 256 kiB...512 kiB in size (your choice)\n"); - return -ENODEV; - } - - /* use the full partition as our persistent environment storage */ - return devfs_add_partition("disk0.1", 0, cdev->size, - DEVFS_PARTITION_FIXED, "env0"); -} - - static int imx23_olinuxino_devices_init(void) { int i, rc; @@ -174,9 +134,9 @@ static int imx23_olinuxino_devices_init(void) olinuxino_init_usb(); - rc = register_persistant_environment(); + rc = register_persistent_environment("disk0", 1); if (rc != 0) - printf("Cannot create the 'env0' persistant " + printf("Cannot create the 'env0' persistent " "environment storage (%d)\n", rc); return 0; -- 1.7.11.7 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 3/3] falconwing: switch to generic peristent env 2013-02-14 11:56 ` [PATCH 1/3] env: add register_persistent_environment Eric Bénard 2013-02-14 11:56 ` [PATCH 2/3] imx23-olinuxino: swith to generic peristent env Eric Bénard @ 2013-02-14 11:56 ` Eric Bénard 2013-02-14 12:09 ` Juergen Beisert 2013-02-14 19:31 ` [PATCH 1/3] env: add register_persistent_environment Sascha Hauer 2 siblings, 1 reply; 28+ messages in thread From: Eric Bénard @ 2013-02-14 11:56 UTC (permalink / raw) To: barebox Signed-off-by: Eric Bénard <eric@eukrea.com> --- arch/arm/boards/chumby_falconwing/falconwing.c | 38 +------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c index 0818666..3a7b830 100644 --- a/arch/arm/boards/chumby_falconwing/falconwing.c +++ b/arch/arm/boards/chumby_falconwing/falconwing.c @@ -265,42 +265,6 @@ static int falconwing_mem_init(void) } mem_initcall(falconwing_mem_init); -/** - * Try to register an environment storage on the attached MCI card - * @return 0 on success - * - * We rely on the existence of a usable SD card, already attached to - * our system, to get something like a persistent memory for our environment. - * If this SD card is also the boot media, we can use the second partition - * for our environment purpose (if present!). - */ -static int register_persistant_environment(void) -{ - struct cdev *cdev; - - /* - * The chumby one only has one MCI card socket. - * So, we expect its name as "disk0". - */ - cdev = cdev_by_name("disk0"); - if (cdev == NULL) { - pr_err("No MCI card preset\n"); - return -ENODEV; - } - - /* MCI card is present, also a useable partition on it? */ - cdev = cdev_by_name("disk0.1"); - if (cdev == NULL) { - pr_err("No second partition available\n"); - pr_info("Please create at least a second partition with" - " 256 kiB...512 kiB in size (your choice)\n"); - return -ENODEV; - } - - /* use the full partition as our persistent environment storage */ - return devfs_add_partition("disk0.1", 0, cdev->size, DEVFS_PARTITION_FIXED, "env0"); -} - #define GPIO_USB_HUB_RESET 29 #define GPIO_USB_HUB_POWER 26 @@ -338,7 +302,7 @@ static int falconwing_devices_init(void) armlinux_set_bootparams((void *)IMX_MEMORY_BASE + 0x100); armlinux_set_architecture(MACH_TYPE_CHUMBY); - rc = register_persistant_environment(); + rc = register_persistant_environment("disk0", 1); if (rc != 0) printf("Cannot create the 'env0' persistant environment storage (%d)\n", rc); -- 1.7.11.7 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 3/3] falconwing: switch to generic peristent env 2013-02-14 11:56 ` [PATCH 3/3] falconwing: switch " Eric Bénard @ 2013-02-14 12:09 ` Juergen Beisert 2013-02-14 13:20 ` [PATCH v2] " Eric Bénard 0 siblings, 1 reply; 28+ messages in thread From: Juergen Beisert @ 2013-02-14 12:09 UTC (permalink / raw) To: barebox Eric Bénard wrote: > [...] > #define GPIO_USB_HUB_RESET 29 > #define GPIO_USB_HUB_POWER 26 > > @@ -338,7 +302,7 @@ static int falconwing_devices_init(void) > armlinux_set_bootparams((void *)IMX_MEMORY_BASE + 0x100); > armlinux_set_architecture(MACH_TYPE_CHUMBY); > > - rc = register_persistant_environment(); > + rc = register_persistant_environment("disk0", 1); ___^ :) jbe -- Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v2] falconwing: switch to generic peristent env 2013-02-14 12:09 ` Juergen Beisert @ 2013-02-14 13:20 ` Eric Bénard 2013-02-14 13:50 ` [PATCH v3] " Eric Bénard 0 siblings, 1 reply; 28+ messages in thread From: Eric Bénard @ 2013-02-14 13:20 UTC (permalink / raw) To: barebox Signed-off-by: Eric Bénard <eric@eukrea.com> --- v2: fix typo on persistent arch/arm/boards/chumby_falconwing/falconwing.c | 38 +------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c index 0818666..3e82596 100644 --- a/arch/arm/boards/chumby_falconwing/falconwing.c +++ b/arch/arm/boards/chumby_falconwing/falconwing.c @@ -265,42 +265,6 @@ static int falconwing_mem_init(void) } mem_initcall(falconwing_mem_init); -/** - * Try to register an environment storage on the attached MCI card - * @return 0 on success - * - * We rely on the existence of a usable SD card, already attached to - * our system, to get something like a persistent memory for our environment. - * If this SD card is also the boot media, we can use the second partition - * for our environment purpose (if present!). - */ -static int register_persistant_environment(void) -{ - struct cdev *cdev; - - /* - * The chumby one only has one MCI card socket. - * So, we expect its name as "disk0". - */ - cdev = cdev_by_name("disk0"); - if (cdev == NULL) { - pr_err("No MCI card preset\n"); - return -ENODEV; - } - - /* MCI card is present, also a useable partition on it? */ - cdev = cdev_by_name("disk0.1"); - if (cdev == NULL) { - pr_err("No second partition available\n"); - pr_info("Please create at least a second partition with" - " 256 kiB...512 kiB in size (your choice)\n"); - return -ENODEV; - } - - /* use the full partition as our persistent environment storage */ - return devfs_add_partition("disk0.1", 0, cdev->size, DEVFS_PARTITION_FIXED, "env0"); -} - #define GPIO_USB_HUB_RESET 29 #define GPIO_USB_HUB_POWER 26 @@ -338,7 +302,7 @@ static int falconwing_devices_init(void) armlinux_set_bootparams((void *)IMX_MEMORY_BASE + 0x100); armlinux_set_architecture(MACH_TYPE_CHUMBY); - rc = register_persistant_environment(); + rc = register_persistent_environment("disk0", 1); if (rc != 0) printf("Cannot create the 'env0' persistant environment storage (%d)\n", rc); -- 1.7.11.7 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v3] falconwing: switch to generic peristent env 2013-02-14 13:20 ` [PATCH v2] " Eric Bénard @ 2013-02-14 13:50 ` Eric Bénard 0 siblings, 0 replies; 28+ messages in thread From: Eric Bénard @ 2013-02-14 13:50 UTC (permalink / raw) To: barebox Signed-off-by: Eric Bénard <eric@eukrea.com> --- v3: also fix the typo in the printf v2: fix typo in persistent arch/arm/boards/chumby_falconwing/falconwing.c | 40 ++------------------------ 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c index 0818666..80eebba 100644 --- a/arch/arm/boards/chumby_falconwing/falconwing.c +++ b/arch/arm/boards/chumby_falconwing/falconwing.c @@ -265,42 +265,6 @@ static int falconwing_mem_init(void) } mem_initcall(falconwing_mem_init); -/** - * Try to register an environment storage on the attached MCI card - * @return 0 on success - * - * We rely on the existence of a usable SD card, already attached to - * our system, to get something like a persistent memory for our environment. - * If this SD card is also the boot media, we can use the second partition - * for our environment purpose (if present!). - */ -static int register_persistant_environment(void) -{ - struct cdev *cdev; - - /* - * The chumby one only has one MCI card socket. - * So, we expect its name as "disk0". - */ - cdev = cdev_by_name("disk0"); - if (cdev == NULL) { - pr_err("No MCI card preset\n"); - return -ENODEV; - } - - /* MCI card is present, also a useable partition on it? */ - cdev = cdev_by_name("disk0.1"); - if (cdev == NULL) { - pr_err("No second partition available\n"); - pr_info("Please create at least a second partition with" - " 256 kiB...512 kiB in size (your choice)\n"); - return -ENODEV; - } - - /* use the full partition as our persistent environment storage */ - return devfs_add_partition("disk0.1", 0, cdev->size, DEVFS_PARTITION_FIXED, "env0"); -} - #define GPIO_USB_HUB_RESET 29 #define GPIO_USB_HUB_POWER 26 @@ -338,9 +302,9 @@ static int falconwing_devices_init(void) armlinux_set_bootparams((void *)IMX_MEMORY_BASE + 0x100); armlinux_set_architecture(MACH_TYPE_CHUMBY); - rc = register_persistant_environment(); + rc = register_persistent_environment("disk0", 1); if (rc != 0) - printf("Cannot create the 'env0' persistant environment storage (%d)\n", rc); + printf("Cannot create the 'env0' persistent environment storage (%d)\n", rc); return 0; } -- 1.7.11.7 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 1/3] env: add register_persistent_environment 2013-02-14 11:56 ` [PATCH 1/3] env: add register_persistent_environment Eric Bénard 2013-02-14 11:56 ` [PATCH 2/3] imx23-olinuxino: swith to generic peristent env Eric Bénard 2013-02-14 11:56 ` [PATCH 3/3] falconwing: switch " Eric Bénard @ 2013-02-14 19:31 ` Sascha Hauer 2013-02-19 9:17 ` [PATCH v4 " Eric Bénard 2 siblings, 1 reply; 28+ messages in thread From: Sascha Hauer @ 2013-02-14 19:31 UTC (permalink / raw) To: Eric Bénard; +Cc: barebox, Juergen Beisert On Thu, Feb 14, 2013 at 12:56:49PM +0100, Eric Bénard wrote: > - heavily copied from register_persistant_environment which was > Signed-off-by: Juergen Beisert <jbe@pengutronix.de> > > Signed-off-by: Eric Bénard <eric@eukrea.com> > --- > common/environment.c | 40 ++++++++++++++++++++++++++++++++++++++++ > include/environment.h | 1 + Please move the prototype to include/envfs.h. include/environment.h has stuff for shell environment variables only. > 2 files changed, 41 insertions(+) > > diff --git a/common/environment.c b/common/environment.c > index e8d623f..55befd9 100644 > --- a/common/environment.c > +++ b/common/environment.c > @@ -363,3 +363,43 @@ out: > free(buf_free); > return ret; > } > + > +#ifdef __BAREBOX__ > +/** > + * Try to register an environment storage on a device's partition > + * @return 0 on success > + * > + * We rely on the existence of a usable storage device, already attached to > + * our system, to get something like a persistent memory for our environment. > + * We need to specify the partition number to use on this device. > + * @param[in] devname Name of the device > + * @param[in] partnr Partition number > + * @return 0 on success, anything else in case of failure > + */ > + > +int register_persistent_environment(const char *devname, unsigned int partnr) I think envfs_register_partition would be a better name. > +{ > + struct cdev *cdev; > + char *partname; > + > + if (!devname) > + return -EINVAL; > + > + cdev = cdev_by_name(devname); > + if (cdev == NULL) { > + pr_err("No %s present\n", devname); > + return -ENODEV; > + } > + partname = asprintf("%s.%d", devname, partnr); free partname? Sascha > + cdev = cdev_by_name(partname); > + if (cdev == NULL) { > + pr_err("No %s partition available\n", partname); > + pr_info("Please create the partition %s to store the env\n", partname); > + return -ENODEV; > + } > + > + return devfs_add_partition(partname, 0, cdev->size, > + DEVFS_PARTITION_FIXED, "env0"); > +} > +EXPORT_SYMBOL(register_persistent_environment); > +#endif > diff --git a/include/environment.h b/include/environment.h > index 7bdd213..d172f8f 100644 > --- a/include/environment.h > +++ b/include/environment.h > @@ -71,6 +71,7 @@ int env_pop_context(void); > int env_push_context(void); > > int export(const char *); > +int register_persistent_environment(const char *devname, unsigned int partnr); > > #endif /* _ENVIRONMENT_H_ */ > > -- > 1.7.11.7 > > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v4 1/3] env: add register_persistent_environment 2013-02-14 19:31 ` [PATCH 1/3] env: add register_persistent_environment Sascha Hauer @ 2013-02-19 9:17 ` Eric Bénard 2013-02-19 9:17 ` [PATCH v4 2/3] imx23-olinuxino: swith to generic peristent env Eric Bénard ` (3 more replies) 0 siblings, 4 replies; 28+ messages in thread From: Eric Bénard @ 2013-02-19 9:17 UTC (permalink / raw) To: barebox; +Cc: Juergen Beisert - heavily copied from register_persistant_environment which was Signed-off-by: Juergen Beisert <jbe@pengutronix.de> Signed-off-by: Eric Bénard <eric@eukrea.com> --- v4: rename function and move to envfs.h v3: also fix the typo in the printf v2: fix typo in persistent common/environment.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/envfs.h | 2 ++ 2 files changed, 42 insertions(+) diff --git a/common/environment.c b/common/environment.c index e8d623f..78cd45c 100644 --- a/common/environment.c +++ b/common/environment.c @@ -363,3 +363,43 @@ out: free(buf_free); return ret; } + +#ifdef __BAREBOX__ +/** + * Try to register an environment storage on a device's partition + * @return 0 on success + * + * We rely on the existence of a usable storage device, already attached to + * our system, to get something like a persistent memory for our environment. + * We need to specify the partition number to use on this device. + * @param[in] devname Name of the device + * @param[in] partnr Partition number + * @return 0 on success, anything else in case of failure + */ + +int envfs_register_partition(const char *devname, unsigned int partnr) +{ + struct cdev *cdev; + char *partname; + + if (!devname) + return -EINVAL; + + cdev = cdev_by_name(devname); + if (cdev == NULL) { + pr_err("No %s present\n", devname); + return -ENODEV; + } + partname = asprintf("%s.%d", devname, partnr); + cdev = cdev_by_name(partname); + if (cdev == NULL) { + pr_err("No %s partition available\n", partname); + pr_info("Please create the partition %s to store the env\n", partname); + return -ENODEV; + } + + return devfs_add_partition(partname, 0, cdev->size, + DEVFS_PARTITION_FIXED, "env0"); +} +EXPORT_SYMBOL(envfs_register_partition); +#endif diff --git a/include/envfs.h b/include/envfs.h index 2db55ed..e9372b3 100644 --- a/include/envfs.h +++ b/include/envfs.h @@ -96,4 +96,6 @@ int envfs_save(char *filename, char *dirname); /* defaults to /dev/env0 */ extern char *default_environment_path; +int envfs_register_partition(const char *devname, unsigned int partnr); + #endif /* _ENVFS_H */ -- 1.7.11.7 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v4 2/3] imx23-olinuxino: swith to generic peristent env 2013-02-19 9:17 ` [PATCH v4 " Eric Bénard @ 2013-02-19 9:17 ` Eric Bénard 2013-02-19 9:17 ` [PATCH v4 3/3] falconwing: switch " Eric Bénard ` (2 subsequent siblings) 3 siblings, 0 replies; 28+ messages in thread From: Eric Bénard @ 2013-02-19 9:17 UTC (permalink / raw) To: barebox Signed-off-by: Eric Bénard <eric@eukrea.com> --- v4: rename function and move to envfs.h arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c | 45 ++-------------------- 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c b/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c index 0482638..9620e85 100644 --- a/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c +++ b/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c @@ -25,6 +25,7 @@ #include <init.h> #include <gpio.h> #include <environment.h> +#include <envfs.h> #include <errno.h> #include <mci.h> #include <asm/armlinux.h> @@ -111,46 +112,6 @@ static void olinuxino_init_usb(void) add_generic_usb_ehci_device(DEVICE_ID_DYNAMIC, IMX_USB_BASE, NULL); } -/** - * Try to register an environment storage on the attached MCI card - * @return 0 on success - * - * We rely on the existence of a usable SD card, already attached to - * our system, to get something like a persistent memory for our environment. - * If this SD card is also the boot media, we can use the second partition - * for our environment purpose (if present!). - */ -static int register_persistant_environment(void) -{ - struct cdev *cdev; - - /* - * The imx23-olinuxino only has one MCI card socket. - * So, we expect its name as "disk0". - */ - cdev = cdev_by_name("disk0"); - if (cdev == NULL) { - pr_err("No MCI card preset\n"); - return -ENODEV; - } - - - - /* MCI card is present, also a useable partition on it? */ - cdev = cdev_by_name("disk0.1"); - if (cdev == NULL) { - pr_err("No second partition available\n"); - pr_info("Please create at least a second partition with" - " 256 kiB...512 kiB in size (your choice)\n"); - return -ENODEV; - } - - /* use the full partition as our persistent environment storage */ - return devfs_add_partition("disk0.1", 0, cdev->size, - DEVFS_PARTITION_FIXED, "env0"); -} - - static int imx23_olinuxino_devices_init(void) { int i, rc; @@ -174,9 +135,9 @@ static int imx23_olinuxino_devices_init(void) olinuxino_init_usb(); - rc = register_persistant_environment(); + rc = envfs_register_partition("disk0", 1); if (rc != 0) - printf("Cannot create the 'env0' persistant " + printf("Cannot create the 'env0' persistent " "environment storage (%d)\n", rc); return 0; -- 1.7.11.7 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v4 3/3] falconwing: switch to generic peristent env 2013-02-19 9:17 ` [PATCH v4 " Eric Bénard 2013-02-19 9:17 ` [PATCH v4 2/3] imx23-olinuxino: swith to generic peristent env Eric Bénard @ 2013-02-19 9:17 ` Eric Bénard 2013-02-19 11:58 ` [PATCH v4 1/3] env: add register_persistent_environment Jean-Christophe PLAGNIOL-VILLARD 2013-02-21 13:52 ` Sascha Hauer 3 siblings, 0 replies; 28+ messages in thread From: Eric Bénard @ 2013-02-19 9:17 UTC (permalink / raw) To: barebox Signed-off-by: Eric Bénard <eric@eukrea.com> --- v4: rename function and move to envfs.h arch/arm/boards/chumby_falconwing/falconwing.c | 41 ++------------------------ 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c index 0818666..fd5bc4c 100644 --- a/arch/arm/boards/chumby_falconwing/falconwing.c +++ b/arch/arm/boards/chumby_falconwing/falconwing.c @@ -16,6 +16,7 @@ #include <init.h> #include <gpio.h> #include <environment.h> +#include <envfs.h> #include <errno.h> #include <mci.h> #include <sizes.h> @@ -265,42 +266,6 @@ static int falconwing_mem_init(void) } mem_initcall(falconwing_mem_init); -/** - * Try to register an environment storage on the attached MCI card - * @return 0 on success - * - * We rely on the existence of a usable SD card, already attached to - * our system, to get something like a persistent memory for our environment. - * If this SD card is also the boot media, we can use the second partition - * for our environment purpose (if present!). - */ -static int register_persistant_environment(void) -{ - struct cdev *cdev; - - /* - * The chumby one only has one MCI card socket. - * So, we expect its name as "disk0". - */ - cdev = cdev_by_name("disk0"); - if (cdev == NULL) { - pr_err("No MCI card preset\n"); - return -ENODEV; - } - - /* MCI card is present, also a useable partition on it? */ - cdev = cdev_by_name("disk0.1"); - if (cdev == NULL) { - pr_err("No second partition available\n"); - pr_info("Please create at least a second partition with" - " 256 kiB...512 kiB in size (your choice)\n"); - return -ENODEV; - } - - /* use the full partition as our persistent environment storage */ - return devfs_add_partition("disk0.1", 0, cdev->size, DEVFS_PARTITION_FIXED, "env0"); -} - #define GPIO_USB_HUB_RESET 29 #define GPIO_USB_HUB_POWER 26 @@ -338,9 +303,9 @@ static int falconwing_devices_init(void) armlinux_set_bootparams((void *)IMX_MEMORY_BASE + 0x100); armlinux_set_architecture(MACH_TYPE_CHUMBY); - rc = register_persistant_environment(); + rc = envfs_register_partition("disk0", 1); if (rc != 0) - printf("Cannot create the 'env0' persistant environment storage (%d)\n", rc); + printf("Cannot create the 'env0' persistent environment storage (%d)\n", rc); return 0; } -- 1.7.11.7 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v4 1/3] env: add register_persistent_environment 2013-02-19 9:17 ` [PATCH v4 " Eric Bénard 2013-02-19 9:17 ` [PATCH v4 2/3] imx23-olinuxino: swith to generic peristent env Eric Bénard 2013-02-19 9:17 ` [PATCH v4 3/3] falconwing: switch " Eric Bénard @ 2013-02-19 11:58 ` Jean-Christophe PLAGNIOL-VILLARD 2013-02-19 13:41 ` Eric Bénard 2013-02-21 13:52 ` Sascha Hauer 3 siblings, 1 reply; 28+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-19 11:58 UTC (permalink / raw) To: Eric Bénard; +Cc: barebox, Juergen Beisert On 10:17 Tue 19 Feb , Eric Bénard wrote: > - heavily copied from register_persistant_environment which was > Signed-off-by: Juergen Beisert <jbe@pengutronix.de> > > Signed-off-by: Eric Bénard <eric@eukrea.com> > --- > v4: rename function and move to envfs.h > v3: also fix the typo in the printf > v2: fix typo in persistent > common/environment.c | 40 ++++++++++++++++++++++++++++++++++++++++ > include/envfs.h | 2 ++ > 2 files changed, 42 insertions(+) > > diff --git a/common/environment.c b/common/environment.c > index e8d623f..78cd45c 100644 > --- a/common/environment.c > +++ b/common/environment.c > @@ -363,3 +363,43 @@ out: > free(buf_free); > return ret; > } > + > +#ifdef __BAREBOX__ > +/** > + * Try to register an environment storage on a device's partition > + * @return 0 on success > + * > + * We rely on the existence of a usable storage device, already attached to > + * our system, to get something like a persistent memory for our environment. > + * We need to specify the partition number to use on this device. > + * @param[in] devname Name of the device > + * @param[in] partnr Partition number > + * @return 0 on success, anything else in case of failure > + */ > + > +int envfs_register_partition(const char *devname, unsigned int partnr) a part can be a number or a name Best Regards, J. > +{ > + struct cdev *cdev; > + char *partname; > + > + if (!devname) > + return -EINVAL; > + > + cdev = cdev_by_name(devname); > + if (cdev == NULL) { > + pr_err("No %s present\n", devname); > + return -ENODEV; > + } > + partname = asprintf("%s.%d", devname, partnr); > + cdev = cdev_by_name(partname); > + if (cdev == NULL) { > + pr_err("No %s partition available\n", partname); > + pr_info("Please create the partition %s to store the env\n", partname); > + return -ENODEV; > + } > + > + return devfs_add_partition(partname, 0, cdev->size, > + DEVFS_PARTITION_FIXED, "env0"); > +} > +EXPORT_SYMBOL(envfs_register_partition); > +#endif > diff --git a/include/envfs.h b/include/envfs.h > index 2db55ed..e9372b3 100644 > --- a/include/envfs.h > +++ b/include/envfs.h > @@ -96,4 +96,6 @@ int envfs_save(char *filename, char *dirname); > /* defaults to /dev/env0 */ > extern char *default_environment_path; > > +int envfs_register_partition(const char *devname, unsigned int partnr); > + > #endif /* _ENVFS_H */ > -- > 1.7.11.7 > > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v4 1/3] env: add register_persistent_environment 2013-02-19 11:58 ` [PATCH v4 1/3] env: add register_persistent_environment Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-19 13:41 ` Eric Bénard 2013-02-19 15:35 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 28+ messages in thread From: Eric Bénard @ 2013-02-19 13:41 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox, Juergen Beisert Le Tue, 19 Feb 2013 12:58:43 +0100, Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > On 10:17 Tue 19 Feb , Eric Bénard wrote: > > +int envfs_register_partition(const char *devname, unsigned int partnr) > a part can be a number or a name > do you have an example please ? Thanks, Eric _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v4 1/3] env: add register_persistent_environment 2013-02-19 13:41 ` Eric Bénard @ 2013-02-19 15:35 ` Jean-Christophe PLAGNIOL-VILLARD 2013-02-19 15:49 ` Eric Bénard 0 siblings, 1 reply; 28+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-19 15:35 UTC (permalink / raw) To: Eric Bénard; +Cc: barebox, Juergen Beisert On 14:41 Tue 19 Feb , Eric Bénard wrote: > Le Tue, 19 Feb 2013 12:58:43 +0100, > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > On 10:17 Tue 19 Feb , Eric Bénard wrote: > > > +int envfs_register_partition(const char *devname, unsigned int partnr) > > a part can be a number or a name > > > do you have an example please ? EFI GPT Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v4 1/3] env: add register_persistent_environment 2013-02-19 15:35 ` Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-19 15:49 ` Eric Bénard 2013-02-19 15:57 ` Eric Bénard 0 siblings, 1 reply; 28+ messages in thread From: Eric Bénard @ 2013-02-19 15:49 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox, Juergen Beisert Le Tue, 19 Feb 2013 16:35:48 +0100, Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > On 14:41 Tue 19 Feb , Eric Bénard wrote: > > Le Tue, 19 Feb 2013 12:58:43 +0100, > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > > > On 10:17 Tue 19 Feb , Eric Bénard wrote: > > > > +int envfs_register_partition(const char *devname, unsigned int partnr) > > > a part can be a number or a name > > > > > do you have an example please ? > EFI GPT > is that present in mailine ? Eric _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v4 1/3] env: add register_persistent_environment 2013-02-19 15:49 ` Eric Bénard @ 2013-02-19 15:57 ` Eric Bénard 2013-02-19 19:21 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 28+ messages in thread From: Eric Bénard @ 2013-02-19 15:57 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox Le Tue, 19 Feb 2013 16:49:41 +0100, Eric Bénard <eric@eukrea.com> a écrit : > Le Tue, 19 Feb 2013 16:35:48 +0100, > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > On 14:41 Tue 19 Feb , Eric Bénard wrote: > > > Le Tue, 19 Feb 2013 12:58:43 +0100, > > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > > > > > On 10:17 Tue 19 Feb , Eric Bénard wrote: > > > > > +int envfs_register_partition(const char *devname, unsigned int partnr) > > > > a part can be a number or a name > > > > > > > do you have an example please ? > > EFI GPT > > > is that present in mailine ? > OK found it in next. Handling that will lead to strange behaviour when someone will name "1" the ata0.0's partition ;-) Eric _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v4 1/3] env: add register_persistent_environment 2013-02-19 15:57 ` Eric Bénard @ 2013-02-19 19:21 ` Jean-Christophe PLAGNIOL-VILLARD 2013-02-21 6:55 ` Eric Bénard 0 siblings, 1 reply; 28+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-19 19:21 UTC (permalink / raw) To: Eric Bénard; +Cc: barebox On 16:57 Tue 19 Feb , Eric Bénard wrote: > Le Tue, 19 Feb 2013 16:49:41 +0100, > Eric Bénard <eric@eukrea.com> a écrit : > > > Le Tue, 19 Feb 2013 16:35:48 +0100, > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > > > On 14:41 Tue 19 Feb , Eric Bénard wrote: > > > > Le Tue, 19 Feb 2013 12:58:43 +0100, > > > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > > > > > > > On 10:17 Tue 19 Feb , Eric Bénard wrote: > > > > > > +int envfs_register_partition(const char *devname, unsigned int partnr) > > > > > a part can be a number or a name > > > > > > > > > do you have an example please ? > > > EFI GPT > > > > > is that present in mailine ? > > > OK found it in next. > > Handling that will lead to strange behaviour when someone will name "1" > the ata0.0's partition ;-) so this will faill don't people enough stupid to name their partition 1 deserve to have issues Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v4 1/3] env: add register_persistent_environment 2013-02-19 19:21 ` Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-21 6:55 ` Eric Bénard 2013-02-21 11:20 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 28+ messages in thread From: Eric Bénard @ 2013-02-21 6:55 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox Le Tue, 19 Feb 2013 20:21:12 +0100, Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > On 16:57 Tue 19 Feb , Eric Bénard wrote: > > Le Tue, 19 Feb 2013 16:49:41 +0100, > > Eric Bénard <eric@eukrea.com> a écrit : > > > > > Le Tue, 19 Feb 2013 16:35:48 +0100, > > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > > > > > On 14:41 Tue 19 Feb , Eric Bénard wrote: > > > > > Le Tue, 19 Feb 2013 12:58:43 +0100, > > > > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > > > > > > > > > On 10:17 Tue 19 Feb , Eric Bénard wrote: > > > > > > > +int envfs_register_partition(const char *devname, unsigned int partnr) > > > > > > a part can be a number or a name > > > > > > > > > > > do you have an example please ? > > > > EFI GPT > > > > > > > is that present in mailine ? > > > > > OK found it in next. > > > > Handling that will lead to strange behaviour when someone will name "1" > > the ata0.0's partition ;-) > so this will faill > > don't people enough stupid to name their partition 1 deserve to have issues > end users's creativity has no limits ;-) Eric _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v4 1/3] env: add register_persistent_environment 2013-02-21 6:55 ` Eric Bénard @ 2013-02-21 11:20 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 0 replies; 28+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-21 11:20 UTC (permalink / raw) To: Eric Bénard; +Cc: barebox On 07:55 Thu 21 Feb , Eric Bénard wrote: > Le Tue, 19 Feb 2013 20:21:12 +0100, > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > On 16:57 Tue 19 Feb , Eric Bénard wrote: > > > Le Tue, 19 Feb 2013 16:49:41 +0100, > > > Eric Bénard <eric@eukrea.com> a écrit : > > > > > > > Le Tue, 19 Feb 2013 16:35:48 +0100, > > > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > > > > > > > On 14:41 Tue 19 Feb , Eric Bénard wrote: > > > > > > Le Tue, 19 Feb 2013 12:58:43 +0100, > > > > > > Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > > > > > > > > > > > > > On 10:17 Tue 19 Feb , Eric Bénard wrote: > > > > > > > > +int envfs_register_partition(const char *devname, unsigned int partnr) > > > > > > > a part can be a number or a name > > > > > > > > > > > > > do you have an example please ? > > > > > EFI GPT > > > > > > > > > is that present in mailine ? > > > > > > > OK found it in next. > > > > > > Handling that will lead to strange behaviour when someone will name "1" > > > the ata0.0's partition ;-) > > so this will faill > > > > don't people enough stupid to name their partition 1 deserve to have issues > > > end users's creativity has no limits ;-) so they will have no limits issues Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v4 1/3] env: add register_persistent_environment 2013-02-19 9:17 ` [PATCH v4 " Eric Bénard ` (2 preceding siblings ...) 2013-02-19 11:58 ` [PATCH v4 1/3] env: add register_persistent_environment Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-21 13:52 ` Sascha Hauer 3 siblings, 0 replies; 28+ messages in thread From: Sascha Hauer @ 2013-02-21 13:52 UTC (permalink / raw) To: Eric Bénard; +Cc: barebox, Juergen Beisert On Tue, Feb 19, 2013 at 10:17:23AM +0100, Eric Bénard wrote: > - heavily copied from register_persistant_environment which was > Signed-off-by: Juergen Beisert <jbe@pengutronix.de> > > Signed-off-by: Eric Bénard <eric@eukrea.com> I'm not 100% sure this is the right thing to do. It seems the only usecase of this function is to print slightly more useful error messages than we would get should we only call devfs_add_partition("disk.1",...) from boards directly. Anyway, two boards are using it, the whole thing has a negative diffstat, so I applied it. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 2/2] cfa10036: Update the environment 2013-02-13 16:45 [PATCH 0/2] ARM: cfa10036: Store the barebox environment on the MMC Maxime Ripard 2013-02-13 16:45 ` [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment Maxime Ripard @ 2013-02-13 16:45 ` Maxime Ripard 1 sibling, 0 replies; 28+ messages in thread From: Maxime Ripard @ 2013-02-13 16:45 UTC (permalink / raw) To: barebox; +Cc: Brian Lilly Since we added a new partition in the board, the partitions number of the boot and rootfs partition have changed as well. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> --- arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 | 6 +++--- arch/arm/boards/crystalfontz-cfa10036/env/init/automount | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 b/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 index 5e508f9..439d174 100644 --- a/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 +++ b/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 @@ -5,6 +5,6 @@ if [ "$1" = menu ]; then exit fi -global.bootm.image="/mnt/disk0.1/zImage-${global.hostname}" -global.bootm.oftree="/mnt/disk0.1/oftree-${global.board.variant}" -global.linux.bootargs.dyn.root="root=/dev/mmcblk0p3 rootfstype=ext3 rootwait" +global.bootm.image="/mnt/disk0.2/zImage-${global.hostname}" +global.bootm.oftree="/mnt/disk0.2/oftree-${global.board.variant}" +global.linux.bootargs.dyn.root="root=/dev/mmcblk0p4 rootfstype=ext3 rootwait" diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/init/automount b/arch/arm/boards/crystalfontz-cfa10036/env/init/automount index 668775d..8fdca7c 100644 --- a/arch/arm/boards/crystalfontz-cfa10036/env/init/automount +++ b/arch/arm/boards/crystalfontz-cfa10036/env/init/automount @@ -5,5 +5,5 @@ if [ "$1" = menu ]; then exit fi -mkdir -p /mnt/disk0.1 -automount -d /mnt/disk0.1 '[ -e /dev/disk0.1 ] && mount /dev/disk0.1 /mnt/disk0.1' +mkdir -p /mnt/disk0.2 +automount -d /mnt/disk0.2 '[ -e /dev/disk0.2 ] && mount /dev/disk0.2 /mnt/disk0.2' -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2013-02-21 13:52 UTC | newest] Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-02-13 16:45 [PATCH 0/2] ARM: cfa10036: Store the barebox environment on the MMC Maxime Ripard 2013-02-13 16:45 ` [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment Maxime Ripard 2013-02-13 17:10 ` Eric Bénard 2013-02-13 17:12 ` Jean-Christophe PLAGNIOL-VILLARD 2013-02-14 9:52 ` Maxime Ripard 2013-02-14 8:16 ` Juergen Beisert 2013-02-14 10:10 ` Maxime Ripard 2013-02-14 11:17 ` Eric Bénard 2013-02-14 11:56 ` [PATCH 1/3] env: add register_persistent_environment Eric Bénard 2013-02-14 11:56 ` [PATCH 2/3] imx23-olinuxino: swith to generic peristent env Eric Bénard 2013-02-14 11:56 ` [PATCH 3/3] falconwing: switch " Eric Bénard 2013-02-14 12:09 ` Juergen Beisert 2013-02-14 13:20 ` [PATCH v2] " Eric Bénard 2013-02-14 13:50 ` [PATCH v3] " Eric Bénard 2013-02-14 19:31 ` [PATCH 1/3] env: add register_persistent_environment Sascha Hauer 2013-02-19 9:17 ` [PATCH v4 " Eric Bénard 2013-02-19 9:17 ` [PATCH v4 2/3] imx23-olinuxino: swith to generic peristent env Eric Bénard 2013-02-19 9:17 ` [PATCH v4 3/3] falconwing: switch " Eric Bénard 2013-02-19 11:58 ` [PATCH v4 1/3] env: add register_persistent_environment Jean-Christophe PLAGNIOL-VILLARD 2013-02-19 13:41 ` Eric Bénard 2013-02-19 15:35 ` Jean-Christophe PLAGNIOL-VILLARD 2013-02-19 15:49 ` Eric Bénard 2013-02-19 15:57 ` Eric Bénard 2013-02-19 19:21 ` Jean-Christophe PLAGNIOL-VILLARD 2013-02-21 6:55 ` Eric Bénard 2013-02-21 11:20 ` Jean-Christophe PLAGNIOL-VILLARD 2013-02-21 13:52 ` Sascha Hauer 2013-02-13 16:45 ` [PATCH 2/2] cfa10036: Update the environment Maxime Ripard
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox