9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Don Bailey <don.bailey@gmail.com>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] RPi in QEMU
Date: Thu, 31 Aug 2023 22:11:53 -0400	[thread overview]
Message-ID: <CAL_X0tAGcXYDKhHEhGdKE-GG9oCrCJkA+_N4gpp6LUNahXDEhw@mail.gmail.com> (raw)
In-Reply-To: <d05378f786a57c054df7acb8f8df6dd2@hamnavoe.com>

[-- Attachment #1: Type: text/plain, Size: 3479 bytes --]

Hmm, I've applied the patches and built the kernel. I can see the image
loaded at 0x80010000, but it is spinning at address 0xffff000c; is this a
sdmmc load loop?

I'm using version 8.0.0 of QEMU. What version are you using, Mr. Miller?
Also, since the SD takes seconds to load and not ms/us, how long are you
waiting until you see something printed on the console...? Curious if I'm
just running very slow, or if there is still something buggy going on...

Thanks for responding and adding some patches. I am trying to follow along
to make it work, if you don't mind a bit of back and forth :-)

D


On Thu, Aug 31, 2023 at 2:48 PM Richard Miller <9fans@hamnavoe.com> wrote:

> don.bailey@gmail.com:
> > So to get this back on the track of RPI emulated in QEMU … has anyone
> successfully used the Miller image with Q?
>
> After a bit of experimentation, I have done so, for some value of
> "successfully".
>
> A few tweaks are required first, because QEMU's emulation of Pi hardware
> and
> firmware is not as faithful as it might be:
>
> - binary kernel file is loaded at 0x10000, not 0x8000
> - the watchdog timer doesn't work (or isn't there)
> - system timer behaviour is a bit peculiar
> - emulation of the SDMMC in multi-block mode is spectacularly slow
>   (transfers take not milliseconds but seconds)
>
> After tweaking as shown below, a QEMU-compatible kernel can be built with
>   mk CONF'='pi2 9pi2.qemu
> and run with something like
>   qemu-system-arm -M raspi2b -kernel 9pi2.qemu -serial stdio \
>     -drive file=9pi.img,if=sd,format=raw \
>     -append 'readparts=1 console=1 *ncpu=1
> nobootprompt=local!/dev/sdM0/fossil'
>
> For convenience I've put a kernel file on
> /n/sources/contrib/miller/9pi2.qemu
>
> However ...
>
> - the DWC usb host adapter of the Pi2/3 does not work the way Plan 9
> expects
> - therefore there's no functioning usb
> - therefore I don't know how to attach a keyboard, mouse or network
> interface
>
> If anybody wants to debug this further I'm happy to collaborate, but I'm
> not sufficiently motivated to do it myself.
>
> Diffs against files in /n/sources/contrib/miller/9/bcm, which I think are
> identical to 9legacy 9/bcm sources):
>
> mkfile:
> 85a86,90
> > $p$CONF.qemu:DQ:      $CONF.$O $OBJ $LIB
> >       $CC $CFLAGS '-DKERNDATE='`{date -n} $CONF.c
> >       echo '# linking kernel for QEMU'
> >       $LD -s -l -o $target -H6 -R4096 -T0x80010000 $OBJ $CONF.$O $LIB
> >
>
> mem.h:
> 48c48
> < #define       KTZERO          (KZERO+0x8000)          /* kernel text
> start */
> ---
> > #define       KTZERO          (KZERO+0x10000)         /* kernel text
> start */
>
> archbcm2.c:
> 225c225
> <       addclock0link(wdogfeed, HZ);
> ---
> >       //addclock0link(wdogfeed, 1000);
>
> sdmmc.c:
> 25c25
> <       Multiblock      = 1,
> ---
> >       Multiblock      = 0,
>
> clock.c:
> 35c35
> <       MinPeriod       = 10,
> ---
> >       MinPeriod       = 100,
> 124c124
> <       u32int t0, t1, tstart, tend;
> ---
> >       u32int t0, t1, tstart;
> 142d141
> <       tend = tstart + 10000;
> 145c144
> <       }while(tn->clo != tend);
> ---
> >       }while(tn->clo - tstart < 10000);

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T5da5467097e4eab2-Meca1d0c552a069be2e26805e
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 5796 bytes --]

  reply	other threads:[~2023-09-01  2:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-26  4:22 Don Bailey
2023-08-26  9:23 ` Philip Silva via 9fans
2023-08-26 11:39   ` hiro
2023-08-26 10:44     ` mkf
2023-08-26 11:48       ` hiro
2023-08-26 12:52         ` Philip Silva via 9fans
2023-08-26 19:38         ` Don A. Bailey
2023-08-31 18:47           ` Richard Miller
2023-09-01  2:11             ` Don Bailey [this message]
2023-09-01  8:18               ` Richard Miller
2023-09-01  8:47                 ` fgergo
2023-09-01  8:56                   ` quiekaizam via 9fans
2023-09-01 14:06               ` Richard Miller
2023-09-01 15:38                 ` Don Bailey
2023-09-01 19:37                   ` Richard Miller
2023-09-02  2:01                     ` Don Bailey
2023-09-02  3:25                       ` Don Bailey
2023-09-02  8:25                         ` hiro
2023-09-02 15:20                         ` Richard Miller
2023-09-14 11:52                           ` adr via 9fans
2023-09-14 17:11                             ` Richard Miller
2023-09-14 17:25                               ` adr via 9fans
2023-09-02 15:17                       ` Richard Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAL_X0tAGcXYDKhHEhGdKE-GG9oCrCJkA+_N4gpp6LUNahXDEhw@mail.gmail.com \
    --to=don.bailey@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).