heltheowl Posted Wednesday at 07:13 PM Posted Wednesday at 07:13 PM (edited) I'm trying to connect Nokia 5110 / PCD8544 LCD to my Orange Pi One H3 (Board v1.1). This is my wiring: Connection (LCD to OPi) Nokia 5110 LCD pin Orange Pi One pin GND GND LIGHT GND VCC 3.3v CLK PC2 (CLK) DIN PC0 (MOSI) DC PA6 CE PC3 (CE) RST PA9 This is my LCD: The backlight is working upon turning on OPi One. The official Orange Pi One H3 manual suggests using fbtft_device kernel module, which is LONG deprecated and no longer supported. On Raspberry Pi forums, someone was suggested to use a Device Tree Overlay instead. I've stumbled upon an Orange Pi Zero overlay file for my LCD. So I've changed a few lines: /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&spi1>; __overlay__ { status = "okay"; spidev@0{ status = "disabled"; }; spidev@1{ status = "disabled"; }; }; }; fragment@1 { target = <&pio>; __overlay__ { opiz_display_pins: opiz_display_pins { pins = "PA9", "PA6"; function = "gpio_out"; }; }; }; fragment@2 { target = <&spi1>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; opizdisplay: opiz-display@0{ compatible = "philips,pcd8544"; reg = <0>; pinctrl-names = "default"; pinctrl-0 = <&opiz_display_pins>; spi-max-frequency = <400000>; fps = <30>; buswidth = <8>; reset-gpios = <&pio 0 33 1>; dc-gpios = <&pio 0 7 0>; }; }; }; }; And compiled, loaded it into an DTS user directory. I've connected Arduino as a Serial-to-USB convertor to OPi and it would seem it has loaded successfully: Applying user provided DT overlay nokia5110opizero.dtbo 4185 bytes read in 14 ms (291 KiB/s) Applying kernel provided DT fixup script (sun8i-h3-fixup.scr) ## Executing script at 45000000 Kernel image @ 0x42000000 [ 0x000000 - 0xa0ea90 ] ## Loading init Ramdisk from Legacy Image at 43400000 ... Image Name: uInitrd Image Type: ARM Linux RAMDisk Image (gzip compressed) Data Size: 17670074 Bytes = 16.9 MiB Load Address: 00000000 Entry Point: 00000000 Verifying Checksum ... OK ## Flattened Device Tree blob at 43000000 Booting using the fdt blob at 0x43000000 Working FDT set to 43000000 Loading Ramdisk to 48f26000, end 49ffffba ... OK Loading Device Tree to 48eb5000, end 48f25fff ... OK Working FDT set to 48eb5000 But according to armbianmonitor -u output , the overlay ends up creating new errors: [ 1.630221] sun8i-h3-pinctrl 1c20800.pinctrl: pin PA14 already requested by 1c28c00.serial; cannot claim for 1c69000.spi [ 1.630250] sun8i-h3-pinctrl 1c20800.pinctrl: error -EINVAL: pin-14 (1c69000.spi) [ 1.630269] sun8i-h3-pinctrl 1c20800.pinctrl: error -EINVAL: could not request pin 14 (PA14) from group PA14 on device 1c20800.pinctrl [ 1.630288] sun6i-spi 1c69000.spi: Error applying setting, reverse things back I know the overlay is for Zero series, but i figured it should be the same since H3 is mentioned in there. Or at least I would be glad to know how to modify this for my board. Attached below are both logs for Serial and the kernel. So far my goal is display anything, even a black square, on the screen. Would be sick to use it as a screen for console (like /dev/fb0). Hoping for your help since I'm stuck. Thanks in advance! dmesg.txt serial.txt Edited Wednesday at 07:26 PM by heltheowl /dev/fb0 mention 0 Quote
Stephen Graf Posted Friday at 12:54 AM Posted Friday at 12:54 AM For a start it looks like you are wiring to spi0 and so fragment0 does not make sense. It also might be causing the pa14 pin problem as the op1 does not have an spi1. Pin pa14 is used on a uart output. I suggest you get rid of fragment0 and just use armbian-config to enable spi0. 1 Quote
Stephen Graf Posted Friday at 10:14 PM Posted Friday at 10:14 PM Try this google AI search instead: create overlay on armbian orangepione for Nokia 5110 / PCD8544 LCD You might also need to add to armbianEnv.txt after enabling spi-spidev root@orangepione:~# more /boot/armbianEnv.txt verbosity=1 bootlogo=false console=both disp_mode=1920x1080p60 overlay_prefix=sun8i-h3 rootdev=UUID=f39623a3-f9cf-4fa1-be36-6854d244c378 rootfstype=ext4 overlays=spi-spidev param_spidev_spi_bus=0 usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u root@orangepione:~# On successful startup of spi you should have a device: root@orangepione:~# ls /dev/spidev0.0 /dev/spidev0.0 root@orangepione:~# 0 Quote
heltheowl Posted 1 hour ago Author Posted 1 hour ago So.... This is what I've came to with Gemini: /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; /* Target the SPI0 controller */ fragment@0 { target = <&spi0>; __overlay__ { status = "okay"; #address-cells = <1>; #size-cells = <0>; /* Disable default spidev to free the bus for the framebuffer */ spidev@0 { status = "disabled"; }; /* PCD8544 LCD Node */ pcd8544@0 { compatible = "philips,pcd8544"; reg = <0>; /* Use SPI Chip Select 0 (PC3) */ spi-max-frequency = <4000000>; /* Max SPI frequency for PCD8544 */ buswidth = <8>; /* Data/Command (DC) Pin Mapping */ /* PA6 -> Port A (0), Pin 6, Active High (0) */ dc-gpios = <&pio 0 6 0>; /* Reset (RST) Pin Mapping */ /* PA9 -> Port A (0), Pin 9, Active High (0) */ reset-gpios = <&pio 0 9 0>; /* Rotate display if needed (e.g., 0, 90, 180, 270) */ rotate = <0>; }; }; }; }; I've got /dev/fb0 to show up this way. Except... It's not usable at all. Can't even print out the console. So there was no point to begin with. What DOES work though, is a Python script using CircuitPython and Blinka: # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT """ This demo will fill the screen with white, draw a black box on top and then print Hello World! in the center of the display This example is for use on (Linux) computers that are using CPython with Adafruit Blinka to support CircuitPython libraries. CircuitPython does not support PIL/pillow (python imaging library)! """ import board import busio import digitalio from PIL import Image, ImageDraw, ImageFont import adafruit_pcd8544 # Parameters to Change BORDER = 5 FONTSIZE = 10 spi = busio.SPI(board.SCK, MOSI=board.MOSI) dc = digitalio.DigitalInOut(board.PA6) # data/command cs = digitalio.DigitalInOut(board.PC3) # Chip select reset = digitalio.DigitalInOut(board.PA9) # reset display = adafruit_pcd8544.PCD8544(spi, dc, cs, reset) # Contrast and Brightness Settings display.bias = 4 display.contrast = 60 # Turn on the Backlight LED #backlight = digitalio.DigitalInOut(board.D13) # backlight #backlight.switch_to_output() #backlight.value = True # Clear display. display.fill(0) display.show() # Create blank image for drawing. # Make sure to create image with mode '1' for 1-bit color. image = Image.new("1", (display.width, display.height)) # Get drawing object to draw on image. draw = ImageDraw.Draw(image) # Draw a black background draw.rectangle((0, 0, display.width, display.height), outline=255, fill=255) # Draw a smaller inner rectangle draw.rectangle( (BORDER, BORDER, display.width - BORDER - 1, display.height - BORDER - 1), outline=0, fill=0, ) # Load a TTF font. font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", FONTSIZE) # Draw Some Text text = "It's working!" #(font_width, font_height) = font.getsize(text) left, top, right, bottom = font.getbbox(text) font_width, font_height = right - left, bottom - top draw.text( (display.width // 2 - font_width // 2, display.height // 2 - font_height // 2), text, font=font, fill=255, ) # Display image display.image(image) display.show() Using Nokia 5110 LCD library for CircuitPython Using CircuitPython on Orange Pi PC (apparently it's the same for OPi One) Unless /dev/fb0 on this things is even a little bit usable on the LCD, I guess I was running for circles because I was bored I've deleted the overlay altogether since it's probably useless in this case. But I think someone else could benefit from me posting all this here, I don't know. Either way, thank you for leading me along the way! 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.