Hello,
while writing a memory map of the default NAND flash on DM365 EVM, I've noticed a potential problem and I'd like to have confirm of it. My EVM uses a Micron MT29F16G08FAA flash chip, with this configuration:
Page size: 2048 + 64 bytes
Block size: 64 pages, 128KB (0x20000) bytes of data
Device size: 16Gbit, 16384 blocks
The default system configuration is this:
RBL searches for UBL in blocks 1-24, skipping bad blocks. UBL fits into 1 block, so addresses from 0x20000 to 0x31FFFF are reserved for UBL.
UBL searches for the main bootloader (U-Boot) in blocks 25-50. This means that addresses from 0x320000 to 0x65FFFF are reserved for U-Boot.
Checking the U-Boot source code, it seems to me that on DM365 its configuration is stored at fixed address 0x3C0000 up to 0x3FFFFF. This is defined in U-Boot source code's DM365 config and in the Linux kernel itself (partition sizes are hard coded). Notice that with 128KB blocks, address 0x3C0000 is block 30, well within the range 25-50.
Then the Linux kernel is commonly stored at address 0x400000, that is block 32, again in the range 25-50. Notice that this is defined in the linux Kernel (again hard coded) and also documented in a lot of readme and wiki pages for DM365.
Also NANDWriter addresses the flash using block numbers (i.e. 1-24, 25-50) while U-Boot and the linux Kernel use hard addresses. This means that the addresses can easily get wrong if the actual block size of the flash is not correcly accounted for. Perhaps this already happened.
One last point I still have to check is what happens if all blocks in the range 25-49 are bad. My U-Boot binary is over 128KB, so it uses at least 2 blocks and another block is required for the header (what a waste!). Probably it is better not to write the config before block 54 and the kernel starting from block 56 (just to be safe).
What happens when using NAND with block size of 4K or 8K? If I am correct the problem can even get worse.
Please tell me I am wrong...