Python on Nintendo DS

L

lickspittle

Hi,

I tried porting Python to the Nintendo DS, and it was surprisingly
easy. Installing something called devkitPro, devkitARM, libNDS, msys,
msys-DTK and then just using that to cross compile a python
installation.

Heres a screenshot of it running in the Dualis emulator. It runs
flawlessly for what has been compiled into it:
http://img520.imageshack.us/img520/2145/python240cj.jpg

You can download the source code to link against the static library and
add a method of input (which you can see in the picture). Also
included is a .nds file for running on your Nintendo DS:
http://files.filefront.com/NDSPythonStuffzip/;4497277;;/fileinfo.html

You click on keys on the touch screen to enter input. Notes: The
clicking on keys in the emulator is extremely non-responsive, on the
DS, it is perfect. Also, the emulators do not handle displaying the
right bits and pieces to the right screen, so the keyboard is displayed
on the top screen and the console on the touch screen (so its kind of
hard to use as you can't see the regions on the touch screen to click
on). The .nds file can be recompiled to use the lcd screens right for
emulators, but the .nds file was compiled to work correctly on a DS.

A problem.. On Dualis, the interpreter works perfectly. However, on
the Nintendo DS, it is completely unreliable and seems to corrupt at
random points. Occasionally you can get to the command line and enter
one command or two, but its guaranteed to corrupt at some point. I
have no idea why this is. I have to assume that Dualis implements the
processor and hardware specs more flexibly than they actually are on
the DS. And that there is some way the compilation options or linking
options can be modified to restrict the output to what the DS can
actually run.

If anyone has the time and interest to give it a shot at getting it
working, you will need a Nintendo DS with some form of homebrewing
hardware which lets you put storage mediums into the DS with custom
media.. like compiled .nds files. I use a Supercard, the compact flash
version.

As for the installation of tools required to compile .nds files, I used
the following page:
http://www.double.co.nz/nintendo_ds/nds_develop1.html
Then I went to the mingw sourceforge page and got msys-dtk and
installed that so that I would have autoconf and automake.
Then I extracted Python2.4 source code and opened a dos console, cd to
the directory with the Python source code and type the following:

set BASECFLAGS=-mcpu=arm9tdmi -mtune=arm946e-s -ffast-math -mthumb
-mthumb-interwork -DARM9
set CFLAGS=-mcpu=arm9tdmi -mtune=arm946e-s -ffast-math -mthumb
-mthumb-interwork -DARM9
set LDFLAGS=-specs=ds_arm9.specs -g -mthumb -mthumb-interwork
-Wl,-Map,libpython2.4.map
sh configure --host=arm-elf

This should give you a makefile, now you need to edit it. Change AR to
have a value of arm-elf-ar (configure doesn't pick that up properly).
Also, where there are references to OBJECT_OBJS, you need to also enter
NDS_OBJS to get included along with it. And enter the following in the
makefile somewhere, maybe after OBJECT_OBJS

NDS_OBJS = RISCOS/Python/getcwd_riscos.o

Also, go into Modules and edit Setup. Comment out all four of the
modules still listed uncommented in the same block, posix, errno, ...
Now in the top level python source code directory, type make.
It should make and then error claiming it can't link against some
function to do with ThreadState, locate all calls of that function in
Python/pystate.c and comment them out -- this is a bug in the Python
2.4.2 source distribution that pops up when threads are disabled. Now
it should compile the static library and error on the python.exe (which
is of no use to us).

You should now be able to compile the contents of NDSPythonStuff.zip
against that library (you'll need to make cosmetic changes to the
Makefile of course).

Anyway, if anyone can help with working out how to change the
compilation or linking options to get the code to work properly on the
DS, please email me.
 
R

Richard Tew

Updated: http://www.disinterest.org/NDS/Python24.html

- Worked out why it was working sporadically (Supercard requires the
NDS loader to be prepended to ROMs). I assumed I was getting a ROM
created with the loader/forgot that it was required, since it even ran.
- Hooked it up to FAT file system code that can read and write to the
compact flash card in the GBA slot (Supercard in my case).
etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top