BPI-R2 SPI Communication

(Prakash) #122

Thanks for the update @frank-w I did not tried SPI after that. May I know if you have prebuilt kernel/u-boot to test it out as quick turn around.


(Frank W.) #123

Kernel is on my repo (releases),uboot i can send you but you need a dto matching your hardware. You have to create this and compile. If you need additional driver tell me.

(Prakash) #124

dto matching your hardware

I am going to interface LORA Radio based on SPI communication. Should I need any special driver for to communicate over BPI-R2?. I done the similar interfaces on others boards without any additional drivers.


(Frank W.) #125

Here a compatible “sx1278” is used…have to look which driver is defining that

As far as i see you have to compile the module by youself with referencing your kernel-source (and maybe crosscompiler).

have tried adding source to my repo in folder utils, but facing many build-problems

lora.tar.gz (11,3 KB) build.log (112,1 KB)

seems lora is not compatible with 4.19…

there is a lkml-thread for lora from july 18, but files are not included in 4.19 yet: https://lwn.net/Articles/758774/ Patchset should be this: https://patchwork.ozlabs.org/cover/937545/

u-boot-2019-01-bpi-r2.bin.gz (163,4 KB)

have applied Patches without error to separate branch (not pushed) and tried to compile…

ERROR: "__aeabi_ldivmod" [drivers/net/lora/lora-sx1276.ko] undefined!
ERROR: "__aeabi_uldivmod" [drivers/net/lora/lora-sx1276.ko] undefined!
make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2

have not found this functions in my source-tree, also not in lora-source…i don’t know why this is needed…

https://stackoverflow.com/questions/25623956/aeabi-ldivmod-undefined-when-compiling-kernel-module recommends using div64.h…but where?

(Prakash) #126

Not sure why we want to add LORA component as part of the kernel since the LORA radio will be using generic SPI communication b/w the host. We enabled SPI and started using radio straightaway in RPI boards by this library, I am using this source, https://github.com/CongducPham/LowCostLoRaGw/tree/master/gw_full_latest

This is the another good source, https://github.com/hallard/RadioHead

(Prakash) #127

@frank-w If you confirmed the generic SPI communication is working fine on the updated kernel, then I can give a try with LORA and let us know the outcome.


(Frank W.) #128

I cannot try spi because i have no spi-device here…i had only tried with wired miso/mosi,but testapp is strange (always shows rx…also if circuit is open)

(Frank W.) #129

good news…i got lora-driver compiled here: https://github.com/frank-w/BPI-R2-4.14/tree/4.19-lora_new

currently hang on dt-overlay

will upload kernel and module for you to test (you will need also new uboot and have to load nodt-kernel with dtb+dto)…take a look here how to configure uboot:

to flash uboot:

gunzip u-boot-2019-01-bpi-r2.bin.gz
dd of=/dev/mmcblk0 if=u-boot-2019-01-bpi-r2.bin bs=1k seek=320 #for SD-Card

download files from here:


unpack kernel (change uImage_nodt and dtb to another filename and use it below)+modules to your SD-card and put this in your uEnv.txt (changed to your filenames)


put sx1278.ko to BPI_ROOT/lib/modules/4.19.20-bpi-r2-lora_new/extra/

and select “Boot from SD/EMMC 4.19 (fdt/dto)” from uboot-menu

(Frank W.) #130

@asprakash can you please try it out (lora on spi0) with new uboot and overlay?