ARM: cfa10036: Store the barebox environment on the MMC
Subsystems (2)
cover ARM: cfa10036: Store the barebox environment on the MMC
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(-)
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/2 cfa-10036: Use the second MMC partition to store the environment
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.
--- arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +43 -1
@@ -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);
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment
Hi Maxime,
Quoted 4 lines · Maxime Ripard
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
Quoted 59 lines
Signed-off-by Maxime Ripard <[email protected]>--- arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +38
-1@@ -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)
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c static int cfa10036_devices_init(void) · line 171
Quoted 10 lines
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +5
-0cfa10036_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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment
In reply to Maxime RipardQuoted 43 lines · Maxime Ripard
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 <[email protected]>--- arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +26
-0@@ -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 ) {
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c static int cfa10036_mem_init(void) · line 135
Quoted 10 lines
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +10
-0+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.
Quoted 28 lines
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +7
-1+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);Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment
Hi Jean-Christophe,
Quoted 47 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 46 lines · Maxime Ripard
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 <[email protected]>--- arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +29
-0@@ -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" );
Quoted 8 lines
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c static int cfa10036_mem_init(void) · line 135
Quoted 7 lines
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +7
-0+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
Signature · 9 lines
Maxime Ripard, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment
In reply to Maxime RipardQuoted 17 lines · Maxime Ripard
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 <[email protected]>--- arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44+++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +0
-0@@ -97,9 +97,46 @@ static int cfa10036_mem_init(void) }mem_initcall (cfa10036_mem_init);
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c static int cfa10036_mem_init(void) · line 109
Quoted 10 lines
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +10
-0+/** +* 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 :))
Quoted 1 line
[...]
jbe
Signature · 7 lines
Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment
Hi Juergen,
Quoted 31 lines · Juergen Beisert
Quoted 17 lines · Maxime Ripard
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 <[email protected]>--- arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44+++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +0
-0@@ -97,9 +97,46 @@ static int cfa10036_mem_init(void) }mem_initcall (cfa10036_mem_init);arch/arm/boards/crystalfontz-cfa10036/cfa10036.c static int cfa10036_mem_init(void) · line 109
Quoted 10 lines
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +10
-0+/** +* 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
Quoted 1 line
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
Signature · 9 lines
Maxime Ripard, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] cfa-10036: Use the second MMC partition to store the environment
Quoted 34 lines · Maxime Ripard
Hi Juergen,
Quoted 31 lines · Juergen Beisert
Quoted 17 lines · Maxime Ripard
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 <[email protected]>--- arch/arm/boards/crystalfontz-cfa10036/cfa10036.c | 44+++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +0
-0@@ -97,9 +97,46 @@ static int cfa10036_mem_init(void) }mem_initcall (cfa10036_mem_init);arch/arm/boards/crystalfontz-cfa10036/cfa10036.c static int cfa10036_mem_init(void) · line 109
Quoted 10 lines
arch/arm/boards/crystalfontz-cfa10036/cfa10036.c +10
-0+/** +* 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
Quoted 5 lines
Quoted 1 line
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/3 env: add register_persistent_environment
- heavily copied from register_persistant_environment which was
--- common/environment.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/environment.h | 1 + 2 files changed, 41 insertions(+)
common/environment.c +40 -0
@@ -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
include/environment.h +1 -0
@@ -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_ */
Signature · 7 lines
1.7.11.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/3 imx23-olinuxino: swith to generic peristent env
--- arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c | 44 +--------------------- 1 file changed, 2 insertions(+), 42 deletions(-)
arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c +2 -42
@@ -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 ;
Signature · 7 lines
1.7.11.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/3 falconwing: switch to generic peristent env
In reply to Eric Bénard--- arch/arm/boards/chumby_falconwing/falconwing.c | 38 +------------------------- 1 file changed, 1 insertion(+), 37 deletions(-)
arch/arm/boards/chumby_falconwing/falconwing.c +1 -37
@@ -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);
Signature · 7 lines
1.7.11.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 3/3] falconwing: switch to generic peristent env
arch/arm/boards/chumby_falconwing/falconwing.c static int falconwing_devices_init(void) · line 305
Quoted 10 lines · Eric Bénard
[...]
#defineGPIO_USB_HUB_RESET29
#defineGPIO_USB_HUB_POWER26arch/arm/boards/chumby_falconwing/falconwing.c +1
-1@@ -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
Signature · 7 lines
Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/1 falconwing: switch to generic peristent env
---
v2: fix typo on persistent
arch/arm/boards/chumby_falconwing/falconwing.c | 38 +------------------------- 1 file changed, 1 insertion(+), 37 deletions(-)
arch/arm/boards/chumby_falconwing/falconwing.c +1 -37
@@ -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);
Signature · 7 lines
1.7.11.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v3 1/1 falconwing: switch to generic peristent env
---
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(-)
arch/arm/boards/chumby_falconwing/falconwing.c +2 -38
@@ -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 ; }
Signature · 7 lines
1.7.11.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH 1/3] env: add register_persistent_environment
In reply to Eric BénardQuoted 7 lines · Eric Bénard
- heavily copied from
register_persistant_environmentwhich wasSigned-off-by Juergen Beisert <[email protected]>Signed-off-by Eric Bénard <[email protected]>--- 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.
Quoted 15 lines
2 files changed, 41 insertions(+)common/environment.c +5
-0@@ -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
common/environment.c out: · line 380
Quoted 10 lines
common/environment.c +10
-0+* +* 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.
common/environment.c out: · line 393
Quoted 13 lines
common/environment.c +13
-0+{ +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
Quoted 32 lines
common/environment.c +12
-0+ 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 include/environment.h +1
-0@@ -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_ */ Signature · 7 lines
1.7.11.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 1/3 env: add register_persistent_environment
- heavily copied from register_persistant_environment which was
---
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(+)
common/environment.c +40 -0
@@ -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
include/envfs.h +2 -0
@@ -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 */
Signature · 7 lines
1.7.11.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 2/3 imx23-olinuxino: swith to generic peristent env
---
v4: rename function and move to envfs.h
arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c | 45 ++-------------------- 1 file changed, 3 insertions(+), 42 deletions(-)
arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c +3 -42
@@ -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 ;
Signature · 7 lines
1.7.11.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 3/3 falconwing: switch to generic peristent env
In reply to Eric Bénard---
v4: rename function and move to envfs.h
arch/arm/boards/chumby_falconwing/falconwing.c | 41 ++------------------------ 1 file changed, 3 insertions(+), 38 deletions(-)
arch/arm/boards/chumby_falconwing/falconwing.c +3 -38
@@ -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 ; }
Signature · 7 lines
1.7.11.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v4 1/3] env: add register_persistent_environment
In reply to Eric BénardQuoted 25 lines · Eric Bénard
- heavily copied from
register_persistant_environmentwhich wasSigned-off-by Juergen Beisert <[email protected]>Signed-off-by Eric Bénard <[email protected]>---
v4: rename function and move toenvfs.h
v3: also fix the typo in the printf
v2: fix typo in persistentcommon/environment.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/envfs.h | 2 ++ 2 files changed, 42 insertions(+)common/environment.c +5
-0@@ -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
common/environment.c out: · line 380
Quoted 10 lines
common/environment.c +10
-0+* +* 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.
Quoted 44 lines
common/environment.c +25
-0+{ +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 include/envfs.h +2
-0@@ -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 */ Signature · 7 lines
1.7.11.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v4 1/3] env: add register_persistent_environment
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 1 line · Eric Bénard
+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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v4 1/3] env: add register_persistent_environment
Quoted 8 lines · Eric Bénard
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 1 line · Eric Bénard
+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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v4 1/3] env: add register_persistent_environment
Quoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · Eric Bénard
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 1 line · Eric Bénard
+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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v4 1/3] env: add register_persistent_environment
Quoted 7 lines · Eric Bénard
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines · Eric Bénard
Le Tue, 19 Feb 2013 12:58:43 +0100,
Jean-Christophe PLAGNIOL-VILLARD <[email protected]> a écrit :
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines · Eric Bénard
Quoted 1 line
+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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v4 1/3] env: add register_persistent_environment
Quoted 15 lines · Eric Bénard
Quoted 12 lines · Eric Bénard
Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · Eric Bénard
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 1 line · Eric Bénard
+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 ?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v4 1/3] env: add register_persistent_environment
Quoted 20 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 19 lines · Eric Bénard
Quoted 16 lines · Eric Bénard
Quoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · Eric Bénard
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 1 line · Eric Bénard
+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 ?
Quoted 8 lines
Quoted 4 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v4 1/3] env: add register_persistent_environment
Quoted 25 lines · Eric Bénard
Quoted 22 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 21 lines · Eric Bénard
Quoted 7 lines · Eric Bénard
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines · Eric Bénard
Le Tue, 19 Feb 2013 12:58:43 +0100,
Jean-Christophe PLAGNIOL-VILLARD <[email protected]> a écrit :Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines · Eric Bénard
Quoted 1 line
+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.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH v4 1/3] env: add register_persistent_environment
In reply to Eric BénardQuoted 4 lines · Eric Bénard
- heavily copied from
register_persistant_environmentwhich wasSigned-off-by Juergen Beisert <[email protected]>Signed-off-by Eric Bénard <[email protected]>
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
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/2 cfa10036: Update the environment
In reply to Maxime RipardSince we added a new partition in the board, the partitions number of the boot and rootfs partition have changed as well.
--- 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(-)
arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 +3 -3
@@ -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"
arch/arm/boards/crystalfontz-cfa10036/env/init/automount +2 -2
@@ -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'
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox