nRF5340 - device_get_binding fails for SH1106 display controller

Hi,

This is Ubuntu and NCS 1.9.2.

I wanted to activate the monochrome OLED display model RAYSTAR REX012864LWAP3N00000
on my nRF5340-based custom board.
Here you can check out the electric connections.

The controller inside the module is SH1106 and the I2C address is 0x3c.
After some worth readings over the internet like this one
I've set up the device node in nrf5340_myboard_cpuapp.dts, this way

&i2c1 {
  clock-frequency = <400000>;
  ...
  sh1106: ssd1306fb@3c {
    compatible = "solomon,ssd1306fb";
    reg = <0x3c>;
    label = "SSD1306";
    width = <128>;
    height = <64>;
    segment-offset = <0>;
    page-offset = <0>;
    display-offset = <0>;
    multiplex-ratio = <63>;
    segment-remap;
    com-invdir;
    com-sequential;
    prechargep = <0x22>;
  };
};

I'm sure the I2C bus is ok, because other working peripherals are defined the same way.
The main program looks like this

#include <zephyr.h>
#include <drivers/display.h>
#include <lvgl.h>
#include <stdio.h>
#include <string.h>
#include "gpio.h"

const struct device *dev;

int display_init(void)
{
  gpio_set_opwr(true);	/* rise power supply */
  k_msleep(200);
  gpio_set_oresn(true);	/* put out of reset */
  k_msleep(200);

  dev = device_get_binding(DT_LABEL(DT_NODELABEL(sh1106)));
  if (dev == NULL) {
    return -1;
  }
  ...
}

GPIOs work fine as I've watched them toggling with oscilloscope.
The problem is that device_get_binding fails without any other prints.

This is the relevant section of prj.conf

CONFIG_I2C=y
CONFIG_DISPLAY=y
CONFIG_DISPLAY_LOG_LEVEL_DBG=y
CONFIG_LVGL=y
CONFIG_LVGL_USE_LABEL=y
CONFIG_LVGL_USE_CONT=y
CONFIG_LVGL_USE_BTN=y
CONFIG_LVGL_USE_BAR=y
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_LVGL_HOR_RES_MAX=128
CONFIG_LVGL_VER_RES_MAX=64
CONFIG_LVGL_DPI=30
CONFIG_SSD1306=y
CONFIG_SSD1306_SH1106_COMPATIBLE=y
CONFIG_SSD1306_REVERSE_MODE=y

Where's the flaw ?

Thank you all guys

Parents Reply Children
  • The devicetree node is well defined and the device is ready before I use it.
    I've fixed the problem by enlarging the concatenation buffer that the controller driver uses for merging multiple I2C messages.

    &i2c1 {
       zephyr,concat-buf-size = <4096>;
       ...


    Now the problem has shifted to a new level.
    The display is blank, no way to see the LVGL graphical features I've created.
    Anyway I think this thread might be closed.

    Regards,
    Gabriele

Related