Skip to content

Commit 652aea5

Browse files
committed
odroidm1: u-boot: enable setexpr; patch 2025.01 for fileenv; enable squashfs support
- as Armbian u-boot is possibly deployed to SPI (replacing Petitboot), try to make as compatible as possible; eg enable squashfs support - in this case, `setexpr` and `fileenv` are used by HAOS - found `fileenv` here spikerguy/khadas-uboot@049e1a1 Signed-off-by: Ricardo Pardini <[email protected]>
1 parent 3743daf commit 652aea5

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

config/boards/odroidm1.conf

+7
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ function post_config_uboot_target__extra_configs_for_odroid-m1() {
137137
run_host_command_logged scripts/config --enable CONFIG_PROT_TCP
138138
run_host_command_logged scripts/config --enable CONFIG_PROT_TCP_SACK
139139

140+
display_alert "u-boot for ${BOARD}" "u-boot: enable more cmdline commands" "info" # for extra compat with eg HAOS
141+
run_host_command_logged scripts/config --enable CONFIG_CMD_SQUASHFS
142+
run_host_command_logged scripts/config --enable CONFIG_CMD_SETEXPR
143+
run_host_command_logged scripts/config --enable CONFIG_CMD_FILEENV # added via cmd-fileenv-read-string-from-file-into-env.patch
144+
run_host_command_logged scripts/config --enable CONFIG_CMD_CAT
145+
run_host_command_logged scripts/config --enable CONFIG_CMD_XXD
146+
140147
display_alert "u-boot for ${BOARD}/${BRANCH}" "u-boot: enabling UMS/RockUSB Gadget functionality" "info"
141148
declare -a enable_configs=("CONFIG_CMD_USB_MASS_STORAGE" "CONFIG_USB_GADGET" "USB_GADGET_DOWNLOAD" "CONFIG_USB_FUNCTION_ROCKUSB" "CONFIG_USB_FUNCTION_ACM" "CONFIG_CMD_ROCKUSB" "CONFIG_CMD_USB_MASS_STORAGE")
142149
for config in "${enable_configs[@]}"; do
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ricardo Pardini <[email protected]>
3+
Date: Fri, 31 Jan 2025 15:52:03 +0100
4+
Subject: cmd: fileenv: read string from file into env
5+
6+
- rpardini: adapted from vendor/legacy patch from 2018
7+
8+
Signed-off-by: Pascal Vizeli <[email protected]>
9+
Signed-off-by: Stefan Agner <[email protected]>
10+
Signed-off-by: Ricardo Pardini <[email protected]>
11+
---
12+
cmd/Kconfig | 5 +
13+
cmd/Makefile | 1 +
14+
cmd/fileenv.c | 46 ++++++++++
15+
3 files changed, 52 insertions(+)
16+
17+
diff --git a/cmd/Kconfig b/cmd/Kconfig
18+
index 111111111111..222222222222 100644
19+
--- a/cmd/Kconfig
20+
+++ b/cmd/Kconfig
21+
@@ -1792,6 +1792,11 @@ config CMD_XXD
22+
help
23+
Print file as hexdump to standard output
24+
25+
+config CMD_FILEENV
26+
+ bool "fileenv"
27+
+ help
28+
+ Read a file into memory and store it to env.
29+
+
30+
endmenu
31+
32+
if NET || NET_LWIP
33+
diff --git a/cmd/Makefile b/cmd/Makefile
34+
index 111111111111..222222222222 100644
35+
--- a/cmd/Makefile
36+
+++ b/cmd/Makefile
37+
@@ -170,6 +170,7 @@ obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o
38+
obj-$(CONFIG_CMD_SEAMA) += seama.o
39+
obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
40+
obj-$(CONFIG_CMD_SETEXPR_FMT) += printf.o
41+
+obj-$(CONFIG_CMD_FILEENV) += fileenv.o
42+
obj-$(CONFIG_CMD_SPI) += spi.o
43+
obj-$(CONFIG_CMD_STRINGS) += strings.o
44+
obj-$(CONFIG_CMD_SMBIOS) += smbios.o
45+
diff --git a/cmd/fileenv.c b/cmd/fileenv.c
46+
new file mode 100644
47+
index 000000000000..111111111111
48+
--- /dev/null
49+
+++ b/cmd/fileenv.c
50+
@@ -0,0 +1,46 @@
51+
+#include <config.h>
52+
+#include <command.h>
53+
+#include <fs.h>
54+
+#include <linux/ctype.h>
55+
+#include <vsprintf.h>
56+
+
57+
+static char *fs_argv[5];
58+
+
59+
+int do_fileenv(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
60+
+{
61+
+ if (argc < 6)
62+
+ return CMD_RET_USAGE;
63+
+
64+
+ fs_argv[0] = "fatload";
65+
+ fs_argv[1] = argv[1];
66+
+ fs_argv[2] = argv[2];
67+
+ fs_argv[3] = argv[3];
68+
+ fs_argv[4] = argv[4];
69+
+
70+
+ if (do_fat_fsload(cmdtp, 0, 5, fs_argv) != 0)
71+
+ return 1;
72+
+
73+
+ char *addr = (char *)simple_strtoul(argv[3], NULL, 16);
74+
+ size_t size = env_get_hex("filesize", 0);
75+
+
76+
+ // Prepare string
77+
+ addr[size] = 0x00;
78+
+ char *s = addr;
79+
+ while(*s != 0x00) {
80+
+ if (isprint(*s)) {
81+
+ s++;
82+
+ }
83+
+ else {
84+
+ *s = 0x00;
85+
+ }
86+
+ }
87+
+
88+
+ return env_set(argv[5], addr);
89+
+}
90+
+
91+
+U_BOOT_CMD(
92+
+ fileenv, 6, 0, do_fileenv,
93+
+ "Read file and store it into env.",
94+
+ "<interface> <dev:part> <addr> <filename> <envname>\n"
95+
+ " - Read file from fat32 and store it as env."
96+
+);
97+
--
98+
Armbian
99+

0 commit comments

Comments
 (0)