xref: /openwifi/doc/img_build_instruction/kuiper.md (revision ef526178fb922089e88d9b6332fa7ad33c78e6ea)
1*ef526178SXianjun Jiao**IMPORTANT pre-conditions**:
2*ef526178SXianjun Jiao- Install Vivado 2021.1. Make sure install Vitis as well. You should have this directory: your_Xilinx_install_directory/Vitis (NOT Vitis_HLS!)
3*ef526178SXianjun Jiao  - If the Vitis is not installed, you can add it by running "Xilinx Design Tools --> Add Design Tools for Devices 2021.1" from Xilinx program group/menu in your OS start menu, or Help menu of Vivado.
4*ef526178SXianjun Jiao- SD card at least with 16GB
5*ef526178SXianjun Jiao- Install the devicetree compiler -- dtc. (For Ubuntu: sudo apt install device-tree-compiler)
6*ef526178SXianjun Jiao- Install the mkimage tool. (For Ubuntu: sudo apt install u-boot-tools)
7*ef526178SXianjun Jiao
8*ef526178SXianjun Jiao[[Use openwifi prebuilt img](#Use-openwifi-prebuilt-img)]
9*ef526178SXianjun Jiao[[Build SD card from scratch](#Build-SD-card-from-scratch)]
10*ef526178SXianjun Jiao[[Use existing SD card on new board](#Use-existing-SD-card-on-new-board)]
11*ef526178SXianjun Jiao
12*ef526178SXianjun Jiao## Use openwifi prebuilt img
13*ef526178SXianjun Jiao
14*ef526178SXianjun JiaoDownload openwifi pre-built img, such as openwifi-xyz.img.xz, and extract it to .img file.
15*ef526178SXianjun Jiao
16*ef526178SXianjun JiaoUse dd command to flash the SD card. (Other software seems having issue!)
17*ef526178SXianjun Jiao```
18*ef526178SXianjun Jiaosudo dd bs=512 count=31116288 if=openwifi-xyz.img of=/dev/your_sdcard_dev
19*ef526178SXianjun Jiao```
20*ef526178SXianjun Jiao
21*ef526178SXianjun Jiao(To have correct count value, better to check the .img file actual situation by "fdisk -l img_filename".
22*ef526178SXianjun Jiao
23*ef526178SXianjun Jiao## Build SD card from scratch
24*ef526178SXianjun Jiao
25*ef526178SXianjun JiaoDownload image_2022-08-04-ADI-Kuiper-full.zip from https://wiki.analog.com/resources/tools-software/linux-software/kuiper-linux?redirect=1
26*ef526178SXianjun Jiao
27*ef526178SXianjun JiaoExtract it to .img file.
28*ef526178SXianjun Jiao
29*ef526178SXianjun JiaoUse dd command to flash the SD card. (Other software seems having issue!)
30*ef526178SXianjun Jiao```
31*ef526178SXianjun Jiaosudo dd bs=512 count=24018944 if=2022-08-04-ADI-Kuiper-full.img of=/dev/your_sdcard_dev
32*ef526178SXianjun Jiao```
33*ef526178SXianjun Jiao
34*ef526178SXianjun Jiao(To have correct count value, better to check the .img file actual situation by "fdisk -l img_filename". While making .img from SD card, check the SD card dev instead)
35*ef526178SXianjun Jiao
36*ef526178SXianjun JiaoMount the BOOT and rootfs partition of SD card to your computer.
37*ef526178SXianjun Jiao
38*ef526178SXianjun JiaoChange the SD card file: Add following into rootfs/etc/network/interfaces
39*ef526178SXianjun Jiao```
40*ef526178SXianjun Jiao# The loopback interface
41*ef526178SXianjun Jiaoauto lo
42*ef526178SXianjun Jiaoiface lo inet loopback
43*ef526178SXianjun Jiaoauto eth0
44*ef526178SXianjun Jiaoiface eth0 inet static
45*ef526178SXianjun Jiao
46*ef526178SXianjun Jiao#your static IP
47*ef526178SXianjun Jiaoaddress 192.168.10.122
48*ef526178SXianjun Jiao
49*ef526178SXianjun Jiao#your gateway IP
50*ef526178SXianjun Jiaogateway 192.168.10.1
51*ef526178SXianjun Jiaonetmask 255.255.255.0
52*ef526178SXianjun Jiao
53*ef526178SXianjun Jiao#your network address "family"
54*ef526178SXianjun Jiaonetwork 192.168.10.0
55*ef526178SXianjun Jiaobroadcast 192.168.10.255
56*ef526178SXianjun Jiao```
57*ef526178SXianjun Jiao
58*ef526178SXianjun JiaoChange the SD card file: Add following into rootfs/etc/sysctl.conf
59*ef526178SXianjun Jiao```
60*ef526178SXianjun Jiaonet.ipv4.ip_forward=1
61*ef526178SXianjun Jiao```
62*ef526178SXianjun Jiao
63*ef526178SXianjun JiaoChange the SD card file: Add following into rootfs/etc/systemd/system.conf
64*ef526178SXianjun Jiao```
65*ef526178SXianjun JiaoDefaultTimeoutStopSec=2s
66*ef526178SXianjun Jiao```
67*ef526178SXianjun Jiao
68*ef526178SXianjun JiaoPut the openwifi/kernel_boot/10-network-device.rules into rootfs/etc/udev/rules.d/
69*ef526178SXianjun Jiao
70*ef526178SXianjun JiaoBuild and put the following 3 files to the BOOT partition of the SD card:
71*ef526178SXianjun Jiao- Linux kernel image file (check how to generate it by prepare_kernel.sh in [Update Driver](../../README.md#Update-Driver)):
72*ef526178SXianjun Jiao  - adi-linux-64/arch/arm64/boot/Image (64bit)
73*ef526178SXianjun Jiao  - adi-linux/arch/arm/boot/uImage (32bit)
74*ef526178SXianjun Jiao- devicetree file:
75*ef526178SXianjun Jiao  - openwifi/kernel_boot/boards/zcu102_fmcs2/system.dtb (64bit)
76*ef526178SXianjun Jiao  - openwifi/kernel_boot/boards/$BOARD_NAME/devicetree.dtb (32bit)
77*ef526178SXianjun Jiao- BOOT.BIN (check how to generate it by boot_bin_gen.sh in [Update FPGA](../../README.md#Update-FPGA)):
78*ef526178SXianjun Jiao  - openwifi/kernel_boot/boards/$BOARD_NAME/output_boot_bin/BOOT.BIN
79*ef526178SXianjun Jiao
80*ef526178SXianjun JiaoBuild openwifi driver according to [Update Driver](../../README.md#Update-Driver)). No need to copy them onboard at this moment.
81*ef526178SXianjun Jiao
82*ef526178SXianjun JiaoCreate /root/openwifi directory in the rootfs partition of the SD card, and put all files in openwifi/user_space to that directory.
83*ef526178SXianjun Jiao
84*ef526178SXianjun JiaoPower on the board with the SD card, connect the board to your host PC (static IP 192.168.10.1) via ethernet, and ssh to the board with password "analog"
85*ef526178SXianjun Jiao```
86*ef526178SXianjun Jiaossh [email protected]
87*ef526178SXianjun Jiao```
88*ef526178SXianjun Jiao
89*ef526178SXianjun JiaoThen change password to "openwifi" via "passwd" command onbard.
90*ef526178SXianjun Jiao
91*ef526178SXianjun JiaoEnlarge the onboard SD disk space, and reboot (https://github.com/analogdevicesinc/adi-kuiper-gen/releases)
92*ef526178SXianjun Jiao```
93*ef526178SXianjun Jiaoraspi-config --expand-rootfs
94*ef526178SXianjun Jiaoreboot now
95*ef526178SXianjun Jiao```
96*ef526178SXianjun Jiao
97*ef526178SXianjun Jiao(You should already build Linux kernel and openwifi driver in previous steps!)
98*ef526178SXianjun Jiao
99*ef526178SXianjun JiaoTransfer the kernel modules .ko and openwifi driver .ko onto the board:
100*ef526178SXianjun Jiao```
101*ef526178SXianjun Jiaocd openwifi/user_space
102*ef526178SXianjun Jiao./transfer_driver_userspace_to_board.sh
103*ef526178SXianjun Jiao./transfer_kernel_image_module_to_board.sh $LINUX_KERNEL_SRC $BOARD_NAME
104*ef526178SXianjun Jiao($LINUX_KERNEL_SRC is the directory openwifi/adi-linux-64 or adi-linux)
105*ef526178SXianjun Jiao```
106*ef526178SXianjun Jiao
107*ef526178SXianjun JiaoIn the ssh session onboard:
108*ef526178SXianjun Jiao```
109*ef526178SXianjun Jiaocd /root
110*ef526178SXianjun Jiaosync
111*ef526178SXianjun Jiaotar -zxvf openwifi.tar.gz
112*ef526178SXianjun Jiao./populate_kernel_image_module_reboot.sh
113*ef526178SXianjun Jiaoreboot now
114*ef526178SXianjun Jiao```
115*ef526178SXianjun JiaoSetup routing/NAT **on the PC** for your board -- this internet connection is **important** for post installation/config.
116*ef526178SXianjun Jiao```
117*ef526178SXianjun Jiaosudo sysctl -w net.ipv4.ip_forward=1
118*ef526178SXianjun Jiaosudo iptables -t nat -A POSTROUTING -o NICY -j MASQUERADE
119*ef526178SXianjun Jiaosudo ip route add 192.168.13.0/24 via 192.168.10.122 dev ethX
120*ef526178SXianjun Jiao```
121*ef526178SXianjun Jiao**ethX** is the PC NIC name connecting the board ethernet. **NICY** is the PC NIC name connecting internet (WiFi or another ethernet).
122*ef526178SXianjun Jiao
123*ef526178SXianjun JiaoIf you want, uncommenting "net.ipv4.ip_forward=1" in /etc/sysctl.conf to make IP forwarding persistent on PC.
124*ef526178SXianjun Jiao
125*ef526178SXianjun JiaoTest the connectivity. Run on board (in the ssh session):
126*ef526178SXianjun Jiao```
127*ef526178SXianjun Jiaoroute add default gw 192.168.10.1
128*ef526178SXianjun Jiaoping IP_YOU_KNOW_ON_YOUR_NETWORK
129*ef526178SXianjun Jiao```
130*ef526178SXianjun JiaoIf there is issue with the connectivity (ping can not reach the target), it needs to be solved before going to the next step.
131*ef526178SXianjun Jiao
132*ef526178SXianjun JiaoDo misc configurations/installations in the ssh session onboard:
133*ef526178SXianjun Jiao```
134*ef526178SXianjun Jiaocd /root/openwifi
135*ef526178SXianjun Jiaoroute add default gw 192.168.10.1 || true
136*ef526178SXianjun Jiaoping google.com
137*ef526178SXianjun Jiaosudo apt update
138*ef526178SXianjun Jiaochmod +x *.sh
139*ef526178SXianjun Jiao
140*ef526178SXianjun Jiao# build sdrctl and inject_80211
141*ef526178SXianjun Jiaosudo apt-get -y install libnl-3-dev
142*ef526178SXianjun Jiaosudo apt-get -y install libnl-genl-3-dev
143*ef526178SXianjun Jiaocd sdrctl_src
144*ef526178SXianjun Jiaomake
145*ef526178SXianjun Jiaocp sdrctl ../
146*ef526178SXianjun Jiaocd ../side_ch_ctl_src/
147*ef526178SXianjun Jiaogcc -o side_ch_ctl side_ch_ctl.c
148*ef526178SXianjun Jiaocp side_ch_ctl ../
149*ef526178SXianjun Jiaocd ..
150*ef526178SXianjun Jiaocd ./inject_80211/
151*ef526178SXianjun Jiaomake
152*ef526178SXianjun Jiaocd ..
153*ef526178SXianjun Jiao
154*ef526178SXianjun Jiao# install and setup dhcp server
155*ef526178SXianjun Jiaosudo apt-get -y install isc-dhcp-server
156*ef526178SXianjun Jiaocp dhcpd.conf /etc/dhcp/dhcpd.conf
157*ef526178SXianjun Jiao
158*ef526178SXianjun Jiao# install hostapd and other useful tools
159*ef526178SXianjun Jiaosudo apt-get -y install hostapd
160*ef526178SXianjun Jiaosudo apt-get -y install tcpdump
161*ef526178SXianjun Jiaosudo apt-get -y install webfs
162*ef526178SXianjun Jiaosudo apt-get -y install iperf
163*ef526178SXianjun Jiaosudo apt-get -y install iperf3
164*ef526178SXianjun Jiaosudo apt-get -y install libpcap-dev
165*ef526178SXianjun Jiaosudo apt-get -y install bridge-utils
166*ef526178SXianjun Jiao
167*ef526178SXianjun Jiao# add video file into the onbard web server
168*ef526178SXianjun Jiaowget -P webserver/ https://users.ugent.be/~xjiao/openwifi-low-aac.mp4
169*ef526178SXianjun Jiao```
170*ef526178SXianjun Jiao
171*ef526178SXianjun JiaoRun openwifi in the ssh session onboard:
172*ef526178SXianjun Jiao```
173*ef526178SXianjun Jiaocd /root/openwifi
174*ef526178SXianjun Jiao./wgd.sh
175*ef526178SXianjun Jiaoiwlist sdr0 scan
176*ef526178SXianjun Jiao./fosdem.sh
177*ef526178SXianjun Jiao```
178*ef526178SXianjun Jiao
179*ef526178SXianjun Jiao## Use existing SD card on new board
180*ef526178SXianjun Jiao
181*ef526178SXianjun JiaoYou don't need to do it from scratch on a blank SD card. Instead, you can start from existing SD card (for example zcu102), and use it for a new board (for example zedboard).
182*ef526178SXianjun Jiao
183*ef526178SXianjun Jiao1. Do this section (see above) "Build and put the following 3 files to the BOOT partition of the SD card" for the new board by replacing the file on the existing SD card.
184*ef526178SXianjun Jiao
185*ef526178SXianjun Jiao2. Build openwifi driver according to [Update Driver](../../README.md#Update-Driver)). No need to copy them onboard at this moment.
186*ef526178SXianjun Jiao
187*ef526178SXianjun Jiao3. Use the existing SD card to boot the new board.
188*ef526178SXianjun Jiao
189*ef526178SXianjun Jiao4. Do this section (see above) "Transfer the kernel modules .ko and openwifi driver .ko onto the board". Do not forget the operations onboard after the file transfer:
190*ef526178SXianjun Jiao  ```
191*ef526178SXianjun Jiao  cd /root
192*ef526178SXianjun Jiao  sync
193*ef526178SXianjun Jiao  tar -zxvf openwifi.tar.gz
194*ef526178SXianjun Jiao  ./populate_kernel_image_module_reboot.sh
195*ef526178SXianjun Jiao  reboot now
196*ef526178SXianjun Jiao  ```
197