| # Intel Wifi driver |
| |
| This repository contains the source code to build, package and run the Intel |
| Wifi driver for Fuchsia using the Fuchsia Bazel SDK. |
| |
| The prebuilts of this driver is uploaded to CIPD at this location. |
| ``` |
| https://chrome-infra-packages.appspot.com/p/fuchsia/drivers/wlan/intel/iwlwifi |
| ``` |
| |
| ## 1. Pre-requisites |
| |
| * A gLinux machine to build the driver. |
| * Building and compiling on a gMac is not yet supported. |
| * A NUC7 or NUC11 for running the driver. |
| |
| ## 2. Prepare your environment |
| |
| ### 2.1 Onetime repo setup |
| |
| 1. Clone the Intel Wi-Fi Driver |
| |
| ``` |
| git clone https://fuchsia.googlesource.com/drivers/wlan/intel/iwlwifi --recurse-submodules |
| ``` |
| |
| 2. Go to the cloned directory |
| ``` |
| cd iwlwifi |
| ``` |
| |
| 3. Run the bootstrap script to install Bazel and other required deps. |
| ``` |
| scripts/bootstrap.sh |
| ``` |
| |
| ### 2.2 Preparing the NUC |
| |
| To prepare your development environment using NUC hardware, please follow the instruction in the below doc. |
| |
| https://docs.google.com/document/d/1w4nEroDYQZ37xTUMlw-nM4F4URF3IvSWbmtcuSxBvus/edit#heading=h.tkg2hhv2medi |
| |
| |
| ## 3. Building the driver |
| |
| Once you have setup your environment, the Intel driver can be built using the following command. |
| ``` |
| ./tools/bazel build third_party/iwlwifi/platform:iwlwifi_pkg |
| ``` |
| |
| When finished successfully, it prints output logs similar to what's shown below: |
| ``` |
| $ ./tools/bazel build third_party/iwlwifi/platform:iwlwifi_pkg |
| ... |
| INFO: Elapsed time: 0.464s, Critical Path: 0.11s |
| INFO: 11 processes: 11 internal. |
| INFO: Build completed successfully, 11 total actions |
| ``` |
| |
| ## 4. Loading the driver on to a device |
| |
| 1. If the product bundle already contains a version of the Intel Wi-Fi driver, use the below command to disable it. Without this step, the OOT built driver will not be able to run and bind. |
| |
| ``` |
| ffx driver disable fuchsia-pkg://fuchsia.com/iwlwifi#meta/iwlwifi.cm |
| ``` |
| |
| The command output would look something like this: |
| ``` |
| $ tools/ffx driver disable fuchsia-pkg://fuchsia.com/iwlwifi#meta/iwlwifi.cm |
| Disabling fuchsia-pkg://fuchsia.com/iwlwifi#meta/iwlwifi.cm and restarting driver hosts with rematching enabled. |
| Successfully restarted and rematching 1 driver hosts with the driver. |
| ``` |
| |
| 2. Build, publish and register the Intel Wi-Fi driver component using a single command: |
| ``` |
| tools/bazel run third_party/iwlwifi/platform:iwlwifi_pkg.iwlwifi_component |
| ``` |
| |
| The command output would look something like this: |
| ``` |
| $ tools/bazel run third_party/iwlwifi/platform:iwlwifi_pkg.iwlwifi_component |
| ... |
| Publishing packages: [PosixPath('third_party/iwlwifi/platform/iwlwifi.far')] |
| Published 1 packages |
| Running task: iwlwifi_pkg.iwlwifi_component.run_only (step 3/4) |
| Registering fuchsia-pkg://bazel.iwlwifi.pkg.publish.anonymous/iwlwifi#meta/iwlwifi.cm, restarting driver hosts, and attempting to bind to unbound nodes |
| Successfully bound: |
| Node 'dev.sys.platform.pt.PCI0.bus.01_00.0.01_00.0', Driver 'fuchsia-pkg://bazel.iwlwifi.pkg.publish.anonymous/iwlwifi#meta/iwlwifi.cm'. |
| Running task: iwlwifi_pkg.publish_anonymous.delete_repo (step 4/4) |
| ``` |
| |
| 3. Verify that the iwlwifi driver is now loaded to the NUC: |
| ``` |
| $ tools/ffx driver list --loaded | grep wifi |
| fuchsia-pkg://bazel.pkg.publish.anonymous/iwlwifi#meta/iwlwifi.cm |
| ``` |
| |
| Notice the iwlwifi driver toward the bottom of the loaded drivers list. |
| |
| 4. View the iwlwifi component information: |
| ``` |
| $ tools/ffx component show iwlwifi.cm |
| Moniker: /bootstrap/full-pkg-drivers:dev.sys.platform.pt.PCI0.bus.01_00.0_.pci-01_00.0-fidl |
| URL: fuchsia-pkg://bazel.iwlwifi.pkg.publish.anonymous/iwlwifi#meta/iwlwifi.cm |
| Environment: full-pkg-driver-env |
| Instance ID: None |
| Type: CML component |
| Component State: Resolved |
| Resolved URL: fuchsia-pkg://bazel.iwlwifi.pkg.publish.anonymous/iwlwifi#meta/iwlwifi.cm |
| Namespace Capabilities: /svc/fuchsia.logger.LogSink |
| /svc/fuchsia.hardware.pci.Service |
| Exposed Capabilities: fuchsia.wlan.softmac.Service |
| fuchsia.wlan.phyimpl.Service |
| diagnostics |
| Merkle root: 98384e7ced5c66b0fbf5f725abb43e9e9b57594e694f9167c032cceb4b009b80 |
| Execution State: Running |
| Start reason: Instance is in a single_run collection |
| Outgoing Capabilities: diagnostics |
| fuchsia.wlan.phyimpl.Service |
| Runtime: Unknown |
| ``` |
| |
| 5. Run a scan command to validate the driver works |
| ``` |
| fx shell wlan-dev scan |
| ``` |
| |
| A successful scan output would look something like this. |
| ``` |
| fuchsia~$ fx shell wlan-dev scan |
| Warning: this tool may cause state mismatches between layers of the WLAN |
| subsystem. It is intended for use by WLAN developers only. Please reach out |
| to the WLAN team if your use case relies on it. |
| Scan(ClientScanCmd { iface_id: 0, scan_type: Passive }) |
| BSSID dBm Chan Protection Compatible SSID |
| 8c:3b:ad:ab:91:4d -86 157V WPA2 PSK Y |
| 60:32:b1:6a:e6:53 -72 9+ WPA2 PSK Y |
| 62:8c:b5:39:0b:fb -85 153V WPA2 PSK Y |
| ``` |
| |
| ## 5. Run tests |
| |
| ### 5.1 Run unit-tests on emulator |
| 1. Stop all existing Fuchsia emulator instance: |
| ``` |
| tools/ffx emu stop --all |
| ``` |
| |
| 2. Start the Fuchsia emulator: |
| ``` |
| tools/bazel run @fuchsia_products//:minimal.x64.emu -- --headless |
| ``` |
| |
| 3. Execute the following command to run the driver tests: |
| ``` |
| tools/bazel test third_party/iwlwifi/test:iwlwifi_test_pkg |
| ``` |
| |
| ### 5.2 Run unit-tests on NUC |
| 1. Boot your NUC in Fastboot mode (or boot it normally to run Fuchsia). |
| |
| 2. Identify your NUC’s device name, for example: |
| ``` |
| $ ffx target list |
| NAME SERIAL TYPE STATE |
| fuchsia-5254-0063-5e7a <unknown> Unknown Unknown |
| ``` |
| |
| 3. Flash the device: |
| ``` |
| tools/bazel run @fuchsia_products//:core.x64.flash -- --target <name_from_target_list> |
| ``` |
| |
| Replace <name_from_target_list> with the target name (in this case, fuchsia-5254-0063-5e7a). |
| |
| 4. Execute the following command to run the driver tests. Note the argument to not cache the results and actually run all tests, even if everything is unchanged. |
| ``` |
| tools/bazel test --cache_test_results=no third_party/iwlwifi/test:iwlwifi_test_pkg |
| ``` |
| |
| |
| ### 5.3 Running tests with ASAN |
| Execute the following command to run the driver tests with ASAN enabled. |
| ``` |
| tools/bazel test --features=asan --cache_test_results=no third_party/iwlwifi/test:iwlwifi_test_pkg |
| ``` |
| |
| ### 6. Upload your changes |
| |
| Once you're ready to send your changes for code review, run: |
| |
| ``` |
| git push origin HEAD:refs/for/main |
| ``` |
| |
| git will then print the URL of your pending CL. |