Search code examples
linux-device-driverembedded-linuxxilinxspizynq

OLED on Zedboard


I am very new to zedboard. I have a zedboard running an Ubuntu image. I am trying to write a driver to run the OLED on the board. On board start-up the OLED on the board shows some display(Xilinx logo), therefore I am assuming it already has a driver. I have the following questions:

a) How is the OLED in the zedboard internally connected, is it through SPI, GPIOs or the PL. If it's through SPI/GPIOs then which pins?

b) Any tutorial or documentation that I can follow to create userspace drivers using SPI/GPIO for the OLED in the zedboard?

c) I have a redhat desktop, is there any SDk I can use to develop userspace drivers for the zedboard from my redhat desktop.

I have seen a lot of materials on the zedboard but none of them talks about how the OLED is internally connected. In one document it shows that it's connected to the PL. If that's the case then how can I write userspace drivers using the PL on the zedboard? I will be coding using C.

Appreciate your help and thanks in advance!


Solution

  • a) How is the OLED in the zedboard internally connected, is it through SPI, GPIOs or the PL. If it's through SPI/GPIOs then which pins?

    First or second result for the web search "zedboard oled pdf" - http://zedboard.org/sites/default/files/ZedBoard_HW_UG_v1_1.pdf then search for "oled" in it (page numbers of the pdf file, not printed in document):

    page3: 2.4.4 OLED...... ... ...... 19

    page4: 128x32 OLED Display

    page5: ZYNQ XC7Z020-CSG484 OLED <- bus_of_5 -> 128x32 OLED

    page20: 2.4.4 OLED An Inteltronic/Wisechip UG-2832HSWEG04 OLED Display is used on the ZedBoard. This provides a 128x32 pixel, passive-matrix, monochrome display. The display size is 30mm x11.5mm x 1.45mm. Table 11 - OLED Connections ... Interface

    oled_pin symb  EPP_pin  Function
    9        RES#   U9      Power Reset for Controller and Driver
    8        CS#    N/C     Chip Select – Pulled Down on Board
    10       D/C#  U10      Data/Command Control
    11       SCLK  AB12     Serial Clock Input Signal
    12       SDIN  AA12     Serial Data Input Signal 
    

    So, we know model of OLED UG-2832HSWEG04 (datasheet http://www.adafruit.com/datasheets/UG-2832HSWEG04.pdf with low-level details on data interface) and data connection; this is OLED with 1 serial data input and 1 serial clock.

    Pinout pdf is http://www.xilinx.com/support/documentation/user_guides/ug865-Zynq-7000-Pkg-Pinout.pdf (too long to read), but there is shorter version of pin list in txt format: http://www.xilinx.com/support/packagefiles/z7packages/xc7z020clg484pkg.txt

    Device/Package xc7z020clg484 9/18/2012 10:07:35

    Pin   Pin Name                 Memory Byte Group  Bank  VCCAUX Group  Super Logic Region  I/O Type 
    AA12  IO_L7P_T1_13             1                  13    NA            NA                  HR        
    AB12  IO_L7N_T1_13             1                  13    NA            NA                  HR        
    

    HR means "3.3V-capable high-range (HR) banks", both data pins are from "bank 13". Pin name is IO_* so it "supports both input, as well as output functionality", and is part of "PL Pins" (PL = programmable logic = FPGA). Default Zedboard firmware of FPGA part gives access to this pin to the ARM part of chip with linux kernel (PS = processing system = ARM) by routing it to some internal processing_system GPIO pin via system.ucf file like:

    NET processing_system7_0_GPIO_pin[5]  LOC = AB12 | IOSTANDARD="LVCMOS25";  # "OLED-SCLK"
    NET processing_system7_0_GPIO_pin[6]  LOC = AA12 | IOSTANDARD="LVCMOS25";  # "OLED-SDIN"
    

    Then the GPIO pins are registered in devicetree (dts) https://github.com/Digilent/linux-digilent/blob/master/arch/arm/boot/dts/digilent-zed.dts in zed_oled group:

    zed_oled {
            compatible = "dglnt,pmodoled-gpio";
            /* GPIO Pins */
            vbat-gpio = <&ps7_gpio_0 55 0>;
            vdd-gpio = <&ps7_gpio_0 56 0>;
            res-gpio = <&ps7_gpio_0 57 0>;
            dc-gpio = <&ps7_gpio_0 58 0>;
            /* SPI-GPIOs */
            spi-bus-num = <2>;
            spi-speed-hz = <4000000>;
            spi-sclk-gpio = <&ps7_gpio_0 59 0>;
            spi-sdin-gpio = <&ps7_gpio_0 60 0>;
        };
    

    b) Any tutorial or documentation that I can follow to create userspace drivers using SPI/GPIO for the OLED in the zedboard?

    According to Avnet's Getting Started pdf, "Demo 2 – OLED Display" scetion on page 17 (web searched as "zedboard oled") http://zedboard.org/sites/default/files/documentations/GS-AES-Z7EV-7Z020-G-14.1-V6%5B1%5D.pdf#page=17 there is kernel driver pmodoled-gpio.ko (on screenshot it reported as "pmodoled-gpio-spi"), so OLED is driven with GPIO pins.

    There are two helper scripts: unload_oled to remove the kernel module and load_oled to insert it into kernel. Driver will create special device file /dev/zed_oled to work with display from user-space and load_oled also displays the /root/logo.bin file using this zed_oled interface.

    Typical usage of zed_oled is like cat yourfile.bin > /dev/zed_oled, for example http://people.mech.kuleuven.be/~lin.zhang/notes/emebedded-linux/zedboard-oled-display.html and better http://zedboard.org/content/zedboard-oled

    The .bin file format. ... The screen is written to right to left, top to bottom with each pixel being represented by a bit within one of the bytes within the .bin file. Bits are read-in top down 8 pixels then move over 1 pixel and write the next 8 bits and continue until you are at the end of the row. Then move down 8 pixels and do this again 3 more times.

    You can do writes from C application, check code from http://www.cnblogs.com/popo0904/p/3853144.html (you can use online web translation services to read the text)

    Documentation on the kernel module PmodOLED used in standard zedboard demo: https://github.com/Digilent/linux-digilent/blob/master/Documentation/pmods/pmodoled.txt

    The driver provides a 512 Byte display buffer for the display of PmodOLED. The Whole screen is divided into four lines, each of them is 128 bits wide and 8 bits high, as shown in the figure below.

        +--------------------------...----------------------------+
        +                         Line 4                          +
        +--------------------------...----------------------------+
        +                         Line 3                          +
        +--------------------------...----------------------------+
        +                         Line 2                          +
        +--------------------------...----------------------------+ MSB (bit 7)
        +                         Line 1                          +
        +--------------------------...----------------------------+ LSB (bit 0)
    byte 127                                                     byte 0
    

    Users can perform read and write functions to the device node to access the data inside the display buffer.

    And there is source code of the dirver: https://github.com/Digilent/linux-digilent/blob/06b388903e5459687ba2538ae3895ffe29e2e39e/drivers/pmods/pmodoled-gpio.c

    c) I have a redhat desktop, is there any SDk I can use to develop userspace drivers for the zedboard from my redhat desktop.

    The standard driver is kernel-space for this OLED on ZEDboard, you can use it from precompiled ZEDboard firmware. Or you can build the kernel according to zedboard instructions, all in-kernel drivers will be built too (if enabled in kernel configuration): http://zedboard.org/content/creating-linux-kernel-image-boot-zc702-sd-card-slot