Hi Igor,
I discovered what problem was happening.
The problem was that the data loaded to addresses that end with 0xb58 and 0xb5c starting from 0x7e3b58 got corrupted when booting from NAND, so the u-boot SPL triggered an exception caused by invalid instruction when executing from one of these addresses and stopped.
Using the exact same image to boot from the SD card did not show this problem and was successful.
I first thought that this problem could have happened because of corruption of the NAND, but I nandumped the SPL load addresses without ecc (nanddump -n) and there was no error at all.
The way that the data is corrupted is somewhat curious because only the 3 lower bytes from 0xb58 and the 3 higher bytes from 0xb5c are corrupted and the data is repeated in all of them. For example:
Corrupted data:
7e3b58: 52e3f3df
7e3b5c: 00000060
7e4b58: 6be3f3df
7e4b5c: 000000a1
7e5b58: 9ae3f3df
7e5b5c: 00000033
(...)
7fcb58: 00e3f3df
7fcb5c: 00000000
7fdb58: 00e3f3df
7fdb5c: 000000c1
7feb58: 04e3f3df
7feb5c: 0000006f
Correct data:
7e3b58: 52800021
7e3b5c: 52800960
7e4b58: 6b00003f
7e4b5c: 540002a1
7e5b58: 9ad70820
7e5b5c: d1004033
(...)
7fcb58: 007f6fcc
7fcb5c: 00000000
7fdb58: 00000000
7fdb5c: 000137c1
7feb58: 00000000
7feb5c: 00000000
I did a crazy workaround, allocating an address of static data that is filled in the binary after compilation with the correct data for those addresses. Then I call a function right in the beginning of board_init_f that loads these data to their addresses, overwriting the corrupted data.
I just need to be sure that this part of the code will not fall in one of the damaged regions and the code runs perfectly after that.
This looks like a ROM bug or my NAND is not compatible with it. Maybe it's related to the NAND page size (4K - similar problem described here), which is also the offset between corrupted addresses. You can escalate this information to the design team if you will. I think that this should be fixed for future revisions or at least documented in an errata. An error like this undocumented is unacceptable.
Best regards,
Fernando.