mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
arch/arm/ameba: register wlan0 synchronously for boot WiFi auto-connect
rtl8720f_wifi_initialize() spawned a kthread to run the blocking WHC host bring-up and register wlan0, so the netdev appeared only after netinit had already run its one-shot associate -- the WiFi never auto-connected at boot. Do the bring-up synchronously on the board bring-up path (mirroring rtl8721dx_wifi_initialize) so wlan0 exists before netinit runs. Enable the standard netinit auto-connect machinery in both board defconfigs: NETINIT_THREAD (runs associate + DHCP off the NSH init path so the prompt is not blocked), NETINIT_DHCPC, and placeholder NETINIT_WAPI_SSID/PASSPHRASE the user replaces with their own credentials (WIRELESS_WAPI + the wapi cmdtool are already enabled). Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
This commit is contained in:
parent
ac675ec653
commit
a60ac789a4
4 changed files with 64 additions and 80 deletions
|
|
@ -67,38 +67,6 @@
|
|||
|
||||
extern int ameba_wifi_start(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ameba_wifi_start_task
|
||||
*
|
||||
* Description:
|
||||
* Task entry running the blocking WHC host bring-up once the scheduler and
|
||||
* IPC are up.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int ameba_wifi_start_task(int argc, char *argv[])
|
||||
{
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
||||
/* Power on the WHC host stack (blocks on the NP round-trip), then register
|
||||
* the wlan0 network device.
|
||||
*/
|
||||
|
||||
int ret = ameba_wifi_start();
|
||||
|
||||
syslog(LOG_INFO, "[ameba-wifi] ameba_wifi_start -> %d\n", ret);
|
||||
if (ret == 0)
|
||||
{
|
||||
#ifdef CONFIG_NET
|
||||
ret = ameba_wlan_initialize();
|
||||
syslog(LOG_INFO, "[ameba-wifi] ameba_wlan_initialize -> %d\n", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -107,17 +75,25 @@ static int ameba_wifi_start_task(int argc, char *argv[])
|
|||
* Name: rtl8720f_wifi_initialize
|
||||
*
|
||||
* Description:
|
||||
* Bring up the KM4 IPC transport for WiFi and start the WHC host stack.
|
||||
* Call from board bring-up after the scheduler is running.
|
||||
* Bring up the km4tz IPC transport for WiFi, start the WHC host stack and
|
||||
* register the wlan0 network device. Call from board bring-up after the
|
||||
* scheduler is running.
|
||||
*
|
||||
* Done synchronously (no worker task) so that wlan0 is registered before
|
||||
* the network initialisation (netinit) runs -- the standard NuttX flow
|
||||
* where the WiFi netdev already exists when board bring-up returns, so
|
||||
* netinit can associate + DHCP automatically. wifi_on() blocks on the NP
|
||||
* IPC round-trip; the NP is already running and IPC is initialised just
|
||||
* above, so the wait is bounded.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success; a negated errno on failure to spawn the bring-up task.
|
||||
* 0 on success; a negated errno on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int rtl8720f_wifi_initialize(void)
|
||||
{
|
||||
int pid;
|
||||
int ret;
|
||||
|
||||
/* Route the km4tz IPC interrupt to the SDK dispatcher and register every
|
||||
* channel the linked objects contributed (WHC WiFi TRX channels included).
|
||||
|
|
@ -126,9 +102,21 @@ int rtl8720f_wifi_initialize(void)
|
|||
|
||||
ameba_ipc_initialize();
|
||||
|
||||
/* wifi_on() blocks on the NP round-trip, so run it off the init path. */
|
||||
/* Power on the WHC host stack (blocks on the NP round-trip). */
|
||||
|
||||
pid = kthread_create("ameba_wifi", SCHED_PRIORITY_DEFAULT, 8192,
|
||||
ameba_wifi_start_task, NULL);
|
||||
return pid < 0 ? pid : 0;
|
||||
ret = ameba_wifi_start();
|
||||
syslog(LOG_INFO, "[ameba-wifi] ameba_wifi_start -> %d\n", ret);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
/* Register wlan0 before returning so netinit sees it at bring-up. */
|
||||
|
||||
ret = ameba_wlan_initialize();
|
||||
syslog(LOG_INFO, "[ameba-wifi] ameba_wlan_initialize -> %d\n", ret);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,38 +102,6 @@ static int ameba_ipc_interrupt(int irq, void *context, void *arg)
|
|||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ameba_wifi_start_task
|
||||
*
|
||||
* Description:
|
||||
* Task entry running the blocking WHC host bring-up once the scheduler and
|
||||
* IPC are up.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int ameba_wifi_start_task(int argc, char *argv[])
|
||||
{
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
||||
/* Power on the WHC host stack (blocks on the NP round-trip), then register
|
||||
* the wlan0 network device.
|
||||
*/
|
||||
|
||||
int ret = ameba_wifi_start();
|
||||
|
||||
syslog(LOG_INFO, "[ameba-wifi] ameba_wifi_start -> %d\n", ret);
|
||||
if (ret == 0)
|
||||
{
|
||||
#ifdef CONFIG_NET
|
||||
ret = ameba_wlan_initialize();
|
||||
syslog(LOG_INFO, "[ameba-wifi] ameba_wlan_initialize -> %d\n", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -142,17 +110,25 @@ static int ameba_wifi_start_task(int argc, char *argv[])
|
|||
* Name: rtl8721dx_wifi_initialize
|
||||
*
|
||||
* Description:
|
||||
* Bring up the KM4 IPC transport for WiFi and start the WHC host stack.
|
||||
* Call from board bring-up after the scheduler is running.
|
||||
* Bring up the KM4 IPC transport for WiFi, start the WHC host stack and
|
||||
* register the wlan0 network device. Call from board bring-up after the
|
||||
* scheduler is running.
|
||||
*
|
||||
* Done synchronously (no worker task) so that wlan0 is registered before
|
||||
* the network initialisation (netinit) runs -- the standard NuttX flow
|
||||
* where the WiFi netdev already exists when board bring-up returns, so
|
||||
* netinit can associate + DHCP automatically. wifi_on() blocks on the NP
|
||||
* IPC round-trip; the NP is already running and IPC is initialised just
|
||||
* above, so the wait is bounded.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success; a negated errno on failure to spawn the bring-up task.
|
||||
* 0 on success; a negated errno on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int rtl8721dx_wifi_initialize(void)
|
||||
{
|
||||
int pid;
|
||||
int ret;
|
||||
|
||||
/* Route the KM4 IPC interrupt to the SDK dispatcher and register every
|
||||
* channel the linked objects contributed (WHC WiFi TRX channels included).
|
||||
|
|
@ -162,9 +138,21 @@ int rtl8721dx_wifi_initialize(void)
|
|||
up_enable_irq(RTL8721DX_IRQ_IPC_KM4);
|
||||
ipc_table_init(IPCKM4_DEV);
|
||||
|
||||
/* wifi_on() blocks on the NP round-trip, so run it off the init path. */
|
||||
/* Power on the WHC host stack (blocks on the NP round-trip). */
|
||||
|
||||
pid = kthread_create("ameba_wifi", SCHED_PRIORITY_DEFAULT, 8192,
|
||||
ameba_wifi_start_task, NULL);
|
||||
return pid < 0 ? pid : 0;
|
||||
ret = ameba_wifi_start();
|
||||
syslog(LOG_INFO, "[ameba-wifi] ameba_wifi_start -> %d\n", ret);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
/* Register wlan0 before returning so netinit sees it at bring-up. */
|
||||
|
||||
ret = ameba_wlan_initialize();
|
||||
syslog(LOG_INFO, "[ameba-wifi] ameba_wlan_initialize -> %d\n", ret);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ CONFIG_NET=y
|
|||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_WIRELESS_IOCTL=y
|
||||
CONFIG_NETINIT_DHCPC=y
|
||||
CONFIG_NETINIT_THREAD=y
|
||||
CONFIG_NETINIT_WAPI_PASSPHRASE="YOUR_WIFI_PASSWORD"
|
||||
CONFIG_NETINIT_WAPI_SSID="YOUR_WIFI_SSID"
|
||||
CONFIG_NETUTILS_DHCPD=y
|
||||
CONFIG_NETUTILS_DHCPD_ROUTERIP=0xc0a80401
|
||||
CONFIG_NETUTILS_DHCPD_STARTIP=0xc0a80402
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ CONFIG_NET=y
|
|||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_WIRELESS_IOCTL=y
|
||||
CONFIG_NETINIT_DHCPC=y
|
||||
CONFIG_NETINIT_THREAD=y
|
||||
CONFIG_NETINIT_WAPI_PASSPHRASE="YOUR_WIFI_PASSWORD"
|
||||
CONFIG_NETINIT_WAPI_SSID="YOUR_WIFI_SSID"
|
||||
CONFIG_NETUTILS_DHCPD=y
|
||||
CONFIG_NETUTILS_DHCPD_ROUTERIP=0xc0a80401
|
||||
CONFIG_NETUTILS_DHCPD_STARTIP=0xc0a80402
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue