Skip to contentSkip to conversation

arm: mach-omap: Change file flags in emmc handler

PATCH In review Daniel Schultz 2 participants 10 messages Apr 28, 2017 – May 5, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/7 arm: mach-omap: Change file flags in emmc handler

This handler tries to read from a file descriptor with 'write only' flags and fails. Add read permissions for the file, so the handler can read the partition layout.

---
 arch/arm/mach-omap/am33xx_bbu_emmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-omap/am33xx_bbu_emmc.c +1 -1
index 3220575..d3adb37 100644
@@ -39,7 +39,7 @@ static int emmc_mlo_handler(struct bbu_handler *handler, struct bbu_data *data)
 	if (ret != 0)
 		return ret;
 
-	fd = open(handler->devicefile, O_WRONLY);
+	fd = open(handler->devicefile, O_RDWR);
 	if (fd < 0) {
 		pr_err("could not open %s: %s\n", handler->devicefile,
 			errno_str());
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/7 arm: boards: Add MLO handler for EMMC devices

This patch enables the barebox handler to flash MLOs on EMMC devices with 'barebox_update'.

---
 arch/arm/boards/phytec-som-am335x/board.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/boards/phytec-som-am335x/board.c +1 -0
index 7f62453..dc3b84a 100644
@@ -112,6 +112,7 @@ static int physom_devices_init(void)
 		xloadslots, ARRAY_SIZE(xloadslots));
 	am33xx_bbu_nand_slots_register_handler("nand", nandslots,
 				ARRAY_SIZE(nandslots));
+	am33xx_bbu_emmc_mlo_register_handler("MLO.emmc", "/dev/mmc1");
 
 	if (IS_ENABLED(CONFIG_SHELL_NONE))
 		return am33xx_of_register_bootdevice();
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 3/7 arm: mach-omap: Change mountpoint of boot partitions

In reply to Daniel Schultz

If using EMMC and SD as bootsources, mounting the boot partition of both devices to /boot makes trouble. Either the correct device is mounted to /boot or a remount of /boot has to be performed.

To ensure this problem each MMCn bootsource will be mounted to his own path in /mnt/{mmc,emmc}.

---
 arch/arm/mach-omap/omap_generic.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
arch/arm/mach-omap/omap_generic.c +19 -5
index 1d03eac..7c50806 100644
@@ -113,10 +113,15 @@ const char *omap_get_bootmmc_devname(void)
 }
 
 #if defined(CONFIG_ENV_HANDLING)
-#define ENV_PATH "/boot/barebox.env"
+#define MMC_PATH "/mnt/mmc/"
+#define MMC_ENV_PATH MMC_PATH "barebox.env"
+#define EMMC_PATH "/mnt/emmc/"
+#define EMMC_ENV_PATH EMMC_PATH "barebox.env"
 static int omap_env_init(void)
 {
 	char *partname;
+	char *mntpath;
+	char *envpath;
 	const char *diskdev;
 	int ret;
 
@@ -132,15 +137,24 @@ static int omap_env_init(void)
 
 	partname = basprintf("/dev/%s.0", diskdev);
 
-	mkdir("/boot", 0666);
-	ret = mount(partname, "fat", "/boot", NULL);
+	if (bootsource_get_instance() == 1) {
+		mntpath = EMMC_PATH;
+		envpath = EMMC_ENV_PATH;
+	} else {
+		mntpath = MMC_PATH;
+		envpath = MMC_ENV_PATH;
+	}
+	mkdir("/mnt", 0666);
+	mkdir(MMC_PATH, 0666);
+	mkdir(EMMC_PATH, 0666);
+	ret = mount(partname, "fat", mntpath, NULL);
 	if (ret) {
 		pr_err("Failed to load environment: mount %s failed (%d)\n", partname, ret);
 		goto out;
 	}
 
-	pr_debug("Loading default env from %s on device %s\n", ENV_PATH, partname);
-	default_environment_path_set(ENV_PATH);
+	pr_debug("Loading default env from %s on device %s\n", envpath, partname);
+	default_environment_path_set(envpath);
 
 out:
 	free(partname);
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Re: [PATCH 3/7] arm: mach-omap: Change mountpoint of boot partitions

Hi Daniel,

Quoted 36 lines · Daniel Schultz

If using EMMC and SD as bootsources, mounting the boot partition of both devices to /boot makes trouble. Either the correct device is mounted to /boot or a remount of /boot has to be performed.

To ensure this problem each MMCn bootsource will be mounted to his own path in /mnt/{mmc,emmc}.

---
 arch/arm/mach-omap/omap_generic.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
arch/arm/mach-omap/omap_generic.c +6 -1
index 1d03eac..7c50806 100644
@@ -113,10 +113,15 @@ const char *omap_get_bootmmc_devname(void)
 }
 
 #if defined(CONFIG_ENV_HANDLING)
-#define ENV_PATH "/boot/barebox.env"
+#define MMC_PATH "/mnt/mmc/"
+#define MMC_ENV_PATH MMC_PATH "barebox.env"
+#define EMMC_PATH "/mnt/emmc/"
+#define EMMC_ENV_PATH EMMC_PATH "barebox.env"
 static int omap_env_init(void)
 {
 	char *partname;
+	char *mntpath;
+	char *envpath;
 	const char *diskdev;
 	int ret;
 
@@ -132,15 +137,24 @@ static int omap_env_init(void)
 
 	partname = basprintf("/dev/%s.0", diskdev);

arch/arm/mach-omap/omap_generic.c static int omap_env_init(void) · line 146

Quoted 10 lines
arch/arm/mach-omap/omap_generic.c +7 -2
 
-	mkdir("/boot", 0666);
-	ret = mount(partname, "fat", "/boot", NULL);
+	if (bootsource_get_instance() == 1) {
+		mntpath = EMMC_PATH;
+		envpath = EMMC_ENV_PATH;
+	} else {
+		mntpath = MMC_PATH;
+		envpath = MMC_ENV_PATH;
+	}

Hardcoding that one instance is eMMC while the other is a SD card slot is not so nice.

arch/arm/mach-omap/omap_generic.c static int omap_env_init(void) · line 150

Quoted 4 lines
arch/arm/mach-omap/omap_generic.c +4 -0
+	mkdir("/mnt", 0666);
+	mkdir(MMC_PATH, 0666);
+	mkdir(EMMC_PATH, 0666);
+	ret = mount(partname, "fat", mntpath, NULL);

You could use cdev_mount_default() instead of mount directly. This function only mounts when it's not mounted already and returns the path the device is mounted to.

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
#4 lore raw

PATCH 4/7 arm: boards: phytec-som-am335x: Add automount script

In reply to Daniel Schultz

Each boot source is mounted to either /mnt/mmc or /mnt/emmc. To make the not-mounted boot source available in Barebox, an automount script mounts this device to /mnt/{mmc, emmc}, if the directory will be accessed.

---
 .../defaultenv-physom-am335x/init/automount           | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/init/automount
arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/init/automount new file +19 -0
new file mode 100644
index 0000000..3d109ec
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# automount tftp server based on $eth0.serverip
+
+mkdir -p /mnt/tftp
+automount /mnt/tftp 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp'
+
+# automount nfs server's nfsroot
+
+mkdir -p /mnt/nfs
+automount /mnt/nfs 'ifup eth0 && mount -t nfs ${eth0.serverip}:/home/${global.user}/nfsroot/${global.hostname} /mnt/nfs'
+
+#automount SD card and EMMC boot partitions
+
+if [ $bootsource = mmc -a $bootsource_instance = 1 ]; then
+	automount /mnt/mmc '[ -e /dev/mmc0.0 ] && mount /dev/mmc0.0 /mnt/mmc'
+else
+	automount /mnt/emmc '[ -e /dev/mmc1.0 ] && mount /dev/mmc1.0 /mnt/emmc'
+fi
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 5/7 arm: boards: phytec-som-am335x: Update boot scripts

In reply to Daniel Schultz

Expand the boot scripts with EMMC and add a default file source for expansions.

Removed "rw" and "rootwait" bootargs from existing boot scripts. Added "rootflags='data=journal'" bootarg to SD card boot script.

---
 .../defaultenv-physom-am335x/boot/emmc                  |  7 +++++++
 .../phytec-som-am335x/defaultenv-physom-am335x/boot/mmc |  7 ++++---
 .../defaultenv-physom-am335x/boot/nand                  |  4 +++-
 .../phytec-som-am335x/defaultenv-physom-am335x/boot/net | 17 +++++++++++++++++
 .../phytec-som-am335x/defaultenv-physom-am335x/boot/spi |  4 +++-
 .../defaultenv-physom-am335x/init/bootsource            | 16 ++++++++++++----
 6 files changed, 46 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/emmc
 create mode 100644 arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/net
arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/emmc new file +7 -0
new file mode 100644
index 0000000..ed0f240
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+[ -e /env/config-expansions ] && /env/config-expansions
+
+global.bootm.image=/mnt/emmc/linuximage
+global.bootm.oftree=/mnt/emmc/oftree
+global.linux.bootargs.dyn.root="root=/dev/mmcblk1p2 rootflags='data=journal'"
arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/mmc +4 -3
index 834669d..21b16f4 100644
@@ -1,6 +1,7 @@
 #!/bin/sh
 
-global.bootm.image=/boot/linuximage
-global.bootm.oftree=/boot/oftree
+[ -e /env/config-expansions ] && /env/config-expansions
 
-global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rw rootwait"
+global.bootm.image=/mnt/mmc/linuximage
+global.bootm.oftree=/mnt/mmc/oftree
+global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootflags='data=journal'"
arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/nand +3 -1
index ece44b7..fa695bb 100644
@@ -1,8 +1,10 @@
 #!/bin/sh
 
+[ -e /env/config-expansions ] && /env/config-expansions
+
 [ ! -e /dev/nand0.root.ubi ] && ubiattach /dev/nand0.root
 
 global.bootm.image="/dev/nand0.root.ubi.kernel"
 global.bootm.oftree="/dev/nand0.root.ubi.oftree"
 
-global.linux.bootargs.dyn.root="root=ubi0:root ubi.mtd=root rw rootfstype=ubifs"
+global.linux.bootargs.dyn.root="root=ubi0:root ubi.mtd=root rootfstype=ubifs"
arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/net new file +17 -0
new file mode 100644
index 0000000..6dbd2aa
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+path="/mnt/tftp"
+
+global.bootm.image="${path}/${global.user}-linux-${global.hostname}"
+
+oftree="${path}/${global.user}-oftree-${global.hostname}"
+if [ -f "${oftree}" ]; then
+    global.bootm.oftree="$oftree"
+fi
+
+nfsroot="/nfsroot/${global.hostname}"
+bootargs-ip
+
+[ -e /env/config-expansions ] && /env/config-expansions
+
+global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,vers=3,udp"
arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/spi +3 -1
index 71c5834..2d88626 100644
@@ -1,7 +1,9 @@
 #!/bin/sh
 
+[ -e /env/config-expansions ] && /env/config-expansions
+
 global.bootm.image="/dev/m25p0.kernel"
 global.bootm.oftree="/dev/m25p0.oftree"
 
 # Use rootfs from NAND
-global.linux.bootargs.dyn.root="root=ubi0:root ubi.mtd=nand0.root rw rootfstype=ubifs"
+global.linux.bootargs.dyn.root="root=ubi0:root ubi.mtd=nand0.root rootfstype=ubifs"
arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/init/bootsource +12 -4
index 3f2ff4b..61a0879 100644
@@ -4,12 +4,20 @@ if [ -n "$nv.boot.default" ]; then
 	exit
 fi
 
-if [ $bootsource = mmc ]; then
-	global.boot.default="mmc nand spi net"
+if [ -e /dev/mmc1.0 ]; then
+	nvmem="emmc"
+else
+	nvmem="nand"
+fi
+
+if [ $bootsource = mmc -a $bootsource_instance = 1 ]; then
+	global.boot.default="emmc mmc spi net"
+elif [ $bootsource = mmc -a $bootsource_instance = 0 ]; then
+	global.boot.default="mmc $nvmem spi net"
 elif [ $bootsource = nand ]; then
 	global.boot.default="nand spi mmc net"
 elif [ $bootsource = spi ]; then
-	global.boot.default="spi nand mmc net"
+	global.boot.default="spi $nvmem mmc net"
 elif [ $bootsource = net ]; then
-	global.boot.default="net nand spi mmc"
+	global.boot.default="net $nvmem spi mmc"
 fi
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH 6/7 arm: boards: beaglebone: Update boot scripts

In reply to Daniel Schultz

Remove the current SD boot script and add support for MMC, EMMC and network bootsources.

---
 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/emmc  |  9 +++++++++
 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/mmc   |  9 +++++++++
 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/sd    |  6 ------
 .../boards/beaglebone/defaultenv-beaglebone/init/bootsource | 13 +++++++++++++
 4 files changed, 31 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/emmc
 create mode 100644 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/mmc
 delete mode 100644 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/sd
 create mode 100644 arch/arm/boards/beaglebone/defaultenv-beaglebone/init/bootsource
arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/emmc new file +9 -0
new file mode 100644
index 0000000..5734e3b
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ -e /mnt/emmc/linuximage ]
+	global.bootm.image=/mnt/emmc/linuximage
+else
+	global.bootm.image=/mnt/emmc/uImage
+fi
+global.bootm.oftree=/mnt/emmc/oftree
+global.linux.bootargs.dyn.root="root=/dev/mmcblk1p2 rootflags='data=journal'"
arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/mmc new file +9 -0
new file mode 100644
index 0000000..e8bd769
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ -e /mnt/mmc/linuximage ]
+	global.bootm.image=/mnt/mmc/linuximage
+else
+	global.bootm.image=/mnt/mmc/uImage
+fi
+global.bootm.oftree=/mnt/mmc/oftree
+global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootflags='data=journal'"
arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/sd deleted +0 -6
deleted file mode 100644
index aa94b2f..0000000
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-global.bootm.image=/boot/uImage
-global.bootm.oftree=/boot/oftree
-#global.bootm.initrd=<path to initrd>
-global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootfstype=ext4 rootwait"
arch/arm/boards/beaglebone/defaultenv-beaglebone/init/bootsource new file +13 -0
new file mode 100644
index 0000000..6301d1d
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ -n "$nv.boot.default" ]; then
+    exit
+fi
+
+if [ $bootsource = mmc -a $bootsource_instance = 1 ]; then
+    global.boot.default="emmc mmc net"
+elif [ $bootsource = mmc -a $bootsource_instance = 0 ]; then
+    global.boot.default="mmc emmc net"
+elif [ $bootsource = net ]; then
+    global.boot.default="net emmc mmc"
+fi
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

Re: [PATCH 6/7] arm: boards: beaglebone: Update boot scripts

Quoted 21 lines · Daniel Schultz

Remove the current SD boot script and add support for MMC, EMMC and network bootsources.

---
 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/emmc  |  9 +++++++++
 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/mmc   |  9 +++++++++
 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/sd    |  6 ------
 .../boards/beaglebone/defaultenv-beaglebone/init/bootsource | 13 +++++++++++++
 4 files changed, 31 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/emmc
 create mode 100644 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/mmc
 delete mode 100644 arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/sd
 create mode 100644 arch/arm/boards/beaglebone/defaultenv-beaglebone/init/bootsource
arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/emmc new file +0 -0
new file mode 100644
index 0000000..5734e3b

arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/emmc line 9

Quoted 9 lines
arch/arm/boards/beaglebone/defaultenv-beaglebone/boot/emmc new file +9 -0
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ -e /mnt/emmc/linuximage ]
+	global.bootm.image=/mnt/emmc/linuximage
+else
+	global.bootm.image=/mnt/emmc/uImage
+fi
+global.bootm.oftree=/mnt/emmc/oftree
+global.linux.bootargs.dyn.root="root=/dev/mmcblk1p2 rootflags='data=journal'"

I know I asked this quite some times already, but: Why not bootloader spec? grepping for "global.bootm.image=" shows that we expect the kernel at "/linuximage", "/zImage" or "/uImage", depending on the board. "data=journal" is only valid for ext4 and even there is not an option everybody wants to have.
With bootloader spec the rootfs can describe itself which kernel(s) shall be started with which devicetrees. From barebox it's easy aswell, only type "boot mmcx" and you're done.

With these bootscripts the first one who comes decides how the board is intended to be used. I really don't want to have this in generic boards.

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
#8 lore raw

PATCH 7/7 arm: boards: afi-gf: Update SD card boot script

In reply to Daniel Schultz

The default mount path for SD cards changed from /boot to /mnt/mmc. Updated paths in SD card boot script.

---
 arch/arm/boards/afi-gf/defaultenv-gf/boot/sd | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boards/afi-gf/defaultenv-gf/boot/sd +2 -2
index aa94b2f..30f373e 100644
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-global.bootm.image=/boot/uImage
-global.bootm.oftree=/boot/oftree
+global.bootm.image=/mnt/mmc/uImage
+global.bootm.oftree=/mnt/mmc/oftree
 #global.bootm.initrd=<path to initrd>
 global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootfstype=ext4 rootwait"
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw
In reply to Daniel Schultz
Quoted 5 lines · Daniel Schultz

This handler tries to read from a file descriptor with 'write only' flags and fails. Add read permissions for the file, so the handler can read the partition layout.

Applied this one and 2/7 for now.

Sascha

Quoted 26 lines
---
 arch/arm/mach-omap/am33xx_bbu_emmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-omap/am33xx_bbu_emmc.c +1 -1
index 3220575..d3adb37 100644
@@ -39,7 +39,7 @@ static int emmc_mlo_handler(struct bbu_handler *handler, struct bbu_data *data)
 	if (ret != 0)
 		return ret;
 
-	fd = open(handler->devicefile, O_WRONLY);
+	fd = open(handler->devicefile, O_RDWR);
 	if (fd < 0) {
 		pr_err("could not open %s: %s\n", handler->devicefile,
 			errno_str());
Signature · 7 lines
1.9.1


_______________________________________________
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