NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

AM335x Android Device Tree Integration

From Texas Instruments Wiki
Jump to: navigation, search

Content is no longer maintained and is being kept for reference only!


TIBanner.png

Introduction
[edit]

Content is no longer maintained and is being kept for reference only!

This is an effort to integrate the Device Tree(DT) support to am335x android kernel of rowboat open source project.

This work is a based on the latest AM335x Android Devkit release

The DT patches have been validated on BeagleBone(an opensource am335x platform).

Also this wiki assume that the user has followed the Hardware Requirements and the Software Requirements for the same release.

What is supported
[edit]

  • Booting AM335x with Device Tree(DT)
  • DT support for GPIO
  • DT support for LEDS

Steps to evaluate [edit]

Getting Sources
[edit]

Downloading Patches
[edit]

  • Download the DT support patches from HERE

Downloading Android Sources
[edit]

For this experiment the user can just download the android kernel and the prebuilt images,

http://software-dl.ti.com/dsps/dsps_public_sw/sdo_tii/TI_Android_DevKit/TI_Android_ICS_4_0_3_DevKit_3_0_1/exports/beaglebone.tar.gz

  • Download RAMDISK file system from this Link.

http://processors.wiki.ti.com/images/5/5a/Ramdisk-pm.gz

Compiling Sources
[edit]

Toolchain setup[edit]

  • Setup the toolchain path to point to arm-eabi- tools in prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
$ export PATH=<android source path>/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH

Applying DT patches[edit]

Extract the downloaded Dt_patches.tar.gz to <android source path>/dt_patches

$ tar -xvzf  Dt_patches.tar.gz <android source path>/

Apply the DT patches on kernel using "git am" command

$ cd <android source path>/kernel

$ git am <android source path>/dt_patches/*

To Build Android Linux Kernel

  • Change directory to kernel
$ cd <android source path>/kernel 
  • Execute following commands
$ make ARCH=arm CROSS_COMPILE=arm-eabi- distclean
$ make ARCH=arm CROSS_COMPILE=arm-eabi- am335x_evm_android_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-eabi- uImage uImage-dtb.am335x-evm

This will generate dtb(device tree blob) appended uImage-dtb.am335x-evm (kernel image) in kernel/arch/arm/boot folder

Preparing Bootable MMC Card
[edit]

Here we prepare the MMC card with the prebuilt images and replace the kernel image for DT demostration

Procedure to populate MMC/SD Card

  • Get an SD Card of minimum size 2GBytes (Class4 minimum) and a USB Card reader
  • Insert the USB SD Card reader (with SD Card) in your host Linux PC
  • Prepare the MMC/SD card with pre-built images beaglebone.tar.gz downloaded from TI release page
$ tar -xvzf beaglebone.tar.gz

$ cd beaglebone

$ sudo ./mkmmc-android.sh /dev/sd<device>
  • Above step will create a bootable MMC/SD card with three partitions namely boot, rootfs and data.
  • Copy the dtb(device tree blob) to the boot partition
$ cp <android source path>/kernel/arch/arm/boot/uImage-dtb.am335x-evm /media/boot/
  • Copy the RAMDISK image ramdisk-pm.gz to the boot partition
$ cp ramdisk-pm.gz /media/boot/
  • Now this MMC/SD card can be unmounted and used for booting the platform

Evaluating DT support
[edit]

The target platform can either be booted with a RAMDISK or Android File System.

Booting the test platform
[edit]

  • Connect USB cable to the mini-USB port(P3) on BeagleBone to the Host PC and have a Terminal software like TeraTerm, Minicom or Hyperterminal.
  • Please refer BeagleBone-Android-DevKit Guide for detailed instructions for serial port setup.
  • Insert Micro SD card into MMC/SD slot on the BeagleBone.
  • Power ON the BeagleBone by connecting power cable to (P5).
  • Press any key at the boot-loader prompt
U-Boot#
  • Type the follwing on the U-boot prompt for booting with RAMDISK File System
U-Boot# setenv bootcmd 'mmc rescan 0; fatload mmc 0 81000000 uImage-dtb.am335x-evm; fatload mmc 0 82000000 ramdisk-pm.gz; bootm 81000000'
U-Boot# setenv bootargs 'console=ttyO0,115200n8 mem=128M root=/dev/ram rw initrd=0x82000000,16MB ramdisk_size=65536 earlyprintk=serial debug'
U-Boot# boot
  • Type the follwing on the U-boot prompt for booting Android File System
U-Boot# setenv bootargs 'console=ttyO0,115200n8 androidboot.console=ttyO0 mem=256M root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait init=/init ip=off'
U-Boot# setenv bootcmd 'mmc rescan ; fatload mmc 0 82000000 uImage; bootm 82000000'
U-Boot# boot

How to check Device Tree Support
[edit]

  • On Boot Log check the line
[ 0.000000] Machine: Generic AM33XX (Flattened Device Tree), model: TI AM335x EVM

This indicate that the machine init happened in the device tree model

  • On Boot Log check the lines
[ 1.872619] DEBUG*** gpio-leds device tree data

[ 1.877349] DEBUG*** led.gpio 56

[ 1.881713] DEBUG*** led.active_low 0

[ 1.885986] DEBUG*** led.name beaglebone::status1

[ 1.891876] DEBUG*** led.default_trigger heartbeat

[ 1.896881] DEBUG*** led.default_state 0

This indicate that the leds-gpio driver has parsed the information from the device tree and used it for creating the leds.

  • The user LED left to the reset button starts blinking as soon as the boot is finished to indicate that the heartbeat led started functioning.
  • After booting check the directory /sys/class/gpio
# ls /sys/class/gpio
export gpiochip0 gpiochip32 gpiochip64 gpiochip96 unexport

The gpiochip entries are essentially populated from DT

Boot Loader Loading seperate DTB files along with Kernel Image
[edit]

In the earlier section,we followed an approach of appending the dtb(device tree blob) to the kernel image.

Here are the steps to get u-boot(boot loader) loading the seperate dtb files along with the uImage. For this the u-boot and the uImage has to be modified further.

Follow the instructions below to add this support to boot loader and kernel

Modifying and Re-building the Boot Loader
[edit]

  • Change directory to u-boot in android source path
$ cd <android source path>/u-boot
$ git am Dt_uboot_patch/*
  • Build u-boot
$ make CROSS_COMPILE=arm-eabi- distclean
$ make CROSS_COMPILE=arm-eabi- am335x_evm_config
$ make CROSS_COMPILE=arm-eabi-
  • Copy the new u-boot image to the boot partition
$ cp u-boot.img /media/boot/

Modifying and Re-building Kernel
[edit]

Change to kernel directory

$ cd <android source path>/kernel

Apply these patches from http://processors.wiki.ti.com/images/4/47/Dt_addtional_patches.tar.gz

$ git am Dt_addtional_patches/*

Build kernel and two device tree blobs.

$ make ARCH=arm CROSS_COMPILE=arm-eabi- distclean
$ make ARCH=arm CROSS_COMPILE=arm-eabi- am335x_evm_android_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-eabi- uImage am335x-evm.dtb beaglebone.dtb

The two dtb files am335x-evm.dtb and beaglebone.dtb will boot on same beaglebone but with different GPIOs for heartbeat LED.

Copy the images to the boot partition

$ cp arch/arm/boot/uImage arch/arm/boot/beaglebone.dtb arch/arm/boot/am335x-evm.dtb /media/boot/

Booting uImage with seperate device tree blob
[edit]

Follow the steps in Booting the test platform to start booting the Beaglebone.

Press any key at the boot-loader prompt

U-Boot#

Type the follwing on the U-boot prompt for booting with am335x-evm.dtb blob

U-Boot# mmc rescan ; fatload mmc 0 82000000 uImage;fatload mmc 0 80000000 am335x-evm.dtb
U-Boot# setenv bootargs 'console=ttyO0,115200n8 androidboot.console=ttyO0 mem=256M root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait init=/init ip=off'
U-Boot# fdt addr 80000000; fdt resize; bootm 82000000 - 80000000

Observe that user LED 4 is blinking as heartbeat.

Type the follwing on the U-boot prompt for booting with beaglebone.dtb blob

U-Boot# mmc rescan ; fatload mmc 0 82000000 uImage;fatload mmc 0 80000000 beaglebone.dtb
U-Boot# setenv bootargs 'console=ttyO0,115200n8 androidboot.console=ttyO0 mem=256M root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait init=/init ip=off'
U-Boot# fdt addr 80000000; fdt resize; bootm 82000000 - 80000000

Observe that user LED 3 is blinking as heartbeat.

Pin Ctrl driver support
[edit]

In this section we explain how we add/evaluate a simple pinctrl driver which can

  • Fetch a set of padconf/pinmux settings from the device tree
  • Setup the board pins with these settings upon boot

This way, we can specify a different set of padconf/pinmux in each device tree and the pinctrl driver will set them accordingly on boot.

Here are the steps to demonstrate the use of this new pinctrl driver. We follow the same approach of boot Loader loading seperate DTB files along with Kernel Image.

Steps to add pinctrl driver support
[edit]

$ cd <android source path>/kernel
$ git am Dt_pinctrl_patches/*

NOTE: These set of patches include Basic DT as well as Pin Ctrl support. Explicit pin muxing for GPIO1_23 and GPIO1_24 in board file has been removed as they were present in the earlier set of patches. Here we do the pinmuxing GPIOs seperately from the device tree data.

  • Build kernel and two device tree blobs.
$ make ARCH=arm CROSS_COMPILE=arm-eabi- distclean
$ make ARCH=arm CROSS_COMPILE=arm-eabi- am335x_evm_android_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-eabi- uImage
$ make ARCH=arm CROSS_COMPILE=arm-eabi- am335x-evm.dtb beaglebone.dtb
  • The two dtb files am335x-evm.dtb and beaglebone.dtb will boot on same beaglebone with the following differences
    • am335x-evm device tree include pinmux data for board pin GPMC_A8(GPIO1_24) whereas beaglebone device tree include pinmux data for board pin GPMC_A7(GPIO1_23)
    • They have different GPIOs for heartbeat LED.
  • Copy the images to the boot partition
$ cp arch/arm/boot/uImage arch/arm/boot/beaglebone.dtb arch/arm/boot/am335x-evm.dtb /media/boot/

Booting uImage with seperate device tree blos[edit]

Follow the steps in "Booting the test platform" to start booting the Beaglebone.

  • Press any key at the boot-loader prompt
U-Boot#

Booting with am335x-evm.dtb
[edit]

  • Type the follwing on the U-boot prompt for booting with am335x-evm.dtb blob
U-Boot# mmc rescan ; fatload mmc 0 82000000 uImage;fatload mmc 0 80000000 am335x-evm.dtb
U-Boot# setenv bootargs 'console=ttyO0,115200n8 androidboot.console=ttyO0 mem=256M root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait init=/init ip=off'
U-Boot# fdt addr 80000000; fdt resize; bootm 82000000 - 80000000
  • Observe that user LED 4 is blinking as heartbeat.
  • After console comes up type the command "dmesg" to see that the pinctrl-simple driver configure the pinmux for GPIO1_24 padconf
root@android:/ # dmesg
....
<7>[ 0.275665] pinctrl-simple 44e10800.pinmux: request pin 24 (44e10860) for 44e10800.pinmux

Booting with beaglebone.dtb
[edit]

  • Type the follwing on the U-boot prompt for booting with beaglebone.dtb blob
U-Boot# mmc rescan ; fatload mmc 0 82000000 uImage;fatload mmc 0 80000000 beaglebone.dtb
U-Boot# setenv bootargs 'console=ttyO0,115200n8 androidboot.console=ttyO0 mem=256M root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait init=/init ip=off'
U-Boot# fdt addr 80000000; fdt resize; bootm 82000000 - 80000000
  • Observe that user LED 3 is blinking as heartbeat.
  • After console comes up type the command "dmesg" to see that the pinctrl-simple driver configure the pinmux for GPIO1_23 padconf
root@android:/ # dmesg
....
<7>[    0.275604] pinctrl-simple 44e10800.pinmux: request pin 23 (44e1085c) for 44e10800.pinmux

FrameBuffer driver with Device tree and Pinctrl
[edit]

In this section we explain how we integrate device tree support to da8xx_lcdc(am335x) framebuffer driver

We add support for the framebuffer driver to

  • Fetch a set of panel settings from the device tree blob
    • Settings specific to the display panel being used, like width, heght, timing etc
  • Fetch a set of lcd config settings from device tree blob
    • Settings specific to the lcd panel to board connection, bits per pixel(bpp), ac_bias, dma burst size etc
  • Fetch the LCD pinmux details from the device tree blob and configure on probe

This way all panel, board pinmux specifics of framebuffer driver are moved to device tree.

Here are the steps to integrate. We follow the approach of boot Loader loading device tree blob along with Kernel Image. We evaluate this on AM335X evm instead of beaglebone.

Steps to Integrate[edit]

$ cd <android source path>/kernel
$ git am Dt_lcdc_patches/*

NOTE: These set of patches include Basic DT, Pin Ctrl and LCDC support.

  •   Build kernel and create kernel image and a device tree blob for am335xevm.
$ make ARCH=arm CROSS_COMPILE=arm-eabi- distclean
$ make ARCH=arm CROSS_COMPILE=arm-eabi- am335x_evm_android_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-eabi- uImage
$ make ARCH=arm CROSS_COMPILE=arm-eabi- am335x-evm.dtb
  • The dtb file am335x-evm.dtb is created to boot on am335xevm with the lcdc dt support.
  • Copy the images to the boot partition of the SD card
$ cp arch/arm/boot/uImage arch/arm/boot/beaglebone.dtb arch/arm/boot/am335x-evm.dtb /media/boot/

Booting AM335x EVM with uImage and device tree blob
[edit]

  • Connect the Serial cable and the Power Cable on AM335X EVM
  • Connect to the board through a terminal software like TeraTerm, Minicom or Hyperterminal to see the console messages.
  • Insert SD card into MMC/SD slot on the AM335X EVM.
  • Power ON the AM335X EVM
  • Press any key at the boot-loader prompt
U-Boot#
  • Type the follwing on the U-boot prompt for booting with am335x-evm.dtb blob
U-Boot# mmc rescan ; fatload mmc 0 82000000 uImage;fatload mmc 0 80000000 am335x-evm.dtb
U-Boot# setenv bootargs 'console=ttyO0,115200n8 androidboot.console=ttyO0 mem=256M root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait init=/init ip=off'
U-Boot# fdt addr 80000000; fdt resize; bootm 82000000 - 80000000
  • Observe that the LCDC is coming up with Android Home screen.
  • After console comes up type the command "dmesg" to see that
root@android:/ # dmesg
....
  • LCDC pinumx configuration is being done
<7>[ 0.300140] pinctrl core: add 1 pinmux maps
<7>[ 0.300170] pinctrl-simple 44e10800.pinmux: found group selector 1 for lcdc_pins
<7>[ 0.300170] pinctrl-simple 44e10800.pinmux: request pin 41 (44e108a4) for display.4
<7>[ 0.300201] pinctrl-simple 44e10800.pinmux: request pin 42 (44e108a8) for display.4
<7>[ 0.300201] pinctrl-simple 44e10800.pinmux: request pin 43 (44e108ac) for display.4
<7>[ 0.300231] pinctrl-simple 44e10800.pinmux: request pin 44 (44e108b0) for display.4
<7>[ 0.300231] pinctrl-simple 44e10800.pinmux: request pin 45 (44e108b4) for display.4

...............

<7>[ 0.300567] pinctrl-simple 44e10800.pinmux: enabling function1 lcdc_pins
  • LCDC Panel Data being fetched from DT and printed
<6>[ 0.299957] da8xx_lcdc display.4: GLCD: Found TFC_S9700RTWV35TR_01B panel
<4>[ 0.299957] PANEL INFO lcdc_info->width 800
<4>[ 0.299987] PANEL INFO lcdc_info->height 480
<4>[ 0.299987] PANEL INFO lcdc_info->hfp 39
<4>[ 0.299987] PANEL INFO lcdc_info->hbp 39 

<7>[ 0.275665] pinctrl-simple 44e10800.pinmux: request pin 24 (44e10860) for 44e10800.pinmux

................
  • LCDC Controller data being fetched from DT and printed
<4>[ 0.300659] LCD CFG lcd_cfg->ac_bias 255
<4>[ 0.300659] LCD CFG lcd_cfg->ac_bias_intrpt 0
<4>[ 0.300689] LCD CFG lcd_cfg->dma_burst_sz 16
<4>[ 0.300689] LCD CFG lcd_cfg->bpp 32 

............

Limitations[edit]

In framebuffer support, the patches are not reviewed to put the proper error checks.


References
[edit]

Different DT efforts from linux-omap-pm branches

http://gitorious.org/omap-pm/linux/trees/for_3.2/5_omap_dt_i2c_twl

and

http://gitorious.org/omap-pm/linux/trees/for_3.4/dt_gpio

TI-Android-ICS-4.0.3-DevKit-3.0.1 Links

http://processors.wiki.ti.com/index.php/TI-Android-ICS-4.0.3-DevKit-3.0.1_UserGuide

http://processors.wiki.ti.com/index.php/TI-Android-ICS-4.0.3-DevKit-3.0.1_DevelopersGuide

Pinctrl Support

pinctrl-simple driver https://lkml.org/lkml/2012/5/2/275

Mainline kernel

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=tag;h=refs/tags/v3.4

Future Work[edit]

Will update soon

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article AM335x Android Device Tree Integration here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article AM335x Android Device Tree Integration here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article AM335x Android Device Tree Integration here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article AM335x Android Device Tree Integration here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article AM335x Android Device Tree Integration here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article AM335x Android Device Tree Integration here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article AM335x Android Device Tree Integration here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article AM335x Android Device Tree Integration here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article AM335x Android Device Tree Integration here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity