1 Reply Latest reply on Mar 23, 2015 6:00 PM by Einse57

    RoboPeak USB Display Setup with Galileo Debian

    Einse57

      Hi Everyone,

       

      I went through the exercise this weekend of getting the RoboPeak USB display (2.8” USB TFT Touch Display Screen for Raspberry Pi V2) working with Galileo without yocto and thought I would share the steps I followed in the hopes that it saves some integration time for someone. If anyone has any notes or comments please chime in.

       

      Useful Resources:

      http://sourceforge.net/p/galileodebian/

      http://www.robopeak.com/data/doc/rpusbdisp/RPUD02-rpusbdisp_usermanual-enUS.1.5.pdf

      https://github.com/robopeak/rpusbdisp

       

      Gathering Software/Preparing the Image

      http://sourceforge.net/p/galileodebian/wiki/Home/

      Packaged yocto build with a bunch of drivers already installed. Downloaded Galileo 1.2 image (galileo-1.2.img.gz)

       

      Used http://www.netbsd.org/~martin/rawrite32/download.html to write the galileo-1.2.img.gz image to SD

       

      Setting Up the Image

      Logged in as root/root

       

      **Decided to compile rp_usbdisp modules natively since they were not present in image

       

      -Prerequisite tools:

      apt-get install git linux-headers gcc binutils make

       

      -Git segfaulted under a normal pull request, traced to pthread segfault. This was caused by a bug which causes the execution to segfault under certain conditions.

      The hack should be safe on Galileo, since its Quark processor is single core, single thread.

      The hack must be re-applied every time libpthread is updated, since the update will overwrite the hack.

      The following hack replaces the lock prefix with a nop:

      (source: galileo debian wiki - setup SD card)

       

      root@GalileoSDK:/# for i in `/usr/bin/find /lib -type f -name \*pthread\*so`; do cp ${i} ${i}.bak; sed -i "s/\xf0\x0f\xb1\x8b/\x90\x0f\xb1\x8b/g" ${i};

      done

       

      -After running the above, git pull requests worked.

       

      Compiling the RoboPeak Module

      -Performed git clone from rp_usbdisp repository

      git clone https://github.com/robopeak/rpusbdisp.git

       

      -Verified that rpusbdisp folder was in home directory

       

      -Cd to ~/rpusbdisp/drivers/linux-driver folder

       

      -Ran make with appropriate parameters for linux headers

      make KERNEL_SOURCE_DIR=/usr/src/linux-headers-3.8.7/

       

      -Rpusbdisp modules compiled ok

       

      -Located rp_usbdisplay.ko module (should be in current directory) and copied to /lib/modules/3.8.7/kernel

       

      -Ran "depmod -a" command

       

      -Asked the kernel to load the newly compiled module with "insmod rp_usbdisplay"

      Should see some notes out success go by

       

      -Screen framerate can be adjusted with "modprobe rp_usbdisplay fps=16" or higher

       

      -You can verify that the kernel module loaded with "lsmod" and looking for "rp_usbdisplay" in the listing

       

      -There was no lsusb on distro, ran "apt-get install usbutils"

       

      -There seemed to be a problem with USB operation. Each time a usb device was plugged in there was a "bad entry 9cdd080" message shown and there were no actions taken by the os to load and create device nodes. "lsusb" returns no device listings.

       

      -Performed "apt-get dist-upgrade"

       

      -Rebooted

       

      -After reboot logged with root/root and ran "depmod -a"

       

      -Verified robopeak display present with "lsusb" display shows up properly as "fccf:a001"

       

      -Ran "modprobe rp_usbdisplay"

      Received no errors/warnings, device registered and input assigned

       

      -Verified that a new framebuffer device was present in /dev/, appeared as /dev/fb0

       

      -Performed screen test using "cat /dev/urandom > /dev/fb0" which correctly filled the screen with random pixel data

       

      Getting to a Desktop

      -When looking at installing X11, noticed that filesystem partition was only 1000MB and most of it was used

      Need roughly 1GB for X11 bloat with "apt-get install gdm3"

       

      *********

      Live Resize:

       

      -Used "parted /dev/mmcblk0 resize part 2" to resize card partition size

      When asked about size, enter the card size in MB. In my 16 GB case this was 14830MB

       

      -Rebooted

       

      -Ran "tune2fs /dev/mmcblk0p2"

       

      -Ran "resize2fs /dev/mmcblk0p2" to take advantage of the new space

       

      *********

      Offline Approach:

      -Shut everything down and pull the SD card

      -Plug the SD card into a linux system

      -Run "parted /dev/sda" where a is the letter your SD shows up as

      -"unit chs" display info on the SD card in terms of cylinder/head/sector

      -"print"

       

      (parted) print

      Model: USB Mass Storage Device (scsi)

      Disk /dev/sda: 3880,27,50

      Sector size (logical/physical): 512B/512B

      BIOS cylinder,head,sector geometry: 3880,255,63.  Each cylinder is 8225kB.

      Partition Table: gpt

       

      Number  Start     End         File system  Name  Flags

      1      0,0,34    12,40,45    fat16              boot

      2      12,40,46  114,186,38  ext3

       

      -Look for the max size of your SD card - in my case this is 3880

      -Look for the partition you want to resize (2 for me) and where it begins (12,40,46 for me)

      -Delete the partition you want to resize with "rm 2"

      -Make a new parition of the desired size with "mkpart 12,40,46 3880,0,0" (your numbers will differ, you can also specify this as "mkpart 12,40,46 100%")

      -"print" to make sure everything show up right, note that the starting address of the new partition 2 is identical to its original value. This is key.

       

      (parted) print

      Model: USB Mass Storage Device (scsi)

      Disk /dev/sda: 3880,27,50

      Sector size (logical/physical): 512B/512B

      BIOS cylinder,head,sector geometry: 3880,255,63.  Each cylinder is 8225kB.

      Partition Table: gpt

       

      Number  Start     End         File system  Name     Flags

      1      0,0,34    12,40,45    fat16                 boot

      2      12,40,46  3880,27,17  ext3         primary

       

      -"quit" out of parted

      -"sudo e2fsck -f /dev/sda2" to rebuild things

      -"sudo resize2fs /dev/sda2" to expand the filesystem

      -Pull the SD card and plug back into the Galileo

      -Boot to prompt

      *********

       

      -Ran "apt-get install gdm3" to install x11/gnome

       

      -Copied /home/root/rpusbdisp/drivers/linux-driver/xserver_conf to /usr/share/X11/xorg.conf.d/

       

      -Verified frame buffer names matched, in this case both were named fb0

       

      -Performed "echo rp_usbdisplay>>/etc/modules"

       

      -Rebooted

       

      -Received continuous streaming messages about "vgaarb: this pci device is not a vga device"

      Some messages pointed to a problem with pthread, which indicated a possible need to perform the hack above again.

       

      -Performed the following

      root@GalileoSDK:/# for i in `/usr/bin/find /lib -type f -name \*pthread\*so`; do cp ${i} ${i}.bak; sed -i "s/\xf0\x0f\xb1\x8b/\x90\x0f\xb1\x8b/g" ${i};

       

      done

       

      *This solved the streaming errors from vgaarb

       

      -Startx and xinit were not found. Had to run "apt-get install xorg"

       

      -With robopeak display plugged into USB, "modprobe rp_usbdisplay" run, "xinit" produced a command line on the display.

       

      -Rebooted

       

      -After reboot with display plugged in, desktop manager properly displayed and dropped to login. Everything appears to be functional.

       

      Account info:

      username: root

      password: root

       

      username: user

      password: none

       

      Follow-ons:

      -May need to set resolution in X11 conf folder 10-disp

      -May need to set up X11 accounts properly, showing "other" at login

       

      Configuration help with X11

      http://wiki.gentoo.org/wiki/Xorg/Configuration

       

      Thanks!

      IMG_1172 - Copy.JPG

        • 1. Re: RoboPeak USB Display Setup with Galileo Debian
          Einse57

          More Fun with the RoboPeak Display


          If you need to set resolution in X11 conf folder 10-disp

          In /usr/share/X11/xorg.conf.d/10-disp.conf, add the "Modes" line below

           

          Section "Screen"

              Identifier "RPUSBDisp"

              Device "RPUSBDispFB"

              DefaultFbBpp 16

              SubSection "Display"

                Visual "TrueColor"

                Modes "320x240"

              EndSubSection

          EndSection

           

          If you need to set up X11 Autologin

          *Option 1

          In /etc/rc.local add a line before "exit 0" as follows: "su - root -c startx &"

          This starts xwindows automatically and logs in as root

           

          *Option 2

          In /etc/gdm3/daemon.conf uncomment the lines below and set root to whatever username you want logged in when x starts

           

          # Enabling automatic login

            AutomaticLoginEnable = true

            AutomaticLogin = root

           

          Then add the following to /etc/rc.local before "exit 0": "startx &"

          This starts xwindows automatically

           

          Setting the display to be used with python UI applications

           

          Install Tkinter (tkinter if using 3.0+) with "apt-get install python-tk"

           

          If when running an application that uses Tkinter, python complains about not knowing what screen to use if run from command line then you most likely don't have the $DISPLAY environment variable set. you can confirm this using:

           

          "echo $DISPLAY"

           

          if it comes back with nothing, we need to identify what display the gdm3 desktop is running on so we can point our UI application to that display.

           

          *Option 1

          find out what display X is running on:

          "ps -aux |grep X", you should see results similar to:

           

          root      2041  0.0  2.1  30216  5028 tty7    Ss+  Jan04  0:01 /usr/bin/Xorg : 0 -br -verbose -novtswitch -auth /var/run/gdm3/auth-for-Debian-gdm-xY8lVV/databa se -nolisten tcp vt7

          root      2153  0.0  0.2  3200  624 ?        S    Jan04  0:00 xinit /etc/X11/ xinit/xinitrc -- /etc/X11/xinit/xserverrc :1 -auth /tmp/serverauth.4AtWqzLo9q

          root      2155  0.0  2.7  31160  6420 tty1    S<s+ Jan04  3:25 /usr/bin/X -nol isten tcp :1 -auth /tmp/serverauth.4AtWqzLo9q

          root    15770  0.0  0.2  1940  616 ttyS1    S+  08:34  0:00 grep X

           

          *Option 2

          you can also check the folder located at:

           

          /tmp/.X11-unix/

           

          and see what displays are listed. These should be in the format of X1, X2, etc.

           

          *Option 3

          You can use this script to enumerate current displays

           

          for file in /proc/[0-9]*; do grep -ao 'DISPLAY=[^[:cntrl:]]*' $file/environ 2>/dd

          ev/null && grep -ao '(.*)' $file/stat; done | sed 'N;s/\n/\t/'

           

          Which will result in something like:

           

          root@galileo:~# ./enum_displays.scr

          DISPLAY==:0    (Xorg)

          DISPLAY=:1      (ck-launch-sessi)

          DISPLAY=:1      (dbus-launch)

          DISPLAY=:1      (ssh-agent)

          DISPLAY=:1      (dbus-daemon)

          DISPLAY=:1      (x-session-manag)

          DISPLAY=:1      (dbus-launch)

          DISPLAY=:1      (dbus-daemon)

          DISPLAY=:1      (gnome-settings-)

          DISPLAY=:1      (gnome-keyring-d)

          DISPLAY=:1      (gvfsd)

          DISPLAY=:1      (gvfs-gdu-volume)

          DISPLAY=:1      (gvfs-afc-volume)

          DISPLAY=:1      (gvfs-gphoto2-vo)

          DISPLAY=:1      (metacity)

          DISPLAY=:1      (gnome-panel)

          DISPLAY=:1      (gsd-printer)

          DISPLAY=:1      (gconfd-2)

          DISPLAY=:1      (dconf-service)

          DISPLAY=:1      (gnome-fallback-)

          DISPLAY=:1      (bluetooth-apple)

          DISPLAY=:1      (polkit-gnome-au)

          DISPLAY=:1      (gnome-sound-app)

          DISPLAY=:1      (notification-da)

          DISPLAY=:1      (pulseaudio)

          DISPLAY=:1      (mission-control)

           

          In all cases the display you should target given these outputs is DISPLAY=:1

           

          You can test which display you're currently addressing using this command to launch your application:

           

          "( DISPLAY=:X yourapp )" subbing X for 0, 1, etc

           

          *Note: if launching python scripts from the command line make sure to add "#!/usr/bin/python" to the top of the script to avoid bash instrusions, chmod +x yourapp will let you execute the script.

           

          Hello world example to try

          --------

          #!/usr/bin/python

          from Tkinter import *

           

           

          class Application(Frame):

              def say_hi(self):

                  print "hi there, everyone!"

           

           

              def createWidgets(self):

                  self.QUIT = Button(self)

                  self.QUIT["text"] = "QUIT"

                  self.QUIT["fg"]  = "red"

                  self.QUIT["command"] =  self.quit

           

           

                  self.QUIT.pack({"side": "left"})

           

           

                  self.hi_there = Button(self)

                  self.hi_there["text"] = "Hello",

                  self.hi_there["command"] = self.say_hi

           

           

                  self.hi_there.pack({"side": "left"})

           

           

              def __init__(self, master=None):

                  Frame.__init__(self, master)

                  self.pack()

                  self.createWidgets()

           

           

          root = Tk()

          app = Application(master=root)

          app.mainloop()

          root.destroy()

          ------

           

          You can test launch the above script using ( DISPLAY=:1 yourapp )

           

          You can make the DISPLAY setting permanent by adding it to your ~/.profile (appropriate) or /etc/environment (bad) as:

           

          DISPLAY=:1

           

          Log out then log in to read in these changes

           

          IMG_1225.JPG

           

          IMG_1224.JPG

           

          Disable the X11 screen blanking timer

           

          With the DISPLAY variable set appropriately, run the following command at the console:

           

          "xset s off"

           

          This disables the X screensaver subsystem entirely.