Hello,
Answering my own question, the reason for the crash is the behavior of i.mx8m DDR driver.
The driver assumes that the size of the last firmware image (ddr4_dmem_2d.bin or lpddr4_pmu_train_2d_dmem.bin) is 16K and accesses the memory beyond 256K of TMU, causing the exception. We were able to modify the driver and avoid the crash.
Looking at the sizes of LPDDR4 firmware,
-rw-r--r-- 1 felix felix 1668 Oct 15 09:50 lpddr4_pmu_train_1d_dmem.bin
-rw-r--r-- 1 felix felix 32244 Oct 15 09:50 lpddr4_pmu_train_1d_imem.bin
-rw-r--r-- 1 felix felix 1380 Oct 15 09:50 lpddr4_pmu_train_2d_dmem.bin
-rw-r--r-- 1 felix felix 23232 Oct 15 09:50 lpddr4_pmu_train_2d_imem.bin
we can see that lpddr4_pmu_train_1d_dmem.bin and lpddr4_pmu_train_2d_dmem.bin are actually less than 2K.
The same is true for DDR4 firmware:
-rw-r--r-- 1 felix felix 16384 Nov 4 17:45 ddr4_dmem_1d.bin
-rw-r--r-- 1 felix felix 1436 Nov 4 17:45 ddr4_dmem_2d.bin
-rw-r--r-- 1 felix felix 32768 Nov 4 17:45 ddr4_imem_1d.bin
-rw-r--r-- 1 felix felix 23772 Nov 4 17:45 ddr4_imem_2d.bin
The ddr4_dmem_1d.bin is 16K but in fact it is zero-padded, with actual size being less than 2K.
The i.MX8M DDR driver assumes that the size of dmem firmware files is 16K, see helper.c\imx8m\ddr\drivers - uboot-imx - i.MX U-Boot
The imx-mkimage Makefile ensures the padding of dmem files to 16K: soc.mak\iMX8M - imx-mkimage - i.MX Mkimage Bootloader Tool
Looks like padding dmem files to 4K should be sufficient. This can avoid redundant copying of almost 100K of padding, since dmem files are copied to and from DDR PHY 4 times.
My question is: is it safe to assume that 4K padding of dmem files is sufficient ? My experiments show this to be true, but I'd be happy to get a confirmation from NXP DDR experts.
Felix.