How to turn on SPI feature on NanoPi Fire 3 running Dietpi

I am definetly having trouble with this board because there really is not that much information I could find on the internet.

The problem is I recently try to add a ADXL345 to the board but Dietpi doesn’t seem to have SPI turned on by default, and I have no idea where to start looking, I have checked Dietpi-Config, found nothing related to SPI there.

Plaese Help!!!

In dietpi-config → advanced options i see an entry “SPI state”.

MichaIng can you have a look pls.

I had a look into the image. Similar like NanoPi 2 series, the S5P6818 SoC based NanoPi M3/Fire3 and NanoPC T3 have a hopelessly outdated kernel provided by FriendlyELEC only, support never made it into upstream Linux. We use the slightly newer Linux v4.14 by Armbian (vs v4.4 by FriendlyELEC), but there are no device tree overlays (anyway not supported by this Linux version) and the U-Boot config is very minimal with no hints about additional features. So I’m AFRAID if the SPI interface is not available OOTB, there is nothing we are able to do :frowning:.

Also on the FriendlyELEC wiki, there are instructions about how to enable it for a bunch of other SoCs, but not S5P6818: https://wiki.friendlyelec.com/wiki/index.php/SPI

But let’s have a least a look whether there are related kernel modules available:

find /lib/modules -name '*spi*'

I got these modules after running

find /lib/modules -name ‘spi


/lib/modules/4.14.180-s5p6818/kernel/sound/soc/codecs/snd-soc-es8328-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/sound/soc/codecs/snd-soc-pcm179x-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/sound/soc/codecs/snd-soc-wm8804-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/sound/soc/codecs/snd-soc-cs4271-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/sound/soc/codecs/snd-soc-tlv320aic23-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/sound/soc/codecs/snd-soc-pcm3168a-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/sound/soc/codecs/snd-soc-pcm512x-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/sound/soc/codecs/snd-soc-ssm2602-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/sound/soc/codecs/snd-soc-adau1761-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/gyro/st_gyro_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/gyro/bmg160_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/humidity/hts221_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/magnetometer/bmc150_magn_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/magnetometer/st_magn_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/magnetometer/hmc5843_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/accel/kxsd9-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/accel/adxl345_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/accel/st_accel_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/accel/bmc150-accel-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/accel/mma7455_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/accel/bma220_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/pressure/bmp280-spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/iio/common/st_sensors/st_sensors_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/char/tpm/tpm_tis_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/char/tpm/st33zp24/tpm_st33zp24_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/nfc/st-nci/st-nci_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/nfc/nfcmrvl/nfcmrvl_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/drivers/media/spi
/lib/modules/4.14.180-s5p6818/kernel/drivers/net/can/spi
/lib/modules/4.14.180-s5p6818/kernel/drivers/input/rmi4/rmi_spi.ko
/lib/modules/4.14.180-s5p6818/kernel/net/nfc/nci/nci_spi.ko

then I ran

modprobe adxl345_spi

nothing shows in

ls /dev/spi*

That adxl345_spi module looks so well. Das it have options?

modinfo adxl345_spi

Sorry for such delay, held up recently.

modinfo adxl345_spi Shows

filename: /lib/modules/4.14.180-s5p6818/kernel/drivers/iio/accel/adxl345_spi.ko
license: GPL v2
description: ADXL345 3-Axis Digital Accelerometer SPI driver
author: Eva Rachel Retuya eraretuya@gmail.com
alias: spi:adxl345
alias: of:NTCadi,adxl345C*
alias: of:NTCadi,adxl345
depends: adxl345_core
intree: Y
name: adxl345_spi
vermagic: 4.14.180-s5p6818 SMP mod_unload aarch64`

Before the driver can serve the ADXL345 you have to wire it up in the devicetree.

yeah,
but as Michalng mentioned up a few posts, the kernel does not have device tree overlays, that’s the tricky part.

and I asked friendlyarm official support about this issue, who have replied a not so friendly answer, that in order to use spi feature with this board, I have to write my own driver for it.

Then I ask if there were any technical supports or document related to spi specifically, they said not able to provide any of that because this board has simply gone out of production.

Devicetree overlays can be written, that’s not the problem, but if your kernel doesn’t have a driver for the SPI IP, then you lose. A look at the base devicetree may provide indications of unactivated SPI master nodes. But if there are no traces, there is a high probability that there is no support.

Since the SPI IP is usually part of the SOC, the TRM should provide all the necessary information, nothing is board-specific except ultimately the outer wiring. And this should be described by devicetree for the driver.

1 Like

Let’s have a look at the device tree for toggles then:

find /proc/device-tree -name status | while read -r line
do
echo "$line: $(<"$line")"
done

Thanks for helping out.
I ran the code, but returns nothing.

A look at the DTB source code should be more meaningful here because you do not know the exact search term before.

I found this blog has a lot of information about this board, https://blog.bachi.net/?p=7484

The devicetree disassembly shown there contains three deactivated SPI instances:

spi0 = “/soc/spi@c005b000”;
spi1 = “/soc/spi@c005c000”;
spi2 = “/soc/spi@c005f000”;

An overlay for spi0 would look something like this, but since I don’t know the real wiring, the values used (interrupt-parent, interrupts) are incomplete:

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/dts-v1/;
/plugin/;

/ {
<---->compatible = “nexell,s5p6818”;
};

&{/soc/spi@c005b000} { // spi0
<---->#address-cells = <1>;
<---->#size-cells = <0>;
<---->status = “okay”;

<---->accelerometer@0 {
<----><------>compatible = “adi,adxl345”;
<----><------>reg = <0>;
<----><------>spi-max-frequency = <5000000>;
<----><------>spi-cpol;
<----><------>spi-cpha;
<----><------>interrupt-parent = <&gpio1>;
<----><------>interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
<---->};
};

In addition, it is unclear whether kernel driver support for compatible = "nexell,s5p6818-spi"; is available.

1 Like

Since no /proc/device-tree/**/status exist, is it possible to still enable it that way or may that kernel build simply not support device tree overlays? It is still based on the original kernel by FriendlyELEC Linux v4.4, Armbian just managed to raise the base version to 4.14. For this SoC I wasn’t able to find newer mainline Linux builds.

My overlay enables a fully defined SPI master device node, if no predefined node exists you have to provide all properties.

There is nothing a kernel needs to support for the application of a DTBO, the kernel uses a DTB and cannot even determine how it is maybe composed. The DTB is assembled before the kernel starts.

The absence of predefined nodes suggests that there is no driver support and adding the devicetree properties does not magically generate the driver code. Look in the sources for a driver that supports nexell,s5p6818-spi

Okay, so most importantly we’d need a kernel driver for this SoC’s SPI.

Exactly, and since s5p6818 nor nexell is mentioned in mainline devicetree binding documentation, it can be assumed that the blog post refers to a legacy kernel fork. The available driver is probably in an unusable state for mainline usage, so that hardkernel answered like this:

1 Like