qemu I'm trying to virtualize FreeBSD 13.2 for armv7 on my ARM Chromebook (armhf) with qemu-kvm

anyway,it worked. As you can see the file produced is called "kernel.bin",is this correct ? What I should do now is to exchange the kernel.bin that's within the img file "FreeBSD-13.2-RELEASE-arm-armv7-GENERICSD.img" with the kernel.bin that I've just produced ? Is this right ?
 
I've said it already few times:
FreeBSD's default kernel is /boot/kernel/kernel, it is expected you copied your compiled kernel here (the whole /boot/kernel and /boot/dtb directory actually).

It could be that my -DNO_CLEAN make option dragged your leftovers from before triggering the issue. Don't know.
 
----> FreeBSD's default kernel is /boot/kernel/kernel, it is expected you copied your compiled kernel here (the whole /boot/kernel and /boot/dtb directory actually).

I don't have modules....do I need them ?

Screenshot from 2023-09-17 01-15-34.png
 
I don't know if it is correct ,but I have swapped the whole directory "dtb" and every file called kernel*. On my build structure I don't have any directory called "kernel",but I have one called "GENERIC". Inside of it I have swapped every file called kernel*,but I haven't any *.ko modules,but only a lot of *.o files, so I didn't swap them.
 
I assumed you are familiar with the kernel compilation. Do have a look at handbook to get familiar with the building process.

Given the last 3 posts you made I am confident you didn't copy proper kernel to a VM and that issue you had here are results of mixed setup and my -DNO_CLEAN being used as an built option.

Once you compile the kernel next step is to install the kernel. Here you don't want to install it on a host but rather:
Just to be sure I did the same thing (applied my patch) for armv7 (generic):
Code:
make -j4 -DNO_KERNELDEPEND -DNO_CLEAN buildkernel TARGET_ARCH=armv7 KERNCONF=GENERIC
make -j4 -DNO_KERNELDEPEND -DNO_CLEAN installkernel TARGET_ARCH=armv7 KERNCONF=GENERIC DESTDIR=$BASEDIR/build

install it somewhere else where you can copy it over. This is why I said
As I wrote before. I'm using custom location where I build stuff depending on architecture/project.

To keep everything organized.

I'm compiling kernel with the options that help me speed up repeated kernel builds. For you purposes you can skip the -D<NAME> variables and use the TARGET, DESTDIR and KERNCONF options only.
 
Code:
bash
cd /build/armv7/usr/src
export BASEDIR=/build/armv7
export MAKEOBJDIRPREFIX=/build/armv7/obj

your make (which is unabled to build the kernel)

Code:
# make -DNO_KERNELDEPEND -DNO_CLEAN buildkernel TARGET_ARCH=armv7 KERNCONF=GENERIC

errors :

make[4]: "/build/armv7/usr/src/sys/conf/kmod.mk" line 234: Malformed conditional (!defined(DEBUG_FLAGS) || ${MK_SPLIT_KERNEL_DEBUG} =="no")

make[4]: "/build/armv7/usr/src/sys/conf/kmod.mk" line 334: Malformed conditional (defined(DEBUG_FLAGS) && ${MK_SPLIT_KERNEL_DEBUG} != "no")

,so I can't issue the further command :

# make -DNO_KERNELDEPEND -DNO_CLEAN installkernel TARGET_ARCH=armv7 KERNCONF=GENERIC DESTDIR=$BASEDIR/build

covacat make (which does not give error during the kernel compilation,but it seems unabled to build the modules,so it does not work as well as your,even if does not give any error on compilation) :

Code:
# make -DNO_MODULES -DNO_CLEAN KERNCONF=GENERIC TARGET=arm TARGET_ARCH=armv7 buildkernel
no error.

# make -DNO_MODULES -DNO_CLEAN installkernel KERNCONF=GENERIC TARGET=arm TARGET_ARCH=armv7 DESTDIR=$BASEDIR/build
no error.

the part of the command that does not work is not the -DNO_CLEAN part (that I've added to the covacat make to exclude that was the broken part),but the "-DNO_KERNELDEPEND" part. Using the covacat make I see that inside the /build/armv7/obj/build/armv7/usr/src/arm.armv7/sys/GENERIC/ directory it hasn't produced any *.ko file. So,it is unabled to build the modules,as well as your make.
 
your make (which is unabled to build the kernel)
I gave you explanation on that twice already. Please at least remember what I wrote before and try to understnad why I wrote it. I said it twice already why NO_CLEAN may be a problem there and that you don't need to use it.
It's your state of the system that is causing issues, not my (nor covacat's ) options provided to make.

I don't understand why you are using NO_MODULES and wondering why modules are not compiled.

Anyway, patch is out there, it is doing what it suppose to do on arm7 too.
 
The part of the command that does not work is not the -DNO_CLEAN part (that I've added to the covacat make to exclude that was the broken part),but the "-DNO_KERNELDEPEND" part. The error produced by this parameter is the following one :

Code:
make[4]: "/build/armv7/usr/src/sys/conf/kmod.mk" line 234: Malformed conditional (!defined(DEBUG_FLAGS) || ${MK_SPLIT_KERNEL_DEBUG} =="no")

make[4]: "/build/armv7/usr/src/sys/conf/kmod.mk" line 334: Malformed conditional (defined(DEBUG_FLAGS) && ${MK_SPLIT_KERNEL_DEBUG} != "no")
 
---> For you purposes you can skip the -D<NAME> variables

I don't know what are the "-D<NAME>" variables. Can you elaborate more ? thanks.

Anyway I have the suspect that it will not solve the problem.

---> I don't understand why you are using NO_MODULES and wondering why modules are not compiled.

maybe because I didn't understand that -DNO_MODULES stands for NO_MODULES :) ; yes,sometime I can be stupid. Also because I didn't think that an experienced user like covacat didn't include the compilation module parameter inside his make. Someone like him can't commit this kind of carelessness :D covacat
 
Code:
# make KERNCONF=GENERIC TARGET=arm TARGET_ARCH=armv7 buildkernel

make[4]: "/build/armv7/usr/src/sys/conf/kmod.mk" line 234: Malformed conditional (!defined(DEBUG_FLAGS) || ${MK_SPLIT_KERNEL_DEBUG} == "no")
make[4]: "/build/armv7/usr/src/sys/conf/kmod.mk" line 334: Malformed conditional (defined(DEBUG_FLAGS) && ${MK_SPLIT_KERNEL_DEBUG} != "no")

at this point I will ask to some pertinent FreeBSD ML how to solve this problem.
 
No its little things like that are not well explained... It is not you.

-DNOCLEAN means -D NOCLEAN
They just leave the space out.
Just like many other compiler options are mashed together.

ok. but the problem is not there.
 
Time for you to turn off hyper mode and read.

Did you even specify FDT in your build? Nope...

Instead of telling things to people it is time to listen. Not insult helpers.
 
I am not sure you would need -DWITH_FDT being virtuilized but it seems to me you would need to use AHCI if not.
I am not familiar with qemu.
 
Given the last 3 posts you made I am confident you didn't copy proper kernel to a VM and that issue you had here are results of mixed setup and my -DNO_CLEAN being used as an built option.
Also because I didn't think that an experienced user like covacat didn't include the compilation module parameter inside his make.

There's no mistake done by covacat (or me for that matter). He applied my patch and gave you the file. That's all.
You have problems with compiling the stuff because you have a mess in the system. I'm reiterating myself but you are not listening.

Don't copy your current /usr/src to a build directory. Download a fresh src.txz or use git to do so. Make sure you don't have anything in src.conf or make.conf (if you can't qualify what can be a problem just use empty files for this compilation).

Note: I used different link to my patch (same patch, same contents).

Then do (I'm using bash):
Code:
export BASEDIR=/build/arm7
export MAKEOBJDIRPREFIX=/build/arm7/obj
cd /build/arm7
fetch http://ftp0.bme.freebsd.org/pub/FreeBSD/releases/amd64/13.2-RELEASE/src.txz
tar -xPjf src.txz
fetch -o if_vtnet.c.patch https://bz-attachments.freebsd.org/attachment.cgi?id=242127
patch -u < if_vtnet.c.patch
cd usr/src
make TARGET_ARCH=armv7 KERNCONF=GENERIC buildkernel
make TARGET_ARCH=armv7 KERNCONF=GENERIC DESTDIR=$BASEDIR/build installkernel
After that you'll have /build/arm7/build/boot directory with compiled kernel. Copy all contents of it to the /boot of your VM.
 
There's no mistake done by covacat (or me for that matter). He applied my patch and gave you the file. That's all.
You have problems with compiling the stuff because you have a mess in the system. I'm reiterating myself but you are not listening.

Don't copy your current /usr/src to a build directory. Download a fresh src.txz or use git to do so. Make sure you don't have anything in src.conf or make.conf (if you can't qualify what can be a problem just use empty files for this compilation).

Note: I used different link to my patch (same patch, same contents).

Then do (I'm using bash):
Code:
export BASEDIR=/build/arm7
export MAKEOBJDIRPREFIX=/build/arm7/obj
cd /build/arm7
fetch http://ftp0.bme.freebsd.org/pub/FreeBSD/releases/amd64/13.2-RELEASE/src.txz
tar -xPjf src.txz
fetch -o if_vtnet.c.patch https://bz-attachments.freebsd.org/attachment.cgi?id=242127
patch -u < if_vtnet.c.patch
cd usr/src
make TARGET_ARCH=armv7 KERNCONF=GENERIC buildkernel
make TARGET_ARCH=armv7 KERNCONF=GENERIC DESTDIR=$BASEDIR/build installkernel
After that you'll have /build/arm7/build/boot directory with compiled kernel. Copy all contents of it to the /boot of your VM.

Perfect. It gave no error. I want to thank you from the bottom of my heart.
 
Sorry,I had taken for granted that this question was solved,but it's not. It's solved for more than 50%,but not totally. Infact something still missing. Infact this is what happened when I booted FreeBSD on my Chromebook running Ubuntu 22.04 for arm32 :

Code:
Consoles: EFI console
    Reading loader env vars from /efi/freebsd/loader.env
Setting currdev to disk0p1:
FreeBSD/arm EFI loader, Revision 1.1

   Command line arguments: l
   Image base: 0x742a8000
   EFI version: 2.70
   EFI Firmware: EDK II (rev 1.00)
   Console: efi (0x20000000)
   Load Path: \EFI\BOOT\BOOTARM.EFI
Loading kernel...
/boot/kernel/kernel text=0x1b4 text=0x719e9c text=0x19a910 data=0xb1f60 data=0x0+0x1e8000 0x4+0xa4160+0x4+0x11
6be3-
Loading configured modules...
can't find '/boot/entropy'
/boot/kernel/umodem.ko text=0x1540 text=0xe90 data=0x230+0x4 0x4+0xe70+0x4+0xa7c
loading required module 'ucom'
/boot/kernel/ucom.ko text=0x19f8 text=0x2d18 data=0x494+0x838 0x4+0x1480+0x4+0xbcf
can't find '/etc/hostid'

Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...          
Using DTB provided by EFI at 0x782eb000.
Kernel entry at 0x6e400200...
Kernel args: (null)
WARNING: Cannot find freebsd,dts-version property, cannot check DTB compliance
---<<BOOT>>---
!!!WARNING!!! CPU(0) is vulnerable to speculative branch attacks. !!!
We cannot enable required bit(s) in ACTRL register
because it's locked by secure monitor and/or firmware.
Copyright (c) 1992-2021 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 13.2-RELEASE GENERIC arm
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
VT: init without driver.
CPU: ARM Cortex-A15 r0p4 (ECO: 0x00000000)
CPU Features:
  Multiprocessing, Thumb2, Security, Virtualization, Generic Timer, VMSAv7,
  PXN, LPAE, Coherent Walk
Optional instructions:
  SDIV/UDIV, UMULL, SMULL, SIMD(ext)
LoUU:2 LoC:3 LoUIS:2
Cache level 1:
 32KB/64B 2-way data cache WB Read-Alloc Write-Alloc
 32KB/64B 2-way instruction cache Read-Alloc
Cache level 2:
 1024KB/64B 16-way unified cache WB Read-Alloc Write-Alloc
real memory  = 892198912 (850 MB)
avail memory = 856809472 (817 MB)
arc4random: WARNING: initial seeding bypassed the cryptographic random device because it was not yet seeded an
d the knob 'bypass_before_seeding' was enabled.
random: entropy device external interface
kbd0 at kbdmux0
ofwbus0: <Open Firmware Device Tree>
simplebus0: <Flattened device tree simple bus> on ofwbus0
clk_fixed0: <Fixed clock> on ofwbus0
psci0: <ARM Power State Co-ordination Interface Driver> on ofwbus0
gic0: <ARM Generic Interrupt Controller> mem 0x8000000-0x800ffff,0x8010000-0x801ffff on ofwbus0
gic0: pn 0x2, arch 0x2, rev 0x0, implementer 0x43b irqs 288
gicv2m0: <ARM Generic Interrupt Controller MSI/MSIX> mem 0x8020000-0x8020fff on gic0
generic_timer0: <ARMv7 Generic Timer> irq 35,36,37,38 on ofwbus0
Timecounter "ARM MPCore Timecounter" frequency 24000000 Hz quality 1000
Event timer "ARM MPCore Eventtimer" frequency 24000000 Hz quality 1000
pcib0: <Generic PCI host controller> mem 0x3f000000-0x3fffffff on ofwbus0
pci0: <PCI bus> on pcib0
virtio_pci0: <VirtIO PCI (legacy) Network adapter> port 0x80-0x9f mem 0x11062000-0x11062fff,0x11058000-0x1105b
fff at device 1.0 on pci0
vtnet0: <VirtIO Networking Adapter> on virtio_pci0
vtnet0: Ethernet address: 52:54:00:12:34:55
virtio_pci1: <VirtIO PCI (modern) GPU adapter> mem 0x11061000-0x11061fff,0x11054000-0x11057fff at device 2.0 o
n pci0
virtio_pci1: cannot alloc resource for COMMON_CFG
virtio_pci1: cannot map configs
device_attach: virtio_pci1 attach returned 22
vgapci0: <VGA-compatible display> port 0xa0-0xaf mem 0x10000000-0x10ffffff,0x11040000-0x1104ffff at device 3.0
on pci0
vgapci0: Boot video device
xhci0: <NEC uPD720200 USB 3.0 controller> mem 0x1105c000-0x1105ffff at device 4.0 on pci0
xhci0: 32 bytes context size, 32-bit DMA
usbus0 on xhci0
virtio_pci1: <VirtIO PCI (legacy) Block adapter> mem 0x11060000-0x11060fff,0x11050000-0x11053fff at device 5.0
on pci0
vtblk0: <VirtIO Block Adapter> on virtio_pci1
vtblk0: 5120MB (10485760 512 byte sectors)
uart0: <PrimeCell UART (PL011)> mem 0x9000000-0x9000fff irq 34 on ofwbus0
uart0: console (115200,n,8,1)
cpulist0: <Open Firmware CPU Group> on ofwbus0
cpu0: <Open Firmware CPU> on cpulist0
Timecounters tick every 1.000 msec
usbus0: 5.0Gbps Super Speed USB v3.0
Trying to mount root from ufs:/dev/ufs/rootfs [rw]...
ugen0.1: <(0x1033) XHCI root HUB> at usbus0
uhub0 on usbus0
uhub0: <(0x1033) XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus0
Warning: no time-of-day clock registered, system time will not be set accurately
Dual Console: Video Primary, Serial Secondary
uhub0: 8 ports with 8 removable, self powered
/etc/rc: WARNING: hostid: unable to figure out a UUID from DMI data, generating a new one
ugen0.2: <QEMU QEMU USB Keyboard> at usbus0
ukbd0 on uhub0
ukbd0: <QEMU QEMU USB Keyboard, class 0/0, rev 2.00/0.00, addr 1> on usbus0
kbd1 at ukbd0
ugen0.3: <QEMU QEMU USB Mouse> at usbus0
ums0 on uhub0
ums0: <QEMU QEMU USB Mouse, class 0/0, rev 2.00/0.00, addr 2> on usbus0
ums0: 3 buttons and [XYZ] coordinates ID=0
random: unblocking device.
Setting hostuuid: 0b976153-64c5-4648-ad24-0715b2c896e1.
Setting hostid: 0x90b53c44.
Starting file system checks:
/dev/ufs/rootfs: FILE SYSTEM CLEAN; SKIPPING CHECKS
/dev/ufs/rootfs: clean, 734787 free (827 frags, 91745 blocks, 0.1% fragmentation)
Growing root partition to fill device
vtbd0s2 resized
vtbd0s2a resized
growfs: requested size 4.9GB is equal to the current filesystem size 4.9GB
Mounting local filesystems:.
Setting hostname: generic.
Setting up harvesting: [UMA],[FS_ATIME],SWI,INTERRUPT,NET_NG,[NET_ETHER],NET_TUN,MOUSE,KEYBOARD,ATTACH,CACHED
Feeding entropy: .
Building /boot/kernel/linker.hints

from this point nothing happens anymore. It's stalled.

I've virtualized FreeBSD using these qemu parameters :

Code:
UEFICODE=/usr/share/AAVMF/AAVMF32_CODE.fd
UEFIVARS=/usr/share/AAVMF/AAVMF32_VARS.fd
DISK=/Dati/img/FreeBSD-13.2-RELEASE-arm-armv7-GENERICSD.img

qemu-system-arm \
    -enable-kvm \
    -serial stdio \
    -m 900 -M virt -cpu cortex-a15 \
    -drive if=pflash,format=raw,unit=0,file=$UEFICODE \
    -drive if=pflash,format=raw,unit=1,file=$UEFIVARS \
    -drive file=$DISK,format=raw \
    -device virtio-net,netdev=net0,mac="52:54:00:12:34:55" \
    -netdev type=user,id=net0 \
    -device virtio-gpu-pci \
    -device vmware-svga,id=video0,vgamem_mb=16 \
    -usb -device nec-usb-xhci \
    -device usb-kbd -device usb-mouse \

Maybe the patch does not work in my case ? :

Code:
virtio_pci1: cannot alloc resource for COMMON_CFG
virtio_pci1: cannot map configs
device_attach: virtio_pci1 attach returned 22
 
My patch has nothing to do with this.

I bet virtio_pci1 is graphics related stuff. Note: you didn't paste your whole qemu command.

As I mentioned above -- start small and work your config up. No kvm, no special graphics settings. Once you get that working add more features.
 
It stops here :

Building /boot/kernel/linker.hints

do you have a vague idea about why ? it seems an error related to the kernel ? I've copied the dtb and the kernel dirs to the boot directory of the freebsd img file. Something else could be missing ?
 
Back
Top