starnight / LoRa

LoRa device driver as a kernel module
Other
133 stars 59 forks source link

crosscompile against 4.19 #13

Closed frank-w closed 5 years ago

frank-w commented 5 years ago

Hi,

can you guide me cross-compiling the module for armhf against Linux 4.19?

i try to integrate it to https://github.com/frank-w/BPI-R2-4.14/tree/4.19-main

i have put it into utils/lora and modified Makefile

KERNEL_LOCATION=../..
BUILDDIR=$(KERNEL_LOCATION)

and tried running make like this:

make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm

regards Frank

starnight commented 5 years ago

This project makes the sx1278 as an external module which does not exist in original Linux kernel. So, I have not tried the cross-compiling for it. However, you can build it on an arm board manually, just like on x86 computers.

Or, you can move the source file into Linux kernel source code by yourself for experiment. Then, also prepare and modify the related Kconfigs and Makefiles which enables to choose the sx1278 module in make menuconfig.

frank-w commented 5 years ago

i compile my kernel with crosscompile (don't want doing on target-machine) so i added it to lora makefile too, as described above. i also changed path to my kernel-source...i know that it is not existing in kernel itself, but makefile needs kernel-sources so i only changed the path to them

problem is that module seems not to be compatible with 4.19, many missing, duplicate and different definitions

have compiled it against 4.19 kernel-sources yet?

starnight commented 5 years ago

Please show the compiling error.

BTW, have you tried the commit which is just pushed few hours ago? I have tried it on my laptop whose kernel is 4.20.

frank-w commented 5 years ago

have now added the patch and got this result:

make -C ../.. M=/media/data_ext/bpi-r2-kernel/github/utils/lora modules
make[1]: Entering directory '/media/data_ext/bpi-r2-kernel/github'
  CC [M]  /media/data_ext/bpi-r2-kernel/github/utils/lora/sx1278.o
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "ieee802154_xmit_complete" [/media/data_ext/bpi-r2-kernel/github/utils/lora/sx1278.ko] undefined!
WARNING: "ieee802154_rx_irqsafe" [/media/data_ext/bpi-r2-kernel/github/utils/lora/sx1278.ko] undefined!
WARNING: "ieee802154_register_hw" [/media/data_ext/bpi-r2-kernel/github/utils/lora/sx1278.ko] undefined!
WARNING: "ieee802154_alloc_hw" [/media/data_ext/bpi-r2-kernel/github/utils/lora/sx1278.ko] undefined!
WARNING: "ieee802154_free_hw" [/media/data_ext/bpi-r2-kernel/github/utils/lora/sx1278.ko] undefined!
WARNING: "ieee802154_unregister_hw" [/media/data_ext/bpi-r2-kernel/github/utils/lora/sx1278.ko] undefined!
  CC      /media/data_ext/bpi-r2-kernel/github/utils/lora/sx1278.mod.o
  LD [M]  /media/data_ext/bpi-r2-kernel/github/utils/lora/sx1278.ko
make[1]: Leaving directory '/media/data_ext/bpi-r2-kernel/github'
starnight commented 5 years ago

The log says sx1278 module is built now. Please copy it to /lib/modules/<kernel-version>/extra/ of your target board.

All of the functions in the warnings are provided by the mac802154 module in Linux kernel. You can check the mac802154 is built within the Linux kernel or not for the warnings. If it is not, please toggle it to Y or M in make menuconfig when you build Linux kernel.

frank-w commented 5 years ago

thank you, this fixes that

now i'm hanging on overlay (have changed target-dir and removed sudo)...

dtc -I dts -O dtb -@ -o rpi-lora-spi.dtbo rpi-lora-spi-overlay.dts
rpi-lora-spi.dtbo: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property
rpi-lora-spi.dtbo: Warning (unit_address_vs_reg): Node /fragment@0/__overlay__/spidev@0 has a unit name, but no reg property
rpi-lora-spi.dtbo: Warning (unit_address_vs_reg): Node /fragment@0/__overlay__/spidev@1 has a unit name, but no reg property

btw. uploaded my staging here: https://github.com/frank-w/BPI-R2-4.14/tree/4.19-lora_new

created a separate dts for bpi-r2 where only spi0 is defined (no spidev), so only the top-node (fragment 0) brings this warning

make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm
dtc -I dts -O dtb -@ -o bpi-r2-lora-spi.dtbo bpi-r2-lora-spi-overlay.dts
bpi-r2-lora-spi.dtbo: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property

build is a symlink to my source-directory on my host-machine (invalid on target)...imho the module has to be inside /lib/modules/kernelname/kernel/...but where?

starnight commented 5 years ago

The original issue is solved. The overlay question is another issue. Please separate it to a new ticket.

frank-w commented 5 years ago

Ok,have opened a new issue for dts

Where should i put the module? build-symlink is invalid on target

starnight commented 5 years ago

Please copy the built module to /lib/modules/<kernel-version>/extra/ of your target board. It is described in Building External Modules