pgj / freebsd-wifibox

wifibox: Use Linux to drive your wireless card on FreeBSD
BSD 2-Clause "Simplified" License
159 stars 12 forks source link

Can't get working with Broadcom BCM43602 (Macbook Pro 2015) #65

Closed suchipi closed 2 months ago

suchipi commented 1 year ago

Description

I can't get wifibox to work with the Broadcom BCM43602 found in my Macbook Pro 2015.

The guest doesn't seem to recognize the device.

I'm testing via ping google.com outside the guest, which times out.

Host operating system

FreeBSD Rei 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC amd64

Wireless NIC

ppt0@pci0:3:0:0:        class=0x028000 rev=0x01 hdr=0x00 vendor=0x14e4 device=0x43ba subvendor=0x106b subdevice=0x0152
    vendor     = 'Broadcom Inc. and subsidiaries'
    device     = 'BCM43602 802.11ac Wireless LAN SoC'
    class      = network

Wifibox version

wifibox version 0.11.0
Disk image checksum: ddd16597adc3dc12846bf7f9b00798f3d728107db52b819b51e78eb6019f34ac

(installed via pkg)

Disk image type and version

wifibox-alpine-20230326

(installed via pkg)

Changes to the default configuration files

bhyve.conf:

console=yes
passthru=3/0/0

core.conf

loglevel=debug

wpa_supplicant.conf

network={
  ssid="redacted"
  psk="redacted"
}

relevant additions to /etc/rc.conf

wifibox_enable="YES"
ifconfig_wifibox="SYNCDHCP"
background_dhclient_wifibox0="YES"

Logs

/var/log/wifibox.log

2023-09-16T22:53:38-0600 INFO  Begin: wifibox start
2023-09-16T22:53:38-0600 DEBUG start=GN
2023-09-16T22:53:38-0600 INFO  Creating bridge interface: wifibox0
2023-09-16T22:53:38-0600 DEBUG [ifconfig] wifibox0
2023-09-16T22:53:38-0600 INFO  Linking tap interface to wifibox0: tap0
2023-09-16T22:53:38-0600 INFO  vmm.ko is expected at path: /boot/kernel/vmm.ko
2023-09-16T22:53:38-0600 INFO  vmm.ko is found at path: /boot/kernel/vmm.ko
2023-09-16T22:53:38-0600 DEBUG assert loaded: kmod=vmm, kmod_file=/boot/kernel/vmm.ko
2023-09-16T22:53:38-0600 DEBUG assert hardware support present: iommu=1, amdvi=0
2023-09-16T22:53:38-0600 DEBUG Backends reported by bhyve:
2023-09-16T22:53:38-0600 DEBUG [bhyve] ahci
2023-09-16T22:53:38-0600 DEBUG [bhyve] ahci-hd
2023-09-16T22:53:38-0600 DEBUG [bhyve] ahci-cd
2023-09-16T22:53:38-0600 DEBUG [bhyve] e1000
2023-09-16T22:53:38-0600 DEBUG [bhyve] dummy
2023-09-16T22:53:38-0600 DEBUG [bhyve] hda
2023-09-16T22:53:38-0600 DEBUG [bhyve] fbuf
2023-09-16T22:53:38-0600 DEBUG [bhyve] amd_hostbridge
2023-09-16T22:53:38-0600 DEBUG [bhyve] hostbridge
2023-09-16T22:53:38-0600 DEBUG [bhyve] lpc
2023-09-16T22:53:38-0600 DEBUG [bhyve] nvme
2023-09-16T22:53:38-0600 DEBUG [bhyve] passthru
2023-09-16T22:53:38-0600 DEBUG [bhyve] virtio-9p
2023-09-16T22:53:38-0600 DEBUG [bhyve] virtio-blk
2023-09-16T22:53:38-0600 DEBUG [bhyve] virtio-console
2023-09-16T22:53:38-0600 DEBUG [bhyve] virtio-input
2023-09-16T22:53:38-0600 DEBUG [bhyve] virtio-net
2023-09-16T22:53:38-0600 DEBUG [bhyve] virtio-rnd
2023-09-16T22:53:38-0600 DEBUG [bhyve] virtio-scsi
2023-09-16T22:53:38-0600 DEBUG [bhyve] uart
2023-09-16T22:53:38-0600 DEBUG [bhyve] xhci
2023-09-16T22:53:38-0600 INFO  Bringing up null-modem devices for console connection
2023-09-16T22:53:38-0600 DEBUG assert loaded: kmod=nmdm, kmod_file=nmdm
2023-09-16T22:53:38-0600 INFO  Null-modem devices are available
2023-09-16T22:53:38-0600 INFO  Waiting for bhyve to start up
2023-09-16T22:53:38-0600 DEBUG Program started as /usr/local/sbin/wifibox, with arguments: _manage_vm
2023-09-16T22:53:38-0600 DEBUG assert daemonized: parent=daemon
2023-09-16T22:53:38-0600 INFO  VM manager launched
2023-09-16T22:53:38-0600 INFO  Gathering necessary configuration files for launching the guest
2023-09-16T22:53:38-0600 INFO  Pulling bhyve options from configuration file
2023-09-16T22:53:38-0600 DEBUG cpus=1, memory=128M, passthru=3/0/0, console=yes
2023-09-16T22:53:38-0600 INFO  Guest console is configured to use
2023-09-16T22:53:38-0600 INFO  Passthru device is configured: 3/0/0
2023-09-16T22:53:38-0600 INFO  PPT driver is configured for pci3:0:0 device
2023-09-16T22:53:38-0600 INFO  tap interface is configured: tap0
2023-09-16T22:53:38-0600 INFO  Launching guest wifibox from /usr/local/share/wifibox with grub-bhyve
2023-09-16T22:53:38-0600 INFO  Application config is found at /usr/local/etc/wifibox/wpa_supplicant
2023-09-16T22:53:38-0600 INFO  Application config will be mounted writeable
2023-09-16T22:53:38-0600 DEBUG Devices: virtio-blk,/usr/local/share/wifibox/disk.img virtio-9p,config=/usr/local/etc/wifibox/appliance,ro virtio-9p,var=/var/run/wifibox/appliance virtio-9p,app_config=/usr/local/etc/wifibox/wpa_supplicant
2023-09-16T22:53:38-0600 DEBUG Arguments:  -S -M 128M -r host -c /dev/nmdm-wifibox.1A -d /usr/local/share/wifibox wifibox
2023-09-16T22:53:38-0600 INFO  Launching guest wifibox from /usr/local/share/wifibox with bhyve
2023-09-16T22:53:38-0600 DEBUG Arguments:  -c 1 -m 128M -AHP -u -S -l com1,/dev/nmdm-wifibox.1A -s 0,hostbridge -s 31,lpc -s 4:0,virtio-blk,/usr/local/share/wifibox/disk.img -s 4:1,virtio-9p,config=/usr/local/etc/wifibox/appliance,ro -s 4:2,virtio-9p,var=/var/run/wifibox/appliance -s 4:3,virtio-9p,app_config=/usr/local/etc/wifibox/wpa_supplicant -s 5:0,e1000,tap0 -s 6:0,passthru,3/0/0 wifibox
2023-09-16T22:53:38-0600 DEBUG [bhyve] wrmsr to register 0x140(0) on vcpu 0
2023-09-16T22:53:39-0600 DEBUG [bhyve] rdmsr to register 0x34 on vcpu 0
2023-09-16T22:53:39-0600 INFO  Guest wifibox has started up
2023-09-16T22:53:39-0600 INFO  Guest is managed by PID 5514
2023-09-16T22:53:39-0600 INFO  Bringing up Unix Domain Socket pass-through
2023-09-16T22:53:39-0600 INFO  Found guest IP address: 10.0.0.1
2023-09-16T22:53:39-0600 INFO  Configured sockets: [path=/var/run/wpa_supplicant/wlan0,user=root,group=0,mode=770,port=1200
path=/var/run/wpa_supplicant/p2p-dev-wlan0,user=root,group=0,mode=770,port=1201]
2023-09-16T22:53:39-0600 INFO  Hooking up 10.0.0.1:1200 as /var/run/wpa_supplicant/wlan0 (root:0@770)
2023-09-16T22:53:39-0600 INFO  Hooking up 10.0.0.1:1201 as /var/run/wpa_supplicant/p2p-dev-wlan0 (root:0@770)
2023-09-16T22:53:39-0600 INFO  End: wifibox start

/var/run/wifibox/appliance/log/dmesg

[    0.000000] Linux version 5.15.104-0-lts (pgj@wifibox-dev) (gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, GNU ld (GNU Binutils) 2.39) #1-Alpine Sun, 26 Mar 2023 00:13:40 +0000
[    0.000000] Command line: console=ttyS0 BOOT_IMAGE=(host)/usr/local/share/wifibox/vmlinuz modules=squashfs root=/dev/vda rootfstype=squashfs clocksource=hpet tsc=unstable
[    0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[    0.000000] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[    0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
[    0.000000] signal: max sigframe size: 1360
[    0.000000] BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009ffff] usable
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x0000000007ffffff] usable
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.6 present.
[    0.000000] DMI: FreeBSD BHYVE/BHYVE, BIOS 13.0 11/10/2020
[    0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
[    0.000000] last_pfn = 0x8000 max_arch_pfn = 0x400000000
[    0.000000] Disabled
[    0.000000] x86/PAT: MTRRs disabled, skipping PAT initialization too.
[    0.000000] CPU MTRRs all blank - virtualized system.
[    0.000000] x86/PAT: Configuration [0-7]: WB  WT  UC- UC  WB  WT  UC- UC  
[    0.000000] Using GB pages for direct mapping
[    0.000000] ACPI: Early table checksum verification disabled
[    0.000000] ACPI: RSDP 0x00000000000F2400 000024 (v02 BHYVE )
[    0.000000] ACPI: XSDT 0x00000000000F2470 00004C (v01 BHYVE  BVXSDT   00000001 BASL 20220504)
[    0.000000] ACPI: FACP 0x00000000000F24C0 000114 (v05 BHYVE  BVFACP   00000001 BASL 20220504)
[    0.000000] ACPI: DSDT 0x00000000000F2750 000A5C (v02 BHYVE  BVDSDT   00000001 INTL 20201113)
[    0.000000] ACPI: FACS 0x00000000000F26C0 000040
[    0.000000] ACPI: FACS 0x00000000000F26C0 000040
[    0.000000] ACPI: APIC 0x00000000000F25E0 00005A (v01 BHYVE  BVAPIC   00000001 BASL 20220504)
[    0.000000] ACPI: HPET 0x00000000000F2640 000038 (v01 BHYVE  BVHPET   00000001 BASL 20220504)
[    0.000000] ACPI: MCFG 0x00000000000F2680 00003C (v01 BHYVE  BVMCFG   00000001 BASL 20220504)
[    0.000000] ACPI: SPCR 0x00000000000F2700 000050 (v01 BHYVE  BVSPCR   00000001 BASL 20220504)
[    0.000000] ACPI: Reserving FACP table memory at [mem 0xf24c0-0xf25d3]
[    0.000000] ACPI: Reserving DSDT table memory at [mem 0xf2750-0xf31ab]
[    0.000000] ACPI: Reserving FACS table memory at [mem 0xf26c0-0xf26ff]
[    0.000000] ACPI: Reserving FACS table memory at [mem 0xf26c0-0xf26ff]
[    0.000000] ACPI: Reserving APIC table memory at [mem 0xf25e0-0xf2639]
[    0.000000] ACPI: Reserving HPET table memory at [mem 0xf2640-0xf2677]
[    0.000000] ACPI: Reserving MCFG table memory at [mem 0xf2680-0xf26bb]
[    0.000000] ACPI: Reserving SPCR table memory at [mem 0xf2700-0xf274f]
[    0.000000] system APIC only can use physical flat
[    0.000000] Setting APIC routing to physical flat.
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000001000-0x0000000000ffffff]
[    0.000000]   DMA32    [mem 0x0000000001000000-0x0000000007ffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000001000-0x000000000009ffff]
[    0.000000]   node   0: [mem 0x0000000000100000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000001000-0x0000000007ffffff]
[    0.000000] On node 0, zone DMA: 1 pages in unavailable ranges
[    0.000000] On node 0, zone DMA: 96 pages in unavailable ranges
[    0.000000] ACPI: PM-Timer IO Port: 0x408
[    0.000000] system APIC only can use physical flat
[    0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] high edge lint[0x1])
[    0.000000] IOAPIC[0]: apic_id 0, version 17, address 0xfec00000, GSI 0-31
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 high edge)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 low level)
[    0.000000] ACPI: Using ACPI (MADT) for SMP configuration information
[    0.000000] ACPI: HPET id: 0x80860701 base: 0xfed00000
[    0.000000] ACPI: SPCR: SPCR table version 1
[    0.000000] ACPI: SPCR: console: uart,io,0x3f8,115200
[    0.000000] [mem 0x08000000-0xffffffff] available for PCI devices
[    0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1910969940391419 ns
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32000
[    0.000000] Kernel command line: console=ttyS0 BOOT_IMAGE=(host)/usr/local/share/wifibox/vmlinuz modules=squashfs root=/dev/vda rootfstype=squashfs clocksource=hpet tsc=unstable
[    0.000000] tsc: Marking TSC unstable due to boot parameter
[    0.000000] Unknown kernel command line parameters "BOOT_IMAGE=(host)/usr/local/share/wifibox/vmlinuz modules=squashfs", will be passed to user space.
[    0.000000] Dentry cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 108968K/130684K available (8193K kernel code, 1465K rwdata, 1572K rodata, 724K init, 1768K bss, 21456K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 4352, nr_irqs: 256, preallocated irqs: 16
[    0.000000] Console: colour EGA 80x25
[    0.000000] printk: console [ttyS0] enabled
[    0.000000] ACPI: Core revision 20210730
[    0.000000] clocksource: hpet: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 113919999973 ns
[    0.000000] APIC: Switch to symmetric I/O mode setup
[    0.000000] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
[    0.006000] tsc: PIT calibration matches PMTIMER. 1 loops
[    0.006000] tsc: Detected 2193.205 MHz processor
[    0.000004] Calibrating delay loop (skipped), value calculated using timer frequency.. 4386.41 BogoMIPS (lpj=2193205)
[    0.001003] pid_max: default: 32768 minimum: 301
[    0.001721] LSM: Security Framework initializing
[    0.002021] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.003004] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.005180] unchecked MSR access error: WRMSR to 0x140 (tried to write 0x0000000000000000) at rIP: 0xffffffffa78298f1 (init_intel+0x191/0x390)
[    0.006004] Call Trace:
[    0.006427]  <TASK>
[    0.007004]  ? get_cpu_cap+0xfa/0x1e0
[    0.007569]  identify_cpu+0x254/0x5a0
[    0.008004]  identify_boot_cpu+0xc/0x93
[    0.008596]  check_bugs+0x1d/0xbe8
[    0.009004]  start_kernel+0x4b0/0x4e4
[    0.009568]  secondary_startup_64_no_verify+0xc2/0xcb
[    0.010004]  </TASK>
[    0.011014] Last level iTLB entries: 4KB 1024, 2MB 1024, 4MB 1024
[    0.011940] Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 1024, 1GB 4
[    0.012006] CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz (family: 0x6, model: 0x46, stepping: 0x1)
[    0.013003] Spectre V1 : Mitigation: usercopy/swapgs barriers and __user pointer sanitization
[    0.014004] Spectre V2 : Kernel not compiled with retpoline; no mitigation available!
[    0.014004] Spectre V2 : Vulnerable
[    0.016003] Spectre V2 : Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch
[    0.017003] Speculative Store Bypass: Vulnerable
[    0.018005] MDS: Mitigation: Clear CPU buffers
[    0.018689] MMIO Stale Data: Unknown: No mitigations
[    0.019003] SRBDS: Unknown: Dependent on hypervisor status
[    0.020336] Performance Events: unsupported p6 CPU model 70 no PMU driver, software events only.
[    0.123207] devtmpfs: initialized
[    0.123851] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275000 ns
[    0.124013] futex hash table entries: 256 (order: 0, 6144 bytes, linear)
[    0.125117] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.126071] thermal_sys: Registered thermal governor 'step_wise'
[    0.126072] thermal_sys: Registered thermal governor 'user_space'
[    0.127008] cpuidle: using governor menu
[    0.128617] ACPI FADT declares the system doesn't support PCIe ASPM, so disable it
[    0.129004] ACPI: bus type PCI registered
[    0.130004] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
[    0.131056] PCI: Using configuration type 1 for base access
[    0.132370] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[    0.133202] ACPI: Added _OSI(Module Device)
[    0.134004] ACPI: Added _OSI(Processor Device)
[    0.135004] ACPI: Added _OSI(3.0 _SCP Extensions)
[    0.135725] ACPI: Added _OSI(Processor Aggregator Device)
[    0.136004] ACPI: Added _OSI(Linux-Dell-Video)
[    0.137005] ACPI: Added _OSI(Linux-Lenovo-NV-HDMI-Audio)
[    0.138004] ACPI: Added _OSI(Linux-HPI-Hybrid-Graphics)
[    0.139192] ACPI: 1 ACPI AML tables successfully acquired and loaded
[    0.140316] ACPI: Interpreter enabled
[    0.141007] ACPI: PM: (supports S0 S5)
[    0.141605] ACPI: Using IOAPIC for interrupt routing
[    0.142020] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[    0.143047] ACPI: Enabled 1 GPEs in block 00 to 07
[    0.145571] ACPI: PCI Root Bridge [PC00] (domain 0000 [bus 00])
[    0.146006] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI HPX-Type3]
[    0.147043] PCI host bridge to bus 0000:00
[    0.148004] pci_bus 0000:00: root bus resource [io  0x0000-0x0cf7 window]
[    0.149003] pci_bus 0000:00: root bus resource [io  0x0d00-0x1fff window]
[    0.150003] pci_bus 0000:00: root bus resource [io  0x2000-0x26bf window]
[    0.151004] pci_bus 0000:00: root bus resource [mem 0xc0000000-0xc05fffff window]
[    0.152003] pci_bus 0000:00: root bus resource [mem 0x800000000-0x81fffffff window]
[    0.153003] pci_bus 0000:00: root bus resource [bus 00]
[    0.154106] pci 0000:00:00.0: [1275:1275] type 00 class 0x060000
[    0.156405] pci 0000:00:04.0: [1af4:1001] type 00 class 0x010000
[    0.157166] pci 0000:00:04.0: reg 0x10: [io  0x2600-0x267f]
[    0.158086] pci 0000:00:04.0: reg 0x14: [mem 0xc0438000-0xc0439fff]
[    0.160341] pci 0000:00:04.1: [1af4:1009] type 00 class 0x010000
[    0.161159] pci 0000:00:04.1: reg 0x10: [io  0x2000-0x21ff]
[    0.162087] pci 0000:00:04.1: reg 0x14: [mem 0xc043a000-0xc043bfff]
[    0.164292] pci 0000:00:04.2: [1af4:1009] type 00 class 0x010000
[    0.165160] pci 0000:00:04.2: reg 0x10: [io  0x2200-0x23ff]
[    0.166088] pci 0000:00:04.2: reg 0x14: [mem 0xc043c000-0xc043dfff]
[    0.168255] pci 0000:00:04.3: [1af4:1009] type 00 class 0x010000
[    0.169159] pci 0000:00:04.3: reg 0x10: [io  0x2400-0x25ff]
[    0.170088] pci 0000:00:04.3: reg 0x14: [mem 0xc043e000-0xc043ffff]
[    0.172184] pci 0000:00:05.0: [8086:100f] type 00 class 0x020000
[    0.173161] pci 0000:00:05.0: reg 0x10: [mem 0xc0400000-0xc041ffff]
[    0.174085] pci 0000:00:05.0: reg 0x14: [mem 0xc0420000-0xc042ffff]
[    0.175085] pci 0000:00:05.0: reg 0x18: [io  0x2680-0x2687]
[    0.177042] pci 0000:00:06.0: [14e4:43ba] type 00 class 0x028000
[    0.178314] pci 0000:00:06.0: reg 0x10: [mem 0xc0430000-0xc0437fff 64bit]
[    0.179184] pci 0000:00:06.0: reg 0x18: [mem 0xc0000000-0xc03fffff 64bit]
[    0.182272] pci 0000:00:06.0: supports D1 D2
[    0.182932] pci 0000:00:06.0: PME# supported from D0 D1 D2 D3hot D3cold
[    0.185004] pci 0000:00:1f.0: [8086:7000] type 00 class 0x060100
[    0.186526] pci_bus 0000:00: on NUMA node 0
[    0.186598] ACPI: PCI: Interrupt link LNKA configured for IRQ 5
[    0.187069] ACPI: PCI: Interrupt link LNKB configured for IRQ 6
[    0.188067] ACPI: PCI: Interrupt link LNKC configured for IRQ 7
[    0.189066] ACPI: PCI: Interrupt link LNKD configured for IRQ 10
[    0.190065] ACPI: PCI: Interrupt link LNKE configured for IRQ 11
[    0.191059] ACPI: PCI: Interrupt link LNKF configured for IRQ 0
[    0.192003] ACPI: PCI: Interrupt link LNKF disabled
[    0.193058] ACPI: PCI: Interrupt link LNKG configured for IRQ 0
[    0.194003] ACPI: PCI: Interrupt link LNKG disabled
[    0.194804] ACPI: PCI: Interrupt link LNKH configured for IRQ 0
[    0.195003] ACPI: PCI: Interrupt link LNKH disabled
[    0.196110] vgaarb: loaded
[    0.197018] pps_core: LinuxPPS API ver. 1 registered
[    0.197778] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.198005] PTP clock support registered
[    0.198697] NetLabel: Initializing
[    0.199003] NetLabel:  domain hash size = 128
[    0.200003] NetLabel:  protocols = UNLABELED CIPSOv4 CALIPSO
[    0.200880] NetLabel:  unlabeled traffic allowed by default
[    0.201021] PCI: Using ACPI for IRQ routing
[    0.202004] PCI: pci_cache_line_size set to 64 bytes
[    0.202213] hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0, 0, 0, 0, 0, 0
[    0.203003] hpet0: 8 comparators, 32-bit 16.777216 MHz counter
[    0.207018] clocksource: Switched to clocksource hpet
[    0.207881] pnp: PnP ACPI init
[    0.208600] system 00:02: [io  0x04d0-0x04d1] has been reserved
[    0.209528] system 00:02: [io  0x0400-0x0407] has been reserved
[    0.210451] system 00:02: [mem 0xe0000000-0xefffffff] has been reserved
[    0.211524] pnp: PnP ACPI: found 8 devices
[    0.217234] clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 2085701024 ns
[    0.218619] NET: Registered PF_INET protocol family
[    0.219426] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.220611] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.221888] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.223063] TCP established hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.224255] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.225359] TCP: Hash tables configured (established 1024 bind 1024)
[    0.226368] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.227397] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.228498] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.229534] pci_bus 0000:00: resource 4 [io  0x0000-0x0cf7 window]
[    0.230508] pci_bus 0000:00: resource 5 [io  0x0d00-0x1fff window]
[    0.231470] pci_bus 0000:00: resource 6 [io  0x2000-0x26bf window]
[    0.232438] pci_bus 0000:00: resource 7 [mem 0xc0000000-0xc05fffff window]
[    0.233506] pci_bus 0000:00: resource 8 [mem 0x800000000-0x81fffffff window]
[    0.234737] pci 0000:00:1f.0: Activating ISA DMA hang workarounds
[    0.235705] PCI: CLS 256 bytes, default 64
[    0.236417] RAPL PMU: API unit is 2^-32 Joules, 0 fixed counters, 163840 ms ovfl timer
[    0.237770] Initialise system trusted keyrings
[    0.238718] workingset: timestamp_bits=62 max_order=15 bucket_order=0
[    0.240328] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.241403] 9p: Installing v9fs 9p2000 file system support
[    0.251566] Key type asymmetric registered
[    0.252237] Asymmetric key parser 'x509' registered
[    0.253193] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
[    0.254363] ACPI: button: Power Button [PWRF]
[    0.255516] virtio-pci 0000:00:04.0: virtio_pci: leaving for legacy driver
[    0.256913] virtio-pci 0000:00:04.1: virtio_pci: leaving for legacy driver
[    0.258217] virtio-pci 0000:00:04.2: virtio_pci: leaving for legacy driver
[    0.259544] virtio-pci 0000:00:04.3: virtio_pci: leaving for legacy driver
[    0.260789] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.261939] 00:03: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    0.263249] 00:04: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
[    0.264540] 00:05: ttyS2 at I/O 0x3e8 (irq = 4, base_baud = 115200) is a 16550A
[    0.265849] 00:06: ttyS3 at I/O 0x2e8 (irq = 3, base_baud = 115200) is a 16550A
[    0.267303] Non-volatile memory driver v1.3
[    0.268677] loop: module loaded
[    0.269737] virtio_blk virtio0: [vda] 196624 512-byte logical blocks (101 MB/96.0 MiB)
[    0.271523] e1000: Intel(R) PRO/1000 Network Driver
[    0.272304] e1000: Copyright (c) 1999-2006 Intel Corporation.
[    0.643357] e1000 0000:00:05.0 eth0: (PCI:33MHz:32-bit) 00:a0:98:8a:05:71
[    0.644530] e1000 0000:00:05.0 eth0: Intel(R) PRO/1000 Network Connection
[    0.645795] i8042: PNP: PS/2 Controller [PNP0303:KBD,PNP0f13:MOU] at 0x60,0x64 irq 1,12
[    0.647467] i8042: Warning: Keylock active
[    0.648928] serio: i8042 KBD port at 0x60,0x64 irq 1
[    0.649800] serio: i8042 AUX port at 0x60,0x64 irq 12
[    0.651469] rtc_cmos 00:07: registered as rtc0
[    0.652304] rtc_cmos 00:07: alarms up to one day, y3k, 114 bytes nvram
[    0.653752] Initializing XFRM netlink socket
[    0.654542] NET: Registered PF_INET6 protocol family
[    0.655600] Segment Routing with IPv6
[    0.656224] In-situ OAM (IOAM) with IPv6
[    0.656866] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    0.657928] NET: Registered PF_PACKET protocol family
[    0.658726] 9pnet: Installing 9P2000 support
[    0.661013] registered taskstats version 1
[    0.661655] Loading compiled-in X.509 certificates
[    0.662514] printk: console [netcon0] enabled
[    0.663206] netconsole: network logging started
[    0.663900] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    0.665322] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    0.666376] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    0.668068] cfg80211: failed to load regulatory.db
[    0.669375] VFS: Mounted root (squashfs filesystem) readonly on device 254:0.
[    0.670887] devtmpfs: mounted
[    0.671580] Freeing unused kernel image (initmem) memory: 724K
[    0.672530] Write protecting the kernel read-only data: 12288k
[    0.674299] Freeing unused kernel image (text/rodata gap) memory: 2044K
[    0.675397] Freeing unused kernel image (rodata/data gap) memory: 476K
[    0.676415] Run /sbin/init as init process
[    0.677034]   with arguments:
[    0.677034]     /sbin/init
[    0.677035]   with environment:
[    0.677035]     HOME=/
[    0.677035]     TERM=linux
[    0.677036]     BOOT_IMAGE=(host)/usr/local/share/wifibox/vmlinuz
[    0.677037]     modules=squashfs

/var/run/wifibox/appliance/log/messages

Sep 17 04:53:39 wifibox syslog.info syslogd started: BusyBox v1.35.0
Sep 17 04:53:39 wifibox daemon.err /etc/init.d/wpa_supplicant[769]: Could not find a wireless interface
Sep 17 04:53:39 wifibox daemon.info supervise-daemon[772]: Supervisor command line: supervise-daemon wpa_supplicant --start --respawn-delay 2 --respawn-max 5 --respawn-period 1800 /sbin/wpa_supplicant -- -c/etc/wpa_supplicant/wpa_supplicant.conf 
Sep 17 04:53:39 wifibox daemon.info supervise-daemon[776]: Child command line: /sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf 
Sep 17 04:53:39 wifibox daemon.warn supervise-daemon[773]: /sbin/wpa_supplicant, pid 776, exited with return code 255
Sep 17 04:53:39 wifibox daemon.info supervise-daemon[927]: Supervisor command line: supervise-daemon uds_passthru --start --respawn-delay 2 --respawn-max 5 --respawn-period 1800 /sbin/uds_passthru -- 
Sep 17 04:53:39 wifibox daemon.info supervise-daemon[931]: Child command line: /sbin/uds_passthru 
Sep 17 04:53:39 wifibox daemon.info : starting pid 934, tty '': '/sbin/openrc default'
Sep 17 04:53:39 wifibox daemon.debug uds_passthru[931]: Configuration: network=10.0.0.1:255.255.255.0, sockets=[path=/var/run/wpa_supplicant/wlan0,user=root,group=0,mode=770,port=1200 path=/var/run/wpa_supplicant/p2p-dev-wlan0,user=root,group=0,mode=770,port=1201]
Sep 17 04:53:39 wifibox daemon.warn uds_passthru[931]: /var/run/wpa_supplicant/wlan0 is not available, skipping.
Sep 17 04:53:39 wifibox daemon.warn uds_passthru[931]: /var/run/wpa_supplicant/p2p-dev-wlan0 is not available, skipping.
Sep 17 04:53:39 wifibox daemon.info uds_passthru[931]: Waiting for PID 941 to stop.
Sep 17 04:53:39 wifibox cron.info crond[988]: crond (busybox 1.35.0) started, log level 8
Sep 17 04:53:39 wifibox daemon.info udhcpd[1041]: started, v1.35.0
Sep 17 04:53:39 wifibox daemon.err udhcpd[1041]: can't open '/var/lib/misc/udhcpd.leases': No such file or directory
Sep 17 04:53:39 wifibox daemon.info : starting pid 1048, tty '/dev/ttyS0': '/sbin/getty -L ttyS0 115200 vt100'
Sep 17 04:53:41 wifibox daemon.info supervise-daemon[1049]: Child command line: /sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf 
Sep 17 04:53:41 wifibox daemon.warn supervise-daemon[773]: /sbin/wpa_supplicant, pid 1049, exited with return code 255
Sep 17 04:53:43 wifibox daemon.info supervise-daemon[1051]: Child command line: /sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf 
Sep 17 04:53:43 wifibox daemon.warn supervise-daemon[773]: /sbin/wpa_supplicant, pid 1051, exited with return code 255
Sep 17 04:53:45 wifibox daemon.info supervise-daemon[1053]: Child command line: /sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf 
Sep 17 04:53:45 wifibox daemon.warn supervise-daemon[773]: /sbin/wpa_supplicant, pid 1053, exited with return code 255
Sep 17 04:53:47 wifibox daemon.info supervise-daemon[1054]: Child command line: /sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf 
Sep 17 04:53:47 wifibox daemon.warn supervise-daemon[773]: /sbin/wpa_supplicant, pid 1054, exited with return code 255
Sep 17 04:53:49 wifibox daemon.info supervise-daemon[1056]: Child command line: /sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf 
Sep 17 04:53:49 wifibox daemon.warn supervise-daemon[773]: /sbin/wpa_supplicant, pid 1056, exited with return code 255
Sep 17 04:53:49 wifibox daemon.warn supervise-daemon[773]: respawned "/sbin/wpa_supplicant" too many times, exiting
Sep 17 05:00:00 wifibox cron.info crond[988]: USER root pid 1064 cmd run-parts /etc/periodic/15min
Sep 17 05:00:00 wifibox cron.info crond[988]: USER root pid 1065 cmd run-parts /etc/periodic/hourly

Additional context

wifibox, wifibox-core, and wifibox-alpine were all installed via pkg. I also tried versions compiled from ports, and tried configuring the port to include all the firmware files, but continued to run into the same issues.

Have you tried to turn it on and off?

pgj commented 1 year ago

Thanks for the report! Apparently the logs are from the 20230326 version of wifibox-alpine. Broadcom cards are not yet properly supported in that version, please try a development branch on GitHub, the pgj/freebsd-wifibox-port repository. There you shall find version 20230916 (or later if I will get to update it to a more recent version in the meantime) which was tested to be working with BCM4331. There are known issues still with instability, though your mileage may vary.

suchipi commented 1 year ago

Thanks!! After deinstalling the old version and installing the version from GitHub, now I see this in the dmesg output, which is promising (but still not-yet-functional):

[    0.649848] Run /sbin/init as init process
[    0.650217]   with arguments:
[    0.650218]     /sbin/init
[    0.650218]   with environment:
[    0.650219]     HOME=/
[    0.650219]     TERM=linux
[    0.650219]     BOOT_IMAGE=(host)/usr/local/share/wifibox/vmlinuz
[    0.650220]     modules=squashfs
[    0.922822] brcmfmac 0000:00:06.0: can't derive routing for PCI INT A
[    0.922825] brcmfmac 0000:00:06.0: PCI INT A: not connected
[    1.041131] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43602-pcie for chip BCM43602/1
[    1.042481] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.FreeBSD-BHYVE.bin failed with error -2
[    1.091154] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.txt failed with error -2
[    1.091168] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.clm_blob failed with error -2
[    1.554564] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[    1.555157] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[    1.617278] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available
[    1.617947] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43602/1 wl0: Nov 10 2015 06:38:10 version 7.35.177.61 (r598657) FWID 01-ea662a8c
[    1.731106] random: crng init done

It seems like the relevant firmware files for my NIC aren't present in the image; is that correct? Where would I get them from and/or how would I add them?

pgj commented 1 year ago

Wow, I have not seen such messages before... You will have modify the Makefile for the net/wifibox-alpine port to download the requires files (as distfiles) and copy them to the guest image before it gets "squashed". An example of that is how the linux-firmware files are added.

But if you can help with finding the missing firmware files, I can make the changes.

pgj commented 1 year ago

For what it is worth, the firmware files are part of the standard linux-firmware distribution. If you choose the FW_BRCM option, they should be added to the image. Though it seems an extra symlink for brcmfmac43602-pcie.FreeBSD-BHYVE.bin needs to be added because it seems to be hardware-specific and not part of the linux-firmware package.

suchipi commented 1 year ago

Thanks! I'll try that. What should the symlink target be?

pgj commented 1 year ago

Based on the log messages, it is brcm/brcmfmac43602-pcie.FreeBSD-BHYVE.bin what the driver is looking for, while the linux-firmware package contains only brcm/brcmfmac43602-pcie.ap.bin and brcm/brcmfmac43602-pcie.bin. Hence a symbolic link with the name brcm/brcmfmac43602-pcie.FreeBSD-BHYVE.bin is needed (under /lib/firmware) that points to either brcmfmac43602-pcie.ap.bin or brcmfmac43602-pcie.bin.

This can be done in the Makefile of net/wifibox-alpine, somewhere in the pre-build step.

suchipi commented 1 year ago

Gotcha, thanks for the explanation! I'll give it a shot

suchipi commented 1 year ago

I was able to get it working!

I had to:

Unfortunately, I think that .txt file can't legally be distributed, so this fix can't be merged into wifibox mainline (unless you don't care). Though even if you didn't are about the legality, you'd have to do something special to get the correct mac address to put in the txt file... which is a lot of work for this one specific card that's only used in certain MacBooks.

What's curious is that that ubuntu live usb environment didn't have the .txt file present, but was nonetheless able to browse the web. Maybe NetworkManager does something interesting...

I did run into some issues with system stability as you indicated (for example, the entire system freezes when attempting wifibox restart), but it does "work" well enough.

Thanks for all your help!

pgj commented 1 year ago

That is great to hear! I think I can integrate the changes you have made. Here is the plan:

That said, do you mind if I reopen this ticket and add the support properly?

suchipi commented 1 year ago

Not at all, that sounds awesome. Thank you!

huanghwh commented 11 months ago

I have the same hardware, directly pkg install wifibox, almost works, except I need to run this command in wifibox:

dhcpcd wlan0

dmesg show firmware is already load:

[ 0.879989] brcmfmac 0000:00:06.0: can't derive routing for PCI INT A [ 0.879995] brcmfmac 0000:00:06.0: PCI INT A: no GSI [ 0.995382] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43602-pcie for chip BCM43602/1 [ 0.996404] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.FreeBSD-BHYVE.bin failed with error -2 [ 1.035498] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.txt failed with error -2 [ 1.035511] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.clm_blob failed with error -2 [ 1.145346] NET: Registered PF_INET6 protocol family [ 1.145491] Segment Routing with IPv6 [ 1.145497] In-situ OAM (IOAM) with IPv6 [ 1.500985] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None [ 1.501488] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready [ 1.532427] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available [ 1.533162] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43602/1 wl0: Nov 10 2015 06:38:10 version 7.35.177.61 (r598657) FWID 01-ea662a8c [ 1.662097] random: crng init done [ 38.619268] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready

pgj commented 11 months ago

Hi @huanghwh: Yes, it is a known issue and there is no fix created for it yet. Please consult https://github.com/pgj/freebsd-wifibox/issues/65#issuecomment-1734695999 above for the workaround.

pgj commented 9 months ago

@suchipi, @huanghwh please note that I have updated the net/wifibox-alpine port to version 20240106 where the necessary symlinks are getting created during the build. You can find it here:

https://github.com/pgj/freebsd-wifibox-port/tree/c2a1abd8dcacd218d325fb545da30c1de98cdcc5

Based on what was discussed in the comments so far, I am not sure if this by itself will fix the issue. But I would be curious to see if this is enough or the .txt file is also needed. I tried to understand the issue better and I have read recommendations where the contents of the .txt did not seem to be relevant hence it might not even be mandatory to have.

@suchipi could you please help me with testing this out? I would need feedback about the following cases:

Also, @suchipi could you please send me the parts of the dmesg output from the Ubuntu Live system where the wireless card is properly detected and configured? It would be interesting to see what firmware files it tries to load.

MegaManSec commented 3 months ago

@pgj I'm willing to pick up the testing.

First thing's first: the patch does not work because it creates a link brcmfmac43602-pcie.bin.FreeBSD-BHYVE.bin@ -> brcmfmac43602-pcie.bin whereas it should be creating a link from brcmfmac43602-pcie.FreeBSD-BHYVE.bin (note the lack of .bin after -pcie)

I have submitted https://github.com/pgj/freebsd-wifibox-port/pull/36 to fix that.

MegaManSec commented 3 months ago

As for further testing...

A non-existent txt file produces:

[    1.049479] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43602-pcie for chip BCM43602/1
[    1.095253] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.txt failed with error -2
[    1.095270] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.clm_blob failed with error -2
[    1.095283] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.txcap_blob failed with error -2

An empty txt file produces(notice it's -22 not -2):

[    1.049479] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43602-pcie for chip BCM43602/1
[    1.095253] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.txt failed with error -22
[    1.095270] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.clm_blob failed with error -2
[    1.095283] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.txcap_blob failed with error -2

At the moment (using FreeBSD-13.3), wifibox does not work at all because wpa_supplicant refuses to start. wifibox attempts to start wpa_supplicant by calling /sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant, but this just returns 0 with the help page:

wifibox:~# wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant
Successfully initialized wpa_supplicant
wpa_supplicant v2.10
Copyright (c) 2003-2022, Jouni Malinen <j@w1.fi> and contributors

This software may be distributed under the terms of the BSD license.
See README for more details.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/)

usage:
  wpa_supplicant [-BddhKLqqtvW] [-P<pid file>] [-g<global ctrl>] \
        [-G<group>] \
        -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
        [-b<br_ifname>] [-e<entropy file>] \
        [-o<override driver>] [-O<override ctrl>] \
        [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
        [-m<P2P Device config file>] \
        [-p<driver_param>] [-b<br_ifname>] [-I<config file>] ...]

drivers:
  nl80211 = Linux nl80211/cfg80211
options:
  -b = optional bridge interface name
  -B = run daemon in the background
  -c = Configuration file
  -C = ctrl_interface parameter (only used if -c is not)
  -d = increase debugging verbosity (-dd even more)
  -D = driver name (can be multiple drivers: nl80211,wext)
  -e = entropy file
  -g = global ctrl_interface
  -G = global ctrl_interface group
  -h = show this help text
  -i = interface name
  -I = additional configuration file
  -K = include keys (passwords, etc.) in debug output
  -L = show license (BSD)
  -m = Configuration file for the P2P Device interface
  -N = start describing new interface
  -o = override driver parameter for new interfaces
  -O = override ctrl_interface parameter for new interfaces
  -p = driver parameters
  -P = PID file
  -q = decrease debugging verbosity (-qq even less)
  -t = include timestamp in debug messages
  -v = show version
  -W = wait for a control interface monitor before starting
example:
  wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf
wifibox:~#

Instead, I have to force wpa_supplicant to pass the argument -iwlan0 (by overwriting /etc/conf.d/wpa_supplicant). From here:

 * Enabling forwarding ... [ ok ]
 * /var/run/wpa_supplicant: creating directory
 * Starting WPA Supplicant ... [ ok ]
 * Starting networking ... *   lo ... [ ok ]
 *   eth0 ... [ ok ]
 *   wlan0 ...ip: SIOCGIFFLAGS: No such device
dhcpcd-10.0.6 starting
wlan0: interface not found
ifup: failed to change interface wlan0 state to 'up'
 [ !! ]
 * /run/radvd: creating directory
 * /run/radvd: correcting owner

indicates some race condition, and I manually have to do the dhcp, and then it works:

wifibox:~# dhcpcd -n wlan0
dhcpcd-10.0.6 starting
wlan0: connected to Access Point: [snip]
DUID [snip]
wlan0: IAID [snip]
wlan0: soliciting an IPv6 router
wlan0: soliciting a DHCP lease
wlan0: offered 192.168.1.124 from 192.168.1.1
wlan0: probing address 192.168.1.124/24
wlan0: leased 192.168.1.124 for 86400 seconds
wlan0: adding route to 192.168.1.0/24
wlan0: adding default route via 192.168.1.1
 * WARNING: you are stopping a boot service
 * Stopping IPv6 Router Advertisement Daemon ... [ ok ]
 * Starting IPv6 Router Advertisement Daemon ... [ ok ]
 * Stopping busybox udhcpd ... [ ok ]
 * Starting busybox udhcpd ... [ ok ]
wifibox:~# ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: seq=0 ttl=53 time=21.021 ms
64 bytes from 1.1.1.1: seq=1 ttl=53 time=10.791 ms

Without the txt file, the dhcp connection cannot be completed:

wifibox:~# dhcpcd -n wlan0
dhcpcd-10.0.6 starting
DUID [snip]
 * WARNING: you are stopping a boot service
 * Stopping IPv6 Router Advertisement Daemon ... [ ok ]
 * Starting IPv6 Router Advertisement Daemon ... [ ok ]
 * Stopping busybox udhcpd ... [ ok ]
 * Starting busybox udhcpd ... [ ok ]
wlan0: waiting for carrier

but it can scan for SSIDs, for example:

wifibox:~# iw wlan0 scan | grep SSID
    SSID: [snip]
    SSID: [snip]
    SSID: [snip]
    SSID: [snip]

The txt file does not need to contain the mac address, and works fine without it.

pgj commented 3 months ago

Thanks @MegaManSec for testing the different variations and submitting the fix for a mistake I made earlier. How did you add the .txt file to the guest image?

Wifibox launches WPA Supplicant on boot through the wpa_supplicant OpenRC init script which is installed at /etc/init.d/wpa_supplicant. This script has its own logic (find_wireless and append_wireless) to locate and inject the interface name for the wireless device automatically.

The interface can go missing only if the logic above fails to work. That is when both /sys/class/net/wlan0/wireless and /sys/class/net/wlan0/phy80211 are missing. The script should wait until the kernel modules are loaded, that is, the wlan0 device becomes available.

You can always restart the networking service or wpa_supplicant separately on the wifibox console, if they do not work right after boot:

wifibox# service networking restart

or

wifibox# service wpa_supplicant restart

Of course, that is just a temporary workaround for the problem. Though I am curious if this can fix the problem without touching the configuration files of the service or launching the binaries individually. Once this is clarified, we could move on to understanding why the wlan0 device is not created by the time when wpa_supplicant wants to use it.

MegaManSec commented 3 months ago

How did you add the .txt file to the guest image?

The same as the suchipi:

+.if ${PORT_OPTIONS:MFW_BRCM}
+       ${CP} /var/tmp/test \
+               ${_FIRMWAREDIR}/brcm/brcmfmac43602-pcie.txt ; \
+.endif

in pre-build.

You can always restart the networking service or wpa_supplicant separately on the wifibox console, if they do not work right after boot:

This does not work, either:

$ sudo wifibox console
Connecting, type "~." to leave the session...
Connected
root
wifibox:~# service networking restart
 * WARNING: you are stopping a boot service
 * WARNING: you are stopping a boot service
 * Stopping Unix Domain Socket pass-through ...
 [ ok ]
 * Stopping busybox udhcpd ...
 [ ok ]
 * WARNING: you are stopping a boot service
 * Stopping IPv6 Router Advertisement Daemon ...
 [ ok ]
 * Stopping networking ...
 *   lo ...
 [ ok ]
 *   eth0 ...
 [ ok ]
 * Starting networking ...
 *   lo ...
 [ ok ]
 *   eth0 ...
 [ ok ]
 *   wlan0 ...
dhcpcd-10.0.6 starting
wlan0: waiting for carrier
^Creceived SIGINT, stopping
 * networking: caught SIGINT, aborting
wifibox:~# wlan0: removing interface
dhcpcd exited

Restarting wpa_supplicant and then manually starting dhcp does, though.

$ sudo wifibox console
Connecting, type "~." to leave the session...
Connected
root
wifibox:~# service wpa_supplicant restart
 * Starting WPA Supplicant ...
 [ ok ]
wifibox:~# ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
ping: sendto: Network unreachable
wifibox:~# dhcpcd -n wlan0
dhcpcd-10.0.6 starting
wlan0: connected to Access Point: [snip]
DUID [snip]
wlan0: IAID [snip]
wlan0: soliciting an IPv6 router
wlan0: soliciting a DHCP lease
wlan0: offered 192.168.1.123 from 192.168.1.1
wlan0: probing address 192.168.1.123/24
wlan0: leased 192.168.1.123 for 86400 seconds
wlan0: adding route to 192.168.1.0/24
wlan0: adding default route via 192.168.1.1
 * WARNING: you are stopping a boot service
 * Stopping IPv6 Router Advertisement Daemon ... [ ok ]
 * Starting IPv6 Router Advertisement Daemon ... [ ok ]
 * Stopping busybox udhcpd ... [ ok ]
 * Starting busybox udhcpd ... [ ok ]
wifibox:~# ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: seq=0 ttl=53 time=12.188 ms

Restarting wpa_supplicant and then restarting networking also works.

wlan0 is being created (of course) at some stage, just apparently too late for wpa_supplicant:

$ sudo service wifibox onerestart
Stopping wifibox....WARNING: PPT device pci3:0:0 could not be destroyed.
...OK
Starting wifibox.......OK
$ sudo wifibox console
Connecting, type "~." to leave the session...
Connected
root
wifibox:~# ls /sys/class/net/
eth0   lo     wlan0
wifibox:~# iface="/sys/class/net/wlan0"; test -e "$iface"/wireless -o -e "$iface
"/phy80211 && echo "${iface##*/}"
wlan0
wifibox:~# 

This is the full output from /var/log/messages when starting it, fyi: https://gist.github.com/MegaManSec/563c6543cbdc137349d9934758f3d0d8

MegaManSec commented 3 months ago

And this is the output of the console when attached immediately after starting wifibox: https://gist.github.com/MegaManSec/dcfc101483bc2ba9a3189e39badb68e8

pgj commented 3 months ago

On the wifibox console, you can use dmesg to get all the messages from the kernel during the boot process.

pgj commented 3 months ago

What port options did you configure?

MegaManSec commented 3 months ago

dmesg: https://gist.github.com/MegaManSec/490462fbdf22beb6207d7a4658d42933

Only the brcm option is chosen from the list of drivers, and the newest kernel option is chosen. Tomorrow I'll send a full screenshot.

pgj commented 3 months ago

Right after boot, can you use the ifconfig wlan0 up command on the wifibox console to create the missing wlan0 interface?

MegaManSec commented 3 months ago

Yes, that creates the missing interface. Attached are the options when building.

wifibox:~# ifconfig wlan0 up
wifibox:~# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr [sino]
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Screenshot-2024-06-19:11:53:31 Screenshot-2024-06-19:11:53:50

MegaManSec commented 3 months ago

I've just tried with all sorts of different configurations, and nothing seems to bring up the interface: either kenel versions, hostapd, or ipv6 disabled.

pgj commented 3 months ago

@MegaManSec please try version 20240629 of the net/wifibox-alpine port from the following branch:

https://github.com/pgj/freebsd-wifibox-port/tree/brcm43602

There you can find two changes:

MegaManSec commented 3 months ago

bc is not installed in alpine:

 * Starting busybox syslog ... [ ok ]
 * No wireless interfaces are available (try: 1)
/lib/rc/sh/openrc-run.sh: line 35: bc: not found
 * No wireless interfaces are available (try: 2)
 * ...

btw, where does this updated /etc/init.d/wpa_supplicant get pulled from? it's not obvious to me

pgj commented 3 months ago

Aw, thanks! Yes, bc is not available at the moment, because the busybox package was stripped down. I have updated busybox to serve this binary as well as the related, missing functionality. Please check the brcm43602 branch again.

The updated version of /etc/init.d/wpa_supplicant is part of the wpa_supplicant package. I updated this package to contain the required changes. You can see in the changes that the version and the checksum of the respective apk has changed. In case you are curious, I published those package changes in https://github.com/pgj/freebsd-wifibox-alpine/pull/25 .

MegaManSec commented 3 months ago

Success:

...
 * Starting busybox syslog ... [ ok ]
 * No wireless interfaces are available (try: 1)
 * No wireless interfaces are available (try: 2)
 * /var/run/wpa_supplicant: creating directory
 * Starting WPA Supplicant ... [ ok ]
 * Starting networking ... *   lo ... [ ok ]
 *   eth0 ... [ ok ]
 *   wlan0 ...udhcpc: started, v1.36.1
...

However, I can't explain why, but it actually now works without the .txt file at all:

wifibox:/lib/firmware/brcm# dmesg |grep \.txt ; ping -c 4 1.1.1.1
[    1.064226] brcmfmac 0000:00:06.0: Direct firmware load for brcm/brcmfmac43602-pcie.txt failed with error -2
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: seq=0 ttl=53 time=13.491 ms
64 bytes from 1.1.1.1: seq=1 ttl=53 time=14.517 ms
64 bytes from 1.1.1.1: seq=2 ttl=53 time=11.325 ms
64 bytes from 1.1.1.1: seq=3 ttl=53 time=18.535 ms

--- 1.1.1.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 11.325/14.467/18.535 ms

The aforementioned Without the txt file, the dhcp connection cannot be completed: cannot even now be called:

wifibox:~# dhcpcd
-ash: dhcpcd: not found

Did dhcpcd just get changed to udhcpc? If so, it seems to have fixed the requirement for the .txt file completely.

pgj commented 3 months ago

That is awesome! Thanks for testing the changes.

I think the reason why the brcmfmac driver works without the .txt file is because it contains certain firmware configuration parameters only. Tweaking these parameters could fix issues with the signal strength and accessing 5 GHz networks, which might not be necessary. For what it is worth, the Debian MBP installation guide says "The installer will complain that it cannot find a file called brcm/brcmfmac43602-pcie.txt. This is related to the WiFi adapter firmware. In fact the firmware (brcmfmac43602-pcie.bin) gets loaded, and you can ignore this message, choosing "No" (i.e. do not load brcmfmac43602-pcie.txt from an external media). The WiFi adapter will work anyway".

The presence of dhcpcd depends on the IPv6 support. The udhcpc utility (that is, BusyBox) is known to have issues with handling IPv6, so the port replaces it with dhcpcd to mitigate that. I decided to not to do this unconditionally (for IPv4 too) because otherwise udhcpc works nicely and it has a low footprint.

MegaManSec commented 3 months ago

Right; when built with ipv6, even dhcpcd works fine now without the txt file, too. I'm not sure why it wasn't working in https://github.com/pgj/freebsd-wifibox/issues/65#issuecomment-2171926393 without the txt file.

So I suppose the BRCM_FWCONF_FILES option can be removed, and then everything is in working order.

pgj commented 2 months ago

@MegaManSec I decided to keep BRCM_FWCONF_FILES as an optional way to supply configuration parameters for the brcm driver.