Selecting board specific (mangoh red specific) devicetree with generic kernel

We are currently using the mangOH Red to prototype a new Sierra Wireless based embedded platform.

I am therefore running on a self-built kernel/rootdisk off the swi-linux-src download.
As described below, I am having trouble booting on the correct device-tree.
How is this determined in the boot process? by lk (android-boot)? or the kernel itself?
Assuming it somehow is matched on the “board-id”, where is this stored?

Also when at a later stage we want to create out own device-tree variant, are there any tutorials/walkthroughs to follow?

Best /Flemming

I can see there is a mangoh-red specific devicetree included in the build when I look at the top Makefile:
arch/arm/boot/dts/qcom/Makefile

dtb-$(CONFIG_ARCH_MDM9607) += mdm9607-mtp.dtb \
	mdm9607-swi-ar.dtb \
	mdm9607-swi-qemu.dtb \
	mdm9607-wp76xx-default.dtb \
	mdm9607-wp76xx-mangoh-green.dtb \
	mdm9607-wp76xx-mangoh-red.dtb \
	mdm9607-wp76xx-mangoh-yellow.dtb \
	mdm9206-wp77xx-default.dtb \
	mdm9206-wp77xx-mangoh-green.dtb \
	mdm9206-wp77xx-mangoh-red.dtb \
	mdm9206-wp77xx-mangoh-yellow.dtb

When I match this with the “model” from the devicetree:

>  strings /proc/device-tree/model
Sierra Wireless, Inc. MDM WP7xxx series

I can see that I booted on “mdm9206-wp77xx-default.dts”:

/* Chipset and module description */
#include "mdm9607-wp76xx.dtsi"

/* Board description */
/ {
        model = "Sierra Wireless, Inc. MDM WP7xxx series";
        compatible = "qcom,mdm9607-mtp", "qcom,mdm9607", "qcom,mtp";
        qcom,board-id = <8 0x81>;
};

And not on “mdm9607-wp76xx-mangoh-red.dts” as i would have expected:

mdm9607-wp76xx-mangoh-red.dts:
/* Chipset and module description */
#include "mdm9607-wp76xx.dtsi"

/* Board description */
#include "swi-wp-mangoh-red.dtsi"

swi-wp-mangoh-red.dtsi:
/ {
	model = "Sierra Wireless, Inc. MDM 9xxx WP series - MangOH Red";
	compatible = "qcom,mdm9607-mtp", "qcom,mdm9607", "qcom,mtp";
	qcom,board-id = <8 0x82>;
};

&sdhc_2 {
	status = "ok";
	ti,non-removable;
	ti,needs-special-hs-handling;
	cap-power-off-card;
	keep-power-in-suspend;
};

&soc {
	sierra_gpio {
		alias-BATTGAUGE_INT = <300 0>;
		alias-BATTCHRGR_INT = <301 0>;
		/* No GPIO 2 */
		alias-GPIO_EXP_RPI_1 = <303 0>;
		alias-GPIO_EXP_RPI_2 = <304 0>;
...

All built off this release

> leaf status
┌──────────────────────────────────────────────────────────────────────────┐
│                    Workspace: /home/fm/swi/workspace                     │
╞══════════════════════════════════════════════════════════════════════════╡
│                   Profile: wp77stable [current] (sync)                   │
├──────────┬────────────────┬──────────────────────────────────────────────┤
│ Packages │   Identifier   │                 Description                  │
├──────────┼────────────────┼──────────────────────────────────────────────┤
│ Included │ swi-wp77_5.0.1 │ SDK for WP77 (Release 14.1 + Legato 19.11.5) │
└──────────┴────────────────┴──────────────────────────────────────────────┘

build_bin> bitbake mdm9x28-image-minimal

The boot blob starts like this. It does boot despite the slightly scary initial kernel output …
The “No devinfo partition found” line looks interesting of course …

Android Bootloader - UART_DM Initialized!!!
[10] Qseecom Init Done in Appsbl version is 0x405000
[10] secure app region addr=0x87900000 size=0x280000[20] TZ App region notif returned with status:0 addr:87900000 size:2621440
[20] TZ App log region register returned with status:0 addr:82681000 size:4096
[30] Qseecom TZ Init Done in Appsbl
[30] ERROR: No devinfo partition found
[30] Neither 'config' nor 'frp' partition found
[40] ERROR: No misc partition found
[1460] SSMEM init OK[1460] ssmem_get: region 20 not exists[1550] DEBUG: cmdline has root=
[1720] Channel alloc freed
[    0.000000] GIC CPU mask not found - kernel will fail to boot.
[    0.000000] GIC CPU mask not found - kernel will fail to boot.
[    0.000000] MPM 1 irq mapping errored -517
[    0.215114] spmi_pmic_arb 200f000.qcom,spmi: PMIC Arb Version-2 0x20010000
[    0.230337] SWI ssmem_framework_init: SSMEM init OK
[    0.230423] mdm9607-pinctrl 1000000.pinctrl: gpio-bit-map = 36
[    0.231953] msm_mpm_dev_probe(): Cannot get clk resource for XO: -517
[    0.235104] smd_channel_probe_now: allocation table not initialized
[    0.242822] msm_thermal:msm_thermal_dev_probe Failed reading node=/soc/qcom,msm-thermal, key=qcom,online-hotplug-core. err:-517
[    0.270579] msm_mpm_dev_probe(): Cannot get clk resource for XO: -517

Finally solved this:

First step was to get lk to say anything about devicetrees at boot.
Turns out “LK_DEBUG” must be set to “1” in the recipe, or all “dprintf(INFO” messages are optimized away.

Once this was in place, the devicetree selection process showed it’s face and it was fairly obvious to follow it to “board_override_hardware_subtype()” and in turn “WP_BOARD_PROBE”

So, it turns out the mangOH boards are dynamically probed for, and it can be enabled with the following bbappend file:

lk_1.3.0.bbappend:

LK_DEBUG := "1"
WP_BOARD_PROBE := "1"

# Debug
do_compile_prepend() {
    echo "OEMAKE: ${EXTRA_OEMAKE}"
}

Sooo nice:

root@amplex-2004042042:~# strings /proc/device-tree/model
Sierra Wireless, Inc. MDM 9xxx WP series - MangOH Red
root@amplex-2004042042:~# cat /sys/class/gpio/v2/alias_map
   0,38   A "2"
...
   0,79   A "42"
   0,25   M "RI"
   0,58   A "WLAN_EN"
   0,79   A "WIFI_IRQ"
 300,0    A "BATTGAUGE_INT"
 300,1    A "BATTCHRGR_INT"
 300,3    A "GPIO_EXP_RPI_1"
 300,4    A "GPIO_EXP_RPI_2"
 300,5    A "MTK_TO_WP_UART_EN"
 300,6    A "WIFI_UART1_TX"
 300,7    A "GPIO_EXP_RPI_3"
 300,8    A "LED_CARD_DETECT_IOT0"
 300,9    A "SDIO_SEL"
 300,10   A "POWER_FAIL_INDIC"
 300,11   A "SENSOR_INT1"
 300,12   A "SENSOR_INT2"
 300,13   A "PCM_EXP1_SEL"
 300,14   A "GENERIC_PUSH_BUTTON"
 300,15   A "CONS_DIR"
root@amplex-2004042042:~#