[U-Boot] CONFIG_SYS_FDT_PAD: Why do we need this?

Dirk Behme dirk.behme at googlemail.com
Sun Mar 25 08:59:18 CEST 2012

In boot_relocate_fdt() [1] we increase the size of the loaded fdt by a 
predefined, hard coded CONFIG_SYS_FDT_PAD. The basic idea seem to be 
to create some space for adding additional information later, like the 

I wonder why we have to do this by a hard coded, predefined value 
(which is most probably always to large)? Why can't we increase 
'totalsize' in the fdt_header just if we add anything? Individually by 
the size of the element added, at runtime? E.g. by anything like [2]?

I debugged a system were

#define CONFIG_SYS_FDT_PAD 0x3000

was used. These 0x3000 are added to totalsize before something is 
added at all. Then, if an element is added, always the whole 0x3000 
bytes have to be memmoved additionally. And in the end only ~0x100 
additional space was really needed.

Best regards




static int _fdt_splice_struct(void *fdt, void *p,
			      int oldlen, int newlen)
	int delta = newlen - oldlen;
	int err;

	if ((err = _fdt_splice(fdt, p, oldlen, newlen)))
		return err;

	fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta);
	fdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);
+	fdt_set_totalsize(fdt, fdt_totalsize(fdt) + delta);
	return 0;



More information about the U-Boot mailing list