Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtb_overlay vs uboot_overlay_addr #138

Open
kugelbit opened this issue Sep 25, 2019 · 1 comment
Open

dtb_overlay vs uboot_overlay_addr #138

kugelbit opened this issue Sep 25, 2019 · 1 comment

Comments

@kugelbit
Copy link

Hey,

We are working on cape for our beaglebone. For our cape we have this overlay:


/dts-v1/;
/plugin/;

/ {
   compatible = "ti,beaglebone", "ti,beaglebone-black";

   part-number = "BB-SHPRD";
   version = "00A0";

   /* This overlay uses the following resources */
   exclusive-use =
        "P8.11", /* DEBUG PIN1 PRU0 */
        "P8.12", /* LED1 PRU0 */
        "P8.13", /* ENABLE HARVESTER */
        "P8.28", /* ADC RST/PDN */
        "P8.30", /* LED2 USER SPACE */
        "P8.33", /* GENERAL PURPOSE BUTTON */
        "P8.34", /* GENERAL PURPOSE LED */
        "P8.36", /* ENABLE LEVEL CONVERTER */
        "P8.41", /* DEBUG PIN0 PRU1 */
        "P8.42", /* DEBUG PIN1 PRU1 */
        "P8.43", /* TARGET GPIO2 */
        "P8.44", /* TARGET GPIO3 */
        "P8.45", /* TARGET GPIO0 */
        "P8.46", /* TARGET GPIO1 */
        "P9.11", /* ENABLE MPPT# */
        "P9.12", /* ENABLE V ANALOG */
        "P9.15", /* SELECT LOAD*/
        "P9.16", /* ENABLE V FIXED*/
        "P9.25", /* SPI CS ADC */
        "P9.27", /* SPI MISO */
        "P9.28", /* SPI SCLK */
        "P9.29", /* DEBUG PIN0 PRU0 */
        "P9.30", /* SPI MOSI */
        "P9.31", /* SPI CS DAC */
        "P9.41", /* SWDIO */
        "P9.42", /* SWDCLK */
        "pru0",
        "pru1";
   /* Check Table 9-60 in am335x TRM */


   fragment@0 {
      target = <&am33xx_pinmux>;
      __overlay__ {
         bb_shprd_pins: pinmux_bb_shprd_pins {
            pinctrl-single,pins = <
            0x034 0x06  /* P8.11, pr1_pru0_pru_r30_15 */
            0x030 0x06  /* P8.12, pr1_pru0_pru_r30_14 */
            0x024 0x07  /* P8.13, gpio0[23] */
            0x0e8 0x07	/* P8.28, gpio2[24] */
            0x0ec 0x07	/* P8.30, gpio2[25] */
            0x0d4 0x37	/* P8.33, gpio0[9] */
            0x0cc 0x07	/* P8.34, gpio2[17] */
            0x0c8 0x07	/* P8.36, gpio2[16] */
            0x0b0 0x05	/* P8.41, pr1_pru1_pru_r30_4 */
            0x0b4 0x05	/* P8.42, pr1_pru1_pru_r30_5 */
            0x0a8 0x26	/* P8.43, pr1_pru1_pru_r31_2 */
            0x0ac 0x26	/* P8.44, pr1_pru1_pru_r31_3 */
            0x0a0 0x26	/* P8.45, pr1_pru1_pru_r31_0 */
            0x0a4 0x26	/* P8.46, pr1_pru1_pru_r31_1 */

            0x070 0x07	/* P9_11, gpio0[30] */
            0x078 0x07	/* P9_12, gpio1[28] */
            0x040 0x07	/* P9_15, gpio1[16] */
            0x04c 0x07	/* P9_16, gpio1[19] */
            0x1ac 0x05	/* P9_25, pr1_pru0_pru_r30_7 */
            0x1a4 0x26	/* P9_27, pr1_pru0_pru_r31_5 */
            0x19c 0x05	/* P9_28, pr1_pru0_pru_r30_3 */
            0x194 0x05	/* P9_28, pr1_pru0_pru_r30_1 */
            0x198 0x05	/* P9_30, pr1_pru0_pru_r30_2 */
            0x190 0x05	/* P9_31, pr1_pru0_pru_r30_0 */
            0x1a8 0x27	/* P9_41B, gpio3[20] */
            0x1a0 0x07	/* P9_42B, gpio3[18] */
            >;
         };
      };
   };

   fragment@1 {
       target = <&pruss>;
       __overlay__ {
           status = "okay";
            pinctrl-names = "default";
            pinctrl-0 = <&bb_shprd_pins>;
            shepherd{
               compatible = "shepherd";
               prusses = <&pruss>;
            };	
       };
   };

};

After installing the overlay there are 2 different options to load it.

  1. Option:
    You can specify the overlay in the uEnv.txt under an uboot_overlay_addr tag like this:
uboot_overlay_addr5=/lib/firmware/BB-SHPRD-00A0.dtbo
  1. Option:
    the second option is the specify the overlay in the uEnv.txt under the dtb_overlay tag like this:
dtb_overlay=/lib/firmware/BB-SHPRD-00A0.dtbo

My first questions are: What is the difference between this two options? - Is there another option?

We found out that there is some strange behavior, if we use option 1.
In fragment@1 we have our own shepherd overlay struct for pruss. In this struct we define a kind of pointer to the pruss: prusses = <&pruss>;.

If we use option 2 this pointer will be set correct:
/proc/device-tree/ocp/pruss_soc_bus@4a326004/pruss@0/shepherd/prusses
correspond to
/proc/device-tree/ocp/pruss_soc_bus@4a326004/pruss@0/phandle

If we use option 1 this pointer will be not set correct and points to no where...

My conclusion is that there must be an difference between loading overlays with dtb_overlay and uboot_overlay_addr. Could it be a problem with the load-order of the overlays? We manipulate the pruss device-tree part, so i guess the /lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo overlay must be loaded before our custom overlay?

Why there are two different option for loading overlays? Can i load more than one overlay with the dtb_overlay option? What is the best practice to load more than one custom overlay?

Here some additional Information:

uEnv.txt (option ):

#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

uname_r=4.14.108-ti-r104
#uuid=
#dtb=

###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
###Master Enable
enable_uboot_overlays=1
###
###Overide capes with eeprom
uboot_overlay_addr0=/lib/firmware/BB-UART1-00A0.dtbo
###
###Additional custom capes
uboot_overlay_addr4=/lib/firmware/BB-I2C1-00A0.dtbo
#uboot_overlay_add5=/lib/firmware/BB-SHPRD-00A0.dtbo # option 1
uboot_overlay_addr6=/lib/firmware/DD-GPS-00A0.dtbo

###Custom Cape
dtb_overlay=/lib/firmware/BB-SHPRD-00A0.dtbo # option 2
#dtb_overlay=/lib/firmware/DD-GPS-00A0.dtbo


###Disable auto loading of virtual capes (emmc/video/wireless/adc)                                                                                 
disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
disable_uboot_overlay_wireless=1
#disable_uboot_overlay_adc=1

###
###PRUSS OPTIONS
###pru_rproc (4.4.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo
###pru_rproc (4.14.x-ti kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_rproc (4.19.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo
###pru_uio (4.4.x-ti, 4.14.x-ti, 4.19.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
###

###Cape Universal Enable
#enable_uboot_cape_universal=1
#cape_enable=bone_capemgr.enable_partno=DD-GPS,BB-SHPRD,UART1,I2C1
#capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN


cmdline=coherent_pool=1M net.ifnames=0 quiet cape_universal=enable

sudo /opt/scripts/tools/version.sh (option 1):

git:/opt/scripts/:[9df8deb6b2ae7570c9102ab58f795d3bed592194]
eeprom:[A335BNLTBBG1BBG219014639]
model:[TI_AM335x_BeagleBone_Green]
dogtag:[rcn-ee.net console Ubuntu Image 2019-04-10]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.01-00002-g6de8c74429]:[location: dd MBR]
kernel:[4.14.108-ti-r104]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr0=/lib/firmware/BB-UART1-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr1=/lib/firmware/BB-I2C1-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr2=/lib/firmware/DD-GPS-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr5=/lib/firmware/BB-SHPRD-00A0.dtbo]
uboot_overlay_options:[disable_uboot_overlay_emmc=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[disable_uboot_overlay_audio=1]
uboot_overlay_options:[disable_uboot_overlay_wireless=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.4.20190922.0-0rcnee0~bionic+20190922]
pkg:[bb-wl18xx-firmware]:[1.20190227.1-0rcnee0~bionic+20190227]
pkg:[kmod]:[24-1ubuntu3.2rcnee0~bionic+20190208]
WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
groups:[ubuntu : ubuntu adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep admin spi tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet cape_universal=enable]
dmesg | grep remote
[    1.236692] remoteproc remoteproc0: wkup_m3 is available
[    1.317856] remoteproc remoteproc0: powering up wkup_m3
[    1.317973] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[    1.321938] remoteproc remoteproc0: remote processor wkup_m3 is now up
[   29.279359] remoteproc remoteproc1: 4a334000.pru is available
[   29.289274] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pru
[   28.972869] pruss 4a300000.pruss: creating PRU cores and other child platform devices
[   29.279359] remoteproc remoteproc1: 4a334000.pru is available
[   29.282237] pru-rproc 4a334000.pru: PRU rproc node /ocp/pruss_soc_bus@4a326004/pruss@0/pru@34000 probed successfully
[   29.289274] remoteproc remoteproc2: 4a338000.pru is available
[   29.289403] pru-rproc 4a338000.pru: PRU rproc node /ocp/pruss_soc_bus@4a326004/pruss@0/pru@38000 probed successfully
dmesg | grep pinctrl-single
[    1.040274] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[    1.041492] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END

sudo /opt/scripts/tools/version.sh (option 2):

git:/opt/scripts/:[9df8deb6b2ae7570c9102ab58f795d3bed592194]
eeprom:[A335BNLTBBG1BBG219014639]
model:[TI_AM335x_BeagleBone_Green]
dogtag:[rcn-ee.net console Ubuntu Image 2019-04-10]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.01-00002-g6de8c74429]:[location: dd MBR]
kernel:[4.14.108-ti-r104]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr0=/lib/firmware/BB-UART1-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr1=/lib/firmware/BB-I2C1-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr2=/lib/firmware/DD-GPS-00A0.dtbo]
uboot_overlay_options:[disable_uboot_overlay_emmc=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[disable_uboot_overlay_audio=1]
uboot_overlay_options:[disable_uboot_overlay_wireless=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo]
uboot_overlay_options:[dtb_overlay=/lib/firmware/BB-SHPRD-00A0.dtbo]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.4.20190922.0-0rcnee0~bionic+20190922]
pkg:[bb-wl18xx-firmware]:[1.20190227.1-0rcnee0~bionic+20190227]
pkg:[kmod]:[24-1ubuntu3.2rcnee0~bionic+20190208]
WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
groups:[ubuntu : ubuntu adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep admin spi tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet cape_universal=enable]
dmesg | grep remote
[    1.236704] remoteproc remoteproc0: wkup_m3 is available
[    1.317855] remoteproc remoteproc0: powering up wkup_m3
[    1.317977] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[    1.321932] remoteproc remoteproc0: remote processor wkup_m3 is now up
[   30.443757] remoteproc remoteproc1: 4a334000.pru is available
[   30.457269] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pru
[   30.162098] pruss 4a300000.pruss: creating PRU cores and other child platform devices
[   30.443757] remoteproc remoteproc1: 4a334000.pru is available
[   30.443880] pru-rproc 4a334000.pru: PRU rproc node /ocp/pruss_soc_bus@4a326004/pruss@0/pru@34000 probed successfully
[   30.457269] remoteproc remoteproc2: 4a338000.pru is available
[   30.457393] pru-rproc 4a338000.pru: PRU rproc node /ocp/pruss_soc_bus@4a326004/pruss@0/pru@38000 probed successfully
dmesg | grep pinctrl-single
[    1.040281] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[    1.041493] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END
@mvduin
Copy link

mvduin commented Jan 17, 2022

I don't know if your ubuntu system is different but in U-Boot 2019.04-00002-g07d5700e21 used in the official beagleboard.org Debian Buster 2020-04-06 images, the order of overlays is:

  • hardware-specific fixup overlay (M-BB-*) if applicable
  • ADC overlay, if not disabled
  • uboot_overlay_addr0..3 if set manually or by cape autodetection, and not disabled
  • uboot_overlay_addr4..7 if set manually
  • eMMC overlay if applicable and not disabled
  • HDMI overlay if applicable and not disabled
    • (selection of HDMI overlay also influenced by disable_uboot_overlay_audio)
  • Wireless overlay if applicable and not disabled
  • uboot_overlay_pru if set manually
  • uboot_overlay_pru_add if set manually
  • dtb_overlay if set manually
  • universal overlay (univ-*) if applicable and enabled

So yes, dtb_overlay is able to reference nodes created by uboot_overlay_pru while uboot_overlay_addr4..7 can not. I'm not completely sure why this goes wrong though since the &pruss node isn't created by the overlay, it already exists in the base dtb. I'm guessing u-boot gets confused by the redefinition of the &pruss label by AM335X-PRU-RPROC-4-14-TI-00A0, even though it's being redefined to point to the exact same node it used to. In that case the problem would also be fixed by trimming the AM335X-PRU-RPROC-4-14-TI-00A0 overlay to something like:

/dts-v1/;
/plugin/;

/*
 * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
 */
&{/chosen} {
	overlays {
		AM335X-PRU-RPROC-4-14-TI-00A0 = __TIMESTAMP__;
	};
};

/ {
	fragment@1 {
		target = <&pruss_soc_bus>;
		__overlay__ {
			status = "okay";

			shmem@0 {
				reg = <0x0 0x2000>,
				      <0x2000 0x2000>,
				      <0x10000 0x3000>;
				reg-names = "dram0",
					    "dram1",
					    "dram2";
				compatible = "uio";
				symlink = "uio/pru-shmem";
			};
		};
	};

	fragment@2 {
		target = <&pruss>;
		__overlay__ {
			status = "okay";
		};
	};
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants