Its alive!!!
So after getting really gatvol of trying to find info on this archaic CPU, I just did random google searches for “RM9200 boot” and I found a page by a chap named Darrell Harmon. Looking at the page, its been a while since he has been there, but, he did modify u-boot to run as the initial loader on an AT91RM9200. After some more searching I found his source code on another page.
I started by building in command line, this took a good bit of time, and was clunky, also, the code did not work. It built fine, and I got it to upload to the CPU via minicom, but it was unresponsive. Some digging in the source led me nowhere, and I was getting tired of using gedit and terminal to build, so I installed Eclipse CDT. Some fiddling with the bashrc script and the PATH variable had me building in eclipse, oh the joy of an IDE.
So I still had a problem, the code was unresponsive, inside I found a memory test that was deactivated, I rewrote this to make it smarter and more thorough, and ran the build. It failed. I then started printing my findings to the console, and found that I could access 256k of the 8MB of the SDRAM. Some scratching (read: 4 days) later I found that the SDRAM chip on my PCB was not compatible with the loader code. Diving into the datasheets of both the CPU and the RAM revealed some answers, and a quick patch to the code had the memtest working, awesome.
Now the loader runs in the device SRAM, and can run be used to load code into either SDRAM or a FLASH device. I wanted to get the loader written to the AT45 serial DataFlash on the board, as this would save some time in the boot sequence. A quick look at the code had me thinking it should work, alas, it did not.
Among my problems was the fact that to get the device into its initial bootloader, I had to short SDI and SDO together, as this is the only way to get the device to fail its boot sequence and revert to the initial bootloader. I thought this might be part of the problem, but soon foun it was not, as I’d remove the short before trying to write to the flash. I then modified the memtest code to run on the flash, and it failed. A substantial amount of probing later, I found that the WP line was held low, not allowing writes to the first page of the device. Modifying this allowed it to pass the memtest, so now its time to get the loader into flash. This went badly, so I tried to get it running out of SDRAM, and after some digging found that the base .text address was to blame, two mods to that had it running it both SDRAM and written to dataflash.
So now I could boot the board into known code with the option to reflash and modify as I pleased. It was time for u-boot. One of the ports for u-boot is a AT91RM200 based dev board from ATMEL called the AT91RM9200-DK or -EK depending on what version you had. I had never seen one, and the schematics looked lank different from my board. Some hacking would be in order. After a few hours of reading through the code and changing both setup and config code, it built and ran on the board. Awesome! The ethernet driver was dead though. After adding tons of debug code and getting familiar with PHY’s, something that I have never used, it was as simple as lifting the reset line on the PHY as its connected to the proccessor. Bingo, dhcp found itself an IP address.
So hopefully the next installment will have the board running a Linux kernel, and that will be awesome!
Here are some logs from the terminal:
Initializing SDRAM
Starting memory test.
Writing SDRAM.
Reading SDRAM.
SDRAM Memtest Passed.
Dataflash Memtest Passed.
1: Upload loader to Dataflash with vector 6 modification.
2: Upload u-boot to Dataflash.
3: Upload linux to Dataflash
4: Start U-boot
Please transfer u-boot.bin via Xmodem
Receiving Xmodem transfer
Dataflash write successful
1: Upload loader to Dataflash with vector 6 modification.
2: Upload u-boot to Dataflash.
3: Upload linux to Dataflash
4: Start U-boot
DataFlash:AT45DB321
Dataflash read successful: Starting U-boot
U-Boot 1.1.6 (Jul 24 2012 - 22:07:21)
DRAM: 8 MB
Atmel: Flash: 0 kB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
U-Boot>
U-Boot> setenv ethaddr 00:10:20:30:40:50
U-Boot> dhcp
Init Ethernet
Check Phy Connected... OK
Init Phy
Dumping Phy registers pre-init
Reset Phy
Waiting for reset
Reset Done
Dumping Phy registers post reset
No Link
No Link
Dumping Phy registers post init
Dumping Phy registers
Addr Boot Reset Init
Addr 00 0x3100 0x3100 0x3100
Addr 01 0x7829 0x7809 0x7809
Addr 02 0x0181 0x0181 0x0181
Addr 03 0xB881 0xB881 0xB881
Addr 04 0x01E1 0x01E1 0x01E1
Addr 05 0x45E1 0x0000 0x0000
Addr 06 0x0003 0x0000 0x0000
Addr 16 0x0600 0x0610 0x0600
Addr 17 0x8008 0xF000 0xF000
Addr 18 0x7800 0x7800 0x7800
Addr 21 0x0F00 0x0F00 0x0F00
Addr 22 0x0000 0x0001 0x0000
Addr 23 0x0000 0x0000 0x0001
Addr 24 0x04E0 0x04E0 0x04E0
Init Phy done
MAC: error during MII initialization
BOOTP broadcast 1
BOOTP broadcast 2
DHCPHandler: got packet: (src=67, dst=68, len=548) state: 3
Filtering pkt = 0
DHCPHandler: got DHCP packet: (src=67, dst=68, len=548) state: 3
DHCP: state=SELECTING bp_file: ""
TRANSITIONING TO REQUESTING STATE
Bootfile:
DhcpSendRequestPkt: Sending DHCPREQUEST
Transmitting DHCPREQUEST packet: len = 343
DHCPHandler: got packet: (src=67, dst=68, len=548) state: 4
Filtering pkt = 0
DHCPHandler: got DHCP packet: (src=67, dst=68, len=548) state: 4
DHCP State: REQUESTING
Bootfile:
DHCP client bound to address 192.168.0.3
*** Warning: no boot file name; using 'C0A80003.img'
TFTP from server 0.0.0.0; our IP address is 192.168.0.3; sending through gatewa4
Filename 'C0A80003.img'.
Load address: 0x20040000
Loading: T T T
Abort
U-Boot>








