NetHubQuickBringup:修订间差异
小 Sync NetHub docs from local MediaWiki export 标签:手工回退 |
小 Sync NetHub docs from local Markdown |
||
| (未显示同一用户的2个中间版本) | |||
| 第1行: | 第1行: | ||
= NetHub | = NetHub Quick Start = | ||
This document is for customers who are using NetHub for the first time. The goal is to help you complete device and host bring-up as quickly as possible. | |||
[[文件:Nethub_sdio_quickstart_demo.gif | NetHub SDIO | [[文件:Nethub_sdio_quickstart_demo.gif | NetHub SDIO Quick Start Demo]] | ||
If you only care about the currently available solution, keep these points in mind: | |||
* | * The current primary path is <code>SDIO</code> | ||
* device | * The device runs <code>Wi-Fi backend (fhost / wl80211) + lwIP</code> | ||
* <code>nethub</code> | * <code>nethub</code> bridges device-side Wi-Fi capabilities to the host | ||
* | * The control channel and <code>USER virtual channel</code> both run on the same host link | ||
Active directories: | |||
* device | * device side | ||
** <code>components/net/nethub</code> | ** <code>components/net/nethub</code> | ||
** <code>examples/wifi/nethub</code> | ** <code>examples/wifi/nethub</code> | ||
* host | * host side | ||
** <code>bsp/common/msg_router/linux_host/kernel</code> | ** <code>bsp/common/msg_router/linux_host/kernel</code> | ||
** <code>bsp/common/msg_router/linux_host/userspace/nethub</code> | ** <code>bsp/common/msg_router/linux_host/userspace/nethub</code> | ||
== | == 1. Confirm Two Choices Before Bring-Up == | ||
=== | === 1.1 Choose the Wi-Fi Backend === | ||
Default configuration: | |||
* | * <code>CONFIG_WL80211</code> is disabled | ||
* | * <code>fhost</code> is used | ||
If you want to switch to <code>wl80211</code>, enable this option in <code>examples/wifi/nethub/defconfig</code>: | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="makefile"> | ||
CONFIG_WL80211=y | CONFIG_WL80211=y | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Notes: | |||
* <code>fhost</code> | * <code>fhost</code> and <code>wl80211</code> are mutually exclusive | ||
* | * The current <code>nethub</code> implementation supports both device-side Wi-Fi backends | ||
=== | === 1.2 Choose the Control Channel === | ||
device | device and host settings must match: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! device configuration !! host startup | |||
|- | |- | ||
| <code>CONFIG_NETHUB_AT_USE_VCHAN=y</code> | | <code>CONFIG_NETHUB_AT_USE_VCHAN=n</code> || <code>./output/bflbwifid</code> or <code>./output/bflbwifid -c tty -p /dev/ttyAT0</code> | ||
| <code>./output/bflbwifid -c vchan</code> | |- | ||
| <code>CONFIG_NETHUB_AT_USE_VCHAN=y</code> || <code>./output/bflbwifid -c vchan</code> | |||
|} | |} | ||
The default configuration is: | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="makefile"> | ||
CONFIG_NETHUB_AT_USE_VCHAN=n | CONFIG_NETHUB_AT_USE_VCHAN=n | ||
</syntaxhighlight> | </syntaxhighlight> | ||
That means the control channel uses <code>TTY</code> by default. | |||
Additional notes: | |||
* host | * The host side always builds both <code>tty + vchan</code> | ||
* | * The actual selection happens at <code>bflbwifid</code> runtime | ||
== | == 2. Build and Flash the Device Firmware == | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第84行: | 第82行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Flash example: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第91行: | 第89行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The most relevant bring-up configuration is located in: | |||
* <code>examples/wifi/nethub/defconfig</code> | |||
Common options: | |||
* <code>CONFIG_NETHUB=y</code> | * <code>CONFIG_NETHUB=y</code> | ||
| 第99行: | 第101行: | ||
* <code>CONFIG_NETHUB_AT_USE_VCHAN=n</code> | * <code>CONFIG_NETHUB_AT_USE_VCHAN=n</code> | ||
== | == 3. Build and Start the Host Software == | ||
=== | === 3.1 Build === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第108行: | 第110行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Artifacts: | |||
* <code>output/mr_sdio.ko</code> | * <code>output/mr_sdio.ko</code> | ||
| 第116行: | 第118行: | ||
* <code>output/nethub_vchan_app</code> | * <code>output/nethub_vchan_app</code> | ||
=== | === 3.2 Load the Kernel Module === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第123行: | 第125行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
To unload: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第129行: | 第131行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 3.3 Start the Host Daemon === | ||
Default TTY mode: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第137行: | 第139行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Explicit TTY mode: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第143行: | 第145行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
VCHAN | VCHAN mode: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第149行: | 第151行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == 4. Basic Verification Flow == | ||
Recommended sequence: | |||
=== | === 4.1 Check the Current Status === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第159行: | 第161行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 4.2 Scan APs === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第165行: | 第167行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 4.3 Connect to an AP === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第171行: | 第173行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 4.4 Check Status Again === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第177行: | 第179行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
If the connection succeeds, you will usually see: | |||
* backend | * the backend is connected | ||
* Wi-Fi | * the Wi-Fi state is <code>CONNECTED</code> or <code>GOTIP</code> | ||
* | * <code>IP / Gateway / Netmask / DNS</code> after an address is assigned | ||
=== | === 4.5 Disconnect === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 第189行: | 第191行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == 5. Common Commands == | ||
The public CLI surface is fixed to 9 commands: | |||
* <code>connect_ap</code> | * <code>connect_ap</code> | ||
| 第203行: | 第205行: | ||
* <code>stop_ap</code> | * <code>stop_ap</code> | ||
== | Examples: | ||
<syntaxhighlight lang="bash"> | |||
sudo ./output/bflbwifictrl version | |||
sudo ./output/bflbwifictrl reboot | |||
sudo ./output/bflbwifictrl start_ap "<ssid>" "<password>" | |||
sudo ./output/bflbwifictrl stop_ap | |||
</syntaxhighlight> | |||
== 6. SDIO Hardware Information == | |||
For the current customer bring-up path, use <code>SDIO</code> directly. <code>USB / SPI</code> still keep architecture skeletons for now and are not the recommended bring-up path. | |||
<code>USB / SPI</code> | |||
=== | === 6.1 Chip Support Matrix === | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| SDIO | ! Interface !! BL616 / BL618 !! BL618DG !! BL616CL | ||
| | |- | ||
| | | SDIO || Supported || Supported || Supported | ||
| | |||
|- | |- | ||
| USB | | USB || Planned || Planned || Planned | ||
| | |||
| | |||
| | |||
|- | |- | ||
| SPI | | SPI || Planned || Planned || Planned | ||
| | |||
| | |||
| | |||
|} | |} | ||
=== | === 6.2 SDIO Pins === | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| SDIO_DAT2 | ! Pin Function !! BL616 / BL618 !! BL618DG !! BL616CL | ||
| GPIO10 | |- | ||
| GPIO43 | | SDIO_DAT2 || GPIO10 || GPIO43 || GPIO6 | ||
| GPIO6 | |||
|- | |- | ||
| SDIO_DAT3 | | SDIO_DAT3 || GPIO11 || GPIO44 || GPIO7 | ||
| GPIO11 | |||
| GPIO44 | |||
| GPIO7 | |||
|- | |- | ||
| SDIO_CMD | | SDIO_CMD || GPIO12 || GPIO45 || GPIO8 | ||
| GPIO12 | |||
| GPIO45 | |||
| GPIO8 | |||
|- | |- | ||
| SDIO_CLK | | SDIO_CLK || GPIO13 || GPIO46 || GPIO9 | ||
| GPIO13 | |||
| GPIO46 | |||
| GPIO9 | |||
|- | |- | ||
| SDIO_DATA0 | | SDIO_DATA0 || GPIO14 || GPIO47 || GPIO10 | ||
| GPIO14 | |||
| GPIO47 | |||
| GPIO10 | |||
|- | |- | ||
| SDIO_DATA1 | | SDIO_DATA1 || GPIO15 || GPIO48 || GPIO11 | ||
| GPIO15 | |||
| GPIO48 | |||
| GPIO11 | |||
|} | |} | ||
== | == 7. USER Virtual Channel == | ||
If you need to transfer private messages between the host and device, use the <code>USER virtual channel</code>. | |||
Notes: | |||
* The <code>USER</code> channel and the control channel are parallel logical channels | |||
* It is not a separate physical interface; it is a logical channel carried on the current host link | |||
=== 7.1 device-side APIs === | |||
Header: | |||
* <code>components/net/nethub/include/nethub_vchan.h</code> | * <code>components/net/nethub/include/nethub_vchan.h</code> | ||
host | Common APIs: | ||
<syntaxhighlight lang="c"> | |||
int nethub_vchan_user_send(const void *data, uint16_t len); | |||
int nethub_vchan_user_recv_register(nethub_vchan_recv_cb_t recv_cb, void *cb_arg); | |||
</syntaxhighlight> | |||
=== 7.2 host-side APIs === | |||
Header: | |||
* <code>bsp/common/msg_router/linux_host/userspace/nethub/virtualchan/nethub_vchan.h</code> | * <code>bsp/common/msg_router/linux_host/userspace/nethub/virtualchan/nethub_vchan.h</code> | ||
Common APIs: | |||
<syntaxhighlight lang="c"> | |||
int nethub_vchan_init(void); | |||
int nethub_vchan_deinit(void); | |||
int nethub_vchan_user_send(const void *data, size_t len); | |||
int nethub_vchan_user_register_callback(nethub_vchan_recv_callback_t callback); | |||
int nethub_vchan_get_state_snapshot(nethub_vchan_state_snapshot_t *snapshot); | |||
</syntaxhighlight> | |||
Typical host-side usage order: | |||
# <code>nethub_vchan_init()</code> | |||
# <code>nethub_vchan_user_register_callback()</code> | |||
# <code>nethub_vchan_user_send()</code> | |||
# Call <code>nethub_vchan_deinit()</code> when finished | |||
If you need to check whether the link is ready, you can optionally query: | |||
* <code>link_state == NETHUB_VCHAN_LINK_UP</code> | |||
** the link is ready for TX/RX | |||
* <code>host_state == NETHUB_VCHAN_HOST_STATE_DEVICE_RUN</code> | |||
** the host has completed the handshake with the device | |||
== 8. Common Issues == | |||
== | === 8.1 <code>bflbwifid</code> Fails to Start === | ||
Check first: | |||
* whether the device and host control backends match | |||
* whether <code>/dev/ttyAT0</code> exists | |||
* whether <code>mr_sdio.ko</code> has been loaded successfully | |||
* whether the SDIO hardware link is working properly | |||
=== 8.2 <code>connect_ap</code> Succeeds but the Host Has No Network Access === | |||
Check first: | |||
* whether <code>status</code> has reached <code>GOTIP</code> | |||
* whether <code>mr_eth0</code> has an address | |||
* whether services such as <code>NetworkManager</code> or <code>dhcpcd</code> override the NetHub configuration | |||
Notes: | |||
* <code>build.sh</code> builds userspace with <code>ENABLE_NETIF_AUTO_CONFIG=1</code> by default | |||
* After the device reports <code>GOTIP</code>, the host automatically configures the IP, gateway, and DNS of <code>mr_eth0</code> | |||
=== 8.3 <code>build.sh unload</code> Reports That the Module Is Busy === | |||
Check first: | |||
* whether <code>bflbwifid</code> is still running | |||
* whether <code>nethub_vchan_app</code> is still running | |||
=== 8.4 How Do I Change the Host-Side Virtual Interface Name <code>mr_eth0</code>? === | |||
The default host-side virtual network interface name comes from <code>bsp/common/msg_router/linux_host/kernel/netdev/mr_netdev.c</code>: | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="c"> | ||
#define ETH_DRV_NAME "mr_eth%d" | |||
</syntaxhighlight> | </syntaxhighlight> | ||
The first created interface therefore appears as <code>mr_eth0</code>. | |||
To change the interface name, update <code>ETH_DRV_NAME</code> to the pattern you want. For example: | |||
<syntaxhighlight lang="c"> | |||
#define ETH_DRV_NAME "nethub%d" | |||
</syntaxhighlight> | |||
Notes: | |||
* | * Keep <code>%d</code> if you want Linux to allocate names such as <code>nethub0</code>, <code>nethub1</code>, and so on | ||
* | * Rebuild the host software after the change and reload the host-side kernel module | ||
* If any local scripts or service configuration still refer to <code>mr_eth0</code>, update them accordingly | |||
2026年3月31日 (二) 00:14的最新版本
NetHub Quick Start
This document is for customers who are using NetHub for the first time. The goal is to help you complete device and host bring-up as quickly as possible.
If you only care about the currently available solution, keep these points in mind:
- The current primary path is
SDIO - The device runs
Wi-Fi backend (fhost / wl80211) + lwIP nethubbridges device-side Wi-Fi capabilities to the host- The control channel and
USER virtual channelboth run on the same host link
Active directories:
- device side
components/net/nethubexamples/wifi/nethub
- host side
bsp/common/msg_router/linux_host/kernelbsp/common/msg_router/linux_host/userspace/nethub
1. Confirm Two Choices Before Bring-Up
1.1 Choose the Wi-Fi Backend
Default configuration:
CONFIG_WL80211is disabledfhostis used
If you want to switch to wl80211, enable this option in examples/wifi/nethub/defconfig:
CONFIG_WL80211=y
Notes:
fhostandwl80211are mutually exclusive- The current
nethubimplementation supports both device-side Wi-Fi backends
1.2 Choose the Control Channel
device and host settings must match:
| device configuration | host startup |
|---|---|
CONFIG_NETHUB_AT_USE_VCHAN=n |
./output/bflbwifid or ./output/bflbwifid -c tty -p /dev/ttyAT0
|
CONFIG_NETHUB_AT_USE_VCHAN=y |
./output/bflbwifid -c vchan
|
The default configuration is:
CONFIG_NETHUB_AT_USE_VCHAN=n
That means the control channel uses TTY by default.
Additional notes:
- The host side always builds both
tty + vchan - The actual selection happens at
bflbwifidruntime
2. Build and Flash the Device Firmware
cd examples/wifi/nethub
# BL616
make CHIP=bl616 BOARD=bl616dk
# BL616CL
make CHIP=bl616cl BOARD=bl616cldk
# BL618DG
make CHIP=bl618dg BOARD=bl618dgdk CPU_ID=ap
Flash example:
cd examples/wifi/nethub
make flash CHIP=bl618dg COMX=/dev/ttyUSB0
The most relevant bring-up configuration is located in:
examples/wifi/nethub/defconfig
Common options:
CONFIG_NETHUB=yCONFIG_MR_NETDEV=yCONFIG_MR_TTY=yCONFIG_MR_VIRTUALCHAN=yCONFIG_NETHUB_AT_USE_VCHAN=n
3. Build and Start the Host Software
3.1 Build
cd bsp/common/msg_router/linux_host/userspace/nethub
./build.sh build
Artifacts:
output/mr_sdio.kooutput/bflbwifidoutput/bflbwifictrloutput/libnethub_vchan.aoutput/nethub_vchan_app
3.2 Load the Kernel Module
cd bsp/common/msg_router/linux_host/userspace/nethub
sudo ./build.sh load
To unload:
sudo ./build.sh unload
3.3 Start the Host Daemon
Default TTY mode:
sudo ./output/bflbwifid
Explicit TTY mode:
sudo ./output/bflbwifid -c tty -p /dev/ttyAT0
VCHAN mode:
sudo ./output/bflbwifid -c vchan
4. Basic Verification Flow
Recommended sequence:
4.1 Check the Current Status
sudo ./output/bflbwifictrl status
4.2 Scan APs
sudo ./output/bflbwifictrl scan
4.3 Connect to an AP
sudo ./output/bflbwifictrl connect_ap "<ssid>" "<password>"
4.4 Check Status Again
sudo ./output/bflbwifictrl status
If the connection succeeds, you will usually see:
- the backend is connected
- the Wi-Fi state is
CONNECTEDorGOTIP IP / Gateway / Netmask / DNSafter an address is assigned
4.5 Disconnect
sudo ./output/bflbwifictrl disconnect
5. Common Commands
The public CLI surface is fixed to 9 commands:
connect_apdisconnectscanstatusversionreboototastart_apstop_ap
Examples:
sudo ./output/bflbwifictrl version
sudo ./output/bflbwifictrl reboot
sudo ./output/bflbwifictrl start_ap "<ssid>" "<password>"
sudo ./output/bflbwifictrl stop_ap
6. SDIO Hardware Information
For the current customer bring-up path, use SDIO directly. USB / SPI still keep architecture skeletons for now and are not the recommended bring-up path.
6.1 Chip Support Matrix
| Interface | BL616 / BL618 | BL618DG | BL616CL |
|---|---|---|---|
| SDIO | Supported | Supported | Supported |
| USB | Planned | Planned | Planned |
| SPI | Planned | Planned | Planned |
6.2 SDIO Pins
| Pin Function | BL616 / BL618 | BL618DG | BL616CL |
|---|---|---|---|
| SDIO_DAT2 | GPIO10 | GPIO43 | GPIO6 |
| SDIO_DAT3 | GPIO11 | GPIO44 | GPIO7 |
| SDIO_CMD | GPIO12 | GPIO45 | GPIO8 |
| SDIO_CLK | GPIO13 | GPIO46 | GPIO9 |
| SDIO_DATA0 | GPIO14 | GPIO47 | GPIO10 |
| SDIO_DATA1 | GPIO15 | GPIO48 | GPIO11 |
7. USER Virtual Channel
If you need to transfer private messages between the host and device, use the USER virtual channel.
Notes:
- The
USERchannel and the control channel are parallel logical channels - It is not a separate physical interface; it is a logical channel carried on the current host link
7.1 device-side APIs
Header:
components/net/nethub/include/nethub_vchan.h
Common APIs:
int nethub_vchan_user_send(const void *data, uint16_t len);
int nethub_vchan_user_recv_register(nethub_vchan_recv_cb_t recv_cb, void *cb_arg);
7.2 host-side APIs
Header:
bsp/common/msg_router/linux_host/userspace/nethub/virtualchan/nethub_vchan.h
Common APIs:
int nethub_vchan_init(void);
int nethub_vchan_deinit(void);
int nethub_vchan_user_send(const void *data, size_t len);
int nethub_vchan_user_register_callback(nethub_vchan_recv_callback_t callback);
int nethub_vchan_get_state_snapshot(nethub_vchan_state_snapshot_t *snapshot);
Typical host-side usage order:
nethub_vchan_init()nethub_vchan_user_register_callback()nethub_vchan_user_send()- Call
nethub_vchan_deinit()when finished
If you need to check whether the link is ready, you can optionally query:
link_state == NETHUB_VCHAN_LINK_UP- the link is ready for TX/RX
host_state == NETHUB_VCHAN_HOST_STATE_DEVICE_RUN- the host has completed the handshake with the device
8. Common Issues
8.1 bflbwifid Fails to Start
Check first:
- whether the device and host control backends match
- whether
/dev/ttyAT0exists - whether
mr_sdio.kohas been loaded successfully - whether the SDIO hardware link is working properly
8.2 connect_ap Succeeds but the Host Has No Network Access
Check first:
- whether
statushas reachedGOTIP - whether
mr_eth0has an address - whether services such as
NetworkManagerordhcpcdoverride the NetHub configuration
Notes:
build.shbuilds userspace withENABLE_NETIF_AUTO_CONFIG=1by default- After the device reports
GOTIP, the host automatically configures the IP, gateway, and DNS ofmr_eth0
8.3 build.sh unload Reports That the Module Is Busy
Check first:
- whether
bflbwifidis still running - whether
nethub_vchan_appis still running
8.4 How Do I Change the Host-Side Virtual Interface Name mr_eth0?
The default host-side virtual network interface name comes from bsp/common/msg_router/linux_host/kernel/netdev/mr_netdev.c:
#define ETH_DRV_NAME "mr_eth%d"
The first created interface therefore appears as mr_eth0.
To change the interface name, update ETH_DRV_NAME to the pattern you want. For example:
#define ETH_DRV_NAME "nethub%d"
Notes:
- Keep
%dif you want Linux to allocate names such asnethub0,nethub1, and so on - Rebuild the host software after the change and reload the host-side kernel module
- If any local scripts or service configuration still refer to
mr_eth0, update them accordingly
