Skip to contentSkip to conversation

cmd: add a fetch utility

PATCH Superseded Caleb Connolly 6 participants 10 messages Aug 8, 2024 – Nov 13, 2024

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: add a fetch utility

While U-Boot does a pretty good job at printing information at startup about what hardware it's running on, it can be hard to take pretty pictures of this to show off on the internet (by far the most important aspect of porting a device in 2024!).

Add a small utility "ufetch" for displaying some information about U-Boot and the hardware it's running on in a similar fashion to the popular neofetch tool for *nix's [1].

While the output is meant to be useful, it should also be pleasing to look at and look good in screenshots. The ufetch command brings this to U-Boot, featuring a colorful ASCII art version of the U-Boot logo and a fancy layout.

Finally, tireless device porters can properly show off their hard work and get the internet points they so deserve!

Not everything is fully supported yet, but this seemed good enough for initial inclusion. Only one MMC device is detected, and other than SCSI other storage devices aren't supported.

[1]: https://en.wikipedia.org/wiki/Neofetch

---
Ephemeral demo image: https://0x0.st/XVUa.png

---
 cmd/Kconfig  |   7 ++
 cmd/Makefile |   1 +
 cmd/ufetch.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 209 insertions(+)
 create mode 100644 cmd/ufetch.c
cmd/Kconfig +7 -0
index 978f44eda426..70acb5727b04 100644
@@ -175,8 +175,15 @@ config CMD_CPU
 	  number of CPUs, type (e.g. manufacturer, architecture, product or
 	  internal name) and clock frequency. Other information may be
 	  available depending on the CPU driver.
 
+config CMD_UFETCH
+	bool "U-Boot fetch"
+	depends on BLK
+	help
+	  Fetch utility for U-Boot (akin to neofetch). Prints information
+	  about U-Boot and the board it is running on in a pleasing format.
+
 config CMD_FWU_METADATA
 	bool "fwu metadata read"
 	depends on FWU_MULTI_BANK_UPDATE
 	help
cmd/Makefile +1 -0
index 87133cc27a8a..ffb04c8f2e0a 100644
@@ -53,8 +53,9 @@ obj-$(CONFIG_CMD_CONSOLE) += console.o
 obj-$(CONFIG_CMD_CPU) += cpu.o
 obj-$(CONFIG_CMD_DATE) += date.o
 obj-$(CONFIG_CMD_DEMO) += demo.o
 obj-$(CONFIG_CMD_DM) += dm.o
+obj-$(CONFIG_CMD_UFETCH) += ufetch.o
 obj-$(CONFIG_CMD_SOUND) += sound.o
 ifdef CONFIG_POST
 obj-$(CONFIG_CMD_DIAG) += diag.o
 endif
cmd/ufetch.c new file +201 -0

201 lines not on this page · raw message

Signature · 1 line
2.46.0
#1 lore raw

Hi Caleb,

Quoted 7 lines · Caleb Connolly

While U-Boot does a pretty good job at printing information at startup about what hardware it's running on, it can be hard to take pretty pictures of this to show off on the internet (by far the most important aspect of porting a device in 2024!).

Add a small utility "ufetch" for displaying some information about U-Boot

and

Quoted 1 line

the hardware it's running on in a similar fashion to the popular neofetch

tool

Quoted 3 lines

for *nix's [1].

While the output is meant to be useful, it should also be pleasing to

look at

Quoted 2 lines

and look good in screenshots. The ufetch command brings this to U-Boot, featuring a colorful ASCII art version of the U-Boot logo and a fancy

layout.

Quoted 2 lines

Finally, tireless device porters can properly show off their hard work

and get

Quoted 3 lines

the internet points they so deserve!

Not everything is fully supported yet, but this seemed good enough for

initial

Quoted 1 line

inclusion. Only one MMC device is detected, and other than SCSI other

storage

Quoted 5 lines

devices aren't supported.

[1]: https://en.wikipedia.org/wiki/Neofetch

Quoted 8 lines

---
Ephemeral demo image: https://0x0.st/XVUa.png

---
 cmd/Kconfig  |   7 ++
 cmd/Makefile |   1 +
 cmd/ufetch.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 209 insertions(+)
 create mode 100644 cmd/ufetch.c

Very cute!

cmd/Kconfig config CMD_CPU · line 175

Quoted 7 lines
cmd/Kconfig +0 -0
index 978f44eda426..70acb5727b04 100644
@@ -175,8 +175,15 @@ config CMD_CPU
          number of CPUs, type (e.g. manufacturer, architecture, product

or

cmd/Kconfig config CMD_CPU · line 180

Quoted 5 lines
cmd/Kconfig +2 -0
          internal name) and clock frequency. Other information may be
          available depending on the CPU driver.
 
+config CMD_UFETCH
+       bool "U-Boot fetch"

How about default y if SANDBOX so that this gets built for that. You should also add doc/ and test/ for the command (although the test can be very basic).

cmd/Kconfig config CMD_CPU

Quoted 4 lines
cmd/Kconfig +4 -0
+       depends on BLK
+       help
+         Fetch utility for U-Boot (akin to neofetch). Prints information
+         about U-Boot and the board it is running on in a pleasing

format.

Quoted 25 lines
cmd/Kconfig +1 -0
+
 config CMD_FWU_METADATA
        bool "fwu metadata read"
        depends on FWU_MULTI_BANK_UPDATE
        help
cmd/Makefile +1 -0
index 87133cc27a8a..ffb04c8f2e0a 100644
@@ -53,8 +53,9 @@ obj-$(CONFIG_CMD_CONSOLE) += console.o
 obj-$(CONFIG_CMD_CPU) += cpu.o
 obj-$(CONFIG_CMD_DATE) += date.o
 obj-$(CONFIG_CMD_DEMO) += demo.o
 obj-$(CONFIG_CMD_DM) += dm.o
+obj-$(CONFIG_CMD_UFETCH) += ufetch.o
 obj-$(CONFIG_CMD_SOUND) += sound.o
 ifdef CONFIG_POST
 obj-$(CONFIG_CMD_DIAG) += diag.o
 endif
cmd/ufetch.c new file +0 -0
new file mode 100644
index 000000000000..f7374eb2e364

cmd/ufetch.c line 3

Quoted 3 lines
cmd/ufetch.c new file +3 -0
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* Small "fetch" utility for U-Boot */

Isn't it a command, rather than a utility? I think of a utility as a program I run.

cmd/ufetch.c line 16

Quoted 13 lines
cmd/ufetch.c new file +13 -0
+
+#include <mmc.h>
+#include <time.h>
+#include <asm/global_data.h>
+#include <cli.h>
+#include <command.h>
+#include <dm/ofnode.h>
+#include <env.h>
+#include <rand.h>
+#include <vsprintf.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <version.h>

Please check [1]

Quoted 5 lines
cmd/ufetch.c new file +5 -0
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define LINE_WIDTH 40
+#define BLUE "\033[38;5;4m"

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+#define YELLOW "\033[38;5;11m"
+#define BOLD "\033[1m"
+#define RESET "\033[0m"
+static const char *logo_lines[] = {
+       BLUE BOLD "                  ......::......                   ",
+       BLUE BOLD "             ...::::::::::::::::::...              ",
+       BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+       BLUE BOLD "        .::::.:::::::::::::::...::::.::::.         ",
+       BLUE BOLD "      .::::::::::::::::::::..::::::::::::::.       ",
+       BLUE BOLD "    .::.:::::::::::::::::::" YELLOW "=*%#*" BLUE

"::::::::::.::. ",

cmd/ufetch.c line 32

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "   .:::::::::::::::::....." YELLOW "*%%*-" BLUE

":....::::::::::. ",

cmd/ufetch.c line 33

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "  .:.:::...:::::::::.:-" YELLOW "===##*---==-" BLUE

"::::::::::.:. ",

cmd/ufetch.c line 34

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " .::::..::::........" YELLOW "-***#****###****-" BLUE

"...::::::.:. ",

cmd/ufetch.c line 35

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " ::.:.-" YELLOW "+***+=" BLUE "::-" YELLOW

"=+**#%%%%%%%%%%%%###*= " BLUE "-::...::::. ",

cmd/ufetch.c line 36

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ".:.::-" YELLOW "*****###%%%%%%%%%%%%%%%%%%%%%%%%%%#*="

BLUE ":..:::: ",

cmd/ufetch.c line 37

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ".::" YELLOW "##" BLUE ":" YELLOW

"***#%%%%%%#####%%%%%%%####%%%%%####%%%*" BLUE "-.::. ",

cmd/ufetch.c line 38

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ":.:" YELLOW "#%" BLUE "::" YELLOW

"*%%%%%%%#*****##%%%#*****##%%##*****#%%+" BLUE ".::.",

cmd/ufetch.c line 39

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ".::" YELLOW

"**==#%%%%%%%##****#%%%%##****#%%%%#****###%%" BLUE ":.. ",

cmd/ufetch.c line 40

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "..:" YELLOW "#%" BLUE "::" YELLOW

"*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#%%%%%+ " BLUE ".:.",

cmd/ufetch.c line 41

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " ::" YELLOW "##" BLUE ":" YELLOW

"+**#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%* " BLUE "-.:: ",

cmd/ufetch.c line 42

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " ..::-" YELLOW "#****#%#%%%%%%%%%%%%%%%%%%%%%%%%%%#*="

BLUE "-..::. ",

cmd/ufetch.c line 43

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "  ...:=" YELLOW "*****=" BLUE

"::-\033[38;5;7m=+**###%%%%%%%%###**+= " BLUE "--:...::: ",

Quoted 17 lines
cmd/ufetch.c new file +17 -0
+       BLUE BOLD "   .::.::--:........::::::--::::::......::::::.    ",
+       BLUE BOLD "    .::.....::::::::::...........:::::::::.::.     ",
+       BLUE BOLD "      .::::::::::::::::::::::::::::::::::::.       ",
+       BLUE BOLD "        .::::.::::::::::::::::::::::.::::.         ",
+       BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+       BLUE BOLD "             ...::::::::::::::::::...              ",
+       BLUE BOLD "                  ......::......                   ",
+};
+
+enum output_lines {
+       FIRST,
+       SECOND,
+       KERNEL,
+       SYSINFO,
+       HOST,
+       UPTIME,
+       IP,

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+       CMDS,
+       CONSOLES,
+       DEVICES,
+       FEATURES,
+       RELOCATION,
+       CORES,
+       MEMORY,
+       STORAGE,
+
+       /* Up to 10 storage devices... Should be enough for anyone right?

*/

Quoted 21 lines
cmd/ufetch.c new file +21 -0
+       _LAST_LINE = (STORAGE + 10),
+#define LAST_LINE (_LAST_LINE - 1UL)
+};
+
+static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,
+                    char *const argv[])
+{
+       int num_lines = max(LAST_LINE + 1, ARRAY_SIZE(logo_lines));
+       const char *model, *compatible;
+       char *ipaddr;
+       int n_cmds, n_cpus = 0, ret, compatlen;
+       ofnode np;
+       struct mmc *mmc;
+       struct blk_desc *scsi_desc;
+       bool skip_ascii = false;
+
+       if (argc > 1 && strcmp(argv[1], "-n") == 0) {
+               skip_ascii = true;
+               num_lines = LAST_LINE;
+       }
+

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+       for (int i = 0; i < num_lines; i++) {
+               if (!skip_ascii) {
+                       if (i < ARRAY_SIZE(logo_lines))
+                               printf("%s ", logo_lines[i]);
+                       else
+                               printf("%*c ", LINE_WIDTH, ' ');
+               }
+               switch (i) {
+               case FIRST:
+                       compatible = ofnode_read_string(ofnode_root(),

"compatible");

Quoted 5 lines
cmd/ufetch.c new file +5 -0
+                       if (!compatible)
+                               compatible = "unknown";
+                       printf(RESET "%s\n", compatible);
+                       compatlen = strlen(compatible);
+                       break;

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+               case SECOND:
+                       for (int j = 0; j < compatlen; j++)
+                               putc('-');
+                       putc('\n');
+                       break;
+               case KERNEL:
+                       printf("Kernel:" RESET " %s\n", U_BOOT_VERSION);
+                       break;
+               case SYSINFO:
+                       printf("Config:" RESET " %s_defconfig\n",

CONFIG_SYS_CONFIG_NAME);

cmd/ufetch.c

Quoted 3 lines
cmd/ufetch.c new file +3 -0
+                       break;
+               case HOST:
+                       model = ofnode_read_string(ofnode_root(),

"model");

cmd/ufetch.c

Quoted 5 lines
cmd/ufetch.c new file +5 -0
+                       if (model)
+                               printf("Host:" RESET " %s\n", model);
+                       break;
+               case UPTIME:
+                       printf("Uptime:" RESET " %ld seconds\n",

get_timer(0) / 1000);

Quoted 8 lines
cmd/ufetch.c new file +8 -0
+                       break;
+               case IP:
+                       ipaddr = env_get("ipvaddr");
+                       if (!ipaddr)
+                               ipaddr = "none";
+                       printf("IP Address:" RESET " %s", ipaddr);
+                       ipaddr = env_get("ipv6addr");
+                       if (ipaddr)

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+                               printf(", %s\n", ipaddr);
+                       else
+                               putc('\n');
+                       break;
+               case CMDS:
+                       n_cmds = ll_entry_count(struct cmd_tbl, cmd);
+                       printf("Commands:" RESET " %d (help)\n", n_cmds);
+                       break;
+               case CONSOLES:
+                       printf("Consoles:" RESET " %s (%d baud)\n",

env_get("stdout"),

cmd/ufetch.c line 148

Quoted 6 lines
cmd/ufetch.c new file +6 -0
+                              gd->baudrate);
+                       break;
+               case DEVICES:
+                       printf("Devices:" RESET " ");
+                       /* TODO: walk the DM tree */
+                       printf("Uncountable!\n");

See dm_announce() for how to do that.

cmd/ufetch.c line 155

Quoted 7 lines
cmd/ufetch.c new file +7 -0
+                       break;
+               case FEATURES:
+                       printf("Features:" RESET " ");
+                       if (IS_ENABLED(CONFIG_NET))
+                               printf("Net");
+                       if (IS_ENABLED(CONFIG_EFI_LOADER))
+                               printf(", EFI");

How about EFI_LOADER ? After all, U-Boot can run as an EFI app so 'EFI' might be better reserved for that.

cmd/ufetch.c

Quoted 7 lines
cmd/ufetch.c new file +7 -0
+                       printf("\n");
+                       break;
+               case RELOCATION:
+                       if (gd->flags & GD_FLG_SKIP_RELOC)
+                               printf("Relocated:" RESET " no\n");
+                       else
+                               printf("Relocated:" RESET " to %#09lx\n",

gd->relocaddr);

Not for this patch but I'd really like to figure out a way to enable/disable ANSI codes globally in U-Boot. For example, we should disable them in tests, or when redirecting sandbox to a file. It affects EFI tests too...so if you have any ideas... :-)

cmd/ufetch.c

Quoted 3 lines
cmd/ufetch.c new file +3 -0
+                       break;
+               case CORES:
+                       ofnode_for_each_subnode(np, ofnode_path("/cpus"))

{

cmd/ufetch.c line 168

Quoted 3 lines
cmd/ufetch.c new file +3 -0
+                               if (ofnode_name_eq(np, "cpu"))
+                                       n_cpus++;
+                       }

uclass_id_count(UCLASS_CPU)

cmd/ufetch.c

Quoted 4 lines
cmd/ufetch.c new file +4 -0
+                       printf("CPU:" RESET " %d (1 in use)\n", n_cpus);
+                       break;
+               case MEMORY:
+                       printf("Memory:" RESET " %lu MB\n",

(ulong)gd->ram_size >> 20);

cmd/ufetch.c

Quoted 7 lines
cmd/ufetch.c new file +7 -0
+                       break;
+               case STORAGE:
+               default:
+                       if (i == STORAGE && get_mmc_num() > 0) {
+                               mmc = find_mmc_device(0);
+                               if (mmc)
+                                       printf("Storage:" RESET "  mmc 0:

%llu MB", mmc->capacity >> 20);

cmd/ufetch.c line 180

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                       }

How about iterating through UCLASS_BLK ?

cmd/ufetch.c line 182

Quoted 2 lines
cmd/ufetch.c new file +2 -0
+                       if (i >= STORAGE + 1) {
+                               ret = blk_get_desc(UCLASS_SCSI, i -

(STORAGE + 1), &scsi_desc);

cmd/ufetch.c line 183

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                               if (!ret && scsi_desc->type !=

DEV_TYPE_UNKNOWN)

cmd/ufetch.c line 184

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                                       /* The calculation here is really

lossy but close enough */

cmd/ufetch.c line 185

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                                       printf("Storage:" RESET " scsi

%d: %lu MB", i - (STORAGE + 1),

cmd/ufetch.c line 186

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                                              ((scsi_desc->lba >> 9) *

scsi_desc->blksz) >> 11);

You can use print_size() - and same above I suppose

Quoted 16 lines
cmd/ufetch.c new file +15 -1
+                       }
+                       printf("\n");
+               }
+       }
+
+       printf(RESET "\n\n");
+
+       return 0;
+}
+
+U_BOOT_CMD(ufetch, 2, 1, do_ufetch,
+       "U-Boot fetch utility",
+       "Print information about your device.\n"
+       "    -n    Don't print the ASCII logo"
+);
--
Quoted 2 lines

2.46.0

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/codingstyle.html#include-files

#2 lore raw

Hi Simon,

Quoted 55 lines · Simon Glass

Hi Caleb,

Quoted 7 lines · On Thu, 8 Aug 2024 at 10:32, Caleb Connolly <[email protected]…

While U-Boot does a pretty good job at printing information at startup about what hardware it's running on, it can be hard to take pretty pictures of this to show off on the internet (by far the most important aspect of porting a device in 2024!).

Add a small utility "ufetch" for displaying some information about

U-Boot and

Quoted 1 line

the hardware it's running on in a similar fashion to the popular

neofetch tool

Quoted 3 lines

for *nix's [1].

While the output is meant to be useful, it should also be pleasing to

look at

Quoted 2 lines

and look good in screenshots. The ufetch command brings this to U-Boot, featuring a colorful ASCII art version of the U-Boot logo and a fancy

layout.

Quoted 2 lines

Finally, tireless device porters can properly show off their hard

work and get

Quoted 3 lines

the internet points they so deserve!

Not everything is fully supported yet, but this seemed good enough

for initial

Quoted 1 line

inclusion. Only one MMC device is detected, and other than SCSI other

storage

Quoted 3 lines

devices aren't supported.

[1]: https://en.wikipedia.org/wiki/Neofetch

<https://en.wikipedia.org/wiki/Neofetch>

Quoted 2 lines

<mailto:[email protected]>>

Quoted 8 lines

---
Ephemeral demo image: https://0x0.st/XVUa.png <https://0x0.st/XVUa.png>
---
  cmd/Kconfig  |   7 ++
  cmd/Makefile |   1 +
  cmd/ufetch.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++

  3 files changed, 209 insertions(+)

  create mode 100644 cmd/ufetch.c

Very cute!

cmd/Kconfig config CMD_CPU · line 175

Quoted 7 lines
cmd/Kconfig +0 -0
index 978f44eda426..70acb5727b04 100644
@@ -175,8 +175,15 @@ config CMD_CPU
            number of CPUs, type (e.g. manufacturer, architecture, 

product or

Quoted 7 lines
Quoted 5 lines

           internal name) and clock frequency. Other information may be available depending on the CPU driver.

+config CMD_UFETCH
+       bool "U-Boot fetch"

How about default y if SANDBOX so that this gets built for that. You should also add doc/ and test/ for the command (although the test can be very basic).

I was really aiming for cmd/2048.c levels of expectation and usability here, not to make this a rugged part of U-Boot's feature set (if someone else would like to go the extra mile they're certainly welcome to).

Making it default y for sandbox so we can at least make sure it compiles sounds reasonable though.

Quoted 28 lines
Quoted 5 lines

+       depends on BLK
+       help
+         Fetch utility for U-Boot (akin to neofetch). Prints information +         about U-Boot and the board it is running on in a pleasing

format.

Quoted 22 lines

+
  config CMD_FWU_METADATA
         bool "fwu metadata read"
         depends on FWU_MULTI_BANK_UPDATE
         help

cmd/Makefile +0 -0
index 87133cc27a8a..ffb04c8f2e0a 100644
@@ -53,8 +53,9 @@ obj-$(CONFIG_CMD_CONSOLE) += console.o

  obj-$(CONFIG_CMD_CPU) += cpu.o
  obj-$(CONFIG_CMD_DATE) += date.o
  obj-$(CONFIG_CMD_DEMO) += demo.o
  obj-$(CONFIG_CMD_DM) += dm.o
+obj-$(CONFIG_CMD_UFETCH) += ufetch.o
  obj-$(CONFIG_CMD_SOUND) += sound.o
  ifdef CONFIG_POST
  obj-$(CONFIG_CMD_DIAG) += diag.o
  endif

cmd/ufetch.c new file +0 -0
new file mode 100644
index 000000000000..f7374eb2e364
Quoted 8 lines

cmd/ufetch.c line 3

Quoted 6 lines
cmd/ufetch.c new file +3 -0
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* Small "fetch" utility for U-Boot */

Isn't it a command, rather than a utility? I think of a utility as a program I run.

I feel like you could ask 5 different people about this and get 5 different answers. As a native british english speaker I would view "utilities" as a subset of "commands" in this context. This isn't a high effort contribution for me so I'm really fine with whatever.

Quoted 16 lines
Quoted 4 lines
cmd/ufetch.c new file +3 -0
+
+#include <mmc.h>
+#include <time.h>

cmd/ufetch.c line 16

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+#include <asm/global_data.h>
+#include <cli.h>
+#include <command.h>
+#include <dm/ofnode.h>
+#include <env.h>
+#include <rand.h>
+#include <vsprintf.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <version.h>

Please check [1]

Sure, I'll order these alphabetically.

Quoted 172 lines
Quoted 6 lines
cmd/ufetch.c new file +5 -0
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define LINE_WIDTH 40
+#define BLUE "\033[38;5;4m"

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+#define YELLOW "\033[38;5;11m"
+#define BOLD "\033[1m"
+#define RESET "\033[0m"
+static const char *logo_lines[] = {
+       BLUE BOLD "                  ......::......                   ",
+       BLUE BOLD "             ...::::::::::::::::::...              ",
+       BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+       BLUE BOLD "        .::::.:::::::::::::::...::::.::::.         ",
+       BLUE BOLD "      .::::::::::::::::::::..::::::::::::::.       ",
+       BLUE BOLD "    .::.:::::::::::::::::::" YELLOW "=*%#*" BLUE 

"::::::::::.::.     ",

cmd/ufetch.c line 32

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "   .:::::::::::::::::....." YELLOW "*%%*-" BLUE 

":....::::::::::.    ",

cmd/ufetch.c line 33

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "  .:.:::...:::::::::.:-" YELLOW "===##*---==-" 

BLUE "::::::::::.:.   ",

cmd/ufetch.c line 34

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " .::::..::::........" YELLOW "-***#****###****-" 

BLUE "...::::::.:.  ",

cmd/ufetch.c line 35

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " ::.:.-" YELLOW "+***+=" BLUE "::-" YELLOW 

"=+**#%%%%%%%%%%%%###*= " BLUE "-::...::::. ",

cmd/ufetch.c line 36

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ".:.::-" YELLOW 

"*****###%%%%%%%%%%%%%%%%%%%%%%%%%%#*=" BLUE ":..:::: ",

cmd/ufetch.c line 37

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ".::" YELLOW "##" BLUE ":" YELLOW 

"***#%%%%%%#####%%%%%%%####%%%%%####%%%*" BLUE "-.::. ",

cmd/ufetch.c line 38

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ":.:" YELLOW "#%" BLUE "::" YELLOW 

"*%%%%%%%#*****##%%%#*****##%%##*****#%%+" BLUE ".::.",

cmd/ufetch.c line 39

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ".::" YELLOW 

"**==#%%%%%%%##****#%%%%##****#%%%%#****###%%" BLUE ":.. ",

cmd/ufetch.c line 40

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "..:" YELLOW "#%" BLUE "::" YELLOW 

"*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#%%%%%+ " BLUE ".:.",

cmd/ufetch.c line 41

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " ::" YELLOW "##" BLUE ":" YELLOW 

"+**#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%* " BLUE "-.:: ",

cmd/ufetch.c line 42

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " ..::-" YELLOW 

"#****#%#%%%%%%%%%%%%%%%%%%%%%%%%%%#*=" BLUE "-..::.  ",

cmd/ufetch.c line 43

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "  ...:=" YELLOW "*****=" BLUE 

"::-\033[38;5;7m=+**###%%%%%%%%###**+=  " BLUE "--:...:::  ",

Quoted 17 lines
cmd/ufetch.c new file +17 -0
+       BLUE BOLD "   .::.::--:........::::::--::::::......::::::.    ",
+       BLUE BOLD "    .::.....::::::::::...........:::::::::.::.     ",
+       BLUE BOLD "      .::::::::::::::::::::::::::::::::::::.       ",
+       BLUE BOLD "        .::::.::::::::::::::::::::::.::::.         ",
+       BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+       BLUE BOLD "             ...::::::::::::::::::...              ",
+       BLUE BOLD "                  ......::......                   ",
+};
+
+enum output_lines {
+       FIRST,
+       SECOND,
+       KERNEL,
+       SYSINFO,
+       HOST,
+       UPTIME,
+       IP,

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+       CMDS,
+       CONSOLES,
+       DEVICES,
+       FEATURES,
+       RELOCATION,
+       CORES,
+       MEMORY,
+       STORAGE,
+
+       /* Up to 10 storage devices... Should be enough for anyone 

right? */

Quoted 21 lines
cmd/ufetch.c new file +21 -0
+       _LAST_LINE = (STORAGE + 10),
+#define LAST_LINE (_LAST_LINE - 1UL)
+};
+
+static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,
+                    char *const argv[])
+{
+       int num_lines = max(LAST_LINE + 1, ARRAY_SIZE(logo_lines));
+       const char *model, *compatible;
+       char *ipaddr;
+       int n_cmds, n_cpus = 0, ret, compatlen;
+       ofnode np;
+       struct mmc *mmc;
+       struct blk_desc *scsi_desc;
+       bool skip_ascii = false;
+
+       if (argc > 1 && strcmp(argv[1], "-n") == 0) {
+               skip_ascii = true;
+               num_lines = LAST_LINE;
+       }
+

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+       for (int i = 0; i < num_lines; i++) {
+               if (!skip_ascii) {
+                       if (i < ARRAY_SIZE(logo_lines))
+                               printf("%s ", logo_lines[i]);
+                       else
+                               printf("%*c ", LINE_WIDTH, ' ');
+               }
+               switch (i) {
+               case FIRST:
+                       compatible = 

ofnode_read_string(ofnode_root(), "compatible");

Quoted 5 lines
cmd/ufetch.c new file +5 -0
+                       if (!compatible)
+                               compatible = "unknown";
+                       printf(RESET "%s\n", compatible);
+                       compatlen = strlen(compatible);
+                       break;

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+               case SECOND:
+                       for (int j = 0; j < compatlen; j++)
+                               putc('-');
+                       putc('\n');
+                       break;
+               case KERNEL:
+                       printf("Kernel:" RESET " %s\n", U_BOOT_VERSION);
+                       break;
+               case SYSINFO:
+                       printf("Config:" RESET " %s_defconfig\n", 

CONFIG_SYS_CONFIG_NAME);

cmd/ufetch.c

Quoted 3 lines
cmd/ufetch.c new file +3 -0
+                       break;
+               case HOST:
+                       model = ofnode_read_string(ofnode_root(), 

"model");

cmd/ufetch.c

Quoted 5 lines
cmd/ufetch.c new file +5 -0
+                       if (model)
+                               printf("Host:" RESET " %s\n", model);
+                       break;
+               case UPTIME:
+                       printf("Uptime:" RESET " %ld seconds\n", 

get_timer(0) / 1000);

Quoted 8 lines
cmd/ufetch.c new file +8 -0
+                       break;
+               case IP:
+                       ipaddr = env_get("ipvaddr");
+                       if (!ipaddr)
+                               ipaddr = "none";
+                       printf("IP Address:" RESET " %s", ipaddr);
+                       ipaddr = env_get("ipv6addr");
+                       if (ipaddr)

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+                               printf(", %s\n", ipaddr);
+                       else
+                               putc('\n');
+                       break;
+               case CMDS:
+                       n_cmds = ll_entry_count(struct cmd_tbl, cmd);
+                       printf("Commands:" RESET " %d (help)\n", n_cmds);
+                       break;
+               case CONSOLES:
+                       printf("Consoles:" RESET " %s (%d baud)\n", 

env_get("stdout"),

cmd/ufetch.c line 148

Quoted 6 lines
cmd/ufetch.c new file +6 -0
+                              gd->baudrate);
+                       break;
+               case DEVICES:
+                       printf("Devices:" RESET " ");
+                       /* TODO: walk the DM tree */
+                       printf("Uncountable!\n");

See dm_announce() for how to do that.

cmd/ufetch.c line 155

Quoted 7 lines
cmd/ufetch.c new file +7 -0
+                       break;
+               case FEATURES:
+                       printf("Features:" RESET " ");
+                       if (IS_ENABLED(CONFIG_NET))
+                               printf("Net");
+                       if (IS_ENABLED(CONFIG_EFI_LOADER))
+                               printf(", EFI");

How about EFI_LOADER ? After all, U-Boot can run as an EFI app so 'EFI' might be better reserved for that.

cmd/ufetch.c

Quoted 7 lines
cmd/ufetch.c new file +7 -0
+                       printf("\n");
+                       break;
+               case RELOCATION:
+                       if (gd->flags & GD_FLG_SKIP_RELOC)
+                               printf("Relocated:" RESET " no\n");
+                       else
+                               printf("Relocated:" RESET " to 
Quoted 3 lines

%#09lx\n", gd->relocaddr);

Not for this patch but I'd really like to figure out a way to enable/disable ANSI codes globally in U-Boot. For example, we should disable them in tests, or when redirecting sandbox to a file. It affects EFI tests too...so if you have any ideas... :-)

Only thing that comes to mind would be adding a compile time flag to printf which teaches it to parse and skip ANSI escape codes.

Quoted 23 lines

cmd/ufetch.c

Quoted 4 lines
cmd/ufetch.c new file +3 -0
+                       break;
+               case CORES:
+                       ofnode_for_each_subnode(np, 

ofnode_path("/cpus")) {

cmd/ufetch.c line 168

Quoted 3 lines
cmd/ufetch.c new file +3 -0
+                               if (ofnode_name_eq(np, "cpu"))
+                                       n_cpus++;
+                       }

uclass_id_count(UCLASS_CPU)

cmd/ufetch.c

Quoted 4 lines
cmd/ufetch.c new file +4 -0
+                       printf("CPU:" RESET " %d (1 in use)\n", n_cpus);
+                       break;
+               case MEMORY:
+                       printf("Memory:" RESET " %lu MB\n", 

(ulong)gd->ram_size >> 20);

cmd/ufetch.c

Quoted 7 lines
cmd/ufetch.c new file +7 -0
+                       break;
+               case STORAGE:
+               default:
+                       if (i == STORAGE && get_mmc_num() > 0) {
+                               mmc = find_mmc_device(0);
+                               if (mmc)
+                                       printf("Storage:" RESET "  
Quoted 4 lines

mmc 0: %llu MB", mmc->capacity >> 20);

cmd/ufetch.c line 180

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                       }

How about iterating through UCLASS_BLK ?

Probably a much more sensible approach tbh, can you easily determine the size of a block device?

Quoted 6 lines

cmd/ufetch.c line 182

Quoted 3 lines
cmd/ufetch.c new file +2 -0
+                       if (i >= STORAGE + 1) {
+                               ret = blk_get_desc(UCLASS_SCSI, i - 

(STORAGE + 1), &scsi_desc);

cmd/ufetch.c line 183

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                               if (!ret && scsi_desc->type != 

DEV_TYPE_UNKNOWN)

Quoted 8 lines

cmd/ufetch.c line 184

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                                       /* The calculation here is 

really lossy but close enough */

cmd/ufetch.c line 185

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                                       printf("Storage:" RESET " 

scsi %d: %lu MB", i - (STORAGE + 1),

cmd/ufetch.c line 186

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                                              ((scsi_desc->lba >> 9) 

* scsi_desc->blksz) >> 11);

You can use print_size() - and same above I suppose

haha yeahp i should really do that instead.

Thanks for the review!

Quoted 25 lines
Quoted 17 lines
cmd/ufetch.c new file +15 -1
+                       }
+                       printf("\n");
+               }
+       }
+
+       printf(RESET "\n\n");
+
+       return 0;
+}
+
+U_BOOT_CMD(ufetch, 2, 1, do_ufetch,
+       "U-Boot fetch utility",
+       "Print information about your device.\n"
+       "    -n    Don't print the ASCII logo"
+);
--
Quoted 2 lines

2.46.0

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/codingstyle.html#include-files <https://docs.u-boot.org/en/latest/develop/codingstyle.html#include-files>

Signature · 1 line
// Caleb (they/them)
#3 lore raw

Hi Caleb,

Quoted 111 lines · Caleb Connolly

Hi Simon,

Quoted 59 lines · Simon Glass

Hi Caleb,

Quoted 7 lines · On Thu, 8 Aug 2024 at 10:32, Caleb Connolly <[email protected]…

While U-Boot does a pretty good job at printing information at startup about what hardware it's running on, it can be hard to take pretty pictures of this to show off on the internet (by far the most important aspect of porting a device in 2024!).

Add a small utility "ufetch" for displaying some information about

U-Boot and

Quoted 1 line

the hardware it's running on in a similar fashion to the popular

neofetch tool

Quoted 3 lines

for *nix's [1].

While the output is meant to be useful, it should also be pleasing to

look at

Quoted 2 lines

and look good in screenshots. The ufetch command brings this to U-Boot, featuring a colorful ASCII art version of the U-Boot logo and a fancy

layout.

Quoted 2 lines

Finally, tireless device porters can properly show off their hard

work and get

Quoted 3 lines

the internet points they so deserve!

Not everything is fully supported yet, but this seemed good enough

for initial

Quoted 1 line

inclusion. Only one MMC device is detected, and other than SCSI other

storage

Quoted 3 lines

devices aren't supported.

[1]: https://en.wikipedia.org/wiki/Neofetch

<https://en.wikipedia.org/wiki/Neofetch>

Quoted 2 lines

<mailto:[email protected]>>

Quoted 8 lines

---
Ephemeral demo image: https://0x0.st/XVUa.png <https://0x0.st/XVUa.png>

---
 cmd/Kconfig  |   7 ++
 cmd/Makefile |   1 +
 cmd/ufetch.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 209 insertions(+)
 create mode 100644 cmd/ufetch.c

Very cute!

cmd/Kconfig config CMD_CPU · line 175

Quoted 7 lines
cmd/Kconfig +0 -0
index 978f44eda426..70acb5727b04 100644
@@ -175,8 +175,15 @@ config CMD_CPU
          number of CPUs, type (e.g. manufacturer, architecture,

product or

Quoted 3 lines
cmd/Kconfig +0 -0
          internal name) and clock frequency. Other information may be
          available depending on the CPU driver.
 
Quoted 6 lines

cmd/Kconfig config CMD_CPU · line 180

Quoted 2 lines
cmd/Kconfig +2 -0
+config CMD_UFETCH
+       bool "U-Boot fetch"

How about default y if SANDBOX so that this gets built for that. You should also add doc/ and test/ for the command (although the test can be very basic).

I was really aiming for cmd/2048.c levels of expectation and usability here, not to make this a rugged part of U-Boot's feature set (if someone else would like to go the extra mile they're certainly welcome to).

Making it default y for sandbox so we can at least make sure it compiles sounds reasonable though.

Quoted 35 lines

cmd/Kconfig config CMD_CPU

Quoted 5 lines
cmd/Kconfig +4 -0
+       depends on BLK
+       help
+         Fetch utility for U-Boot (akin to neofetch). Prints information
+         about U-Boot and the board it is running on in a pleasing

format.

Quoted 28 lines
cmd/Kconfig +1 -0
+
 config CMD_FWU_METADATA
        bool "fwu metadata read"
        depends on FWU_MULTI_BANK_UPDATE
        help
cmd/Makefile +1 -0
index 87133cc27a8a..ffb04c8f2e0a 100644
@@ -53,8 +53,9 @@ obj-$(CONFIG_CMD_CONSOLE) += console.o
 obj-$(CONFIG_CMD_CPU) += cpu.o
 obj-$(CONFIG_CMD_DATE) += date.o
 obj-$(CONFIG_CMD_DEMO) += demo.o
 obj-$(CONFIG_CMD_DM) += dm.o
+obj-$(CONFIG_CMD_UFETCH) += ufetch.o
 obj-$(CONFIG_CMD_SOUND) += sound.o
 ifdef CONFIG_POST
 obj-$(CONFIG_CMD_DIAG) += diag.o
 endif
cmd/ufetch.c new file +3 -0
new file mode 100644
index 000000000000..f7374eb2e364
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* Small "fetch" utility for U-Boot */
Quoted 7 lines
Quoted 2 lines

Isn't it a command, rather than a utility? I think of a utility as a program I run.

I feel like you could ask 5 different people about this and get 5 different answers. As a native british english speaker I would view "utilities" as a subset of "commands" in this context. This isn't a high effort contribution for me so I'm really fine with whatever.

OK I see, fair enough.

Quoted 193 lines
Quoted 16 lines
Quoted 4 lines
cmd/ufetch.c new file +3 -0
+
+#include <mmc.h>
+#include <time.h>

cmd/ufetch.c line 16

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+#include <asm/global_data.h>
+#include <cli.h>
+#include <command.h>
+#include <dm/ofnode.h>
+#include <env.h>
+#include <rand.h>
+#include <vsprintf.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <version.h>

Please check [1]

Sure, I'll order these alphabetically.

Quoted 175 lines
Quoted 6 lines
cmd/ufetch.c new file +5 -0
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define LINE_WIDTH 40
+#define BLUE "\033[38;5;4m"

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+#define YELLOW "\033[38;5;11m"
+#define BOLD "\033[1m"
+#define RESET "\033[0m"
+static const char *logo_lines[] = {
+       BLUE BOLD "                  ......::......                   ",
+       BLUE BOLD "             ...::::::::::::::::::...              ",
+       BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+       BLUE BOLD "        .::::.:::::::::::::::...::::.::::.         ",
+       BLUE BOLD "      .::::::::::::::::::::..::::::::::::::.       ",
+       BLUE BOLD "    .::.:::::::::::::::::::" YELLOW "=*%#*" BLUE

"::::::::::.::. ",

cmd/ufetch.c line 32

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "   .:::::::::::::::::....." YELLOW "*%%*-" BLUE

":....::::::::::. ",

cmd/ufetch.c line 33

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "  .:.:::...:::::::::.:-" YELLOW "===##*---==-"

BLUE "::::::::::.:. ",

cmd/ufetch.c line 34

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " .::::..::::........" YELLOW "-***#****###****-"

BLUE "...::::::.:. ",

cmd/ufetch.c line 35

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " ::.:.-" YELLOW "+***+=" BLUE "::-" YELLOW

"=+**#%%%%%%%%%%%%###*= " BLUE "-::...::::. ",

cmd/ufetch.c line 36

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ".:.::-" YELLOW

"*****###%%%%%%%%%%%%%%%%%%%%%%%%%%#*=" BLUE ":..:::: ",

cmd/ufetch.c line 37

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ".::" YELLOW "##" BLUE ":" YELLOW

"***#%%%%%%#####%%%%%%%####%%%%%####%%%*" BLUE "-.::. ",

cmd/ufetch.c line 38

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ":.:" YELLOW "#%" BLUE "::" YELLOW

"*%%%%%%%#*****##%%%#*****##%%##*****#%%+" BLUE ".::.",

cmd/ufetch.c line 39

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD ".::" YELLOW

"**==#%%%%%%%##****#%%%%##****#%%%%#****###%%" BLUE ":.. ",

cmd/ufetch.c line 40

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "..:" YELLOW "#%" BLUE "::" YELLOW

"*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#%%%%%+ " BLUE ".:.",

cmd/ufetch.c line 41

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " ::" YELLOW "##" BLUE ":" YELLOW

"+**#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%* " BLUE "-.:: ",

cmd/ufetch.c line 42

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD " ..::-" YELLOW

"#****#%#%%%%%%%%%%%%%%%%%%%%%%%%%%#*=" BLUE "-..::. ",

cmd/ufetch.c line 43

Quoted 1 line
cmd/ufetch.c new file +1 -0
+       BLUE BOLD "  ...:=" YELLOW "*****=" BLUE

"::-\033[38;5;7m=+**###%%%%%%%%###**+= " BLUE "--:...::: ",

Quoted 17 lines
cmd/ufetch.c new file +17 -0
+       BLUE BOLD "   .::.::--:........::::::--::::::......::::::.    ",
+       BLUE BOLD "    .::.....::::::::::...........:::::::::.::.     ",
+       BLUE BOLD "      .::::::::::::::::::::::::::::::::::::.       ",
+       BLUE BOLD "        .::::.::::::::::::::::::::::.::::.         ",
+       BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+       BLUE BOLD "             ...::::::::::::::::::...              ",
+       BLUE BOLD "                  ......::......                   ",
+};
+
+enum output_lines {
+       FIRST,
+       SECOND,
+       KERNEL,
+       SYSINFO,
+       HOST,
+       UPTIME,
+       IP,

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+       CMDS,
+       CONSOLES,
+       DEVICES,
+       FEATURES,
+       RELOCATION,
+       CORES,
+       MEMORY,
+       STORAGE,
+
+       /* Up to 10 storage devices... Should be enough for anyone

right? */

Quoted 21 lines
cmd/ufetch.c new file +21 -0
+       _LAST_LINE = (STORAGE + 10),
+#define LAST_LINE (_LAST_LINE - 1UL)
+};
+
+static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,
+                    char *const argv[])
+{
+       int num_lines = max(LAST_LINE + 1, ARRAY_SIZE(logo_lines));
+       const char *model, *compatible;
+       char *ipaddr;
+       int n_cmds, n_cpus = 0, ret, compatlen;
+       ofnode np;
+       struct mmc *mmc;
+       struct blk_desc *scsi_desc;
+       bool skip_ascii = false;
+
+       if (argc > 1 && strcmp(argv[1], "-n") == 0) {
+               skip_ascii = true;
+               num_lines = LAST_LINE;
+       }
+

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+       for (int i = 0; i < num_lines; i++) {
+               if (!skip_ascii) {
+                       if (i < ARRAY_SIZE(logo_lines))
+                               printf("%s ", logo_lines[i]);
+                       else
+                               printf("%*c ", LINE_WIDTH, ' ');
+               }
+               switch (i) {
+               case FIRST:
+                       compatible =

ofnode_read_string(ofnode_root(), "compatible");

Quoted 5 lines
cmd/ufetch.c new file +5 -0
+                       if (!compatible)
+                               compatible = "unknown";
+                       printf(RESET "%s\n", compatible);
+                       compatlen = strlen(compatible);
+                       break;

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+               case SECOND:
+                       for (int j = 0; j < compatlen; j++)
+                               putc('-');
+                       putc('\n');
+                       break;
+               case KERNEL:
+                       printf("Kernel:" RESET " %s\n", U_BOOT_VERSION);
+                       break;
+               case SYSINFO:
+                       printf("Config:" RESET " %s_defconfig\n",

CONFIG_SYS_CONFIG_NAME);

cmd/ufetch.c

Quoted 3 lines
cmd/ufetch.c new file +3 -0
+                       break;
+               case HOST:
+                       model = ofnode_read_string(ofnode_root(),

"model");

cmd/ufetch.c

Quoted 5 lines
cmd/ufetch.c new file +5 -0
+                       if (model)
+                               printf("Host:" RESET " %s\n", model);
+                       break;
+               case UPTIME:
+                       printf("Uptime:" RESET " %ld seconds\n",

get_timer(0) / 1000);

Quoted 8 lines
cmd/ufetch.c new file +8 -0
+                       break;
+               case IP:
+                       ipaddr = env_get("ipvaddr");
+                       if (!ipaddr)
+                               ipaddr = "none";
+                       printf("IP Address:" RESET " %s", ipaddr);
+                       ipaddr = env_get("ipv6addr");
+                       if (ipaddr)

cmd/ufetch.c

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+                               printf(", %s\n", ipaddr);
+                       else
+                               putc('\n');
+                       break;
+               case CMDS:
+                       n_cmds = ll_entry_count(struct cmd_tbl, cmd);
+                       printf("Commands:" RESET " %d (help)\n", n_cmds);
+                       break;
+               case CONSOLES:
+                       printf("Consoles:" RESET " %s (%d baud)\n",

env_get("stdout"),

cmd/ufetch.c line 148

Quoted 6 lines
cmd/ufetch.c new file +6 -0
+                              gd->baudrate);
+                       break;
+               case DEVICES:
+                       printf("Devices:" RESET " ");
+                       /* TODO: walk the DM tree */
+                       printf("Uncountable!\n");

See dm_announce() for how to do that.

cmd/ufetch.c line 155

Quoted 7 lines
cmd/ufetch.c new file +7 -0
+                       break;
+               case FEATURES:
+                       printf("Features:" RESET " ");
+                       if (IS_ENABLED(CONFIG_NET))
+                               printf("Net");
+                       if (IS_ENABLED(CONFIG_EFI_LOADER))
+                               printf(", EFI");

How about EFI_LOADER ? After all, U-Boot can run as an EFI app so 'EFI' might be better reserved for that.

cmd/ufetch.c

Quoted 7 lines
cmd/ufetch.c new file +7 -0
+                       printf("\n");
+                       break;
+               case RELOCATION:
+                       if (gd->flags & GD_FLG_SKIP_RELOC)
+                               printf("Relocated:" RESET " no\n");
+                       else
+                               printf("Relocated:" RESET " to

%#09lx\n", gd->relocaddr);

Quoted 7 lines
Quoted 4 lines

Not for this patch but I'd really like to figure out a way to enable/disable ANSI codes globally in U-Boot. For example, we should disable them in tests, or when redirecting sandbox to a file. It affects EFI tests too...so if you have any ideas... :-)

Only thing that comes to mind would be adding a compile time flag to printf which teaches it to parse and skip ANSI escape codes.

Ideally it would have the option to be run-time, if we want to pay an extra penalty. Then we can use the same sandbox build with tests as we do for normal usage.

Quoted 26 lines
Quoted 26 lines

cmd/ufetch.c

Quoted 4 lines
cmd/ufetch.c new file +3 -0
+                       break;
+               case CORES:
+                       ofnode_for_each_subnode(np,

ofnode_path("/cpus")) {

cmd/ufetch.c line 168

Quoted 3 lines
cmd/ufetch.c new file +3 -0
+                               if (ofnode_name_eq(np, "cpu"))
+                                       n_cpus++;
+                       }

uclass_id_count(UCLASS_CPU)

cmd/ufetch.c

Quoted 4 lines
cmd/ufetch.c new file +4 -0
+                       printf("CPU:" RESET " %d (1 in use)\n", n_cpus);
+                       break;
+               case MEMORY:
+                       printf("Memory:" RESET " %lu MB\n",

(ulong)gd->ram_size >> 20);

cmd/ufetch.c

Quoted 7 lines
cmd/ufetch.c new file +7 -0
+                       break;
+               case STORAGE:
+               default:
+                       if (i == STORAGE && get_mmc_num() > 0) {
+                               mmc = find_mmc_device(0);
+                               if (mmc)
+                                       printf("Storage:" RESET "

mmc 0: %llu MB", mmc->capacity >> 20);

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                       }
Quoted 4 lines
Quoted 1 line

How about iterating through UCLASS_BLK ?

Probably a much more sensible approach tbh, can you easily determine the size of a block device?

You can do something like this:

struct udevice *dev; // block device
struct blk_desc *desc = dev_get_uclass_plat(dev);

size = desc->lba * desc->blksz

Quoted 13 lines
Quoted 13 lines

cmd/ufetch.c line 182

Quoted 3 lines
cmd/ufetch.c new file +2 -0
+                       if (i >= STORAGE + 1) {
+                               ret = blk_get_desc(UCLASS_SCSI, i -

(STORAGE + 1), &scsi_desc);

cmd/ufetch.c line 183

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                               if (!ret && scsi_desc->type !=

DEV_TYPE_UNKNOWN)

cmd/ufetch.c line 184

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                                       /* The calculation here is

really lossy but close enough */

cmd/ufetch.c line 185

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                                       printf("Storage:" RESET "

scsi %d: %lu MB", i - (STORAGE + 1),

cmd/ufetch.c line 186

Quoted 1 line
cmd/ufetch.c new file +1 -0
+                                              ((scsi_desc->lba >> 9)

* scsi_desc->blksz) >> 11);

Quoted 29 lines
Quoted 1 line

You can use print_size() - and same above I suppose

haha yeahp i should really do that instead.

Thanks for the review!

Quoted 24 lines
Quoted 17 lines
cmd/ufetch.c new file +15 -1
+                       }
+                       printf("\n");
+               }
+       }
+
+       printf(RESET "\n\n");
+
+       return 0;
+}
+
+U_BOOT_CMD(ufetch, 2, 1, do_ufetch,
+       "U-Boot fetch utility",
+       "Print information about your device.\n"
+       "    -n    Don't print the ASCII logo"
+);
--
Quoted 1 line

2.46.0

[1]
https://docs.u-boot.org/en/latest/develop/codingstyle.html#include-files
<https://docs.u-boot.org/en/latest/develop/codingstyle.html#include-files>

Regards,
Simon

#4 lore raw
In reply to Caleb Connolly
Quoted 189 lines · Caleb Connolly

While U-Boot does a pretty good job at printing information at startup about what hardware it's running on, it can be hard to take pretty pictures of this to show off on the internet (by far the most important aspect of porting a device in 2024!).

Add a small utility "ufetch" for displaying some information about U-Boot and the hardware it's running on in a similar fashion to the popular neofetch tool for *nix's [1].

While the output is meant to be useful, it should also be pleasing to look at and look good in screenshots. The ufetch command brings this to U-Boot, featuring a colorful ASCII art version of the U-Boot logo and a fancy layout.

Finally, tireless device porters can properly show off their hard work and get the internet points they so deserve!

Not everything is fully supported yet, but this seemed good enough for initial inclusion. Only one MMC device is detected, and other than SCSI other storage devices aren't supported.

[1]: https://en.wikipedia.org/wiki/Neofetch

---
Ephemeral demo image: https://0x0.st/XVUa.png

---
  cmd/Kconfig  |   7 ++
  cmd/Makefile |   1 +
  cmd/ufetch.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 209 insertions(+)

create mode 100644 cmd/ufetch.c

cmd/Kconfig +7 -0
index 978f44eda426..70acb5727b04 100644
@@ -175,8 +175,15 @@ config CMD_CPU
  	  number of CPUs, type (e.g. manufacturer, architecture, product or
  	  internal name) and clock frequency. Other information may be
  	  available depending on the CPU driver.
 
+config CMD_UFETCH
+	bool "U-Boot fetch"
+	depends on BLK
+	help
+	  Fetch utility for U-Boot (akin to neofetch). Prints information
+	  about U-Boot and the board it is running on in a pleasing format.
+
  config CMD_FWU_METADATA
  	bool "fwu metadata read"
  	depends on FWU_MULTI_BANK_UPDATE
  	help
cmd/Makefile +1 -0
index 87133cc27a8a..ffb04c8f2e0a 100644
@@ -53,8 +53,9 @@ obj-$(CONFIG_CMD_CONSOLE) += console.o
  obj-$(CONFIG_CMD_CPU) += cpu.o
  obj-$(CONFIG_CMD_DATE) += date.o
  obj-$(CONFIG_CMD_DEMO) += demo.o
  obj-$(CONFIG_CMD_DM) += dm.o
+obj-$(CONFIG_CMD_UFETCH) += ufetch.o
  obj-$(CONFIG_CMD_SOUND) += sound.o
  ifdef CONFIG_POST
  obj-$(CONFIG_CMD_DIAG) += diag.o
  endif
cmd/ufetch.c new file +117 -0
new file mode 100644
index 000000000000..f7374eb2e364
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* Small "fetch" utility for U-Boot */
+
+#include <mmc.h>
+#include <time.h>
+#include <asm/global_data.h>
+#include <cli.h>
+#include <command.h>
+#include <dm/ofnode.h>
+#include <env.h>
+#include <rand.h>
+#include <vsprintf.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <version.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define LINE_WIDTH 40
+#define BLUE "\033[38;5;4m"
+#define YELLOW "\033[38;5;11m"
+#define BOLD "\033[1m"
+#define RESET "\033[0m"
+static const char *logo_lines[] = {
+	BLUE BOLD "                  ......::......                   ",
+	BLUE BOLD "             ...::::::::::::::::::...              ",
+	BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+	BLUE BOLD "        .::::.:::::::::::::::...::::.::::.         ",
+	BLUE BOLD "      .::::::::::::::::::::..::::::::::::::.       ",
+	BLUE BOLD "    .::.:::::::::::::::::::" YELLOW "=*%#*" BLUE "::::::::::.::.     ",
+	BLUE BOLD "   .:::::::::::::::::....." YELLOW "*%%*-" BLUE ":....::::::::::.    ",
+	BLUE BOLD "  .:.:::...:::::::::.:-" YELLOW "===##*---==-" BLUE "::::::::::.:.   ",
+	BLUE BOLD " .::::..::::........" YELLOW "-***#****###****-" BLUE "...::::::.:.  ",
+	BLUE BOLD " ::.:.-" YELLOW "+***+=" BLUE "::-" YELLOW "=+**#%%%%%%%%%%%%###*= " BLUE "-::...::::. ",
+	BLUE BOLD ".:.::-" YELLOW "*****###%%%%%%%%%%%%%%%%%%%%%%%%%%#*=" BLUE ":..:::: ",
+	BLUE BOLD ".::" YELLOW "##" BLUE ":" YELLOW "***#%%%%%%#####%%%%%%%####%%%%%####%%%*" BLUE "-.::. ",
+	BLUE BOLD ":.:" YELLOW "#%" BLUE "::" YELLOW "*%%%%%%%#*****##%%%#*****##%%##*****#%%+" BLUE ".::.",
+	BLUE BOLD ".::" YELLOW "**==#%%%%%%%##****#%%%%##****#%%%%#****###%%" BLUE ":.. ",
+	BLUE BOLD "..:" YELLOW "#%" BLUE "::" YELLOW "*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#%%%%%+ " BLUE ".:.",
+	BLUE BOLD " ::" YELLOW "##" BLUE ":" YELLOW "+**#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%* " BLUE "-.:: ",
+	BLUE BOLD " ..::-" YELLOW "#****#%#%%%%%%%%%%%%%%%%%%%%%%%%%%#*=" BLUE "-..::.  ",
+	BLUE BOLD "  ...:=" YELLOW "*****=" BLUE "::-\033[38;5;7m=+**###%%%%%%%%###**+=  " BLUE "--:...:::  ",
+	BLUE BOLD "   .::.::--:........::::::--::::::......::::::.    ",
+	BLUE BOLD "    .::.....::::::::::...........:::::::::.::.     ",
+	BLUE BOLD "      .::::::::::::::::::::::::::::::::::::.       ",
+	BLUE BOLD "        .::::.::::::::::::::::::::::.::::.         ",
+	BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+	BLUE BOLD "             ...::::::::::::::::::...              ",
+	BLUE BOLD "                  ......::......                   ",
+};
+
+enum output_lines {
+	FIRST,
+	SECOND,
+	KERNEL,
+	SYSINFO,
+	HOST,
+	UPTIME,
+	IP,
+	CMDS,
+	CONSOLES,
+	DEVICES,
+	FEATURES,
+	RELOCATION,
+	CORES,
+	MEMORY,
+	STORAGE,
+
+	/* Up to 10 storage devices... Should be enough for anyone right? */
+	_LAST_LINE = (STORAGE + 10),
+#define LAST_LINE (_LAST_LINE - 1UL)
+};
+
+static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,
+		     char *const argv[])
+{
+	int num_lines = max(LAST_LINE + 1, ARRAY_SIZE(logo_lines));
+	const char *model, *compatible;
+	char *ipaddr;
+	int n_cmds, n_cpus = 0, ret, compatlen;
+	ofnode np;
+	struct mmc *mmc;
+	struct blk_desc *scsi_desc;
+	bool skip_ascii = false;
+
+	if (argc > 1 && strcmp(argv[1], "-n") == 0) {
+		skip_ascii = true;
+		num_lines = LAST_LINE;
+	}
+
+	for (int i = 0; i < num_lines; i++) {
+		if (!skip_ascii) {
+			if (i < ARRAY_SIZE(logo_lines))
+				printf("%s ", logo_lines[i]);
+			else
+				printf("%*c ", LINE_WIDTH, ' ');
+		}
+		switch (i) {
+		case FIRST:
+			compatible = ofnode_read_string(ofnode_root(), "compatible");
+			if (!compatible)
+				compatible = "unknown";
+			printf(RESET "%s\n", compatible);
+			compatlen = strlen(compatible);
+			break;
+		case SECOND:
+			for (int j = 0; j < compatlen; j++)
+				putc('-');
+			putc('\n');
+			break;
+		case KERNEL:
+			printf("Kernel:" RESET " %s\n", U_BOOT_VERSION);
+			break;
+		case SYSINFO:
+			printf("Config:" RESET " %s_defconfig\n", CONFIG_SYS_CONFIG_NAME);
+			break;

cmd/ufetch.c line 127

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+		case HOST:
+			model = ofnode_read_string(ofnode_root(), "model");
+			if (model)
+				printf("Host:" RESET " %s\n", model);
+			break;
+		case UPTIME:
+			printf("Uptime:" RESET " %ld seconds\n", get_timer(0) / 1000);
+			break;
+		case IP:
+			ipaddr = env_get("ipvaddr");

ipaddr here.

Quoted 35 lines
cmd/ufetch.c new file +35 -0
+			if (!ipaddr)
+				ipaddr = "none";
+			printf("IP Address:" RESET " %s", ipaddr);
+			ipaddr = env_get("ipv6addr");
+			if (ipaddr)
+				printf(", %s\n", ipaddr);
+			else
+				putc('\n');
+			break;
+		case CMDS:
+			n_cmds = ll_entry_count(struct cmd_tbl, cmd);
+			printf("Commands:" RESET " %d (help)\n", n_cmds);
+			break;
+		case CONSOLES:
+			printf("Consoles:" RESET " %s (%d baud)\n", env_get("stdout"),
+			       gd->baudrate);
+			break;
+		case DEVICES:
+			printf("Devices:" RESET " ");
+			/* TODO: walk the DM tree */
+			printf("Uncountable!\n");
+			break;
+		case FEATURES:
+			printf("Features:" RESET " ");
+			if (IS_ENABLED(CONFIG_NET))
+				printf("Net");
+			if (IS_ENABLED(CONFIG_EFI_LOADER))
+				printf(", EFI");
+			printf("\n");
+			break;
+		case RELOCATION:
+			if (gd->flags & GD_FLG_SKIP_RELOC)
+				printf("Relocated:" RESET " no\n");
+			else
+				printf("Relocated:" RESET " to %#09lx\n", gd->relocaddr);

cmd/ufetch.c line 172

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+			break;
+		case CORES:
+			ofnode_for_each_subnode(np, ofnode_path("/cpus")) {
+				if (ofnode_name_eq(np, "cpu"))
+					n_cpus++;
+			}
+			printf("CPU:" RESET " %d (1 in use)\n", n_cpus);
+			break;
+		case MEMORY:
+			printf("Memory:" RESET " %lu MB\n", (ulong)gd->ram_size >> 20);

This is kind of shortcut (and nothing wrong on it)

In my case I see 2GB here but board has 4GB which is properly shown via show_dram_config() as

DRAM: 2 GiB (effective 4 GiB)

Maybe you can simply call this function to get the same information.
Also I see that there is board_add_ram_info() called which can provide more information.

Thanks,
Michal

#5 lore raw
In reply to Caleb Connolly

Am 8. August 2024 18:24:24 MESZ schrieb Caleb Connolly <[email protected]>:

Quoted 13 lines

While U-Boot does a pretty good job at printing information at startup about what hardware it's running on, it can be hard to take pretty pictures of this to show off on the internet (by far the most important aspect of porting a device in 2024!).

Add a small utility "ufetch" for displaying some information about U-Boot and the hardware it's running on in a similar fashion to the popular neofetch tool for *nix's [1].

While the output is meant to be useful, it should also be pleasing to look at and look good in screenshots. The ufetch command brings this to U-Boot, featuring a colorful ASCII art version of the U-Boot logo and a fancy layout.

Quoted 6 lines

Finally, tireless device porters can properly show off their hard work and get the internet points they so deserve!

Not everything is fully supported yet, but this seemed good enough for initial inclusion. Only one MMC device is detected, and other than SCSI other storage devices aren't supported.

This command is not very generic. E.g. it supports SCSI drives but not SATA. Many boards have eMMC and SD-card. This lks more ike an RFC tan something ready to merge.

Why don't you use a script or an EFI program to print whatever information you need?

Quoted 155 lines

[1]: https://en.wikipedia.org/wiki/Neofetch

---
Ephemeral demo image: https://0x0.st/XVUa.png
---

cmd/Kconfig  |   7 ++
cmd/Makefile |   1 +
cmd/ufetch.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 209 insertions(+)

create mode 100644 cmd/ufetch.c

cmd/Kconfig +7 -0
index 978f44eda426..70acb5727b04 100644
@@ -175,8 +175,15 @@ config CMD_CPU
 	  number of CPUs, type (e.g. manufacturer, architecture, product or
 	  internal name) and clock frequency. Other information may be
 	  available depending on the CPU driver.
 
+config CMD_UFETCH
+	bool "U-Boot fetch"
+	depends on BLK
+	help
+	  Fetch utility for U-Boot (akin to neofetch). Prints information
+	  about U-Boot and the board it is running on in a pleasing format.
+

config CMD_FWU_METADATA
bool "fwu metadata read"
depends on FWU_MULTI_BANK_UPDATE
help

cmd/Makefile +0 -0
index 87133cc27a8a..ffb04c8f2e0a 100644
@@ -53,8 +53,9 @@ obj-$(CONFIG_CMD_CONSOLE) += console.o

obj-$(CONFIG_CMD_CPU) += cpu.o
obj-$(CONFIG_CMD_DATE) += date.o
obj-$(CONFIG_CMD_DEMO) += demo.o
obj-$(CONFIG_CMD_DM) += dm.o
+obj-$(CONFIG_CMD_UFETCH) += ufetch.o
obj-$(CONFIG_CMD_SOUND) += sound.o
ifdef CONFIG_POST
obj-$(CONFIG_CMD_DIAG) += diag.o
endif

cmd/ufetch.c new file +102 -0
new file mode 100644
index 000000000000..f7374eb2e364
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* Small "fetch" utility for U-Boot */
+
+#include <mmc.h>
+#include <time.h>
+#include <asm/global_data.h>
+#include <cli.h>
+#include <command.h>
+#include <dm/ofnode.h>
+#include <env.h>
+#include <rand.h>
+#include <vsprintf.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <version.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define LINE_WIDTH 40
+#define BLUE "\033[38;5;4m"
+#define YELLOW "\033[38;5;11m"
+#define BOLD "\033[1m"
+#define RESET "\033[0m"
+static const char *logo_lines[] = {
+	BLUE BOLD "                  ......::......                   ",
+	BLUE BOLD "             ...::::::::::::::::::...              ",
+	BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+	BLUE BOLD "        .::::.:::::::::::::::...::::.::::.         ",
+	BLUE BOLD "      .::::::::::::::::::::..::::::::::::::.       ",
+	BLUE BOLD "    .::.:::::::::::::::::::" YELLOW "=*%#*" BLUE "::::::::::.::.     ",
+	BLUE BOLD "   .:::::::::::::::::....." YELLOW "*%%*-" BLUE ":....::::::::::.    ",
+	BLUE BOLD "  .:.:::...:::::::::.:-" YELLOW "===##*---==-" BLUE "::::::::::.:.   ",
+	BLUE BOLD " .::::..::::........" YELLOW "-***#****###****-" BLUE "...::::::.:.  ",
+	BLUE BOLD " ::.:.-" YELLOW "+***+=" BLUE "::-" YELLOW "=+**#%%%%%%%%%%%%###*= " BLUE "-::...::::. ",
+	BLUE BOLD ".:.::-" YELLOW "*****###%%%%%%%%%%%%%%%%%%%%%%%%%%#*=" BLUE ":..:::: ",
+	BLUE BOLD ".::" YELLOW "##" BLUE ":" YELLOW "***#%%%%%%#####%%%%%%%####%%%%%####%%%*" BLUE "-.::. ",
+	BLUE BOLD ":.:" YELLOW "#%" BLUE "::" YELLOW "*%%%%%%%#*****##%%%#*****##%%##*****#%%+" BLUE ".::.",
+	BLUE BOLD ".::" YELLOW "**==#%%%%%%%##****#%%%%##****#%%%%#****###%%" BLUE ":.. ",
+	BLUE BOLD "..:" YELLOW "#%" BLUE "::" YELLOW "*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#%%%%%+ " BLUE ".:.",
+	BLUE BOLD " ::" YELLOW "##" BLUE ":" YELLOW "+**#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%* " BLUE "-.:: ",
+	BLUE BOLD " ..::-" YELLOW "#****#%#%%%%%%%%%%%%%%%%%%%%%%%%%%#*=" BLUE "-..::.  ",
+	BLUE BOLD "  ...:=" YELLOW "*****=" BLUE "::-\033[38;5;7m=+**###%%%%%%%%###**+=  " BLUE "--:...:::  ",
+	BLUE BOLD "   .::.::--:........::::::--::::::......::::::.    ",
+	BLUE BOLD "    .::.....::::::::::...........:::::::::.::.     ",
+	BLUE BOLD "      .::::::::::::::::::::::::::::::::::::.       ",
+	BLUE BOLD "        .::::.::::::::::::::::::::::.::::.         ",
+	BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+	BLUE BOLD "             ...::::::::::::::::::...              ",
+	BLUE BOLD "                  ......::......                   ",
+};
+
+enum output_lines {
+	FIRST,
+	SECOND,
+	KERNEL,
+	SYSINFO,
+	HOST,
+	UPTIME,
+	IP,
+	CMDS,
+	CONSOLES,
+	DEVICES,
+	FEATURES,
+	RELOCATION,
+	CORES,
+	MEMORY,
+	STORAGE,
+
+	/* Up to 10 storage devices... Should be enough for anyone right? */
+	_LAST_LINE = (STORAGE + 10),
+#define LAST_LINE (_LAST_LINE - 1UL)
+};
+
+static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,
+		     char *const argv[])
+{
+	int num_lines = max(LAST_LINE + 1, ARRAY_SIZE(logo_lines));
+	const char *model, *compatible;
+	char *ipaddr;
+	int n_cmds, n_cpus = 0, ret, compatlen;
+	ofnode np;
+	struct mmc *mmc;
+	struct blk_desc *scsi_desc;
+	bool skip_ascii = false;
+
+	if (argc > 1 && strcmp(argv[1], "-n") == 0) {
+		skip_ascii = true;
+		num_lines = LAST_LINE;
+	}
+
+	for (int i = 0; i < num_lines; i++) {
+		if (!skip_ascii) {
+			if (i < ARRAY_SIZE(logo_lines))
+				printf("%s ", logo_lines[i]);
+			else
+				printf("%*c ", LINE_WIDTH, ' ');
+		}
+		switch (i) {
+		case FIRST:
+			compatible = ofnode_read_string(ofnode_root(), "compatible");
+			if (!compatible)

cmd/ufetch.c line 112

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+				compatible = "unknown";
+			printf(RESET "%s\n", compatible);
+			compatlen = strlen(compatible);
+			break;
+		case SECOND:
+			for (int j = 0; j < compatlen; j++)
+				putc('-');
+			putc('\n');
+			break;
+		case KERNEL:

Please, do not use misleading variable names.

Quoted 16 lines
cmd/ufetch.c new file +16 -0
+			printf("Kernel:" RESET " %s\n", U_BOOT_VERSION);
+			break;
+		case SYSINFO:
+			printf("Config:" RESET " %s_defconfig\n", CONFIG_SYS_CONFIG_NAME);
+			break;
+		case HOST:
+			model = ofnode_read_string(ofnode_root(), "model");
+			if (model)
+				printf("Host:" RESET " %s\n", model);
+			break;
+		case UPTIME:
+			printf("Uptime:" RESET " %ld seconds\n", get_timer(0) / 1000);
+			break;
+		case IP:
+			ipaddr = env_get("ipvaddr");
+			if (!ipaddr)

cmd/ufetch.c line 138

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+				ipaddr = "none";
+			printf("IP Address:" RESET " %s", ipaddr);
+			ipaddr = env_get("ipv6addr");
+			if (ipaddr)
+				printf(", %s\n", ipaddr);
+			else
+				putc('\n');
+			break;
+		case CMDS:
+			n_cmds = ll_entry_count(struct cmd_tbl, cmd);

Who cares if you have 50 commands or 51 if you don't know which?

cmd/ufetch.c line 148

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+			printf("Commands:" RESET " %d (help)\n", n_cmds);
+			break;
+		case CONSOLES:
+			printf("Consoles:" RESET " %s (%d baud)\n", env_get("stdout"),
+			       gd->baudrate);
+			break;
+		case DEVICES:
+			printf("Devices:" RESET " ");
+			/* TODO: walk the DM tree */
+			printf("Uncountable!\n");

Nothing we should merge.

cmd/ufetch.c line 153

Quoted 5 lines
cmd/ufetch.c new file +5 -0
+			break;
+		case FEATURES:
+			printf("Features:" RESET " ");
+			if (IS_ENABLED(CONFIG_NET))
+				printf("Net");

Wouuldn't you want to know which devices where detected?

Quoted 16 lines
cmd/ufetch.c new file +16 -0
+			if (IS_ENABLED(CONFIG_EFI_LOADER))
+				printf(", EFI");
+			printf("\n");
+			break;
+		case RELOCATION:
+			if (gd->flags & GD_FLG_SKIP_RELOC)
+				printf("Relocated:" RESET " no\n");
+			else
+				printf("Relocated:" RESET " to %#09lx\n", gd->relocaddr);
+			break;
+		case CORES:
+			ofnode_for_each_subnode(np, ofnode_path("/cpus")) {
+				if (ofnode_name_eq(np, "cpu"))
+					n_cpus++;
+			}
+			printf("CPU:" RESET " %d (1 in use)\n", n_cpus);

cmd/ufetch.c line 179

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+			break;
+		case MEMORY:
+			printf("Memory:" RESET " %lu MB\n", (ulong)gd->ram_size >> 20);
+			break;
+		case STORAGE:
+		default:
+			if (i == STORAGE && get_mmc_num() > 0) {
+				mmc = find_mmc_device(0);
+				if (mmc)
+					printf("Storage:" RESET "  mmc 0: %llu MB", mmc->capacity >> 20);

And if my eMMC is device 1 and SD card is 0?

Why wouldn't you iterate over all UCLASS_BLK devices?

Best regards

Heinrich

Quoted 22 lines
cmd/ufetch.c new file +22 -0
+			}
+			if (i >= STORAGE + 1) {
+				ret = blk_get_desc(UCLASS_SCSI, i - (STORAGE + 1), &scsi_desc);
+				if (!ret && scsi_desc->type != DEV_TYPE_UNKNOWN)
+					/* The calculation here is really lossy but close enough */
+					printf("Storage:" RESET " scsi %d: %lu MB", i - (STORAGE + 1),
+					       ((scsi_desc->lba >> 9) * scsi_desc->blksz) >> 11);
+			}
+			printf("\n");
+		}
+	}
+
+	printf(RESET "\n\n");
+
+	return 0;
+}
+
+U_BOOT_CMD(ufetch, 2, 1, do_ufetch,
+	"U-Boot fetch utility",
+	"Print information about your device.\n"
+	"    -n    Don't print the ASCII logo"
+);
#6 lore raw
Quoted 19 lines · Heinrich Schuchardt

Am 8. August 2024 18:24:24 MESZ schrieb Caleb Connolly <[email protected]>:

Quoted 16 lines

While U-Boot does a pretty good job at printing information at startup about what hardware it's running on, it can be hard to take pretty pictures of this to show off on the internet (by far the most important aspect of porting a device in 2024!).

Add a small utility "ufetch" for displaying some information about U-Boot and the hardware it's running on in a similar fashion to the popular neofetch tool for *nix's [1].

While the output is meant to be useful, it should also be pleasing to look at and look good in screenshots. The ufetch command brings this to U-Boot, featuring a colorful ASCII art version of the U-Boot logo and a fancy layout.

Finally, tireless device porters can properly show off their hard work and get the internet points they so deserve!

Quoted 6 lines
Quoted 3 lines

Not everything is fully supported yet, but this seemed good enough for initial inclusion. Only one MMC device is detected, and other than SCSI other storage devices aren't supported.

This command is not very generic. E.g. it supports SCSI drives but not SATA. Many boards have eMMC and SD-card. This lks more ike an RFC tan something ready to merge.

Honestly it didn't even occur to me to send an RFC since this is purely a vanity thing...

I'll make it generic over UCLASS_BLK if possible for the next revision.

Quoted 2 lines

Why don't you use a script or an EFI program to print whatever information you need?

Well , then you'd need to have a way to load the script or EFI binary, which might not be possible for an early U-Boot port which doesn't have storage support yet (or at least, be a bunch of effort).

The only motivation to have this in U-Boot is really because

a) it's cute
b) it motivates "reward oriented" people like myself to get U-Boot booting on new/interesting devices because now it can be really easily shown off.

Maybe it's a cynical take, but I think stuff like this really has the potential to get more folks interested. Nobody likes doing the invisible background work, so why not bring some visibility to things?

Assuming I did a bad job at conveying my intent in the patch description: the point here is not to convey useful debugging information to developers, it's to show off, look pretty, and be amusing. Plenty of other U-Boot commands can convey information, this one is more like the 2048 port.

Quoted 160 lines
Quoted 160 lines

[1]: https://en.wikipedia.org/wiki/Neofetch

---
Ephemeral demo image: https://0x0.st/XVUa.png
---

cmd/Kconfig  |   7 ++
cmd/Makefile |   1 +
cmd/ufetch.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 209 insertions(+)

create mode 100644 cmd/ufetch.c

cmd/Kconfig +7 -0
index 978f44eda426..70acb5727b04 100644
@@ -175,8 +175,15 @@ config CMD_CPU
 	  number of CPUs, type (e.g. manufacturer, architecture, product or
 	  internal name) and clock frequency. Other information may be
 	  available depending on the CPU driver.
 
+config CMD_UFETCH
+	bool "U-Boot fetch"
+	depends on BLK
+	help
+	  Fetch utility for U-Boot (akin to neofetch). Prints information
+	  about U-Boot and the board it is running on in a pleasing format.
+

config CMD_FWU_METADATA
bool "fwu metadata read"
depends on FWU_MULTI_BANK_UPDATE
help

cmd/Makefile +0 -0
index 87133cc27a8a..ffb04c8f2e0a 100644
@@ -53,8 +53,9 @@ obj-$(CONFIG_CMD_CONSOLE) += console.o

obj-$(CONFIG_CMD_CPU) += cpu.o
obj-$(CONFIG_CMD_DATE) += date.o
obj-$(CONFIG_CMD_DEMO) += demo.o
obj-$(CONFIG_CMD_DM) += dm.o
+obj-$(CONFIG_CMD_UFETCH) += ufetch.o
obj-$(CONFIG_CMD_SOUND) += sound.o
ifdef CONFIG_POST
obj-$(CONFIG_CMD_DIAG) += diag.o
endif

cmd/ufetch.c new file +106 -0
new file mode 100644
index 000000000000..f7374eb2e364
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* Small "fetch" utility for U-Boot */
+
+#include <mmc.h>
+#include <time.h>
+#include <asm/global_data.h>
+#include <cli.h>
+#include <command.h>
+#include <dm/ofnode.h>
+#include <env.h>
+#include <rand.h>
+#include <vsprintf.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <version.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define LINE_WIDTH 40
+#define BLUE "\033[38;5;4m"
+#define YELLOW "\033[38;5;11m"
+#define BOLD "\033[1m"
+#define RESET "\033[0m"
+static const char *logo_lines[] = {
+	BLUE BOLD "                  ......::......                   ",
+	BLUE BOLD "             ...::::::::::::::::::...              ",
+	BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+	BLUE BOLD "        .::::.:::::::::::::::...::::.::::.         ",
+	BLUE BOLD "      .::::::::::::::::::::..::::::::::::::.       ",
+	BLUE BOLD "    .::.:::::::::::::::::::" YELLOW "=*%#*" BLUE "::::::::::.::.     ",
+	BLUE BOLD "   .:::::::::::::::::....." YELLOW "*%%*-" BLUE ":....::::::::::.    ",
+	BLUE BOLD "  .:.:::...:::::::::.:-" YELLOW "===##*---==-" BLUE "::::::::::.:.   ",
+	BLUE BOLD " .::::..::::........" YELLOW "-***#****###****-" BLUE "...::::::.:.  ",
+	BLUE BOLD " ::.:.-" YELLOW "+***+=" BLUE "::-" YELLOW "=+**#%%%%%%%%%%%%###*= " BLUE "-::...::::. ",
+	BLUE BOLD ".:.::-" YELLOW "*****###%%%%%%%%%%%%%%%%%%%%%%%%%%#*=" BLUE ":..:::: ",
+	BLUE BOLD ".::" YELLOW "##" BLUE ":" YELLOW "***#%%%%%%#####%%%%%%%####%%%%%####%%%*" BLUE "-.::. ",
+	BLUE BOLD ":.:" YELLOW "#%" BLUE "::" YELLOW "*%%%%%%%#*****##%%%#*****##%%##*****#%%+" BLUE ".::.",
+	BLUE BOLD ".::" YELLOW "**==#%%%%%%%##****#%%%%##****#%%%%#****###%%" BLUE ":.. ",
+	BLUE BOLD "..:" YELLOW "#%" BLUE "::" YELLOW "*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#%%%%%+ " BLUE ".:.",
+	BLUE BOLD " ::" YELLOW "##" BLUE ":" YELLOW "+**#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%* " BLUE "-.:: ",
+	BLUE BOLD " ..::-" YELLOW "#****#%#%%%%%%%%%%%%%%%%%%%%%%%%%%#*=" BLUE "-..::.  ",
+	BLUE BOLD "  ...:=" YELLOW "*****=" BLUE "::-\033[38;5;7m=+**###%%%%%%%%###**+=  " BLUE "--:...:::  ",
+	BLUE BOLD "   .::.::--:........::::::--::::::......::::::.    ",
+	BLUE BOLD "    .::.....::::::::::...........:::::::::.::.     ",
+	BLUE BOLD "      .::::::::::::::::::::::::::::::::::::.       ",
+	BLUE BOLD "        .::::.::::::::::::::::::::::.::::.         ",
+	BLUE BOLD "          ..::::::::::::::::::::::::::..           ",
+	BLUE BOLD "             ...::::::::::::::::::...              ",
+	BLUE BOLD "                  ......::......                   ",
+};
+
+enum output_lines {
+	FIRST,
+	SECOND,
+	KERNEL,
+	SYSINFO,
+	HOST,
+	UPTIME,
+	IP,
+	CMDS,
+	CONSOLES,
+	DEVICES,
+	FEATURES,
+	RELOCATION,
+	CORES,
+	MEMORY,
+	STORAGE,
+
+	/* Up to 10 storage devices... Should be enough for anyone right? */
+	_LAST_LINE = (STORAGE + 10),
+#define LAST_LINE (_LAST_LINE - 1UL)
+};
+
+static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,
+		     char *const argv[])
+{
+	int num_lines = max(LAST_LINE + 1, ARRAY_SIZE(logo_lines));
+	const char *model, *compatible;
+	char *ipaddr;
+	int n_cmds, n_cpus = 0, ret, compatlen;
+	ofnode np;
+	struct mmc *mmc;
+	struct blk_desc *scsi_desc;
+	bool skip_ascii = false;
+
+	if (argc > 1 && strcmp(argv[1], "-n") == 0) {
+		skip_ascii = true;
+		num_lines = LAST_LINE;
+	}
+
+	for (int i = 0; i < num_lines; i++) {
+		if (!skip_ascii) {
+			if (i < ARRAY_SIZE(logo_lines))
+				printf("%s ", logo_lines[i]);
+			else
+				printf("%*c ", LINE_WIDTH, ' ');
+		}
+		switch (i) {
+		case FIRST:
+			compatible = ofnode_read_string(ofnode_root(), "compatible");
+			if (!compatible)
+				compatible = "unknown";
+			printf(RESET "%s\n", compatible);
+			compatlen = strlen(compatible);
+			break;
Quoted 8 lines

cmd/ufetch.c line 112

Quoted 6 lines
cmd/ufetch.c new file +6 -0
+		case SECOND:
+			for (int j = 0; j < compatlen; j++)
+				putc('-');
+			putc('\n');
+			break;
+		case KERNEL:

Please, do not use misleading variable names.

it is meant to be a little satirical, but I get it.

Quoted 22 lines
Quoted 22 lines
cmd/ufetch.c new file +20 -0
+			printf("Kernel:" RESET " %s\n", U_BOOT_VERSION);
+			break;
+		case SYSINFO:
+			printf("Config:" RESET " %s_defconfig\n", CONFIG_SYS_CONFIG_NAME);
+			break;
+		case HOST:
+			model = ofnode_read_string(ofnode_root(), "model");
+			if (model)
+				printf("Host:" RESET " %s\n", model);
+			break;
+		case UPTIME:
+			printf("Uptime:" RESET " %ld seconds\n", get_timer(0) / 1000);
+			break;
+		case IP:
+			ipaddr = env_get("ipvaddr");
+			if (!ipaddr)
+				ipaddr = "none";
+			printf("IP Address:" RESET " %s", ipaddr);
+			ipaddr = env_get("ipv6addr");
+			if (ipaddr)
Quoted 8 lines

cmd/ufetch.c line 138

Quoted 6 lines
cmd/ufetch.c new file +6 -0
+				printf(", %s\n", ipaddr);
+			else
+				putc('\n');
+			break;
+		case CMDS:
+			n_cmds = ll_entry_count(struct cmd_tbl, cmd);

Who cares if you have 50 commands or 51 if you don't know which?

This is a play on the neofetch "packages" counter.

Quoted 80 lines

cmd/ufetch.c line 148

Quoted 12 lines
cmd/ufetch.c new file +10 -0
+			printf("Commands:" RESET " %d (help)\n", n_cmds);
+			break;
+		case CONSOLES:
+			printf("Consoles:" RESET " %s (%d baud)\n", env_get("stdout"),
+			       gd->baudrate);
+			break;
+		case DEVICES:
+			printf("Devices:" RESET " ");
+			/* TODO: walk the DM tree */
+			printf("Uncountable!\n");

Nothing we should merge.

cmd/ufetch.c line 153

Quoted 5 lines
cmd/ufetch.c new file +5 -0
+			break;
+		case FEATURES:
+			printf("Features:" RESET " ");
+			if (IS_ENABLED(CONFIG_NET))
+				printf("Net");

Wouuldn't you want to know which devices where detected?

Quoted 16 lines
cmd/ufetch.c new file +16 -0
+			if (IS_ENABLED(CONFIG_EFI_LOADER))
+				printf(", EFI");
+			printf("\n");
+			break;
+		case RELOCATION:
+			if (gd->flags & GD_FLG_SKIP_RELOC)
+				printf("Relocated:" RESET " no\n");
+			else
+				printf("Relocated:" RESET " to %#09lx\n", gd->relocaddr);
+			break;
+		case CORES:
+			ofnode_for_each_subnode(np, ofnode_path("/cpus")) {
+				if (ofnode_name_eq(np, "cpu"))
+					n_cpus++;
+			}
+			printf("CPU:" RESET " %d (1 in use)\n", n_cpus);

cmd/ufetch.c line 179

Quoted 10 lines
cmd/ufetch.c new file +10 -0
+			break;
+		case MEMORY:
+			printf("Memory:" RESET " %lu MB\n", (ulong)gd->ram_size >> 20);
+			break;
+		case STORAGE:
+		default:
+			if (i == STORAGE && get_mmc_num() > 0) {
+				mmc = find_mmc_device(0);
+				if (mmc)
+					printf("Storage:" RESET "  mmc 0: %llu MB", mmc->capacity >> 20);

And if my eMMC is device 1 and SD card is 0?

Why wouldn't you iterate over all UCLASS_BLK devices?

Best regards

Heinrich

Quoted 22 lines
cmd/ufetch.c new file +22 -0
+			}
+			if (i >= STORAGE + 1) {
+				ret = blk_get_desc(UCLASS_SCSI, i - (STORAGE + 1), &scsi_desc);
+				if (!ret && scsi_desc->type != DEV_TYPE_UNKNOWN)
+					/* The calculation here is really lossy but close enough */
+					printf("Storage:" RESET " scsi %d: %lu MB", i - (STORAGE + 1),
+					       ((scsi_desc->lba >> 9) * scsi_desc->blksz) >> 11);
+			}
+			printf("\n");
+		}
+	}
+
+	printf(RESET "\n\n");
+
+	return 0;
+}
+
+U_BOOT_CMD(ufetch, 2, 1, do_ufetch,
+	"U-Boot fetch utility",
+	"Print information about your device.\n"
+	"    -n    Don't print the ASCII logo"
+);
Signature · 1 line
// Caleb (they/them)
#7 lore raw
Quoted 46 lines · Caleb Connolly
Quoted 19 lines · Heinrich Schuchardt

Am 8. August 2024 18:24:24 MESZ schrieb Caleb Connolly <[email protected]>:

Quoted 16 lines

While U-Boot does a pretty good job at printing information at startup about what hardware it's running on, it can be hard to take pretty pictures of this to show off on the internet (by far the most important aspect of porting a device in 2024!).

Add a small utility "ufetch" for displaying some information about U-Boot and the hardware it's running on in a similar fashion to the popular neofetch tool for *nix's [1].

While the output is meant to be useful, it should also be pleasing to look at and look good in screenshots. The ufetch command brings this to U-Boot, featuring a colorful ASCII art version of the U-Boot logo and a fancy layout.

Finally, tireless device porters can properly show off their hard work and get the internet points they so deserve!

Quoted 6 lines
Quoted 3 lines

Not everything is fully supported yet, but this seemed good enough for initial inclusion. Only one MMC device is detected, and other than SCSI other storage devices aren't supported.

This command is not very generic. E.g. it supports SCSI drives but not SATA. Many boards have eMMC and SD-card. This lks more ike an RFC tan something ready to merge.

Honestly it didn't even occur to me to send an RFC since this is purely a vanity thing...

I'll make it generic over UCLASS_BLK if possible for the next revision.

Quoted 2 lines

Why don't you use a script or an EFI program to print whatever information you need?

Well , then you'd need to have a way to load the script or EFI binary, which might not be possible for an early U-Boot port which doesn't have storage support yet (or at least, be a bunch of effort).

The only motivation to have this in U-Boot is really because

a) it's cute
b) it motivates "reward oriented" people like myself to get U-Boot booting on new/interesting devices because now it can be really easily shown off.

Quoted 8 lines

Maybe it's a cynical take, but I think stuff like this really has the potential to get more folks interested. Nobody likes doing the invisible background work, so why not bring some visibility to things?

Assuming I did a bad job at conveying my intent in the patch description:
the point here is not to convey useful debugging information to developers, it's to show off, look pretty, and be amusing. Plenty of other U-Boot commands can convey information, this one is more like the 2048 port.

So, at the high level, yes, this is something that ought to get merged as it's handy enough, but not intended to replace for example smbios information.

Signature · 1 line
Tom
#8 lore raw

Hi Tom,

Quoted 52 lines · Tom Rini
Quoted 50 lines · Caleb Connolly
Quoted 19 lines · Heinrich Schuchardt

Am 8. August 2024 18:24:24 MESZ schrieb Caleb Connolly <[email protected]>:

Quoted 16 lines

While U-Boot does a pretty good job at printing information at startup about what hardware it's running on, it can be hard to take pretty pictures of this to show off on the internet (by far the most important aspect of porting a device in 2024!).

Add a small utility "ufetch" for displaying some information about U-Boot and the hardware it's running on in a similar fashion to the popular neofetch tool for *nix's [1].

While the output is meant to be useful, it should also be pleasing to look at and look good in screenshots. The ufetch command brings this to U-Boot, featuring a colorful ASCII art version of the U-Boot logo and a fancy layout.

Finally, tireless device porters can properly show off their hard work and get the internet points they so deserve!

Quoted 6 lines
Quoted 3 lines

Not everything is fully supported yet, but this seemed good enough for initial inclusion. Only one MMC device is detected, and other than SCSI other storage devices aren't supported.

This command is not very generic. E.g. it supports SCSI drives but not SATA. Many boards have eMMC and SD-card. This lks more ike an RFC tan something ready to merge.

Honestly it didn't even occur to me to send an RFC since this is purely a vanity thing...

I'll make it generic over UCLASS_BLK if possible for the next revision.

Quoted 2 lines

Why don't you use a script or an EFI program to print whatever information you need?

Well , then you'd need to have a way to load the script or EFI binary, which might not be possible for an early U-Boot port which doesn't have storage support yet (or at least, be a bunch of effort).

The only motivation to have this in U-Boot is really because

a) it's cute
b) it motivates "reward oriented" people like myself to get U-Boot booting on new/interesting devices because now it can be really easily shown off.

Maybe it's a cynical take, but I think stuff like this really has the potential to get more folks interested. Nobody likes doing the invisible background work, so why not bring some visibility to things?

Quoted 8 lines
Quoted 4 lines

Assuming I did a bad job at conveying my intent in the patch description:
the point here is not to convey useful debugging information to developers, it's to show off, look pretty, and be amusing. Plenty of other U-Boot commands can convey information, this one is more like the 2048 port.

So, at the high level, yes, this is something that ought to get merged as it's handy enough, but not intended to replace for example smbios information.

Up vote for this patch. Can we merge this to next?

All the best,
Tony

Quoted 3 lines

--
Tom

#9 lore raw
Quoted 60 lines · Tony Dinh

Hi Tom,

Quoted 57 lines · Tom Rini
Quoted 54 lines · Caleb Connolly
Quoted 19 lines · Heinrich Schuchardt

Am 8. August 2024 18:24:24 MESZ schrieb Caleb Connolly <[email protected]>:

Quoted 16 lines

While U-Boot does a pretty good job at printing information at startup about what hardware it's running on, it can be hard to take pretty pictures of this to show off on the internet (by far the most important aspect of porting a device in 2024!).

Add a small utility "ufetch" for displaying some information about U-Boot and the hardware it's running on in a similar fashion to the popular neofetch tool for *nix's [1].

While the output is meant to be useful, it should also be pleasing to look at and look good in screenshots. The ufetch command brings this to U-Boot, featuring a colorful ASCII art version of the U-Boot logo and a fancy layout.

Finally, tireless device porters can properly show off their hard work and get the internet points they so deserve!

Quoted 6 lines
Quoted 3 lines

Not everything is fully supported yet, but this seemed good enough for initial inclusion. Only one MMC device is detected, and other than SCSI other storage devices aren't supported.

This command is not very generic. E.g. it supports SCSI drives but not SATA. Many boards have eMMC and SD-card. This lks more ike an RFC tan something ready to merge.

Honestly it didn't even occur to me to send an RFC since this is purely a vanity thing...

I'll make it generic over UCLASS_BLK if possible for the next revision.

Quoted 2 lines

Why don't you use a script or an EFI program to print whatever information you need?

Well , then you'd need to have a way to load the script or EFI binary, which might not be possible for an early U-Boot port which doesn't have storage support yet (or at least, be a bunch of effort).

The only motivation to have this in U-Boot is really because

a) it's cute
b) it motivates "reward oriented" people like myself to get U-Boot booting on new/interesting devices because now it can be really easily shown off.

Maybe it's a cynical take, but I think stuff like this really has the potential to get more folks interested. Nobody likes doing the invisible background work, so why not bring some visibility to things?

Assuming I did a bad job at conveying my intent in the patch description:
the point here is not to convey useful debugging information to developers, it's to show off, look pretty, and be amusing. Plenty of other U-Boot commands can convey information, this one is more like the 2048 port.

Quoted 5 lines
Quoted 3 lines

So, at the high level, yes, this is something that ought to get merged as it's handy enough, but not intended to replace for example smbios information.

Up vote for this patch. Can we merge this to next?

I think I was expecting another iteration from Caleb based on some minor feedback?

Signature · 1 line
Tom