From afe56d3ab3194d81d07f2c18b7fe56794bc191cf Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Fri, 13 Jun 2014 20:14:57 +0200 Subject: [PATCH] Load uImage higher so it doesn't overwrite itself Loading of haiku_loader from an uImage is a 2-step process: * First, the uImage is loaded (in our case from SD card using fatload) to RAM at a temporary address. * Then (using bootm), it is unpacked. The uImage is a container format and can hold several files, with a load and execution address. The files are copied from the uImage to their final location, and it's better if that doesn't overlap with the uImage content When this loading is done, bootm jumps to the entry point found in the uImage. We now actually execute our code from haiku_loader. This crashes with the following call stack: * vsnprintf * dprintf * boot_arch_cpu_init * cpu_init It seems vsnprintf is trying to use VFP instructions (probably from the libgcc) but that triggers some kind of fault, and the handler (setup by uboot?) ends up crashing the system by jumping to unmapped memory at 0. --- src/system/boot/platform/u-boot/Jamfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/system/boot/platform/u-boot/Jamfile b/src/system/boot/platform/u-boot/Jamfile index 8eb7611623..c154381bc3 100644 --- a/src/system/boot/platform/u-boot/Jamfile +++ b/src/system/boot/platform/u-boot/Jamfile @@ -179,10 +179,13 @@ actions BuildUBootSDImage1 MTOOLSRC=$(<).mtools mpartition -cI -T 0xc i: # format the image MTOOLSRC=$(<).mtools mformat -L 32 -v "Haiku" i: + # generate u-boot environment variables + # We load the uImage 2MB above its final destination, bootm will decode + # it to the proper location. Our image is smaller than 2MB so this works. echo 'uenvcmd=run loadImage; run mmcboot; - loadImage=fatload mmc0 0 0x80008000 haiku_loader_nbsd.ub - mmcboot=bootm 0x80008000' > uEnv.txt + loadImage=fatload mmc0 0 0x80200000 haiku_loader_nbsd.ub + mmcboot=bootm 0x80200000' > uEnv.txt # populate MTOOLSRC=$(<).mtools mcopy $(>) i: MTOOLSRC=$(<).mtools mcopy uEnv.txt i: