Omega2 & Omega2plus Image Build process for FBTFT - Frame Buffer TFTLCD Devices



  • Installing Operating System

    Debian Stretch 9.5 Multi Arch including firmwares
    Debian Stretch 9.5 multiarch page
    Direct Download Includes Firmwares

    Preperations - To do list

    PS.

    • wrt-build is my machine name
    • yasin is my username
    • if you are not using git, you can ignore git config part.

    [ ] ! Install the system just ssh-server package, either X nor other packages.
    [ ] ! First login

    • login as root
    • apt-get update && apt-get upgrade
    • apt-get install sudo screen reptyr bash-completion net-tools dnsutils
      • sudo -> gives root's power to a simple user
      • screen -> we can start a job and teke it from else where
      • reptyr -> we can intervention any process with this (just cool)
      • bash-completion -> it's useful in most cases on console
      • net-tools and dnsutils -> networking and name resolve binaries

    [ ] ! Give root permissions to user (add user to sudo group)

    • as root type adduser yasin sudo we already install sudo app.
    • logout and login as user
    • test it root power with this command sudo apt-get upgrade ! we need to type user's password not root's

    [ ] ! Install needed applications and extra applications to the build system

    • Applications listed below are gathered from OpenWrt's page and I appened my try & errors.
    • You can take a coffe or two in this step. (Depends bandwidth of the internet connection)
    sudo apt-get install asciidoc bc binutils bzip2 fastjar flex git git-core g++ g++-multilib util-linux gawk libgtk2.0-dev libgtk3.0-cil-dev libgtk3-perl intltool jikespg zlib1g-dev make genisoimage libncurses5-dev libssl-dev patch python2.7-dev python3-dev python3.5-dev python-pip python3-pip rsync ruby sdcc unzip wget gettext xsltproc zlibc zlib-gst zlib1g zlib1g-dev zlib1g-dbg libboost-all-dev libxml-parser-perl libusb-dev bin86 bcc sharutils curl libexpat1 libexpat1-dev gettext gettext-lint gettext-el libintl-perl libpng++-dev gfortran mpich debhelper libtool libtool-bin libremctl-dev libdbus-1-dev libdbus-c++-dev libdbusmenu-glib-dev libdbus-glib2.0-cil-dev libdbusmenu-qt-dev libdbus-ocaml-dev libdbus-1-3 libdbusmenu-gtk-dev libdbuskit-dev libdbus-glib-1-dev subversion mercurial hgsvn hgsubversion locate m4 openjdk-8-jdk libre2-dev unrar-free imagemagick libssl-ocaml-dev libncurses5-dev ccache csh debconf libiconv-hook-dev
    

    Need to get 1,587 MB of archives.

    • Installing nodejs and node-gyp using nvm (node version manager)
    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
    	or
    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
    
    • logout and login as user or type source ~/.bashrc this way we can use nvm
    
    nvm install lts/argon
    nvm install stable
    nvm alias default stable
    nvm use stable
    npm install -g node-gyp
    
    yasin@uxn:~$ node -v
    v9.11.1
    yasin@uxn:~$ npm -v
    5.6.0
    yasin@uxn:~$ node-gyp -v
    v3.7.0
    

    All the packages those need to node-gyp can build with default but node-usb and i2c-exp-node packages

    [ ] Git configuration
    If you don't have any git account you can ignore this step and use https://... github clone processes.

    • add a ssh key to github, tutorial is here
    • create ~/.ssh directory and needed file(s)
    mkdir ~/.ssh
    nano ~/.ssh/config
    # add below lines in to config file
    	Host github.com
            User    unique1984 "this one is your github username"
            IdentityFile ~/.ssh/id_rsa "this one is your created id_rsa file"
    # save and close the file Ctrl+o, Ctrl+x
    # change permissions to ./ssh and nested files
    chmod 744 ~/.ssh
    chmod 600 ~/.ssh/*
    
    • id_rsa is your enc/dec key, don't lose it nor give someone else, id_rsa.pub goes to github's side.
    • add github hostkey in to knownhosts typing,
    ssh-keyscan -H "github.com" >> ~/.ssh/known_hosts
    

    this way we won't see append key prompt from github

    • configuring git global
    • git config --global user.name "Yasin KARABULAK"
    • git config --global user.email "yasinkarabulak@gmail.com"
      that's it.

    Getting the build system source from omega

    [ ] Clone the source

    cd ~/
    git clone https://github.com/OnionIoT/source.git
    	# or if you have a github account that setted up with your ssh key.
    git clone git@github.com:OnionIoT/source.git
    

    ! At least 1 time reading before any question, would be nice (I'm just a human being I might miss some points.)
    ! Open Wrt Lede Build System Usage Docs

    • Fully specified documentation of lede build system.

    ! Onion Cross Compilation Docs

    • Fully specified documentation of Onion's side

    With these two documents we can start build process


    [ ] Make host system config

    • Cross Compile binaries's location in to the $PATH variable.
    nano ~/.bashrc
    # append below line in to .bashrc file
    export PATH=$PATH":~/source/staging_dir/host/bin:~/source/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/bin"
    # save and close the file ctrl+o,ctrl+x
    

    this way system will know where are the cross compilation binaries.

    Image Build Process

    cd ~/source
    git log
    commit d62d8430d155f737013a9f4aa9c2a98e6440e903
    Author: greenbreakfast <lazardemin@gmail.com>
    Date:   Tue Jul 17 23:41:25 2018 +0000
    
        added telnet and telnetd to busybox config
    
    commit 0066202f3a8ef8dc8b0da6842d9b72692a814646
    Author: greenbreakfast <lazardemin@gmail.com>
    Date:   Wed Jul 11 21:38:47 2018 +0000
    
        added adc-exp package and python module to package repo, as well as kernel modules for spi gpio bitbang
    
    commit 72d103106dd7a22edbdfdba0d0c98d3ac33afcf6
    Author: greenbreakfast <lazardemin@gmail.com>
    Date:   Thu Jul 5 21:42:13 2018 +0000
    
        updated onion script, new versions of OnionOS and camera apps
    
    ...
    
    # each commit is our build number last commit is "b192" before that "b191" after compilation our build named to "b193".
    

    Image Configuration

    We are using the Onion's build system so we don't need to change menuconfig's "Target System", "Subtarget", "Target Profile", "Target Devices" and "Target Images" options, if anyone who wants to chroot type image then activate this selection in the "Target Images" menu.

    Target Images  --->
    	[*] tar.gz
    

    [ ] Revert to the base

    1. git reset --hard d62d8430d155f737013a9f4aa9c2a98e6440e903
      • reset everything to b192

    [ ] Update & Install feeds

    1. ./scripts/feeds update -a
      • Update feeds
    2. ./scripts/feeds install -a
      • install feeds

    [ ] Menu configuration

    1. make menuconfig
      • save and exit for now, details are here
    2. make defconfig

    [ ] Kernel menu configuration

    1. make kernel_menuconfig
      • this command will compile some of the cross compile tools and shows the kernel_menuconfig window.
      • details are here
      • we will select fbtft driver modules in here.
      • You can take a coffe or two in this step. (Depends of Cpu power)
        We will select some Graphic Drivers, some Character Devices, some Staging Drivers from under the "Device Drivers" section

    attention: below list is not a menu ordered, it is a process ordered list

    Device Drivers  --->
    	Graphics support  --->
        	Frame buffer Devices  --->
            	<M> Support for frame buffer devices  --->
                	[*]   Enable firmware EDID
    			[*] Framebuffer foreign endianness support  --->
                [*] Enable Video Mode Handling Helpers
                [*] Enable Tile Blitting Support
    		[*] Backlight & LCD device support  --->
            [*] Bootup logo  --->
    	[*] Staging drivers  --->
        	[*]   Staging Board Support
        	<M>   Support for small TFT LCD display modules  --->
            	# select your display driver or all of them your cohice
            	<M>   FB driver for the ILI9341 LCD Controller
                <M>   Generic FB driver for TFT LCD displays
                <M>   Module to for adding FBTFT devices
    	Character devices  --->
        	[*]   Virtual terminal
            [*]     Enable character translations in console (NEW)
            [*]     Support for console on virtual terminal (NEW)
            [*]     Support for binding and unbinding console drivers
            [*]     Support multiple instances of devpts
    	Graphics support  --->
        	Console display driver support  --->
            	[*]   Enable Scrollback Buffer in System RAM (NEW)
                <M> Framebuffer Console support
                [*]   Map the console to the primary display device
                [*]   Framebuffer Console Rotation
    Library routines  --->
    	[*] Select compiled-in fonts
        [*]   VGA 8x8 font
        [*]   VGA 8x16 font
    # Save and Exit kernel_menuconfig window
    
    1. ./scripts/diffconfig.sh > ~/diffconfig
      • Creates a diff file
      • Details are here
    2. make defconfig
      • ! again

    [ ] Download have compile packages

    1. make download
      • This command get all the files those will compile

    ! Before the compile process

    • check this file's 29th line package/feeds/telephony/re/Makefile
    	...
    	DEPENDS:=+libopenssl +libpthread +zlib
        ...
    

    if +zlib is not in there, put it in there. libre, librem, baresip packages allways gives an error for this.


    • Leave your computer connected to the internet, i think make download is not enough.
    • LANG=C LC_ALL=C enter.

    [ ] Before the compilation process check the config files for reset
    ! It happened to me while writing this tutorial, built was succeeded but created image was 5.3MB it should be 7.1MB, when I checked the menuconfig there was nothing in there, there are 2 things that i can think

    • 1st one is, It is normal, first run just compile the toolchain with base system without packages then after this we should make menuconfig and kernel_menuconfig.
    • 2nd one is, This is abnormal do 'make clean' take Revert to the base step and do it again above steps.

    I could not try the 2nd possibilty because of the time (23:13) and already compiled toolchain (it took 2 hours on my computer) simply I did menu_config and kernel_menuconfig without make clean (this clean all the packages those built) and diff (7th step).


    [ ] Compile the images and all selected packages ignoring errors.

    1. IGNORE_ERRORS=1 make -j2
      • node-usb and i2c-exp-node packages will give an error (look at the after compilation part)
      • This command starts build process
      • make package/utils/busybox/{clean,compile,install} -j1 V=s this will clean then compile then install the package busybox with debugging mode (-j1 V=s)
      • IGNORE_ERRORS=1 make -j2 this is a life saver :) if you want to troubleshooting after compilation you can use this, if some packets give an error then you can compile and debug them using above command.
      • Details are here

    [ ] After Compilation

    • we should use node lts/argon for the node-usb and i2c-exp-node packages.
    nvm use lts/argon
    npm install -g node-gyp
    # after restart the machine node default will be node version
    
    make package/feeds/onion/node-usb/{clean,compile,install} -j1 V=s
    make package/feeds/onion/i2c-exp-node/{clean,compile,install} -j1 V=s
    
    # after these steps refreshing the compile
    
    make -j2
    # that is it.
    

    [ ] For cleanup and revert the config (do not use if it's not must, time issues)

    • make clean deletes all of the compiled packages without touching toolchain, if you use it mistakenly it will possibly give a headache. Details are here
    • after make clean you can go to step Revert to the base and start all over with having toolchain.

    [ ] Locating image (bin) files

    • They have created under ~/source/bin/targets/ramips/mt7688/ directory.
    • #Omega2plus lede-ramips-mt7688-omega2p-squashfs-sysupgrade.bin
    • #Omega2 lede-ramips-mt7688-omega2-squashfs-sysupgrade.bin

    [ ] Copy image file in to a flashdisk and flash the Omega2, tutorial is here

    [ ] Locating the needed fbtft module (.ko) files

    # under the ~/source/ directory
    find . -name "*.ko" | grep "fb" -type f
    

    this command gives us most of the modules we need. Other ones trial and error, insmod and if it is give an error grep -irn "error_function_name" ./ this way we will learn which module is absent and find it and append the list.

    • They have created under these directories;
      • ~/source/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7688/linux-4.4.74/drivers/video/fbdev/core/
        1. fb.ko
        2. fb_sys_fops.ko
        3. syscopyarea.ko
        4. sysfillrect.ko
        5. sysimgblt.ko
      • ~/source/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7688/linux-4.4.74/drivers/staging/fbtft/
        1. fb_ili9341.ko
        2. fbtft_device.ko
        3. fbtft.ko
      • ~/source/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7688/linux-4.4.74/drivers/video/backlight/
        1. backlight.ko
      • ~/source/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7688/linux-4.4.74/drivers/video/console/
        1. bitblit.ko
        2. fbcon_ccw.ko
        3. fbcon_cw.ko
        4. fbcon.ko
        5. fbcon_rotate.ko
        6. fbcon_ud.ko
        7. softcursor.ko
        8. tileblit.ko
      • ~/source/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7688/linux-4.4.74/lib/fonts/
        1. font.ko

    Overall modules (18 items) and use purposes with init order.

    # frame buffer device `/dev/fb0` kernel modules
    1st fb_sys_fops.ko
    2nd fb.ko
    3rd backlight.ko
    4th sysfillrect.ko
    5th syscopyarea.ko
    6th sysimgblt.ko
    7th fbtft.ko
    8th fb_ili9341.ko
    9th fbtft_device.ko <with arguments>
    
    # virtual console `/dev/vcs1` kernel kernel modules
    font.ko
    softcursor.ko
    fbcon_cw.ko
    fbcon_ccw.ko
    fbcon_ud.ko
    tileblit.ko
    fbcon_rotate.ko
    bitblit.ko
    fbcon.ko
    

    [ ] Copy the kernel modules in to just flashed Omega2's /root/modules directory.

    Special thanks to Maximilian Gerhardt without his Building Kernel Modules for the Omega2 topic I did'nt think about to copy ".ko" files in to omega2.

    • On the omega2's console,
    cd ~/
    mkdir modules
    
    • after this copy all the files in to Omega2's /root/modules/ directory using scp, flashdisk, microsd etc.

    [ ] Inıting the modules.

    • I will share just the init/deinit scripts, in here. You can find more in this topic

    display init script

    #!/usr/bin/env sh
    
    # init order
    insmod /root/modules/fb_sys_fops.ko
    insmod /root/modules/fb.ko
    insmod /root/modules/backlight.ko
    insmod /root/modules/sysfillrect.ko
    insmod /root/modules/syscopyarea.ko
    insmod /root/modules/sysimgblt.ko
    insmod /root/modules/fbtft.ko
    insmod /root/modules/fb_ili9341.ko
    
    insmod /root/modules/fbtft_device.ko custom name="fb_ili9341" busnum=32766 cs=1 speed=96666000 mode=3 fps=100 txbuflen=3145728 buswidth=8 bgr=1 gpios=reset:2,dc:3 width=240 height=320 verbose=3 rotate=90 debug=2 
    

    display deinit script

    #!/usr/bin/env sh
    
    rmmod /root/modules/fbtft_device.ko
    
    rmmod /root/modules/fb_ili9341.ko
    rmmod /root/modules/fbtft.ko
    rmmod /root/modules/sysimgblt.ko
    rmmod /root/modules/syscopyarea.ko
    rmmod /root/modules/sysfillrect.ko
    rmmod /root/modules/backlight.ko
    rmmod /root/modules/fb.ko
    rmmod /root/modules/fb_sys_fops.ko
    

    virtual console has a missing point, i could'nt use this properly so initing this is not must

    virtual console init script

    #!/usr/bin/env sh
    
    # fbcon vcs device
    insmod /root/modules/font.ko
    insmod /root/modules/softcursor.ko
    insmod /root/modules/fbcon_cw.ko
    insmod /root/modules/fbcon_ccw.ko
    insmod /root/modules/fbcon_ud.ko
    insmod /root/modules/tileblit.ko
    insmod /root/modules/fbcon_rotate.ko
    insmod /root/modules/bitblit.ko
    insmod /root/modules/fbcon.ko
    

    virtual console deinit script

    #!/usr/bin/env sh
    
    # fbcon deinit
    rmmod /root/modules/fbcon.ko
    rmmod /root/modules/bitblit.ko
    rmmod /root/modules/fbcon_rotate.ko
    rmmod /root/modules/tileblit.ko
    rmmod /root/modules/fbcon_ud.ko
    rmmod /root/modules/fbcon_ccw.ko
    rmmod /root/modules/fbcon_cw.ko
    rmmod /root/modules/softcursor.ko
    rmmod /root/modules/font.ko
    

    • Further to do list for myself, i have.
      [ X ] Find a way to creating image includes these modules. | Edit 29.07.2018 without fbtft_device.ko, the way found. (+200KB in to the original image)

    [ X ] Find a way to implement fbtft_device (31.07.2018)
    0_1533027702843_7e04d279-86b3-45dc-be36-65c645323064-image.png


    [ X] Find a way to append spi touch modules.(29.08.2018)
    0_1535528823952_Screenshot_20180829_103932.png
    With Atmega328p, rc522 and spi touch modules integrated. I wrote my communication protocol(simple and stupid, 1Mhz) because of serial interface's slow transmit rate. This way i am manipulating Atmega for my own needs, using omega2's power.


    [ X ] Write a simple framebuffer parser that can create and manipulate a desktop area on the display.(29.08.2018)
    0_1535529394649_7f2abc67-7d72-4cd8-af6b-9e0966c6900d-image.png


    [ ] Find a way to make use of kdb and UTF-8 console fonts for the desktop and it's applications.


    [ ] Take over the Mars before Elon do.

    If these are happens, many projects that look cool and with minimal cost can be implemented with Omega2, I think.

    Bonus


    0_1536175626912_8d828bf5-c9c8-4037-a3f1-795549c88639-image.png

    0_1536175881214_283366c0-3ea1-4619-bd06-6bcd5dcdb84d-image.png



Looks like your connection to Community was lost, please wait while we try to reconnect.