Question about Device Trees

Im trying to get support for the USG3P going but im struggling to understand the concept of the device tree loading.

As far as i know the u-boot environment should have the device tree set, but thats not the case for the Edge Router Lite thats already supported by LEDE (i cant verify that)

In the following thread some people posted their u-boot env output

No FDT stuff or DTB referenced.

I digged into the official gpl archives and found the following code in arch/mips/cavium-octeon/setup.c

arch/mips/cavium-octeon/setup.c
void __init device_tree_init(void)
{
	int dt_size;
	struct boot_param_header *fdt;
	bool do_prune;
	bool do_set_mac = false;
	if (octeon_bootinfo->minor_version >= 3 && octeon_bootinfo->fdt_addr) {
		fdt = phys_to_virt(octeon_bootinfo->fdt_addr);
		pr_info("Using passed Device Tree <%p>.\n", fdt);
		if (fdt_check_header(fdt))
			panic("Corrupt Device Tree passed to kernel.");
		dt_size = be32_to_cpu(fdt->totalsize);
		do_prune = false;
	} else if (OCTEON_IS_MODEL(OCTEON_CN68XX)) {
		fdt = (struct boot_param_header *)&__dtb_octeon_68xx_begin;
		dt_size = &__dtb_octeon_68xx_end - &__dtb_octeon_68xx_begin;
		do_prune = true;
	} else if (octeon_bootinfo->board_type == CVMX_BOARD_TYPE_UBNT_E100) {
		switch (octeon_bootinfo->board_rev_major) {
		case 1:
			fdt = (struct boot_param_header *)
			      &__dtb_ubnt_e101_begin;
			dt_size = &__dtb_ubnt_e101_end
			          - &__dtb_ubnt_e101_begin;
			break;
		default:
			fdt = (struct boot_param_header *)
			      &__dtb_ubnt_e100_begin;
			dt_size = &__dtb_ubnt_e100_end
			          - &__dtb_ubnt_e100_begin;
			break;
		}
		do_prune = false;
		do_set_mac = true;
	} else if (octeon_bootinfo->board_type == CVMX_BOARD_TYPE_UBNT_E120) {
		fdt = (struct boot_param_header *)
			&__dtb_ubnt_e100_begin;
		dt_size = &__dtb_ubnt_e100_end
			- &__dtb_ubnt_e100_begin;
		do_prune = false;
		do_set_mac = true;
	} else {
		fdt = (struct boot_param_header *)&__dtb_octeon_3xxx_begin;
		dt_size = &__dtb_octeon_3xxx_end - &__dtb_octeon_3xxx_begin;
		do_prune = true;
	}

	/* Copy the default tree from init memory. */
	initial_boot_params = early_init_dt_alloc_memory_arch(dt_size, 8);
	if (initial_boot_params == NULL)
		panic("Could not allocate initial_boot_params\n");
	memcpy(initial_boot_params, fdt, dt_size);

	if (do_prune) {
		octeon_prune_device_tree();
		pr_info("Using internal Device Tree.\n");
	}

	if (do_set_mac)
		ubnt_dt_set_mac();

	unflatten_device_tree();
}

Doesnt that indicate that the device tree needs to be loaded manually ?
This code is entirely missing from OpenWRT and Lede and so i wonder how the Edgerouter Lite is supposed to work ?

Can someone clear up my confusion?
Kind regards
MartB

This is still an ongoing issue for me.

The ubnt device tree is simply getting ignored because the base file (octeon3sth gets loaded).
How does the kernel decide which device tree to load ?

I can only work around that with hardcoding the device tree into the octeon setup logic.

HI

First
I don't know the current (as of this day !) status of DT in LEDE or upstream linux for mips

But there is some way to append the DTB at the end of the end of the kernel image for arm/arm64 arches. (*)
The same will happen for other arches In LEDE or upstream linux
Look into
target/linux/ramips/dts
for ramips

Maybe there are help needed from other people who own this device ...

(*)
This is done is respect to older uboot versions with DT support.

Hey there, thats already set by default and it does include all the trees.
However it loads the "wrong" one for my device.

It loads the one marked as
compatible = "cavium,octeon-3860";
So if i want to make it load mine (USG = UBNT_E120)

I would make that ?
model = "ubnt,e120";
compatible = "ubnt,e120";

in my own device tree ?

Is there any documentation from where these model and compatible things get retrieved on runtime?

DT entries land in
/sys/firmware/devicetree

They are parsed i.e. in LEDE
/etc/board.d

The easiest way to understand this is to read some of the add (new) support patches in LEDE.
.i.e. for Netear R6220 Router
git id 38bee61dab029a7608088f64da71c19cfc8cf267

For DT entries the linux kernel Documentation is the first place to look at.
Documentation/devicetree
They is also some vendor prefixes in
Documentation/devicetree/bindings/vendor-prefixes.txt

Thank you, i will check that out!