I’ve been attempting to get an external USB Wi-Fi adapter(D-Link DWA-171) working on a Raspberry Pi 3, running Resin OS(started with v1.24.1, but then switched to v2.0.0-beta.7 as suggested by @craig due to missing headers/scripts in previous versions).
I’ve built that same module, albeit for a different platform. Based on my experience with the huge range of versions of the rtl8812au drivers out there, I’d recommend starting by pulling the resin headers down for your architecture (you can see how to get them by following the code in the kernel-module-build project) and just build it yourself outside of the resin / docker environment to start with. I had to mangle the makefile quite a bit to get everything to compile properly. If I remember correctly, the particular issue you’re having there is related to the way the kernel sources are brought in on this line:
Thanks for the tips @cmoss that’s very handy! Is there a repo you can share with complete example, or something that can be adapted into a working base project / boilerplate? There’s indeed a lot of variation out there, and kernel modules will be just more important later.
Hi @bjorn, that was an over-eager spam filter on the forums, reinstated your posts, and whitelisted github.com, so it won’t happen again with that domain. Hope it didn’t cause too much inconvenience!
I’ve been looking at this when I get the time, but I havn’t been able to make it build yet either. It’s not really my area of expertise but I’ll keep looking, and update if I reach anything meaningful. At the moment I’m also just failing on Makefile errors. Sorry I’ve not been more help
Unfortunately I don’t have anything ARM here right now to test with, nor do I have the cross compile toolchain setup (we’re doing everything resin with x86), however here’s what I noticed when I tried building your repo:
A). Build with a standard git push resin master:
Failed - like you said:
[Build] scripts/Makefile.build:44: init/Makefile: No such file or directory
[Build] make[1]: *** No rule to make target 'init/Makefile'. Stop.
[Build] Makefile:947: recipe for target 'init' failed
[Build] make: *** [init] Error 2
[Build] make: Leaving directory '/tmp/tmp.mQsAYtBAoq'
B) Build locally, using the standard Makefile:
Pull down the kernel headers: wget https://files.resinstaging.io/images/raspberrypi3/2.0.0-beta.7/kernel_modules_headers.tar.gz
Compile from within the module directory:
make ARCH=arm CROSS_COMPILE= -C /lib/modules/3.14.0/build M=/home/cmoss/Development/rtl8812-resin-module/rtl8812au_rtl8821au modules
make[1]: *** /lib/modules/3.14.0/build: No such file or directory. Stop.
Makefile:1680: recipe for target ‘modules’ failed
make: *** [modules] Error 2
No surprise there, shouldn’t work anway.
Hack the KSRC directory, to point to the headers that we downloaded:
(vivid)cmoss@localhost:~/Development/rtl8812-resin-module/rtl8812au_rtl8821au$ make
make ARCH=arm CROSS_COMPILE= -C /home/cmoss/Development/rtl8812-resin-module/kernel_modules_headers M=/home/cmoss/Development/rtl8812-resin-module/rtl8812au_rtl8821au modules
make[1]: Entering directory '/home/cmoss/Development/rtl8812-resin-module/kernel_modules_headers’
CC [M] /home/cmoss/Development/rtl8812-resin-module/rtl8812au_rtl8821au/core/rtw_cmd.o
gcc: error: unrecognized argument in option '-mabi=aapcs-linux’
gcc: note: valid arguments to ‘-mabi=’ are: ms sysv
gcc: error: unrecognized command line option '-mlittle-endian’
gcc: error: unrecognized command line option '-mapcs’
gcc: error: unrecognized command line option '-mno-sched-prolog’
gcc: error: unrecognized command line option '-mno-thumb-interwork’
gcc: error: unrecognized command line option '-mfpu=vfp’
scripts/Makefile.build:258: recipe for target ‘/home/cmoss/Development/rtl8812-resin-module/rtl8812au_rtl8821au/core/rtw_cmd.o’ failed
make[2]: *** [/home/cmoss/Development/rtl8812-resin-module/rtl8812au_rtl8821au/core/rtw_cmd.o] Error 1
Makefile:1384: recipe for target ‘module/home/cmoss/Development/rtl8812-resin-module/rtl8812au_rtl8821au’ failed
make[1]: *** [module/home/cmoss/Development/rtl8812-resin-module/rtl8812au_rtl8821au] Error 2
make[1]: Leaving directory '/home/cmoss/Development/rtl8812-resin-module/kernel_modules_headers’
Makefile:1680: recipe for target ‘modules’ failed
make: *** [modules] Error 2
Tries to compile, fails, because I don’t have any of the ARM cross compile stuff here - but at least it knows what it has to do.
I’m 99.9% sure if you do this either directly on the ARM system, or on a rig with the ARM toolchain, then it will compile properly.
I’ve not had a chance to dig much into the Makefile, but if you look at the top there are any number of switches based on architecture, which then use a different definition of KSRC. The build.sh you’re using expects the makefile to play nicely with the kernel headers it gets given which that Makefile really doesn’t do. Basically, although you have the right headers, your Makefile is ignoring them.
Ok, so I couldn’t let that evil Makefile get its way. If you want a quick and very dirty way to get your module compiled, using the resin toolchain, here you go:
There is certainly a much cleaner way to get this working (I haven’t checked how many files build artifacts are left hanging around after this) - but at least this way you’ll get the module compiled, and I don’t have to spend any more time looking at that horrible Makefile
Thanks a ton @cmoss, the hacky solution worked perfectly!
This issue was a blocker for the project I’m working on… At least now I’ll be able to get a move on with things. I’ll try and work out a cleaner solution eventually, now that I know what the problem was.