I have imx7d-pico with Carrier board.
...
I have issue: Reading file would overwrite reserved memory ** Failed to load hello_world.bin,
Your use of an SoC that has both a microprocessor and an auxiliary microcontroller with shared memory is a salient point. Refer to the NXP Appnote (esp. Table 5) for details. The use of multiple memory address ranges probably makes your problem a boundary case that U-Boot developers may have overlooked.
很显然,U-Boot在能够装上空间的档案(可能是为了帮助发现错误)方面,已经变得更加严格。 液压板结构的垃圾堆放清楚表明,某些U-Boot指挥部只能获取主要记忆,即0x80000至0xbfffff。 由于获得辅助处理器记忆的地址空间(0x7f8000至0x7fff)不属于这一主要记忆范围,因此这一附属记忆区无法由各种负荷文件指挥所解释。
错误信息的根源在于U-Boot的“图书馆”,lib/lmb.c。 程序lmb_init_and_serv()仅根据U-Boot的遗产定义分配现有(因而可装)记忆空间。
遗产法依靠宏观定义,如CFG_SYS_SDRAM_BASE,通常在一份针对理事会的负责人档案中加以界定。 例如,以下定义摘自include/configs/imx7-cm.h><<>>>/strong>:
#define CFG_SYS_SDRAM_BASE PHYS_SDRAM
#define CFG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR
#define CFG_SYS_INIT_RAM_SIZE IRAM_SIZE
然后在common/pad_f.c上,SDRAM基面地址被分配到用于U-Boot使用的RAM基面地址的全球数据变量上:
static int setup_dest_addr(void)
{
...
gd->ram_base = CFG_SYS_SDRAM_BASE;
委员会信息结构的第一个记忆库后来填充了common/板_f.c的全球数据记忆:
__weak int dram_init_banksize(void)
{
gd->bd->bi_dram[0].start = gd->ram_base;
gd->bd->bi_dram[0].size = get_effective_memsize();
return 0;
}
这是后来用于填充LMB结构(lib/lmb.c)的理事会记忆:
/* Initialize the struct, add memory and call arch/board reserve functions */
void lmb_init_and_reserve(struct lmb *lmb, struct bd_info *bd, void *fdt_blob)
{
int i;
lmb_init(lmb);
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
if (bd->bi_dram[i].size) {
lmb_add(lmb, bd->bi_dram[i].start,
bd->bi_dram[i].size);
}
}
lmb_reserve_common(lmb, fdt_blob);
}
So the Logical Memory Block "library" relies on U-Boot s legacy method for defining memory.
That means the memory definitions in the Device Tree are ignored by U-Boot.
When you try to load a file from a storage device to memory, the following procedure is called in fs/fs.c
#ifdef CONFIG_LMB
/* Check if a file may be read to the given address */
static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset,
loff_t len, struct fstype_info *info)
{
...
lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
lmb_dump_all(&lmb);
if (lmb_alloc_addr(&lmb, addr, read_len) == addr)
return 0;
log_err("** Reading file would overwrite reserved memory **
");
return -ENOSPC;
}
#endif
Note the conditional compilation for this routine that performs the memory check.
I tied to build a version of U-Boot 2022.01 without CONFIG_LMB, but the build failed. So even though CONFIG_LMB appears to be an optional library selection in the menuconfig, there seems to be source code changes needed to de-select CONFIG_LMB.
So you cannot try to bypass this memory check by building an alternate configuration of U-Boot.
A Workaround
Rather than try to define the aux memory as a bank of main memory, there is a simple & easy workaround to use a recent & unmodified U-Boot in your situation.
Instead of loading the file directly to the auxiliary processor memory, simply load the file to main memory at 0x80008000
, and then perform a copy of 32KB to the aux memory at tcm_addr
.
The loadm4image
variable should be changed to:
loadm4image=fatload mmc ${mmcdev}:${mmcpart} 80008000 ${m4image};
cp.b 80008000 ${tcm_addr} 8000
This can be accomplished with the following command to the previously posted environment:
setenv loadm4image fatload mmc ${mmcdev}:${mmcpart} 80008000 ${m4image}; cp.b 80008000 ${tcm_addr} 8000