hoplahop
Posts: 1
Joined: Wed Nov 08, 2017 3:52 pm

device tree question? What is the right way to configure

Fri Nov 10, 2017 6:54 am

Hello together,

I am using the PI3 and I would like to use the SDIO interface. https://de.pinout.xyz/pinout/sdio#

I learned in the following post, that the PI3 is using the SDIO internally for its WIFI chip. viewtopic.php?f=107&t=161771

With the following dtbo I was able to deactivate the mmc :)

Code: Select all

/dts-v1/;
/plugin/;

/{
	compatible = "brcm,bcm2708";

	[email protected] {
		target = <&mmc>;
		__overlay__ {
			status = "disabled";
		};
	};
};
Thereafter I tried to extend my dtbo so that I activate the external SDIO on my PI3. The corresponding dts I took from here viewtopic.php?f=107&t=161771

Code: Select all

/* Enable SDIO from MMC interface via GPIOs 22-27 for RPi 3B while disabling Wifi */

/dts-v1/;
/plugin/;

/{
   compatible = "brcm,bcm2708";

   [email protected] {
      target = <&mmc>;
      __overlay__ {
         status = "disabled";
      };
   };

   [email protected] {
      target = <&soc>;
      __overlay__ {
         #address-cells = <1>;
         #size-cells = <1>;

         mymmc: [email protected] {
            compatible = "brcm,bcm2835-mmc";
            reg = <0x7e300000 0x100>;
            interrupts = <2 30>;
            clocks = <&clk_mmc>;
            dmas = <&dma 11>;
            dma-names = "rx-tx";
            brcm,overclock-50 = <0>;
            pinctrl-names = "default";
            pinctrl-0 = <&mymmc_pins>;
            bus-width = <4>;
            status = "okay";
         };
      };
   };

   [email protected] {
      target = <&gpio>;
      __overlay__ {
         mymmc_pins: mymmc_pins {
            brcm,pins = <22 23 24 25 26 27>;
            brcm,function = <7 7 7 7 7 7>; /* ALT3 = SD1 */
            brcm,pull = <0 2 2 2 2 2>;
         };
      };
   };
};
This is not working. This activates again the internal SDIO. So when I give this dtbo to the config, the internal WIFI chip of the PI3 is working again. :o

I got the external SDIO running by deactivating the mmc (see first dts above) and thereafter using the sdio from /boot/overlays :D
Here is my config.txt

Code: Select all

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on
enable_uart=1
#dtoverlay=sdio,poll_once=off
#dtoverlay=mySdio,poll_once=off
dtoverlay=internalMmcOff
dtoverlay=sdio,poll_once=off
:?:
What is the right approach mapping internal SDIO to the external PINs?
- Creating 1 dtbo file or do it in steps?
How dtbo files are used? Can a dtbo file that is later listed in my config overwrite a config that is set in an earlier dtbo file?
What is wrong in my second dts? Why does it activate again the internal SDIO? I couldn't find any failure in the logs.

Thanks!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1902
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: device tree question? What is the right way to configure

Fri Nov 10, 2017 1:50 pm

Your original overlay doesn't work because there is an unresolved symbol:

Code: Select all

[email protected]:~ $ sudo vcdbg log msg
...
001844.355: Loading 'bcm2710-rpi-3-b-plus.dtb' to 0x465d80 size 0x454d
001961.008: dtparam: audio=on
001989.953: dterror: can't find symbol 'clk_mmc'
001989.967: Failed to resolve overlay 'foo'
002995.767: Device tree loaded to 0x2effb600 (size 0x49bc)
...
clk_mmc is no longer part of the base dtb, which has evolved since the early Pi DT support. This rate of change has now slowed, and hopefully the fundamentals like clocking won't change much more. There are a number of reasons the overlays are hosted in the kernel tree, but one is so that they can change with different kernel versions.

The current version of the mmc node looks like this:

Code: Select all

		mmc: [email protected] {
			compatible = "brcm,bcm2835-mmc";
			reg = <0x7e300000 0x100>;
			interrupts = <2 30>;
			clocks = <&clocks BCM2835_CLOCK_EMMC>;
			dmas = <&dma 11>;
			dma-names = "rx-tx";
			brcm,overclock-50 = <0>;
			status = "disabled";
		};
BCM2835_CLOCK_EMMC is provided by a header file and has the value 28, so your overlay ends up like this:

Code: Select all

/* Enable SDIO from MMC interface via GPIOs 22-27 for RPi 3B while disabling Wifi */

/dts-v1/;
/plugin/;

/{
   compatible = "brcm,bcm2708";

   [email protected] {
      target = <&mmc>;
      __overlay__ {
         status = "disabled";
      };
   };

   [email protected] {
      target = <&soc>;
      __overlay__ {
         #address-cells = <1>;
         #size-cells = <1>;


         mymmc: [email protected] {
            compatible = "brcm,bcm2835-mmc";
            reg = <0x7e300000 0x100>;
            interrupts = <2 30>;
            clocks = <&clocks 28>;
            dmas = <&dma 11>;
            dma-names = "rx-tx";
            brcm,overclock-50 = <0>;
            pinctrl-names = "default";
            pinctrl-0 = <&mymmc_pins>;
            bus-width = <4>;
            status = "okay";
         };
      };
   };

   [email protected] {
      target = <&gpio>;
      __overlay__ {
         mymmc_pins: mymmc_pins {
            brcm,pins = <22 23 24 25 26 27>;
            brcm,function = <7 7 7 7 7 7>; /* ALT3 = SD1 */
            brcm,pull = <0 2 2 2 2 2>;
         };
      };
   };
};
However, you should only need the sdio overlay, which works by changing the pin mapping of the existing mmc node to use GPIOs 22-27. Since it also enables the mmc node, your minimal overlay that disables the mmc node should have no overall effect and can be omitted.

"dtoverlay=" directives in config.txt are applied in order of appearance (top to bottom), so the semantics of applying overlapping overlays are well defined - the last modification to any property is the one that survives.

Return to “Device Tree”