Skip to content

Commit 61fd552

Browse files
dgarskedanielinux
authored andcommitted
Peer review fixes (thanks copilot and customer)
1 parent 8c059a8 commit 61fd552

6 files changed

Lines changed: 49 additions & 23 deletions

File tree

config/examples/nxp-t2080.config

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
#CFLAGS_EXTRA+=-DBOARD_NAII_68PPC2
1111
#
1212
# For CW VPX3-152 (256 MB NOR flash at 0xF0000000), uncomment the BOARD
13-
# define AND the address override block at the bottom of this file.
13+
# define below AND the entire address-override block at the bottom of this
14+
# file. That block includes OS_64BIT=1, which is REQUIRED to boot a 64-bit
15+
# RTOS (VxWorks 7 / Green Hills INTEGRITY-178 tuMP) -- it gates the e6500 SMP
16+
# spin-table + DDR-LAW handoff in hal/nxp_t2080.c; without it the loader runs
17+
# but the OS hangs silently right after "do_boot: jumping".
1418
#CFLAGS_EXTRA+=-DBOARD_CW_VPX3152
1519

1620
ARCH=PPC
@@ -79,28 +83,40 @@ WOLFBOOT_DTS_UPDATE_ADDRESS?=0xE8050000
7983
WOLFBOOT_LOAD_DTS_ADDRESS?=0x200000
8084

8185
# -----------------------------------------------------------------------------
82-
# CW VPX3-152 address overrides (256 MB NOR flash @ 0xF0000000)
83-
# Uncomment ALL lines below when building for VPX3-152.
84-
# Also uncomment CFLAGS_EXTRA+=-DBOARD_CW_VPX3152 at the top of this file.
86+
# CW VPX3-152 overrides (256 MB NOR flash @ 0xF0000000, 4 GB DDR3L)
87+
# Uncomment ALL lines below when building for VPX3-152, AND uncomment
88+
# CFLAGS_EXTRA+=-DBOARD_CW_VPX3152 at the top of this file. This is the
89+
# known-good config used to boot VxWorks 7 and Green Hills INTEGRITY-178
90+
# tuMP (Ada Scheduler) on this board.
8591
# -----------------------------------------------------------------------------
8692
#ARCH_FLASH_OFFSET=0xFFFE0000
8793
#L2SRAM_ADDR=0xEE900000
8894
#WOLFBOOT_ORIGIN=0xFFFE0000
89-
#WOLFBOOT_PARTITION_BOOT_ADDRESS=0xFFEE0000
90-
#WOLFBOOT_PARTITION_UPDATE_ADDRESS=0xFFDE0000
91-
#WOLFBOOT_PARTITION_SWAP_ADDRESS=0xFFDD0000
95+
# 8 MB partitions -- full RTOS images do not fit the 1 MB RDB default.
96+
#WOLFBOOT_PARTITION_SIZE=0x800000
97+
#WOLFBOOT_PARTITION_BOOT_ADDRESS=0xFF000000
98+
#WOLFBOOT_PARTITION_UPDATE_ADDRESS=0xFE800000
99+
#WOLFBOOT_PARTITION_SWAP_ADDRESS=0xFE7F0000
92100
#WOLFBOOT_DTS_BOOT_ADDRESS=0xF0040000
93101
#WOLFBOOT_DTS_UPDATE_ADDRESS=0xF0050000
94-
#WOLFBOOT_LOAD_DTS_ADDRESS=0xF000000
95-
# ELF staging buffer. wolfBoot copies the signed image here, then
96-
# elf_load scatters PT_LOAD segments IN PLACE to their vaddrs. It MUST sit
97-
# ABOVE the ELF's vaddr span (e.g. a VxWorks/Integrity ELF spanning
98-
# 0x2000-0x75F000) or the in-place loader's collide-guard silently drops
99-
# the segment overlapping the program-header table -- the OS then executes
100-
# unloaded memory and traps early. The 0x19000 default overlaps the span;
101-
# 0x900000 is above it, below the 16MB DDR stack, inside the 32MB cache-
102-
# inhibit window. Raw uImage kernels override this via ih_load (unaffected).
102+
#WOLFBOOT_LOAD_DTS_ADDRESS=0x03FE6000
103+
# REQUIRED for 64-bit RTOS boot (VxWorks 7 / INTEGRITY-178 tuMP). Gates the
104+
# e6500 SMP spin-table (0x7FEE41C0) + DDR-LAW-slot-17 handoff in
105+
# hal/nxp_t2080.c. Without it the loader runs but the OS hangs silently after
106+
# "do_boot: jumping" (it is NOT a missing device tree -- tuMP has no FDT
107+
# parser; this build option is what was actually missing).
108+
#OS_64BIT=1
109+
# ELF staging buffer. wolfBoot copies the signed image here, then elf_load
110+
# scatters PT_LOAD segments IN PLACE to their vaddrs. It MUST sit ABOVE the
111+
# ELF's vaddr span (a VxWorks/INTEGRITY ELF spans ~0x2000-0x75F000) or the
112+
# in-place loader's collide-guard silently drops the segment overlapping the
113+
# program-header table -- the OS then executes unloaded memory and traps
114+
# early. The 0x19000 default overlaps the span; 0x900000 is above it, below
115+
# the 16 MB DDR stack, inside the 32 MB cache-inhibit window. Raw uImage
116+
# kernels override this via ih_load (unaffected).
103117
#WOLFBOOT_LOAD_ADDRESS=0x900000
118+
# Optional: verbose pre-OS register/TLB/LAW dump for handoff debugging.
119+
#CFLAGS_EXTRA+=-DWOLFBOOT_PPC_PRE_OS_DUMP
104120

105121
# Flash erase/write/read test at update partition address
106122
#TEST_FLASH?=1

hal/nxp_t2080.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,10 @@ extern uint32_t _spin_table_addr;
13981398
* hal_dts_fixup() for cpu-release-addr fixups. Also read by boot_ppc.c
13991399
* pre-jump dump to capture spin-table contents at handoff. */
14001400
uint32_t g_spin_table_ddr = 0;
1401+
/* DDR address of the secondary-core boot page, set by hal_mp_init() and used
1402+
* by hal_dts_fixup() to /memreserve/ the actual page (it differs by config:
1403+
* 0x7E3FF000 for VPX3 OS64BIT, 0x7FFFF000 otherwise). */
1404+
uint32_t g_bootpg_ddr = 0;
14011405
extern uint32_t _bootpg_addr;
14021406

14031407
/* Startup additional cores with spin table and synchronize the timebase.
@@ -1597,6 +1601,7 @@ static void hal_mp_init(void)
15971601

15981602
/* Persist DDR spin-table base for hal_dts_fixup() (cpu-release-addr). */
15991603
g_spin_table_ddr = spin_table_ddr;
1604+
g_bootpg_ddr = bootpg;
16001605

16011606
/* Release all cores from reset into the spin loop. The cluster L2 runs
16021607
* with ECC ON (boot_ppc_start.S), so the secondaries spin ECC-consistent
@@ -1681,17 +1686,18 @@ int hal_dts_fixup(void* dts_addr)
16811686
{
16821687
int rsv_ret;
16831688
uint64_t spin_pg = (uint64_t)(g_spin_table_ddr & ~0xFFFU);
1689+
uint64_t boot_pg = (uint64_t)(g_bootpg_ddr & ~0xFFFU);
16841690

16851691
rsv_ret = fdt_add_mem_rsv(fdt, spin_pg, 0x1000ULL);
16861692
if (rsv_ret != 0) {
16871693
wolfBoot_printf("FDT: failed to reserve spin-table page "
16881694
"@ 0x%llx: %d\n", spin_pg, rsv_ret);
16891695
return rsv_ret;
16901696
}
1691-
rsv_ret = fdt_add_mem_rsv(fdt, 0x7ffff000ULL, 0x1000ULL);
1697+
rsv_ret = fdt_add_mem_rsv(fdt, boot_pg, 0x1000ULL);
16921698
if (rsv_ret != 0) {
16931699
wolfBoot_printf("FDT: failed to reserve boot page "
1694-
"@ 0x7ffff000: %d\n", rsv_ret);
1700+
"@ 0x%llx: %d\n", boot_pg, rsv_ret);
16951701
return rsv_ret;
16961702
}
16971703
rsv_ret = fdt_add_mem_rsv(fdt, 0xfffff000ULL, 0x1000ULL);

src/boot_ppc_mp.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ _secondary_start_page:
4848
* may exhibit cache speculation / DVA-stale / coherency bugs.
4949
* VPX3-152 ships rev 1.1 (PVR 0x85380011). */
5050
mfspr r3, SPRN_PVR
51-
rlwinm r3, r3, 28, 0xf /* major_rev */
51+
rlwinm r3, r3, 28, 28, 31 /* major_rev = (PVR>>4)&0xF */
5252
cmpwi r3, 0x1
5353
bne mp_t2080_errata_done
5454

src/boot_ppc_start.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ _reset:
229229
* VPX3-152 ships rev 1.1 (PVR 0x85380011) per CW U-Boot banner.
230230
* Read PVR major_rev and gate the rev-1-only fixes accordingly. */
231231
mfspr r3, SPRN_PVR
232-
rlwinm r3, r3, 28, 0xf /* r3 = major_rev */
232+
rlwinm r3, r3, 28, 28, 31 /* r3 = major_rev = (PVR>>4)&0xF */
233233
cmpwi r3, 0x1 /* is rev 1? */
234234
bne t2080_errata_done
235235

src/string.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,9 @@ void uart_vprintf(const char* fmt, va_list argp)
495495
long long sll = va_arg(argp, long long);
496496
if (sll < 0) {
497497
is_neg = 1;
498-
val = (unsigned long long)(-sll);
498+
/* Negate in unsigned space so LLONG_MIN
499+
* does not overflow. */
500+
val = 0ULL - (unsigned long long)sll;
499501
}
500502
else {
501503
val = (unsigned long long)sll;

src/update_ram.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,10 @@ void RAMFUNCTION wolfBoot_start(void)
447447
load_address = (uint32_t*)(uintptr_t)ih_load;
448448
} else {
449449
/* Linux PPC path: leave load_address alone, just advance it
450-
* past the header to match upstream behaviour. */
451-
load_address += UBOOT_IMG_HDR_SZ;
450+
* past the header to match upstream behaviour. load_address is
451+
* a uint32_t*, so advance by BYTES, not words. */
452+
load_address = (uint32_t*)((uint8_t*)load_address +
453+
UBOOT_IMG_HDR_SZ);
452454
}
453455
(void)ih_ep; /* TODO: pass through to do_boot when ih_ep != ih_load */
454456
}

0 commit comments

Comments
 (0)