Libre Computer Wiring Tool

Where are the overlay files located? I need to convert my gpio layout from RPi and it has been a bit challenging. I need spidev.0 as well as an output bit to reset a quad uart and an incoming interrupt request line. Is there a noob guide for building overlays?

SPI is easy: sudo ldto enable spicc-cs1

There are tons of overlays already and you can just look through them to see how they work. GitHub - libre-computer-project/libretech-wiring-tool

Does that command permanently add the SPI pins to my device tree? Where are overlays normally stored on the controller?

Read the OP, this is covered there already.

Please forgive my ignorance: What is an “OP”, where can it be had? I did attempt man ldto to no avail. Also, I noticed that after I applied the overlay I did not see the pins appear in the output of gpioinfo even though ldto status shows spicc-cs1 as active. Thanks for your kind patience.

Original post. Just scroll up using the scroll bar. It goes over ldto basics.

SPI is not GPIO. Raspberry Pi stuff is a confusing mess of ideas.

GPIO is general purpose IO. SPI bus is serial peripheral interface. SPI shows up as /dev/spidevx.y. Best not to get the concepts confused.

Roger that on the RPI being a mess. I do see line 89: “7J1 Header Pin24” “spi0 CS0” output active-low [used] appears in the output of gpioinfo thus my confusion. Regarding the UART reset and interrupt line that I need I see that they are listed as lines 85 and 95 respectively (albeit unused) which suggests that I should be able to use libgpiod to set them up. Am I to assume that once I set them up with libgpriod functions that they will transition into “used”?

The answer is that it depends.

If your device has a Linux kernel driver, the driver should handle the reservation of the pin functions. You create a device tree and provide the driver what it needs (GPIO, interrupts, pinmux, clocks, etc). Everything is done in kernel space.

If you are handling a portion of it in userspace or completely in userspace, that’s a different ball game. libgpiod is a userspace library so it really can’t reserve anything in kernel space. /dev/spidev0.0 is an userspace interface for the kernel SPI driver. You need to separately enable it via ldto enable spicc-cs1-spidev. This has 2 CS (pin 24 and pin 26). If you don’t need the CS, you can use spicc and spicc-spidev overlays. spicc/spicc-cs1 enables the SPI device. spicc/spicc-cs1 spidev enable the SPI device userspace interface (/dev/spidevx.y). Hope that makes sense.

We provide a tool called lgpio and you can use it to manually toggle pins and such. It can also convert header/pin combinations to libgpiod numberings for you to use in python or whatever userspace application you have interacting with the GPIO kernel interface. The documentation is also in the OP.

So I’ve tried using the sudo apt install function to get the libretech-gpio library, and my device throws the error that it can’t find it. Is there some other way I could try to access these files?

  1. Use official images as this tool is only available on official images.
  2. If you are using an image from a long time ago, sudo apt update and then try that command.

Only our Ubuntu Raspbian and Debian images have this tool. Images by third parties do not include the repository with it.

A little bit more about your installation?

For the longest time I could not ‘find’ some of the libraries that I was downloading to the Libre. I am using Thonny which sets up its own Venv. Thonny did not do or find some of the libraries so I used Thonny’s open a terminal window link figuring that would install the thing to the Venv. what I found was that the libraries did indeed download to the Thonny directory of the working project. I then search those directories for the libraries I was looking for and moved them to sit with the current.py project file and it all works now. Took me several days and loading lots of libraries to figure that out.

Pin 17 in the GPIO Header of Renegade is GND but should be 3.3V

Using 2023-10-10-raspbian-bookworm-arm64-lite+aml-s905x-cc.

On first boot, after cloning the repository and installing the dtos, I ran into the following issue when running ldto merge [overlay]:

/opt/libretech-wiring-tool/ldto merge uart-a spi-cc-cs1 spi-cc-1cs-ili9341

LDTO_findEFIDTBPath: no EFI boot path found.

After rebooting, it works without errors. I assume a reboot is required either right after booting for the first time or installing the wiring tool, but I just want to make sure this is the intended behavior.

spi-cc-cs1 spi-cc- 1cs-ili9341

This is wrong.

Sorry typo on my end, but the behavior is the same with the correctly inputted dto names.

What is the output of the command if you prefix it with bash -x?

Do you mean like this?

fpts@raspbian-bookworm-aml-s905x-cc:/opt/FiberPTS $ sudo bash -x /opt/libretech-wiring-tool/ldto merge uart-a spi-cc
-cs1 spi-cc-1cs-ili9341
+ set -e
+ '[' -z '' ']'
+ '[' '!' -e /sys/class/dmi/id/board_vendor ']'
++ tr -d '\0'
+ VENDOR=libre-computer
+ '[' -z '' ']'
+ '[' '!' -e /sys/class/dmi/id/board_name ']'
++ tr -d '\0'
+ BOARD=aml-s905x-cc
+ PATH_OF_CONFIG=/sys/kernel/config/device-tree/overlays
+ PATH_OF_DT=/sys/firmware/fdt
+ PATH_OF_DTB_OVERRIDE=
+ PATH_OF_EFI_DTB=
+ '[' '!' -d /sys/kernel/config/device-tree/overlays ']'
+++ readlink -f /opt/libretech-wiring-tool/ldto
++ dirname /opt/libretech-wiring-tool/ldto
+ cd /opt/libretech-wiring-tool
+ PATH_DTBO=libre-computer/aml-s905x-cc/dt
+ PATH_DTCFG=libre-computer/aml-s905x-cc/dt.config
+ MAP_FILE=libre-computer/aml-s905x-cc/dt.map
+ TAB_CHAR='    '
+ declare -A MAP_DT_ALIAS
+ declare -A MAP_ALIAS_DT
+ cmd=help
+ '[' '!' -z merge ']'
+ cmd=merge
+ shift
+ LDTO_merge uart-a spi-cc
+ LDTO_checkFirmwareDT
+ '[' '!' -e /sys/firmware/fdt ']'
+ test -r /sys/firmware/fdt
+ LDTO_importDTConfig
+ '[' -f libre-computer/aml-s905x-cc/dt.config ']'
+ . libre-computer/aml-s905x-cc/dt.config
++ DT_OVERRIDE_PATH=dtb
++ DT_OVERRIDE=amlogic/meson-gxl-s905x-libretech-cc.dtb
+ '[' -z uart-a ']'
+ LDTO_loadMap
+ '[' -e libre-computer/aml-s905x-cc/dt.map ']'
+ IFS=
+ read -r mapping
++ grep -v '^#' libre-computer/aml-s905x-cc/dt.map
+ local dt_alias=H40P_I2C_0
+ local dt_file=i2c-ao
+ MAP_DT_ALIAS[$dt_file]=H40P_I2C_0
+ MAP_ALIAS_DT[$dt_alias]=i2c-ao
+ IFS=
+ read -r mapping
+ local dt_alias=H40P_I2C_1
+ local dt_file=i2c-b
+ MAP_DT_ALIAS[$dt_file]=H40P_I2C_1
+ MAP_ALIAS_DT[$dt_alias]=i2c-b
+ IFS=
+ read -r mapping
+ local dt_alias=H40P_SPI_0_1CS
+ local dt_file=spi-cc-1cs
+ MAP_DT_ALIAS[$dt_file]=H40P_SPI_0_1CS
+ MAP_ALIAS_DT[$dt_alias]=spi-cc-1cs
+ IFS=
+ read -r mapping
+ local dt_alias=H40P_SPI_0_1CS_DEV
+ local dt_file=spi-cc-1cs-spidev
+ MAP_DT_ALIAS[$dt_file]=H40P_SPI_0_1CS_DEV
+ MAP_ALIAS_DT[$dt_alias]=spi-cc-1cs-spidev
+ IFS=
+ read -r mapping
+ local dt_alias=H40P_SPI_0_2CS
+ local dt_file=spi-cc-2cs
+ MAP_DT_ALIAS[$dt_file]=H40P_SPI_0_2CS
+ MAP_ALIAS_DT[$dt_alias]=spi-cc-2cs
+ IFS=
+ read -r mapping
+ local dt_alias=H40P_SPI_0_2CS_DEV
+ local dt_file=spi-cc-2cs-spidev
+ MAP_DT_ALIAS[$dt_file]=H40P_SPI_0_2CS_DEV
+ MAP_ALIAS_DT[$dt_alias]=spi-cc-2cs-spidev
+ IFS=
+ read -r mapping
+ local dt_alias=H40P_SPI_0_LCD_35
+ local dt_file=spi-cc-2cs-mpi3501.dts
+ MAP_DT_ALIAS[$dt_file]=H40P_SPI_0_LCD_35
+ MAP_ALIAS_DT[$dt_alias]=spi-cc-2cs-mpi3501.dts
+ IFS=
+ read -r mapping
+ local dt_alias=H40P_UART_1
+ local dt_file=uart-a-clk81
+ MAP_DT_ALIAS[$dt_file]=H40P_UART_1
+ MAP_ALIAS_DT[$dt_alias]=uart-a-clk81
+ IFS=
+ read -r mapping
+ for dtbo in "$@"
++ LDTO_getDTBO uart-a
++ local dtbo=libre-computer/aml-s905x-cc/dt/uart-a.dtbo
++ '[' -f libre-computer/aml-s905x-cc/dt/uart-a.dtbo ']'
++ echo libre-computer/aml-s905x-cc/dt/uart-a.dtbo
+ local dtbo_file=libre-computer/aml-s905x-cc/dt/uart-a.dtbo
+ '[' -z libre-computer/aml-s905x-cc/dt/uart-a.dtbo ']'
+ LDTO_apply libre-computer/aml-s905x-cc/dt/uart-a.dtbo
+ LDTO_findEFIDTBPath RW
++ cut -f 2 -d ' ' /proc/mounts
++ grep '^/boot'
+ local mnt_boot=
++ echo ''
++ wc -l
+ local mnt_boot_count=1
+ '[' 1 -lt 1 ']'
+ grep root=/dev/nfs /proc/cmdline
+ echo 'LDTO_findEFIDTBPath: no EFI boot path found.'
LDTO_findEFIDTBPath: no EFI boot path found.
+ return 1
-cs1: command not found

This is where it fails. Did you modify the image? What is the output of cat /proc/mounts?