[WP7609] How to customize the firmware for modified HW

Hi @jyijyi, I am helping @allent with this issue…
So basically, this is our current situation.
We updated our custom board to use the very same pins the mangoh green devkit uses to control the TI WiFi module WL18.

  • WLAN_EN is connected to GPIO8 (IOT0_GPIO4).
  • /etc/init.d/tiwifi was modified to bypass the IOEXPANDERS (our hardware does not have chip select, etc)
  • The yocto image was modified to generate 1.8V instead of 3.3V, as we don’t have the stepdown the devkit has.

But when we try to run wifi ap start, we get the following:

    Jan  6 01:14:59 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1005]/framework T=main | LE_FILENAME ExtractFileDescriptor() 34 | Received fd (11).
    Jan  6 01:14:59 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1005]/framework T=main | LE_FILENAME ExtractFileDescriptor() 34 | Received fd (12).
    Jan  6 01:14:59 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1005]/daemon T=main | pa_wifi_ap_ti.c pa_wifiAp_Start() 469 | Starting AP, SSID: wifiAPssid
    Jan  6 01:14:59 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1005]/framework T=main | LE_FILENAME le_mem_ForceAlloc() 841 | Memory pool 'framework.DestructorObjs' overflowed. Expanded to 2 blocks.
    Jan  6 01:14:59 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1005]/framework T=WifiApPaThread | LE_FILENAME PThreadStartRoutine() 365 | Set nice level to 0.
    Jan  6 01:14:59 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1005]/framework T=WifiApPaThread | LE_FILENAME le_mem_ForceAlloc() 841 | Memory pool 'framework.DestructorObjs' overflowed. Expanded to 3 blocks.
    Jan  6 01:14:59 swi-mdm9x28-wp user.info Legato:  INFO | wifiService[1005]/daemon T=WifiApPaThread | pa_wifi_ap_ti.c WifiApPaThreadMain() 243 | Started!
    Jan  6 01:14:59 swi-mdm9x28-wp user.info Legato:  INFO | wifiService[1005]/daemon T=WifiApPaThread | pa_wifi_ap_ti.c WifiApPaThreadMain() 260 | PARSING:WIFI_SET_EVENT : len:15
    Jan  6 01:14:59 swi-mdm9x28-wp user.info Legato:  INFO | wifiService[1005] | WIFI_START
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319480] cfg80211: Calling CRDA to update world regulatory domain
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319599] cfg80211: World regulatory domain updated:
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319611] cfg80211:  DFS Master region: unset
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319621] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319634] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319645] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319656] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319667] cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319678] cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319689] cfg80211:   (5490000 KHz - 5710000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319700] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
    Jan  6 01:14:59 swi-mdm9x28-wp user.info kernel: [  420.319711] cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
    Jan  6 01:15:01 swi-mdm9x28-wp cron.info crond[1340]: (*system*) RELOAD (/etc/crontab)
    Jan  6 01:15:05 swi-mdm9x28-wp user.info Legato:  INFO | wifiService[1005] | Failed to start TI wifi1
    Jan  6 01:15:05 swi-mdm9x28-wp user.err Legato: =ERR= | wifiService[1005]/daemon T=main | pa_wifi_ap_ti.c pa_wifiAp_Start() 484 | WiFi AP Command Failed: (23296)wlan0 WIFI_START
    Jan  6 01:15:05 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[840]/supervisor T=main | supervisor.c SigChildHandler() 784 | Reaping unconfigured child process 2374.
    Jan  6 01:15:05 swi-mdm9x28-wp user.err Legato: =ERR= | wifiService[1005]/daemon T=WifiApPaThread | pa_wifi_ap_ti.c ThreadDestructor() 192 | Unable to kill the WIFI events script
    Jan  6 01:15:05 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1005]/framework T=main | le_wifiAp_server.c CleanupClientData() 148 | Client 0x7f57d7ec is closed !!!
    Jan  6 01:15:05 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1005]/daemon T=main | le_wifiClient.c CloseSessionEventHandler() 478 | sessionRef 0x7f57d75c GetFirstSessionRef (nil)
    Jan  6 01:15:05 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1005]/framework T=main | le_wifiClient_server.c CleanupClientData() 148 | Client 0x7f57d75c is closed !!!

So in a nutshell, /etc/init.d/tiwifi loads these 3 kernel objects
modprobe wlcore
modprobe wlcore_sdio
modprobe wl18xx
Waits 5 seconds, looks for WLAN0 interface and throws error “Failed to start TI wifi1” because the interface is not found…
The thing is… We are probing WLAN_EN and the driver is not even trying to pull it high when “wifi ap start” is issued.

We then tried to manually set WLAN_EN high, which indeed causes the pin to be set high, but leads to the following:

[...]
    Jan  6 01:57:04 swi-mdm9x28-wp user.info kernel: [  612.881799] cfg80211:   (5490000 KHz - 5710000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
    Jan  6 01:57:04 swi-mdm9x28-wp user.info kernel: [  612.881810] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
    Jan  6 01:57:04 swi-mdm9x28-wp user.info kernel: [  612.881822] cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
    Jan  6 01:57:04 swi-mdm9x28-wp user.debug kernel: [  612.910683] gpio_sync_ri: RI owner is Modem
    Jan  6 01:57:04 swi-mdm9x28-wp user.debug kernel: [  612.910709] gpio_map_name_to_num: find GPIO 58
    Jan  6 01:57:04 swi-mdm9x28-wp user.debug kernel: [  612.910720] export_store: Export GPIO: 58
    Jan  6 01:57:04 swi-mdm9x28-wp user.debug kernel: [  612.910747] gpio_sync_ri: RI owner is Modem
    Jan  6 01:57:04 swi-mdm9x28-wp user.debug kernel: [  612.910762] gpiod_export: sierra--find GPIO,chipdev = -824019952,chipngpio = 80,chipbase = 0
    Jan  6 01:57:04 swi-mdm9x28-wp user.warn kernel: [  613.804345] sdhci_msm 7864900.sdhci: card claims to support voltages below defined range
    Jan  6 01:57:04 swi-mdm9x28-wp user.warn kernel: [  613.864325] mmc0: queuing unknown CIS tuple 0x91 (3 bytes)
    Jan  6 01:57:04 swi-mdm9x28-wp user.info kernel: [  613.867344] mmc0: new high speed SDIO card at address 0001
    Jan  6 01:57:05 swi-mdm9x28-wp user.debug kernel: [  614.033770] gpio-58 (sysfs): gpiod_request: status -16
    Jan  6 01:57:05 swi-mdm9x28-wp user.err kernel: [  614.033794] wlcore: ERROR cannot assign WLAN_EN GPIO58.
    Jan  6 01:57:05 swi-mdm9x28-wp user.err kernel: [  614.033794]
    Jan  6 01:57:05 swi-mdm9x28-wp user.warn kernel: [  614.050497] wl18xx_driver: probe of wl18xx.0.auto failed with error -16
    Jan  6 01:57:09 swi-mdm9x28-wp user.info Legato:  INFO | wifiService[1002] | Failed to start TI wifi1
    Jan  6 01:57:09 swi-mdm9x28-wp user.err Legato: =ERR= | wifiService[1002]/daemon T=main | pa_wifi_ap_ti.c pa_wifiAp_Start() 484 | WiFi AP Command Failed: (23296)wlan0 WIFI_START
    Jan  6 01:57:09 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[838]/supervisor T=main | supervisor.c SigChildHandler() 784 | Reaping unconfigured child process 2910.
    Jan  6 01:57:09 swi-mdm9x28-wp user.err Legato: =ERR= | wifiService[1002]/daemon T=WifiApPaThread | pa_wifi_ap_ti.c ThreadDestructor() 192 | Unable to kill the WIFI events script
    Jan  6 01:57:09 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1002]/framework T=main | le_wifiAp_server.c CleanupClientData() 148 | Client 0x7f57d7ec is closed !!!
    Jan  6 01:57:09 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1002]/daemon T=main | le_wifiClient.c CloseSessionEventHandler() 478 | sessionRef 0x7f57d75c GetFirstSessionRef (nil)
    Jan  6 01:57:09 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[1002]/framework T=main | le_wifiClient_server.c CleanupClientData() 148 | Client 0x7f57d75c is closed !!!

Which means the driver is indeed trying to take control of GPIO8 (IOT0_GPIO4, exported as GPIO: 58), and it complains if we drive it high manually.
But at the same time, if not set manually… It is never driven high by the driver.

Do you know what could be causing this?

Thanks in advance,

Here says the wlcore driver will take control of GPIO8:

Also have you checked the voltage of SDIO pin and see if it is really operating in 1.8V?
This thread shows someone modifying the yocto image to change the voltage to be 1.8V:

Currently I am using Mangoh red board for testing the WIFI IOT card, it works fine for me.
I saw in the tiwifi script, it will do the following:
echo “mangOH red board”

           # Set IOT0_GPIO2 = 1 (WP GPIO13)
           [ -d /sys/class/gpio/gpio13 ] || echo 13 >/sys/class/gpio/export
           echo out >/sys/class/gpio/gpio13/direction
           echo 1 >/sys/class/gpio/gpio13/value

           # Set IOT0_RESET = 1 (WP GPIO2)
           [ -d /sys/class/gpio/gpio2 ] || echo 2 >/sys/class/gpio/export
           echo out >/sys/class/gpio/gpio2/direction
           echo 1 >/sys/class/gpio/gpio2/value

           # Clear SDIO_SEL, GPIO#9/EXPANDER#1 - Select the SDIO
           gpioexp 1 9 output normal low >/dev/null || exit 127

so you can double check if it has the same state as your custom board.