xref: /openwifi/doc/app_notes/radar-self-csi.md (revision e556af35c696ecef552192823e107caf37eb6af9)
1<!--
2Author: Xianjun jiao
3SPDX-FileCopyrightText: 2019 UGent
4SPDX-License-Identifier: AGPL-3.0-or-later
5-->
6
7One super power of the openwifi platform is "**Full Duplex**" which means that openwifi baseband can receive its own TX signal. Just like a radar! This brings a unique capability of "**joint radar and communication**" to openwifi. For instance, put two directional antennas to openwifi TX and RX, and the **CSI** (Channel State Information) of the self-TX signal will refect the change of the target object.
8 ![](./openwifi-radar.jpg)
9 ![](./sensing.png)
10
11## Quick start
12- Power on the SDR board.
13- Connect a computer to the SDR board via Ethernet cable. The computer should have static IP 192.168.10.1. Open a terminal on the computer, and then in the terminal:
14  ```
15  ssh [email protected]
16  (password: openwifi)
17  ```
18- On computer, build the latest driver and FPGA package after clone/update openwifi and openwifi-hw-img repository:
19  ```
20  export XILINX_DIR=your_Xilinx_install_directory
21  (Example: export XILINX_DIR=/opt/Xilinx. The Xilinx directory should include sth like: Downloads, Vitis, etc.)
22  export OPENWIFI_HW_IMG_DIR=your_openwifi-hw-img_directory
23  (The directory where you get the open-sdr/openwifi-hw-img repo via git clone)
24  export BOARD_NAME=your_board_name
25  (Check the BOARD_NAME definitions in README)
26
27  cd openwifi/user_space
28  ./drv_and_fpga_package_gen.sh $OPENWIFI_HW_IMG_DIR $XILINX_DIR $BOARD_NAME
29  scp drv_and_fpga.tar.gz [email protected]:openwifi/
30  scp ./side_ch_ctl_src/side_ch_ctl.c [email protected]:openwifi/
31  scp ./inject_80211/* [email protected]:openwifi/inject_80211/
32  ```
33- On SDR board (/root/openwifi directory):
34  ```
35  cd /root/openwifi/
36  ./wgd.sh drv_and_fpga.tar.gz
37  ./monitor_ch.sh sdr0 1
38  insmod ./drv_and_fpga/side_ch.ko
39  gcc -o side_ch_ctl side_ch_ctl.c
40  ./side_ch_ctl wh1h4001
41  ./side_ch_ctl wh7h4433225a
42  (Above two commands ensure receiving CSI only from XX:XX:44:33:22:5a, which will be set by our own packet injector later)
43  ./sdrctl dev sdr0 set reg xpu 1 1
44  (Above unmute the baseband self-receiving to receive openwifi own TX signal/packet)
45  ./side_ch_ctl g0
46  ```
47- Open another ssh session on SDR board:
48  ```
49  cd /root/openwifi/inject_80211
50  make
51  ./inject_80211 -m g -r 4 -t d -e 0 -b 5a -n 99999999 -s 20 -d 1000 sdr0
52
53  (Above command injects the 802.11a/g packet, for 802.11n packet please use:
54  ./inject_80211 -m n -r 4 -t d -e 8 -b 5a -n 99999999 -s 20 -d 1000 sdr0)
55  ```
56- Now you should see the increasing numbers in the previous ssh terminal of the SDR board.
57- On your computer (NOT ssh session!), run:
58  ```
59  cd openwifi/user_space/side_ch_ctl_src
60  python3 side_info_display.py 8 waterfall
61  ```
62  The python script needs "matplotlib.pyplot" and "numpy" packages installed. Now you should see figures showing run-time **CSI**, **CSI waterfall**, **Equalizer out** and **frequency offset**. The following photo shows the CSI change in the waterfall plot when I left my seat in front of two directional antennas (Tx/Rx antenna).
63  ![](./sensing.png)
64
65  While running, all CSI data is also stored into a file **side_info.txt**. A matlab script **test_side_info_file_display.m** is offered to help you do CSI analysis offline. In this case, run **test_side_info_file_display** in Matlab.
66  ![](./csi-screen-shot-radar-matlab.jpg)
67
68Please learn the python and Matlab script for CSI data structure per packet according to your requirement.
69
70Do read the [normal CSI app note](csi.md) to understand the basic implementation architecture.
71