Module kobo

Module kobo 

Source
Expand description

WiFi management for Kobo devices.

This module provides native WiFi lifecycle management, replacing the previous shell script-based implementation at scripts/wifi-enable.sh and scripts/wifi-disable.sh.

§Architecture

The implementation follows the same patterns as KOReader, with some key differences documented below.

§Power Toggle Strategies

Different Kobo devices use different mechanisms to power the WiFi chip:

  • Module: Insmod sdio_wifi_pwr.ko - most older devices
  • NtxIo: ioctl on /dev/ntx_io with command 208 - devices with moal module
  • Wmt: WMT character device - devices with wlan_drv_gen4m module

§Module Path Resolution

The module path depends on the WiFi module type:

  • Default: /drivers/{PLATFORM}/wifi/
  • wlan_drv_gen4m: /drivers/{PLATFORM}/mt66xx/

§Why No DHCP Client?

This implementation does NOT run a DHCP client.

The rationale is:

  1. Nickel’s dhcpcd persists: When Cadmus starts, it does NOT kill Nickel’s dhcpcd -d -z wlan0 daemon. This daemon continuously manages the DHCP lease and writes lease files to /var/db/ on eMMC, which persists across reboots.
  2. Lease stability: When reconnecting, dhcpcd reads the matching lease file and requests the same IP (DHCP Option 50), avoiding the DHCP server handing out a different address.
  3. Avoid udhcpc pitfalls: The original shell script used udhcpc -q which exits after obtaining a lease with no persistence mechanism, causing a new IP on every toggle.
  4. wpa_supplicant handles 802.11 connectivity: Network configuration is managed by the platform’s dhcpcd.

§Features Copied from KOReader

The following improvements were adopted from KOReader’s implementation:

  1. No DHCP client: KOReader omits udhcpc when possible.
  2. Module loading: Uses insmod_asneeded() helper that checks /proc/modules before loading to avoid duplicate module loads
  3. 250ms delay after insmod: Matches KOReader’s timing for module stabilization
  4. File descriptor cleanup: Not implemented (KOReader closes non-standard fds before WiFi operations to avoid issues with USBMS)

§Country Code Handling

Regulatory domain is read from /mnt/onboard/.kobo/Kobo/Kobo eReader.conf under the WifiRegulatoryDomain key. The code parameter is passed to the kernel module as:

  • 8821cs: rtw_country_code=XX
  • moal: reg_alpha2=XX

§Moal-Specific Module Parameters

The moal module (NXP/Marvell 88W8987) additionally requires:

  • mod_para=nxp/wifi_mod_para_sd8987.conf
  • Loading mlan.ko dependency before the main module

Modules§

types 🔒
WiFi types for Kobo devices.

Structs§

KoboWifiManager

Constants§

CONFIG_PATH 🔒
DRIVERS_DIR 🔒
NTX_IO_PATH 🔒
NTX_IO_WIFI_CTRL 🔒
WIFI_POST_DOWN_SCRIPT 🔒
WIFI_POST_UP_SCRIPT 🔒
WIFI_PRE_DOWN_SCRIPT 🔒
WIFI_PRE_UP_SCRIPT 🔒
WMT_WIFI_PATH 🔒
WPA_SUPPLICANT_CONF 🔒
WPA_SUPPLICANT_SOCKET 🔒

Functions§

create_wifi_manager
Creates a WiFi manager for the current platform.
is_interface_up 🔒
is_module_loaded 🔒
set_ntx_io_wifi_ctrl