@kwisatz Hi , firstly I think you have done some excellent research in this thread , and it has inspired and equipped to implement the overlay for the Waveshare CAN hat onto the Radxa Zero . I had done something similiar for RockPi S , but AMlogic resources and examples are in short supply on the internet.
The CAN hat employs Microchip MCP2515 , but its interface is not unlike the enc 28j60, meaning it has a SPI interface and a GPIO external IRQ interface. So with your help I have compiled the following dts source, and it works perfectly . Don’t know why I don’t have any SPI issues , could be because the packets are smaller and less frequent than Ethernet.
As you can see I am using SPI1 (SPIB per gpio pinout diagram) and i am using GPIOC_7 as the GPIO IRQ input. Gpio number 48 represents the GPIOC_7 and the IRQ number 60 the IRQ mapping for GPIOC_7. The latter I got from your link table below :
223:100 undefined (no interrupt)
99:97 3 pins on bank GPIOE
96:77 20 pins on bank GPIOX
76:61 16 pins on bank GPIOA
60:53 8 pins on bank GPIOC
52:37 16 pins on bank BOOT
36:28 9 pins on bank GPIOH
27:12 16 pins on bank GPIOZ
11:0 12 pins in the AO domain
So thank my man , you did some great work here . Have you managed success regarding your ethernet interface ?
@Antonr, I’m happy that the hours that we’ve spent on this have at least benefited someone else. As for us, we haven’t been able to make it work. I’ve not been able to redefine the entire GPIO as @RadxaYuntian suggested, and given how broken the CS is on the default mapping, the enc28j60 just won’t react to whatever the radxa-zero is sending.
I’d be interested in seeing your CS signal if you ever get the chance of connecting a logic analyzer.
Thanks for your investigation.
We purchased the enc28j60 module and tested it on radxa zero (based on amlogic). The problem you mentioned does exist. At the same time, we also tested on our other boards (based on rockchip) and found that it was feasible. The timing of the cs pin is the same as you described.
@kwisatz@shawaj@iplanux@feng Doing a mass ping here since we have implemented a gpio-spi based overlay and have tested it with real hardware.
You can find the source code for overlay here.
However, when testing against a iperf3 server, we only recorded around 500kpbs speed. Logic analyzer shows inconsistent clock signal, which is an unfortunately limitation with this software SPI imitation.
Edit: A SPI based overlay has been uploaded with combined bandwidth of ~3.5Mbps. @iplanux’s idea of using cs-gpios proves to be a better solution.
This is currently intended to be compiled along with the kernel, so the kbuild can resolve include directives first. Your error message is on line 4 which is the unsupported #include line for dtc. So for right now you should delete those include lines, and replace the constants (dtc will error out on them) with the value you can find from those included files. Those files are in the Linux kernel.
@wanthalf perhaps did you forget the -@ parameter to dtc ? Apparently it’s mandatory to compile overlays that lay above another one ; I think it’s related to symbol resolution. I don’t know if it’s involved in includes though.
I have not found any documentation to that option, so I have no idea what it does - but I think (not sure) that I tried it as well, without any effect. But replacing the (three?) constants manually worked well.
I think it would be nice to include both this overlay and the enc28j60.ko kernel module in the pre-built radxa images. It is an easy and cheap way to add a basic wired ethernet interface to the Zero - and probably sufficient for many IoT projects.
I plan to use the third UART_EE_C, so I modified the overlay for SPI-A and it seems to work. I use GPIOH_4 for interrupt – that is number 32 (thanks to @Antonr for the numbers!). I hope it won’t collide with the UART_EE_C just because GPIOH_4 is also assigned as UART_EE_C_RTS..?
UPDATE: Well, it does… So, changing to GPIOC_7, number 60.
Hi Yuntian,
I have tried to compile my files using dtc $ dtc -I dts -O dtb -o meson-g12a-spi-b-enc28j60.dtbo meson-g12a-spi-b-enc28j60.dts
But no matter what, it never works and always gives the same error:
Error: meson-g12a-spi-b-enc28j60.dts:xxx syntax error
FATAL ERROR: Unable to parse input tree.
I have already deleted those #includes, but the error came from the next line continue.
Do you have the out-of-tree bulid yet? Or can you please tell me how to compile the .dts file correctly?
Hi @kwisatz@feng,
How do you compile the .dts files into Radxa? I have tried with dtc to compile and still not working.
It always gives same error:
Error: meson-g12a-spi-b-enc28j60.dts: xxx syntax error
FATAL ERROR: Unable to parse input tree.
I have already tried to delete #include, but it changes nothing, the error came immediately from the next line.
I don’t have any clue how to compile it now. Could you please give me some guides?
The source for meson-g12a-spi-a-enc28j60.dts has been posted above in this post. But I thought the precompiled overlays were now part of the Radxa distribution, aren’t they?
Hi @wanthalf, I have already compiled both .dts Files from you, and copied them into the Overlay Ordner. But I can still not find the Device(ENC28J60) in the lsmod or dmesg and when I connect my enc28j60 to Radxa Zero via SPIA or SPIB pins, I still can’t get any data from the Ethernet. The uEnv.txt data from me is like this:
Hi @RadxaYuntian ,
Thanks for your reply. The driver from enc28j69 is maybe not in the build, the Terminal shows “CONFIG_ENC28J60 is not set”. I’m using Debian Buster from your official Website. What should I do next?
I am not using a custom kernel. When I give the command make menuconfig, I get: make:***No rule to make target 'menuconfig'. Stop.
How do I use the custom kernel?
I’m sorry I’m new to Linux, can you please explain it more clearly?