Skip to content

Commit a56514f

Browse files
committed
Fixes for zynqmp test-app. Working SD card boot.
1 parent 8e264f6 commit a56514f

File tree

7 files changed

+67
-22
lines changed

7 files changed

+67
-22
lines changed

docs/Targets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ wolfBoot replaces U-Boot in the ZynqMP boot flow:
19911991
FSBL -> PMUFW -> BL31 (EL3) -> wolfBoot (EL2) -> Linux (EL1)
19921992
```
19931993

1994-
For QSPI boot, wolfBoot runs from DDR at `0x7FF00000` (EL2, non-secure). For SD card boot, wolfBoot runs at `0x8000000`. All clock, MIO, and DDR initialization is handled by the FSBL/PMUFW before wolfBoot starts.
1994+
For QSPI boot, wolfBoot runs from DDR at `0x7FE00000` (EL2, non-secure). For SD card boot, wolfBoot runs at `0x8000000`. All clock, MIO, and DDR initialization is handled by the FSBL/PMUFW before wolfBoot starts.
19951995

19961996
This target supports **two boot paths**:
19971997
- **QSPI boot** (primary, production-style): `config/examples/zynqmp.config`
@@ -2049,7 +2049,7 @@ make
20492049
**QSPI layout**
20502050
| Partition | Size | Address | Description |
20512051
|-------------|--------|-------------|--------------------------------|
2052-
| Bootloader | - | 0x7FF00000 | wolfBoot in DDR (loaded by FSBL) |
2052+
| Bootloader | - | 0x7FE00000 | wolfBoot in DDR (loaded by FSBL) |
20532053
| Primary | 42MB | 0x800000 | Boot partition in QSPI |
20542054
| Update | 42MB | 0x3A00000 | Update partition in QSPI |
20552055
| Swap | - | 0x63E0000 | Swap area in QSPI |

hal/zynq.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,16 +2175,19 @@ void sdhci_platform_dma_prepare(void *buf, uint32_t sz, int is_write)
21752175

21762176
void sdhci_platform_dma_complete(void *buf, uint32_t sz, int is_write)
21772177
{
2178-
(void)is_write;
2179-
/* After DMA: clean and invalidate to ensure CPU sees DMA-written data */
2178+
/* After DMA read (card->memory): invalidate so CPU sees DMA-written data.
2179+
* For DMA write (card<-memory): DMA only read from memory, so there is no
2180+
* new data for the CPU to see and invalidation could discard dirty lines. */
21802181
uintptr_t addr;
21812182
uintptr_t start = (uintptr_t)buf & ~(CACHE_LINE_SIZE - 1);
21822183
uintptr_t end = (uintptr_t)buf + sz;
21832184

2184-
for (addr = start; addr < end; addr += CACHE_LINE_SIZE) {
2185-
__asm__ volatile("dc civac, %0" : : "r"(addr) : "memory");
2185+
if (!is_write) {
2186+
for (addr = start; addr < end; addr += CACHE_LINE_SIZE) {
2187+
__asm__ volatile("dc civac, %0" : : "r"(addr) : "memory");
2188+
}
2189+
__asm__ volatile("dsb sy" : : : "memory");
21862190
}
2187-
__asm__ volatile("dsb sy" : : : "memory");
21882191
}
21892192
#endif /* DISK_SDCARD || DISK_EMMC */
21902193

hal/zynq.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363

6464

6565
/* IOP System-level Control */
66-
#define IOU_SLCR_BASSE 0xFF180000
67-
#define IOU_TAPDLY_BYPASS_ADDR (IOU_SLCR_BASSE + 0x390)
66+
#define IOU_SLCR_BASE 0xFF180000
67+
#define IOU_TAPDLY_BYPASS_ADDR (IOU_SLCR_BASE + 0x390)
6868
#define IOU_TAPDLY_BYPASS (*((volatile uint32_t*)IOU_TAPDLY_BYPASS_ADDR))
6969
#define IOU_TAPDLY_BYPASS_LQSPI_RX (1UL << 2) /* LQSPI Tap Delay Enable on Rx Clock signal. 0: enable. 1: disable (bypass tap delay). */
7070

@@ -419,7 +419,7 @@
419419
#define RST_LPD_IOU2_SDIO1 (1UL << 6)
420420

421421
/* IOU_SLCR SD Configuration (feeds into SDHCI Capabilities register) */
422-
#define IOU_SLCR_SD_CONFIG_REG2 (*((volatile uint32_t*)(IOU_SLCR_BASSE + 0x320)))
422+
#define IOU_SLCR_SD_CONFIG_REG2 (*((volatile uint32_t*)(IOU_SLCR_BASE + 0x320)))
423423
/* SD1 Slot Type: 00=Removable, 01=Embedded, 10=Shared Bus */
424424
#define SD_CONFIG_REG2_SD1_SLOTTYPE_SHIFT 28
425425
#define SD_CONFIG_REG2_SD1_SLOTTYPE_MASK 0x30000000UL

hal/zynq.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ SECTIONS
4141
*(.gnu.linkonce.t.*)
4242
*(.plt)
4343
*(.gnu_warning)
44-
*(.gcc_execpt_table)
44+
*(.gcc_except_table)
4545
*(.glue_7)
4646
*(.glue_7t)
4747
*(.ARM.extab)
@@ -200,7 +200,7 @@ SECTIONS
200200
.ARM.exidx : {
201201
__exidx_start = .;
202202
*(.ARM.exidx*)
203-
*(.gnu.linkonce.armexidix.*.*)
203+
*(.gnu.linkonce.armexidx.*.*)
204204
__exidx_end = .;
205205
} > psu_ddr_0_MEM_0
206206

hal/zynq_sd.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ SECTIONS
4141
*(.gnu.linkonce.t.*)
4242
*(.plt)
4343
*(.gnu_warning)
44-
*(.gcc_execpt_table)
44+
*(.gcc_except_table)
4545
*(.glue_7)
4646
*(.glue_7t)
4747
*(.ARM.extab)
@@ -200,7 +200,7 @@ SECTIONS
200200
.ARM.exidx : {
201201
__exidx_start = .;
202202
*(.ARM.exidx*)
203-
*(.gnu.linkonce.armexidix.*.*)
203+
*(.gnu.linkonce.armexidx.*.*)
204204
__exidx_end = .;
205205
} > psu_ddr_0_MEM_0
206206

src/boot_aarch64.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "image.h"
2525
#include "loader.h"
26+
#include "printf.h"
2627
#include "wolfboot/wolfboot.h"
2728

2829
/* Include platform-specific header for EL configuration defines */
@@ -130,7 +131,10 @@ void RAMFUNCTION do_boot(const uint32_t *app_offset, const uint32_t* dts_offset)
130131
void RAMFUNCTION do_boot(const uint32_t *app_offset)
131132
#endif
132133
{
134+
wolfBoot_printf("do_boot: entry=0x%08x, EL=%d\n",
135+
(uint32_t)(uintptr_t)app_offset, current_el());
133136
#ifdef MMU
137+
wolfBoot_printf("do_boot: dts=0x%08x\n", (uint32_t)(uintptr_t)dts_offset);
134138
hal_dts_fixup((uint32_t*)dts_offset);
135139
#endif
136140

@@ -155,6 +159,7 @@ void RAMFUNCTION do_boot(const uint32_t *app_offset)
155159
#else
156160
uintptr_t dts = 0;
157161
#endif
162+
wolfBoot_printf("do_boot: EL2->EL1 via ERET\n");
158163
el2_to_el1_boot((uintptr_t)app_offset, dts);
159164
}
160165
#else

test-app/app_zynq.c

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* app_zynq.c
22
*
3-
* Test bare-metal boot application
3+
* Test bare-metal boot application for AMD ZynqMP ZCU102
44
*
55
* Copyright (C) 2025 wolfSSL Inc.
66
*
@@ -21,19 +21,56 @@
2121
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2222
*/
2323

24-
#include <stdlib.h>
2524
#include <stdint.h>
26-
#include <string.h>
2725

2826
#include "wolfboot/wolfboot.h"
27+
#include "printf.h"
2928

3029
#ifdef TARGET_zynq
3130

32-
volatile uint32_t time_elapsed = 0;
33-
void main(void) {
31+
/* Provide current_el() for hal/zynq.o (normally in boot_aarch64.c) */
32+
unsigned int current_el(void)
33+
{
34+
unsigned long el;
35+
__asm__ volatile("mrs %0, CurrentEL" : "=r" (el) : : "cc");
36+
return (unsigned int)((el >> 2) & 0x3U);
37+
}
38+
39+
/* Stub for QSPI DMA code in hal/zynq.o (not used with SD card boot) */
40+
void flush_dcache_range(unsigned long start, unsigned long end)
41+
{
42+
(void)start;
43+
(void)end;
44+
}
45+
46+
void main(void)
47+
{
48+
#ifdef WOLFBOOT_FIXED_PARTITIONS
49+
uint32_t boot_version, update_version;
50+
#endif
51+
52+
wolfBoot_printf("\n\n");
53+
wolfBoot_printf("===========================================\n");
54+
wolfBoot_printf(" wolfBoot Test Application - AMD ZynqMP\n");
55+
wolfBoot_printf("===========================================\n\n");
56+
57+
wolfBoot_printf("Current EL: %d\n", current_el());
58+
59+
#ifdef WOLFBOOT_FIXED_PARTITIONS
60+
boot_version = wolfBoot_get_image_version(PART_BOOT);
61+
update_version = wolfBoot_get_image_version(PART_UPDATE);
62+
wolfBoot_printf("BOOT: Version: %d (0x%08x)\n", boot_version, boot_version);
63+
wolfBoot_printf("UPDATE: Version: %d (0x%08x)\n", update_version, update_version);
64+
#else
65+
wolfBoot_printf("Boot mode: Disk-based (MBR partitions)\n");
66+
#endif
67+
68+
wolfBoot_printf("Application running successfully!\n");
69+
wolfBoot_printf("\nEntering idle loop...\n");
3470

35-
/* Wait for reboot */
36-
while(1)
37-
;
71+
/* Idle loop */
72+
while (1) {
73+
__asm__ volatile("wfi");
74+
}
3875
}
3976
#endif /** TARGET_zynq **/

0 commit comments

Comments
 (0)