ZipCPU / arrowzip

A ZipCPU based demonstration of the MAX1000 FPGA board
21 stars 5 forks source link

hello.c #5

Closed NeuerUser closed 5 years ago

NeuerUser commented 5 years ago

I'm having problems to get any output from the test program "hello".

$ ./wbregs version; ./wbregs buildtime
00800014 ( VERSION) : [....] 20190308
00800000 (BUILDTIME) : [....] 00081204

When I start zipload 'hello' the first time, I get an error:

 time ./zipload -v -r ../board/hello
ZipLoad: Verbose mode on
Halting the CPU
Loading: ../board/hello
Sending to flash: 01000000-01000134
Sending to flash: 01000134-01004a54
ERASING SECTOR: 01000000
Erasing sector: 000000
SECTOR ERASE FAILED!
ERR: Could not write program to flash

real    1m18.194s
user    0m0.323s
sys     0m1.361s

This seems to be the flash erase.

Starting a second time, no flash erase is done. Instead the code is written:

$ time ./zipload -v -r ../board/hello                                                            ZipLoad: Verbose mode on
Halting the CPU
Loading: ../board/hello
Sending to flash: 01000000-01000134
Sending to flash: 01000134-01004a54
Writing page: 0x01000000 - 0x010000ff
Writing page: 0x01000100 - 0x010001ff
Writing page: 0x01000200 - 0x010002ff
Writing page: 0x01000300 - 0x010003ff
[...]
Writing page: 0x01004900 - 0x010049ff
Writing page: 0x01004a00 - 0x01004aff
Clearing the CPUs registers
Setting PC to 01000000
Starting the CPU
CPU Status is: 0000000f

real    8m22.885s
user    1m45.880s
sys     4m4.044s

After taking this 8,5 min, there is no output visible, neither on telnet session, nor on the netuart console.

If I read the code correctly (which is rather small), it should output "Hello, world!".

ZipCPU commented 5 years ago

Yes, you should see "Hello, world!" printed onto the console on the telnet port if this program works.

As for the "SECTOR ERASE FAILED" message, I've chased it down some. The issue appears to be that the flash isn't setting the status register properly to indicate that the flash is busy. Hence, the controller checks the results of the (still in progress) erase, reads that the erase is no longer busy (when it is), and then starts to read from memory--getting a bad result. When you read from the flash later, once the flash has finished erasing the memory, then the zipload program sees that the erase is no longer needed and then successfully programs the flash.

Given that the flash isn't returning the right value, I'm not yet certain how to "break the protocol" to fix things. Perhaps reading the status register twice?

Next, you will also need to rebuild the hello.c program since I adjusted the board linkscript that it depends on. That and your problem may be the SDRAM, so let's make sure that the memtest passes first. Based upon your other issue, it isn't.

NeuerUser commented 5 years ago

Now working after fixing SDRAM. :+1: