[PATCH] ARM: i.MX: OCOTP: read serial number with correct endianness

2020-12-03 Thread Robert Karszniewicz
The serial number is stored with the low bytes first, as can be seen in
Linux commit 8267ff89b713 ("ARM: imx: Add serial number support for
i.MX6/7 SoCs").  The same goes for i.MX8M.

Also renamed the macro to the more descriptive name from Linux.

Fixes: c4d9463d969b ("i.MX: Introduce imx_ocotp_read_uid()")
Signed-off-by: Robert Karszniewicz 
---
 arch/arm/mach-imx/include/mach/ocotp.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-imx/include/mach/ocotp.h 
b/arch/arm/mach-imx/include/mach/ocotp.h
index 7ba5da156b76..20205c5da759 100644
--- a/arch/arm/mach-imx/include/mach/ocotp.h
+++ b/arch/arm/mach-imx/include/mach/ocotp.h
@@ -26,8 +26,8 @@
 #define OCOTP_BIT(n)   FIELD_PREP(OCOTP_BIT_MASK, n)
 #define OCOTP_WIDTH(n) FIELD_PREP(OCOTP_WIDTH_MASK, (n) - 1)
 
-#define OCOTP_OFFSET_CFG0  0x410
-#define OCOTP_OFFSET_CFG1  0x420
+#define OCOTP_UID_L0x410
+#define OCOTP_UID_H0x420
 
 
 int imx_ocotp_read_field(uint32_t field, unsigned *value);
@@ -39,9 +39,9 @@ static inline u64 imx_ocotp_read_uid(void __iomem *ocotp)
 {
u64 uid;
 
-   uid  = readl(ocotp + OCOTP_OFFSET_CFG0);
+   uid  = readl(ocotp + OCOTP_UID_H);
uid <<= 32;
-   uid |= readl(ocotp + OCOTP_OFFSET_CFG1);
+   uid |= readl(ocotp + OCOTP_UID_L);
 
return uid;
 }
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Using bootspec with RAUC and redundant partitions

2020-09-30 Thread Robert Karszniewicz

Hello, Robin.

On 9/30/20 11:19 AM, robin wrote:

Hi Enrico, Sascha,

On 2020-09-30 10:09, Enrico Jörns wrote:

Hi Robin,

Am Mittwoch, den 30.09.2020, 09:39 +0200 schrieb Sascha Hauer:

> Is there a door number 3 or am I missing something here?

What's the reason for additional kernel partitions? Things would be
easier if you put the kernel images into the rootfs partitions along
with the bootspec entries.


the road to success here is to not encode any slot-/partition-specific
information in the bootspec entries.


I see.


Why this would work anyway is because barebox extends the kernel
commandline with the root= entries required to boot the kernel from
that specific partition where it did read the entry from.

This way it should work having an A+B setup with only two rootfs
partitions that include the kernel, the (generic) bootspec entry and
the rootfs itself (as Sascha already pointed out).


We've decided to separate the kernel from the OS a long time ago because,
back then, we wanted to keep the bootloader simple, minimal and solid and
including ext4 support didn't quite fit into that picture. Also, our
customer used to create their own rootfs, and we'd build them a kernel
and back then we didn't bundle releases (like rauc does now).


I don't know if it helps in your case, but we had a similar problem 
(wanted rootfs and kernel separate, but couldn't predict the rootfs 
partition device number in kernel). We ended up with a patch to barebox 
that allows specifying the rootfs device, which barebox then converts to 
"root=PARTUUID=".


The patch is currently on 'master':
d39a98718154 ("bootm: add global.bootm.root_dev env var for booting via 
PARTUUID")


Maybe it helps.

Regards.



Since things changed in the meantime I'll re-open that discussion
and go from there. Thanks for pointing me in this direction.

Best regards,
Robin van der Gracht


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] scripts: compiler.h: include

2020-09-19 Thread Robert Karszniewicz
ulong is not a standard type, so it has to be defined explicitly.

Signed-off-by: Robert Karszniewicz 
---
This fixes compile errors on musl when building the sandbox.

 scripts/compiler.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/compiler.h b/scripts/compiler.h
index 0ad25f9e8..c932f715c 100644
--- a/scripts/compiler.h
+++ b/scripts/compiler.h
@@ -62,6 +62,7 @@ typedef unsigned int  uint;
   defined(__NetBSD__) || defined(__DragonFly__)
 # include 
 #else /* assume Linux */
+# include 
 # include 
 # include 
 #endif
-- 
2.28.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] README: add some commas for clarity

2020-09-19 Thread Robert Karszniewicz
Signed-off-by: Robert Karszniewicz 
---
 README | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/README b/README
index d8077d21b..0a837b2de 100644
--- a/README
+++ b/README
@@ -114,7 +114,7 @@ in board/sandbox/env:
 
   # ./scripts/bareboxenv -s -p 0x1 arch/sandbox/board/env env.bin
 
-To get some files to play with you can generate a cramfs image:
+To get some files to play with, you can generate a cramfs image:
   # mkcramfs somedir/ cramfs.bin
 
 The barebox image is a normal Linux executable, so it can be started
@@ -133,14 +133,14 @@ given with '-i' will appear as /dev/fd[n].
 
 If barebox finds a valid configuration sector on /dev/env0 it will
 load it to /env. It then executes /env/init if it exists. If you have
-loaded the example environment barebox will show you a menu asking for
+loaded the example environment, barebox will show you a menu asking for
 your settings.
 
-If you have started barebox as root you will find a new tap device on your
+If you have started barebox as root, you will find a new tap device on your
 host which you can configure using ifconfig. Once you configured bareboxs
-network settings accordingly you can do a ping or tftpboot.
+network settings accordingly, you can do a ping or tftpboot.
 
-If you have mapped a cramfs image try mounting it with
+If you have mapped a cramfs image, try mounting it with
 
   # mkdir /cram
   # mount /dev/fd0 cramfs /cram
-- 
2.28.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH v3] bootm: add global.bootm.root_dev env var for booting via PARTUUID

2020-08-20 Thread Robert Karszniewicz

On 8/20/20 9:05 AM, Sascha Hauer wrote:

On Mon, Aug 10, 2020 at 02:20:08PM +0200, Robert Karszniewicz wrote:

Introduces a new env var which specifies which device is the rootfs
device to be used in Linux, passed to Linux via bootargs, identified by
the rootfs partition's PARTUUID.

global.bootm.root_dev supplements global.bootm.appendroot, in that it
overrides appendroot's naïve default, which picks the partition that the
kernel resides on (global.bootm.image).

Example:
detect mmc2
global.bootm.image='/mnt/mmc2.0/zImage'
global.bootm.appendroot=1
global.bootm.root_dev=/dev/mmc2.1
boot mmc

Signed-off-by: Robert Karszniewicz 
---


Applied, thanks

Sascha



Thanks!

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH v3] bootm: add global.bootm.root_dev env var for booting via PARTUUID

2020-08-19 Thread Robert Karszniewicz

What's the status on this, please?

Greetings.

On 8/10/20 2:20 PM, Robert Karszniewicz wrote:

Introduces a new env var which specifies which device is the rootfs
device to be used in Linux, passed to Linux via bootargs, identified by
the rootfs partition's PARTUUID.

global.bootm.root_dev supplements global.bootm.appendroot, in that it
overrides appendroot's naïve default, which picks the partition that the
kernel resides on (global.bootm.image).

Example:
detect mmc2
global.bootm.image='/mnt/mmc2.0/zImage'
global.bootm.appendroot=1
global.bootm.root_dev=/dev/mmc2.1
boot mmc

Signed-off-by: Robert Karszniewicz 
---
Changes from v2:
- correct commit message line lengths

Changes from v1:
- minor commit message change

Changes from RFC v2:
- replaced path_get_linux_rootarg("invalid") by ERR_PTR(-EINVAL)
- added error messages. (I've made them mutually exclusive to prevent
   NULL-pointer dereference)

  common/bootm.c  | 25 +++--
  include/bootm.h |  2 ++
  2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 8fec1ee34dd8..7f951172ccf5 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -64,6 +64,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
getenv_ul("global.bootm.image.loadaddr", &data->os_address);
getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
data->initrd_file = getenv_nonempty("global.bootm.initrd");
+   data->root_dev = getenv_nonempty("global.bootm.root_dev");
data->verify = bootm_get_verify_mode();
data->appendroot = bootm_appendroot;
data->provide_machine_id = bootm_provide_machine_id;
@@ -655,7 +656,25 @@ int bootm_boot(struct bootm_data *bootm_data)
if (bootm_data->appendroot) {
char *rootarg;
  
-		rootarg = path_get_linux_rootarg(data->os_file);

+   if (bootm_data->root_dev) {
+   const char *root_dev_name = 
devpath_to_name(bootm_data->root_dev);
+   const struct cdev *root_cdev = 
cdev_by_name(root_dev_name);
+
+   if (root_cdev && root_cdev->partuuid[0] != 0) {
+   rootarg = basprintf("root=PARTUUID=%s", 
root_cdev->partuuid);
+   } else {
+   rootarg = ERR_PTR(-EINVAL);
+
+   if (!root_cdev)
+   pr_err("no cdev found for %s, cannot set 
root= option\n",
+   root_dev_name);
+   else if (!root_cdev->partuuid[0])
+   pr_err("%s doesn't have a PARTUUID, cannot 
set root= option\n",
+   root_dev_name);
+   }
+   } else {
+   rootarg = path_get_linux_rootarg(data->os_file);
+   }
if (!IS_ERR(rootarg)) {
printf("Adding \"%s\" to Kernel commandline\n", 
rootarg);
globalvar_add_simple("linux.bootargs.bootm.appendroot",
@@ -742,6 +761,7 @@ static int bootm_init(void)
globalvar_add_simple("bootm.image", NULL);
globalvar_add_simple("bootm.image.loadaddr", NULL);
globalvar_add_simple("bootm.oftree", NULL);
+   globalvar_add_simple("bootm.root_dev", NULL);
globalvar_add_simple("bootm.tee", NULL);
globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
globalvar_add_simple_bool("bootm.provide_machine_id", 
&bootm_provide_machine_id);
@@ -771,5 +791,6 @@ BAREBOX_MAGICVAR_NAMED(global_bootm_oftree, global.bootm.oftree, 
"bootm default
  BAREBOX_MAGICVAR_NAMED(global_bootm_tee, global.bootm.tee, "bootm default tee 
image");
  BAREBOX_MAGICVAR_NAMED(global_bootm_verify, global.bootm.verify, "bootm default 
verify level");
  BAREBOX_MAGICVAR_NAMED(global_bootm_verbose, global.bootm.verbose, "bootm default 
verbosity level (0=quiet)");
-BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add root= 
option to Kernel to mount rootfs from the device the Kernel comes from");
+BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add root= 
option to Kernel to mount rootfs from the device the Kernel comes from (default, device 
can be overridden via global.bootm.root_dev)");
+BAREBOX_MAGICVAR_NAMED(global_bootm_root_dev, global.bootm.root_dev, "bootm default 
root device (overrides default device in global.bootm.appendroot)");
  BAREBOX_MAGICVAR_NAMED(global_bootm_provide_machine_id, 
global.bootm.prov

[PATCH v3] bootm: add global.bootm.root_dev env var for booting via PARTUUID

2020-08-10 Thread Robert Karszniewicz
Introduces a new env var which specifies which device is the rootfs
device to be used in Linux, passed to Linux via bootargs, identified by
the rootfs partition's PARTUUID.

global.bootm.root_dev supplements global.bootm.appendroot, in that it
overrides appendroot's naïve default, which picks the partition that the
kernel resides on (global.bootm.image).

Example:
detect mmc2
global.bootm.image='/mnt/mmc2.0/zImage'
global.bootm.appendroot=1
global.bootm.root_dev=/dev/mmc2.1
boot mmc

Signed-off-by: Robert Karszniewicz 
---
Changes from v2:
- correct commit message line lengths

Changes from v1:
- minor commit message change

Changes from RFC v2:
- replaced path_get_linux_rootarg("invalid") by ERR_PTR(-EINVAL)
- added error messages. (I've made them mutually exclusive to prevent
  NULL-pointer dereference)

 common/bootm.c  | 25 +++--
 include/bootm.h |  2 ++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 8fec1ee34dd8..7f951172ccf5 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -64,6 +64,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
getenv_ul("global.bootm.image.loadaddr", &data->os_address);
getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
data->initrd_file = getenv_nonempty("global.bootm.initrd");
+   data->root_dev = getenv_nonempty("global.bootm.root_dev");
data->verify = bootm_get_verify_mode();
data->appendroot = bootm_appendroot;
data->provide_machine_id = bootm_provide_machine_id;
@@ -655,7 +656,25 @@ int bootm_boot(struct bootm_data *bootm_data)
if (bootm_data->appendroot) {
char *rootarg;
 
-   rootarg = path_get_linux_rootarg(data->os_file);
+   if (bootm_data->root_dev) {
+   const char *root_dev_name = 
devpath_to_name(bootm_data->root_dev);
+   const struct cdev *root_cdev = 
cdev_by_name(root_dev_name);
+
+   if (root_cdev && root_cdev->partuuid[0] != 0) {
+   rootarg = basprintf("root=PARTUUID=%s", 
root_cdev->partuuid);
+   } else {
+   rootarg = ERR_PTR(-EINVAL);
+
+   if (!root_cdev)
+   pr_err("no cdev found for %s, cannot 
set root= option\n",
+   root_dev_name);
+   else if (!root_cdev->partuuid[0])
+   pr_err("%s doesn't have a PARTUUID, 
cannot set root= option\n",
+   root_dev_name);
+   }
+   } else {
+   rootarg = path_get_linux_rootarg(data->os_file);
+   }
if (!IS_ERR(rootarg)) {
printf("Adding \"%s\" to Kernel commandline\n", 
rootarg);
globalvar_add_simple("linux.bootargs.bootm.appendroot",
@@ -742,6 +761,7 @@ static int bootm_init(void)
globalvar_add_simple("bootm.image", NULL);
globalvar_add_simple("bootm.image.loadaddr", NULL);
globalvar_add_simple("bootm.oftree", NULL);
+   globalvar_add_simple("bootm.root_dev", NULL);
globalvar_add_simple("bootm.tee", NULL);
globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
globalvar_add_simple_bool("bootm.provide_machine_id", 
&bootm_provide_machine_id);
@@ -771,5 +791,6 @@ BAREBOX_MAGICVAR_NAMED(global_bootm_oftree, 
global.bootm.oftree, "bootm default
 BAREBOX_MAGICVAR_NAMED(global_bootm_tee, global.bootm.tee, "bootm default tee 
image");
 BAREBOX_MAGICVAR_NAMED(global_bootm_verify, global.bootm.verify, "bootm 
default verify level");
 BAREBOX_MAGICVAR_NAMED(global_bootm_verbose, global.bootm.verbose, "bootm 
default verbosity level (0=quiet)");
-BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add 
root= option to Kernel to mount rootfs from the device the Kernel comes from");
+BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add 
root= option to Kernel to mount rootfs from the device the Kernel comes from 
(default, device can be overridden via global.bootm.root_dev)");
+BAREBOX_MAGICVAR_NAMED(global_bootm_root_dev, global.bootm.root_dev, "bootm 
default root device (overrides default device in global.bootm.appendroot)");
 BAREBOX_MAGICVAR_NAMED(global_bootm_provide_machine_id, 
global.bootm.provide_machine_id, "If true, add systemd.machine_id= with value 
of global.machine_id to Kernel&qu

[PATCH v2] bootm: add global.bootm.root_dev env var for booting via PARTUUID

2020-08-10 Thread Robert Karszniewicz
Introduces a new env var which specifies which device is the rootfs device to
be used in Linux, passed to Linux via bootargs, identified by the rootfs
partition's PARTUUID.

global.bootm.root_dev supplements global.bootm.appendroot, in that it
overrides appendroot's naïve default, which picks the partition that the
kernel resides on (global.bootm.image).

Example:
detect mmc2
global.bootm.image='/mnt/mmc2.0/zImage'
global.bootm.appendroot=1
global.bootm.root_dev=/dev/mmc2.1
boot mmc

Signed-off-by: Robert Karszniewicz 
---
Changes from v1:
- minor commit message change

Changes from RFC v2:
- replaced path_get_linux_rootarg("invalid") by ERR_PTR(-EINVAL)
- added error messages. (I've made them mutually exclusive to prevent
  NULL-pointer dereference)

 common/bootm.c  | 25 +++--
 include/bootm.h |  2 ++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 8fec1ee34dd8..7f951172ccf5 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -64,6 +64,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
getenv_ul("global.bootm.image.loadaddr", &data->os_address);
getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
data->initrd_file = getenv_nonempty("global.bootm.initrd");
+   data->root_dev = getenv_nonempty("global.bootm.root_dev");
data->verify = bootm_get_verify_mode();
data->appendroot = bootm_appendroot;
data->provide_machine_id = bootm_provide_machine_id;
@@ -655,7 +656,25 @@ int bootm_boot(struct bootm_data *bootm_data)
if (bootm_data->appendroot) {
char *rootarg;
 
-   rootarg = path_get_linux_rootarg(data->os_file);
+   if (bootm_data->root_dev) {
+   const char *root_dev_name = 
devpath_to_name(bootm_data->root_dev);
+   const struct cdev *root_cdev = 
cdev_by_name(root_dev_name);
+
+   if (root_cdev && root_cdev->partuuid[0] != 0) {
+   rootarg = basprintf("root=PARTUUID=%s", 
root_cdev->partuuid);
+   } else {
+   rootarg = ERR_PTR(-EINVAL);
+
+   if (!root_cdev)
+   pr_err("no cdev found for %s, cannot 
set root= option\n",
+   root_dev_name);
+   else if (!root_cdev->partuuid[0])
+   pr_err("%s doesn't have a PARTUUID, 
cannot set root= option\n",
+   root_dev_name);
+   }
+   } else {
+   rootarg = path_get_linux_rootarg(data->os_file);
+   }
if (!IS_ERR(rootarg)) {
printf("Adding \"%s\" to Kernel commandline\n", 
rootarg);
globalvar_add_simple("linux.bootargs.bootm.appendroot",
@@ -742,6 +761,7 @@ static int bootm_init(void)
globalvar_add_simple("bootm.image", NULL);
globalvar_add_simple("bootm.image.loadaddr", NULL);
globalvar_add_simple("bootm.oftree", NULL);
+   globalvar_add_simple("bootm.root_dev", NULL);
globalvar_add_simple("bootm.tee", NULL);
globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
globalvar_add_simple_bool("bootm.provide_machine_id", 
&bootm_provide_machine_id);
@@ -771,5 +791,6 @@ BAREBOX_MAGICVAR_NAMED(global_bootm_oftree, 
global.bootm.oftree, "bootm default
 BAREBOX_MAGICVAR_NAMED(global_bootm_tee, global.bootm.tee, "bootm default tee 
image");
 BAREBOX_MAGICVAR_NAMED(global_bootm_verify, global.bootm.verify, "bootm 
default verify level");
 BAREBOX_MAGICVAR_NAMED(global_bootm_verbose, global.bootm.verbose, "bootm 
default verbosity level (0=quiet)");
-BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add 
root= option to Kernel to mount rootfs from the device the Kernel comes from");
+BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add 
root= option to Kernel to mount rootfs from the device the Kernel comes from 
(default, device can be overridden via global.bootm.root_dev)");
+BAREBOX_MAGICVAR_NAMED(global_bootm_root_dev, global.bootm.root_dev, "bootm 
default root device (overrides default device in global.bootm.appendroot)");
 BAREBOX_MAGICVAR_NAMED(global_bootm_provide_machine_id, 
global.bootm.provide_machine_id, "If true, add systemd.machine_id= with value 
of global.machine_id to Kernel");
diff --git a/include/bootm.h b/include/bootm.h
inde

[PATCH] bootm: add global.bootm.root_dev env var for booting via PARTUUID

2020-08-10 Thread Robert Karszniewicz
This patch introduces a new env var which specifies which device is the
rootfs device to be used in Linux, passed to Linux via bootargs,
identified by the rootfs partition's PARTUUID.

global.bootm.root_dev supplements global.bootm.appendroot, in that it
overrides appendroot's naïve default, which picks the partition that the
kernel resides on (global.bootm.image).

Example:
detect mmc2
global.bootm.image='/mnt/mmc2.0/zImage'
global.bootm.appendroot=1
global.bootm.root_dev=/dev/mmc2.1
boot mmc

Signed-off-by: Robert Karszniewicz 
---
Changes from RFC v2:
- replaced path_get_linux_rootarg("invalid") by ERR_PTR(-EINVAL)
- added error messages. (I've made them mutually exclusive to prevent
  NULL-pointer dereference)

 common/bootm.c  | 25 +++--
 include/bootm.h |  2 ++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 8fec1ee34dd8..7f951172ccf5 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -64,6 +64,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
getenv_ul("global.bootm.image.loadaddr", &data->os_address);
getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
data->initrd_file = getenv_nonempty("global.bootm.initrd");
+   data->root_dev = getenv_nonempty("global.bootm.root_dev");
data->verify = bootm_get_verify_mode();
data->appendroot = bootm_appendroot;
data->provide_machine_id = bootm_provide_machine_id;
@@ -655,7 +656,25 @@ int bootm_boot(struct bootm_data *bootm_data)
if (bootm_data->appendroot) {
char *rootarg;
 
-   rootarg = path_get_linux_rootarg(data->os_file);
+   if (bootm_data->root_dev) {
+   const char *root_dev_name = 
devpath_to_name(bootm_data->root_dev);
+   const struct cdev *root_cdev = 
cdev_by_name(root_dev_name);
+
+   if (root_cdev && root_cdev->partuuid[0] != 0) {
+   rootarg = basprintf("root=PARTUUID=%s", 
root_cdev->partuuid);
+   } else {
+   rootarg = ERR_PTR(-EINVAL);
+
+   if (!root_cdev)
+   pr_err("no cdev found for %s, cannot 
set root= option\n",
+   root_dev_name);
+   else if (!root_cdev->partuuid[0])
+   pr_err("%s doesn't have a PARTUUID, 
cannot set root= option\n",
+   root_dev_name);
+   }
+   } else {
+   rootarg = path_get_linux_rootarg(data->os_file);
+   }
if (!IS_ERR(rootarg)) {
printf("Adding \"%s\" to Kernel commandline\n", 
rootarg);
globalvar_add_simple("linux.bootargs.bootm.appendroot",
@@ -742,6 +761,7 @@ static int bootm_init(void)
globalvar_add_simple("bootm.image", NULL);
globalvar_add_simple("bootm.image.loadaddr", NULL);
globalvar_add_simple("bootm.oftree", NULL);
+   globalvar_add_simple("bootm.root_dev", NULL);
globalvar_add_simple("bootm.tee", NULL);
globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
globalvar_add_simple_bool("bootm.provide_machine_id", 
&bootm_provide_machine_id);
@@ -771,5 +791,6 @@ BAREBOX_MAGICVAR_NAMED(global_bootm_oftree, 
global.bootm.oftree, "bootm default
 BAREBOX_MAGICVAR_NAMED(global_bootm_tee, global.bootm.tee, "bootm default tee 
image");
 BAREBOX_MAGICVAR_NAMED(global_bootm_verify, global.bootm.verify, "bootm 
default verify level");
 BAREBOX_MAGICVAR_NAMED(global_bootm_verbose, global.bootm.verbose, "bootm 
default verbosity level (0=quiet)");
-BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add 
root= option to Kernel to mount rootfs from the device the Kernel comes from");
+BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add 
root= option to Kernel to mount rootfs from the device the Kernel comes from 
(default, device can be overridden via global.bootm.root_dev)");
+BAREBOX_MAGICVAR_NAMED(global_bootm_root_dev, global.bootm.root_dev, "bootm 
default root device (overrides default device in global.bootm.appendroot)");
 BAREBOX_MAGICVAR_NAMED(global_bootm_provide_machine_id, 
global.bootm.provide_machine_id, "If true, add systemd.machine_id= with value 
of global.machine_id to Kernel");
diff --git a/include/bootm.h b/include/bootm.h
index 7782de7a476d..3628a7eea5b9 100644
--- 

Re: [RFC PATCH v2 3/3] bootm: handle global.bootm.root_dev

2020-08-05 Thread Robert Karszniewicz

On 8/5/20 12:10 PM, Robert Karszniewicz wrote:

---
  common/bootm.c | 13 -
  1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/common/bootm.c b/common/bootm.c
index 73409bf9f70c..01b54ab93958 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -656,7 +656,18 @@ int bootm_boot(struct bootm_data *bootm_data)
if (bootm_data->appendroot) {
char *rootarg;
  
-		rootarg = path_get_linux_rootarg(data->os_file);

+   if (bootm_data->root_dev) {
+   const char *root_dev_name = 
devpath_to_name(bootm_data->root_dev);
+   const struct cdev *root_cdev = 
cdev_by_name(root_dev_name);
+
+   if (root_cdev && root_cdev->partuuid[0] != 0) {
+   rootarg = basprintf("root=PARTUUID=%s", 
root_cdev->partuuid);
+   } else {
+   rootarg = path_get_linux_rootarg("invalid");


Here I wasn't sure if I should be uniform and let the function return an 
error or just straight assign ERR_PTR(-EINVAL).



+   }
+   } else {
+   rootarg = path_get_linux_rootarg(data->os_file);
+   }
if (!IS_ERR(rootarg)) {
printf("Adding \"%s\" to Kernel commandline\n", 
rootarg);
globalvar_add_simple("linux.bootargs.bootm.appendroot",




___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC PATCH v2 3/3] bootm: handle global.bootm.root_dev

2020-08-05 Thread Robert Karszniewicz
---
 common/bootm.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/common/bootm.c b/common/bootm.c
index 73409bf9f70c..01b54ab93958 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -656,7 +656,18 @@ int bootm_boot(struct bootm_data *bootm_data)
if (bootm_data->appendroot) {
char *rootarg;
 
-   rootarg = path_get_linux_rootarg(data->os_file);
+   if (bootm_data->root_dev) {
+   const char *root_dev_name = 
devpath_to_name(bootm_data->root_dev);
+   const struct cdev *root_cdev = 
cdev_by_name(root_dev_name);
+
+   if (root_cdev && root_cdev->partuuid[0] != 0) {
+   rootarg = basprintf("root=PARTUUID=%s", 
root_cdev->partuuid);
+   } else {
+   rootarg = path_get_linux_rootarg("invalid");
+   }
+   } else {
+   rootarg = path_get_linux_rootarg(data->os_file);
+   }
if (!IS_ERR(rootarg)) {
printf("Adding \"%s\" to Kernel commandline\n", 
rootarg);
globalvar_add_simple("linux.bootargs.bootm.appendroot",
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC PATCH v2 2/3] globalvar: add bootm.root_dev

2020-08-05 Thread Robert Karszniewicz
---
 common/bootm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/bootm.c b/common/bootm.c
index 311d0e058321..73409bf9f70c 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -743,6 +743,7 @@ static int bootm_init(void)
globalvar_add_simple("bootm.image", NULL);
globalvar_add_simple("bootm.image.loadaddr", NULL);
globalvar_add_simple("bootm.oftree", NULL);
+   globalvar_add_simple("bootm.root_dev", NULL);
globalvar_add_simple("bootm.tee", NULL);
globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
globalvar_add_simple_bool("bootm.provide_machine_id", 
&bootm_provide_machine_id);
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC PATCH v2 0/3] Introduce global.bootm.root_dev env var for booting via PARTUUID

2020-08-05 Thread Robert Karszniewicz
This patch introduces a new env var which specifies which device is the
rootfs device to be used in Linux, passed to Linux via bootargs,
identified by the rootfs partition's PARTUUID.

global.bootm.root_dev supplements global.bootm.appendroot, in that it
overrides appendroot's naïve default, which picks the partition that the
kernel resides on (global.bootm.image).

Example:
detect mmc2
global.bootm.image='/mnt/mmc2.0/zImage'
global.bootm.appendroot=1
global.bootm.root_dev=/dev/mmc2.1
boot mmc

For proper patch, I would squash all commits.

Changes from v1:
- renamed env var s/root/root_dev/
- used filesystem-agnostic approach (root_dev now takes a /dev/ instead
  of a mounted partition)

Robert Karszniewicz (3):
  bootm: add env var root_dev
  globalvar: add bootm.root_dev
  bootm: handle global.bootm.root_dev

 common/bootm.c  | 18 --
 include/bootm.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC PATCH v2 1/3] bootm: add env var root_dev

2020-08-05 Thread Robert Karszniewicz
---
 common/bootm.c  | 4 +++-
 include/bootm.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/common/bootm.c b/common/bootm.c
index 8fec1ee34dd8..311d0e058321 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -64,6 +64,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
getenv_ul("global.bootm.image.loadaddr", &data->os_address);
getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
data->initrd_file = getenv_nonempty("global.bootm.initrd");
+   data->root_dev = getenv_nonempty("global.bootm.root_dev");
data->verify = bootm_get_verify_mode();
data->appendroot = bootm_appendroot;
data->provide_machine_id = bootm_provide_machine_id;
@@ -771,5 +772,6 @@ BAREBOX_MAGICVAR_NAMED(global_bootm_oftree, 
global.bootm.oftree, "bootm default
 BAREBOX_MAGICVAR_NAMED(global_bootm_tee, global.bootm.tee, "bootm default tee 
image");
 BAREBOX_MAGICVAR_NAMED(global_bootm_verify, global.bootm.verify, "bootm 
default verify level");
 BAREBOX_MAGICVAR_NAMED(global_bootm_verbose, global.bootm.verbose, "bootm 
default verbosity level (0=quiet)");
-BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add 
root= option to Kernel to mount rootfs from the device the Kernel comes from");
+BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add 
root= option to Kernel to mount rootfs from the device the Kernel comes from 
(default, device can be overridden via global.bootm.root_dev)");
+BAREBOX_MAGICVAR_NAMED(global_bootm_root_dev, global.bootm.root_dev, "bootm 
default root device (overrides default device in global.bootm.appendroot)");
 BAREBOX_MAGICVAR_NAMED(global_bootm_provide_machine_id, 
global.bootm.provide_machine_id, "If true, add systemd.machine_id= with value 
of global.machine_id to Kernel");
diff --git a/include/bootm.h b/include/bootm.h
index 7782de7a476d..3628a7eea5b9 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -18,6 +18,7 @@ struct bootm_data {
const char *initrd_file;
const char *oftree_file;
const char *tee_file;
+   const char *root_dev;
int verbose;
enum bootm_verify verify;
bool force;
@@ -25,6 +26,7 @@ struct bootm_data {
/*
 * appendroot - if true, try to add a suitable root= Kernel option to
 * mount the rootfs from the same device as the Kernel comes from.
+* The default rootfs device can be overridden with root_dev.
 */
bool appendroot;
/*
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] ARM: boards: phytec-som-imx6: Add mmc and emmc-boot bbu update handler

2020-07-20 Thread Robert Karszniewicz
From: Stefan Riedmueller 

Add mmc and emmc-boot bbu update handler to update barebox on SD card
and eMMC boot partitions easily.

Signed-off-by: Stefan Riedmueller 
Signed-off-by: Robert Karszniewicz 
---
 arch/arm/boards/phytec-som-imx6/board.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/boards/phytec-som-imx6/board.c 
b/arch/arm/boards/phytec-som-imx6/board.c
index a59552b95c5f..bac3e8a8a1c8 100644
--- a/arch/arm/boards/phytec-som-imx6/board.c
+++ b/arch/arm/boards/phytec-som-imx6/board.c
@@ -161,12 +161,18 @@ static int physom_imx6_devices_init(void)
default_environment_path = "/chosen/environment-spinor";
default_envdev = "SPI NOR flash";
 
+   imx6_bbu_internal_mmc_register_handler("mmc2",
+   "/dev/mmc2", 0);
+
} else if (of_machine_is_compatible("phytec,imx6q-pcaaxl3")) {
 
barebox_set_hostname("phyCARD-i.MX6");
default_environment_path = "/chosen/environment-nand";
default_envdev = "NAND flash";
 
+   imx6_bbu_internal_mmc_register_handler("mmc2",
+   "/dev/mmc2", 0);
+
} else if (of_machine_is_compatible("phytec,imx6q-pcm058-nand")
|| of_machine_is_compatible("phytec,imx6q-pcm058-emmc")
|| of_machine_is_compatible("phytec,imx6dl-pcm058-nand")
@@ -180,6 +186,9 @@ static int physom_imx6_devices_init(void)
default_environment_path = "/chosen/environment-spinor";
default_envdev = "SPI NOR flash";
 
+   imx6_bbu_internal_mmc_register_handler("mmc0",
+   "/dev/mmc0", 0);
+
} else if (of_machine_is_compatible("phytec,imx6ul-pcl063-nand")
|| of_machine_is_compatible("phytec,imx6ul-pcl063-emmc")) {
barebox_set_hostname("phyCORE-i.MX6UL");
@@ -189,6 +198,9 @@ static int physom_imx6_devices_init(void)
phy_register_fixup_for_uid(PHY_ID_KSZ8081, MICREL_PHY_ID_MASK,
ksz8081_phy_fixup);
 
+   imx6_bbu_internal_mmc_register_handler("mmc0",
+   "/dev/mmc0", 0);
+
} else
return 0;
 
@@ -227,10 +239,14 @@ static int physom_imx6_devices_init(void)
imx6_bbu_internal_mmc_register_handler("mmc3",
"/dev/mmc3",
BBU_HANDLER_FLAG_DEFAULT);
+   imx6_bbu_internal_mmcboot_register_handler("mmc3-boot",
+   "mmc3", 0);
} else if (of_machine_is_compatible("phytec,imx6ul-pcl063-emmc")) {
imx6_bbu_internal_mmc_register_handler("mmc1",
"/dev/mmc1",
BBU_HANDLER_FLAG_DEFAULT);
+   imx6_bbu_internal_mmcboot_register_handler("mmc1-boot",
+   "mmc1", 0);
} else {
imx6_bbu_nand_register_handler("nand", 
BBU_HANDLER_FLAG_DEFAULT);
}
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [RFC PATCH 0/4] Introduce global.bootm.root env var for booting via PARTUUID

2020-07-13 Thread Robert Karszniewicz

On 7/9/20 4:14 PM, Sascha Hauer wrote:

On Tue, Jun 30, 2020 at 03:48:30PM +0200, Robert Karszniewicz wrote:

This patch introduces a new env var which specifies which device
is the rootfs device to be used in Linux, passed to Linux via bootargs,
identified by the rootfs partition's PARTUUID.

global.bootm.root supplements global.bootm.appendroot, in that it overrides
appendroot's naïve default, which picks the partition that the kernel resides
on (global.bootm.image).

I don't know if it is the right way, or a good way, but this is the shortest
and simplest way that I've found.

What do you think of this? And is it generally something that would be
accepted, or is this out of scope for barebox?

Example:
detect mmc2
global.bootm.image='/mnt/mmc2.0/zImage'
global.bootm.appendroot=1
global.bootm.root='/mnt/mmc2.1/'




Generally, this was just the shortest possible way to make it basically 
work, before I knew if such a feature would be accepted at all.



Why do you pass the standard mount path here? I would expect /dev/mmc2.1.



Agree.


In 4/4 you mount the root device. I think this should be avoided as it


Agree.


only works when barebox has support for the rootfs, i.e. it doesn't work
for XFS or the like.



I see.


Ok, fsdev_set_linux_rootarg() is tied to a filesystem, so maybe we need
something similar for a cdev.

Generally I think barebox should support this usecase, but I am not
convinced the approach you took is the right API.



So do I understand it correctly, that doing it via a new 'root_dev' 
variable is fine, just that the implementation needs to be better?



Sascha



Robert

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/2] ARM: configs: imx_v7_defconfig: Add state framework

2020-07-07 Thread Robert Karszniewicz
From: Daniel Schultz 

Signed-off-by: Daniel Schultz 
Signed-off-by: Robert Karszniewicz 
---
 arch/arm/configs/imx_v7_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/configs/imx_v7_defconfig 
b/arch/arm/configs/imx_v7_defconfig
index 24bdc0122c6a..ad5d43a68b62 100644
--- a/arch/arm/configs/imx_v7_defconfig
+++ b/arch/arm/configs/imx_v7_defconfig
@@ -65,6 +65,7 @@ CONFIG_BLSPEC=y
 CONFIG_CONSOLE_ACTIVATE_NONE=y
 CONFIG_PARTITION_DISK_EFI=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_STATE=y
 CONFIG_RESET_SOURCE=y
 CONFIG_FASTBOOT_CMD_OEM=y
 CONFIG_CMD_DMESG=y
@@ -127,6 +128,7 @@ CONFIG_CMD_OF_NODE=y
 CONFIG_CMD_OF_PROPERTY=y
 CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_STATE=y
 CONFIG_NET=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
@@ -173,6 +175,7 @@ CONFIG_MFD_DA9063=y
 CONFIG_MFD_MC34704=y
 CONFIG_MFD_MC9SDZ60=y
 CONFIG_MFD_STMPE=y
+CONFIG_STATE_DRV=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_GPIO_OF=y
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] ARM: configs: imx_v7_defconfig: Add bootchooser

2020-07-07 Thread Robert Karszniewicz
From: Daniel Schultz 

Signed-off-by: Daniel Schultz 
Signed-off-by: Robert Karszniewicz 
---
 arch/arm/configs/imx_v7_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/imx_v7_defconfig 
b/arch/arm/configs/imx_v7_defconfig
index ad5d43a68b62..76bf63bb2065 100644
--- a/arch/arm/configs/imx_v7_defconfig
+++ b/arch/arm/configs/imx_v7_defconfig
@@ -66,6 +66,7 @@ CONFIG_CONSOLE_ACTIVATE_NONE=y
 CONFIG_PARTITION_DISK_EFI=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_STATE=y
+CONFIG_BOOTCHOOSER=y
 CONFIG_RESET_SOURCE=y
 CONFIG_FASTBOOT_CMD_OEM=y
 CONFIG_CMD_DMESG=y
@@ -129,6 +130,7 @@ CONFIG_CMD_OF_PROPERTY=y
 CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_STATE=y
+CONFIG_CMD_BOOTCHOOSER=y
 CONFIG_NET=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] ARM: configs: Update configs to use new Kconfig FASTBOOT_* names

2020-07-07 Thread Robert Karszniewicz
Some Kconfig symbols have been moved and renamed in commit
2879373370eb ("fastboot: split generic code from USB gadget")

Signed-off-by: Robert Karszniewicz 
---
I used `make savedefconfig` to make Kbuild move them to the new place.

 arch/arm/configs/imx23_defconfig | 2 +-
 arch/arm/configs/imx28_defconfig | 2 +-
 arch/arm/configs/imx_v7_defconfig| 2 +-
 arch/arm/configs/imx_v8_defconfig| 2 +-
 arch/arm/configs/kindle-mx50_defconfig   | 2 +-
 arch/arm/configs/omap_defconfig  | 2 +-
 arch/arm/configs/zii_vf610_dev_defconfig | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm/configs/imx23_defconfig b/arch/arm/configs/imx23_defconfig
index bff9c08c4027..48bf14a39006 100644
--- a/arch/arm/configs/imx23_defconfig
+++ b/arch/arm/configs/imx23_defconfig
@@ -22,6 +22,7 @@ CONFIG_BLSPEC=y
 CONFIG_CONSOLE_ALLOW_COLOR=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_RESET_SOURCE=y
+CONFIG_FASTBOOT_CMD_OEM=y
 CONFIG_CMD_DMESG=y
 CONFIG_LONGHELP=y
 CONFIG_CMD_IOMEM=y
@@ -90,7 +91,6 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_DFU=y
 CONFIG_USB_GADGET_SERIAL=y
 CONFIG_USB_GADGET_FASTBOOT=y
-CONFIG_USB_GADGET_FASTBOOT_CMD_OEM=y
 CONFIG_VIDEO=y
 CONFIG_DRIVER_VIDEO_STM=y
 CONFIG_MCI=y
diff --git a/arch/arm/configs/imx28_defconfig b/arch/arm/configs/imx28_defconfig
index 4442c79cc4d9..beb0bc2f7666 100644
--- a/arch/arm/configs/imx28_defconfig
+++ b/arch/arm/configs/imx28_defconfig
@@ -25,6 +25,7 @@ CONFIG_CONSOLE_ALLOW_COLOR=y
 CONFIG_PBL_CONSOLE=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_RESET_SOURCE=y
+CONFIG_FASTBOOT_CMD_OEM=y
 CONFIG_CMD_DMESG=y
 CONFIG_LONGHELP=y
 CONFIG_CMD_IOMEM=y
@@ -105,7 +106,6 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_DFU=y
 CONFIG_USB_GADGET_SERIAL=y
 CONFIG_USB_GADGET_FASTBOOT=y
-CONFIG_USB_GADGET_FASTBOOT_CMD_OEM=y
 CONFIG_VIDEO=y
 CONFIG_DRIVER_VIDEO_STM=y
 CONFIG_MCI=y
diff --git a/arch/arm/configs/imx_v7_defconfig 
b/arch/arm/configs/imx_v7_defconfig
index d89ac1e3490c..24bdc0122c6a 100644
--- a/arch/arm/configs/imx_v7_defconfig
+++ b/arch/arm/configs/imx_v7_defconfig
@@ -66,6 +66,7 @@ CONFIG_CONSOLE_ACTIVATE_NONE=y
 CONFIG_PARTITION_DISK_EFI=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_RESET_SOURCE=y
+CONFIG_FASTBOOT_CMD_OEM=y
 CONFIG_CMD_DMESG=y
 CONFIG_LONGHELP=y
 CONFIG_CMD_IOMEM=y
@@ -159,7 +160,6 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_DFU=y
 CONFIG_USB_GADGET_SERIAL=y
 CONFIG_USB_GADGET_FASTBOOT=y
-CONFIG_USB_GADGET_FASTBOOT_CMD_OEM=y
 CONFIG_VIDEO=y
 CONFIG_DRIVER_VIDEO_IMX_IPUV3=y
 CONFIG_DRIVER_VIDEO_IMX_IPUV3_LVDS=y
diff --git a/arch/arm/configs/imx_v8_defconfig 
b/arch/arm/configs/imx_v8_defconfig
index 06fb4060848b..b96867ad0ce9 100644
--- a/arch/arm/configs/imx_v8_defconfig
+++ b/arch/arm/configs/imx_v8_defconfig
@@ -25,6 +25,7 @@ CONFIG_CONSOLE_RATP=y
 CONFIG_PARTITION_DISK_EFI=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_RESET_SOURCE=y
+CONFIG_FASTBOOT_SPARSE=y
 CONFIG_CMD_DMESG=y
 CONFIG_LONGHELP=y
 CONFIG_CMD_IOMEM=y
@@ -106,7 +107,6 @@ CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_SERIAL=y
 CONFIG_USB_GADGET_FASTBOOT=y
-CONFIG_USB_GADGET_FASTBOOT_SPARSE=y
 CONFIG_MCI=y
 CONFIG_MCI_MMC_BOOT_PARTITIONS=y
 CONFIG_MCI_IMX_ESDHC=y
diff --git a/arch/arm/configs/kindle-mx50_defconfig 
b/arch/arm/configs/kindle-mx50_defconfig
index 855daef71ad7..552b2d6d331c 100644
--- a/arch/arm/configs/kindle-mx50_defconfig
+++ b/arch/arm/configs/kindle-mx50_defconfig
@@ -20,6 +20,7 @@ CONFIG_BOOTM_OFTREE=y
 CONFIG_CONSOLE_ACTIVATE_ALL=y
 CONFIG_CONSOLE_ALLOW_COLOR=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_FASTBOOT_CMD_OEM=y
 CONFIG_CMD_DMESG=y
 CONFIG_LONGHELP=y
 CONFIG_CMD_MEMINFO=y
@@ -50,7 +51,6 @@ CONFIG_USB_EHCI=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_SERIAL=y
 CONFIG_USB_GADGET_FASTBOOT=y
-CONFIG_USB_GADGET_FASTBOOT_CMD_OEM=y
 CONFIG_MCI=y
 CONFIG_MCI_STARTUP=y
 CONFIG_MCI_MMC_BOOT_PARTITIONS=y
diff --git a/arch/arm/configs/omap_defconfig b/arch/arm/configs/omap_defconfig
index 9d71d0274435..59892cb231b6 100644
--- a/arch/arm/configs/omap_defconfig
+++ b/arch/arm/configs/omap_defconfig
@@ -34,6 +34,7 @@ CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_STATE=y
 CONFIG_BOOTCHOOSER=y
 CONFIG_RESET_SOURCE=y
+CONFIG_FASTBOOT_CMD_OEM=y
 CONFIG_LONGHELP=y
 CONFIG_CMD_IOMEM=y
 CONFIG_CMD_MEMINFO=y
@@ -121,7 +122,6 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_DFU=y
 CONFIG_USB_GADGET_SERIAL=y
 CONFIG_USB_GADGET_FASTBOOT=y
-CONFIG_USB_GADGET_FASTBOOT_CMD_OEM=y
 CONFIG_USB_MUSB=y
 CONFIG_USB_MUSB_AM335X=y
 CONFIG_USB_MUSB_HOST=y
diff --git a/arch/arm/configs/zii_vf610_dev_defconfig 
b/arch/arm/configs/zii_vf610_dev_defconfig
index 7161d740ac1c..45c24d6df471 100644
--- a/arch/arm/configs/zii_vf610_dev_defconfig
+++ b/arch/arm/configs/zii_vf610_dev_defconfig
@@ -22,6 +22,7 @@ CONFIG_CONSOLE_RATP=y
 CONFIG_PARTITION_DISK_EFI=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_RESET_SOURCE=y
+CONFIG_FASTBOOT_CMD_OEM=y
 CONFIG_CMD_DMESG=y
 CONFIG_LONGHELP=y
 CONFIG_C

[PATCH] ARM: configs: Remove unused Kconfig symbol 'NAND_IMX_BBM'

2020-07-06 Thread Robert Karszniewicz
This Kconfig symbol has been removed in
2ad441bb7e78 ("mtd: nand-imx: Create BBT automatically when necessary")

Signed-off-by: Robert Karszniewicz 
---
 arch/arm/configs/eukrea_cpuimx35_defconfig| 1 -
 arch/arm/configs/freescale-mx21-ads_defconfig | 1 -
 arch/arm/configs/imx_defconfig| 1 -
 arch/arm/configs/imx_v7_defconfig | 1 -
 4 files changed, 4 deletions(-)

diff --git a/arch/arm/configs/eukrea_cpuimx35_defconfig 
b/arch/arm/configs/eukrea_cpuimx35_defconfig
index bd19fc45aa11..b3d5741c6978 100644
--- a/arch/arm/configs/eukrea_cpuimx35_defconfig
+++ b/arch/arm/configs/eukrea_cpuimx35_defconfig
@@ -74,7 +74,6 @@ CONFIG_MTD_RAW_DEVICE=y
 CONFIG_NAND=y
 CONFIG_NAND_ALLOW_ERASE_BAD=y
 CONFIG_NAND_IMX=y
-CONFIG_NAND_IMX_BBM=y
 CONFIG_USB_HOST=y
 CONFIG_USB_IMX_CHIPIDEA=y
 CONFIG_USB_EHCI=y
diff --git a/arch/arm/configs/freescale-mx21-ads_defconfig 
b/arch/arm/configs/freescale-mx21-ads_defconfig
index 7dc8cb142687..e1843db3e24c 100644
--- a/arch/arm/configs/freescale-mx21-ads_defconfig
+++ b/arch/arm/configs/freescale-mx21-ads_defconfig
@@ -36,5 +36,4 @@ CONFIG_DRIVER_CFI=y
 CONFIG_CFI_BUFFER_WRITE=y
 CONFIG_NAND=y
 CONFIG_NAND_IMX=y
-CONFIG_NAND_IMX_BBM=y
 CONFIG_FS_TFTP=y
diff --git a/arch/arm/configs/imx_defconfig b/arch/arm/configs/imx_defconfig
index ede70d7eaf9a..02e33e122ec8 100644
--- a/arch/arm/configs/imx_defconfig
+++ b/arch/arm/configs/imx_defconfig
@@ -90,7 +90,6 @@ CONFIG_NAND=y
 # CONFIG_NAND_ECC_HW_SYNDROME is not set
 CONFIG_NAND_ALLOW_ERASE_BAD=y
 CONFIG_NAND_IMX=y
-CONFIG_NAND_IMX_BBM=y
 CONFIG_MTD_UBI=y
 CONFIG_MTD_UBI_FASTMAP=y
 CONFIG_USB_HOST=y
diff --git a/arch/arm/configs/imx_v7_defconfig 
b/arch/arm/configs/imx_v7_defconfig
index 5bf908ee850c..d89ac1e3490c 100644
--- a/arch/arm/configs/imx_v7_defconfig
+++ b/arch/arm/configs/imx_v7_defconfig
@@ -143,7 +143,6 @@ CONFIG_MTD_SST25L=y
 CONFIG_NAND=y
 CONFIG_NAND_ALLOW_ERASE_BAD=y
 CONFIG_NAND_IMX=y
-CONFIG_NAND_IMX_BBM=y
 CONFIG_NAND_MXS=y
 CONFIG_MTD_UBI=y
 CONFIG_MTD_UBI_FASTMAP=y
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [RFC PATCH 0/4] Introduce global.bootm.root env var for booting via PARTUUID

2020-06-30 Thread Robert Karszniewicz
The problem is that we want to be able to have the rootfs and kernel on 
separate partitions. We've looked into the Boot Loader Specification, 
but from what we saw, it makes A-B systems difficult (according to the 
spec, there can only be one "$BOOT" filesystem on a device).


For reference: https://systemd.io/BOOT_LOADER_SPECIFICATION/

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC PATCH 0/4] Introduce global.bootm.root env var for booting via PARTUUID

2020-06-30 Thread Robert Karszniewicz
This patch introduces a new env var which specifies which device
is the rootfs device to be used in Linux, passed to Linux via bootargs,
identified by the rootfs partition's PARTUUID.

global.bootm.root supplements global.bootm.appendroot, in that it overrides
appendroot's naïve default, which picks the partition that the kernel resides
on (global.bootm.image).

I don't know if it is the right way, or a good way, but this is the shortest
and simplest way that I've found.

What do you think of this? And is it generally something that would be
accepted, or is this out of scope for barebox?

Example:
detect mmc2
global.bootm.image='/mnt/mmc2.0/zImage'
global.bootm.appendroot=1
global.bootm.root='/mnt/mmc2.1/'
boot mmc

Note that the trailing slash is important.
See comment in follow_automount() in fs/fs.c

Robert Karszniewicz (4):
  bootm: add env var root_dev
  globalvar: add bootm.root
  bootm: handle global.bootm.root
  bootm: mount root device before accessing linux_rootarg

 common/bootm.c  | 13 +++--
 include/bootm.h |  2 ++
 2 files changed, 13 insertions(+), 2 deletions(-)

-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC PATCH 1/4] bootm: add env var root_dev

2020-06-30 Thread Robert Karszniewicz
---
 common/bootm.c  | 4 +++-
 include/bootm.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/common/bootm.c b/common/bootm.c
index 8fec1ee34dd8..af9f9b8f447d 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -64,6 +64,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
getenv_ul("global.bootm.image.loadaddr", &data->os_address);
getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
data->initrd_file = getenv_nonempty("global.bootm.initrd");
+   data->root_dev = getenv_nonempty("global.bootm.root");
data->verify = bootm_get_verify_mode();
data->appendroot = bootm_appendroot;
data->provide_machine_id = bootm_provide_machine_id;
@@ -771,5 +772,6 @@ BAREBOX_MAGICVAR_NAMED(global_bootm_oftree, 
global.bootm.oftree, "bootm default
 BAREBOX_MAGICVAR_NAMED(global_bootm_tee, global.bootm.tee, "bootm default tee 
image");
 BAREBOX_MAGICVAR_NAMED(global_bootm_verify, global.bootm.verify, "bootm 
default verify level");
 BAREBOX_MAGICVAR_NAMED(global_bootm_verbose, global.bootm.verbose, "bootm 
default verbosity level (0=quiet)");
-BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add 
root= option to Kernel to mount rootfs from the device the Kernel comes from");
+BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add 
root= option to Kernel to mount rootfs from the device the Kernel comes from 
(default, device can be overridden via global.bootm.root)");
+BAREBOX_MAGICVAR_NAMED(global_bootm_root, global.bootm.root, "bootm default 
root device (overrides default device in global.bootm.appendroot)");
 BAREBOX_MAGICVAR_NAMED(global_bootm_provide_machine_id, 
global.bootm.provide_machine_id, "If true, add systemd.machine_id= with value 
of global.machine_id to Kernel");
diff --git a/include/bootm.h b/include/bootm.h
index 7782de7a476d..3628a7eea5b9 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -18,6 +18,7 @@ struct bootm_data {
const char *initrd_file;
const char *oftree_file;
const char *tee_file;
+   const char *root_dev;
int verbose;
enum bootm_verify verify;
bool force;
@@ -25,6 +26,7 @@ struct bootm_data {
/*
 * appendroot - if true, try to add a suitable root= Kernel option to
 * mount the rootfs from the same device as the Kernel comes from.
+* The default rootfs device can be overridden with root_dev.
 */
bool appendroot;
/*
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC PATCH 3/4] bootm: handle global.bootm.root

2020-06-30 Thread Robert Karszniewicz
---
 common/bootm.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/common/bootm.c b/common/bootm.c
index 3772fa4c2c51..1a9ef0673e55 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -656,7 +656,11 @@ int bootm_boot(struct bootm_data *bootm_data)
if (bootm_data->appendroot) {
char *rootarg;
 
-   rootarg = path_get_linux_rootarg(data->os_file);
+   if (bootm_data->root_dev) {
+   rootarg = path_get_linux_rootarg(bootm_data->root_dev);
+   } else {
+   rootarg = path_get_linux_rootarg(data->os_file);
+   }
if (!IS_ERR(rootarg)) {
printf("Adding \"%s\" to Kernel commandline\n", 
rootarg);
globalvar_add_simple("linux.bootargs.bootm.appendroot",
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC PATCH 4/4] bootm: mount root device before accessing linux_rootarg

2020-06-30 Thread Robert Karszniewicz
---
 common/bootm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/bootm.c b/common/bootm.c
index 1a9ef0673e55..b7c15cac0ba4 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -657,6 +657,8 @@ int bootm_boot(struct bootm_data *bootm_data)
char *rootarg;
 
if (bootm_data->root_dev) {
+   struct stat s;
+   stat(bootm_data->root_dev, &s); /* mount root device */
rootarg = path_get_linux_rootarg(bootm_data->root_dev);
} else {
rootarg = path_get_linux_rootarg(data->os_file);
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC PATCH 2/4] globalvar: add bootm.root

2020-06-30 Thread Robert Karszniewicz
---
 common/bootm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/bootm.c b/common/bootm.c
index af9f9b8f447d..3772fa4c2c51 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -743,6 +743,7 @@ static int bootm_init(void)
globalvar_add_simple("bootm.image", NULL);
globalvar_add_simple("bootm.image.loadaddr", NULL);
globalvar_add_simple("bootm.oftree", NULL);
+   globalvar_add_simple("bootm.root", NULL);
globalvar_add_simple("bootm.tee", NULL);
globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
globalvar_add_simple_bool("bootm.provide_machine_id", 
&bootm_provide_machine_id);
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] blspec: Allow the "options" key to be given multiple times

2020-05-18 Thread Robert Karszniewicz
The Boot Loader Spec says:
"This key is optional and may appear more than once in which case all
specified parameters are used in the order they are listed."

Signed-off-by: Robert Karszniewicz 
---
 common/blspec.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/common/blspec.c b/common/blspec.c
index 1a6d581..3be26d0 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -298,6 +298,18 @@ static struct blspec_entry *blspec_entry_open(struct 
bootentries *bootentries,
 
val = end;
 
+   if (!strcmp(name, "options")) {
+   /* If there was a previous "options" key given, prepend 
its value
+* (as per spec). */
+   char *prev_val = blspec_entry_var_get(entry, name);
+   if (prev_val) {
+   char *opts = xasprintf("%s %s", prev_val, val);
+   blspec_entry_var_set(entry, name, opts);
+   free(opts);
+   continue;
+   }
+   }
+
blspec_entry_var_set(entry, name, val);
}
 
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] ARM: dts: imx6: phycard: remove baseboard compatible

2020-05-14 Thread Robert Karszniewicz
This devicetree isn't baseboard-specific, so keep it compatible at
SOM-level.

Signed-off-by: Robert Karszniewicz 
---
 arch/arm/dts/imx6q-phytec-phycard.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/imx6q-phytec-phycard.dts 
b/arch/arm/dts/imx6q-phytec-phycard.dts
index c06461c..b0e47e9 100644
--- a/arch/arm/dts/imx6q-phytec-phycard.dts
+++ b/arch/arm/dts/imx6q-phytec-phycard.dts
@@ -16,7 +16,7 @@
 
 / {
model = "PHYTEC phyCARD-i.MX6 Quad";
-   compatible = "phytec,imx6q-pbaa03", "phytec,imx6q-pcaaxl3", "fsl,imx6q";
+   compatible = "phytec,imx6q-pcaaxl3", "fsl,imx6q";
 
chosen {
stdout-path = &uart3;
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] usb: storage: Increase retries for usb_stor_transport()

2019-11-04 Thread Robert Karszniewicz

On 11/4/19 4:21 PM, Marco Felsch wrote:

Hi Robert,

On 19-11-04 15:59, Robert Karszniewicz wrote:

On 11/4/19 3:54 PM, Marco Felsch wrote:

Hi Sascha,

On 19-11-04 10:42, Sascha Hauer wrote:

On Fri, Oct 25, 2019 at 05:56:08PM +0200, Robert Karszniewicz wrote:

This should make writing and reading more reliable.

Also:
- change loop condition to make "retries" semantically correct
- add a debug message in case of fatal failure
---
We've had problems writing (and even reading) a 10 MiB file from barebox
to multiple USB flash drives.
The 10 MiB file copy failed with "write: I/O error" almost every time.
Increasing the retry count made 100 MiB file copies succeed every time.



Doing this doesn't hurt, so I applied this patch. I wonder though if
there's something else wrong which makes increasing the retry counts
necessary.

Sascha


there is a missing sob is that okay with you? Robert can you add a
signed-off-by line?



Oops, I'm sorry for that! How do we handle this? Should I just amend and
resubmit the patch?


Resend as you already did is fine :) else you could reply with your
sob-tag.


Ok!



Regards,
   Marco


Regards,
Marco

___
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






___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2] usb: storage: Increase retries for usb_stor_transport()

2019-11-04 Thread Robert Karszniewicz
This should make writing and reading more reliable.

Also:
- change loop condition to make "retries" semantically correct
- add a debug message in case of fatal failure

Signed-off-by: Robert Karszniewicz 
---
 drivers/usb/storage/usb.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 63d624e..e0ef4f5 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -87,8 +87,7 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev,
struct device_d *dev = &us->pusb_dev->dev;
int i, ret;
 
-
-   for (i = 0; i < retries; i++) {
+   for (i = 0; i <= retries; i++) {
dev_dbg(dev, "%s\n", usb_stor_opcode_name(cmd[0]));
ret = us->transport(usb_blkdev, cmd, cmdlen, data, datalen);
dev_dbg(dev, "%s returns %d\n", usb_stor_opcode_name(cmd[0]),
@@ -105,6 +104,8 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev,
mdelay(request_sense_delay_ms);
}
 
+   dev_dbg(dev, "Retried %s %d times, and failed.\n", 
usb_stor_opcode_name(cmd[0]), retries);
+
return -EIO;
 }
 
@@ -194,7 +195,7 @@ static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 
opcode,
put_unaligned_be16(blocks, &cmd[7]);
 
return usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data,
- blocks * SECTOR_SIZE, 2, 0);
+ blocks * SECTOR_SIZE, 10, 0);
 }
 
 /***
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] usb: storage: Increase retries for usb_stor_transport()

2019-11-04 Thread Robert Karszniewicz

On 11/4/19 3:54 PM, Marco Felsch wrote:

Hi Sascha,

On 19-11-04 10:42, Sascha Hauer wrote:

On Fri, Oct 25, 2019 at 05:56:08PM +0200, Robert Karszniewicz wrote:

This should make writing and reading more reliable.

Also:
- change loop condition to make "retries" semantically correct
- add a debug message in case of fatal failure
---
We've had problems writing (and even reading) a 10 MiB file from barebox
to multiple USB flash drives.
The 10 MiB file copy failed with "write: I/O error" almost every time.
Increasing the retry count made 100 MiB file copies succeed every time.



Doing this doesn't hurt, so I applied this patch. I wonder though if
there's something else wrong which makes increasing the retry counts
necessary.

Sascha


there is a missing sob is that okay with you? Robert can you add a
signed-off-by line?



Oops, I'm sorry for that! How do we handle this? Should I just amend and 
resubmit the patch?



Regards,
   Marco

___
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


Re: [PATCH] usb: storage: Increase retries for usb_stor_transport()

2019-11-04 Thread Robert Karszniewicz

On 11/4/19 10:42 AM, Sascha Hauer wrote:

On Fri, Oct 25, 2019 at 05:56:08PM +0200, Robert Karszniewicz wrote:

This should make writing and reading more reliable.

Also:
- change loop condition to make "retries" semantically correct
- add a debug message in case of fatal failure
---
We've had problems writing (and even reading) a 10 MiB file from barebox
to multiple USB flash drives.
The 10 MiB file copy failed with "write: I/O error" almost every time.
Increasing the retry count made 100 MiB file copies succeed every time.



Doing this doesn't hurt, so I applied this patch. I wonder though if
there's something else wrong which makes increasing the retry counts
necessary.

Sascha




Thanks, yes, so I thought, too; it doesn't hurt, so I sent it in.

From when I looked at the problem, it seemed to me that the whole USB 
flash drives thing is fickle. I glanced at the USB storage drivers of 
Linux and saw that they have a bunch of workarounds and per-device 
quirks. So Linux' drivers simply seem more mature and tolerant than 
those in barebox.


Robert

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] test: usb: storage: Increase retries for usb_stor_transport()

2019-10-25 Thread Robert Karszniewicz
This should make writing and reading more reliable.

Also:
- change loop condition to make "retries" semantically correct
- add a debug message in case of fatal failure
---
And here is the test for how many retries were required at maximum. In case
anyone wants to try for themselves.

barebox:/ usb && mkdir /mnt/usb && mount /dev/disk0.0 /mnt/usb && echo 
'generating 100MiB file' && memcpy -s /dev/prng -d testfile 0x0 0x0 104857600 
&& echo 'writing file to drive' && cp testfile /mnt/usb/testfile && md5sum 
testfile /mnt/usb/testfile; ls -l testfile /mnt/usb/testfile

The highest max_retries for our three drives was 4. So 10 should be high enough.

 drivers/usb/storage/usb.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 63d624e..90e4492 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -86,9 +86,13 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev,
struct us_data *us = usb_blkdev->us;
struct device_d *dev = &us->pusb_dev->dev;
int i, ret;
+   static int max_retries = 0;
 
-
-   for (i = 0; i < retries; i++) {
+   for (i = 0; i <= retries; i++) {
+   if (cmd[0] == SCSI_WRITE10 && i > max_retries) {
+   max_retries = i;
+   printf("max_retries = %d\n", max_retries);
+   }
dev_dbg(dev, "%s\n", usb_stor_opcode_name(cmd[0]));
ret = us->transport(usb_blkdev, cmd, cmdlen, data, datalen);
dev_dbg(dev, "%s returns %d\n", usb_stor_opcode_name(cmd[0]),
@@ -105,6 +109,8 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev,
mdelay(request_sense_delay_ms);
}
 
+   dev_dbg(dev, "Retried %s %d times, and failed.\n", 
usb_stor_opcode_name(cmd[0]), retries);
+
return -EIO;
 }
 
@@ -194,7 +200,7 @@ static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 
opcode,
put_unaligned_be16(blocks, &cmd[7]);
 
return usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data,
- blocks * SECTOR_SIZE, 2, 0);
+ blocks * SECTOR_SIZE, 100, 0);
 }
 
 /***
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] usb: storage: Increase retries for usb_stor_transport()

2019-10-25 Thread Robert Karszniewicz
This should make writing and reading more reliable.

Also:
- change loop condition to make "retries" semantically correct
- add a debug message in case of fatal failure
---
We've had problems writing (and even reading) a 10 MiB file from barebox
to multiple USB flash drives.
The 10 MiB file copy failed with "write: I/O error" almost every time.
Increasing the retry count made 100 MiB file copies succeed every time.

 drivers/usb/storage/usb.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 63d624e..e0ef4f5 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -87,8 +87,7 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev,
struct device_d *dev = &us->pusb_dev->dev;
int i, ret;
 
-
-   for (i = 0; i < retries; i++) {
+   for (i = 0; i <= retries; i++) {
dev_dbg(dev, "%s\n", usb_stor_opcode_name(cmd[0]));
ret = us->transport(usb_blkdev, cmd, cmdlen, data, datalen);
dev_dbg(dev, "%s returns %d\n", usb_stor_opcode_name(cmd[0]),
@@ -105,6 +104,8 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev,
mdelay(request_sense_delay_ms);
}
 
+   dev_dbg(dev, "Retried %s %d times, and failed.\n", 
usb_stor_opcode_name(cmd[0]), retries);
+
return -EIO;
 }
 
@@ -194,7 +195,7 @@ static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 
opcode,
put_unaligned_be16(blocks, &cmd[7]);
 
return usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data,
- blocks * SECTOR_SIZE, 2, 0);
+ blocks * SECTOR_SIZE, 10, 0);
 }
 
 /***
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2] sandbox: add_image: mmap block devices

2019-10-25 Thread Robert Karszniewicz
This makes it possible to mount block devices from the host machine,
which have been passed as arguments to --image

Signed-off-by: Robert Karszniewicz 
---
Changes from v1:
- move -1 to the right side of the comparison

 arch/sandbox/os/common.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 86118822a..e826c9cb3 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -39,6 +39,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 /*
  * ...except the ones needed to connect with barebox
  */
@@ -260,6 +262,12 @@ static int add_image(char *str, char *devname_template, 
int *devname_number)
hf->size = s.st_size;
hf->devname = strdup(devname);
 
+   if (S_ISBLK(s.st_mode)) {
+   if (ioctl(fd, BLKGETSIZE64, &hf->size) == -1) {
+   perror("ioctl");
+   goto err_out;
+   }
+   }
hf->base = (unsigned long)mmap(NULL, hf->size,
PROT_READ | (readonly ? 0 : PROT_WRITE),
MAP_SHARED, fd, 0);
-- 
2.11.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] sandbox: add_image: mmap block devices

2019-10-25 Thread Robert Karszniewicz

On 10/24/19 6:07 PM, Ahmad Fatoum wrote:

On 10/24/19 6:02 PM, Robert Karszniewicz wrote:

This makes it possible to mount block devices from the host machine,
which have been passed as arguments to --image

Signed-off-by: Robert Karszniewicz 
---
  arch/sandbox/os/common.c | 8 
  1 file changed, 8 insertions(+)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 86118822a..805ac8eef 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -39,6 +39,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
  /*
   * ...except the ones needed to connect with barebox
   */
@@ -260,6 +262,12 @@ static int add_image(char *str, char *devname_template, 
int *devname_number)
hf->size = s.st_size;
hf->devname = strdup(devname);
  
+	if (S_ISBLK(s.st_mode)) {

+   if (-1 == ioctl(fd, BLKGETSIZE64, &hf->size)) {


This looks out of place for barebox, the -1 should be on the right side.


Oh, right, sorry! I have a habit to put trivial- and constant-sized 
symbols to the left, to not hide them behind those long function calls, etc.





+   perror("ioctl");
+   goto err_out;
+   }
+   }
hf->base = (unsigned long)mmap(NULL, hf->size,
PROT_READ | (readonly ? 0 : PROT_WRITE),
MAP_SHARED, fd, 0);







___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] sandbox: add_image: mmap block devices

2019-10-24 Thread Robert Karszniewicz
This makes it possible to mount block devices from the host machine,
which have been passed as arguments to --image

Signed-off-by: Robert Karszniewicz 
---
 arch/sandbox/os/common.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 86118822a..805ac8eef 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -39,6 +39,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 /*
  * ...except the ones needed to connect with barebox
  */
@@ -260,6 +262,12 @@ static int add_image(char *str, char *devname_template, 
int *devname_number)
hf->size = s.st_size;
hf->devname = strdup(devname);
 
+   if (S_ISBLK(s.st_mode)) {
+   if (-1 == ioctl(fd, BLKGETSIZE64, &hf->size)) {
+   perror("ioctl");
+   goto err_out;
+   }
+   }
hf->base = (unsigned long)mmap(NULL, hf->size,
PROT_READ | (readonly ? 0 : PROT_WRITE),
MAP_SHARED, fd, 0);
-- 
2.11.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v4] libfile: copy_file: fix error handling

2019-10-22 Thread Robert Karszniewicz
Before this, ret was falsely polluted, which caused a misleading error
message if the function bailed out at a later point.

Signed-off-by: Robert Karszniewicz 
---
 lib/libfile.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/libfile.c b/lib/libfile.c
index 3f3ec21..7bade39 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -330,7 +330,7 @@ int copy_file(const char *src, const char *dst, int verbose)
 {
char *rw_buf = NULL;
int srcfd = 0, dstfd = 0;
-   int r;
+   int r, s;
int ret = 1, err1 = 0;
int mode;
int total = 0;
@@ -341,22 +341,27 @@ int copy_file(const char *src, const char *dst, int 
verbose)
srcfd = open(src, O_RDONLY);
if (srcfd < 0) {
printf("could not open %s: %s\n", src, errno_str());
+   ret = srcfd;
goto out;
}
 
mode = O_WRONLY | O_CREAT;
 
-   ret = stat(dst, &dststat);
-   if (ret && ret != -ENOENT)
+   s = stat(dst, &dststat);
+   if (s && s != -ENOENT) {
+   printf("could not stat %s: %s\n", dst, errno_str());
+   ret = s;
goto out;
+   }
 
/* Set O_TRUNC only if file exist and is a regular file */
-   if (!ret && S_ISREG(dststat.st_mode))
+   if (!s && S_ISREG(dststat.st_mode))
mode |= O_TRUNC;
 
dstfd = open(dst, mode);
if (dstfd < 0) {
printf("could not open %s: %s\n", dst, errno_str());
+   ret = dstfd;
goto out;
}
 
@@ -371,12 +376,14 @@ int copy_file(const char *src, const char *dst, int 
verbose)
r = read(srcfd, rw_buf, RW_BUF_SIZE);
if (r < 0) {
perror("read");
+   ret = r;
goto out;
}
if (!r)
break;
 
-   if (write_full(dstfd, rw_buf, r) < 0) {
+   ret = write_full(dstfd, rw_buf, r);
+   if (ret < 0) {
perror("write");
goto out;
}
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] sandbox: add_image: output errno string on mmap failure

2019-10-21 Thread Robert Karszniewicz
Signed-off-by: Robert Karszniewicz 
---
 arch/sandbox/os/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 86118822a..1b2daa396 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -264,7 +264,7 @@ static int add_image(char *str, char *devname_template, int 
*devname_number)
PROT_READ | (readonly ? 0 : PROT_WRITE),
MAP_SHARED, fd, 0);
if ((void *)hf->base == MAP_FAILED)
-   printf("warning: mmapping %s failed\n", filename);
+   printf("warning: mmapping %s failed: %s\n", filename, 
strerror(errno));
 
ret = barebox_register_filedev(hf);
if (ret)
-- 
2.11.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH v3] libfile: copy_file: prevent spurious error message

2019-10-18 Thread Robert Karszniewicz

In all this haste, I forgot my question.

What error codes should be used? For each goto its own code, in 
sequence, starting from -1?


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v3] libfile: copy_file: prevent spurious error message

2019-10-18 Thread Robert Karszniewicz
Before this, ret was falsely polluted, which caused a misleading error
message if the function bailed out at a later point.

Signed-off-by: Robert Karszniewicz 
---
 lib/libfile.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/libfile.c b/lib/libfile.c
index 3f3ec21..fe11d34 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -330,7 +330,7 @@ int copy_file(const char *src, const char *dst, int verbose)
 {
char *rw_buf = NULL;
int srcfd = 0, dstfd = 0;
-   int r;
+   int r, s;
int ret = 1, err1 = 0;
int mode;
int total = 0;
@@ -346,12 +346,12 @@ int copy_file(const char *src, const char *dst, int 
verbose)
 
mode = O_WRONLY | O_CREAT;
 
-   ret = stat(dst, &dststat);
-   if (ret && ret != -ENOENT)
+   s = stat(dst, &dststat);
+   if (s && s != -ENOENT)
goto out;
 
/* Set O_TRUNC only if file exist and is a regular file */
-   if (!ret && S_ISREG(dststat.st_mode))
+   if (!s && S_ISREG(dststat.st_mode))
mode |= O_TRUNC;
 
dstfd = open(dst, mode);
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] cp: complete command help

2019-10-16 Thread Robert Karszniewicz
Signed-off-by: Robert Karszniewicz 
---
 commands/cp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/commands/cp.c b/commands/cp.c
index 54934dd..845dae6 100644
--- a/commands/cp.c
+++ b/commands/cp.c
@@ -100,13 +100,14 @@ BAREBOX_CMD_HELP_START(cp)
 BAREBOX_CMD_HELP_TEXT("Copy file from SRC to DEST.")
 BAREBOX_CMD_HELP_TEXT("")
 BAREBOX_CMD_HELP_TEXT("Options:")
+BAREBOX_CMD_HELP_OPT ("-r", "recursive")
 BAREBOX_CMD_HELP_OPT ("-v", "verbose")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(cp)
.cmd= do_cp,
BAREBOX_CMD_DESC("copy files")
-   BAREBOX_CMD_OPTS("[-v] SRC DEST")
+   BAREBOX_CMD_OPTS("[-rv] SRC DEST")
BAREBOX_CMD_GROUP(CMD_GRP_FILE)
BAREBOX_CMD_HELP(cmd_cp_help)
 BAREBOX_CMD_END
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: readling, ctrl-u is not working like linux console

2019-10-16 Thread Robert Karszniewicz

On 10/16/19 10:57 AM, Roland Hieber wrote:

On Wed, Oct 16, 2019 at 04:57:45AM +0800, duhuanpeng wrote:

Hi,

I find it the barebox console's ctrl-u is not working like my
linux host.
for now, the barebox's ctrl-u discard the whole line. but the
linux consle just remove characters before cursor.
is the barebox ctrl-u follows any standard, if not, how about
make it just works like linux(ah, it is gnu readline) does.


FWIW, in bash on both my tty2 and urxvt, Ctrl-U clears the whole line.
But I don't know if there is a standard for this shortkey.

  - Roland



In some shells, like mksh, the default behaviour of ctrl-u is to kill 
the whole line. But then it's not called unix-line-discard, and I don't 
think mksh uses readline, either. The "standard" is probably just 
readline, though it makes me wonder where the "unix" came from…


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2] libfile: copy_file: prevent spurious error message

2019-10-16 Thread Robert Karszniewicz
Before this, if the function bails out somewhere at a later point, this
return value will be outdated and will produce a misleading error
message down the line.

Signed-off-by: Robert Karszniewicz 
---
Changes from v1:
- commit message

 lib/libfile.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/libfile.c b/lib/libfile.c
index 3f3ec21..319e66b 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -349,6 +349,7 @@ int copy_file(const char *src, const char *dst, int verbose)
ret = stat(dst, &dststat);
if (ret && ret != -ENOENT)
goto out;
+   ret = 0;
 
/* Set O_TRUNC only if file exist and is a regular file */
if (!ret && S_ISREG(dststat.st_mode))
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] libfile: copy_file: prevent spurious error message

2019-10-15 Thread Robert Karszniewicz
Signed-off-by: Robert Karszniewicz 
---
 lib/libfile.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/libfile.c b/lib/libfile.c
index 3f3ec21..319e66b 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -349,6 +349,7 @@ int copy_file(const char *src, const char *dst, int verbose)
ret = stat(dst, &dststat);
if (ret && ret != -ENOENT)
goto out;
+   ret = 0;
 
/* Set O_TRUNC only if file exist and is a regular file */
if (!ret && S_ISREG(dststat.st_mode))
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] chdir(): add LOOKUP_DIRECTORY flag to filename_lookup()

2019-09-18 Thread Robert Karszniewicz
This makes sure that automount points get handled even if the path
doesn't end with a '/'.

Signed-off-by: Robert Karszniewicz 
---
 fs/fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fs.c b/fs/fs.c
index c6cb499..901beab 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -2690,7 +2690,7 @@ int chdir(const char *pathname)
struct path path;
int ret;
 
-   ret = filename_lookup(AT_FDCWD, getname(pathname), LOOKUP_FOLLOW, 
&path);
+   ret = filename_lookup(AT_FDCWD, getname(pathname), LOOKUP_FOLLOW | 
LOOKUP_DIRECTORY, &path);
if (ret)
goto out;
 
-- 
2.7.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] readline: add ctrl-u (unix-line-discard)

2019-02-01 Thread Robert Karszniewicz
Signed-off-by: Robert Karszniewicz 
---
 lib/readline.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/readline.c b/lib/readline.c
index 904a77639..d026af110 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -290,6 +290,7 @@ int readline(const char *prompt, char *buf, int len)
insert = !insert;
break;
case BB_KEY_ERASE_LINE:
+   case CTL_CH('u'):
BEGINNING_OF_LINE();
ERASE_TO_EOL();
break;
-- 
2.11.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox