2006-09-17
Factor code to upload to the S1 MP3 Player
Futher to my post on using Factor to program the S1 MP3 Player, I got some basic code working to upload Z80 code and execute it.
It requires updates to the usb code in my Factor repository:
darcs get http://www.bluishcoder.co.nz/repos/factor
I've created a darcs repository to host the code. It's best to get the repository from within the Factor 'contrib' subdirectory so you can use the standard module system to load the code:
darcs get http://www.bluishcoder.co.nz/repos/s1mp3
libusb must also be installed. Once all that's done you can test things out by plugging in the MP3 player and navigating to the 'Update Firmware' menu option. The MP3 player then sits waiting to receive code.
The following will load a Z80 assembled file called 'test.bin', upload it to the MP3 player and start executing it:
"contrib/s1mp3" require
USE: s1mp3
"test.bin" s1mp3-run-file
The Z80 file must be assembled with an origin of 0x3400. For a quick test I've included in the repository Carlos Aguilar's LCD autodetect program. The binary is in 'detect/detect.bin' and can e sent to the player with:
"contrib/s1mp3/detect/detect.bin" s1mp3-run-file
This should find details about the LCD display on the device and display it. Hopefully this code will work on all supported Factor platforms as long as libusb is available. This covers Windows, Linux and Mac OS X that I know of.
If you get errors due to 'permissions' it may be because your user does not have permission to access the USB device directly. On Linux this can be fixed by running Factor as root. A better option though is to set up hotplug or udev to change the permission on the device when it is plugged in so you can access it.