Re: [PATCH 2/6] Documentation: add chapter on Talks about barebox

2022-01-24 Thread Ahmad Fatoum
On 24.01.22 16:18, Ahmad Fatoum wrote:

Argh, botched authorship on rebase. @Sascha, could you fix up
Johannes as git author on apply if there's no v2? Thanks.

> There's been a number of talks about barebox. Collect them in a new
> chapter for those, who prefer something less dry than wading through the
> docs. A top-level chapter is chosen, so it's more visible to visitors.
> 
> The ordering is reverse chronological, except for the first entry: The
> newest talk is German about running DOOM in barebox, which is a bit
> detached to how barebox is normally used.
> 
> Instead, let's keep the first entry as a pointer to the latest overview
> talk and then use reverse chronological order for the rest.
> 
> Signed-off-by: Johannes Schneider 
> Signed-off-by: Ahmad Fatoum 
> ---
>  Documentation/index.rst |   1 +
>  Documentation/talks.rst | 130 
>  2 files changed, 131 insertions(+)
>  create mode 100644 Documentation/talks.rst
> 
> diff --git a/Documentation/index.rst b/Documentation/index.rst
> index 836dc41af2a3..a3e019e9f0a2 100644
> --- a/Documentation/index.rst
> +++ b/Documentation/index.rst
> @@ -20,6 +20,7 @@ Contents:
> glossary
> devicetree/*
> devel/devel.rst
> +   talks
>  
>  * :ref:`search`
>  * :ref:`genindex`
> diff --git a/Documentation/talks.rst b/Documentation/talks.rst
> new file mode 100644
> index ..5f1af599316b
> --- /dev/null
> +++ b/Documentation/talks.rst
> @@ -0,0 +1,130 @@
> +Talks and Lectures
> +==
> +
> +This is a collection of talks held about barebox use and development
> +at different technical conferences. The most recent overview talk
> +is from 2020:
> +
> +Beyond 'Just' Booting: Barebox Bells and Whistles
> +-
> +
> +Ahmad Fatoum, Embedded Linux Conference - Europe 2020
> +`[slides] `__
> +`[video] `__
> +
> +   Porting barebox to a new STM32MP1 board and a general discussion
> +   of design choices like multi-image, VFS, POSIX/Linux API,
> +   fail-safe updates, boot fall-back mechanisms, etc.
> +
> +Besides older overview talks, there's a number of talks held
> +about different aspects of barebox use.
> +These are listed here in reverse chronological order.
> +
> +DOOM portieren für Einsteiger - Heavy Metal auf Bare Metal (German)
> +---
> +
> +Ahmad Fatoum, FrOSCon 2021
> +`[slides] 
> `__
> +`[video] 
> `__
> +
> +  "DOOM as a boot splash. How, why and how to get it on your nearest
> +  home appliance". A (German) walkthrough on how to leverage barebox
> +  APIs to run DOOM on any hardware supported by barebox.
> +
> +Initializing RISC-V: A Guided Tour for ARM Developers
> +-
> +
> +Rouven Czerwinski & Ahmad Fatoum, Embedded Linux Conference 2021
> +`[slides] `__
> +`[video] `__
> +
> +  A guide through the RISC-V architecture and some of its ISA extensions
> +  and a walkthrough of the barebox port to the Beagle-V Starlight.
> +
> +From Reset Vector to Kernel - Navigating the ARM Matryoshka
> +---
> +
> +Ahmad Fatoum, FOSDEM 2021
> +`[slides & video] 
> `__
> +
> +  A walkthrough of NXP i.MX8M bootstrap. From Boot ROM through barebox to 
> Linux.
> +
> +Booting your i.MX processor secure and implementing i.MX8 secure boot in 
> barebox
> +
> +
> +Rouven Czerwinski, `Stratum 0 Talk 2019 
> `__
> +`[video] `__
> +
> +  A walkthrough of NXP i.MX8MQ high assurance boot with barebox.
> +
> +Porting Barebox to the Digi CC-MX6UL SBC Pro (German)
> +-
> +
> +Rouven Czerwinski, `Stratum 0 Live-Hacking 2019 
> `__
> +`[video] `__
> +
> +  Live-coding a barebox port to a new i.MX6UL board while
> +  explaining the details (in German).
> +
> +Remote update adventures with RAUC, Yocto and Barebox
> +-
> +
> +Patrick Boettcher, `Embedded Recipes 2019 
> `__
> +`[video] `__
> +
> +  Remote update and redundant boot 

[PATCH 6/6] Documentation: user: watchdog: note new wd -x option

2022-01-24 Thread Ahmad Fatoum
wd command documentation is generated automatically and will list the
new -x option. It's still a good idea to reference this in the
watchdog user doc as well. Do so.

Signed-off-by: Ahmad Fatoum 
---
 Documentation/user/watchdog.rst | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/user/watchdog.rst b/Documentation/user/watchdog.rst
index ff400317a0bc..0220965598ed 100644
--- a/Documentation/user/watchdog.rst
+++ b/Documentation/user/watchdog.rst
@@ -10,6 +10,15 @@ the bootloader. For these scenarios barebox provides the 
watchdog framework
 with the following functionality and at least ``CONFIG_WATCHDOG`` should be
 enabled.
 
+Disabling for development
+~
+
+The shorthand command ``wd -x`` will disable all watchdogs.
+If hardware (or driver) doesn't support turning off the watchdog,
+an autpoller will be registered to periodically feed watchdogs.
+This should only be needed for development.
+See :ref:`boot-watchdog-timeout` for how to use the watchdog in the field.
+
 Polling
 ~~~
 
@@ -98,6 +107,8 @@ device tree or via the ``priority`` device parameter. 
Normally, watchdogs
 that have a wider effect should be given the higher priority (e.g.
 PMIC watchdog resetting the board vs. SoC's watchdog resetting only itself).
 
+.. _boot-watchdog-timeout:
+
 Boot Watchdog Timeout
 ~
 
-- 
2.30.2


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


[PATCH 2/6] Documentation: add chapter on Talks about barebox

2022-01-24 Thread Ahmad Fatoum
There's been a number of talks about barebox. Collect them in a new
chapter for those, who prefer something less dry than wading through the
docs. A top-level chapter is chosen, so it's more visible to visitors.

The ordering is reverse chronological, except for the first entry: The
newest talk is German about running DOOM in barebox, which is a bit
detached to how barebox is normally used.

Instead, let's keep the first entry as a pointer to the latest overview
talk and then use reverse chronological order for the rest.

Signed-off-by: Johannes Schneider 
Signed-off-by: Ahmad Fatoum 
---
 Documentation/index.rst |   1 +
 Documentation/talks.rst | 130 
 2 files changed, 131 insertions(+)
 create mode 100644 Documentation/talks.rst

diff --git a/Documentation/index.rst b/Documentation/index.rst
index 836dc41af2a3..a3e019e9f0a2 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -20,6 +20,7 @@ Contents:
glossary
devicetree/*
devel/devel.rst
+   talks
 
 * :ref:`search`
 * :ref:`genindex`
diff --git a/Documentation/talks.rst b/Documentation/talks.rst
new file mode 100644
index ..5f1af599316b
--- /dev/null
+++ b/Documentation/talks.rst
@@ -0,0 +1,130 @@
+Talks and Lectures
+==
+
+This is a collection of talks held about barebox use and development
+at different technical conferences. The most recent overview talk
+is from 2020:
+
+Beyond 'Just' Booting: Barebox Bells and Whistles
+-
+
+Ahmad Fatoum, Embedded Linux Conference - Europe 2020
+`[slides] `__
+`[video] `__
+
+   Porting barebox to a new STM32MP1 board and a general discussion
+   of design choices like multi-image, VFS, POSIX/Linux API,
+   fail-safe updates, boot fall-back mechanisms, etc.
+
+Besides older overview talks, there's a number of talks held
+about different aspects of barebox use.
+These are listed here in reverse chronological order.
+
+DOOM portieren für Einsteiger - Heavy Metal auf Bare Metal (German)
+---
+
+Ahmad Fatoum, FrOSCon 2021
+`[slides] 
`__
+`[video] 
`__
+
+  "DOOM as a boot splash. How, why and how to get it on your nearest
+  home appliance". A (German) walkthrough on how to leverage barebox
+  APIs to run DOOM on any hardware supported by barebox.
+
+Initializing RISC-V: A Guided Tour for ARM Developers
+-
+
+Rouven Czerwinski & Ahmad Fatoum, Embedded Linux Conference 2021
+`[slides] `__
+`[video] `__
+
+  A guide through the RISC-V architecture and some of its ISA extensions
+  and a walkthrough of the barebox port to the Beagle-V Starlight.
+
+From Reset Vector to Kernel - Navigating the ARM Matryoshka
+---
+
+Ahmad Fatoum, FOSDEM 2021
+`[slides & video] 
`__
+
+  A walkthrough of NXP i.MX8M bootstrap. From Boot ROM through barebox to 
Linux.
+
+Booting your i.MX processor secure and implementing i.MX8 secure boot in 
barebox
+
+
+Rouven Czerwinski, `Stratum 0 Talk 2019 
`__
+`[video] `__
+
+  A walkthrough of NXP i.MX8MQ high assurance boot with barebox.
+
+Porting Barebox to the Digi CC-MX6UL SBC Pro (German)
+-
+
+Rouven Czerwinski, `Stratum 0 Live-Hacking 2019 
`__
+`[video] `__
+
+  Live-coding a barebox port to a new i.MX6UL board while
+  explaining the details (in German).
+
+Remote update adventures with RAUC, Yocto and Barebox
+-
+
+Patrick Boettcher, `Embedded Recipes 2019 
`__
+`[video] `__
+
+  Remote update and redundant boot of Embedded Linux devices
+  in the field with RAUC and barebox bootchooser.
+
+Verified Boot: From ROM to Userspace
+
+
+Marc Kleine-Budde, Embedded Linux Conference - Europe 2016
+`[slides] `__
+`[video] `__
+
+  Using FOSS components, including barebox, for a 

[PATCH 1/6] Documentation: user: introduction: update with lore/matrix/libera info

2022-01-24 Thread Ahmad Fatoum
The Website already points at Libera instead of Freenode. Update the
intro section, so the docs are correct as well.

While at it, mention lore and matrix.

Signed-off-by: Ahmad Fatoum 
---
 Documentation/user/introduction.rst | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/Documentation/user/introduction.rst 
b/Documentation/user/introduction.rst
index 8a980a70abc7..523fe288f9fe 100644
--- a/Documentation/user/introduction.rst
+++ b/Documentation/user/introduction.rst
@@ -24,6 +24,15 @@ discussion of barebox takes place here:
 
 http://lists.infradead.org/mailman/listinfo/barebox/
 
-There's also an IRC channel:
+Mails sent to the barebox mailing list are archived on
+`lore.barebox.org `_.
 
-IRC: #barebox (Freenode)
+Patch series sent there can be fetched with `b4 
`_ ::
+
+   git config b4.midmask https://lore.barebox.org/%s
+   git config b4.linkmask https://lore.barebox.org/%s
+   b4 am https://lore.barebox.org/$messageid # replace with link
+
+There's also an IRC channel, which is
+`bridged to Matrix  `_:
+#barebox on Libera Chat
-- 
2.30.2


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


[PATCH 5/6] Documentation: boards: openrisc: fix wrong header format

2022-01-24 Thread Ahmad Fatoum
Build warns that line is too short. Fix it.

Signed-off-by: Ahmad Fatoum 
---
 Documentation/boards/openrisc.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/boards/openrisc.rst 
b/Documentation/boards/openrisc.rst
index 34586b4a76b3..17b0aef4a6ad 100644
--- a/Documentation/boards/openrisc.rst
+++ b/Documentation/boards/openrisc.rst
@@ -22,7 +22,7 @@ Example of downloading and installing a toolchain::
   $ export PATH=$PATH:$PWD/or1k-elf/bin
 
 Running OpenRISC barebox on qemu
---
+
 
 Running barebox on qemu is similar to running linux on qemu see more details on
 the qemu wiki site at https://wiki.qemu.org/Documentation/Platforms/OpenRISC
-- 
2.30.2


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


[PATCH 3/6] commands: add missing command groups

2022-01-24 Thread Ahmad Fatoum
CMD_GRP_MISC is assumed in absence of an explicit group. Let's be
explicit instead to silence the warnings during documentation build.

Signed-off-by: Ahmad Fatoum 
---
 commands/mmc.c | 1 +
 fs/fs.c| 2 ++
 lib/kasan/test_kasan.c | 1 +
 3 files changed, 4 insertions(+)

diff --git a/commands/mmc.c b/commands/mmc.c
index cbbb9d615145..1e62b71850e0 100644
--- a/commands/mmc.c
+++ b/commands/mmc.c
@@ -194,5 +194,6 @@ BAREBOX_CMD_HELP_END
 BAREBOX_CMD_START(mmc)
.cmd = do_mmc,
BAREBOX_CMD_OPTS("enh_area [-c] /dev/mmcX")
+   BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
BAREBOX_CMD_HELP(cmd_mmc_help)
 BAREBOX_CMD_END
diff --git a/fs/fs.c b/fs/fs.c
index 60fdb29078d6..02ced6d6dfbd 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -3255,6 +3255,7 @@ static int do_lookup_dentry(int argc, char *argv[])
 
 BAREBOX_CMD_START(lookup_dentry)
 .cmd= do_lookup_dentry,
+   BAREBOX_CMD_GROUP(CMD_GRP_MISC)
 BAREBOX_CMD_END
 
 static struct dentry *debug_follow_mount(struct dentry *dentry)
@@ -3309,5 +3310,6 @@ static int do_debug_fs_dump(int argc, char *argv[])
 
 BAREBOX_CMD_START(debug_fs_dump)
 .cmd= do_debug_fs_dump,
+   BAREBOX_CMD_GROUP(CMD_GRP_MISC)
 BAREBOX_CMD_END
 #endif
diff --git a/lib/kasan/test_kasan.c b/lib/kasan/test_kasan.c
index e472bb34993b..d0ea91547711 100644
--- a/lib/kasan/test_kasan.c
+++ b/lib/kasan/test_kasan.c
@@ -474,5 +474,6 @@ static int do_kasan_test(int argc, char *argv[])
 BAREBOX_CMD_START(kasan_tests)
 .cmd= do_kasan_test,
 BAREBOX_CMD_DESC("Run KAsan tests")
+BAREBOX_CMD_GROUP(CMD_GRP_MISC)
 BAREBOX_CMD_COMPLETE(empty_complete)
 BAREBOX_CMD_END
-- 
2.30.2


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


[PATCH 4/6] Documentation: regulator: reference new directory from index

2022-01-24 Thread Ahmad Fatoum
The binding was recently added, but unreferenced. Fix this.

Signed-off-by: Ahmad Fatoum 
---
 Documentation/devicetree/index.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/index.rst 
b/Documentation/devicetree/index.rst
index 198c4893ff51..d03db3cf8263 100644
--- a/Documentation/devicetree/index.rst
+++ b/Documentation/devicetree/index.rst
@@ -114,4 +114,5 @@ Contents:
bindings/leds/*
bindings/misc/*
bindings/mtd/*
+   bindings/regulator/*
bindings/rtc/*
-- 
2.30.2


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


Re: [PATCH 1/2] Documentation: reboot-mode: fix typos

2022-01-24 Thread Sascha Hauer
On Thu, Jan 20, 2022 at 12:47:24PM +0100, Ulrich Ölmann wrote:
> Signed-off-by: Ulrich Ölmann 
> ---
>  Documentation/user/reboot-mode.rst | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/Documentation/user/reboot-mode.rst 
> b/Documentation/user/reboot-mode.rst
> index 681438d94498..24deae78727e 100644
> --- a/Documentation/user/reboot-mode.rst
> +++ b/Documentation/user/reboot-mode.rst
> @@ -29,9 +29,9 @@ User API
>  Devices registered with the reboot mode API gain two parameters:
>  
>   - ``$dev_of_reboot_mode.prev`` (read-only): The reboot mode that was
> -   set previous to barebox startup
> +   set previously to barebox startup.
>   - ``$dev_of_reboot_mode.next``: The next reboot mode, for when the
> -   system is reset
> +   system is reset.
>  
>  The reboot mode driver core use the alias name if available to name
>  the device. By convention, this should end with ``.reboot_mode``, e.g.::
> -- 
> 2.30.2
> 
> 
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

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


[PATCH 2/3] cdev: add diskuuid support

2022-01-24 Thread Michael Olbrich
This allows identifying disks by UUID. For disks with GPT the disk GUID is
used. For DOS partition tables the NT signature ist used, similar to how
the partuuid is generated.

Signed-off-by: Michael Olbrich 
---
 common/partitions/dos.c |  3 +++
 common/partitions/efi.c |  2 ++
 fs/devfs-core.c | 14 ++
 include/driver.h|  1 +
 4 files changed, 20 insertions(+)

diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 6c76aac37172..258b10a9ed3c 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -182,6 +182,9 @@ static void dos_partition(void *buf, struct block_device 
*blk,
struct disk_signature_priv *dsp;
uint32_t signature = get_unaligned_le32(buf + 0x1b8);
 
+   if (signature)
+   sprintf(blk->cdev.uuid, "%08x", signature);
+
table = (struct partition_entry *)[446];
 
for (i = 0; i < 4; i++) {
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 6d811bfb3b01..0787b93f120b 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -445,6 +445,8 @@ static void efi_partition(void *buf, struct block_device 
*blk,
return;
}
 
+   snprintf(blk->cdev.uuid, sizeof(blk->cdev.uuid), "%pUl", 
>disk_guid);
+
nb_part = le32_to_cpu(gpt->num_partition_entries);
 
if (nb_part > MAX_PARTITION) {
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 82e4811b384a..2475ab959a10 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -107,6 +107,20 @@ struct cdev *cdev_by_partuuid(const char *partuuid)
return NULL;
 }
 
+struct cdev *cdev_by_diskuuid(const char *diskuuid)
+{
+   struct cdev *cdev;
+
+   if (!diskuuid)
+   return NULL;
+
+   list_for_each_entry(cdev, _list, list) {
+   if (!cdev->master && !strcasecmp(cdev->uuid, diskuuid))
+   return cdev;
+   }
+   return NULL;
+}
+
 /**
  * device_find_partition - find a partition belonging to a physical device
  *
diff --git a/include/driver.h b/include/driver.h
index 409ed7e02afd..e38a15f51f00 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -484,6 +484,7 @@ struct cdev *lcdev_by_name(const char *filename);
 struct cdev *cdev_readlink(struct cdev *cdev);
 struct cdev *cdev_by_device_node(struct device_node *node);
 struct cdev *cdev_by_partuuid(const char *partuuid);
+struct cdev *cdev_by_diskuuid(const char *partuuid);
 struct cdev *cdev_open(const char *name, unsigned long flags);
 struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset);
 void cdev_remove_loop(struct cdev *cdev);
-- 
2.30.2


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


[PATCH 3/3] state: support backend-diskuuid / backend-offset

2022-01-24 Thread Michael Olbrich
On some platforms (e.g. EFI on x86_64) the state backend can only be
selected by a partiton UUID. On existing devices with a DOS partition
table, there may be no spare partition available for state.

This makes it possible to select the disk via UUID. The exact position is
defined by an explicitly specified offset.

Signed-off-by: Michael Olbrich 
---

I wasn't sure where to add the helper function. Is include/fs.h ok or
should I put it somewhere else?

I'll implement the same helper for dt-utils, so we can avoid additional
#ifdef here.

 common/state/state.c | 55 +---
 include/fs.h | 12 ++
 2 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/common/state/state.c b/common/state/state.c
index 8c34ae83e52b..2a8b12d20c5a 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -592,6 +592,7 @@ struct state *state_new_from_node(struct device_node *node, 
bool readonly)
const char *backend_type;
const char *storage_type = NULL;
const char *alias;
+   const char *diskuuid;
uint32_t stridesize;
struct device_node *partition_node;
off_t offset = 0;
@@ -607,30 +608,48 @@ struct state *state_new_from_node(struct device_node 
*node, bool readonly)
if (IS_ERR(state))
return state;
 
-   partition_node = of_parse_phandle(node, "backend", 0);
-   if (!partition_node) {
-   dev_err(>dev, "Cannot resolve \"backend\" phandle\n");
-   ret = -EINVAL;
-   goto out_release_state;
-   }
+   ret = of_property_read_string(node, "backend-diskuuid", );
+   if (ret == 0) {
+   u64 off;
+
+   ret = devpath_from_diskuuid(diskuuid, >backend_path);
+   if (ret) {
+   dev_err(>dev, "state failed find backend device 
for diskuuid='%s'\n",
+   diskuuid);
+   goto out_release_state;
+   }
+   ret = of_property_read_u64(node, "backend-offset", );
+   if (ret) {
+   dev_err(>dev, "'backend-offset' property 
undefined\n");
+   goto out_release_state;
+   }
+   offset = off;
+   } else {
+   partition_node = of_parse_phandle(node, "backend", 0);
+   if (!partition_node) {
+   dev_err(>dev, "Cannot resolve \"backend\" 
phandle\n");
+   ret = -EINVAL;
+   goto out_release_state;
+   }
 
 #ifdef __BAREBOX__
-   ret = of_partition_ensure_probed(partition_node);
-   if (ret)
-   goto out_release_state;
+   ret = of_partition_ensure_probed(partition_node);
+   if (ret)
+   goto out_release_state;
 
-   ret = of_find_path_by_node(partition_node, >backend_path, 0);
+   ret = of_find_path_by_node(partition_node, 
>backend_path, 0);
 #else
-   ret = of_get_devicepath(partition_node, >backend_path, , 
);
+   ret = of_get_devicepath(partition_node, >backend_path, 
, );
 #endif
-   if (ret) {
-   if (ret != -EPROBE_DEFER)
-   dev_err(>dev, "state failed to parse path to 
backend: %s\n",
-  strerror(-ret));
-   goto out_release_state;
-   }
+   if (ret) {
+   if (ret != -EPROBE_DEFER)
+   dev_err(>dev, "state failed to parse 
path to backend: %s\n",
+  strerror(-ret));
+   goto out_release_state;
+   }
 
-   state->backend_reproducible_name = 
of_get_reproducible_name(partition_node);
+   state->backend_reproducible_name = 
of_get_reproducible_name(partition_node);
+   }
 
ret = of_property_read_string(node, "backend-type", _type);
if (ret) {
diff --git a/include/fs.h b/include/fs.h
index cd5eb571e08e..1a2f9c7f8e16 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -177,4 +177,16 @@ static inline const char *devpath_to_name(const char 
*devpath)
return devpath;
 }
 
+static inline int devpath_from_diskuuid(const char *diskuuid, char **devpath)
+{
+   struct cdev *cdev;
+
+   cdev = cdev_by_diskuuid(diskuuid);
+   if (!cdev)
+   return -EINVAL;
+
+   *devpath = xasprintf("/dev/%s", cdev->name);
+   return 0;
+}
+
 #endif /* __FS_H */
-- 
2.30.2


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


[PATCH 0/3] state: find backend with UUID but without a partition

2022-01-24 Thread Michael Olbrich
Hi,

When adding state with a barebox update on existing devices, then it's not
always possible to add a partition for it. But currently that's the only
way to specify the state backend on x86_64/EFI devices.

This adds support backend-diskuuid / backend-offset. This way the backend
is defined by a UUID that selects a disk and an offset within that disk.

Michael

Michael Olbrich (3):
  cdev: rename partuuid to uuid
  cdev: add diskuuid support
  state: support backend-diskuuid / backend-offset

 common/bootm.c |  6 ++---
 common/partitions.c|  2 +-
 common/partitions/dos.c|  3 +++
 common/partitions/efi.c|  2 ++
 common/partitions/parser.h |  2 +-
 common/state/state.c   | 55 +-
 fs/devfs-core.c| 16 ++-
 fs/fs.c|  4 +--
 include/driver.h   |  5 ++--
 include/fs.h   | 12 +
 10 files changed, 79 insertions(+), 28 deletions(-)

-- 
2.30.2


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


[PATCH 1/3] cdev: rename partuuid to uuid

2022-01-24 Thread Michael Olbrich
Partitions are not the only devices that can have UUIDs. Change the name to
something more generic to prepare for other users.

Signed-off-by: Michael Olbrich 
---
 common/bootm.c | 6 +++---
 common/partitions.c| 2 +-
 common/partitions/parser.h | 2 +-
 fs/devfs-core.c| 2 +-
 fs/fs.c| 4 ++--
 include/driver.h   | 4 ++--
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 89e3e93f2ce0..4652467448eb 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -709,15 +709,15 @@ int bootm_boot(struct bootm_data *bootm_data)
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);
+   if (root_cdev && root_cdev->uuid[0] != 0) {
+   rootarg = basprintf("root=PARTUUID=%s", 
root_cdev->uuid);
} 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])
+   else if (!root_cdev->uuid[0])
pr_err("%s doesn't have a PARTUUID, 
cannot set root= option\n",
root_dev_name);
}
diff --git a/common/partitions.c b/common/partitions.c
index b579559672a0..9cca5c4a1546 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -51,7 +51,7 @@ static int register_one_partition(struct block_device *blk,
cdev->flags |= DEVFS_PARTITION_FROM_TABLE;
 
cdev->dos_partition_type = part->dos_partition_type;
-   strcpy(cdev->partuuid, part->partuuid);
+   strcpy(cdev->uuid, part->partuuid);
 
free(partition_name);
 
diff --git a/common/partitions/parser.h b/common/partitions/parser.h
index 69508932b361..d67f8e1d6a09 100644
--- a/common/partitions/parser.h
+++ b/common/partitions/parser.h
@@ -17,7 +17,7 @@
 struct partition {
char name[MAX_PARTITION_NAME];
u8 dos_partition_type;
-   char partuuid[MAX_PARTUUID_STR];
+   char partuuid[MAX_UUID_STR];
uint64_t first_sec;
uint64_t size;
 };
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 2d016e0e4861..82e4811b384a 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -101,7 +101,7 @@ struct cdev *cdev_by_partuuid(const char *partuuid)
return NULL;
 
list_for_each_entry(cdev, _list, list) {
-   if (!strcasecmp(cdev->partuuid, partuuid))
+   if (cdev->master && !strcasecmp(cdev->uuid, partuuid))
return cdev;
}
return NULL;
diff --git a/fs/fs.c b/fs/fs.c
index 7da3a050c1cb..a92b4e9dfca1 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -2969,8 +2969,8 @@ int mount(const char *device, const char *fsname, const 
char *pathname,
cdev_is_mci_main_part_dev(fsdev->cdev->master))
str = get_linux_mmcblkdev(fsdev);
 
-   if (!str && fsdev->cdev->partuuid[0] != 0)
-   str = basprintf("root=PARTUUID=%s", 
fsdev->cdev->partuuid);
+   if (!str && fsdev->cdev->uuid[0] != 0)
+   str = basprintf("root=PARTUUID=%s", fsdev->cdev->uuid);
 
if (str)
fsdev_set_linux_rootarg(fsdev, str);
diff --git a/include/driver.h b/include/driver.h
index 4f6d40e17c14..409ed7e02afd 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -447,7 +447,7 @@ struct cdev_operations {
int (*truncate)(struct cdev*, size_t size);
 };
 
-#define MAX_PARTUUID_STR   sizeof("00112233-4455-6677-8899-AABBCCDDEEFF")
+#define MAX_UUID_STR   sizeof("00112233-4455-6677-8899-AABBCCDDEEFF")
 
 struct cdev {
const struct cdev_operations *ops;
@@ -460,7 +460,7 @@ struct cdev {
char *partname; /* the partition name, usually the above without the
 * device part, i.e. name = "nand0.barebox" -> partname 
= "barebox"
 */
-   char partuuid[MAX_PARTUUID_STR];
+   char uuid[MAX_UUID_STR];
loff_t offset;
loff_t size;
unsigned int flags;
-- 
2.30.2


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


Re: [PATCH v1] ARM: Rockchip: Add rk3568 BananaPi R2 Pro board support

2022-01-24 Thread Ahmad Fatoum
Hello Frank,

On 23.01.22 17:51, Frank Wunderlich wrote:
> From: Frank Wunderlich 

> +/ {
> + model = "Rockchip RK3568 Bananapi R2 Pro Board";
> + compatible = "rockchip,rk3568-bpi-r2pro", "rockchip,rk3568";
> +
> + aliases {
> + emmc = 
> + sd = 
> + };
> +
> + chosen: chosen {

You can drop the label.

> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index 3c6b3dd9b531..7d54f357cfda 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -68,6 +68,12 @@ config MACH_RK3568_EVB
>   help
> Say Y here if you are using a RK3568 EVB
>  
> +config MACH_RK3568_R2PRO
> + select ARCH_RK3568
> + bool "RK3568 R2PRO"
> + help
> +   Say Y here if you are using a RK3568 Bananpi R2 Pro

Banana Pi BPI-R2 Pro*. Perhaps include the Banana Pi bit in the prompt
text as well?

> +
>  config MACH_PINE64_QUARTZ64
>   select ARCH_RK3568
>   bool "Pine64 Quartz64"
> diff --git a/dts/Bindings/arm/rockchip.yaml b/dts/Bindings/arm/rockchip.yaml
> index 4aed16176434..109f885d970f 100644
> --- a/dts/Bindings/arm/rockchip.yaml
> +++ b/dts/Bindings/arm/rockchip.yaml

dts/ is synchronized with Linux, so patches here are not accepted in barebox.
You can add new bindings to Documentation/devicetree/bindings/, although
boards are usually not documented in the bindings, but instead in board
docs:

Could you add an entry to Documentation/boards/rockchip.rst -> Rockchip RK356x
-> Supported Boards?

And enabling the board in arch/arm/configs/rockchip_v8_defconfig
would be nice as well.

Cheers,
Ahmad

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

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


Aw: Re: [PATCH v1] ARM: Rockchip: Add rk3568 BananaPi R2 Pro board support

2022-01-24 Thread Frank Wunderlich
Hi,
> Gesendet: Montag, 24. Januar 2022 um 09:55 Uhr
> Von: "Sascha Hauer" 

> > +static bool machine_is_rk3568_r2pro = false;
> > +
> > +static int rk3568_r2pro_probe(struct device_d *dev)
> > +{
> > +   enum bootsource bootsource = bootsource_get();
> > +   int instance = bootsource_get_instance();
> > +
> > +   barebox_set_model("RK3568 R2PRO");
> > +   barebox_set_hostname("rk3568-r2pro");
> > +   machine_is_rk3568_r2pro = true;
>
> Maybe add a bpi to the hostname, model, variable names and instead drop
> the rk3568?

i can do...

> > +   if (!IS_ENABLED(CONFIG_AIODEV))
> > +   return 0;
> > +
> > +   if (!machine_is_rk3568_r2pro)
> > +   return 0;
> > +
> > +   hwid_chan = aiochannel_by_name("aiodev0.in_value1_mV");
> > +   if (IS_ERR(hwid_chan)) {
> > +   ret = PTR_ERR(hwid_chan);
> > +   goto err_hwid;
> > +   }
> > +
> > +   ret = aiochannel_get_value(hwid_chan, _voltage);
> > +   if (ret)
> > +   goto err_hwid;
> > +
> > +   pr_info("hwid_voltage: %d\n", hwid_voltage);
>
> The voltage is not really interesting. This should be a pr_debug.

ok, i change this

> > +
> > +   if (hwid_voltage == 1800)
> > +   hwid = "V00";
> > +   else
> > +   hwid = "unknown";
>
> Have you verified this board really encodes the hardware revision using
> this adc channel?

yes, in shematics it is named SARADC_VIN1_HW_ID (which should map the 
in_value1_mV), but i have only this one prototype for testing.

> > diff --git a/arch/arm/dts/rk3568-bpi-r2-pro.dts 
> > b/arch/arm/dts/rk3568-bpi-r2-pro.dts
>
> I saw this device tree looks different from the one you sent for kernel
> inclusion. This is not a problem now, but once the kernel dts is
> upstream it will show up in dts/ in the barebox tree. We then usually
> include the upstream dts from the barebox board dts, so that only the
> barebox specific additions are in the barebox dts. Given that it would
> be nice if you could minimize the differences now already, so that later
> inclusion of the upstream dts becomes easier.

ok, we can wait for kernel dts to be merged, but most stuff in kernel dts will 
be unused in barebox. so i started with the evb one which is enough for barebox 
atm. Only added the leds.

regards Frank

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


Re: [PATCH v1] ARM: Rockchip: Add rk3568 BananaPi R2 Pro board support

2022-01-24 Thread Sascha Hauer
On Sun, Jan 23, 2022 at 05:51:49PM +0100, Frank Wunderlich wrote:
> From: Frank Wunderlich 
> 
> This adds support for the BananaPi R2 Pro board.
> It is basicly a copy of rk3568 evb board but with slightly modified DTS.
> Added GPIO-Leds to dts and modified the hw-detection a bit.
> 
> Tested features so far are:
> 
>  - 1st stage booting
>  - Network
>  - SD card (Emmc not tested but basicly same as on EVB)
>  - power LED (green)
> 
> Signed-off-by: Frank Wunderlich 
> ---
>  arch/arm/boards/Makefile  |   1 +
>  .../rockchip-rk3568-bpi-r2pro/.gitignore  |   1 +
>  .../boards/rockchip-rk3568-bpi-r2pro/Makefile |   2 +
>  .../boards/rockchip-rk3568-bpi-r2pro/board.c  |  93 +++
>  .../rockchip-rk3568-bpi-r2pro/lowlevel.c  |  49 ++
>  arch/arm/dts/Makefile |   1 +
>  arch/arm/dts/rk3568-bpi-r2-pro.dts| 593 ++
>  arch/arm/mach-rockchip/Kconfig|   6 +
>  dts/Bindings/arm/rockchip.yaml|   5 +
>  images/Makefile.rockchip  |   7 +
>  10 files changed, 758 insertions(+)
>  create mode 100644 arch/arm/boards/rockchip-rk3568-bpi-r2pro/.gitignore
>  create mode 100644 arch/arm/boards/rockchip-rk3568-bpi-r2pro/Makefile
>  create mode 100644 arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c
>  create mode 100644 arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c
>  create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro.dts
> 
> diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
> index 6fe1b5991455..c26f84dcd8de 100644
> --- a/arch/arm/boards/Makefile
> +++ b/arch/arm/boards/Makefile
> @@ -186,4 +186,5 @@ obj-$(CONFIG_MACH_TQMLS1046A) += 
> tqmls1046a/
>  obj-$(CONFIG_MACH_MNT_REFORM)+= mnt-reform/
>  obj-$(CONFIG_MACH_SKOV_ARM9CPU)  += skov-arm9cpu/
>  obj-$(CONFIG_MACH_RK3568_EVB)+= rockchip-rk3568-evb/
> +obj-$(CONFIG_MACH_RK3568_R2PRO)  += 
> rockchip-rk3568-bpi-r2pro/
>  obj-$(CONFIG_MACH_PINE64_QUARTZ64)   += pine64-quartz64/
> diff --git a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/.gitignore 
> b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/.gitignore
> new file mode 100644
> index ..f458f794b54c
> --- /dev/null
> +++ b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/.gitignore
> @@ -0,0 +1 @@
> +sdram-init.bin
> diff --git a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/Makefile 
> b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/Makefile
> new file mode 100644
> index ..01c7a259e9a5
> --- /dev/null
> +++ b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/Makefile
> @@ -0,0 +1,2 @@
> +obj-y += board.o
> +lwl-y += lowlevel.o
> diff --git a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c 
> b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c
> new file mode 100644
> index ..37634a7e33ed
> --- /dev/null
> +++ b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c
> @@ -0,0 +1,93 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#define pr_fmt(fmt) "rk3568-r2pro: " fmt
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static bool machine_is_rk3568_r2pro = false;
> +
> +static int rk3568_r2pro_probe(struct device_d *dev)
> +{
> + enum bootsource bootsource = bootsource_get();
> + int instance = bootsource_get_instance();
> +
> + barebox_set_model("RK3568 R2PRO");
> + barebox_set_hostname("rk3568-r2pro");
> + machine_is_rk3568_r2pro = true;

Maybe add a bpi to the hostname, model, variable names and instead drop
the rk3568?

> + if (!IS_ENABLED(CONFIG_AIODEV))
> + return 0;
> +
> + if (!machine_is_rk3568_r2pro)
> + return 0;
> +
> + hwid_chan = aiochannel_by_name("aiodev0.in_value1_mV");
> + if (IS_ERR(hwid_chan)) {
> + ret = PTR_ERR(hwid_chan);
> + goto err_hwid;
> + }
> +
> + ret = aiochannel_get_value(hwid_chan, _voltage);
> + if (ret)
> + goto err_hwid;
> +
> + pr_info("hwid_voltage: %d\n", hwid_voltage);

The voltage is not really interesting. This should be a pr_debug.

> +
> + if (hwid_voltage == 1800)
> + hwid = "V00";
> + else
> + hwid = "unknown";

Have you verified this board really encodes the hardware revision using
this adc channel?

> diff --git a/arch/arm/dts/rk3568-bpi-r2-pro.dts 
> b/arch/arm/dts/rk3568-bpi-r2-pro.dts

I saw this device tree looks different from the one you sent for kernel
inclusion. This is not a problem now, but once the kernel dts is
upstream it will show up in dts/ in the barebox tree. We then usually
include the upstream dts from the barebox board dts, so that only the
barebox specific additions are in the barebox dts. Given that it would
be nice if you could minimize the differences now already, so that later
inclusion of the upstream dts becomes easier.

Sascha


-- 
Pengutronix e.K.