Merge ~xnox/ubuntu/+source/u-boot:fixup-fdtdir-properly into ubuntu/+source/u-boot:ubuntu/devel

Proposed by Dimitri John Ledkov
Status: Needs review
Proposed branch: ~xnox/ubuntu/+source/u-boot:fixup-fdtdir-properly
Merge into: ubuntu/+source/u-boot:ubuntu/devel
Diff against target: 260 lines (+141/-47)
7 files modified
debian/changelog (+17/-0)
debian/patches/0001-cmd-pxe-Use-internal-FDT-if-retrieving-from-FDTDIR-f.patch (+57/-0)
debian/patches/0001-cmd-pxe_utils-sysboot-fix-crash-if-either-board-or-s.patch (+39/-0)
debian/patches/riscv64/sifive-unleashed-default-fdt-files.patch (+0/-21)
debian/patches/riscv64/sifive-unmatched-default-fdt-files.patch (+24/-0)
debian/patches/series (+4/-2)
dev/null (+0/-24)
Reviewer Review Type Date Requested Status
Dave Jones (community) Approve
git-ubuntu developers Pending
Review via email: mp+401545@code.launchpad.net

Commit message

fixup fdtdir things properly.

this is for ii opening & sruing through to back to focal

To post a comment you must log in.
Revision history for this message
Dave Jones (waveform) wrote :

The patches all look sane, so +1 from me.

The one thing that worries me is I'm not sure "soc" or "board" are ever *meant* to be blank in the env, but I can't find anything to that effect in the docs/comments. Anyway, they evidently are in this case so the workaround's necessary.

review: Approve

Unmerged commits

1774cfd... by Dimitri John Ledkov

sifive-unleashed-default-fdt-files.patch: split into unleashed & unmatched separate patches, for ease of upstreaming to meta-sifive and u-boot upstreams.

e7d08ec... by Dimitri John Ledkov

Fix LP: #1925267 LP: #1923162 using upstream friendly patches:

* Fix LP: #1925267 LP: #1923162 using upstream friendly patches:
  - riscv64/qemu-skip-fdtdir.patch: drop patch,
    functionality replaced by cherrypick & fix up.
  - 0001-cmd-pxe-Use-internal-FDT-if-retrieving-from-FDTDIR-f.patch:
    cherrypick post-2021.01 patch to gracefully carry-on booting using
    internal FDT if there isn't a different one in FDTDIR.
  - 0001-cmd-pxe_utils-sysboot-fix-crash-if-either-board-or-s.patch: fix
    crash on trying to use fdtdir when either "soc" or "board" environment
    variables are not set (like on qemu-riscv64).

b046cee... by Dimitri John Ledkov

2021.01+dfsg-3ubuntu8 (patches unapplied)

Imported using git-ubuntu import.

cf5c992... by Dimitri John Ledkov

2021.01+dfsg-3ubuntu7 (patches unapplied)

Imported using git-ubuntu import.

f2b547d... by Dimitri John Ledkov

2021.01+dfsg-3ubuntu6 (patches unapplied)

Imported using git-ubuntu import.

25523ec... by Dimitri John Ledkov

2021.01+dfsg-3ubuntu5 (patches unapplied)

Imported using git-ubuntu import.

7966246... by Dimitri John Ledkov

2021.01+dfsg-3ubuntu4 (patches unapplied)

Imported using git-ubuntu import.

0bc3ac5... by Dimitri John Ledkov

2021.01+dfsg-3ubuntu3 (patches unapplied)

Imported using git-ubuntu import.

41dcfe4... by Dimitri John Ledkov

2021.01+dfsg-3ubuntu2 (patches unapplied)

Imported using git-ubuntu import.

967141b... by Dave Jones

2021.01+dfsg-3ubuntu1 (patches unapplied)

Imported using git-ubuntu import.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index df5f9f4..d82e11c 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,20 @@
6+u-boot (2021.01+dfsg-3ubuntu9) UNRELEASED; urgency=medium
7+
8+ * Fix LP: #1925267 LP: #1923162 using upstream friendly patches:
9+ - riscv64/qemu-skip-fdtdir.patch: drop patch,
10+ functionality replaced by cherrypick & fix up.
11+ - 0001-cmd-pxe-Use-internal-FDT-if-retrieving-from-FDTDIR-f.patch:
12+ cherrypick post-2021.01 patch to gracefully carry-on booting using
13+ internal FDT if there isn't a different one in FDTDIR.
14+ - 0001-cmd-pxe_utils-sysboot-fix-crash-if-either-board-or-s.patch: fix
15+ crash on trying to use fdtdir when either "soc" or "board" environment
16+ variables are not set (like on qemu-riscv64).
17+ * sifive-unleashed-default-fdt-files.patch: split into unleashed &
18+ unmatched separate patches, for ease of upstreaming to meta-sifive and
19+ u-boot upstreams.
20+
21+ -- Dimitri John Ledkov <xnox@ubuntu.com> Wed, 21 Apr 2021 14:11:38 +0100
22+
23 u-boot (2021.01+dfsg-3ubuntu8) hirsute; urgency=medium
24
25 * Skip processing fdtdir on qemu-riscv64_smode target, as it crashes the
26diff --git a/debian/patches/0001-cmd-pxe-Use-internal-FDT-if-retrieving-from-FDTDIR-f.patch b/debian/patches/0001-cmd-pxe-Use-internal-FDT-if-retrieving-from-FDTDIR-f.patch
27new file mode 100644
28index 0000000..27a0c1f
29--- /dev/null
30+++ b/debian/patches/0001-cmd-pxe-Use-internal-FDT-if-retrieving-from-FDTDIR-f.patch
31@@ -0,0 +1,57 @@
32+From db3667413d99b8ec1b1e7e9b34c20a8883ec413d Mon Sep 17 00:00:00 2001
33+From: Anton Leontiev <aleontiev@elvees.com>
34+Date: Tue, 3 Sep 2019 10:52:24 +0300
35+Subject: [PATCH] cmd: pxe: Use internal FDT if retrieving from FDTDIR fails
36+
37+As FDTDIR label doesn't specify exact file to be loaded, it should
38+not fail if no file exists in the directory. In this case try to boot
39+with internal FDT if it exists.
40+
41+Signed-off-by: Anton Leontiev <aleontiev@elvees.com>
42+---
43+ cmd/pxe_utils.c | 21 ++++++++++++++-------
44+ 1 file changed, 14 insertions(+), 7 deletions(-)
45+
46+diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
47+index 8716e782f6..235522f4bb 100644
48+--- a/cmd/pxe_utils.c
49++++ b/cmd/pxe_utils.c
50+@@ -451,11 +451,14 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
51+
52+ /*
53+ * fdt usage is optional:
54+- * It handles the following scenarios. All scenarios are exclusive
55++ * It handles the following scenarios.
56+ *
57+- * Scenario 1: If fdt_addr_r specified and "fdt" label is defined in
58+- * pxe file, retrieve fdt blob from server. Pass fdt_addr_r to bootm,
59+- * and adjust argc appropriately.
60++ * Scenario 1: If fdt_addr_r specified and "fdt" or "fdtdir" label is
61++ * defined in pxe file, retrieve fdt blob from server. Pass fdt_addr_r to
62++ * bootm, and adjust argc appropriately.
63++ *
64++ * If retrieve fails and no exact fdt blob is specified in pxe file with
65++ * "fdt" label, try Scenario 2.
66+ *
67+ * Scenario 2: If there is an fdt_addr specified, pass it along to
68+ * bootm, and adjust argc appropriately.
69+@@ -521,9 +524,13 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
70+
71+ free(fdtfilefree);
72+ if (err < 0) {
73+- printf("Skipping %s for failure retrieving fdt\n",
74+- label->name);
75+- goto cleanup;
76++ bootm_argv[3] = NULL;
77++
78++ if (label->fdt) {
79++ printf("Skipping %s for failure retrieving FDT\n",
80++ label->name);
81++ goto cleanup;
82++ }
83+ }
84+ } else {
85+ bootm_argv[3] = NULL;
86+--
87+2.27.0
88+
89diff --git a/debian/patches/0001-cmd-pxe_utils-sysboot-fix-crash-if-either-board-or-s.patch b/debian/patches/0001-cmd-pxe_utils-sysboot-fix-crash-if-either-board-or-s.patch
90new file mode 100644
91index 0000000..489e1a1
92--- /dev/null
93+++ b/debian/patches/0001-cmd-pxe_utils-sysboot-fix-crash-if-either-board-or-s.patch
94@@ -0,0 +1,39 @@
95+From 077ee0830ec3ed3b8db334717910fbbfc1b4e302 Mon Sep 17 00:00:00 2001
96+From: Dimitri John Ledkov <xnox@ubuntu.com>
97+Date: Wed, 21 Apr 2021 11:44:34 +0100
98+Subject: [PATCH] cmd: pxe_utils: sysboot: fix crash if either board or soc are
99+ not set.
100+
101+If the environment does not have "soc" or "board" set, and fdtdir
102+option is specified in extlinux.conf, the bootloader will crash whilst
103+dereferencing a null pointer. Add a guard against null soc or
104+board. Fixes a crash of qemu-riscv64_smode configuration, which does
105+not have CONFIG_SYS_SOC defined.
106+
107+Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
108+---
109+ cmd/pxe_utils.c | 8 ++++++++
110+ 1 file changed, 8 insertions(+)
111+
112+diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
113+index 71c5af4c25..9a30629e26 100644
114+--- a/cmd/pxe_utils.c
115++++ b/cmd/pxe_utils.c
116+@@ -587,6 +587,14 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
117+ f2 = "-";
118+ f3 = env_get("board");
119+ f4 = ".dtb";
120++ if (!f1) {
121++ f1 = "";
122++ f2 = "";
123++ }
124++ if (!f3) {
125++ f2 = "";
126++ f3 = "";
127++ }
128+ }
129+
130+ len = strlen(label->fdtdir);
131+--
132+2.27.0
133+
134diff --git a/debian/patches/riscv64/qemu-skip-fdtdir.patch b/debian/patches/riscv64/qemu-skip-fdtdir.patch
135deleted file mode 100644
136index 70b9436..0000000
137--- a/debian/patches/riscv64/qemu-skip-fdtdir.patch
138+++ /dev/null
139@@ -1,24 +0,0 @@
140-Description: Skip processing fdtdir on qemu-riscv64_smode target
141- it crashes the riscv qemu VM.
142-Author: Dimitri John Ledkov <xnox@ubuntu.com>
143-Bug-Ubuntu: https://bugs.launchpad.net/bugs/1925267
144-
145-
146---- u-boot-2021.01+dfsg.orig/cmd/pxe_utils.c
147-+++ u-boot-2021.01+dfsg/cmd/pxe_utils.c
148-@@ -471,6 +471,7 @@ static int label_boot(struct cmd_tbl *cm
149-
150- if (label->fdt) {
151- fdtfile = label->fdt;
152-+#if !(defined(CONFIG_TARGET_QEMU_VIRT) && defined(CONFIG_RISCV_SMODE))
153- } else if (label->fdtdir) {
154- char *f1, *f2, *f3, *f4, *slash;
155-
156-@@ -513,6 +514,7 @@ static int label_boot(struct cmd_tbl *cm
157- snprintf(fdtfilefree, len, "%s%s%s%s%s%s",
158- label->fdtdir, slash, f1, f2, f3, f4);
159- fdtfile = fdtfilefree;
160-+#endif
161- }
162-
163- if (fdtfile) {
164diff --git a/debian/patches/riscv64/sifive-default-fdt-files.patch b/debian/patches/riscv64/sifive-unleashed-default-fdt-files.patch
165similarity index 68%
166rename from debian/patches/riscv64/sifive-default-fdt-files.patch
167rename to debian/patches/riscv64/sifive-unleashed-default-fdt-files.patch
168index 01ffec0..3407169 100644
169--- a/debian/patches/riscv64/sifive-default-fdt-files.patch
170+++ b/debian/patches/riscv64/sifive-unleashed-default-fdt-files.patch
171@@ -10,15 +10,6 @@ Index: u-boot-2021.01+dfsg/configs/sifive_fu540_defconfig
172 CONFIG_RISCV=y
173 CONFIG_SPL_GPIO_SUPPORT=y
174 CONFIG_SYS_MALLOC_F_LEN=0x3000
175-Index: u-boot-2021.01+dfsg/configs/sifive_hifive_unmatched_fu740_defconfig
176-===================================================================
177---- u-boot-2021.01+dfsg.orig/configs/sifive_hifive_unmatched_fu740_defconfig
178-+++ u-boot-2021.01+dfsg/configs/sifive_hifive_unmatched_fu740_defconfig
179-@@ -1,3 +1,4 @@
180-+CONFIG_DEFAULT_FDT_FILE="sifive/hifive-unmatched-a00.dtb"
181- CONFIG_RISCV=y
182- CONFIG_SPL_GPIO_SUPPORT=y
183- CONFIG_SYS_MALLOC_F_LEN=0x3000
184 Index: u-boot-2021.01+dfsg/include/configs/sifive-fu540.h
185 ===================================================================
186 --- u-boot-2021.01+dfsg.orig/include/configs/sifive-fu540.h
187@@ -31,15 +22,3 @@ Index: u-boot-2021.01+dfsg/include/configs/sifive-fu540.h
188 BOOTENV \
189 BOOTENV_SF
190
191-Index: u-boot-2021.01+dfsg/include/configs/sifive-hifive-unmatched-fu740.h
192-===================================================================
193---- u-boot-2021.01+dfsg.orig/include/configs/sifive-hifive-unmatched-fu740.h
194-+++ u-boot-2021.01+dfsg/include/configs/sifive-hifive-unmatched-fu740.h
195-@@ -84,6 +84,7 @@
196- "type_guid_gpt_loader2=" TYPE_GUID_LOADER2 "\0" \
197- "type_guid_gpt_system=" TYPE_GUID_SYSTEM "\0" \
198- "partitions=" PARTS_DEFAULT "\0" \
199-+ "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
200- BOOTENV
201-
202- #define CONFIG_PREBOOT \
203diff --git a/debian/patches/riscv64/sifive-unmatched-default-fdt-files.patch b/debian/patches/riscv64/sifive-unmatched-default-fdt-files.patch
204new file mode 100644
205index 0000000..73fdbc8
206--- /dev/null
207+++ b/debian/patches/riscv64/sifive-unmatched-default-fdt-files.patch
208@@ -0,0 +1,24 @@
209+Description: set default FDT filenames to load from boot disk
210+Bug: https://github.com/sifive/meta-sifive/issues/16
211+
212+Index: u-boot-2021.01+dfsg/configs/sifive_hifive_unmatched_fu740_defconfig
213+===================================================================
214+--- u-boot-2021.01+dfsg.orig/configs/sifive_hifive_unmatched_fu740_defconfig
215++++ u-boot-2021.01+dfsg/configs/sifive_hifive_unmatched_fu740_defconfig
216+@@ -1,3 +1,4 @@
217++CONFIG_DEFAULT_FDT_FILE="sifive/hifive-unmatched-a00.dtb"
218+ CONFIG_RISCV=y
219+ CONFIG_SPL_GPIO_SUPPORT=y
220+ CONFIG_SYS_MALLOC_F_LEN=0x3000
221+Index: u-boot-2021.01+dfsg/include/configs/sifive-hifive-unmatched-fu740.h
222+===================================================================
223+--- u-boot-2021.01+dfsg.orig/include/configs/sifive-hifive-unmatched-fu740.h
224++++ u-boot-2021.01+dfsg/include/configs/sifive-hifive-unmatched-fu740.h
225+@@ -84,6 +84,7 @@
226+ "type_guid_gpt_loader2=" TYPE_GUID_LOADER2 "\0" \
227+ "type_guid_gpt_system=" TYPE_GUID_SYSTEM "\0" \
228+ "partitions=" PARTS_DEFAULT "\0" \
229++ "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
230+ BOOTENV
231+
232+ #define CONFIG_PREBOOT \
233diff --git a/debian/patches/series b/debian/patches/series
234index 71f2ca7..c222e62 100644
235--- a/debian/patches/series
236+++ b/debian/patches/series
237@@ -1,3 +1,5 @@
238+0001-cmd-pxe-Use-internal-FDT-if-retrieving-from-FDTDIR-f.patch
239+0001-cmd-pxe_utils-sysboot-fix-crash-if-either-board-or-s.patch
240 add-debian-revision-to-u-boot-version
241
242 tools-generic-builds.patch
243@@ -14,6 +16,7 @@ test-imagetools-test-fixes
244
245 exynos/0001-arm-config-fix-default-console-only-to-specify-the-d.patch
246
247+riscv64/sifive-unleashed-default-fdt-files.patch
248 riscv64/qemu-riscv64_smode-sifive-fu540-fix-extlinux-define-.patch
249 riscv64/sifive-fu540-compressed-booti-support.patch
250 riscv64/0001-clk-sifive-fu540-prci-Extract-prci-core-to-common-ba.patch
251@@ -57,9 +60,8 @@ riscv64/0038-cmd-pwm-Rework-argc-sanity-checking.patch
252 riscv64/0039-riscv-sifive-unmatched-enable-PWM.patch
253 riscv64/0040-riscv-sifive-unmatched-update-for-rev3-16GB-1866.patch
254 riscv64/0041-Fix-CRC32-checksum-for-SiFive-HiFive-EEPROM.patch
255-riscv64/sifive-default-fdt-files.patch
256+riscv64/sifive-unmatched-default-fdt-files.patch
257 riscv64/use-preboot-unmatched.patch
258-riscv64/qemu-skip-fdtdir.patch
259
260 n900/bootz_and_raw_initrd.patch
261

Subscribers

People subscribed via source and target branches