It looks reasonable. You want to shift by 3 though, not 23, not 15, so you read from 0x1d0 for writing to the MRS.
OK, a few questions:
- Do I read32() from somewhere for _every_ RAM command or only for
MRS?
For every command. For commands other than "load MRS", you use address 0.
- The v1 code seems to read from the highest RAM address for each DRB register.
You need to do this init sequence for every rank of memory. Using each DRB gives you a lot of duplicates, which can be harmless; it can also give you 0 as the top-of-rank address (if the first ranks are empty) which is bad.
In my case: Get contents of DRB6 (0x8), shift left by 23 as the DRB registers store multiples of 8 MB, so I get my 64 MB. Correct?
Yes. So you need to address somewhere between the previous rank top, and this 64MB. Using the _previous_ rank top as-is might be best. Example:
rank 0 empty DRB=0 don't init rank 1 0..64MB-1 DRB=8 init @ 0 (+0x1d0) rank 2 64MB..128MB-1 DRB=16 init @ 64MB (+0x1d0) rank 3 empty DRB=16 don't init
Now; do I read32() from * (8 << 23) * (8 << 23) + 0x1d0 * 0x0 + 0x1d0 * 0x0 + 0x1d0 AND (8 << 23) + 0x1d0 * 0x0 * ???
You init exactly the memory that's there; nothing more, nothing less.
A useful trick is to temporarily set the DRB registers such that the one rank under consideration is mapped to address 0, all the rest disabled; only later set the full "real" DRB map. This might or might not make the code simpler, your choice.
Do I read from x for most commands but from (x + 0x1d0) for MRS? Or should I read from (x + 0x1d0) for all commands?
x for most commands. The 0x1d0 actually is the data sent to the MRS reg on the memory; it is sent over the address lines.
I've tried a lot of variations here, but nothing worked. Maybe some other parts of the code are still broken?
Could be, hard to tell.
Attached my latest code and a minicom log...
I'll see if I see anything.
Segher