reTerminal display driver on kernel version v5.15

Hi,

I am having troubles getting LCD to work on kernel version 5.15 (which is default in Raspberry OS 64bit). Here is a dmesg log where errors in mipi_dsi driver can be seen (the entire log is too long, so I’ve trimmed it to what I believe is relevant part is):

[    4.567596] [drm] Initialized v3d 1.0.0 20180419 for fec00000.v3d on minor 0
[    5.142594] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    5.237660] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    5.244980] cfg80211: loaded regulatory.db is malformed or signature is missing/invalid
[    5.592936] random: crng init done
[    5.592962] random: 7 urandom warning(s) missed due to ratelimiting
[    5.699727] bq24179_charger: loading out-of-tree module taints kernel.
[    5.729793] bq25790-charger 1-006b: battery info missing, default values will be applied
[    5.730018] wm8960 1-001a: Failed to issue reset
[    5.730103] bq25790-charger 1-006b: Cannot initialize the chip.
[    5.730217] wm8960: probe of 1-001a failed with error -121
[    5.734505] pcf857x: probe of 1-0021 failed with error -121
[    5.748363] CAN device driver interface
[    5.759998] brcmfmac: F1 signature read @0x18000000=0x15264345
[    5.763575] lis3lv02d_i2c 1-0019: supply Vdd not found, using dummy regulator
[    5.763979] lis3lv02d_i2c 1-0019: supply Vdd_IO not found, using dummy regulator
[    5.764632] spi_master spi0: will run message pump with realtime priority
[    5.776361] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43455-sdio for chip BCM4345/6
[    5.777162] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43455-sdio.raspberrypi,4-compute-module.bin failed with error -2
[    5.779501] usbcore: registered new interface driver brcmfmac
[    5.780630] mcp230xx 1-0038: error -EREMOTEIO: can't write IOCON 56
[    5.780823] mcp230xx: probe of 1-0038 failed with error -121
[    5.781071] lis331dlh_i2c: 8 bits 3DC sensor found
[    5.799323] mcp251xfd spi0.1 (unnamed net_device) (uninitialized): Failed to detect MCP251xFD (osc=0x00000000).
[    5.805482] [DSI]i2c_md_init:
[    5.805707] [DSI]i2c_md_probe:start
[    5.807574] i2c_mipi_dsi 1-0045: I2C read id: 0xc3
[    5.809668] [DSI]mipi_dsi_device:
[    5.813569] pca953x 1-0038: supply vcc not found, using dummy regulator
[    5.813977] bq25790-charger: probe of 1-006b failed with error -121
[    5.814011] rtc-pcf8563 3-0051: registered as rtc0
[    5.815898] rtc-pcf8563 3-0051: setting system clock to 2022-04-10T13:57:10 UTC (1649599030)
[    5.819639] input: seeed-tp as /devices/platform/soc/fe804000.i2c/i2c-1/1-0045/input/input20
[    5.856918] [DSI]i2c_md_probe:finished.
[    5.865441] pca953x 1-0038: using no AI
[    5.871172] [DSI]mipi_dsi_probe:
[    5.873254] vc4-drm gpu: bound fe400000.hvs (ops vc4_hvs_ops [vc4])
[    5.878547] Registered IR keymap rc-cec
[    5.896323] input: gpio_keys as /devices/platform/gpio_keys/input/input21
[    5.896402] rc rc0: vc4 as /devices/platform/soc/fef00700.hdmi/rc/rc0
[    5.900477] input: vc4 as /devices/platform/soc/fef00700.hdmi/rc/rc0/input23
[    5.910582] input: ST LIS3LV02DL Accelerometer as /devices/platform/lis3lv02d/input/input22
[    6.020677] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43455-sdio for chip BCM4345/6
[    6.020836] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43455-sdio for chip BCM4345/6
[    6.030334] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM4345/6 wl0: Nov  1 2021 00:37:25 version 7.45.241 (1a2f2fa CY) FWID 01-703fd60
[    6.254299] mipi_dsi fe700000.dsi.0: failed to attach dsi to host: -517
[    6.262292] [DSI]mipi_dsi_probe:
[    6.264083] vc4-drm gpu: bound fe400000.hvs (ops vc4_hvs_ops [vc4])
[    6.270982] Registered IR keymap rc-cec
[    6.272177] rc rc0: vc4 as /devices/platform/soc/fef00700.hdmi/rc/rc0
[    6.272436] input: vc4 as /devices/platform/soc/fef00700.hdmi/rc/rc0/input24
[    6.417797] mipi_dsi fe700000.dsi.0: failed to attach dsi to host: -517
[    6.441573] [DSI]mipi_dsi_probe:
[    6.443382] vc4-drm gpu: bound fe400000.hvs (ops vc4_hvs_ops [vc4])
[    6.470361] Registered IR keymap rc-cec
[    6.480789] rc rc0: vc4 as /devices/platform/soc/fef00700.hdmi/rc/rc0
[    6.495963] input: vc4 as /devices/platform/soc/fef00700.hdmi/rc/rc0/input25
[    6.502842] vc4-drm gpu: bound fef00700.hdmi (ops vc4_hdmi_ops [vc4])
[    6.518078] Registered IR keymap rc-cec
[    6.518300] rc rc1: vc4 as /devices/platform/soc/fef05700.hdmi/rc/rc1
[    6.519983] input: vc4 as /devices/platform/soc/fef05700.hdmi/rc/rc1/input26
[    6.525900] vc4-drm gpu: bound fef05700.hdmi (ops vc4_hdmi_ops [vc4])
[    6.527268] vc4-drm gpu: bound fe700000.dsi (ops vc4_dsi_ops [vc4])
[    6.527652] vc4-drm gpu: bound fe004000.txp (ops vc4_txp_ops [vc4])
[    6.527964] vc4-drm gpu: bound fe206000.pixelvalve (ops vc4_crtc_ops [vc4])
[    6.528266] vc4-drm gpu: bound fe207000.pixelvalve (ops vc4_crtc_ops [vc4])
[    6.528551] vc4-drm gpu: bound fe20a000.pixelvalve (ops vc4_crtc_ops [vc4])
[    6.528803] vc4-drm gpu: bound fe216000.pixelvalve (ops vc4_crtc_ops [vc4])
[    6.529284] vc4-drm gpu: bound fec12000.pixelvalve (ops vc4_crtc_ops [vc4])
[    6.547665] [drm] Initialized vc4 0.0.0 20140616 for gpu on minor 1
[    6.554842] [DSI]panel_prepare:
[    6.616970] [DSI]ili9881d_prepare:
[    7.644947] vc4_dsi fe700000.dsi: transfer interrupt wait timeout
[    7.644974] vc4_dsi fe700000.dsi: instat: 0x00000000
[    7.644989] [drm:vc4_dsi_host_transfer [vc4]] *ERROR* DSI transfer failed, resetting: -110
[    7.645080] [DSI]ili9881d_prepare:No LCD connected,pls check your hardware!

[    7.651197] [DSI]panel_enable:
[    7.670321] Console: switching to colour frame buffer device 160x45
[    7.692793] vc4-drm gpu: [drm] fb0: vc4drmfb frame buffer device
[    7.884203] 8021q: 802.1Q VLAN Support v1.8
[    7.912277] uart-pl011 fe201000.serial: no DMA platform data
[    8.005226] Adding 102396k swap on /var/swap.  Priority:-2 extents:1 across:102396k SSFS
[    8.292650] bcmgenet fd580000.ethernet: configuring instance for external RGMII (RX delay)
[    8.293189] bcmgenet fd580000.ethernet eth0: Link is Down
[   12.381161] bcmgenet fd580000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[   12.381231] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   13.476641] ICMPv6: process `dhcpcd' is using deprecated sysctl (syscall) net.ipv6.neigh.eth0.retrans_time - use net.ipv6.neigh.eth0.retrans_time_ms instead
[   14.596034] Bluetooth: Core ver 2.22
[   14.596179] NET: Registered PF_BLUETOOTH protocol family
[   14.596193] Bluetooth: HCI device and connection manager initialized
[   14.596222] Bluetooth: HCI socket layer initialized
[   14.596241] Bluetooth: L2CAP socket layer initialized
[   14.596272] Bluetooth: SCO socket layer initialized
[   14.604146] Bluetooth: HCI UART driver ver 2.3
[   14.604182] Bluetooth: HCI UART protocol H4 registered
[   14.604299] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   14.604729] Bluetooth: HCI UART protocol Broadcom registered
[   14.832112] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   14.832132] Bluetooth: BNEP filters: protocol multicast
[   14.832146] Bluetooth: BNEP socket layer initialized
[   14.844532] NET: Registered PF_ALG protocol family
[   33.756957] cam-dummy-reg: disabling

The one way I’ve found to work around the problem is to downgrade raspberrypi-kernel and raspberrypi-kernel-headers to version 1.20220308-2 (which likely still can be found in the Raspberry Pi archive and which brings kernel version v5.10). Downgrading and rebooting the reTerminal makes LCD to work. Upgrading them back to the latest version and reboot makes LCD to be black again. So far this is what’ve I’ve managed to narrow down the problem.

Even with the newer kernel and LCD black the i2cdetect -y 1 looks nominal to me:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
40: -- -- -- -- -- UU -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Surely, staying at an older kernel is good-enough workaround for the short term, but would be really nice to find a more sustainable solution. If anyone has suggestions or ideas of a solution or troubleshooting I’m really curios to know!

Addendum:

This is a clean install of Raspberry Os 64bit, with the drivers installed as per the instructions. The current overlays in the /boot/config.txt is what the scripts/reTerminal.sh configured them to.

[all]
enable_uart=1
dtoverlay=dwc2,dr_mode=host
dtparam=ant2
disable_splash=1
ignore_lcd=1
dtoverlay=vc4-kms-v3d-pi4
dtoverlay=i2c3,pins_4_5
gpio=13=pu
dtoverlay=reTerminal
dtoverlay=reTerminal-bridge

This is actually a kernel driver bug, see this thread on the raspberry pi forums, and this PR on the pi kernel github - it was patched the day after the current pi kernel release was tagged >:(

rpi-update will get you a nightly kernel which should have it fixed, and with any luck DKMS will just install the modules. Typical…

[Edit]: OK, rpi-update doesn’t help - probably because of the custom shenanigans seeed are doing with the STM32 that sits between the display and the CM4. Will need an update to their custom module. sigh

1 Like

Yeah, unfortunately, the seeed does not use ili9881c from the “vanilla” kernel but uses own ili9881d (which kind of makes sense since the latter is different resolution). It feels like it should be possible to upstream ili9881d driver but that’s another discussion :slight_smile:

What i’ve noticed is that with kernel 5.15 drm/vc4 logs the following:

[    6.825544] [drm] Initialized vc4 0.0.0 20140616 for gpu on minor 1

and 5.10 logs the following:

[    6.496895] [drm] Initialized vc4 0.0.0 20140616 for gpu on minor 0

Is it DSI0 vs. DSI1 issue? Is it caused by a mistake in the custom mipi_dsi module, or is it something addressable as an overlay? :thinking:

I hadn’t noticed that - that’s the GPU device, not the DSI channel, but that would explain why it’s failing when it tries to get the MIPI host device. Maybe down to devicetree changes from 5.10 to 5.15 breaking the overlay? Let me try a couple things…

Also, worth noting that panel-ili9881c.c supports the ili9881d as well, as of late last year - but the controller isn’t hooked directly to the Pi’s i2c bus, so some custom-ness is needed regardless. To be honest I’m not entirely sure exactly what the driver is trying and failing to do here, so not really sure where to look. I’m sure seeed will have it figured out soon enough :slight_smile:

I fixed it! clone this branch of my fork on github and install as normal. You might have to change the panel rotation with an overlay parameter, I did (though I didn’t on 5.10 which is weird).

Given that this panel seems to pretty obviously be the Huarui LHR050H41, which is already supported in mainline, and only needs a few extra bits and pieces added to handle talking to the STM32 for PWM backlight control, I might have a crack at rewriting it to make use of existing kernel infrastructure at some point…

This works for now, though - and I’m sure seeed will have a proper fix soon enough :slight_smile:

1 Like

This is lovely! Just gave it a try and it works on my unit. Thanks for your work! :slight_smile:
There seems to be missing rename of ili9881d_modes to ili9881d_default_mode, but that’s details.

Also thanks for sharing insights about ili9881d support in panel-ili9881c.c and Huarui LHR050H41. Somehow I’ve missed those details.

1 Like

Heh, yeah, initially I started rewriting the panel driver to look like the mainline one, but then decided I had better things to do and I guess I forgot to revert that bit :sweat_smile: glad it works for you!

I also had to flip the X axis on the accelerometer so iio-sensor-proxy wouldn’t flip the LCD upside down, and set tp_rotate=1 in the dtoverlay=reTerminal line, but YMMV depending on the revision of your unit.

If anyone else has trouble working out how the heck to flip the accel axis, save this as /etc/udev/hwdb.d/61-sensor-local.hwdb:

# fix reterminal accelerometer orientation
sensor:modalias:platform:lis3lv02d:*
 ACCEL_LOCATION=display
 ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1
1 Like

@neggles
I tried your changes and I get the following error on compile

pi@reterm77:~/seeed-linux-dtoverlays $ cat /var/lib/dkms/mipi_dsi/0.1/build/make.log
DKMS make.log for mipi_dsi-0.1 for kernel 5.15.32-v8+ (aarch64)
Sun 24 Apr 18:19:37 CDT 2022
make -C /lib/modules/5.15.32-v8+/build M=/var/lib/dkms/mipi_dsi/0.1/build modules
make[1]: Entering directory '/usr/src/linux-headers-5.15.32-v8+'
  CC [M]  /var/lib/dkms/mipi_dsi/0.1/build/mipi_dsi_drv.o
  CC [M]  /var/lib/dkms/mipi_dsi/0.1/build/touch_panel.o
  CC [M]  /var/lib/dkms/mipi_dsi/0.1/build/panel-ili9881d.o
/var/lib/dkms/mipi_dsi/0.1/build/panel-ili9881d.c: In function ‘ili9881d_get_modes’:
/var/lib/dkms/mipi_dsi/0.1/build/panel-ili9881d.c:34:45: error: ‘ili9881d_default_mode’ undeclared (first use in this function); did you mean ‘ili9881d_get_modes’?
   34 |  mode = drm_mode_duplicate(connector->dev, &ili9881d_default_mode);
      |                                             ^~~~~~~~~~~~~~~~~~~~~
      |                                             ili9881d_get_modes
/var/lib/dkms/mipi_dsi/0.1/build/panel-ili9881d.c:34:45: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/mipi_dsi/0.1/build/panel-ili9881d.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:1868: /var/lib/dkms/mipi_dsi/0.1/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.32-v8+'
make: *** [Makefile:15: all] Error 2

@neggles
rename of ili9881d_modes to ili9881d_default_mode in panel-ili9881d.c as suggested by @sergey fixed the compilation error.

For me the tp_rotate=1 did not work. What worked instead was the fix documented here reTerminalのディスプレイ向きを直す - Seeed K.K. エンジニアブログ and here reTerminal CM4 bullseye 64 bit issue Screen fix vertical · Issue #31 · Seeed-Studio/seeed-linux-dtoverlays · GitHub

cat ~pi/.config/monitors.xml
<monitors version="2">
  <configuration>
    <logicalmonitor>
      <x>0</x>
      <y>0</y>
      <primary>yes</primary>
      <monitor>
        <monitorspec>
          <connector>DSI-1</connector>
          <vendor>unknown</vendor>
          <product>unknown</product>
          <serial>unknown</serial>
        </monitorspec>
        <mode>
          <width>720</width>
          <height>1280</height>
          <rate>60.000</rate>
        </mode>
      </monitor>
      <transform>
        <rotation>right</rotation>
      </transform>
    </logicalmonitor>
  </configuration>
</monitors>
1 Like

I thought I’d pushed that fix to the repo, my bad… Will fix that up tomorrow, it’s midnight here :sweat_smile:

Yeah, you have to either do that at the same time or edit /usr/share/X11/xorg.conf.d/10-disp.conf - I don’t remember the specific changes I made, but I can dig them out tomorrow as well.

@neggles @sergey
Thank you so much! You saved me a ton of time. I second the motion that the mainline driver should be extended to support the STM32 control. No need to rewrite the entire boat.