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
  • Hello

    Is I2C1, or another peripheral using the same address already in use?

    Have you checked that the device is ready before you bind it?

    Best regards,

    Einar

  • Hello Einar.

    Wait, wait ...

    [00:00:00.009,185] <dbg> ssd1306.ssd1306_init:
    [00:00:00.091,735] <inf> lvgl: lv_init ready
    [00:00:00.096,618] <inf> lvgl: Object create ready
    [00:00:00.101,898] <inf> lvgl: Object create ready
    [00:00:00.107,208] <inf> lvgl: Object create ready
    [00:00:01.581,207] <inf> lvgl: Object create ready
    [00:00:01.588,775] <inf> lvgl: label created
    [00:00:01.595,794] <inf> lvgl: Object create ready
    [00:00:01.603,302] <inf> lvgl: label created
    [00:00:01.609,954] <wrn> lvgl: Can't set VDB height using the round function. (Wrong round_cb or to small VDB)

    Eureka!

    Unfortunately, after a "$ nrfjprog --pinreset", the screen turns on on a random base.

    When it fails, the console says 

    [00:00:00.009,246] <dbg> ssd1306.ssd1306_init:
    [00:00:00.014,221] <err> i2c_nrfx_twim: Error 0x0BAE0001 occurred for message 1
    [00:00:00.022,094] <err> ssd1306: Failed to initialize device!
    [00:00:00.104,705] <err> lvgl: Display device not found.

Reply
  • Hello Einar.

    Wait, wait ...

    [00:00:00.009,185] <dbg> ssd1306.ssd1306_init:
    [00:00:00.091,735] <inf> lvgl: lv_init ready
    [00:00:00.096,618] <inf> lvgl: Object create ready
    [00:00:00.101,898] <inf> lvgl: Object create ready
    [00:00:00.107,208] <inf> lvgl: Object create ready
    [00:00:01.581,207] <inf> lvgl: Object create ready
    [00:00:01.588,775] <inf> lvgl: label created
    [00:00:01.595,794] <inf> lvgl: Object create ready
    [00:00:01.603,302] <inf> lvgl: label created
    [00:00:01.609,954] <wrn> lvgl: Can't set VDB height using the round function. (Wrong round_cb or to small VDB)

    Eureka!

    Unfortunately, after a "$ nrfjprog --pinreset", the screen turns on on a random base.

    When it fails, the console says 

    [00:00:00.009,246] <dbg> ssd1306.ssd1306_init:
    [00:00:00.014,221] <err> i2c_nrfx_twim: Error 0x0BAE0001 occurred for message 1
    [00:00:00.022,094] <err> ssd1306: Failed to initialize device!
    [00:00:00.104,705] <err> lvgl: Display device not found.

Children
Related