Cross Compile Driver for Asus USB-AC56

Hello,

I am having some trouble cross-compiling an Asus-AC56 Driver for the Jetson TK1 - code is here:

That code compiles perfectly under x86, but I can’t cross-compile it. This is the command:
make ARCH:=arm CROSS_COMPILE:=arm-linux-gnueabihf-

This tells me that it can’t find asm/bitsperlong.h, but it does exist on /usr/include/asm !

What am I missing?

Thank you for your patience!
Pedro Roque

A more correct subforum for TK1 related questions would be this:
https://devtalk.nvidia.com/default/board/162/jetson-tk1/

Cross compilation can be a very complex process when the code doesn’t explicitly support it.

E.g. in your case /usr/include/asm might be a link to the asm headers for the host (PC) but not the target (Jetson TK1).

Is there a reason not to try compiling the driver natively on the Jetson?

I tried to, but had this error:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /lib/modules/3.10.40-gc017b03/build M=/home/ubuntu/Drivers/rtl8812au modules
make[1]: Entering directory /usr/src/linux-headers-3.10.40-gc017b03' CC [M] /home/ubuntu/Drivers/rtl8812au/core/rtw_cmd.o /usr/src/linux-headers-3.10.40-gc017b03/scripts/recordmcount: 1: /usr/src/linux-headers-3.10.40-gc017b03/scripts/recordmcount: Syntax error: "(" unexpected make[2]: *** [/home/ubuntu/Drivers/rtl8812au/core/rtw_cmd.o] Error 2 make[1]: *** [_module_/home/ubuntu/Drivers/rtl8812au] Error 2 make[1]: Leaving directory /usr/src/linux-headers-3.10.40-gc017b03’
make: *** [modules] Error 2

What am I doing wrong?

This is my kernel: 3.10.40-gc017b03

Can’t find, on the apt-get, a linux-header for this version. Do I need to upgrade it to 3.13 ? If so, how?

Thank you for your fast answear!

Ok, so I did the following:

  1. Fresh install of the system;

  2. make on driver from ( http://elinux.org/Jetson/Network_Adapters ), while changing the kernel source to /usr/src/(KVER)/kernel and KVER=(shell uname -r)

  3. Said to first do make modules_prepare on kernel folder, did it

  4. make, sudo make install -> asked for directory to puth 8812au.ko -> gave liv/modules/KVER/kernel/drivers/net/wireless , where the other are. With this, it instelled fine.

  5. sudo modprobe 8812au -> said cannot allocate memory. After this I rebooted and had no ifconfig, no internet, and nothing from internet drivers.

What happened?

What error exactly do you see when you run the modprobe command? And what message do you see from the kernel (run “dmesg”)?

Hello,

First, thank you for your time and patience!

This is the error I have doing sudo modprobe 8812au:

-----------CODE
ubuntu@tegra-ubuntu:~/Downloads/rtl8812au$ sudo make install
[sudo] password for ubuntu:
install -p -m 644 8812au.ko /lib/modules/3.10.40-gdacac96/kernel/drivers/net/wireless/
/sbin/depmod -a 3.10.40-gdacac96
ubuntu@tegra-ubuntu:~/Downloads/rtl8812au$ sudo modprobe 8812au
modprobe: ERROR: could not insert ‘8812au’: Cannot allocate memory
-----------END CODE

And this is dmesg:

Thank you!

Best,

From the dmesg log:

[  248.658114] vmap allocation for size 19832832 failed: use vmalloc=<size> to increase size.

You can try adding vmalloc=320M in /boot/extlinux/extlinux.conf. It is a bit risky and you should create another entry there and during the Jetson boot use the serial cable to interrupt the bootloader and select that new entry. If you don’t mind flashing the board again, you can just add the option to the existing “APPEND” line.

I think you can check the vmalloc allocation and usage like this on Jetson:

cat /proc/meminfo | grep -i vmalloc

Hello,

That worked and solved the problem - but yet another one appeared: if I dont plugin the device, everything is okay. When I do plug it in, I return to the previous state, no internet, no ping, no ifconfig.

Here is the log from dmesg:

http://pastebin.com/raw/420jxhPW

Any advice? I see some problems regarding the driver in there - mainly in this:

------------ CODE
[ 68.667274] RTL871X: use other value 63
[ 68.667287] Unable to handle kernel paging request at virtual address 983c032b
[ 68.674828] pgd = dbf94000
[ 68.677550] [983c032b] *pgd=00000000
[ 68.681141] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[ 68.686442] Modules linked in: 8812au(O) cfg80211 dm_crypt dm_mod rfcomm bnep bluetooth rfkill joydev nvhost_vi
[ 68.696607] CPU: 0 PID: 678 Comm: NetworkManager Tainted: G O 3.10.40-gdacac96 #1
[ 68.704940] task: dbba2a40 ti: db018000 task.ti: db018000
[ 68.710394] PC is at PHY_ConvertPowerLimitToPowerIndex+0x590/0xa64 [8812au]
[ 68.717402] LR is at PHY_ConvertPowerLimitToPowerIndex+0x578/0xa64 [8812au]
[ 68.724349] pc : [] lr : [] psr: 600f0013
[ 68.724349] sp : db019938 ip : 00000000 fp : 0000345c
[ 68.735801] r10: 00000000 r9 : 00000000 r8 : d91da872
[ 68.741013] r7 : d91d8000 r6 : d91da872 r5 : 00000000 r4 : 0000003f
[ 68.747524] r3 : 983c0329 r2 : bf1e5564 r1 : 600f0093 r0 : 0000001b
[ 68.754037] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 68.761157] Control: 10c5387d Table: 9bf9406a DAC: 00000015
------------ END CODE

Unfortunately I can’t help you with that.

Actually I think I’ve used a similar driver on my Jetson but it was quite a long time ago and I don’t remember the details anymore.

I might have been this:

And version 91f08b1914d9e46abbb9aaf70e724f6788624190

But I need to add rules and directories to Makefile on that, right?

Many many thanks to you!

That branch solved the problem, just added to the Makefile the rules for compiling and it worked flawlessly.

For the future:

  • download driver from https://github.com/codeworkx/rtl8812au_asus ;

  • add rule as follows:

    add “CONFIG_PLATFORM_TEGRA_K1 = y” on platform related; make sure all other platforms are set as “=n”
    add after I386 make rules:

    ifeq ((CONFIG_PLATFORM_TEGRA_K1), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN ARCH := arm CROSS_COMPILE := arm-linux-gnueabihf- KVER := (shell uname -r)
    KSRC ?= /usr/src/linux-headers-(KVER) MODDESTDIR := /lib/modules/(KVER)/kernel/drivers/net/wireless/
    endif

  • do " make ". If it asks to make modules_prepare on /usr/src/linux-headers-KVER, do so

  • do “sudo make install”

  • do “sudo modprobe 8812au”

  • if it gives an error saying it cannot allocate memory, add vmalloc=512M on /boot/extlinux/extlinux.conf , as suggested by @kulve . Then reboot. If the error persists or if the driver does not work, you may need to reflash TK1 and add vmalloc to the file right after the first boot, reboot again, and proceed from step one.

Kulve, this wouldn’t be possible without your help. Thank you!