Jump to content

ssd1306 OLED screen on orange pi pc


AndryBlack

Recommended Posts

Latest kernels include experimental fbttf modules. I connect cheapest oled screen(128x64px) via SPI to orange pi pc.

Connections:

  • data - spi0 mosi (PC0 pin 19)
  • clk - spi0 clk (PC2 pin 23)
  • cs - spi0 cs (PC3 pin 24)
  • d/c - PC7 (pin 18)
  • vcc - 3.3v (pin 1)
  • gnd - gnd (pin 6)

dts overlay:

/*
 * adafruit13m-overlay.dts
 *
 * based on overlay for RPi https://github.com/kenrestivo/linux/blob/3d61a22b05cbf7ac2f6b620dcd45c2fb49fb9442/arch/arm/boot/dts/overlays/adafruit13m-overlay.dts
 */

/dts-v1/ /plugin/;

/ {
	
	compatible = "allwinner,sun8i-h3";
	
	fragment@0 {
		target-path = "/aliases";
		__overlay__ {
			spi0 = "/soc/spi@01c68000";
		};
	};

	fragment@1 {
		target = <&pio>;
		__overlay__ {
			adafruit13m_pins: adafruit13m_pins {
				allwinner,pins = "PC7";
				allwinner,function = "gpio_out";
			};
		};
	};

	fragment@2 {
		target = <&spi0>;
		__overlay__ {
			/* needed to avoid dtc warning */
			#address-cells = <1>;
			#size-cells = <0>;

			status = "okay";
			adafruit13m: adafruit13m@0{
				compatible = "solomon,ssd1306";
				reg = <0>;
				pinctrl-names = "default";
				pinctrl-0 = <&adafruit13m_pins>;
				spi-max-frequency = <6000000>;
				buswidth = <8>;
				fps = <20>;
				dc-gpios = <&pio 2 7 0>;
				#debug = <3>;
				rotate = <0>;
			};
		};
	};

	__overrides__ {
		#speed =      <&adafruit13m>,"spi-max-frequency:0";
		#rotate =     <&adafruit13m>,"rotate:0";
		fps =        <&adafruit13m>,"fps:0";
		#debug =      <&adafruit13m>,"debug:0";
	};
};

build:

/usr/src/linux-headers-4.10.0-sun8i/scripts/dtc/dtc -@ -I dts -O dtb -o /boot/dtb-4.10.0-sun8i/overlay/adafruit13m-overlay.dtbo adafruit13m-overlay.dts

added to /boot/armbianEnv.txt:

  • overlays=adafruit13m-overlay #overlay loading
  • extraargs=fbcon=map:1 #remove fbcon attachement 

after reboot new framebuffer device found (/dev/fb0 on my headless configuration)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines