xref: /openwifi/doc/app_notes/drv_fpga_dynamic_loading.md (revision 40773b7882a840f41a4b585d6e6866cc81fa13a9)
1*40773b78SXianjun JiaoThe **wgd.sh** (running on board) supports reloading driver and/or FPGA image dynamically without rebooting/power-cycle. It can work in different modes in a
2*40773b78SXianjun Jiaoflexible way.
3*40773b78SXianjun Jiao
4*40773b78SXianjun Jiao- [[Reload driver only](#Reload-driver-only)]
5*40773b78SXianjun Jiao- [[Reload driver and FPGA](#Reload-driver-and-FPGA)]
6*40773b78SXianjun Jiao- [[Reload driver and FPGA in target directory](#Reload-driver-and-FPGA-in-target-directory)]
7*40773b78SXianjun Jiao- [[Reload driver and FPGA from a single package file](#Reload-driver-and-FPGA-from-a-single-package-file)]
8*40773b78SXianjun Jiao- [[Detailed full usage info](#Detailed-full-usage-info)]
9*40773b78SXianjun Jiao
10*40773b78SXianjun Jiao## Reload driver only
11*40773b78SXianjun JiaoThis 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**
12*40773b78SXianjun Jiaopresent in the directory. If wgd.sh can not find the FPGA image, it will skip reloading it.
13*40773b78SXianjun Jiao
14*40773b78SXianjun Jiao## Reload driver and FPGA
15*40773b78SXianjun Jiao- Generate the reloadable FPGA file **system_top.bit.bin**. In the Linux host computer:
16*40773b78SXianjun Jiao  ```
17*40773b78SXianjun Jiao  cd openwifi/user_space
18*40773b78SXianjun Jiao  ./drv_and_fpga_package_gen.sh $OPENWIFI_HW_DIR $XILINX_DIR $BOARD_NAME
19*40773b78SXianjun Jiao  ```
20*40773b78SXianjun Jiao  Then **system_top.bit.bin** will be generated in openwifi/user_space
21*40773b78SXianjun Jiao- Put **system_top.bit.bin** on board in the same directory as wgd.sh and other driver files (.ko)
22*40773b78SXianjun Jiao- Run **wgd.sh** on board as usual
23*40773b78SXianjun Jiao
24*40773b78SXianjun Jiao## Reload driver and FPGA in target directory
25*40773b78SXianjun JiaoPut **system_top.bit.bin** on board together with other driver files (.ko) in a directory ($TARGET_DIR), then run on board:
26*40773b78SXianjun Jiao```
27*40773b78SXianjun Jiao./wgd.sh $TARGET_DIR
28*40773b78SXianjun Jiao```
29*40773b78SXianjun JiaoIn this way, different versions/variants of driver/FPGA can be put in different directories. Then **wgd.sh** can be used to switch
30*40773b78SXianjun Jiaobetween them without rebooting/power-cycle.
31*40773b78SXianjun Jiao
32*40773b78SXianjun Jiao## Reload driver and FPGA from a single package file
33*40773b78SXianjun JiaoThe 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),
34*40773b78SXianjun JiaoFPGA image and many other rich source files/infos that are related. You can rename it with a more meaningful name (such as add version or variant info), and put
35*40773b78SXianjun Jiaothe renamed **drv_and_fpga_MEANINGFUL_POSTFIX.tar.gz** on board in the same directory as **wgd.sh**, and let **wgd.sh** load it:
36*40773b78SXianjun Jiao```
37*40773b78SXianjun Jiao./wgd.sh ./drv_and_fpga_MEANINGFUL_POSTFIX.tar.gz
38*40773b78SXianjun Jiao```
39*40773b78SXianjun JiaoIn this way, different version/variants of driver/FPGA can be packaged as different files. Then **wgd.sh** can be used to switch
40*40773b78SXianjun Jiaobetween them without rebooting/power-cycle.
41*40773b78SXianjun Jiao
42*40773b78SXianjun Jiao## Detailed full usage info
43*40773b78SXianjun JiaoRun the "./wgd.sh -h" on board or open wgd.sh to see full usage info:
44*40773b78SXianjun Jiao```
45*40773b78SXianjun Jiaousage:
46*40773b78SXianjun Jiao  Script for load (or download+load) different driver and FPGA img without rebooting
47*40773b78SXianjun Jiao  no  argument: Load .ko driver files and FPGA img (if system_top.bit.bin exist) in current dir with test_mode=0.
48*40773b78SXianjun Jiao  1st argument: If it is a NUMBER, it will be assigned to test_mode. Then load everything from current dir.
49*40773b78SXianjun Jiao  1st argument: If it is a string called "remote", it will download driver/FPGA and load everything.
50*40773b78SXianjun Jiao  - 2nd argument (if exist) is the target directory name for downloading and reloading
51*40773b78SXianjun Jiao  - 3rd argument (if exist) is the value for test_mode
52*40773b78SXianjun Jiao  1st argument: neither NUMBER nor "remote" nor a .tar.gz file, it is regarded as a directory and load everything from it.
53*40773b78SXianjun Jiao  - 2nd argument (if exist) is the value for test_mode
54*40773b78SXianjun Jiao  1st argument: a .tar.gz file, it will be unpacked then load from that unpacked directory
55*40773b78SXianjun Jiao  - 2nd argument (if exist) is the value for test_mode
56*40773b78SXianjun Jiao```
57