OK with the Makefile like so:
KERNEL_TREE_PATH?=/lib/modules/$(shell uname -r)/build
EXTRA_CFLAGS="-DDEBUG"
obj-m += peak_usb.o
peak_usb-y = pcan_usb_core.o pcan_usb.o pcan_usb_pro.o pcan_usb_fd.o
all:
make -C $(KERNEL_TREE_PATH) M=$(PWD) modules
clean:
make -C $(KERNEL_TREE_PATH) M=$(PWD) clean
.PHONY: all clean
Dockerfile.template:
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian
RUN apt-get update && apt-get install -y \
awscli \
bc \
bison \
build-essential \
curl \
flex \
libelf-dev \
libssl-dev \
python \
wget
ENV VERSION '2.47.0+rev1'
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN ./build.sh %%BALENA_MACHINE_NAME%% $VERSION peak_usb
CMD ./run.sh
Doing the build reults in the following:
[Build] [can-peak] CC /tmp/tmp.14Q9jqGKEd/tools/objtool/special.o
[Build] [can-peak] CC /tmp/tmp.14Q9jqGKEd/tools/objtool/objtool.o
[Build] [can-peak] CC /tmp/tmp.14Q9jqGKEd/tools/objtool/libstring.o
[Build] [can-peak] CC /tmp/tmp.14Q9jqGKEd/tools/objtool/str_error_r.o
[Build] [can-peak] LD /tmp/tmp.14Q9jqGKEd/tools/objtool/objtool-in.o
[Build] [can-peak] diff: ../../arch/x86/lib/insn.c: No such file or directory
[Build]
[Build] [can-peak] Warning: synced file at 'tools/objtool/arch/x86/lib/insn.c' differs from latest kernel version at 'arch/x86/lib/insn.c'
[Build] [can-peak] diff:
[Build] [can-peak] ../../arch/x86/lib/inat.c
[Build] [can-peak] : No such file or directory
[Build] [can-peak]
[Build]
[Build] [can-peak] Warning: synced file at 'tools/objtool/arch/x86/lib/inat.c' differs from latest kernel version at 'arch/x86/lib/inat.c'
[Build] [can-peak] diff:
[Build] [can-peak] ../../arch/x86/lib/x86-opcode-map.txt
[Build] [can-peak] : No such file or directory
[Build] [can-peak]
[Build]
[Build] [can-peak] Warning: synced file at 'tools/objtool/arch/x86/lib/x86-opcode-map.txt' differs from latest kernel version at 'arch/x86/lib/x86-opcode-map.txt'
[Build] [can-peak] diff:
[Build] [can-peak] ../../arch/x86/tools/gen-insn-attr-x86.awk
[Build] [can-peak] : No such file or directory
[Build] [can-peak]
[Build]
[Build] [can-peak] Warning: synced file at 'tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk' differs from latest kernel version at 'arch/x86/tools/gen-insn-attr-x86.awk'
[Build] [can-peak] LINK /tmp/tmp.14Q9jqGKEd/tools/objtool/objtool
[Build] [can-peak] make: Leaving directory '/tmp/tmp.14Q9jqGKEd'
[Build] [can-peak] make: Entering directory '/tmp/tmp.14Q9jqGKEd'
[Build] [can-peak] CC [M] /usr/src/app/peak_usb_intel-nuc_2.47.0+rev1.prod_from_src/pcan_usb_core.o
[Build] [can-peak] CC [M] /usr/src/app/peak_usb_intel-nuc_2.47.0+rev1.prod_from_src/pcan_usb.o
[Build] [can-peak] CC [M] /usr/src/app/peak_usb_intel-nuc_2.47.0+rev1.prod_from_src/pcan_usb_pro.o
[Build] [can-peak] CC [M] /usr/src/app/peak_usb_intel-nuc_2.47.0+rev1.prod_from_src/pcan_usb_fd.o
[Build] [can-peak] LD [M] /usr/src/app/peak_usb_intel-nuc_2.47.0+rev1.prod_from_src/peak_usb.o
[Build] [can-peak] Building modules, stage 2.
[Build] [can-peak] MODPOST 1 modules
[Build] [can-peak] CC /usr/src/app/peak_usb_intel-nuc_2.47.0+rev1.prod_from_src/peak_usb.mod.o
[Build] [can-peak] LD [M] /usr/src/app/peak_usb_intel-nuc_2.47.0+rev1.prod_from_src/peak_usb.ko
[Build] [can-peak] make: Leaving directory '/tmp/tmp.14Q9jqGKEd'
[Build] [can-peak] Removing intermediate container bae5a4b8cfae
[Build] [can-peak] ---> baacf040b324
[Build] [can-peak] Step 7/9 : CMD ./run.sh
[Build] [can-peak] ---> Running in 5381204516c8
[Build] [can-peak] Removing intermediate container 5381204516c8
[Build] [can-peak] ---> c09acf8878bd
[Build] [can-peak] Step 8/9 : LABEL io.resin.local.image=1
[Build] [can-peak] ---> Running in 7ee27adb7e42
[Build] [can-peak] Removing intermediate container 7ee27adb7e42
[Build] [can-peak] ---> fabc09d32752
[Build] [can-peak] Step 9/9 : LABEL io.resin.local.service=can-peak
[Build] [can-peak] ---> Running in cc9feb4e77b2
[Build] [can-peak] Removing intermediate container cc9feb4e77b2
[Build] [can-peak] ---> c190cb009532
[Build] [can-peak] Successfully built c190cb009532
[Build] [can-peak] Successfully tagged local_image_can-peak:latest
[Live] Waiting for device state to settle...
[Info] Streaming device logs...
[Live] Watching for file changes...
[Logs] [4/14/2020, 9:54:17 PM] Killing service 'can-peak sha256:cd06dfe98fec8e552bec58d35eb913ef7632859172be2b426ab76c494ab51cde'
[Logs] [4/14/2020, 9:54:24 PM] [peak] 2020-04-14 13:54:24.256 | Level 10 | paho.mqtt.client:_easy_log:2415 - Sending PINGREQ
[Logs] [4/14/2020, 9:54:24 PM] [peak] 2020-04-14 13:54:24.299 | Level 10 | paho.mqtt.client:_easy_log:2415 - Received PINGRESP
[Logs] [4/14/2020, 9:54:28 PM] Service exited 'can-peak sha256:cd06dfe98fec8e552bec58d35eb913ef7632859172be2b426ab76c494ab51cde'
[Logs] [4/14/2020, 9:54:29 PM] Killed service 'can-peak sha256:cd06dfe98fec8e552bec58d35eb913ef7632859172be2b426ab76c494ab51cde'
[Logs] [4/14/2020, 9:54:34 PM] Installing service 'can-peak sha256:c190cb009532c31d6209144fa781167b075d7e87655fcdc22fbdf1281612680f'
[Logs] [4/14/2020, 9:54:34 PM] Installed service 'can-peak sha256:c190cb009532c31d6209144fa781167b075d7e87655fcdc22fbdf1281612680f'
[Logs] [4/14/2020, 9:54:34 PM] Starting service 'can-peak sha256:c190cb009532c31d6209144fa781167b075d7e87655fcdc22fbdf1281612680f'
[Logs] [4/14/2020, 9:54:35 PM] Started service 'can-peak sha256:c190cb009532c31d6209144fa781167b075d7e87655fcdc22fbdf1281612680f'
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] modprobe: FATAL: Module can not found in directory /lib/modules/5.2.10-yocto-standard
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] insmod: ERROR: could not load module peak_usb.ko: No such file or directory
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] Loading module from peak_usb_intel-nuc_2.47.0+rev1.prod_from_src
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] insmod: ERROR: could not load module peak_usb.ko: No such file or directory
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] insmod: ERROR: could not load module peak_usb.ko: No such file or directory
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] OS Version is 2.47.0+rev1
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] Loading module from peak_usb_intel-nuc_2.47.0+rev1.dev
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.2.10-yocto-standard/modules.dep.bin'
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] Loading module from peak_usb_intel-nuc_2.47.0+rev1.prod
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] Loading module from peak_usb_intel-nuc_2.47.0+rev1.dev_from_src
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.2.10-yocto-standard/modules.dep.bin'
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.2.10-yocto-standard/modules.dep.bin'
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.2.10-yocto-standard/modules.dep.bin'
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] modprobe: FATAL: Module can not found in directory /lib/modules/5.2.10-yocto-standard
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] modprobe: FATAL: Module can not found in directory /lib/modules/5.2.10-yocto-standard
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] insmod: ERROR: could not load module peak_usb.ko: No such file or directory
[Logs] [4/14/2020, 9:54:35 PM] [can-peak] modprobe: FATAL: Module can not found in directory /lib/modules/5.2.10-yocto-standard
The .ko gets built (with the Makefile above) and it is available in the can-peak container:
root@a942892:/usr/src/app# ls /usr/src/app/peak_usb_intel-nuc_2.47.0+rev1.prod_from_src/peak_usb.ko
/usr/src/app/peak_usb_intel-nuc_2.47.0+rev1.prod_from_src/peak_usb.ko
Trying to load the dependencies
root@a942892:/usr/src/app# modprobe can can-dev
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.2.10-yocto-standard/modules.dep.bin'
modprobe: FATAL: Module can not found in directory /lib/modules/5.2.10-yocto-standard