inferno-ds with usable wm/wm under desmume (rev 62)

19 views
Skip to first unread message

Salva Peiró

unread,
Mar 16, 2008, 5:06:21 PM3/16/08
to infer...@googlegroups.com
I've added a inferno kernel nds file to the downloads section of inferno-ds [1]
it starts wm/wm from dsinit.b and one can interact through the touch screen.
So one can give it a try and get an idea of what/how things are working.

Note that it has to be run under desmume,
since arm9 interrupts on the hardware don't work.
I'm figuring what is missing for them to work,
i suspect that the mpu bits are still not set correctly. Any Ideas?

[1] http://code.google.com/p/inferno-ds/downloads/list
--
salva

Salva Peiró

unread,
Mar 18, 2008, 2:11:04 PM3/18/08
to infer...@googlegroups.com
i forgot to note that for making it work you have to:
pause & execute the emulator twice.

Otherwise the desmume gets stuck (on the hardware it crashes),
and desmume's dissasembler shows PC=0x2068e90.

% echo 'asm(0x2068e90)' | i acid -l acidmap isds.p9
isds.p9:Arm plan 9 executable

$ROOT/lib/acid/port
$ROOT/lib/acid/arm
acid: canontod+0x4 0x02068e90 CDP #0x1, #0x0, C(8), C(0), C(9), #0x4

% echo 'asm(canontod)' | i acid -l acidmap isds.p9
isds.p9:Arm plan 9 executable

$ROOT/lib/acid/port
$ROOT/lib/acid/arm
acid: canontod 0x02068e8c MOVW.W R14,#-0xc(R13)
canontod+0x4 0x02068e90 CDP #0x1, #0x0, C(8), C(0), C(9), #0x4
canontod+0x8 0x02068e94 UNK
canontod+0xc 0x02068e98 MOVW a-8(SP),R1
canontod+0x10 0x02068e9c CMP.S $#0x0,R1
canontod+0x14 0x02068ea0 B.EQ canontod+0x30
canontod+0x18 0x02068ea4 MOVW #0x0(R0),R1
canontod+0x1c 0x02068ea8 MOVW R1,a-8(SP)
canontod+0x20 0x02068eac MOVW #0x4(R0),R1
canontod+0x24 0x02068eb0 MOVW R1,#0x8(R13)
canontod+0x28 0x02068eb4 UNK
canontod+0x2c 0x02068eb8 RET.P #0xc(R13)
canontod+0x30 0x02068ebc MOVW #0x0(R0),R1
canontod+0x34 0x02068ec0 MOVW R1,#0x8(R13)
canontod+0x38 0x02068ec4 MOVW #0x4(R0),R1
canontod+0x3c 0x02068ec8 MOVW R1,a-8(SP)
canontod+0x40 0x02068ecc UNK
canontod+0x44 0x02068ed0 RET.P #0xc(R13)
load 0x02068ed4 MOVW.W R14,#-0x10(R13)

I look at the UNKs:

% echo '*0x02068e94; *0x02068e94\B' | i acid -l acidmap isds.p9
isds.p9:Arm plan 9 executable

$ROOT/lib/acid/port
$ROOT/lib/acid/arm
acid: 0xed8d8101
acid: 0b11101101100011011000000100000001
acid:

given their encoding and being preceded by CPD instructions.
They are VFP instructions, which agrees with libinterp/load.c:/^canontod
as the C code is performing an LDC/STC instruction.

So the emulator/hw is getting stuck because the code is not trapping
and emulating fpi.

and now the question: i'm more or less on the track, or i've lost it?

thanks
--
salva

saoret

unread,
Mar 18, 2008, 2:28:02 PM3/18/08
to inferno-ds
So i continue and perform the following changes:

Index: libinterp/load.c
===================================================================
--- libinterp/load.c (revision 270)
+++ libinterp/load.c (working copy)
@@ -344,7 +344,7 @@
for(i = 0; i < n; i++) {
ul[0] = disw(isp);
ul[1] = disw(isp);
- *(REAL*)si = canontod(ul);
+ //*(REAL*)si = canontod(ul);
si += sizeof(REAL);
}
break;

and you can play with wm/wm under desmume. Changing:

Index: os/ds/devnds.c
===================================================================
--- os/ds/devnds.c (revision 64)
+++ os/ds/devnds.c (working copy)
@@ -77,7 +77,7 @@
REG_KEYCNT = (1<<0) | (1<<1) | (1<<14);
intrenable(0, KEYbit, keysintr, nil, 0);

- if(1)kproc("touchread", touchread, nil, 0);
+ if(0)kproc("touchread", touchread, nil, 0);
return devattach('T', spec);
}

Index: os/ds/clock.c
===================================================================
--- os/ds/clock.c (revision 64)
+++ os/ds/clock.c (working copy)
@@ -149,7 +149,7 @@
clockinit(void)
{
m->ticks = 0;
- if(1)timerenable(0, HZ, clockintr, 0);
+ if(0)timerenable(0, HZ, clockintr, 0);
}

void

and it can run without clockintr and touchscreen on the hardware.

So we need to fix arm9 interrupts!

David Leimbach

unread,
Mar 18, 2008, 6:35:59 PM3/18/08
to infer...@googlegroups.com
Wow... so does this mean there's code I can build or a binary to try on my hardware at this point somewhere?

Salva Peiró

unread,
Mar 18, 2008, 7:21:31 PM3/18/08
to infer...@googlegroups.com
just give it a try!, and answer it by yourself

it should be straigthforward just following the previous mails.
And in case it is not: the inferno-ds project has good docs/info.

btw, there're also some scattered guide files in the inferno-ds project
that can also help in figuring out the commands to run.

Good luck!

On Tue, Mar 18, 2008 at 11:35 PM, David Leimbach <lei...@gmail.com> wrote:
> Wow... so does this mean there's code I can build or a binary to try on my
> hardware at this point somewhere?

--
salva

David Leimbach

unread,
Mar 18, 2008, 8:11:27 PM3/18/08
to infer...@googlegroups.com
Ok.
For whatever reason I don't remember how to cross compile from mac os x leopard.

I'll try to get some time to check it out tonight

David Leimbach

unread,
Mar 19, 2008, 12:03:26 AM3/19/08
to infer...@googlegroups.com
Ok I've got it building, but I STILL have to do the following to ds

Index: ds
===================================================================
--- ds (revision 64)
+++ ds (working copy)
@@ -138,7 +138,7 @@
  /dis/ftest.dis
  /dis/kill.dis
  /dis/lib
- /dis/lib/acmewin.dis
+# /dis/lib/acmewin.dis
  /dis/lib/arg.dis
  /dis/lib/bufio.dis
  /dis/lib/chanfill.dis
@@ -152,7 +152,7 @@
  /dis/lib/libc0.dis
  /dis/lib/login.dis
  /dis/lib/memfs.dis
- /dis/lib/menuhit.dis
+# /dis/lib/menuhit.dis
  /dis/lib/newns.dis
  /dis/lib/rand.dis
  /dis/lib/random.dis
@@ -211,7 +211,7 @@
  /dis/os.dis
  /dis/p.dis
  /dis/pause.dis
- /dis/pipefile.dis
+# /dis/pipefile.dis
  /dis/plumb.dis
  /dis/plumber.dis
  /dis/prof.dis

Salva Peiró

unread,
Mar 19, 2008, 4:24:31 AM3/19/08
to infer...@googlegroups.com
if you've built and installed the compilers: 5{a,c,l}, doing

# the following is taken from guide.sds
cd os/ds
cp dsinit.b ../init
mk vclean
mk CONF=sds

should produce as a result a runnable isds.nds file.
In case you can't get it to work report the details in order to fix it.

On Wed, Mar 19, 2008 at 1:11 AM, David Leimbach <lei...@gmail.com> wrote:
>
> Ok.
> For whatever reason I don't remember how to cross compile from mac os x leopard.
>
> I'll try to get some time to check it out tonight
>
>


--
salva

saoret

unread,
Mar 19, 2008, 8:06:26 AM3/19/08
to inferno-ds

just another update:
with rev 65 i've added devaudio.c which performs an audio test at
startup,
it works for me both on the hardware and on the emulators.

David Leimbach

unread,
Mar 19, 2008, 10:26:44 AM3/19/08
to infer...@googlegroups.com
I get to mk CONF=sds and get:

mk: don't know how to make '/Users/dave/work/inferno-os/usr/inferno/lib/wmsetup'

David Leimbach

unread,
Mar 19, 2008, 10:42:20 AM3/19/08
to infer...@googlegroups.com
I copied inferno-os/lib/wmsetup to /inferno-os/usr/inferno/lib/wmsetup to satisfy that dependency... and now I get:

mk i5
mk i5.p9
mk: don't know how to make 'i5'
mk: cd arm7 mk ...  : exit status=exit(1)

when doing mk CONF=sds

David Leimbach

unread,
Mar 19, 2008, 11:21:26 AM3/19/08
to infer...@googlegroups.com
Alright, I keep forgetting my steps... :-)

here's what I ended up doing to make this build on Mac OS X Leopard.

1. I checked out inferno-os.
2. set up mkconfig to build for Mac OS X/386
3. build it :-)  (there are issues in the inferno-os issue list about problems with mk, but it seems to work ok)
4. Changed mkconfig for TARGET=Inferno and arm
5. cd os, and checkout inferno-ds code there.
6. cd inferno-ds
7. mk vclean
8. mk (or to use Salva's config mk CONF=sds).  I often have to edit the ds config to deal with missing .dis files 

I think that's correct but haven't had time to start from scratch to reproduce.

Dave

David Leimbach

unread,
Mar 19, 2008, 11:24:12 AM3/19/08
to infer...@googlegroups.com
Also key to this working is using Inferno's yacc.  It's good to do something like 

"export PATH=/path/to/inferno/MacOSX/386/bin:$PATH"

BEFORE you try to compile the whole OS and tools etc.

Mac OS X's yacc is bison which doesn't cut it for building Inferno.

Also on Mac OS X you may find you need to up your stack size to make the limbo compiler happy.  (ulimit).  That issue is at the inferno-os list too.

Dave

Salva Peiró

unread,
Mar 19, 2008, 11:33:00 AM3/19/08
to infer...@googlegroups.com
On Wed, Mar 19, 2008 at 3:26 PM, David Leimbach <lei...@gmail.com> wrote:
> I get to mk CONF=sds and get:
>
> mk: don't know how to make
> '/Users/dave/work/inferno-os/usr/inferno/lib/wmsetup'
>

That will make wm/wm show duplicated menu entries,
here is the lib/wmsetup i'm using:

% cat ../../usr/inferno/lib/wmsetup
#!/dis/sh script

menu '' ''
menu Kbd { wm/keyboard }
menu Halt { wmrun shutdown -h }

# rawdbfs $home/cal /mnt/schedule
# wmrun wm/calendar $home/cal &
# wmrun acme -a -c1 $home/guide &

wmrun wm/keyboard -t

--
salva

Salva Peiró

unread,
Mar 25, 2008, 5:50:46 AM3/25/08
to inferno-ds
i've done some progress on this:

fixed a bug where MRC/MCR where confused at the bottom of mpuinit,
which caused that some of the mpuinit setup being ignored.

with that fixed the vectors/vtable are being setup properly at 0x00000000
and it's possible to reach trap().

but for some reason that i haven't figured if the mpu enable bit
(CpCmpu) is set,
when an interrupt occurs it results in a nice panic (), instead of an interrupt:
"TRAP: SVC/SWI Exception in Undefined instruction"

I guess that's related with some use of the memory,
which contradicts the memory protection setup.

The good thing is that if you disable the the CpCmpu enable bit,
then you can get a kernel booting on the nds hardware
with interrupts, clockintr, and touchscreen working properly.

There're still some glitches, improvements and things to fix.

So here is the plan, with this working and a bit of help of the emulators
i think it won't be hard to get some devices working, here are my preferences:

- devdldi.c, or any other mean to access sd card storage
- devnds.c, touchscreen calibration, right now it's not very accurate
- devaudio.c, provide audio input/output & control settings
- devrtc.c, fix it to work properly both read/write access.
- devether.c, the big thing: get wifi working.
- any other thing, are suggestions welcome.

any takers?


On Tue, Mar 18, 2008 at 7:28 PM, saoret <saore...@gmail.com> wrote:
> and it can run without clockintr and touchscreen on the hardware.
>
> So we need to fix arm9 interrupts!
>
>

--
salva

David Leimbach

unread,
Mar 25, 2008, 5:57:49 PM3/25/08
to inferno-ds
I've managed to boot a version of the "ds" configuration (still can't
boot SDS), with some things stripped out as I don't have the
right .dis files for them anywhere available.

It gets to the GUI, after printing some messages about "touch worked"
even though I didn't touch anything. Then the kernel panics due to
arena sizes.

Still, I consider this pretty darned good progress.

David Leimbach

unread,
Mar 25, 2008, 6:01:46 PM3/25/08
to inferno-ds
Here's the crash screen:

alloc:D2B(a10fc): pool heap CORRUPT: chain hdr!=MAGIC_E at 23bbf38'73027709magic=65666e69)
arena too large: main size 8200 cursize 522688 arenasize 524544 maxsize 528384, alloc = 131136
bad Bhdr at 23bbf28: a110c 20 2025de4 065666e69 6f6e72 23ae328

David Leimbach

unread,
Mar 25, 2008, 6:03:02 PM3/25/08
to inferno-ds
Oops darn this google mail web thing and "tab".

I'll email a screenshot in a bit...

Dave

David Leimbach

unread,
Mar 25, 2008, 6:27:43 PM3/25/08
to inferno-ds
http://homepage.mac.com/leimy2k/inferno-ds-3-25-2008.MOV is a movie of this booting I just uploaded.  It doesn't fully panic like the screenshot I have attached.



On Tue, Mar 25, 2008 at 2:57 PM, David Leimbach <lei...@gmail.com> wrote:
Inferno-panic.JPG

Salva Peiró

unread,
Mar 25, 2008, 7:07:26 PM3/25/08
to infer...@googlegroups.com
well, lets see if we can get a nice video of inferno booting properly :)
i'll contact you off-list

On Tue, Mar 25, 2008 at 11:27 PM, David Leimbach <lei...@gmail.com> wrote:
> http://homepage.mac.com/leimy2k/inferno-ds-3-25-2008.MOV is a movie of this
> booting I just uploaded. It doesn't fully panic like the screenshot I have
> attached.
>
>
> On Tue, Mar 25, 2008 at 2:57 PM, David Leimbach <lei...@gmail.com> wrote:
>
> >
> > I've managed to boot a version of the "ds" configuration (still can't
> > boot SDS), with some things stripped out as I don't have the
> > right .dis files for them anywhere available.
> >
> > It gets to the GUI, after printing some messages about "touch worked"
> > even though I didn't touch anything. Then the kernel panics due to
> > arena sizes.

--
salva

Reply all
Reply to author
Forward
0 new messages