The only major changes I made were to the DTS to add some of our custom hardware, and I ended up creating an entirely new Yocto layer to hold all our patches and changes to the already existing Atmel bsp. I have become somewhat familiar with working with Yocto project as a result.
Revision -20 of our product now has NAND flash. I decided that a good first step was to use the SAMA5D44-Xplained demonstration as a starting point. This is where I initially discovered a problem. After flashing the NAND flash demo using SAM-BA, the only output I would get was RomBOOT.
Initially, I thought it may have been a hardware error. After consulting with our electrical engineering team, they confirmed via oscilloscope that the NAND flash was operating correctly, and that it was properly being flashed. I dumped all the data of the NAND flash as well, and everything I flashed was there at the expected memory addresses as outlined in the SAMA5D4 memory map on Linux4Sam.
It was around this time that I discovered PMECC. I quickly realized that our NAND flash was a different model compared to the SAMA5D44-Xplained reference board. More specifically, our model was the MT29F2G08ABAEAWP, while the reference board contained MT29F4G08ABAEA. After reviewing PMECC, and reviewing the datasheets for our NAND module and the SAMA5D44, I was able to modify the header in the QML script provided by the NAND demo.
I determined that the new PMECC header should be 0xC0902405. After changing the script to reflect this, the AT91Bootstrap was successfully loaded into memory, followed by u-boot. However, u-boot reported multiple ECC errors. After some research, I realized that u-boot encodes the PMECC settings separately. At this point I realized using the default demonstration would not work very well without modification, so I broke out my Yocto build environment.
The first step of the process was to modify u-boot such that I could successfully load the Linux Kernel and Device Tree into memory. After researching u-boot for sometime, I identified two areas that required modification. The first change I made was to the sama5d4_xplained.h file in the u-boot source code. I realize that because we have a custom board, I should create my own header, however for the time being I am simply attempting to hack together a bootable image.
sama5d4_xplained.h before:
Code: Select all
#elif CONFIG_NAND_BOOT
#define CONFIG_SPL_NAND_DRIVERS
#define CONFIG_SPL_NAND_BASE
#endif
#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x40000
#define CONFIG_SYS_NAND_5_ADDR_CYCLE
#define CONFIG_SYS_NAND_PAGE_SIZE 0x1000
#define CONFIG_SYS_NAND_PAGE_COUNT 64
#define CONFIG_SYS_NAND_OOBSIZE 224
#define CONFIG_SYS_NAND_BLOCK_SIZE 0x40000
#define CONFIG_SYS_NAND_BAD_BLOCK_POS 0x0
sama5d4_xplained.h after:
Code: Select all
#elif CONFIG_NAND_BOOT
#define CONFIG_SPL_NAND_DRIVERS
#define CONFIG_SPL_NAND_BASE
#endif
#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x40000
#define CONFIG_SYS_NAND_5_ADDR_CYCLE
#define CONFIG_SYS_NAND_PAGE_SIZE 0x800
#define CONFIG_SYS_NAND_PAGE_COUNT 64
#define CONFIG_SYS_NAND_OOBSIZE 64
#define CONFIG_SYS_NAND_BLOCK_SIZE 0x20000
#define CONFIG_SYS_NAND_BAD_BLOCK_POS 0x0
#endif
I quickly realized our SDRAM settings are also different then the reference board. It turns out that the memory settings on our board are more analogous to the SAMA5D3-Xplained in that we have a similar version of NAND flash with the same specifications and identical SDRAM. Using this information, I modified the header for the sama5d4_xplained again and made the following changes:
Code: Select all
#define CONFIG_SYS_SDRAM_BASE 0x20000000
#define CONFIG_SYS_SDRAM_SIZE 0x10000000
#ifdef CONFIG_SPL_BUILD
#define CONFIG_SYS_INIT_SP_ADDR 0x218000
#else
#define CONFIG_SYS_INIT_SP_ADDR \
(CONFIG_SYS_SDRAM_BASE + 16 * 1024 - GENERATED_GBL_DATA_SIZE)
#endif
#define CONFIG_SYS_LOAD_ADDR 0x22000000 /* load address */
After making the above changes, I have some good progress. The below output is what I see when attempting to boot the board.
Code: Select all
RomBOOT
AT91Bootstrap 3.8.13 (Tue Oct 29 17:30:33 UTC 2019)
EEPROM: Loading AT24xx information ...
EEPROM: BoardName | [Revid] | VendorName
EEPROM: Using default information
EEPROM: Board sn: 0x1012420 revision: 0x680820
NAND: ONFI flash detected
NAND: Manufacturer ID: 0x2c Chip ID: 0xda
NAND: Page Bytes: 2048, Spare Bytes: 64
NAND: ECC Correctability Bits: 4, ECC Sector Bytes: 512
NAND: Disable On-Die ECC
NAND: Initialize PMECC params, cap: 4, sector: 512
NAND: Image: Copy 0xa0000 bytes from 0x40000 to 0x26f00000
NAND: Done to load image
<debug_uart>
U-Boot 2019.04-linux4sam_6.1 (Oct 29 2019 - 21:11:15 +0000)
CPU: SAMA5D44
Crystal frequency: 12 MHz
CPU clock : 600 MHz
Master clock : 200 MHz
DRAM: 256 MiB
NAND: 256 MiB
MMC: Atmel mci: 0
Loading Environment from NAND... *** Warning - bad CRC, using default environment
In: serial@fc00c000
Out: serial@fc00c000
Err: serial@fc00c000
Net: eth0: ethernet@f8020000
Hit any key to stop autoboot: 0
NAND read: device 0 offset 0x180000, size 0x80000
524288 bytes read: OK
NAND read: device 0 offset 0x200000, size 0x600000
6291456 bytes read: OK
=>
The next thing I noticed is that the FIT image has been read successfully, however neither the device tree nor the Linux Kernel are starting.
The next oddity is that there should be nothing at offset 0x200000. The ROOT FS is loaded at 0x800000, and I suspect that u-boot should not be responsible for loading this into memory, but rather the monolithic FIT Image.
Now, I suspect that either my u-boot settings are still incorrect OR it is time to modify my DTS such that it conforms to the correct NAND profile. Perhaps the FIT Image is loaded correctly, but it does not start because it to needs to know what NAND environment it is on?
My question regarding all this is, what exactly must I modify in the Kernel and the DTS (more generally the FIT Image) assuming this is the likely culprit? More generally, where can I find resources for all of these settings? Googling has not given me much details to work with. Ultimately, I want to understand every component of this boot process such that I can easily modify the AT91Bootstrap, U-boot, FIT Image and ROOT FS in the future for any given compatible NAND flash module. Thank you for your time in reading all of this!