[PATCH] ARM: rpi: add SD card environment support
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Tue Oct 15 07:36:30 EDT 2013
On 12:50 Tue 15 Oct , Sascha Hauer wrote:
> Similar to the OMAP boards mount the SD card to /boot and expect
> the environment as /boot/barebox.env
>
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
> arch/arm/boards/raspberry-pi/rpi.c | 33 +++++++++++++++++++++++++++++++--
> 1 file changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c
> index d4912cc..971a603 100644
> --- a/arch/arm/boards/raspberry-pi/rpi.c
> +++ b/arch/arm/boards/raspberry-pi/rpi.c
> @@ -15,6 +15,9 @@
>
> #include <common.h>
> #include <init.h>
> +#include <fs.h>
> +#include <linux/stat.h>
> +#include <envfs.h>
> #include <asm/armlinux.h>
> #include <generated/mach-types.h>
>
> @@ -37,11 +40,37 @@ static int rpi_console_init(void)
> }
> console_initcall(rpi_console_init);
>
> +static int rpi_env_init(void)
> +{
> + struct stat s;
> + const char *diskdev = "/dev/disk0.0";
> + int ret;
> +
> + device_detect_by_name("mci0");
> +
> + ret = stat(diskdev, &s);
> + if (ret) {
> + printf("no %s. using default env\n", diskdev);
> + return 0;
> + }
> +
> + mkdir("/boot", 0666);
> + ret = mount(diskdev, "fat", "/boot");
> + if (ret) {
> + printf("failed to mount %s\n", diskdev);
> + return 0;
> + }
> +
> + default_environment_path = "/boot/barebox.env";
> +
> + return 0;
> +}
can we drop all of this and do something like this
set_defaultenv and do not have custom code in the c duplicated everywhere?
> +
> static int rpi_devices_init(void)
> {
> armlinux_set_architecture(MACH_TYPE_BCM2708);
> armlinux_set_bootparams((void *)(0x00000100));
> + rpi_env_init();
> return 0;
> }
> -
> -device_initcall(rpi_devices_init);
> +late_initcall(rpi_devices_init);
> --
> 1.8.4.rc3
>
>
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
More information about the barebox
mailing list