MP3TSi: Home | News Archive | Developer Guide | External Input | ISA MP3 Card | ECU Security | Colour LCD | FAQ | External Links | email me


Developer Guide

Important Notice

I apologize; I didn't update the header on this page, so my email address was not valid. I did not intend to come off as a snob by not answering email sent to the previous address; I just didn't get the mail. Sorry! I've corrected the address; please try sending again.

Introduction

Okay, so you bought a PJRC MP3 player. What have you gotten yourself into? A whole lotta fun, that's what! But it could be a bit frustrating if you just have to look at code and schematics alone to figure out the details and caveats of developing for this amazing project. So hopefully, you will find plenty of useful information here.

Yeah, yeah, get to the good stuff already!

Okay, this is a work-in-progress. I try to update as I learn new things.

8051 architecture

Visit one of these sites for a tutorial on 8051 (important!):

They're remarkably similar. I don't know who the author is, but he deserves big credit for the excellent tutorial.

Setting up a build environment

Source code management

Use CVS if you have Linux, and if you're using Windows, get TortoiseCVS or WinCVS. TortoiseCVS integrates with Windows Explorer, making life so much easier on a Windows machine. Please read the instructions, however, and also familiarize yourself a little with CVS in general (search on the web for 'cvs manual' or 'cvs faq' or similar).

Here are some tips for command-line CVS in Linux:

Building new firmware

You will need to make jw002.asm writeable, or the build will fail. The reason is that jw002.asm gets copied to lcd.asm, but lcd.asm gets modified after that (it must be writeable, so the source it was copied from must be writeable as well). To fix jw002.asm, go to your working directory and type chmod +w lcd.asm and the file will become writeable. Now, all you need to do is type make from your working directory. You can use make clean to erase the intermediate/temporary/compiled data, then make again to ensure that your copy is as fresh as possible.

Update: Tom Parker suggested that one can do an "authenticated" (or was it "authorized"?) checkout, which will make all the files in your working directory (your local copy) writeable, so you won't need to fiddle with jw002.asm.

Uploading new firmware

After a successful build, you'll have several options, depending on what you modified. First, though, you need to get to the PaulMon2 (PM2) prompt. There are two ways. The easiest is to type QUIT (or possibly " QUIT", that's [space]QUIT) while the player is running. The second (more reliable, but trickier, because it involves timing) is to press S when the player starts up (as soon as possible after power-up). A PM2 prompt is fairly obvious, but I may include a screen shot here eventually. Anyway, now it's option time...

Fast firmware upload

There are some things to watch out for with the fast firmware upload on Win systems. One is, if you're using CygWin, you'll probably need to make a soft-link for perl. The hex2fdl script, for example, expects to find perl in /usr/bin, and on my system, it was in /CygDrive/c/Perl/bin (ActivePerl's default installation directory). You can just make a soft-link in /usr/bin called "perl" which points to the actual executable (eg. "ln -s /CygDrive/c/Perl/bin/perl /usr/bin/perl"). The other issue is that (currently, anyway), newlines get mangled into CRLFs on Win-type systems, so you'll need to tweak hex2fdl a bit by adding the ":raw" layer directive to the binmode near the top.

Musings

On my laptop, Linux compiles faster than Windows, especially the "peephole" stuff. I don't have any timings, but the difference is obvious to me.

If you're doing C development, a good place to start learning is the memory management. It's important to understand how the [A|a]ddr[5|6|7] functions work or at least what they do. Basically, memory is always allocated in 4K-byte blocks, and these blocks may be mapped into the 8051's address space. There are limitations: you may map, at most, any 3 blocks at a single time. Obviously, you must map a block before you can use the memory at that block. More on this subject later...

PJRC glossary

In the code, you will come across particular expressions; here are meanings of some:

Setting up a dual-boot Win/Linux machine

I am running a laptop that dual-boots NT and Linux. It was was a little tricky to set up, because my particular laptop (a used IBM Thinkpad 760ED) is a bit of a strange one. The serial port was disabled when I bought, and the BIOS setup has no facility to enable/disable it. It had to be done with a driver disk from IBM. If you are using only Linux, try the this site. I had to disable the IR serial port's IRQ before I could enable the COM1 serial port. That's fine, because I don't intend to use the IR port. You should be able to figure out the utility, but you can email me for help if you need to.

For a dual-boot NT/Linux setup on a 2GB drive, I first installed Linux (Debian potato 2.2), with partitions similar to the following layout (this is my table after installing NT, however -- you can see that the NT partition became the boot partition after NT was installed. NT is fine with placing the boot loader pretty much anywhere on the disk, AFAIK. Here's the table (as seen in cfdisk 2.10f):
Name FlagsPart TypeFS Type[Label]Size (MB)
hda1 PrimaryLinux ext2 10.33
hda5 LogicalLinux swap 33.04
hda6 LogicalLinux swap 33.04
hda7 LogicalLinux ext2 999.17
hda3BootPrimaryFAT16[NO NAME ]1038.39
I installed LILO on the boot partition (at the start of the disk), and when I reached a root shell, I used the dd command (in my case, I believe it was dd if=/dev/hda1 of=/linux.boo bs=512 count=1) to copy the boot sector to a temporary file (linux.boo). Then I stuck in a disk, did mount /floppy, then cp linux.boo /floppy, and finally umount /floppy. Make a copy on another floppy just in case the first is bad (never trust floppies). Then install NT. Finally, copy linux.boo into NT's root directory (in my case, C:\), and add a line to BOOT.INI that says something like c:\linux.boo="Linux". Oh yeah, you'll have to unhide/unsystem/unreadonly the file with attrib or whatever first (and restore the attributes after your change). Restart, and you should have dual-boot working.

You'll also need to install AS31 and SDCC. You can find a link to a stable version on the PJRC file area on Yahoo Groups, or at PJRC.com. If you get the Linux version, you'll need to build it and install it. You'll obviously need the common development packages (gcc, etc) to build AS31 and SDCC. You'll need the gtklib library to build AS31. You may need to install other packages as well in order to build SDCC. Go to the AS31/SDCC page for more help.

1