This feature is intended for advanced users.
As of July 15th 2014, the Raspberry Pi firmware supports custom default pin configurations through a user-provided device tree blob file. In order to ensure that your firmware is recent enough, please run vcgencmd version.
In order to compile a device tree source (dts) file into a device tree blob (dtb) file, the device tree compiler must be installed by running sudo apt-get install device-tree-compiler.
The dtc command can then be used as follows:
sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob.dts
NOTE: In the case of NOOBS installs, the dtb file should be placed on the recovery partition instead.
Similarly, a dtb file can be converted back to a dts file, if required.
dtc -I dtb -O dts -o dt-blob.dts /boot/dt-blob.bin
The dt-blob.bin is used to configure the binary blob (Videocore) at boot time. It is not something that the linux kernel uses (at the moment) although a kernel section will be added at a later stage when we move the Raspberry Pi kernel to use a dt-blob for configuration. The dt-blob is capable of configuring each of the different versions of the Raspberry Pi including the Compute Module to set up the alternate settings correctly. The following sections are valid in the dt-blob.
-
videocoreThis section contains the whole videocore blob information, all subsequent sections must be enclosed within this section
-
pins_*There are up to eight separate pins_* sections, namely:
- pins_rev1 Rev1 pin setup. There are some difference because of the moved I2C pins
- pins_rev2 Rev2 pin setup. This includes the additional codec pins on P5
- pins_bplus1 Model B+ rev 1.1, including the full 40pin connector
- pins_bplus2 Model B+ rev 1.2, swapping the low-power and lan-run pins
- pins_aplus Model A+, lacking ethernet
- pins_2b1 Pi 2 Model B rev 1.0, controls the SMPS via I2C0
- pins_2b2 Pi 2 Model B rev 1.1, controls the SMPS via software I2C on 42&43
- pins_cm The Compute Module, note the default for this is the default for the chip so can be a useful source of information about default pullups / downs on the chip.
Each
pins_*section can containpin_configandpin_definessections. -
pin_configThe
pin_configsection is used to configure the individual pins, each item in this section must be a named pin section, such aspin@p32meaning GPIO32. There is a special sectionpin@defaultwhich has the default settings for anything not specifically named in the pin_config section. -
pin@pinnameThis section can contain any combination of the following items
polarityactive_highactive_low
terminationpull_uppull_downno_pulling
startup_stateactiveinactive
functioninputoutputsdcardi2c0i2c1spispi1spi2smidpipcmpwmuart0uart1gp_clkemmcarm_jtag
drive_strength_maThe drive strength is used to set a strength for the pins, please note you can only set the bank to a single drive strength. <8> <16> are valid values
-
pin_definesThis section is used to set specific videocore functionality to particular pins, this enables the user to move the camera power enable pin to somewhere different or the hdmi hotplug postion (i.e. things that linux have no control over). Please refer to the example dts file below
It is possible to change the configuration of the clocks through this interface, although very difficult to predict the results! The configuration of the clocking system is very very complex, there are five separate PLLs each one has its own fixed (or variable in the case of PLLC) VCO frequency. Each VCO then has a number of different channels which can be set up with a different division of the VCO frequency. Then each of the clock destinations can then be configured to come from one of the clock channels (although there is a restricted mapping of source to destination so not all channels can be routed to all clock destinations).
For this reason I'll just add here a couple of example configurations that you can use to alter very specific clocks. Beyond this it is something we'll add to when requests for clock configurations are made.
clock_routing {
vco@PLLA { freq = <1966080000>; };
chan@APER { div = <4>; };
clock@GPCLK0 { pll = "PLLA"; chan = "APER"; };
};
clock_setup {
clock@PWM { freq = <2400000>; };
clock@GPCLK0 { freq = <12288000>; };
clock@GPCLK1 { freq = <25000000>; };
};
The above will set the PLLA to a source VCO running at 1.96608GHz (the limits for this VCO are 600MHz - 2.4GHz), the APER channel to /4 and configures GPCLK0 to be sourced from PLLA through APER. This is used specifically to give an audio codec the 12288000Hz it needs to do the 48000 range of frequencies.
NOTE: As this is a new feature, there is no reference dts file which is guaranteed to be supported by future firmware revisions.
The dts file used for the dtb compiled into the May 30th 2015 firmware can be downloaded from here.