Skip to content

Raspberry Pi Pico - ssd1306 display attempts to initialize before i2c bus is ready for communication #53800

@doctorseus

Description

@doctorseus

Describe the bug

Hi, I am working on a Raspberry Pi Pico connected to a ssd1306 based o-led display: https://www.adafruit.com/product/938
I used zephyr/boards/shields/ssd1306/ssd1306_128x32.overlay as a basis:

&i2c0 {
	status = "okay";

	ssd1306_ssd1306_128x64: ssd1306@3c {
		compatible = "solomon,ssd1306fb";
		reg = <0x3d>;
		width = <128>;
		height = <64>;
		segment-offset = <0>;
		page-offset = <0>;
		display-offset = <0>;
		multiplex-ratio = <31>;
		segment-remap;
		com-invdir;
		com-sequential;
		prechargep = <0x22>;
	};
};

When I run any of the display sample applications (e.g. zephyr/samples/subsys/display/cfb), the application will just work (as the device is just soft-resets before running the code and not disconnected from power). However, I noticed that when I unplug the RPI Pico and re-plug it again, the display stays black.

To me it appears, that the i2c is not immediately ready after power-on to actually be usable for the communication to the display IC when Zypher tries to initialize it. If I add a delay of about 170ms in the ssd1306_init_device function the app works correctly and the display is initialized. (Please note that there is no other modification of the sample code. I just attempted to flash the sample using the SHIELD define on a stock Raspberry Pi Pico.)

Also the console prints that node ssd1306@3c is not ready, before even initializing i2c.

To Reproduce
Steps to reproduce the behavior:

  1. build cfb sample
  2. flash on a rpi_pico with a ssd1306 display connected
  3. See black display

Expected behavior
See application working as expected.

Impact
Delaying the initialization works for me but this might have other effects too.

Logs and console output

Device ssd1306@3c not ready
[00:00:00.000,000] <inf> i2c_dw: I2C: i2c_dw_initialize > start        # dbg output added by me
[00:00:00.000,000] <inf> i2c_dw: I2C: i2c_dw_runtime_configure > 1        # dbg output added by me
[00:00:00.000,000] <inf> i2c_dw: I2C: i2c_dw_runtime_configure > 2        # dbg output added by me
[00:00:00.000,000] <inf> i2c_dw: I2C: i2c_dw_initialize > end        # dbg output added by me
[00:00:00.000,000] <inf> i2c_dw: I2C: i2c_dw_initialize > start         # dbg output added by me
[00:00:00.000,000] <inf> i2c_dw: I2C: i2c_dw_runtime_configure > 1         # dbg output added by me
[00:00:00.000,000] <inf> i2c_dw: I2C: i2c_dw_runtime_configure > 2         # dbg output added by me
[00:00:00.000,000] <inf> i2c_dw: I2C: i2c_dw_initialize > end         # dbg output added by me
[00:00:00.000,000] <inf> ssd1306: ssd1306_init > start         # dbg output added by me
[00:00:00.001,000] <err> ssd1306: Failed to initialize device!
*** Booting Zephyr OS build zephyr-v3.2.0-3446-g2017ed50bf9a ***

Environment (please complete the following information):

  • OS: Arch Linux
  • Toolchain: Zephyr SDK
  • master

Additional context

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions