Wednesday, May 21, 2014

Device tree for my Beagleboard-xM

Hey Guys!

About 3 years ago I purchased my  beagleboard-xM (rev B) over the web.
For those who are less familiar with this toy, it's a SoC equipped with ARM Cortex A8, serial interface, I2C etc. (For more details)
 
So back in those days, after setting it up (partitions, u-boot , image kernel) the operating system which called Angstrom (kernel version 2.6.17) As you may guessed?!

I decided to join few google groups  which were discussing about any subject regarding the new toy in the block :-)

but since then, many things have changed and few days ago I decided to update my kernel to the latest. eventually I decided to move to Ubuntu distribution, and give a try to Ubuntu LTS (3.14.2) .

After settings things up, I tried yo lunch some of my past written code which were written for the old kernel. but apparently the subsystem for muxing the pins has been changed.
Eventually I decided to delve into the subject, and see how come I can't interact with  those gpios.

After some reading I found out, since Linux kernel 3.7 (ARM family) a new method was introduced for describing the hardware, by this I mean a well configured Device Tree should be deliver to the uboot.
A device tree is a data-structure which is responsible for describing the hardware on the system. such as:
  • The number and name of CPUs running on the system
  • Base address and size of the RAM
  • The buses 
  • The peripheral device connections, such as gpios, which i'll be talking about it now.
This data-structure is loaded into the kernel during boot time. before the kernel is loaded. the device tree can be easily configured since it is stored as a readable file with the dts extension., So the developer can modify the tree according to his own needs.
example for a device tree:

Before the Device Tree was introduced to the ARMs, the kernel was actually storing this valuable information inside himself ( either the binary image uImage or zImage), but now two binary files are supplied to the u-boot:
  1. device tree blob
  2. uImage/zImage

Comment: A complete coverage about the device tree can be found at the linux kernel directory:   /Documentation/devicetree


So After configuring the gpios in the device tree, we should compile the this source file, via device tree compiler :


The command:
dtc -O dtb -o omap3-beagle-xm-ab.dtb -b 0 -@ omap3-beagle-xm-ab.dts

In case you got lucky you haven't received any syntax errors, you good to go!
now we should order the kernel to use this updated dtb file, we do that by simple overwriting the corresponding file (I suggest you to backup first the original dtb file) in the directory:

/boot/uboot/dtbs/

now you should reboot and check if the system recognized your attached device.

That's all for now, I hope you enjoyed today's section. see ya on the next post!


P.S

I have explained in short the configuration settings, since in my opinion it's less interesting, but for giving you a good start you should read thoroughly the pages taken from:
  • The "Technical Reference Manual" of the Texas Instrument's processor (Pages 2,444-2,453).

1 comment:

About