zephyr/samples/net/wpanusb
Johann Fischer 5296339fde usb: rework to use macro STRUCT_SECTION_FOREACH
Replace deprecated macro USBD_CFG_DATA_DEFINE by
USBD_DEFINE_CFG_DATA which places usb_cfg_data structures
in specific iterable section.

Replace __usb_data_start, __usb_data_end usage patterns
  size_t size = (__usb_data_end - __usb_data_start);
  for (size_t i = 0; i < size; i++) {...}
by
  STRUCT_SECTION_FOREACH(usb_cfg_data, ...) {...}

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-12-10 07:22:15 -06:00
..
boards samples: wpanusb: Add atsamr21_xpro board support 2020-01-16 10:47:10 +02:00
src usb: rework to use macro STRUCT_SECTION_FOREACH 2021-12-10 07:22:15 -06:00
CMakeLists.txt cmake: increase minimal required version to 3.20.0 2021-08-20 09:47:34 +02:00
Kconfig samples: wpanusb: assign next free sample PID 2020-05-27 14:15:52 +02:00
README.rst samples: wpanusb: assign next free sample PID 2020-05-27 14:15:52 +02:00
prj.conf samples: remove USB configuration option 2021-08-03 19:00:12 -04:00
sample.yaml sanitycheck: inclusive language 2020-08-27 07:04:07 -04:00
wpan-radio-spec.txt

README.rst

.. _wpanusb-sample:

wpanusb sample
##############

Overview
********

This application exports ieee802154 radio over USB to be used in
other OSes such as Linux.  For Linux, the ieee802154 stack would be
implemented using the Linux SoftMAC driver.
This sample can be found under :zephyr_file:`samples/net/wpanusb` in the
Zephyr project tree.

Requirements
************

- a Zephyr board with supported 802.15.4 radio and supported USB driver
  (such as the :ref:`nrf52840dk_nrf52840` or :ref:`atsamr21_xpro`)
  connected via USB to a Linux host
- wpanusb Linux kernel driver (in the process of being open sourced)
- wpan-tools (available for all Linux distributions)

Building and Running
********************

There are configuration files for various setups in the
``samples/net/wpanusb`` directory:

- :file:`prj.conf`
    This is the standard default config.  This can be used by itself for
    hardware which has native 802.15.4 support.

- :file:`overlay-cc2520.conf`
    This overlay config enables support for CC2520

Build the wpanusb sample for a board:

.. zephyr-app-commands::
   :zephyr-app: samples/net/wpanusb
   :board: <board to use>
   :gen-args: -DOVERLAY_CONFIG=<overlay file to use>
   :goals: build
   :compact:

Example building for the Nordic nRF52840 Development Kit:

.. zephyr-app-commands::
   :zephyr-app: samples/net/wpanusb
   :board: nrf52840dk_nrf52840
   :goals: build
   :compact:

When connected to Linux with wpanusb kernel driver, it is recognized as:

.. code-block:: console

   ...
   T:  Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  3 Spd=12  MxCh= 0
   D:  Ver= 1.10 Cls=ff(vend.) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
   P:  Vendor=2fe3 ProdID=000d Rev=01.00
   C:  #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA
   I:  If#= 0 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=00 Driver=wpanusb
   ...

The following script enables the network interface in Linux
(uses iwpan tool from above):

.. code-block:: console

    #!/bin/sh
    PHY=`iwpan phy | grep wpan_phy | cut -d' ' -f2`
    echo 'Using phy' $PHY
    iwpan dev wpan0 set pan_id 0xabcd
    iwpan dev wpan0 set short_addr 0xbeef
    iwpan phy $PHY set channel 0 26
    ip link add link wpan0 name lowpan0 type lowpan
    ip link set wpan0 up
    ip link set lowpan0 up