freebsd / crochet

Build FreeBSD images for RaspberryPi, BeagleBone, PandaBoard, and others.
BSD 2-Clause "Simplified" License
609 stars 187 forks source link

How to start FreeBSD on Orange PC ? #211

Open eleutherius opened 6 years ago

eleutherius commented 6 years ago

Hello gues, I have problem with starting FreeBSD Current on ORANGE PI PC I tried to make an image for OrangePi-Plus2E, but it did not work.

U-Boot 2017.01-rc3 (Aug 12 2017 - 22:48:07 +0000) Allwinner Technology
arm-none-eabi-gcc (FreeBSD Ports Collection for armnoneeabi) 6.3.0
GNU ld (GNU Binutils) 2.28
=> boot
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found FreeBSD U-Boot Loader (bin)
reading ubldr.bin
239144 bytes read in 35 ms (6.5 MiB/s)
## Starting application at 0x42000000 ...
Consoles: U-Boot console
Compatible U-Boot API signature found @0x7bf3f6b8

FreeBSD/armv6 U-Boot loader, Revision 1.2
(Mon Sep 11 16:20:55 EEST 2017 alex@FreeBSD)

DRAM: 1024MB
Card did not respond to voltage select!
MMC Device 2 not found
MMC Device 3 not found
Number of U-Boot devices: 1
U-Boot env: loaderdev not set, will probe all devices.
Found U-Boot device: disk
  Probing all disk devices...
  Checking unit=0 slice=<auto> partition=<auto>... good.
Booting from disk0s2a:
/boot/kernel/kernel text=0x74ff3c data=0x71110+0x1d9fb0 syms=[0x4+0x8df30+0x4+0xcc36b]

Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...
No valid device tree blob found!

I tried to choose dtb but it did not lead to success.

loader> ls /boot/dtb/
/boot/dtb/
    nanopi-neo.dtb
    orangepi-plus-2e.dtb
    sinovoip-bpi-m3.dtb
    sun4i-a10-cubieboard.dtb
    sun4i-a10-olinuxino-lime.dtb
    sun6i-a31s-sinovoip-bpi-m2.dtb
    sun5i-a13-olinuxino.dtb
    sun5i-r8-chip.dtb
    sun7i-a20-bananapi.dtb
    sun7i-a20-cubieboard2.dtb
    sun7i-a20-olimex-som-evb.dtb
    sun7i-a20-pcduino3.dtb
    sun8i-h2-plus-orangepi-zero.dtb
    sun8i-h3-nanopi-m1.dtb
    ufw.dtb
    sun8i-h3-orangepi-one.dtb
    cubieboard.dtb
    olinuxino-lime.dtb
    bananapim2.dtb
    bananapi.dtb
    cubieboard2.dtb
    olimex-a20-som-evb.dtb
    pcduino3.dtb
    sun8i-h3-nanopi-neo.dtb
    am335x-bone.dtb
    am335x-boneblack.dtb
    am335x-bonegreen.dtb
    beaglebone.dtb
    beaglebone-black.dtb
    tegra124-jetson-tk1-fbsd.dtb
    omap4-duovero-parlor.dtb
    pandaboard.dtb
    rpi.dtb
    pandaboard-es.dtb
    rpi2.dtb
    bcm2835-rpi-b.dtb
    bcm2835-rpi-b-rev2.dtb
    bcm2835-rpi-b-plus.dtb
    bcm2835-rpi-zero.dtb
    bcm2836-rpi-2-b.dtb
loader> load /boot/kernel/kernel
loader> load -t dtb /boot/dtb/sun8i-h3-orangepi-one.dtb
/boot/dtb/sun8i-h3-orangepi-one.dtb size=0x6040
loader> autoboot
Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...
Using DTB from loaded file '/boot/dtb/sun8i-h3-orangepi-one.dtb'.
Kernel entry at 0x42200180...
Kernel args: (null)
KDB: debugger backends: ddb
KDB: current backend: ddb
Copyright (c) 1992-2017 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 12.0-CURRENT #0 r323431: Mon Sep 11 16:20:48 EEST 2017
    alex@FreeBSD:/usr/home/alex/crochet-master/work/obj/arm.armv6/usr/src/sys/GENERIC arm
FreeBSD clang version 5.0.0 (tags/RELEASE_500/final 312559) (based on LLVM 5.0.0svn)
WARNING: WITNESS option enabled, expect reduced performance.
VT: init without driver.
CPU: ARM Cortex-A7 r0p5 (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 4-way data cache WB Read-Alloc Write-Alloc
 32KB/32B 2-way instruction cache Read-Alloc
Cache level 2:
 512KB/64B 8-way unified cache WB Read-Alloc Write-Alloc
real memory  = 1073741824 (1024 MB)
avail memory = 1033150464 (985 MB)
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
arc4random: no preloaded entropy cache
random: entropy device external interface
kbd0 at kbdmux0
ofwbus0: <Open Firmware Device Tree>
aw_ccu0: <Allwinner Clock Control Unit> on ofwbus0
clk_fixed0: <Fixed clock> on aw_ccu0
clk_fixed1: <Fixed clock> on aw_ccu0
clk_fixed2: <Fixed clock> on aw_ccu0
simplebus0: <Flattened device tree simple bus> on ofwbus0
aw_ccung0: <Allwinner Clock Control Unit NG> mem 0x1c20000-0x1c203ff on simplebus0
regfix0: <Fixed Regulator> on ofwbus0
regfix1: <Fixed Regulator> on ofwbus0
regfix2: <Fixed Regulator> on ofwbus0
regfix3: <Fixed Regulator> on ofwbus0
awusbphy0: <Allwinner USB PHY> mem 0x1c19400-0x1c1942b,0x1c1a800-0x1c1a803,0x1c1b800-0x1c1b803,0x1c1c800-0x1c1c1d800-0x1c1d803 on simplebus0
gic0: <ARM Generic Interrupt Controller> mem 0x1c81000-0x1c81fff,0x1c82000-0x1c83fff,0x1c84000-0x1c85fff,0x1c1c87fff irq 33 on simplebus0
gic0: pn 0x1, arch 0x2, rev 0x1, implementer 0x43b irqs 160
gpio0: <Allwinner GPIO/Pinmux controller> mem 0x1c20800-0x1c20bff irq 17,18 on simplebus0
gpiobus0: <OFW GPIO bus> on gpio0
gpio1: <Allwinner GPIO/Pinmux controller> mem 0x1f02c00-0x1f02fff irq 37 on simplebus0
gpiobus1: <OFW GPIO bus> on gpio1
panic: mtx_lock_spin: recursed on non-recursive mutex a10 gpio @ /usr/src/sys/arm/allwinner/a10_gpio.c:513

cpuid = 0
time = 1
KDB: stack backtrace:
db_trace_self() at db_trace_self
         pc = 0xc0532f3c  lr = 0xc005ecb4 (db_trace_self_wrapper+0x30)
         sp = 0xc0c13b90  fp = 0xc0c13ca8
db_trace_self_wrapper() at db_trace_self_wrapper+0x30
         pc = 0xc005ecb4  lr = 0xc025fc4c (vpanic+0x158)
         sp = 0xc0c13cb0  fp = 0xc0c13cd0
         r4 = 0x00000100  r5 = 0x00000001
         r6 = 0xc0659141  r7 = 0xc08cb408
vpanic() at vpanic+0x158
         pc = 0xc025fc4c  lr = 0xc025faf4 (vpanic)
         sp = 0xc0c13cd8  fp = 0xc0c13cec
         r4 = 0xc0659141  r5 = 0xc0c13cf4
         r6 = 0x00000000  r7 = 0xc429b598
         r8 = 0x00000201  r9 = 0xc0697b51
        r10 = 0xc429b588
vpanic() at vpanic
         pc = 0xc025faf4  lr = 0xc024652c (__mtx_lock_spin_flags+0x1a4)
         sp = 0xc0c13cf4  fp = 0xc0c13d28
         r4 = 0xc0c13cec  r5 = 0xc025faf4
         r6 = 0xc0c13cf4  r7 = 0x00000000
         r8 = 0x00000002  r9 = 0x00000000
        r10 = 0xc429b588
__mtx_lock_spin_flags() at __mtx_lock_spin_flags+0x1a4
         pc = 0xc024652c  lr = 0xc056816c (a10_gpio_pin_configure+0xd4)
         sp = 0xc0c13d30  fp = 0xc0c13d50
         r4 = 0xc429b580  r5 = 0x00000002
         r6 = 0x00000000  r7 = 0xc429b598
         r8 = 0xc429b598  r9 = 0xc429b580
        r10 = 0x00000002
a10_gpio_pin_configure() at a10_gpio_pin_configure+0xd4
         pc = 0xc056816c  lr = 0xc0567508 (a10_gpio_pin_setflags+0x60)
         sp = 0xc0c13d58  fp = 0xc0c13d70
         r4 = 0x00000002  r5 = 0x00000002
         r6 = 0xc429b580  r7 = 0xc429b598
         r8 = 0xc0697b51  r9 = 0x00000002
        r10 = 0x00000000
a10_gpio_pin_setflags() at a10_gpio_pin_setflags+0x60
         pc = 0xc0567508  lr = 0xc0078844 (regnode_fixed_init+0x138)
         sp = 0xc0c13d78  fp = 0xc0c13d98
         r4 = 0xc412e800  r5 = 0xc40a6ee0
         r6 = 0x00000002  r7 = 0x00000000
         r8 = 0xc4130200 r10 = 0x00000000
regnode_fixed_init() at regnode_fixed_init+0x138
         pc = 0xc0078844  lr = 0xc0076320 (regnode_register+0xb8)
         sp = 0xc0c13da0  fp = 0xc0c13db0
         r4 = 0xc4293e00  r5 = 0xc4130200
         r6 = 0xc075883c  r7 = 0xc412e380
         r8 = 0xc4130200  r9 = 0xc40a6ee0
        r10 = 0xc427aae0
regnode_register() at regnode_register+0xb8
         pc = 0xc0076320  lr = 0xc00786c4 (regnode_fixed_register+0x218)
         sp = 0xc0c13db8  fp = 0xc0c13dd8
         r4 = 0xc40a6ee0  r5 = 0xc412e7d0
         r6 = 0xc4293e00 r10 = 0xc427aae0
regnode_fixed_register() at regnode_fixed_register+0x218
         pc = 0xc00786c4  lr = 0xc0078cc8 (regfix_new_pass+0x48)
         sp = 0xc0c13de0  fp = 0xc0c13de8
         r4 = 0xc412e780  r5 = 0xc4130200
         r6 = 0xc07c0c90  r7 = 0xc065f226
         r8 = 0xc08db4f0  r9 = 0xc0947acc
        r10 = 0xc09470c8
regfix_new_pass() at regfix_new_pass+0x48
         pc = 0xc0078cc8  lr = 0xc029a4a4 (bus_generic_new_pass+0xec)
         sp = 0xc0c13df0  fp = 0xc0c13e08
         r4 = 0xc4130200  r5 = 0xc077ce5c
bus_generic_new_pass() at bus_generic_new_pass+0xec
         pc = 0xc029a4a4  lr = 0xc029a4a4 (bus_generic_new_pass+0xec)
         sp = 0xc0c13e10  fp = 0xc0c13e28
         r4 = 0xc4130600  r5 = 0xc077ce5c
         r6 = 0xc07c0c90  r7 = 0xc065f226
         r8 = 0xc08db4f0 r10 = 0xc09470c8
bus_generic_new_pass() at bus_generic_new_pass+0xec
         pc = 0xc029a4a4  lr = 0xc029a4a4 (bus_generic_new_pass+0xec)
         sp = 0xc0c13e30  fp = 0xc0c13e48
         r4 = 0xc4130700  r5 = 0xc077ce5c
         r6 = 0xc07c0c90  r7 = 0xc065f226
         r8 = 0xc08db4f0 r10 = 0xc09470c8
bus_generic_new_pass() at bus_generic_new_pass+0xec
         pc = 0xc029a4a4  lr = 0xc0296580 (bus_set_pass+0x94)
         sp = 0xc0c13e50  fp = 0xc0c13e68
         r4 = 0xc3c18ea0  r5 = 0xc077ce5c
         r6 = 0xc4130a80  r7 = 0xc08db4f0
         r8 = 0x7fffffff r10 = 0xc09470c8
bus_set_pass() at bus_set_pass+0x94
         pc = 0xc0296580  lr = 0xc0200094 (mi_startup+0xfc)
         sp = 0xc0c13e70  fp = 0xc0c13e90
         r4 = 0xc09471c4  r5 = 0x00000001
         r6 = 0xc06af29c  r7 = 0x00000000
         r8 = 0xc09471c0  r9 = 0xc06b01c0
mi_startup() at mi_startup+0xfc
         pc = 0xc0200094  lr = 0xc00002c4 (btext+0x144)
         sp = 0xc0c13e98  fp = 0x00000000
         r4 = 0xc00003f8  r5 = 0xc0998000
         r6 = 0x42056500  r7 = 0x00c52078
         r8 = 0xc0b06000  r9 = 0x00000014
        r10 = 0x0000000a
btext() at btext+0x144
         pc = 0xc00002c4  lr = 0xc00002c4 (btext+0x144)
         sp = 0xc0c13e98  fp = 0x00000000
KDB: enter: panic
[ thread pid 0 tid 100000 ]
Stopped at      $d.3:   ldrb    r15, [r15, r15, ror r15]!
db> -

Please, help me start FreeBSD on OrangePC. Thanks.

arrowd commented 6 years ago

I had limited success with Orange Pi PC.

First, I had to apply this patch to prevent kernel panic: http://arrowd.name/h3audio.patch Next, I came up with following dtb: http://arrowd.name/sun8i-h3-orangepi-pc.dtb

With these I was able to successfully boot into FreeBSD, but unfortunately ethernet driver does not work.

eleutherius commented 6 years ago

How to insert your custom .dtb file into FreeBSD image ?

arrowd commented 6 years ago

Create a memory disk from it (man mdconfig), mount FreeBSD partition (md0s2a, probably) then copy that dtb into /mnt/boot/dtb.

eleutherius commented 6 years ago

I was able to install the correct dtb, but how did you install the patch?

arrowd commented 6 years ago

Well, cd /usr/src && patch < patchfile. Then rebuilt the image using crochet. Make sure to remove crochet/work/._builtkernel_something to make crochet recompile the kernel.

valpackett commented 6 years ago

Audio patch has landed a while ago: https://reviews.freebsd.org/D8425

How exactly does the ethernet fail?

arrowd commented 6 years ago

The patch I posted seems to be a different one, it wasn't committed.

Ethernet wasn't working as no awg device was showing up. But this got fixed automagically in a funny way - I inserted a cable into an ethernet port first and then powered up the board. After that the awg0 device appeared during boot and now it works fine.

Well, there are some hangs when bridging tap and awg, but that's a different story, I think.

valpackett commented 6 years ago

Built orangepi-pc U-Boot and dtb, an image for this board… but hit this problem: https://lists.freebsd.org/pipermail/freebsd-arm/2017-November/017104.html (originally on Plus2E)

So I had to load -t dtb /boot/dtb/sun8i-h3-nanopi-neo.dtb :D And that works, but we should be using our fdt…

valpackett commented 6 years ago

hmmm I guess that kernel panic might be audio related, since it happens right after probing pcm.

valpackett commented 6 years ago

Oh @arrowd your patch applies after the committed one. Where did it come from?

valpackett commented 6 years ago

ehhh it doesn't seem to help, just adds the H3 Audio Codec (analog part) but the kernel still doesn't boot.

Posted some stuff to bugzilla:

arrowd commented 6 years ago

Oh @arrowd your patch applies after the committed one. Where did it come from?

I bugged jmcneill on #bsdmips IRC channel, he gave me it. It helped me with the crash, though.

ghost commented 6 years ago

Succeed in compiling Orange Pi One on FreeBSD 12.0-CURRENT #0 r334337(released on Tue May 29 17:12:35 UTC 2018) and set target to armv6 or armv7 by "-b" parameter . But hung when booting above images either armv6 or armv7 , error message is the following: Loaded DTB from file 'sun8i-h3-orangepi-one.dtb' kernel entry at 0x42200100... kernel args: (null)

Any successful runing on Orange Pi One ? I am appreciated if anyone may let me know the cause of this error or your detailed and correct system environment . BTW , I couldn't get FreeBSD 12.0-CURRENT r333094 as mentioned in "http://occnc.com/info/arm64/NOTES.html" above.

Thanks!

CurtisVillamizar commented 6 years ago

A board directory for Orange Pi One is now available. I have two of them and both work fine. I should update the NOTES.html file. I have not tried Orange Pi PC (I don't have one or a need for one at the moment). The Orange Pi PC seems more similar to Orange Pi PC Plus but it would be best to create a new board directory and use the correct dts file.

CurtisVillamizar commented 6 years ago

Looks like one of the cards that I thought was Orange Pi PC Plus is actually Orange Pi PC but it is running the Orange Pi PC Plus board config. The marvels of buying on Amazon - wrong card. BTW you don't have to run a specific build of FreeBSD 12. So far it has worked on two versions that I pulled. I mentioned the version just as an FYI.

valpackett commented 6 years ago

Hm, so the dtb has arrived in the linux 4.15 sync, the u-boot port was merged, no updates on the audio bug though...

CurtisVillamizar commented 6 years ago

FYI- I just created a pull request for an Orange Pi PC board directory. And yes the audio bug is still there. btw- I updated http://occnc.com/info/arm64/NOTES.html a day or two ago. It does not reflect the pull request just made so I supposed needs another small update but I'll wait until the pull request is acted on.