【RISC-V 生态软件系列】Waft基础教学一:搭建Waft运行环境
本文旨在帮助开发者搭建平头哥上的waft运行环境
调试接口说明
该type-c usb口支持adb通道,支持adb命令(push、shell)
该type-c usb口是串口通道,安装ch340驱动后,搞开发的这个应该都有, 可以使用串口工具(如SecureCRT,Putyy)登入调试。
串口参数设置:
更新waft容器
Waft引擎也在持续迭代开发中,板子系统自带的waft容器固件相对较老,可以通过下载链接获取Waft容器固件,链接如下: 下载waft固件包,解压后,按如下说明push到开发板
bin目录
存放waft容器二进制运行文件,waft_app放到/usr/bin目录
lib目录
存放waft_app运行时依赖的共享库,统一放到/usr/lib目录
resource目录
存放waft依赖的资源文件,如字库文件。把resource目录放到根目录/,保持目录内容不变
waftapps目录
存放waft字节码文件。把waftapps目录放到根目录/,保持目录内容不变
推送方式参考adb或者scp的使用方法。
WIFI连接
waft的运行、更新均需要依赖网络,所以需要在开发板上配置好wifi网络:
方法一更新完waft容器后,运行如下命令: waft_app /waftapps/app_wifi.wasm 点击wifi信号位置进入wifi连接设置界面,搜索wifi、输入密码连接即可。
方法二
方法一直接修改wpa_supplicant的配置文件,增加如下内容到/etc/wifi/wpa_supplicant.conf文件中,直接用vi编辑,vi /etc/wifi/wpa_supplicant.conf ctrl_interface=/etc/wifi/socketsctrl_interface_group=0disable_scan_offload=1update_config=1network={ ssid="YourSSID" psk="YourPassword"}YourSSID替换成自己的wifi网络名,YourPassword改为自己的密码。
方法三
方法二使用wpa_cli工具,熟悉的用户可以选择这种方式 扫描wifi网络
wpa_cli -iwlan0 scan
获取扫描结果
wpa_cli -iwlan0 scan_result
添加网络
wpa_cli -iwlan0 add_network
记住返回的数字,这个是网络配置序号,后续要用到,假如返回的是“1”,后面以“1”为举例。
设置ssid
wpa_cli -iwlan0 set_network 1 ssid '"YourSsid"'
注意:无线网络名需要用一个单引号加一个双引号包含住。
wpa_cli -iwlan0 set_network 1 psk '"YourPassword"'注意:密码需要用一个单引号加一个双引号包含住。 wpa_cli -iwlan0 enable_network 1wpa_cli -iwlan0 save_config用于下次开机自动重连 wpa_cli -iwlan0 status 有COMPLETED字段表示ok freq=2437ssid=xxxxxxid=0mode=stationpairwise_cipher=CCMPgroup_cipher=CCMPkey_mgmt=WPA2-PSKwpa_state=COMPLETEDip_address=172.16.0.167address=94:f7:f9:9a:40:68uuid=53f24614-85b0-5e32-b3d1-9bac85a5958cudhcpc -iwlan0
开发环境搭建
MacOS, Linux,(Windows支持中)
vscode安装
vscode安装请自行下载安装
脚手架安装
输入命令npm i waft-cli -g
- sun@sun-ubuntu:~$ npm i waft-cli -g
- ^[^A[..................] - fetchMetadata: sill resolveWithNewModule waft-devtoolnpm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
- npm WARN deprecated @types/ora@3.2.0: This is a stub types definition. ora provides its own type definitions, so you do not need this installed.
- npm WARN deprecated @types/stylelint@14.0.0: This is a stub types definition. stylelint provides its own type definitions, so you do not need this installed.
- npm WARN deprecated @types/colors@1.2.1: This is a stub types definition. colors provides its own type definitions, so you don't need this installed.
- npm WARN deprecated loadsh@0.0.4: This is a typosquat on the popular Lodash package. This is not maintained nor is the original Lodash package.
- npm WARN deprecated @types/table@6.3.2: This is a stub types definition. table provides its own type definitions, so you do not need this installed.
- [ ...............] - fetchMetadata: sill resolveWithNewModule callsites[ .npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
- npm WARN deprecated har-validator@5.1.5: this library is no longer supported
- /opt/node-v14.15.4-linux-x64/bin/waft -> /opt/node-v14.15.4-linux-x64/lib/node_modules/waft-cli/bin/waft
- > core-js-pure@3.21.1 postinstall /opt/node-v14.15.4-linux-x64/lib/node_modules/waft-cli/node_modules/core-js-pure
- > node -e "try{require('./postinstall')}catch(e){}"
- Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
- The project needs your help! Please consider supporting of core-js:
- > https://opencollective.com/core-js
- > https://patreon.com/zloirock
- > https://paypal.me/zloirock
- > bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz
- Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
- + waft-cli@0.7.18
- added 886 packages from 513 contributors in 1642.959s
复制代码 这样就安装好了,安装过程有点长
如果有权限问题,加上sudo ,sudo npm i waft-cli -g。
创建项目
通过waft脚手架初始化项目,会引导您进行项目命名等,您将得到一个新project [code]sun@sun-ubuntu:~$ mkdir waft
sun@sun-ubuntu:~$ cd waft
sun@sun-ubuntu:~/waft$ waft init
? What's project name? hello_waft
? Which template package to from? waft-hello-world
|