Power & Source of Big Ideas

Enabling SPI and the ENC28J60 ethernet driver on NanoPi A64

Moderators: chensy, FATechsupport

I've been working at enabling the kernel (linux-3.10) for using an ENC28J60 board http://www.industrialberry.com/ethernetberry-v-1-1/

I have set up the build environment for building the boot.img and have successfully replaced and booted an image I built.

Secondly, I enabled the enc28j60 driver, cleaned, and re-ran the config and rebuilt and was able to generate an enc28j60.ko kernel module.

Finally, I also configured (thought unsure if correctly), the spi busses in the /lichee/tools/pack/chips/sun50iw1p1/configs/nanopi_a64/sys_config.fex file.

I changed the configuration as follows:

Code: Select all

;----------------------------------------------------------------------------------
;SPI controller configuration
;----------------------------------------------------------------------------------
[spi0]
; spi0_used       = 0
; XXX 5D change to enable SPI
spi0_used       = 1
spi0_cs_number  = 1
spi0_cs_bitmap  = 1
spi0_cs0        = port:PC3<4><1><default><default>
spi0_sclk       = port:PC2<4><default><default><default>
spi0_mosi       = port:PC0<4><default><default><default>
spi0_miso       = port:PC1<4><default><default><default>

[spi1]
; spi1_used       = 0
; XXX 5D change to enable SPI
spi1_used       = 1
spi1_cs_number  = 1
spi1_cs_bitmap  = 1
spi1_cs0        = port:PD0<4><1><default><default>
spi1_sclk       = port:PD1<4><default><default><default>
spi1_mosi       = port:PD2<4><default><default><default>
spi1_miso       = port:PD3<4><default><default><default>


Basically the only change was to change spi0_used and spi1_used to 1 to enable spi. There's another section in the .fex file that is the SPI device configuration:

Code: Select all

;----------------------------------------------------------------------------------
;SPI device configuration
;compatible        --- device name
;spi-max-frequency --- work frequency
;reg               --- chip select
;optional properties: spi-cpha, spi-cpol, spi-cs-high
;----------------------------------------------------------------------------------
;[spi0/spi_board0]
;compatible        =
;spi-max-frequency =
;reg               =
;spi-cpha
;spi-cpol
;spi-cs-high


I didn't change any of it, so I assume it will default to some reasonable value.

I can:

Code: Select all

sudo insmod enc28j60.ko


and can see it listed:

Code: Select all

Module                  Size  Used by
enc28j60               18648  0
mali                  213077  0
8189es               1032333  0


I think I'm close, but I'm still not seeing any signs the ports were recognized. I don't see any SPI messages in the message log, etc.

Does anyone have a recommendation for what to try next? I think the issue may be in enabling SPI because I don't see anything resembling SPI devices in /dev/ or in the logs.
In older Linux distros used for the mini2440 and maybe even the NanoPi SPI had to be enabled in the kernel.

Also there is a test app called spidev where you perform a loopback test to check that things are operating.
I've attached the two files I've modified to attempt to support SPI / ENC28J60. I hope someone might review these and see what I'm missing, mis-configuring, or suggest additional configuration that is required to get SPI running on the NanoPi A64.

    sun50iw1p1smp_linux_defconfig - in: lichee/linux-3.10/arch/arm64/configs

    sys_config.fex - in: lichee/tools/pack/chips/sun50iw1p1/configs/nanopi_a64

configs.tar.gz
configs changed to support SPI ENC28J60
(31.84 KiB) Downloaded 882 times

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 3 guests