xref: /openwifi/doc/app_notes/drv_fpga_dynamic_loading.md (revision 70cedb2220ce3dc467f97e16f1a60c1776ea94f6)
1The **wgd.sh** (running on board) supports reloading driver and/or FPGA image dynamically without rebooting/power-cycle. It can work in a
2flexible way.
3
4The purpose of this feature is to help you easily reload driver and FPGA built from your branch/version/variant/modification, and switch/run different driver and FPGA of different branch/version/variant/modification without rebooting. To enjoy this feature, always ensure your onboard openwifi/files are the latest files in [user_space](../../user_space)).
5
6- [[Reload driver only](#Reload-driver-only)]
7- [[Reload driver and FPGA](#Reload-driver-and-FPGA)]
8- [[Reload driver and FPGA in target directory](#Reload-driver-and-FPGA-in-target-directory)]
9- [[Reload driver and FPGA from a single package file](#Reload-driver-and-FPGA-from-a-single-package-file)] -- **RECOMMENDED!**
10- [[Detailed full usage info](#Detailed-full-usage-info)]
11
12## Reload driver only
13This is the original way. To let **wgd.sh** only loads the driver without touching FPGA, please ensure FPGA image file **system_top.bit.bin** does **NOT**
14present in the directory. If wgd.sh can not find the FPGA image, it will skip reloading it.
15
16## Reload driver and FPGA
17- Generate the reloadable FPGA file **system_top.bit.bin**. In the Linux host computer:
18  ```
19  cd openwifi/user_space
20  ./drv_and_fpga_package_gen.sh $OPENWIFI_HW_DIR $XILINX_DIR $BOARD_NAME
21  ```
22  Then **system_top.bit.bin** will be generated in openwifi/user_space.
23  (**Attention:** above command will call **make_all.sh** to build the driver. If you have conditional compiling option, do not forget to put them into **drv_and_fpga_package_gen.sh** for the **make_all.sh** in it.
24- Put **system_top.bit.bin** on board in the same directory as wgd.sh and other driver files (.ko)
25- Run **wgd.sh** on board as usual
26
27## Reload driver and FPGA in target directory
28Put **system_top.bit.bin** on board together with other driver files (.ko) in a directory ($TARGET_DIR), then run on board:
29```
30./wgd.sh $TARGET_DIR
31```
32In this way, different versions/variants of driver/FPGA can be put in different directories. Then **wgd.sh** can be used to switch
33between them without rebooting/power-cycle.
34
35## Reload driver and FPGA from a single package file
36The openwifi/user_space/**drv_and_fpga_package_gen.sh** also generates a single package file **drv_and_fpga.tar.gz**, which includes driver files (.ko),
37FPGA image and many other source files with rich infos that are related.
38
39You can switch to your own branch/version/variant, build the single package file via **drv_and_fpga_package_gen.sh**, rename it with a more meaningful name (such as add version or variant info as postfix), put the renamed **drv_and_fpga_MEANINGFUL_POSTFIX.tar.gz** on board in the same directory as **wgd.sh**, and let **wgd.sh** load it:
40```
41./wgd.sh ./drv_and_fpga_MEANINGFUL_POSTFIX.tar.gz
42```
43In this way, different version/variants of driver/FPGA can be switched by **wgd.sh** without rebooting/power-cycle.
44
45## Detailed full usage info
46Run the "./wgd.sh -h" on board or open wgd.sh to see full usage info:
47```
48usage:
49  Script for load (or download+load) different driver and FPGA img without rebooting
50  no  argument: Load .ko driver files and FPGA img (if system_top.bit.bin exist) in current dir with test_mode=0.
51  1st argument: If it is a NUMBER, it will be assigned to test_mode. Then load everything from current dir.
52  1st argument: If it is a string called "remote", it will download driver/FPGA and load everything.
53  - 2nd argument (if exist) is the target directory name for downloading and reloading
54  - 3rd argument (if exist) is the value for test_mode
55  1st argument: neither NUMBER nor "remote" nor a .tar.gz file, it is regarded as a directory and load everything from it.
56  - 2nd argument (if exist) is the value for test_mode
57  1st argument: a .tar.gz file, it will be unpacked then load from that unpacked directory
58  - 2nd argument (if exist) is the value for test_mode
59```
60