From nobody Mon Feb 28 17:19:46 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 0510C19EA762 for ; Mon, 28 Feb 2022 17:20:08 +0000 (UTC) (envelope-from julien.cassette@gmail.com) Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) (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 4K6nFM0pTVz3jtm for ; Mon, 28 Feb 2022 17:20:07 +0000 (UTC) (envelope-from julien.cassette@gmail.com) Received: by mail-lf1-x132.google.com with SMTP id u20so22595101lff.2 for ; Mon, 28 Feb 2022 09:20:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=YAx75wYtVoBboLiKEFHRjfLq+zM5SuD6tZHNlA48Muo=; b=h+5+qtlovA7RoIbf7O3M6zmaHHTcBcdKWSk6tqHhtTZsm05a7MnDYQ5stRKrExiZpo SwlCK9Bz0oPAZstE8rzMOHk4ZJEe40lUaAb4BAT+AYXk/JUXykq388r806KwG2dzdzjw twGahoQbvYoHOs6upcejnM149Xt6z/SVbCgzyh1asF9vHYHdia3FBVSxxyLGwpvKDdI0 qcCG5Ys69hbgm6wXxHE2hurTeJpMXkyr2pAK2bUzjSFroq3NqRO+T/kZGGFO6MDPh626 AAHx7LbvbvE8fZs7DCzJsCWWM1PXgjW4vUkMrfi1xQT6V9KNtjW3+8Fa1y2df9peMA0L nCTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=YAx75wYtVoBboLiKEFHRjfLq+zM5SuD6tZHNlA48Muo=; b=bden5dqqPmU259G+8kEO0r7k80INFqGpvCtUVh6onMzgGajr1XmouyBxpJpjpMP2FB eOrARypLe2YT8mhTonWZY5hKgDpB54BYuyP3d9NYc7uiJVbYxM0AK46YHgw9CT+72uvV +u5A60CGEdQZHTftX9DCFFAGSjsAkA96Na7YVZqzeTbVNy7/tE6emp6kQh2eyNEbOjA8 /NyHt5/1ydex/QJv8pH4wq0VQsCgQRKVYm1ZQUQCOAd1ZB0ZhVyT/zpcKbh8wf/6Ef7/ SR/GlZrBPtXkjlUT46mssVXgYlXFVy9BPEvrWbXFdw1MtI4gzqIYqA7SD9sFajVMgFXs NhiQ== X-Gm-Message-State: AOAM533ZEAYoFBcYwI9kzkSrPJLu+jrguDk3Ki+6Q+t5q3MSInpthG0U qSbiHPQx9EGpjmOXZjbkUi7ft5SR0qghVy3FwRPUUIO6EQM= X-Google-Smtp-Source: ABdhPJzac2NLP0YxeCdR9EQDARwbRg7DZkLjMQMuGN8VQNMLxkJCVHUrr8UnAQv8HoUfBoz7aVuHUqPhBO4joIUgC3I= X-Received: by 2002:a19:691c:0:b0:443:9a02:35d with SMTP id e28-20020a19691c000000b004439a02035dmr13209145lfc.541.1646068800026; Mon, 28 Feb 2022 09:20:00 -0800 (PST) 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 References: <54a1fb0c-1128-a9fc-a96d-fe973bd2cabc@alvermark.net> <41855845-4e9f-deb9-386c-3e98b99692e9@alvermark.net> In-Reply-To: <41855845-4e9f-deb9-386c-3e98b99692e9@alvermark.net> From: Julien Cassette Date: Mon, 28 Feb 2022 18:19:46 +0100 Message-ID: Subject: Re: Sipeed Lichee RV (Allwinner D1) To: freebsd-riscv@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4K6nFM0pTVz3jtm X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=h+5+qtlo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of juliencassette@gmail.com designates 2a00:1450:4864:20::132 as permitted sender) smtp.mailfrom=juliencassette@gmail.com X-Spamd-Result: default: False [-4.00 / 15.00]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; TO_DN_NONE(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; TAGGED_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-riscv@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::132:from]; MLMMJ_DEST(0.00)[freebsd-riscv]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N Le dim. 27 f=C3=A9vr. 2022 =C3=A0 20:26, Jakob Alvermark a =C3=A9crit : > > > > On 2/7/22 18:44, Jessica Clarke wrote: > > On 7 Feb 2022, at 17:38, Jakob Alvermark wrote: > >> On 1/29/22 16:12, Jakob Alvermark wrote: > >>> On 1/28/22 16:29, Mitchell Horne wrote: > >>>> On 1/19/22 18:05, Jakob Alvermark wrote: > >>>>> On 1/19/22 17:24, Mitchell Horne wrote: > >>>>>> > >>>>>> On 1/17/22 15:02, Jakob Alvermark wrote: > >>>>>>> Hi, > >>>>>>> > >>>>>>> > >>>>>>> With RISC-V SBCs now coming down in price, I got curios and got m= yself a Lichee RV (with the dock). > >>>>>>> > >>>>>>> https://linux-sunxi.org/Sipeed_Lichee_RV > >>>>>>> > >>>>>>> The instructions here, https://linux-sunxi.org/Allwinner_Nezha al= ong with some patching got me a working U-boot. > >>>>>>> > >>>>>>> Cross-building and putting together and image for and SD card got= me this far: > >>>>>>> > >>>>> > >>>>>>> Loading kernel... > >>>>>>> /boot/kernel/kernel text=3D0x609ddc text=3D0x133abc data=3D0xf442= 0 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) > >>>>>>> > >>>>>>> ----- > >>>>>>> > >>>>>>> And here it stops for ~16 seconds then restarts, that's the watc= hdog resetting it. > >>>>>>> > >>>>>>> So where do I go from here? > >>>>>>> > >>>>>> Hi Jakob, > >>>>>> > >>>>>> 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. > >>>>>> > >>>>>> I will say that generally FreeBSD is not expected to work on the D= 1; as far as I know you are the first to try it. This hardware has some qui= rks 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 a= ttributes of physical and device memory. This _may_ have something to do wi= th why it is failing where it is. It would take a motivated party to add th= e support required for this SoC, and I'm not aware of anyone currently taki= ng 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 :) > >>>>>> > >>>>>> If you wanted to debug this further, you might rebuild the kernel = after adding 'options EARLY_PRINTF' to the config file, as this should enab= le a couple early outputs and narrow down the search slightly. > >>>>> > >>>>> Hi Mitchell, > >>>>> > >>>>> > >>>>> I did not expect it to work. But it would be nice if it did. > >>>>> > >>>>> 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. > >>>>> > >>>>> I built a kernel with EARLY_PRINTF, but it did not give me any more= output... > >>>>> > >>>>> Is there anything else I could try? > >>>>> > >>>> Yes, I missed an important detail: the required uart driver is missi= ng from the kernel. Please add 'device uart_snps' to the kernel config as w= ell, and see if this results in any output. > >>> > >>> Hi, I tried that, but sadly it did not make any difference. > >>> > >>> I looked at what they have done in Linux, and this commit seems to ha= ve some interesting bits: > >>> > >>> https://github.com/smaeul/linux/commit/c1bc61cee73e236c3cd69fe6c998b7= f80c654263#diff-4f4bb4eea826b523d76ddb1c539dad5685a0e7fd7cc8f1089a0493efd0e= 8e5b8 > >> > >> Hi again, > >> > >> > >> I noticed they have updated the U-Boot code to specifically support th= is board. > >> > >> With nothing to loose, I decided to try it. > >> > >> Now I get a little more: > >> > >> > >> Loading kernel... > >> /boot/kernel/kernel text=3D0x5ef0ec text=3D0x1704dc data=3D0xf7900 dat= a=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. > > I tried this: > > ----- > > OK fdt prop /chosen > Using DTB provided by EFI at 0x47ef6000. > fixup-applied > boot-hartid =3D <0x00000000> > stdout-path =3D "serial0:115200n8" > > ----- > > And then... > > ----- > > OK boot -v > 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' > Kernel entry at 0x56a0002e... > Kernel args: -v > t[0] =3D=3D 0xffffffc00085bcb0 > t[1] =3D=3D 0xffffffc00085bcd2 > t[2] =3D=3D 0xffffffc00085bcd1 > t[3] =3D=3D 0x00000000000004b5 > t[4] =3D=3D 0x0000000000000001 > t[5] =3D=3D 0x0000000015c59000 > t[6] =3D=3D 0x0000000015c59001 > s[0] =3D=3D 0xffffffc000003ca0 > s[1] =3D=3D 0xffffffc000ccf000 > s[2] =3D=3D 0xffffffc000ac6f00 > s[3] =3D=3D 0x0000000000008000 > s[4] =3D=3D 0xffffffc000003f10 > s[5] =3D=3D 0x0000000000000800 > s[6] =3D=3D 0x000000000000001f > s[7] =3D=3D 0x00000000000f4241 > s[8] =3D=3D 0x00000000000f4240 > s[9] =3D=3D 0x0000000056a00000 > s[10] =3D=3D 0x0000000000000ff0 > s[11] =3D=3D 0x000000005eb1c7a0 > a[0] =3D=3D 0xffffffbf80cd74d0 > a[1] =3D=3D 0x0000000000008007 > a[2] =3D=3D 0x0000000000000001 > a[3] =3D=3D 0x0000000000000001 > a[4] =3D=3D 0xffffffffffffffff > a[5] =3D=3D 0x0000000000000001 > a[6] =3D=3D 0x0000000000000003 > a[7] =3D=3D 0x0000000000000010 > ra =3D=3D 0xffffffc0005d3f3c > sp =3D=3D 0xffffffc000003c90 > gp =3D=3D 0x0000000000000000 > tp =3D=3D 0x0000000000000000 > sepc =3D=3D 0xffffffc000387cbc > sstatus =3D=3D 0x8000000201806100 > panic: Fatal page fault at 0xffffffc000387cbc: 0xffffffbf80cd74d0 > cpuid =3D 0 > time =3D 1 > KDB: stack backtrace: > Uptime: 1s > > I don't know what happened with my previous message, I am trying to repost properly, sorry about that... I was stuck at the same point but I managed to get further by disabling the custom memory attributes, ie. having the MMU in compatible mode. This is configured in the MMU code of the SBL, by the bit number 21 (MAEE) of the MXSTATUS register: julien@Julien-T460:~/sun20i_d1_spl$ git diff diff --git a/arch/riscv/cpu/riscv64/mmu.c b/arch/riscv/cpu/riscv64/mmu.c index f1bd043..4ddde0f 100644 --- a/arch/riscv/cpu/riscv64/mmu.c +++ b/arch/riscv/cpu/riscv64/mmu.c @@ -43,7 +43,7 @@ __weak void dcache_enable(void) (21) MAEE=E4=B8=BA1=E6=97=B6MMU=E7=9A=84pte=E4=B8=AD=E6=89=A9=E5=B1= =95=E5=9C=B0=E5=9D=80=E5=B1=9E=E6=80=A7=E4=BD=8D=EF=BC=8C=E7=94=A8=E6=88=B7= =E5=8F=AF=E4=BB=A5=E9=85=8D=E7=BD=AE=E9=A1=B5=E9=9D=A2=E7=9A=84=E5=9C=B0=E5= =9D=80=E5=B1=9E=E6=80=A7 (22) THEADISAEE=E4=B8=BA1=E6=97=B6=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94= =A8C906=E6=89=A9=E5=B1=95=E6=8C=87=E4=BB=A4=E9=9B=86 */ - csr_set(CSR_MXSTATUS, 0x638000); + csr_set(CSR_MXSTATUS, 0x438000); /* I have opened a pull request for this: https://github.com/smaeul/sun20i_d1_spl/pull/5 Now the boot is failing while mouting the rootfs: Hit [Enter] to boot immediately, or any other key for command prompt. Booting [/boot/kernel/kernel]... Using DTB provided by EFI at 0x47ef6000. Kernel entry at 0x56a0002e... Kernel args: (null) ---<>--- 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.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr 9 03:30:22 UTC 2021 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/riscv.riscv64/sys/GENERIC riscv FreeBSD clang version 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c3fe) SBI: OpenSBI v0.9 SBI Specification Version: 0.3 CPU(0): Unknown Implementer Unknown Processor real memory =3D 536870912 (512 MB) avail memory =3D 507383808 (483 MB) arc4random: WARNING: initial seeding bypassed the cryptographic random device because it was not yet seeded and the knob 'bypass_before_seeding' was enabled. random: entropy device external interface WARNING: Device "openfirm" is Giant locked and may be deleted before FreeBSD 14.0. ofwbus0: clk_fixed0: on ofwbus0 simplebus0: on ofwbus0 timer0: Timecounter "RISC-V Timecounter" frequency 24000000 Hz quality 1000 Event timer "RISC-V Eventtimer" frequency 24000000 Hz quality 1000 rcons0: cpulist0: on ofwbus0 cpu0: on cpulist0 cryptosoft0: Timecounters tick every 1.000 msec Trying to mount root from ufs:/dev/ufs/rootfs [rw]... mountroot: waiting for device /dev/ufs/rootfs... Mounting from ufs:/dev/ufs/rootfs failed with error 19. The full boot log is here: https://pastebin.com/BVaqnRh9 I hope this helps Julien