Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Device tree driven kernel for raspberry pi

I'd like to boot the raspberry pi with a device-tree-driven linux kernel, is there anything special to do to do that?

Can anyone point what are required to set up a device-tree-based kernel boot up for the raspberry pi.

I may need to have raspberry pi kernel source where drivers for devices should be compatible with device tree. If so, where can I find such kernel sources for Raspberry Pi?

like image 234
Amit Singh Tomar Avatar asked Mar 05 '14 15:03

Amit Singh Tomar


Video Answer


1 Answers

Device-Tree support on Raspberry Pi

Raspberry Pi embeds an ARM11 SoC: Broadcom BCM2835. Device Tree (DT) support for ARM is fairly new, but it seems that it has made its way to the Raspberry Pi CPU. You can find a DT for the Raspberry Pi in arch/arm/boot/dts/bcm2835.dts*.

However the default config file bcm2835_defconfig does not enable device tree:

$ grep DT arch/arm/configs/bcm2835_defconfig
<nothing interesting>

I expected something like CONFIG_OF*=y or CONFIG_USE_OF=y. Bad news: that is going to be tough and long (3 noob.month ?).

is there anything special to do to do that?

It depends on your current linux kernel version. Chances are that your current linux already uses the device-tree (linux-3.7 or later ?).

If not, there are wide changes that you need to study:

Device-Tree impact on a system

Device Tree completely changes the way Linux kernel boots. It impacts:

  1. your bootloader (e.g. u-boot.bin). U-Boot must know how to handle device-tree. Old U-Boots do not know what a device-tree is...
  2. the Linux kernel image (e.g. zImage). Linux must know that it has to fetch its hardware description in the device-tree.
  3. the flash/SD card partition layout. You need to make room for the device tree file itself.

Impact means: you need a way to compile/program these images: full-source, build environment, UART access, potentially JTAG hardware. Changing the bootloader without JTAG is usually suicide, except (today) you can reprogram your SD card off the board safely.

You might find references to OpenFirmware (OF) when talking about device tree. OpenFirmware was the original specification on IBM PowerPC before the Device Tree convention was chosen. Code related to device-tree is prefixed with of_ in linux. Not intuitive, I know...

Please read:

  1. http://devicetree.org/Main_Page
  2. Documentation/devicetree

How to generate the Device-Tree Binary (.dtb)?

Example on a PowerPC board using buildroot:

/usr/bin/make -j5 HOSTCC="/usr/bin/gcc" HOSTCFLAGS="" ARCH=powerpc INSTALL_MOD_PATH=/home/evigier/buildroot/output/target CROSS_COMPILE=" /home/evigier/buildroot/output/host/usr/bin/powerpc-buildroot-linux-gnu-" DEPMOD=/home/evigier/buildroot/output/host/sbin/depmod -C /home/evigier/buildroot/output/build/linux-master mpc8347.dtb

Example U-Boot console output on a PowerPC board:

Uncompressing Kernel Image ... OK
kernel loaded at 0x00000000, end = 0x006f8780
## cmdline at 0x0ff1b900 ... 0x0ff1b925
## initrd_high = 0xffffffff, copy_to_ram = 1
ramdisk load start = 0x00000000, ramdisk load end = 0x00000000
## device tree at 00780000 ... 00781f57 (len=20312 [0x4F58])
Loading Device Tree to 0ff16000, end 0ff1af57 ... OK
## Transferring control to Linux (at address 00000000) ...
Booting using OF flat tree..

Happy hacking :-)

like image 78
m-ric Avatar answered Oct 24 '22 20:10

m-ric