开发环境:
我这里使用的是WSL2+VS Code进行开发,在Windows11上安装ubuntu,然后在VS Code当中使用WSL进行连接。
安装步骤:
在管理员模式下打开windows命令符运行wsl install然后重启电脑。
wsl install
然后安装Ubuntu-24.04
wsl --install -d Ubuntu-24.04
我电脑上安装的wsl已经是wsl2了,所以没有进行升级操作,如果是wsl1,需要进行升级。
使用串口来进行查看当前的usb设备,需要下载usbipd-win工具。
windows查看usb设备:
usbipd list
找到对应设备的编号,共享设备:
usbipd bind --busid <BUSID>
usbipd bind --busid 1-9
usbipd attach --wsl --busid=<BUSID>
usbipd attach --wsl --busid=1-9

查看设备:
ls -l /dev
在WSL和Windows之间切换还是比较麻烦的,这里找到了一个可以在WSL中调试窗口的项目,先下载源码:
git clone https://github.com/npat-efault/picocom.git
进入wifi/quick_connect/main.c文件当中添加自己的wifi信息

然后使用 make 编译:
make

我编译的是wifi/quick_connect这个项目,尝试连接wifi,make之后就会出现build_out文件,然后就可以烧录了。
make flash p=/dev/ttyUSB0 b=115200
烧录的过程中会出现

需要手动按一下板子上的RST键才能正常烧录。
然后程序就可以正常烧录进去了,程序也可以正常运行,我自己电脑的热点也显示已连接一台设备。

注:在这个过程中出现了一些烧录的bug,我也不清楚是什么原因,程序烧录时卡住无法正常烧录,试了好几次断电重启,以及按住boot和rst进入下载模式也没反应。在断电一段时间之后就莫名其妙的好了。
a36dian5hao@localhost:~/Ai-Thinker-WB2/applications/wifi/station$ make flash p=/dev/ttyUSB0 b=115200
****** Please SET BL60X_SDK_PATH ******
****** Trying SDK PATH [/home/a36dian5hao/Ai-Thinker-WB2/applications/wifi/station/../../..]
Your configuration chipname is Ai-Thinker Ai-WB2 Wi-Fi&BLE Module
Building Finish. To flash build output. run 'make flash' or:
c ...
cd /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool && env SDK_APP_BIN=/home/a36dian5hao/Ai-Thinker-WB2/applications/wifi/station/build_out/station.bin SDK_BOARD=evb SDK_NAME=station SDK_MEDIA_BIN= SDK_ROMFS_DIR= SDK_DTS= SDK_XTAL= BL_FLASH_TOOL_INPUT_PATH_cfg2_bin_input=/home/a36dian5hao/Ai-Thinker-WB2/applications/wifi/station/build_out/station.bin ./bflb_iot_tool-ubuntu --chipname=BL602 --baudrate=921600 --port=/dev/ttyUSB0 --pt=/home/a36dian5hao/Ai-Thinker-WB2/applications/wifi/station/img_conf/partition_cfg_2M.toml --dts=/home/a36dian5hao/Ai-Thinker-WB2/applications/wifi/station/img_conf/bl_factory_params_IoTKitA_40M.dts --firmware=/home/a36dian5hao/Ai-Thinker-WB2/applications/wifi/station/build_out/station.bin
['./bflb_iot_tool-ubuntu', '--chipname=BL602', '--baudrate=115200', '--port=/dev/ttyUSB0', '--pt=/home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/partition/partition_cfg_2M.toml', '--dts=/home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/device_tree/04-bl_factory_params_IoTKitA_40M-20220625.dts', '--boot2=/home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/builtin_imgs/boot2_isp_bl602_v6.5.1/boot2_iap_release.bin', '--firmware=/home/a36dian5hao/Ai-Thinker-WB2/applications/wifi/station/build_out/station.bin']
[15:45:42.945] -
[15:45:42.945] - ==================================================
[15:45:42.945] - Chip name is BL602
[15:45:42.945] - Serial port is /dev/ttyUSB0
[15:45:42.945] - Baudrate is 115200
[15:45:42.945] - Firmware is /home/a36dian5hao/Ai-Thinker-WB2/applications/wifi/station/build_out/station.bin
[15:45:42.945] - Partition Table is /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/partition/partition_cfg_2M.toml
[15:45:42.945] - Device Tree is /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/device_tree/04-bl_factory_params_IoTKitA_40M-20220625.dts
[15:45:42.945] - Boot2 is /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/builtin_imgs/boot2_isp_bl602_v6.5.1/boot2_iap_release.bin
[15:45:42.945] - MFG is None
[15:45:42.945] - Media is None
[15:45:42.945] - Romfs Dir is None
[15:45:42.945] - ==================================================
[15:45:42.946] - ========= Interface is Uart =========
[15:45:42.948] - eflash loader bin is eflash_loader_40m.bin
[15:45:42.949] - ========= chip flash id: ef4015 =========
[15:45:42.952] - create partition.bin, pt_new is True
[15:45:42.959] - fw_boot_head_gen xtal: 40M
[15:45:42.960] - Create bootheader using /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/img_create_iot/efuse_bootheader_cfg.ini
[15:45:42.960] - Updating data according to </home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/img_create_iot/efuse_bootheader_cfg.ini[BOOTHEADER_CFG]>
[15:45:42.961] - Created file len:176
[15:45:42.963] - Create efuse using /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/img_create_iot/efuse_bootheader_cfg.ini
[15:45:42.963] - Updating data according to </home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/img_create_iot/efuse_bootheader_cfg.ini[EFUSE_CFG]>
[15:45:42.964] - Created file len:128
[15:45:42.965] - ========= sp image create =========
[15:45:42.966] - Image hash is b'60fa5a43cce1faf36a8567e05fa84f3da4ad1dc252b9424a8748b14236417f78'
[15:45:42.966] - Hash ignored
[15:45:42.966] - Header crc ignored
[15:45:42.966] - Write flash img
[15:45:42.974] - fw_boot_head_gen xtal: 40M
[15:45:42.975] - Create bootheader using /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/img_create_iot/efuse_bootheader_cfg.ini
[15:45:42.976] - Updating data according to </home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/img_create_iot/efuse_bootheader_cfg.ini[BOOTHEADER_CFG]>
[15:45:42.977] - Created file len:176
[15:45:42.978] - Create efuse using /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/img_create_iot/efuse_bootheader_cfg.ini
[15:45:42.978] - Updating data according to </home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/img_create_iot/efuse_bootheader_cfg.ini[EFUSE_CFG]>
[15:45:42.979] - Created file len:128
[15:45:42.981] - ========= sp image create =========
[15:45:42.982] - Image hash is b'94acd8d93076a09ca9c64dcb46e074c64cc049a7a304554731ea51dbceefb212'
[15:45:42.982] - Header crc: b'fc1cab64'
[15:45:42.982] - Write flash img
[15:45:42.984] - FW Header is 176, 3920 still needed
[15:45:42.985] - FW OTA bin header is Done. Len is 4096
[15:45:43.011] - BL60X_OTA_Ver1.0
[15:45:43.045] - FW OTA bin is Done. Len is 366896
[15:45:43.153] - OTA XZ file len = 210944
[15:45:43.153] - Partiton len = 557056
[15:45:43.153] - BL60X_OTA_Ver1.0
[15:45:43.170] - FW OTA xz is Done
[15:45:43.170] - ========= eflash loader config =========
[15:45:43.190] - =========/home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/device_tree/04-bl_factory_params_IoTKitA_40M-20220625.dts ——> /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/device_tree/ro_params.dtb=========
[15:45:43.284] - Version: eflash_loader_v2.4.3
[15:45:43.284] - Program Start
[15:45:43.284] - ========= eflash loader cmd arguments =========
[15:45:43.284] - /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/eflash_loader/eflash_loader_cfg.ini
[15:45:43.284] - Config file: /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/eflash_loader/eflash_loader_cfg.ini
[15:45:43.284] - serial port is /dev/ttyUSB0
[15:45:43.284] - cpu_reset=False
[15:45:43.284] - chiptype: bl602
[15:45:43.284] - ========= Interface is uart =========
[15:45:43.284] - com speed: 115200
[15:45:43.284] - isp mode speed: 921600
[15:45:43.284] - Eflash load helper file: /home/a36dian5hao/Ai-Thinker-WB2/tools/flash_tool/chips/bl602/eflash_loader/eflash_loader_40m.bin
[15:45:43.284] - ========= load eflash_loader.bin =========
[15:45:43.285] - Load eflash_loader.bin via uart
[15:45:43.285] - ========= image load =========