[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Booting the FreeBSD kernel as an zImage file needs a patch upgrade ?.



Excuse Me for my ignorance,but from the patch I'm not able to understand if I should remove or keep this part as is :

cpsid ifa

    mov r9, r0
    mov r8, r1
    mov ip, r2

thanks.

On Mon, Jan 8, 2024 at 10:54 PM Mario Marietto <marietto2008@xxxxxxxxx> wrote:
Very thanks for the new patch. I'm working on that....

On Mon, Jan 8, 2024 at 10:29 PM Warner Losh <imp@xxxxxxxxxx> wrote:
With this patch, I get the following results (I don't have Xen so I can't try it from there):

%  make buildkernel TARGET_ARCH=armv7 -DWITH_KERNEL_BIN
....
--- kernel.bin ---
linking kernel.bin
--- kernel.full ---
linking kernel.full
--- kernel.bin ---
     text     data       bss        dec        hex   filename
  9111273   740924   2441216   12293413   0xbb9525   kernel.bin
--- kernel.full ---
ctfmerge -L VERSION -g -o kernel.full ...
     text     data       bss        dec        hex   filename
  9111273   740924   2441216   12293413   0xbb9525   kernel.full
Building /usr/home/imp/obj/usr/home/imp/git/head/arm.armv7/sys/GENERIC/kernel.debug
Building /usr/home/imp/obj/usr/home/imp/git/head/arm.armv7/sys/GENERIC/kernel
        7.08 real        34.55 user        41.50 sys
--------------------------------------------------------------
>>> Kernel build for GENERIC completed on Mon Jan  8 14:25:58 MST 2024
--------------------------------------------------------------
>>> Kernel(s)  GENERIC built in 7 seconds, ncpu: 64, make -j100
--------------------------------------------------------------
% file /usr/home/imp/obj/usr/home/imp/git/head/arm.armv7/sys/GENERIC/kernel.bin
/usr/home/imp/obj/usr/home/imp/git/head/arm.armv7/sys/GENERIC/kernel.bin: Linux kernel ARM boot executable zImage (little-endian)

And that w/o installing a different tool chain.

So natively or in a linux/macos world the same results...

Warner

On Mon, Jan 8, 2024 at 1:58 PM Julien Grall <julien@xxxxxxx> wrote:
Hi Mario,

On 08/01/2024 14:20, Mario Marietto wrote:
> I took for granted that "arm-none-eabi-objcopy" does not work. It says
> command not found.

This is usually not installed by default. The triple (i.e.
arm-none-eabi-) depending on with cross-toolchain you installed (there
are various for Arm).

That said if you are on the Chromebook, the normal objdump may already
be compatible (that's assuming your OS is 32-bit).

Anyway, as you are building using the option WITH_KERNEL_BIN=1, then you
should not need the trick. If 'file' still doesn't show zImage, then it
would indicate that the header is not at the correct place.

I had some spare time this evening and decided to give a try. I have
downloaded the latest FreeBSD (I wasn't sure which with branch from
Elliott tree you were using). Below the changes I made to FreeBSD:

diff --git a/sys/arm/arm/locore-v6.S b/sys/arm/arm/locore-v6.S
index 4e356d6b34e2..56a7cf476d5b 100644
--- a/sys/arm/arm/locore-v6.S
+++ b/sys/arm/arm/locore-v6.S
@@ -105,6 +105,17 @@
         .globl  btext
  btext:
  ASENTRY_NP(_start)
+    .rept 8
+    mov r0, r0
+    .endr
+
+    b start
+
+    .word 0x016f2818
+    .word 0                 /* absolute load/run zImage address or 0
for PIC */
+    .word (_edata - btext)
+
+start:
         STOP_UNWINDING          /* Can't unwind into the bootloader! */

         /* Make sure interrupts are disabled. */
diff --git a/sys/arm/conf/GENERIC b/sys/arm/conf/GENERIC
index f8a39cb370d5..caaf29216d27 100644
--- a/sys/arm/conf/GENERIC
+++ b/sys/arm/conf/GENERIC
@@ -278,3 +278,4 @@ makeoptions MODULES_EXTRA+="dtb/zynq"
  # SOC-specific modules
  makeoptions    MODULES_EXTRA+="allwinner"
  makeoptions    MODULES_EXTRA+="imx"
+makeoptions WITH_KERNEL_BIN=1

The first hunk is my patch rebased as it didn't apply correctly. The
second part is the hack to enable WITH_KERNEL_BIN=1.

I compiled on an M2 MacBook Pro (it should not matter though). With:

42sh> MAKEOBJDIRPREFIX=$HOME/works/oss/freebsd/build/
tools/build/make.py -j 8 TARGET=arm TARGET_ARCH=armv7 buildkernel

Then I checked the output:

42sh> file
../build/Users/jgrall/works/oss/freebsd/src/arm.armv7/sys/GENERIC/kernel.bin
../build/Users/jgrall/works/oss/freebsd/src/arm.armv7/sys/GENERIC/kernel.bin:
Linux kernel ARM boot executable zImage (little-endian)

I didn't try to load the kernel, but at least file thinks that this a
zImage. I expect that 'xl' will be able to load the binary.

Would you be able to give a try and report?

Cheers,

--
Julien Grall


--
Mario.


--
Mario.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.