Kernel Headers for Driver Install

I’m trying to install a driver for an unsupported WiFi dongle, but I can’t compile it without kernel headers for the Raspberry Pi 3 B. How do I get them?

Older forum posts I’ve seen point to a wiki entry that seems to have vanished –
https://osmc.tv/help/wiki/kernel-sources

Any help would be greatly appreciated!

Is it a RealTek based dongle? Then chances are that it’s no longer supported. Why aren’t you just using the Pi3’s built in WiFi?

It is. By no longer supported, do you mean I won’t be able to get it to compile even with the headers? I found a driver with a Makefile that can be configured for “generic ARM” architectures, which supposedly works on the Pi3.

Built-in WiFi on my Pi is 2.4 GHz only, and that band is too crowded in my apartment. I can’t even reliably stream 720p video. OSMC frequently freezes and shows me the sad/angry face.

EDIT: Thanks for the quick reply by the way!

If you’re willing to adapt the driver and maintain it, then you might as well submit it upstream for inclusion in OSMC.

You will likely need to adapt the driver for OSMC. Use apt-cache search rbp2-source to grab sources (which have complete headers)

It probably would not compile with the headers. That’s why support has been dropped. RealTek has not updated their driver for linux in years, and the time it takes to keep making the drivers work on newer kernels has become to much of a burden.

You could try this:

sudo apt install rbp2-headers-$(uname -r)

(You may need to do rbp3-headers, I don’t have a Pi3, to check with)

If I manage to get it working I’d be glad to submit it for inclusion in OSMC. But bear in mind that I have little to no experience tweaking Linux drivers (save for some FPGA lab I fumbled my way through in university). The driver might not be stable if it ever compiles.

Right now I’m hitting the same roadblock no matter which driver modification I try to build. I’ve tried modifying the manufacturer’s original driver, two old versions tweaked by others and posted on GitHub, and one recent version somebody posted on GitHub that allegedly works on a newer kernel than the one the most recent version of OSMC is built on.

Here’s a link to the newest GitHub driver modification I’ll rate “most promising” –
https://github.com/sbarthelmess/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959

That one comes with a pre-compiled driver for kernel version 4.19.58, which I tried installing to no avail. OSMC is currently on 4.19.55.

The issue I’m running into while compiling the driver may be related to the headers. Right now I’m using “rbp2-headers-4.19.55-6-osmc”. I can’t find any for the Pi 3.

apt-cache search rbp3

Yields no results.

For what it’s worth, here’s the output when I try to compile showing all of the errors. It’s the same result no matter which modified driver source I use.

root@KodiLivingRoom:/usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master# make
make ARCH=arm CROSS_COMPILE= -C /lib/modules/4.19.55-6-osmc/build M=/usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master  modules
make[1]: Entering directory '/usr/src/rbp2-headers-4.19.55-6-osmc'
  CC [M]  /usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master/core/rtw_cmd.o
In file included from ./include/linux/srcu.h:33:0,
                 from ./include/linux/notifier.h:16,
                 from ./include/linux/memory_hotplug.h:7,
                 from ./include/linux/mmzone.h:748,
                 from ./include/linux/gfp.h:6,
                 from ./include/linux/umh.h:4,
                 from ./include/linux/kmod.h:22,
                 from ./include/linux/module.h:13,
                 from /usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master/include/basic_types.h:76,
                 from /usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master/include/drv_types.h:26,
                 from /usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master/core/rtw_cmd.c:17:
./include/linux/netfilter.h: In function ‘nf_hook’:
./include/linux/netfilter.h:211:34: error: dereferencing pointer to incomplete type ‘struct net’
   hook_head = rcu_dereference(net->nf.hooks_ipv4[hook]);
                                  ^
./include/linux/rcupdate.h:347:10: note: in definition of macro ‘__rcu_dereference_check’
  typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
          ^
./include/linux/rcupdate.h:542:28: note: in expansion of macro ‘rcu_dereference_check’
 #define rcu_dereference(p) rcu_dereference_check(p, 0)
                            ^~~~~~~~~~~~~~~~~~~~~
./include/linux/netfilter.h:211:15: note: in expansion of macro ‘rcu_dereferenc’
   hook_head = rcu_dereference(net->nf.hooks_ipv4[hook]);
               ^~~~~~~~~~~~~~~
In file included from ./arch/arm/include/asm/bug.h:60:0,
                 from ./include/linux/bug.h:5,
                 from ./include/linux/thread_info.h:12,
                 from ./include/asm-generic/preempt.h:5,
                 from ./arch/arm/include/generated/asm/preempt.h:1,
                 from ./include/linux/preempt.h:81,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/seqlock.h:36,
                 from ./include/linux/time.h:6,
                 from ./include/linux/stat.h:19,
                 from ./include/linux/module.h:10,
                 from /usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master/include/basic_types.h:76,
                 from /usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master/include/drv_types.h:26,
                 from /usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master/core/rtw_cmd.c:17:
./include/linux/build_bug.h:29:45: error: bit-field ‘<anonymous>’ width not an integer constant
 #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                             ^
./include/asm-generic/bug.h:148:27: note: in definition of macro ‘WARN_ON_ONCE’
  int __ret_warn_once = !!(condition);   \
                           ^~~~~~~~~
./include/linux/compiler-gcc.h:71:28: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
 #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                            ^~~~~~~~~~~~~~~~~
./include/linux/kernel.h:72:59: note: in expansion of macro ‘__must_be_array’
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                           ^~~~~~~~~~~~~~~
./include/linux/netfilter.h:218:28: note: in expansion of macro ‘ARRAY_SIZE’
   if (WARN_ON_ONCE(hook >= ARRAY_SIZE(net->nf.hooks_arp)))
                            ^~~~~~~~~~
scripts/Makefile.build:303: recipe for target '/usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master/core/rtw_cmd.o' failed
make[2]: *** [/usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master/core/rtw_cmd.o] Error 1
Makefile:1517: recipe for target '_module_/usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master' failed
make[1]: *** [_module_/usr/src/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959-master] Error 2
make[1]: Leaving directory '/usr/src/rbp2-headers-4.19.55-6-osmc'
Makefile:2011: recipe for target 'modules' failed
make: *** [modules] Error 2

Disclaimer: I probably said something wrong in this post. This is all outside my area of expertise.

I’m away from home this weekend, so won’t have a lot of free time to help out. Nevertheless, I VPN-ed back to base and tried to compile the code you linked to. It fails, but in a totally different way:

osmc@osmc:~/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959$ make
make ARCH=arm CROSS_COMPILE= -C /lib/modules/4.19.55-6-osmc/build M=/home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959  modules
make[1]: Entering directory '/usr/src/rbp2-headers-4.19.55-6-osmc'
  CC [M]  /home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959/core/rtw_cmd.o
In file included from ./include/linux/compat.h:16:0,
                 from ./include/linux/ethtool.h:17,
                 from ./include/linux/netdevice.h:41,
                 from /home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959/include/osdep_service_linux.h:30,
                 from /home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959/include/osdep_service.h:50,
                 from /home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959/include/drv_types.h:27,
                 from /home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959/core/rtw_cmd.c:17:
./include/linux/if.h:28:54: fatal error: sys/socket.h: No such file or directory
 #include <sys/socket.h>   /* for struct sockaddr.  */
                                                      ^
compilation terminated.
scripts/Makefile.build:303: recipe for target '/home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959/core/rtw_cmd.o' failed
make[2]: *** [/home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959/core/rtw_cmd.o] Error 1
Makefile:1517: recipe for target '_module_/home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959' failed
make[1]: *** [_module_/home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959] Error 2
make[1]: Leaving directory '/usr/src/rbp2-headers-4.19.55-6-osmc'
Makefile:2011: recipe for target 'modules' failed
make: *** [modules] Error 2
osmc@osmc:~/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959$ uname -a
Linux osmc 4.19.55-6-osmc #1 SMP PREEMPT Sun Nov 3 22:15:28 UTC 2019 armv7l GNU/Linux
osmc@osmc:~/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959$ dpkg -l "rbp2-headers*"
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                 Version                 Architecture            Description
+++-====================================-=======================-=======================-=============================================================================
un  rbp2-headers                         <none>                  <none>                  (no description available)
un  rbp2-headers-4.19                    <none>                  <none>                  (no description available)
ii  rbp2-headers-4.19.55-6-osmc          6                       armhf                   Header files related to Linux kernel, specifically,
osmc@osmc:~/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959$ 

This sys/socket.h: No such file or directory is a familiar error. See Has anybody tried to install Wireguard? - #9 by graza and the posts that follow.

Can you think of any reason why you’re seeing something completely different?

Ah, I forgot about that.

I believe I created an ./include/sys/ directory since none existed, then copiedsocket.h into it from ./include/linux/. That got the compiler chugging along for a few extra seconds before it broke again.

That’s just one of many issues with the OSMC headers, which still seem to be broken.

Please run the workaround mentioned here: Has anybody tried to install Wireguard? - #28 by dillthedog

It then compiles successfully – though no guarantees it’ll work, of course:

osmc@osmc:~/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959$ modinfo ./8812bu.ko
filename:       /home/osmc/Downloads/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959/./8812bu.ko
version:        v5.3.1_27678.20180430_COEX20180427-5959
author:         Realtek Semiconductor Corp.
description:    Realtek Wireless Lan Driver
license:        GPL
srcversion:     49D451124CBE237914609CA
alias:          usb:v0B05p184Cd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0B05p1841d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v7392pC822d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v7392pB822d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2357p0115d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2001p331Cd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v13B1p0043d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDApB812d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDApB82Cd*dc*dsc*dp*icFFiscFFipFFin*
depends:        cfg80211
name:           8812bu
vermagic:       4.19.55-6-osmc SMP preempt mod_unload modversions ARMv7 p2v8 
parm:           rtw_ips_mode:The default IPS mode (int)
parm:           rtw_lps_level:The default LPS level (int)
parm:           rtw_usb_rxagg_mode:int
parm:           rtw_dynamic_agg_enable:int
parm:           rtw_drv_log_level:set log level when insert driver module, default log level is _DRV_INFO_ = 4 (uint)
parm:           rtw_tx_bw_mode:The max tx bw for 2.4G and 5G. format is the same as rtw_bw_mode (uint)
parm:           rtw_rx_ampdu_sz_limit_1ss:RX AMPDU size limit for 1SS link of each BW, 0xFF: no limitation (array of uint)
parm:           rtw_rx_ampdu_sz_limit_2ss:RX AMPDU size limit for 2SS link of each BW, 0xFF: no limitation (array of uint)
parm:           rtw_rx_ampdu_sz_limit_3ss:RX AMPDU size limit for 3SS link of each BW, 0xFF: no limitation (array of uint)
parm:           rtw_rx_ampdu_sz_limit_4ss:RX AMPDU size limit for 4SS link of each BW, 0xFF: no limitation (array of uint)
parm:           rtw_vht_enable:int
parm:           rtw_vht_rx_mcs_map:VHT RX MCS map (uint)
parm:           rtw_rf_config:int
parm:           rtw_country_code:The default country code (in alpha2) (charp)
parm:           rtw_channel_plan:The default chplan ID when rtw_alpha2 is not specified or valid (int)
parm:           rtw_excl_chs:exclusive channel array (array of uint)
parm:           rtw_qos_opt_enable:int
parm:           ifname:The default name to allocate for first interface (charp)
parm:           if2name:The default name to allocate for second interface (charp)
parm:           rtw_pwrtrim_enable:int
parm:           rtw_initmac:charp
parm:           rtw_special_rf_path:int
parm:           rtw_chip_version:int
parm:           rtw_rfintfs:int
parm:           rtw_lbkmode:int
parm:           rtw_network_mode:int
parm:           rtw_channel:int
parm:           rtw_mp_mode:int
parm:           rtw_wmm_enable:int
parm:           rtw_vrtl_carrier_sense:int
parm:           rtw_vcs_type:int
parm:           rtw_busy_thresh:int
parm:           rtw_ht_enable:int
parm:           rtw_bw_mode:int
parm:           rtw_ampdu_enable:int
parm:           rtw_rx_stbc:int
parm:           rtw_rx_ampdu_amsdu:int
parm:           rtw_tx_ampdu_amsdu:int
parm:           rtw_beamform_cap:int
parm:           rtw_lowrate_two_xmit:int
parm:           rtw_power_mgnt:int
parm:           rtw_smart_ps:int
parm:           rtw_low_power:int
parm:           rtw_wifi_spec:int
parm:           rtw_full_ch_in_p2p_handshake:int
parm:           rtw_antdiv_cfg:int
parm:           rtw_antdiv_type:int
parm:           rtw_drv_ant_band_switch:int
parm:           rtw_single_ant_path:int
parm:           rtw_switch_usb_mode:int
parm:           rtw_enusbss:int
parm:           rtw_hwpdn_mode:int
parm:           rtw_hwpwrp_detect:int
parm:           rtw_hw_wps_pbc:int
parm:           rtw_check_hw_status:int
parm:           rtw_max_roaming_times:The max roaming times to try (uint)
parm:           rtw_mc2u_disable:int
parm:           rtw_advnace_ota:int
parm:           rtw_notch_filter:0:Disable, 1:Enable, 2:Enable only for P2P (uint)
parm:           rtw_hiq_filter:0:allow all, 1:allow special, 2:deny all (uint)
parm:           rtw_adaptivity_en:0:disable, 1:enable (uint)
parm:           rtw_adaptivity_mode:0:normal, 1:carrier sense (uint)
parm:           rtw_adaptivity_dml:0:disable, 1:enable (uint)
parm:           rtw_adaptivity_dc_backoff:DC backoff for Adaptivity (uint)
parm:           rtw_adaptivity_th_l2h_ini:th_l2h_ini for Adaptivity (int)
parm:           rtw_adaptivity_th_edcca_hl_diff:th_edcca_hl_diff for Adaptivity (int)
parm:           rtw_amplifier_type_2g:BIT3:2G ext-PA, BIT4:2G ext-LNA (uint)
parm:           rtw_amplifier_type_5g:BIT6:5G ext-PA, BIT7:5G ext-LNA (uint)
parm:           rtw_RFE_type:default init value:64 (uint)
parm:           rtw_powertracking_type:default init value:64 (uint)
parm:           rtw_GLNA_type:default init value:0 (uint)
parm:           rtw_TxBBSwing_2G:default init value:0xFF (uint)
parm:           rtw_TxBBSwing_5G:default init value:0xFF (uint)
parm:           rtw_OffEfuseMask:default open Efuse Mask value:0 (uint)
parm:           rtw_FileMaskEfuse:default drv Mask Efuse value:0 (uint)
parm:           rtw_rxgain_offset_2g:default RF Gain 2G Offset value:0 (uint)
parm:           rtw_rxgain_offset_5gl:default RF Gain 5GL Offset value:0 (uint)
parm:           rtw_rxgain_offset_5gh:uint
parm:           rtw_rxgain_offset_5gm:default RF Gain 5GM Offset value:0 (uint)
parm:           rtw_pll_ref_clk_sel:force pll_ref_clk_sel, 0xF:use autoload value (uint)
parm:           rtw_tx_pwr_by_rate:0:Disable, 1:Enable, 2: Depend on efuse (int)
parm:           rtw_target_tx_pwr_2g_a:2.4G target tx power (unit:dBm) of RF path A for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_2g_b:2.4G target tx power (unit:dBm) of RF path B for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_2g_c:2.4G target tx power (unit:dBm) of RF path C for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_2g_d:2.4G target tx power (unit:dBm) of RF path D for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_5g_a:5G target tx power (unit:dBm) of RF path A for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_5g_b:5G target tx power (unit:dBm) of RF path B for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_5g_c:5G target tx power (unit:dBm) of RF path C for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_target_tx_pwr_5g_d:5G target tx power (unit:dBm) of RF path D for each rate section, should match the real calibrate power, -1: undefined (array of int)
parm:           rtw_phy_file_path:The path of phy parameter (charp)
parm:           rtw_load_phy_file:PHY File Bit Map (int)
parm:           rtw_decrypt_phy_file:Enable Decrypt PHY File (int)
parm:           rtw_dynamic_soml_en:0: disable, 1: enable with default param, 2: enable with specified param. (int)
parm:           rtw_dynamic_soml_train_num:SOML training number (int)
parm:           rtw_dynamic_soml_interval:SOML training interval (int)
parm:           rtw_dynamic_soml_period:SOML training period (int)
parm:           rtw_dynamic_soml_delay:SOML training delay (int)
parm:           rtw_en_napi:int
parm:           rtw_en_gro:int
parm:           rtw_iqk_fw_offload:int
parm:           rtw_ch_switch_offload:int