u-boot ERROR: Failed to allocate 0x5c6f bytes below 0x17ffffff.Failed using fdt_high value

本文档详细记录了在U-Boot启动过程中遇到的内存分配失败错误,错误源于lbm模块。通过分析代码,发现在board/platform/board.c中缺少dram_init_banksize()函数来设置内存信息。修复方案是在相关文件中添加和修改函数以正确初始化内存池,并确保内存分配。修复后,U-Boot能够成功加载内核和设备树。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

## Loading kernel from FIT Image at 08000000 ...
   Using 'config_0x775E@1' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel@1' kernel subimage
     Description:  Linux kernel
     Created:      2022-08-06  10:42:14 UTC
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x080001e8
     Data Size:    4049224 Bytes = 3.9 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x00008000
     Entry Point:  0x00008000
     Hash algo:    crc32
     Hash value:   5716757b
   Verifying Hash Integrity ... crc32+ OK
## Loading fdt from FIT Image at 08000000 ...
   Using 'config_0x775E@1' configuration
   Trying 'fdt_775E@1' fdt subimage
     Description:  775E device tree
     Created:      2022-08-06  10:42:14 UTC
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x083fd9fc
     Data Size:    11375 Bytes = 11.1 KiB
     Architecture: ARM
     Hash algo:    crc32
     Hash value:   2eda7b23
   Verifying Hash Integrity ... crc32+ OK
   Booting using the fdt blob at 0x83fd9fc
   Uncompressing Kernel Image ... OK
ERROR: Failed to allocate 0x5c6f bytes below 0x17ffffff.
Failed using fdt_high value for Device TreeFDT creation failed! hanging...### ERROR ### Please RESET the board ###

解决办法:
通过搜索错误代码,定位到时u-boot的lbm模块出了问题:
lbm:Logical memory blocks.
lbm使用全局的gd->bd->bi_dram[0].start和gd->bd->bi_dram[0].size作为自己内存池管理

common/board_f.c

static int setup_dram_config(void)
{
	/* Ram is board specific, so move it to board code ... */
	dram_init_banksize();

	return 0;
}

board/platform/board.c 中增加如下代码:

void dram_init_banksize(void)
{
	gd->bd->bi_dram[0].start = PHYS_SDRAM_1_BASE;
	gd->bd->bi_dram[0].size = gd->ram_size;
}

common/bootm.c

#ifdef CONFIG_LMB
static void boot_start_lmb(bootm_headers_t *images)
{
	ulong		mem_start;
	phys_size_t	mem_size;

	lmb_init(&images->lmb);

	mem_start = getenv_bootm_low();
	mem_size = getenv_bootm_size();

	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);

	arch_lmb_reserve(&images->lmb);
	board_lmb_reserve(&images->lmb);
}
#else
#define lmb_reserve(lmb, base, size)
static inline void boot_start_lmb(bootm_headers_t *images) { }
#endif

u-boot/arch/arm/lib/bootm.c


void arch_lmb_reserve(struct lmb *lmb)
{
	ulong sp;

	/*
	 * Booting a (Linux) kernel image
	 *
	 * Allocate space for command line and board info - the
	 * address should be as high as possible within the reach of
	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
	 * memory, which means far enough below the current stack
	 * pointer.
	 */
	sp = get_sp();
	debug("## Current stack ends at 0x%08lx ", sp);

	/* adjust sp by 4K to be safe */
	sp -= 4096;
	lmb_reserve(lmb, sp,
		    gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size - sp);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值