From nobody Mon Feb 07 17:44:06 2022 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BC52019B4606 for ; Mon, 7 Feb 2022 17:44:14 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jstms725pz4RWg for ; Mon, 7 Feb 2022 17:44:13 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f52.google.com with SMTP id j5-20020a05600c1c0500b0034d2e956aadso9131677wms.4 for ; Mon, 07 Feb 2022 09:44:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=P+kRdC0dnYFcJpOOTZEVKI1qsMFZCu/gQLPHnhNzEZE=; b=MsUp8qeKOFKbx3kb29eaPk8fuiREBk2K6bNENPGCpFfbkkIOd6H91vYSbIBsnpfj5n V7IJJTDI4rbXxNEJ+Skq0J7GfUnZAJNVPFYqW4jE6o3IRCjRuYUkl4oHmh3AAnSQdx8O URiPNQoMQ5nbzCFQTb5TS4cTFXHxdyiSfvbRQ/PTkatkOVhkWbUp9s4tz2plUkB3pRGh VEHI4JJe5+7XI0WVxav6T8KPDdOVztDsL4Wl9g0A0t6Nvz72+JLR3D3lVbr4H7U/lE2j INV9IsUpXSlg+kzCtlyraldf0SW61LkyhqyX8kiaMb6xG8gBqWWJ3AkoV893U2SwjBuf agUw== X-Gm-Message-State: AOAM531uyUkoHW6f4DiacsckL/K6ev+q2Qa3kK/7sFZjEd+M/u8Hl9eC +snkluh3nm9gPMikeyAv5uh07w== X-Google-Smtp-Source: ABdhPJwi+c7VVTfvsoATbYk15YO1Ugy7uzMHpfivqy6yw/MtsAihwU6REay+7OuXxO5olDgr6x5DTA== X-Received: by 2002:a7b:ce08:: with SMTP id m8mr40453wmc.70.1644255847140; Mon, 07 Feb 2022 09:44:07 -0800 (PST) Received: from smtpclient.apple (global-5-143.nat-2.net.cam.ac.uk. [131.111.5.143]) by smtp.gmail.com with ESMTPSA id o22sm3193wmh.13.2022.02.07.09.44.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Feb 2022 09:44:06 -0800 (PST) Content-Type: text/plain; charset=utf-8 List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.40.0.1.81\)) Subject: Re: Sipeed Lichee RV (Allwinner D1) From: Jessica Clarke In-Reply-To: <39674ce9-bbc4-a817-57ab-922d9c522fac@alvermark.net> Date: Mon, 7 Feb 2022 17:44:06 +0000 Cc: Mitchell Horne , "freebsd-riscv@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <4975A04C-FF52-4FE4-91C3-E445C75EF62A@freebsd.org> References: <5a74bd6d-4000-c413-02e2-33608f9ae683@freebsd.org> <18b735fb-fd36-daad-9ee7-974ff1955400@alvermark.net> <39674ce9-bbc4-a817-57ab-922d9c522fac@alvermark.net> To: Jakob Alvermark X-Mailer: Apple Mail (2.3693.40.0.1.81) X-Rspamd-Queue-Id: 4Jstms725pz4RWg X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of jrtc27@jrtc27.com designates 209.85.128.52 as permitted sender) smtp.mailfrom=jrtc27@jrtc27.com X-Spamd-Result: default: False [-2.50 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FORGED_SENDER(0.30)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; MID_RHS_MATCH_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FREEFALL_USER(0.00)[jrtc27]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; SH_EMAIL_DBL_DONT_QUERY_IPS(0.00)[0.61.87.32:email,0.38.37.160:email,0.91.184.120:email,0.61.91.8:email]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-riscv@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.128.52:from]; MLMMJ_DEST(0.00)[freebsd-riscv]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.128.52:from]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On 7 Feb 2022, at 17:38, Jakob Alvermark wrote: >=20 > On 1/29/22 16:12, Jakob Alvermark wrote: >>=20 >> On 1/28/22 16:29, Mitchell Horne wrote: >>> On 1/19/22 18:05, Jakob Alvermark wrote: >>>>=20 >>>> On 1/19/22 17:24, Mitchell Horne wrote: >>>>>=20 >>>>>=20 >>>>> On 1/17/22 15:02, Jakob Alvermark wrote: >>>>>> Hi, >>>>>>=20 >>>>>>=20 >>>>>> With RISC-V SBCs now coming down in price, I got curios and got = myself a Lichee RV (with the dock). >>>>>>=20 >>>>>> https://linux-sunxi.org/Sipeed_Lichee_RV >>>>>>=20 >>>>>> The instructions here, https://linux-sunxi.org/Allwinner_Nezha = along with some patching got me a working U-boot. >>>>>>=20 >>>>>> Cross-building and putting together and image for and SD card got = me this far: >>>>>>=20 >>>> >>>>>> Loading kernel... >>>>>> /boot/kernel/kernel text=3D0x609ddc text=3D0x133abc data=3D0xf4420 = data=3D0xb54+0x1d73e4 syms=3D[0x8+0xcd188+0x8+0xee5ae] >>>>>> Loading configured modules... >>>>>> can't find '/etc/hostid' >>>>>> can't find '/boot/entropy' >>>>>> Using DTB provided by EFI at 0x47ef5000. >>>>>> Kernel entry at 0x56a0002e... >>>>>> Kernel args: (null) >>>>>>=20 >>>>>> ----- >>>>>>=20 >>>>>> And here it stops for ~16 seconds then restarts, that's the = watchdog resetting it. >>>>>>=20 >>>>>> So where do I go from here? >>>>>>=20 >>>>> Hi Jakob, >>>>>=20 >>>>> Looks like it bails somewhere in the initial kernel setup, before = the first output to the console. This is a wide range, so it's difficult = to say exactly where things are going wrong. >>>>>=20 >>>>> I will say that generally FreeBSD is not expected to work on the = D1; as far as I know you are the first to try it. This hardware has some = quirks requiring special support, which we are entirely lacking. = Specifically, there is one related to virtual memory management, which = requires custom (spec-breaking) bits in the page tables to be set, to = properly specify the attributes of physical and device memory. This = _may_ have something to do with why it is failing where it is. It would = take a motivated party to add the support required for this SoC, and I'm = not aware of anyone currently taking this on. This board has caused some = headaches in Linux-land for the same reasons, but there are more hands = to do the work there. I just want to set the expectations properly :) >>>>>=20 >>>>> If you wanted to debug this further, you might rebuild the kernel = after adding 'options EARLY_PRINTF' to the config file, as this should = enable a couple early outputs and narrow down the search slightly. >>>>=20 >>>>=20 >>>> Hi Mitchell, >>>>=20 >>>>=20 >>>> I did not expect it to work. But it would be nice if it did. >>>>=20 >>>> I have a long experience with FreeBSD and I have played around with = a couple of different ARM-boards, but I'm not very experienced with = kernel hacking. >>>>=20 >>>> I built a kernel with EARLY_PRINTF, but it did not give me any more = output... >>>>=20 >>>> Is there anything else I could try? >>>>=20 >>>=20 >>> Yes, I missed an important detail: the required uart driver is = missing from the kernel. Please add 'device uart_snps' to the kernel = config as well, and see if this results in any output. >>=20 >>=20 >> Hi, I tried that, but sadly it did not make any difference. >>=20 >> I looked at what they have done in Linux, and this commit seems to = have some interesting bits: >>=20 >> = https://github.com/smaeul/linux/commit/c1bc61cee73e236c3cd69fe6c998b7f80c6= 54263#diff-4f4bb4eea826b523d76ddb1c539dad5685a0e7fd7cc8f1089a0493efd0e8e5b= 8=20 >=20 >=20 > Hi again, >=20 >=20 > I noticed they have updated the U-Boot code to specifically support = this board. >=20 > With nothing to loose, I decided to try it. >=20 > Now I get a little more: >=20 > [35]HELLO! BOOT0 is starting! > [38]BOOT0 commit : 525883d-dirty > [41]set pll start > [43]periph0 has been enabled > [46]set pll end > [47]board init ok > [49]DRAM only have internal ZQ!! > [52]get_pmu_exist() =3D -1 > [55]ddr_efuse_type: 0x0 > [58][AUTO DEBUG] single rank and full DQ! > [62]ddr_efuse_type: 0x0 > [65][AUTO DEBUG] rank 0 row =3D 15 > [68][AUTO DEBUG] rank 0 bank =3D 8 > [71][AUTO DEBUG] rank 0 page size =3D 2 KB > [75]DRAM BOOT DRIVE INFO: V0.24 > [77]DRAM CLK =3D 792 MHz > [80]DRAM Type =3D 3 (2:DDR2,3:DDR3) > [83]DRAMC ZQ value: 0x7b7bfb > [85]DRAM ODT value: 0x42. > [88]ddr_efuse_type: 0x0 > [91]DRAM SIZE =3D512 M > [94]DRAM simple test OK. > [96]dram size =3D512 > [98]card no is 0 > [100]sdcard 0 line count 4 > [102][mmc]: mmc driver ver 2021-04-2 16:45 > [112][mmc]: Wrong media type 0x0 > [115][mmc]: ***Try SD card 0*** > [132][mmc]: HSSDR52/SDR25 4 bit > [135][mmc]: 50000000 Hz > [137][mmc]: 15193 MB > [139][mmc]: ***SD/MMC 0 init OK!!!*** > [176]Loading boot-pkg Succeed(index=3D1). > [180]Entry_name =3D opensbi > [183]Entry_name =3D dtb > [185]Entry_name =3D u-boot > [189]Adding DRAM info to DTB. > [193]Jump to second Boot. >=20 > OpenSBI v1.0 > ____ _____ ____ _____ > / __ \ / ____| _ \_ _| > | | | |_ __ ___ _ __ | (___ | |_) || | > | | | | '_ \ / _ \ '_ \ \___ \| _ < | | > | |__| | |_) | __/ | | |____) | |_) || |_ > \____/| .__/ \___|_| |_|_____/|____/_____| > | | > |_| >=20 > Platform Name : Sipeed Lichee RV Dock > Platform Features : medeleg > Platform HART Count : 1 > Platform IPI Device : aclint-mswi > Platform Timer Device : aclint-mtimer @ 24000000Hz > Platform Console Device : uart8250 > Platform HSM Device : --- > Platform Reboot Device : sunxi-wdt-reset > Platform Shutdown Device : --- > Firmware Base : 0x40000000 > Firmware Size : 264 KB > Runtime SBI Version : 0.3 >=20 > Domain0 Name : root > Domain0 Boot HART : 0 > Domain0 HARTs : 0* > Domain0 Region00 : 0x0000000014008000-0x000000001400bfff (I) > Domain0 Region01 : 0x0000000014000000-0x0000000014007fff (I) > Domain0 Region02 : 0x0000000040000000-0x000000004007ffff () > Domain0 Region03 : 0x0000000000000000-0xffffffffffffffff = (R,W,X) > Domain0 Next Address : 0x000000004a000000 > Domain0 Next Arg1 : 0x0000000044000000 > Domain0 Next Mode : S-mode > Domain0 SysReset : yes >=20 > Boot HART ID : 0 > Boot HART Domain : root > Boot HART ISA : rv64imafdcvsux > Boot HART Features : scounteren,mcounteren,mcountinhibit,time > Boot HART PMP Count : 16 > Boot HART PMP Granularity : 2048 > Boot HART PMP Address Bits: 38 > Boot HART MHPM Count : 0 > Boot HART MIDELEG : 0x0000000000000222 > Boot HART MEDELEG : 0x000000000000b109 >=20 >=20 > U-Boot 2022.01-32931-gc249924b17-dirty (Feb 06 2022 - 17:29:00 +0100) >=20 > DRAM: 512 MiB > Core: 43 devices, 18 uclasses, devicetree: board > WDT: Started watchdog@6011000 with servicing (16s timeout) > MMC: mmc@4020000: 0, mmc@4021000: 1 > Loading Environment from nowhere... OK > In: serial@2500000 > Out: serial@2500000 > Err: serial@2500000 > Net: No ethernet found. > Hit any key to stop autoboot: 0 > switch to partitions #0, OK > mmc0 is current device > Scanning mmc 0:1... > ** Unable to read file / ** > Failed to load '/' > libfdt fdt_check_header(): FDT_ERR_BADMAGIC > Scanning disk mmc@4020000.blk... > Scanning disk mmc@4021000.blk... > Disk mmc@4021000.blk not ready > Found 3 disks > ** Unable to read file ubootefi.var ** > Failed to load EFI variables > BootOrder not defined > EFI boot manager: Cannot load any image > Found EFI removable media binary efi/boot/bootriscv64.efi > 1409436 bytes read in 248 ms (5.4 MiB/s) > libfdt fdt_check_header(): FDT_ERR_BADMAGIC > Booting /efi\boot\bootriscv64.efi >=20 > Consoles: EFI console > Reading loader env vars from /efi/freebsd/loader.env > Setting currdev to disk0p1: > FreeBSD/riscv EFI loader, Revision 1.1 > (Fri Jan 14 13:21:23 CET 2022 root@legion) >=20 > Command line arguments: l > Image base: 0x5e9d8000 > EFI version: 2.90 > EFI Firmware: Das U-Boot (rev 8226.256) > Console: comconsole (0) > Load Path: /efi\boot\bootriscv64.efi > Load Device: = /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,GPT,1ab17495= -7795-11ec-9e49-f875a47d4ead,0xa1f8,0x10418) > Trying ESP: = /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,GPT,1ab17495= -7795-11ec-9e49-f875a47d4ead,0xa1f8,0x10418) > Setting currdev to disk0p1: > Trying: = /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(2,GPT,2973d4b3= -7795-11ec-9e49-f875a47d4ead,0x1a610,0x200000) > Setting currdev to disk0p2: > Loading /boot/defaults/loader.conf > Loading /boot/defaults/loader.conf > Loading /boot/device.hints > Loading /boot/loader.conf > Loading /boot/loader.conf.local > / > ______ ____ _____ _____ > | ____| | _ \ / ____| __ \ > | |___ _ __ ___ ___ | |_) | (___ | | | | > | ___| '__/ _ \/ _ \| _ < \___ \| | | | > | | | | | __/ __/| |_) |____) | |__| | > | | | | | | || | | | > |_| |_| \___|\___||____/|_____/|_____/ ``` = ` > s` = `.....---.......--.``` -/ > +---------- Welcome to FreeBSD -----------+ +o .--` /y:` +. > | | yo`:. :o `+- > | 1. Boot Multi user [Enter] | y/ -/` -o/ > | 2. Boot Single user | .- = ::/sy+:. > | 3. Escape to loader prompt | / `-- = / > | 4. Reboot | `: = :` > | 5. Cons: Video | `: = :` > | | / = / > | Options: | .- = -. > | 6. Kernel: default/kernel (1 of 1) | -- = -. > | 7. Boot Options | `:` `:` > | | .-- `--. > | | .---.....----. > +-----------------------------------------+ > Autoboot in 0 seconds. [Space] to pause >=20 > Loading kernel... > /boot/kernel/kernel text=3D0x5ef0ec text=3D0x1704dc data=3D0xf7900 = data=3D0xbcc+0x2741cc syms=3D[0x8+0xd0290+0x8+0xf1d3e] > Loading configured modules... > can't find '/boot/entropy' > can't find '/etc/hostid' > Using DTB provided by EFI at 0x47ef6000. > Kernel entry at 0x56a0002e... > Kernel args: (null) > ERROR loading DTB > panic: Boot hart ID was not properly set > cpuid =3D 0 > time =3D 1 > KDB: stack backtrace: > Uptime: 1s Like it says, your device tree is broken. U-Boot is supposed to copy the previous stage=E2=80=99s /chosen/boot-hartid to any device tree it = loads, but something=E2=80=99s gone wrong there. Not much FreeBSD can do about = that. Jess