sabato 21 dicembre 2013

Watterott MI0283QT-9A display on Beaglebone Black with Angstrom

The MI0283QT-adapter is a pratical and good display. As you find more on the internet, this display is fully functional on Raspberry PI but not yet on the TI BeagleboneBlack.
To get it running, there are a number of steps to be taken which I'll summarize in this post.

Compiling the kernel module fbtft_device

In order to compile the kernel module you must be able to build a development environment kernel of Angstrom disto based on the Yoctoproject.

Setting the Angstrom Building Environment

cd setup-scripts
git clone git://github.com/angstrom-distribution/setup-scripts.git
MACHINE=beaglebone ./oebb.sh config beaglebone
MACHINE=beaglebone ./oebb.sh update
bitbake virtual/kernel
Now take a coffee... (a long coffee...). When a building shell is ready, move to the kernel directory drivers/video and clone the notro's repo for fbtft device:
cd drivers/video
git clone https://github.com/notro/fbtft.git

# Let make/kbuild see the directory and config options.
echo "obj-y += fbtft/" >> Makefile
sed -i 's/endmenu/source "drivers\/video\/fbtft\/Kconfig"\n\nendmenu/' Kconfig

# Make the header file available
ln fbtft/fbtft.h ../../include/linux/fbtft.h
After that, return in the "main kernel directory" and add these line to your .config:
CONFIG_FB_TFT=m
CONFIG_FB_TFT_HX8340BN=m
CONFIG_FB_TFT_HX8347D=m
CONFIG_FB_TFT_ILI9320=m
CONFIG_FB_TFT_ILI9325=m
CONFIG_FB_TFT_ILI9341=m
CONFIG_FB_TFT_PCD8544=m
CONFIG_FB_TFT_SSD1289=m
CONFIG_FB_TFT_SSD1351=m
CONFIG_FB_TFT_ST7735R=m
CONFIG_FB_TFT_WATTEROTT=m
CONFIG_FB_FLEX=m
CONFIG_FB_TFT_FBTFT_DEVICE=m
Now expect to be able to build the kernel and modules fbtft as usual.

UPDATE: (following some comments) please put the fbtft driver in /lib/modules/3.8.13/drivers/video/fbtft/, create it if does not exist in your bbb and then execute depmod -a. Thanks

Setting the Angstrom distribution

1- Replace the kernel with the previously compiled
cp uImage-mynewkernel /boot/
cd /boot
mv uImage uImage-3.8.13
ln -sf uImage-mynewkernel uImage
cd 
sync

2- Create the DeviceTree for MI0283QT-9A

Save the following file as BB-LCDWATTEROTT-00A0.dts on beaglebone black:
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
/dts-v1/;
/plugin/;

/ {
 compatible = "ti,beaglebone", "ti,beaglebone-black";

 /* identification */
 part-number = "BB-LCDWATTEROTT";
 version = "00A0";

 /* state the resources this cape uses */
 exclusive-use =
  /* the pin header uses */
  "P9.31", /* spi1_sclk */
  "P9.29", /* spi1_d0 */
  "P9.30", /* spi1_d1 */
  "P9.28", /* spi1_cs0 */
  "P9.42", /* spi1_cs1 */
  "P9.15", /* gpio1_16 - reset */
  "P9.23", /* gpio1_17 - led */
  /* the hardware ip uses */
  "spi1",
  "gpio1_16",
  "gpio1_17";

 fragment@0 {
  target = <&am33xx_pinmux>;
  __overlay__ {
   /* default state has all gpios released and mode set to uart1 */
   bb_spi1_pins: pinmux_bb_spi1_pins {
    pinctrl-single,pins = <
     0x190 0x33 /* mcasp0_aclkx.spi1_sclk, INPUT_PULLUP | MODE3 */
     0x194 0x33 /* mcasp0_fsx.spi1_d0, INPUT_PULLUP | MODE3 */
     0x198 0x13 /* mcasp0_axr0.spi1_d1, OUTPUT_PULLUP | MODE3 */
     0x19c 0x13 /* mcasp0_ahclkr.spi1_cs0, OUTPUT_PULLUP | MODE3 */
     //0x164 0x12 /* eCAP0_in_PWM0_out.spi1_cs1 OUTPUT_PULLUP | MODE2 */
    >;
   };
  };
 };

 fragment@1 {
  target = <&spi1>; /* spi1 is numbered correctly */
  __overlay__ {
   status = "okay";
   pinctrl-names = "default";
   pinctrl-0 = <&bb_spi1_pins>;

   #address-cells = <1>;
   #size-cells = <0>;

   channel@0 {
    #address-cells = <1>;
    #size-cells = <0>;

    compatible = "spidev";

    reg = <0>;
    spi-max-frequency = <32000000>;
    spi-cpha;
   };


   channel@1 {
    #address-cells = <1>;
    #size-cells = <0>;

    compatible = "spidev";

    reg = <1>;
    spi-max-frequency = <32000000>;
   };
  };
 };

 fragment@2 {
  target = <&am33xx_pinmux>;
  __overlay__ {
  status = "okay";
  lcd_ctrl_pinmux: lcd_ctrl_pins {
    pinctrl-single,pins = <
     0x040 0x17  /* gpio1_16  OUTPUT_PULLUP | MODE7 */
                                        0x044 0x17  /* gpio1_17  OUTPUT_PULLUP | MODE7 */
     >;
   };
  };
 };

 
 fragment@3 {
  target = <&ocp>;
  __overlay__ {
  test_helper: helper {
    compatible = "bone-pinmux-helper";
    pinctrl-names = "default";
    pinctrl-0 = <&lcd_ctrl_pinmux>;
    status = "okay";
   };
  };
 };
};
Then run:
dtc -O dtb -o BB-LCDWATTEROTT-00A0.dtbo -b 0 -@ BB-LCDWATTEROTT-00A0.dts
cp BB-LCDWATTEROTT-00A0.dtbo /lib/firmware/

Enable the driver

Edit uEnv.txt for disable HDMI cape on boot. Add capemgr.disable option to optargs.

mount /dev/mmcblk0p1 /media/card
cat /media/card/uEnv.txt
optargs=text quiet capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN
then you can reboot. After that you can start the display:
echo BB-LCDWATTEROTT > /sys/devices/bone_capemgr.9/slots
modprobe fbtft_device name=mi0283qt-9a busnum=1 gpios=reset:48,led:49
Optionally you can disable the blank console on tty1 with this command:
echo -ne "\033[9;0]" > /dev/tty1
Testing the watterott's display

Thanks to Derek Molloy and Noralf Trønnes and Lindsey Stirling that have inspired me!


martedì 2 luglio 2013

Nulla si crea e nulla si distrugge


Non so che direzione prenderanno queste pagine scritte alla rinfusa su internet, ma speriamo che siano interessanti per chi si ritrova tra navigare tra queste pagine.

...tutto si trasforma !


Perchè una citazione così altisonante?
Perchè tra queste pagine non si crea e non si distrugge nulla ma si trasfmorma e si riadatta e si modifica a piacimento e per necessità come e solo l'opensource e la sua filosofia in piena libertà ti concede di fare.


Buona lettura.