Skip to content

Commit 87f5b7a

Browse files
committed
Make Agilex 5 console UART, DDR size and FDT node disables board configurable
1 parent decd4b2 commit 87f5b7a

4 files changed

Lines changed: 67 additions & 21 deletions

File tree

‎config/examples/agilex5_013b_sdcard.config‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ CFLAGS_EXTRA+=-DBOOT_PART_A=1 -DBOOT_PART_B=2
4949
CFLAGS_EXTRA+=-DDISK_BLOCK_SIZE=0x80000
5050
CFLAGS_EXTRA+=-DLINUX_BOOTARGS_ROOT=\"/dev/mmcblk0p4\"
5151

52+
# Board settings, see docs/Agilex5.md. Defaults match the 013B dev kit.
53+
#CFLAGS_EXTRA+=-DDEBUG_UART_NUM=1
54+
#CFLAGS_EXTRA+=-DAGILEX5_DDR_SIZE=0x70000000
55+
CFLAGS_EXTRA+=-DAGILEX5_FDT_DISABLE_PATHS=\"/leds\"
56+
5257
# SD6HC uses SDMA for cache-coherent multi-block transfers.
5358
CFLAGS_EXTRA+=-DSDHCI_FORCE_CARD_DETECT
5459

‎docs/Agilex5.md‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ Create the Linux FIT from the GSRD `Image` and the exact board DTB, then sign
3636
that FIT with wolfBoot's normal image-signing flow. Initialize both raw A/B
3737
partitions with a valid signed image for the first boot.
3838

39+
### Board settings
40+
41+
The example config targets the DK-A5E013BM16AEA. Other boards set these in
42+
their config:
43+
44+
| Setting | Default | Purpose |
45+
|---|---|---|
46+
| `CFLAGS_EXTRA+=-DDEBUG_UART_NUM=1` | UART0 (`0x10C02000`) | console UART for wolfBoot and Linux `earlycon` |
47+
| `CFLAGS_EXTRA+=-DDEBUG_UART_BASE=<addr>` | unset | any other console UART; write the address without a `UL` suffix |
48+
| `CFLAGS_EXTRA+=-DAGILEX5_DDR_SIZE=<bytes>` | `0x70000000` (1792 MiB) | DDR size written to the DTB memory node |
49+
| `CFLAGS_EXTRA+=-DAGILEX5_FDT_DISABLE_PATHS=\"/leds\"` | unset | comma-separated DTB node paths to mark `disabled`, for hardware behind the unprogrammed FPGA |
50+
51+
wolfBoot does not read the DDR size from the DTB, because without U-Boot the
52+
memory node holds whatever the DTB author wrote rather than the fitted size.
53+
3954
The checked-in `hal/agilex5.its` is a minimal FIT example. A GSRD production
4055
image must use the GSRD-generated kernel load address and board DTB, then be
4156
signed with the deployment key. Do not place private keys in the source tree
@@ -72,7 +87,9 @@ software and is deliberately not linked into bare-metal wolfBoot.
7287
PSCI reboot, and rootfs `/dev/mmcblk0p4`.
7388
5. Build the complete WIC, inspect all four partitions, flash the whole card,
7489
compare the complete image span, cold boot, and test A-to-B fallback by
75-
corrupting only a disposable copy of A.
90+
corrupting only a disposable copy of A. Both slots must hold the same
91+
version: with `ALLOW_DOWNGRADE=0` wolfBoot refuses to fall back to a lower
92+
version (`Rollback to lower version not allowed`) and panics instead.
7693
6. From the booted WIC run `/usr/bin/wolfcrypttest`. Require exit zero and
7794
`ALTERA-FCS test passed!` to prove the Linux image still provides hardware
7895
FCS offload.

‎hal/agilex5.c‎

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@
3838
#ifndef LINUX_BOOTARGS_ROOT
3939
#define LINUX_BOOTARGS_ROOT "/dev/mmcblk0p4"
4040
#endif
41+
#define AGILEX5_STR2(x) #x
42+
#define AGILEX5_STR(x) AGILEX5_STR2(x)
4143
#define LINUX_BOOTARGS \
42-
"earlycon=uart8250,mmio32,0x10c02000 console=ttyS0,115200 " \
43-
"root=" LINUX_BOOTARGS_ROOT " rootwait"
44+
"earlycon=uart8250,mmio32," AGILEX5_STR(DEBUG_UART_BASE) \
45+
" console=ttyS0,115200 root=" LINUX_BOOTARGS_ROOT " rootwait"
4446
#endif
4547

4648
#ifdef DEBUG_UART
@@ -51,7 +53,8 @@
5153
#define UART_LSR_TEMT (1U << 6)
5254
#define UART_TIMEOUT 1000000U
5355
#define UART_REG(_n) \
54-
(*(volatile uint32_t *)(AGILEX5_UART0_BASE + ((uintptr_t)(_n) << 2)))
56+
(*(volatile uint32_t *)((uintptr_t)DEBUG_UART_BASE + \
57+
((uintptr_t)(_n) << 2)))
5558

5659
void uart_init(void)
5760
{
@@ -153,11 +156,22 @@ void *hal_get_dts_update_address(void)
153156
}
154157

155158
#ifdef __WOLFBOOT
159+
#ifdef AGILEX5_FDT_DISABLE_PATHS
160+
static const char* const agilex5_fdt_disable[] = { AGILEX5_FDT_DISABLE_PATHS };
161+
#endif
162+
156163
int hal_dts_fixup(void *dts_addr, uint32_t capacity)
157164
{
158165
fdt_ctx ctx;
159166
int off;
160167
int ret;
168+
#ifdef AGILEX5_FDT_DISABLE_PATHS
169+
unsigned int i;
170+
#endif
171+
172+
/* Bare-metal and RTOS payloads carry no DTB. */
173+
if (dts_addr == NULL)
174+
return 0;
161175

162176
/* Validate the blob against the window it actually occupies. */
163177
ret = fdt_open(&ctx, dts_addr, capacity);
@@ -171,9 +185,6 @@ int hal_dts_fixup(void *dts_addr, uint32_t capacity)
171185
return ret;
172186
}
173187

174-
/* U-Boot normally patches the memory node after SPL has measured the
175-
* LPDDR4. wolfBoot bypasses U-Boot and passes this DTB directly to
176-
* Linux, so preserve the board's 1792 MiB memory map explicitly. */
177188
off = fdt_find_devtype(&ctx, -1, "memory");
178189
if (off >= 0) {
179190
uint64_t reg[2];
@@ -190,19 +201,23 @@ int hal_dts_fixup(void *dts_addr, uint32_t capacity)
190201
(unsigned long)AGILEX5_DDR_SIZE);
191202
}
192203

193-
/* The board DT contains an optional FPGA-backed gpio-leds node. The
194-
* normal GSRD path programs the fabric in U-Boot before probing it; the
195-
* direct wolfBoot handoff does not yet program that optional design.
196-
* Keep Linux from touching an unconfigured fabric register while the
197-
* HPS, FCS and storage paths remain available. */
198-
off = fdt_find_node_offset(&ctx, -1, "leds");
199-
if (off >= 0) {
200-
ret = fdt_fixup_str(&ctx, off, "leds", "status", "disabled");
204+
/* wolfBoot does not program the fabric, so the board config lists the
205+
* nodes whose hardware sits behind the unprogrammed FPGA. */
206+
#ifdef AGILEX5_FDT_DISABLE_PATHS
207+
for (i = 0; i < sizeof(agilex5_fdt_disable) /
208+
sizeof(agilex5_fdt_disable[0]); i++) {
209+
off = fdt_path_offset(&ctx, agilex5_fdt_disable[i]);
210+
if (off < 0)
211+
continue;
212+
ret = fdt_fixup_str(&ctx, off, agilex5_fdt_disable[i], "status",
213+
"disabled");
201214
if (ret != 0) {
202-
wolfBoot_printf("FDT: failed to disable FPGA LEDs (%d)\n", ret);
215+
wolfBoot_printf("FDT: failed to disable %s (%d)\n",
216+
agilex5_fdt_disable[i], ret);
203217
return ret;
204218
}
205219
}
220+
#endif
206221

207222
off = fdt_subnode_offset(&ctx, 0, "chosen");
208223
if (off == -FDT_ERR_NOTFOUND)

‎hal/agilex5.h‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,21 @@
5151
#endif
5252

5353
#define AGILEX5_DDR_BASE 0x80000000UL
54-
/* The DK-A5E013BM16AEA is fitted with 1792 MiB of LPDDR4. The SPL/U-Boot
55-
* device tree normally fills this in at runtime; wolfBoot hands the DTB
56-
* directly to Linux, so the fixed board size must be supplied here. */
54+
/* U-Boot normally writes the measured DDR size into the DTB; wolfBoot hands
55+
* the DTB straight to Linux, so the board config supplies it. Default is the
56+
* DK-A5E013BM16AEA's 1792 MiB. */
57+
#ifndef AGILEX5_DDR_SIZE
5758
#define AGILEX5_DDR_SIZE 0x70000000UL
58-
#define AGILEX5_UART0_BASE 0x10C02000UL
59-
#define AGILEX5_UART1_BASE 0x10C02100UL
59+
#endif
60+
61+
/* No UL suffix: the base is also stringified into the earlycon argument. */
62+
#ifndef DEBUG_UART_BASE
63+
#if defined(DEBUG_UART_NUM) && DEBUG_UART_NUM == 1
64+
#define DEBUG_UART_BASE 0x10C02100
65+
#else
66+
#define DEBUG_UART_BASE 0x10C02000
67+
#endif
68+
#endif
6069
#define AGILEX5_SDHCI_BASE 0x10808000UL
6170
#define CACHE_LINE_SIZE 64UL
6271

0 commit comments

Comments
 (0)