Skip to content

Commit e1831b3

Browse files
committed
bsp: tegra: systemd-boot: double dtb buffer size
This is probably due to fact systemd-boot does not allocate any extra space for the device tree. Without the modification, because there is not any extra space, the UEFI will fail applying the overlay changes from its .dtbo files Fixes: | EFI stub: ERROR: Invalid header detected on UEFI supplied FDT, ignoring ... | EFI stub: Generating empty DTB References: anduril/jetpack-nixos#111 Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
1 parent 663fd4c commit e1831b3

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 919601f2598eb3dd17fe88d26cafed88420daad2 Mon Sep 17 00:00:00 2001
2+
From: Brian McGillion <bmg.avoin@gmail.com>
3+
Date: Thu, 23 Jan 2025 13:08:15 +0400
4+
Subject: [PATCH] Increase the dtb size
5+
6+
This is probably due to fact systemd-boot does not allocate any extra space for the device tree.
7+
Without the modification, because there is not any extra space, the UEFI will fail applying the
8+
overlay changes from its .dtbo files
9+
10+
Fixes:
11+
| EFI stub: ERROR: Invalid header detected on UEFI supplied FDT, ignoring ...
12+
| EFI stub: Generating empty DTB
13+
14+
References:
15+
https://github.com/anduril/jetpack-nixos/issues/111
16+
17+
Upstream-Status: Pending [https://github.com/tiiuae/ghaf/blob/main/modules/common/systemd/systemd-boot-double-dtb-buffer-size.patch]
18+
19+
Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
20+
Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
21+
---
22+
src/boot/efi/devicetree.c | 8 +++++++-
23+
1 file changed, 7 insertions(+), 1 deletion(-)
24+
25+
diff --git a/src/boot/efi/devicetree.c b/src/boot/efi/devicetree.c
26+
index 61a43cd77d..f939a79963 100644
27+
--- a/src/boot/efi/devicetree.c
28+
+++ b/src/boot/efi/devicetree.c
29+
@@ -3,6 +3,7 @@
30+
#include "devicetree.h"
31+
#include "proto/dt-fixup.h"
32+
#include "util.h"
33+
+#include <endian.h>
34+
35+
#define FDT_V1_SIZE (7*4)
36+
37+
@@ -88,7 +89,8 @@ EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE *root_dir
38+
/* 32MB device tree blob doesn't seem right */
39+
return EFI_INVALID_PARAMETER;
40+
41+
- len = info->FileSize;
42+
+ /* Double the length to be allocated so there's space for modifications */
43+
+ len = info->FileSize * 4;
44+
45+
err = devicetree_allocate(state, len);
46+
if (err != EFI_SUCCESS)
47+
@@ -102,6 +104,10 @@ EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE *root_dir
48+
if (err != EFI_SUCCESS)
49+
return err;
50+
51+
+ /* Double the size inside the device tree structure */
52+
+ uint32_t *totalsize = (uint32_t *)(((char *)PHYSICAL_ADDRESS_TO_POINTER(state->addr) + 4));
53+
+ (*totalsize) = htobe32(be32toh(*totalsize) * 4);
54+
+
55+
return BS->InstallConfigurationTable(
56+
MAKE_GUID_PTR(EFI_DTB_TABLE), PHYSICAL_ADDRESS_TO_POINTER(state->addr));
57+
}
58+
--
59+
2.48.1
60+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
2+
3+
SRC_URI:append:orin-nano = " file://0001-Increase-the-dtb-size.patch"

0 commit comments

Comments
 (0)