Project

General

Profile

Issue #2109

Make the internal WiFi work

Added by Denis 'GNUtoo' Carikli about 1 year ago. Updated 9 days ago.

Status:
New
Priority:
Normal
Category:
-
Target version:
Start date:
08/25/2020
Due date:
% Done:

0%

Estimated time:
Resolution:
Device:
Unknown
Grant:
Porting Replicant to Android 9 (NLnet Foundation)
Type of work:
Any programming languages (scripts, C, etc), C programming
#1

Updated by Denis 'GNUtoo' Carikli about 1 year ago

From #replicant:

23:41 <@sensiblemn> ChronoMonochrome said he got Wifi working https://github.com/CustomROMs/android_local_manifests_i9300/issues/1#issuecomment-678714702

#2

Updated by Denis 'GNUtoo' Carikli about 1 year ago

  • Grant set to Porting Replicant to Android 9 (NLnet Foundation)
#3

Updated by Denis 'GNUtoo' Carikli 11 months ago

  • Target version changed from Replicant 11.0 0001 to Replicant 11.0 0002
#4

Updated by Victor Shilin 6 months ago

Internal wifi worked in replicant 11 (no significant efforts were required to adapt it to Android 11 since it worked in Replicant 9 already):
https://github.com/Midas-Mainline/android_device_samsung_i9300/commit/376bca58403a3e187ec89e2217e782ce754bea22
https://github.com/Midas-Mainline/android_device_midas_common/commit/e65d0596187804c5b74f3e91eeba4c5f80c3600f

As Android 11 doesn't properly support kernel modules build, there is an ugly hack in the kernel without which the kernel will try to load the firmware before the system partition mounted:
https://github.com/Midas-Mainline/android_kernel_samsung_smdk4412/commit/e93cf91b073f44745f9e78307352bca6bddc11f7

#5

Updated by _I3^ RELATIVISM 6 months ago

  • Type of work Any programming languages (scripts, C, etc), C programming added
#6

Updated by Denis 'GNUtoo' Carikli 10 days ago

Thanks a lot,

I had the same issue that 56630895e967c78a4f7e45d869166b8418c96f6b fixes in MidasMainline (HACK: brcmfmac: defer initialization for firmware to load).

In Replicant 6 the WiFi module was loaded with insmod / modprobe anyway so it could avoid that but here we'd rather not do that as:
  • The way to build Linux in Replicant 11 doesn't support modules yet either. I half-backported the kernel build from LineageOS and I disabled the modules builds along the way to make the integration easier. Do you know a cleaner implementation (still without the modules building)?
  • It would be better not to load any modules right now as it would makes the images less generic. The downside of doing that it that the kernel images will use a bit more RAM.
  • Android is probably not meant to have modules autodetected and loaded like in GNU/Linux with udev / mdev / systemd.

So I tried to find a way to get something upstreamable, but it seems that late_initcall and late_initcall_sync don't wait for the rootfs to be mounted.

I digged more and I didn't find anything that would tell a driver to wait for the rootfs to be mounted as the code that does the mounts the rootfs (in init/main.c and init/do_mounts.c) doesn't signal it to the drivers.

We could still have userspace code trigger the driver probe again with a generic version of that code in the meantime:

echo 'mmc1:0001:2' > /sys/bus/sdio/drivers_probe

We could probably autodetect what to echo where somehow.

I then need to integrate the MidasMainline userspace changes into Replicant.

Also I tried to make usbip work to forward ath9k_htc cards for easy testing (including with multiple WiFi cards) but apparently enabling the modules required for usbip in the kernel configuration makes the device not expose adb anymore.

This is probably because we use a kernel approach to have ADB. We should probably move that to userspace setup scripts instead at some point.

Denis.

edit1: add question about kernel build implementation

#7

Updated by Denis 'GNUtoo' Carikli 10 days ago

I wrote:

We could still have userspace code trigger the driver probe again with a generic version of that code in the meantime:

It's probably a better idea to send a bugreport first than trying to workaround in userspace.

I'll try to reproduce with the lastest git revision and send a bugreport.

#8

Updated by Denis 'GNUtoo' Carikli 10 days ago

I've sent the question to the linux-wireless mailing list: https://marc.info/?l=linux-wireless&m=163097506203321&w=2

#9

Updated by Denis 'GNUtoo' Carikli 9 days ago

I wanted to use a stock and standard wpa_supplicant compatible WiFi HAL.

In frameworks/opt/net/wifi/libwifi_hal/Android.mk we have:

# Pick a vendor provided HAL implementation library.
# ============================================================
LIB_WIFI_HAL := libwifi-hal-fallback
VENDOR_LOCAL_SHARED_LIBRARIES :=
ifeq ($(BOARD_WLAN_DEVICE), bcmdhd)
  LIB_WIFI_HAL := libwifi-hal-bcm
  VENDOR_LOCAL_SHARED_LIBRARIES := libcrypto
else ifeq ($(BOARD_WLAN_DEVICE), qcwcn)
  LIB_WIFI_HAL := libwifi-hal-qcom
  VENDOR_LOCAL_SHARED_LIBRARIES := libcld80211
else ifeq ($(BOARD_WLAN_DEVICE), mrvl)
  # this is commented because none of the nexus devices
  # that sport Marvell's wifi have support for HAL
  # LIB_WIFI_HAL := libwifi-hal-mrvl
else ifeq ($(BOARD_WLAN_DEVICE), MediaTek)
  # support MTK WIFI HAL
  LIB_WIFI_HAL := libwifi-hal-mt66xx
else ifeq ($(BOARD_WLAN_DEVICE), realtek)
  # support Realtek WIFI HAL
  LIB_WIFI_HAL := libwifi-hal-rtk
else ifeq ($(BOARD_WLAN_DEVICE), emulator)
  LIB_WIFI_HAL := libwifi-hal-emu
endif

And:

include $(CLEAR_VARS)
LOCAL_MODULE := libwifi-hal-fallback
LOCAL_VENDOR_MODULE := true
LOCAL_CFLAGS := $(wifi_hal_cflags)
LOCAL_SRC_FILES := wifi_hal_fallback.cpp
LOCAL_HEADER_LIBRARIES := libhardware_legacy_headers
include $(BUILD_STATIC_LIBRARY)

So far that looks fine and we might think that we need to use the libwifi-hal fallback, however here it's full implementation (in wifi_hal_fallback.cpp in the same directory):

/*
 * Copyright 2016, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "hardware_legacy/wifi_hal.h" 

wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) {
  return WIFI_ERROR_NOT_SUPPORTED;
}

Also available in: Atom PDF