Hi Scott,
I couldn't wait any more for you to fix this for me, so I have fixed it myself
http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/wink.gif
I compared the datasheets for the AMD29LV065D and the AMD29LV128 and noticed that the difference is that the erase and program commands need to be written to specific address for the AMD29LV128 whereas the AMD29LV128 does not care where the commands are written to. I changed the code in flash_erase() in AMDLV065D.c from
writeb (addr, 0xaa);
writeb (addr, 0x55);
writeb (addr, 0x80);
writeb (addr, 0xaa);
writeb (addr, 0x55);
writeb (addr2, 0x30);
to
writeb (0xaaa, 0xaa);
writeb (0x555, 0x55);
writeb (0xaaa, 0x80);
writeb (0xaaa, 0xaa);
writeb (0x555, 0x55);
writeb (addr2, 0x30);
This change allowed u-boot to erase sectors in my flash. Then I changed the code in write_buff() in AMDLV065D.c from
writeb (cmd, 0xaa);
writeb (cmd, 0x55);
writeb (cmd, 0xa0);
writeb (dst, b);
to
writeb (0xaaa, 0xaa);
writeb (0x555, 0x55);
writeb (0xaaa, 0xa0);
writeb (dst, b);
This change allowed u-boot to write data into my flash. So far so good! But I haven't worked out how to use u-boot reliably.
I have copied u-boot.bin to address 0x0 in flash so that it boots when I reset the board. I have made an s-record image of my application and then downloaded it into flash at 0x00050000 using the u-boot commands protect off / erase/ loads 0x00050000. If I then read the file back from flash using saves then I can verify that u-boot has correctly written the file to flash.
I have tried to start the app using the u-boot commands:
cp 0x00050000 0x02000020 0x8000
go 0x020001c8
This works sometimes, but not every time. When it fails, it fails after the cp command. I think the problem is due to overwriting the exception address at 0x02000020. I am only using the SRAM on my dev board, and TEXT_BASE for u-boot has been set safely high in SRAM at 0x021E0000.
I have also tried building a binary file that includes the Altera bootloader (As made by the flash programmer in the IDE). When I use that image I can sometimes start it by simply using the command go 0x00050000 which causes the app to copy itself to SRAM and start running. But this doesn't work every time either.
The bootm command sounds good as it disables interuupts before copying the image, but I don't have the mk-image tool.
Can you tell me a few basic steps to make a binary file, download it into flash at an address above 0x0 and then execute it? I think I am close, but I am also stuck.
Thanks,
Mike