9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Richard Miller <9fans@hamnavoe.com>
To: 9fans@9fans.net
Subject: Re: [9fans] RPi in QEMU
Date: Thu, 31 Aug 2023 19:47:06 +0100	[thread overview]
Message-ID: <d05378f786a57c054df7acb8f8df6dd2@hamnavoe.com> (raw)
In-Reply-To: <E8FBFED9-05AD-4A81-A824-54E6EEC5D743@gmail.com>

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-M2edf6c6413ee49aaee761281
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

  reply	other threads:[~2023-08-31 18:47 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 [this message]
2023-09-01  2:11             ` Don Bailey
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=d05378f786a57c054df7acb8f8df6dd2@hamnavoe.com \
    --to=9fans@hamnavoe.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).