OK, so here’s my tutorial on getting my 65C02 Simulator to run on a Raspberry PI – bare metal style.
This is for an original PI 1. I have a B model with 256MB of RAM.
First you need to download the minimal boot files that will allow the GPU and ARM to initialize and prepare to boot. I got mine from this GIT repository:
https://github.com/raspberrypi/firmware ... aster/bootThe files you need are:
bootcode.bin
start.elf
When the PI powers up, the GPU will start running from an internal ROM image. It will then set itself up and load the two files above. Those will be used to further set up the GPU and ARM. When it’s all done, it will look on the SD card for a file named kernel.img. This file usually contains the code to boot Raspian Linux or some other OS. We will be creating our own file to do whatever we want to do.
David Welch put together a great tutorial site, located here ->
https://github.com/dwelch67/raspberrypiI am using his bootloader06 app to provide an easy xmodem file transfer of my target kernal.img file. In this way, I don’t need to remove/install the SD card a thousand times. It uses the UART02 located on the 40 pin GPIO header. Gnd is on pin 6, TX is pin 8, and RX is pin 10. I connect a cheap USB to TTL serial adapter to the GPIO header for connection to my PC. I also installed a 2 pin header on my board at P6, near the RG2 voltage regulator. In this way, I can add a momentary switch to the header which will reset the PI and start the boot loader. You can download the bootloader’s kernel.img file from David’s site here ->
https://github.com/dwelch67/raspberrypi ... kernel.imgA quick note, the kernel.img file expects to get loaded at RAM address 0x8000. The bootloader is installed and moved to RAM at 0x200000. This restricts your kermal.img file to about 2Mb.
Put those three files on your SD card and insert it in your PI, connect your serial cable, and boot it up.
Your terminal needs to be set for 115200,N,8,1 with no handshaking. You should see a small prompt similar to this:
12345678
002002B8
00008000
Then you will get a slow addition of the “section sign” symbol. This is telling you to start an xmodem download. The protocol uses the checksum error detection vs. the CRC error detection, so if you need to select one, be sure its checksum.
My 65C02 Simulator is a 104Kb file called “kernel.bin” It takes about 25 seconds to download. Once the download is done, you’ll get a “DADADADA” response meaning good data transfer. If you see a message like “00BADBAD”, something went wrong and try again. Once you get a good transfer, just press “G” and the bootloader will transfer execution to your program.
If all went well, my SBC2OS prompt will appear on your terminal. You also rename my simulator file to kernel.img and replace the bootloader kernel.img file on the SD card to boot direct to the simulator.
I compiled my C code using GCC v4.7 as David recommended. I’m using Windows 10 so I created a batch file to run the GCC toolchain. My first release is running at a measly 1.1MHz. I plan to try a newer version of GCC. The C code is mostly the same as the one I ran on my other ARM dev board, which ran at about 7.5MHz from a 300MHz ARM. I clearly have some more work to do.
It’s a start, and can only get better and faster. I want to work on the C code before I release it, but I will include the current binary for others to give it a spin.
I'm attaching the 3 boot files and my Simulator binary in the enclosed ZIP.
I will try to put together a similar tutorial for the PI2, as I have one of those around too.
Thanks!
Daryl