How To Resolve Wifi Driver Problem on Ubuntu 20.04 [duplicate]

I am encountering a problem while installing the wireless driver in my ubuntu 20.04 version also facing the same issue with (Ubuntu 18.04).

I have gone through rtl8822be wifi driver ubuntu 20.04 hp 15-da1009ne.

These are the steps which I am following:

git clone https://github.com/lwfinger/rtlwifi_new.git
cd rtlwifi_new
git checkout extended
sudo make install
sudo modprobe -r rtl8723de
sudo modprobe rtl8723de

But while executing the the sudo make install, I am getting this error:

make -C /lib/modules/5.4.0-28-generic/build M=/home/username/rtlwifi_new modules
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-28-generic'
  CC [M]  /home/username/rtlwifi_new/rc.o
/home/username/rtlwifi_new/rc.c:336:11: error: initialization of ‘void * (*)(struct ieee80211_hw *, struct dentry *)’ from incompatible pointer type ‘void * (*)(struct ieee80211_hw *)’ [-Werror=incompatible-pointer-types]
  336 |  .alloc = rtl_rate_alloc,
      |           ^~~~~~~~~~~~~~
/home/username/rtlwifi_new/rc.c:336:11: note: (near initialization for ‘rtl_rate_ops.alloc’)
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:275: /home/username/rtlwifi_new/rc.o] Error 1
make[1]: *** [Makefile:1719: /home/username/rtlwifi_new] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-28-generic'
make: *** [Makefile:85: all] Error 2

The output of lspci -knn | grep Net -A3; rfkill list:

08:00.0 Network controller [0280]: Broadcom Inc. and subsidiaries BCM43142 802.11b/g/n [14e4:4365] (rev 01)
    DeviceName: Broadcom BCM43142 802.11bgn 1x1 WiFi Adapter + BT 4.0 combo adapter
    Subsystem: Hewlett-Packard Company BCM43142 802.11b/g/n [103c:2230]
    Kernel driver in use: wl
0: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: brcmwl-0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
2: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no

Solution 1:

Something is wrong with that source in newer kernels, so use this instead

sudo apt install dkms
cd
git clone https://github.com/smlinux/rtl8723de.git
sudo dkms add ./rtl8723de
sudo dkms install rtl8723de/5.1.1.8_21285.20171026_COEX20170111-1414
Check mokutil --sb-state as Secure Boot needs to be disabled Reboot

Solution 2:

The following commands worked perfectly to get Broadcom BCM43142 working on ubuntu 20.04. You need to do each one.

sudo apt-get purge bcmwl-kernel-source
sudo apt-get install broadcom-sta-source
sudo apt-get install broadcom-sta-dkms
sudo apt-get install broadcom-sta-common