[bsp][amebaz] BSP工程更新,适配新的WLAN框架

This commit is contained in:
tyx authored and tangyuxin committed 2018-10-21 23:41:59 +08:00
1 parent 1699a12b15
commit 646cb6cabc
24 files changed
+1437 -13239

No files matched your search

+119 -21
View File
File diff suppressed because it is too large. Load diff
+1 -5
View File
@@ -26,10 +26,6 @@ config $ENV_DIR
source "$RTT_DIR/Kconfig"
source "$PKGS_DIR/Kconfig"
source "$ENV_DIR/tools/scripts/cmds/Kconfig"
config RT_USING_UART0
bool "Using RT_USING_UART0"
default y
source "$BSP_DIR/drivers/Kconfig"
select PKG_USING_REALTEK_AMEBA
+98 -29
View File
@@ -17,8 +17,8 @@ amebaz 是由Realtek推出的Cortex-M4内核的WiFi SOC芯片rtl8710b系列
| 环境 | 说明 |
| ------------ | ------------------------------------------------------------ |
| PC操作系统 | Linux/MacOS/Windows |
| 编译器 | arm-none-eabi-gcc version 6.3.1 20170620 (release)/iar |
| 构建工具 | scons/iar |
| 编译器 | arm-none-eabi-gcc version 6.3.1 20170620 (release) |
| 构建工具 | scons |
| 依赖软件环境 | Env工具/(IAR或arm-none-eabi-gcc)/git/调试器驱动 |
1) 下载源码
@@ -40,9 +40,9 @@ amebaz 是由Realtek推出的Cortex-M4内核的WiFi SOC芯片rtl8710b系列
(Windows)
>在[RT-Thread官网][1]下载ENV工具包
>在[RT-Thread官网][1]下载ENV工具包,并参考官网给出的env使用教程
3) 配置芯片型号
3) 配置工程(可选)
(Linux/Mac)
@@ -56,8 +56,6 @@ amebaz 是由Realtek推出的Cortex-M4内核的WiFi SOC芯片rtl8710b系列
menuconfig
```
在menuconfig页面配置并选择对应的芯片型号,若开发环境为IAR,则需要生成工程
4) 下载package
amebaz配套的驱动库以package形式提供,故需先下载对应的package(realtek-ameba),请使用env下载package
@@ -66,28 +64,11 @@ amebaz配套的驱动库以package形式提供,故需先下载对应的package
pkgs --update
```
5) 生成工程(Mac/Linux下请跳过此步骤)
*该板级支持包不支持生成mdk的工程及iar工程,后续会支持iar工程
(Windows IAR)
5) 编译
```bash
SET RTT_CC=iar
scons --target=iar -s
```
*该板级支持包不支持生成mdk的工程
6) 编译
使用IAR请参见对应教程
(Windows arm-none-eabi-gcc)
使用以下指令设置gcc路径
```bash
SET RTT_EXEC_PATH=[GCC路径]
```
Windows可以使用env编译工程,无需设置GCC工具链路径,直接在bsp/amebaz工程目录下编译即可。
(Linux/Mac arm-none-eabi-gcc)
使用以下指令设置gcc路径
@@ -148,15 +129,103 @@ msh />
*默认串口
## 4. WIFI简单使用
## 4. 驱动支持情况及计划
### 4.1 wifi扫描命令
wifi 扫描命令格式如下
```unknown
wifi scan
```
命令说明
| 字段 | 描述 |
| ---- | ------------------------ |
| wifi | 有关wifi命令都以wifi开头 |
| scan | wifi执行扫描动作 |
在调试工具中输入该命令,即可进行 wifi 命令扫描,调试信息如下
```unknown
scan ap down
SSID MAC security rssi chn Mbps
------------------------------- ----------------- -------------- ---- --- ----
NEO-shanghai-ap2 58:66:ba:a1:ee:71 WPA2_TKIP_PSK -74 11 0
WQ1 88:25:93:94:51:54 WPA2_AES_PSK -76 13 0
shyc1 a0:40:a0:a3:e8:c9 WPA2_AES_PSK -77 13 0
KVIP 70:65:82:3b:71:43 WPA2_AES_PSK -83 11 0
YST2016 88:25:93:c6:67:d1 WPA2_TKIP_PSK -84 4 0
```
> 注:
>
> 测试命令有关 wifi,均以wifi开头。
### 4.2 wifi 接入
接入 wifi 之前,先介绍一下其接入的命令 ,如下
```unknown
wifi join ssid 123456789
```
命令说明
| 字段 | 描述 |
| --------- | ---------------------------------- |
| wifi | 有关wifi命令都以wifi开头 |
| join | wifi执行连接动作 |
| ssid | 热点的名字 |
| 123456789 | 热点的密码,没有密码可不输入这一项 |
了解上述命令,并且成功完成前面步骤,在串口中输入 `wifi w0 join realthread_VIP 123456789` ,如下日志表示连接成功
```unknown
WIFI wlan0 Setting:
==============================
MODE => STATION
SSID => realthread_VIP
CHANNEL => 6
SECURITY => AES
PASSWORD => 123456789
[I/WLAN.mgnt] wifi connect success ssid:realthread_VIP
```
另外,提供一个简单的测试使用命令,查询设备IP地址命令:ifconfig。
```unknown
network interface: w0 (Default)
MTU: 1500
MAC: 00 e0 4c d5 ac 46
FLAGS: UP LINK_UP ETHARP BROADCAST
ip address: 172.16.200.110
gw address: 172.16.200.1
net mask : 255.255.255.0
dns server #0: 172.16.200.1
dns server #1: 223.5.5.5
```
## 5. 驱动支持情况及计划
| 驱动 | 支持情况 | 备注 |
| ---------- | :------: | :--------------------------: |
| UART | 支持 | UART0 |
| UART | 支持 | UART0 |
| WLAN | 部分支持 | 仅支持STA模式 |
## 6. 已知问题
## 5. 联系人信息
wlan仅支持STA模式,连接WIFI输入错误密码时,会宕机。
## 7. 联系人信息
维护人:
[flyingcys][4] < [flyingcys@163.com][5] >
+2 -9
View File
@@ -15,19 +15,12 @@
#include <rthw.h>
#include <rtthread.h>
/**
* @addtogroup ameba
*/
/*@{*/
#include <rtdevice.h>
int main(void)
{
rt_kprintf("build time: %s %s\n", __DATE__, __TIME__);
rt_kprintf("Hello RT-Thread!\n");
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
return 0;
}
/*@}*/
+9
View File
@@ -0,0 +1,9 @@
config BSP_USING_UART0
bool "Using UART0"
select RT_USING_SERIAL
default y
config BSP_USING_WIFI
bool "Using WIFI"
select RT_USING_WIFI
default y
+3 -8
View File
@@ -5,14 +5,9 @@ list = os.listdir(cwd)
objs = []
src = Split('''
board.c
drv_uart.c
''')
if GetDepend(['RT_USING_LWIP']):
src += Split('''
drv_wifi.c
''')
board.c
drv_uart.c
''')
CPPPATH = [cwd]
+4 -4
View File
@@ -37,7 +37,7 @@ struct device_uart
rt_uint32_t irqno;
};
#ifdef RT_USING_UART0
#ifdef BSP_USING_UART0
static struct rt_serial_device serial0;
static struct device_uart uart0;
#endif
@@ -230,16 +230,16 @@ int rt_hw_uart_init(void)
struct rt_serial_device *serial;
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
#ifdef RT_USING_UART0
#ifdef BSP_USING_UART0
{
struct device_uart *uart;
serial = &serial0;
uart = &uart0;
/* Init UART Hardware */
serial_init(&uart->serial, UART_TX, UART_RX);
serial->ops = &_uart_ops;
serial->config = config;
serial->config.baud_rate = 115200;
File diff suppressed because it is too large. Load diff
+5 -4
View File
@@ -6,10 +6,11 @@ CPPPATH = [cwd, str(Dir('#'))]
src = []
if GetDepend(['RT_USING_LWIP']):
src += Split('''
amebaz_wlan.c
''')
src += Split('''
drv_wifi.c
drv_wlan.c
''')
group = DefineGroup('amebaz_wlan', src, depend = [''], CPPPATH = CPPPATH)
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
File diff suppressed because it is too large. Load diff
-54
View File
@@ -1,54 +0,0 @@
/*
* File : amebaz_wlan.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2017-5-30 Bernard the first version
* 2018-6-12 flyingcys add amebaz wlan interface
*/
#ifndef __AMEBAZ_WLAN_H__
#define __AMEBAZ_WLAN_H__
int amebaz_wifi_scan();
void amebaz_wifi_info_init(void);
int amebaz_wifi_set_sta_info(char *ssid, char *passwd);
int amebaz_wifi_set_ap_info(char *ssid, char *passwd);
int amebaz_wifi_connect(char *ssid, char *passwd);
int amebaz_wifi_disconnect(void);
int amebaz_wifi_ap_start(char *ssid, char *passwd, int channel);
int amebaz_wifi_ap_stop(void);
int amebaz_wifi_get_rssi(void);
void amebaz_wifi_set_channel(int channel);
int amebaz_wifi_get_channel(void);
int amebaz_wifi_init(rt_wlan_mode_t mode);
#endif /* __AMEBAZ_WLAN_H__ */
File diff suppressed because it is too large. Load diff
@@ -25,7 +25,7 @@
#ifndef __DRV_WIFI_H__
#define __DRV_WIFI_H__
int rt_hw_wifi_init(void);
int rthw_wifi_low_init(void);
#endif /* __DRV_WIFI_H__ */
File diff suppressed because it is too large. Load diff
+101
View File
@@ -0,0 +1,101 @@
/*
* File : drv_wlan.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2018-7-10 tyx the first version
*/
#ifndef __DRV_WLAN_H__
#define __DRV_WLAN_H__
#include <rtthread.h>
typedef enum
{
RTHW_MODE_NONE = 0,
RTHW_MODE_STA,
RTHW_MODE_AP,
RTHW_MODE_STA_AP,
RTHW_MODE_PROMISC,
RTHW_MODE_P2P
}rthw_mode_t;
#define SHARED_ENABLED 0x00008000
#define WPA_SECURITY 0x00200000
#define WPA2_SECURITY 0x00400000
#define WPS_ENABLED 0x10000000
#define WEP_ENABLED 0x0001
#define TKIP_ENABLED 0x0002
#define AES_ENABLED 0x0004
#define WSEC_SWFLAG 0x0008
typedef enum {
RTHW_SECURITY_OPEN = 0, /**< Open security */
RTHW_SECURITY_WEP_PSK = WEP_ENABLED, /**< WEP Security with open authentication */
RTHW_SECURITY_WEP_SHARED = ( WEP_ENABLED | SHARED_ENABLED ), /**< WEP Security with shared authentication */
RTHW_SECURITY_WPA_TKIP_PSK = ( WPA_SECURITY | TKIP_ENABLED ), /**< WPA Security with TKIP */
RTHW_SECURITY_WPA_AES_PSK = ( WPA_SECURITY | AES_ENABLED ), /**< WPA Security with AES */
RTHW_SECURITY_WPA2_AES_PSK = ( WPA2_SECURITY | AES_ENABLED ), /**< WPA2 Security with AES */
RTHW_SECURITY_WPA2_TKIP_PSK = ( WPA2_SECURITY | TKIP_ENABLED ), /**< WPA2 Security with TKIP */
RTHW_SECURITY_WPA2_MIXED_PSK = ( WPA2_SECURITY | AES_ENABLED | TKIP_ENABLED ), /**< WPA2 Security with AES & TKIP */
RTHW_SECURITY_WPA_WPA2_MIXED = ( WPA_SECURITY | WPA2_SECURITY ), /**< WPA/WPA2 Security */
RTHW_SECURITY_WPS_OPEN = WPS_ENABLED, /**< WPS with open security */
RTHW_SECURITY_WPS_SECURE = (WPS_ENABLED | AES_ENABLED), /**< WPS with AES security */
RTHW_SECURITY_UNKNOWN = -1, /**< May be returned by scan function if security is unknown. Do not pass this to the join function! */
RTHW_SECURITY_FORCE_32_BIT = 0x7fffffff /**< Exists only to force rtw_security_t type to 32 bits */
} rthw_security_t;
typedef enum {
RTHW_802_11_BAND_5GHZ = 0, /**< Denotes 5GHz radio band */
RTHW_802_11_BAND_2_4GHZ = 1 /**< Denotes 2.4GHz radio band */
} rthw_802_11_band_t;
struct rthw_wlan_info
{
char *ssid;
rt_uint8_t *bssid;
rthw_802_11_band_t band;
rt_uint32_t datarate;
rt_uint16_t channel;
rt_int16_t rssi;
rthw_security_t security;
};
typedef void (*scan_callback_fn)(struct rthw_wlan_info *info, void *user_data);
typedef void (*rthw_wlan_monitor_callback_t)(rt_uint8_t *data, int len, void *user_data);
rthw_mode_t rthw_wifi_mode_get(void);
int rthw_wifi_stop(void);
int rthw_wifi_start(rthw_mode_t mode);
int rthw_wifi_connect(char *ssid, int ssid_len, char *password, int pass_len, rthw_security_t security_type);
int rthw_wifi_connect_bssid(char *bssid, char *ssid, int ssid_len, char *password, int pass_len, rthw_security_t security_type);
int rthw_wifi_ap_start(char *ssid, char *password, int channel);
int rthw_wifi_rssi_get(void);
void rthw_wifi_channel_set(int channel);
int rthw_wifi_channel_get(void);
int rthw_wifi_sta_disconnect(void);
int rthw_wifi_ap_disconnect(void);
int rthw_wifi_scan(scan_callback_fn fun, void *data);
void rthw_wifi_monitor_enable(int enable);
void rthw_wifi_monitor_callback_set(rthw_wlan_monitor_callback_t callback);
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-10
View File
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<workspace>
<project>
<path>$WS_DIR$\project.ewp</path>
</project>
<batchBuild/>
</workspace>
+48 -11
View File
@@ -11,15 +11,14 @@
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 1000
#define RT_DEBUG
#define RT_USING_OVERFLOW_CHECK
#define RT_DEBUG_INIT 0
#define RT_DEBUG_THREAD 0
#define RT_USING_HOOK
#define RT_IDEL_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 256
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512
#define RT_DEBUG
/* Inter-Thread communication */
@@ -45,6 +44,9 @@
/* RT-Thread Components */
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
#define RT_MAIN_THREAD_PRIORITY 10
/* C++ features */
@@ -62,6 +64,7 @@
#define FINSH_CMD_SIZE 80
#define FINSH_USING_MSH
#define FINSH_USING_MSH_DEFAULT
#define FINSH_USING_MSH_ONLY
#define FINSH_ARG_MAX 10
/* Device virtual file system */
@@ -70,13 +73,27 @@
/* Device Drivers */
#define RT_USING_DEVICE_IPC
#define RT_PIPE_BUFSZ 512
#define RT_USING_SERIAL
#define RT_USING_PIN
/* Using WiFi */
#define RT_USING_WIFI
#define RT_USING_WLAN_STA
#define RT_USING_WLAN_AP
#define WIFI_DEVICE_STA_NAME "w0"
#define WIFI_DEVICE_AP_NAME "ap"
#define RT_WLAN_DEVICE_STA_NAME "wlan0"
#define RT_WLAN_DEVICE_AP_NAME "wlan1"
#define RT_WLAN_DEFAULT_PROT "lwip"
#define RT_WLAN_SCAN_WAIT_MS 10000
#define RT_WLAN_CONNECT_WAIT_MS 10000
#define RT_WLAN_SSID_MAX_LENGTH 32
#define RT_WLAN_PASSWORD_MAX_LENGTH 32
#define RT_WLAN_SCAN_SORT
#define RT_WLAN_CFG_INFO_MAX 3
#define RT_WLAN_WORKQUEUE_THREAD_NAME "wlan_job"
#define RT_WLAN_WORKQUEUE_THREAD_SIZE 2048
#define RT_WLAN_WORKQUEUE_THREAD_PRIO 22
#define RT_WLAN_DEV_EVENT_NUM 2
#define RT_WLAN_DEBUG
#define RT_WLAN_CMD_DEBUG
/* Using USB */
@@ -85,12 +102,15 @@
#define RT_USING_LIBC
/* Network stack */
/* Network */
/* Socket abstraction layer */
/* light weight TCP/IP stack */
#define RT_USING_LWIP
#define RT_USING_LWIP141
#define RT_USING_LWIP202
#define RT_LWIP_IGMP
#define RT_LWIP_ICMP
#define RT_LWIP_DNS
@@ -129,6 +149,9 @@
/* Modbus master and slave stack */
/* AT commands */
/* VBUS(Virtual Software BUS) */
@@ -148,6 +171,9 @@
/* Wiced WiFi */
/* IoT Cloud */
/* security packages */
@@ -173,12 +199,23 @@
/* sample package */
/* samples: kernel and components samples */
/* example package: hello */
/* Privated Packages of RealThread */
/* Network Utilities */
/* Test Packages of RealThread */
/* Env config */
#define RT_USING_UART0
#define BSP_USING_WIFI
#endif
+8 -3
View File
@@ -9,12 +9,17 @@ if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.join(os.path.normpath(os.getcwd()), 'rt-thread')
# cross_tool provides the cross compiler
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
EXEC_PATH = r'/opt/gcc-arm-none-eabi-5_4-2016q3/bin'
EXEC_PATH = 'C:/work/env/tools/gnu_gcc/arm_gcc/mingw/bin'
elif CROSS_TOOL == 'iar':
PLATFORM = 'iar'
EXEC_PATH = 'C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0'
else:
print 'Please make sure your toolchains is GNU GCC!'
exit(0)
@@ -39,7 +44,7 @@ if PLATFORM == 'gcc':
NM = PREFIX + 'nm'
DEVICE = ' -DM3 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections'
CFLAGS = DEVICE + ' -g2 -w -O2 -Wno-pointer-sign -fno-common -fmessage-length=0 -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-short-enums -DF_CPU=166000000L -std=gnu99 -fsigned-char'
CFLAGS = DEVICE + ' -g2 -Wall -Wno-pointer-sign -fno-common -fmessage-length=0 -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-short-enums -DF_CPU=166000000L -std=gnu99 -fsigned-char'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb '
LFLAGS = DEVICE + ' -lm -lgcc -lc' + ' -g --specs=nano.specs -nostartfiles -Wl,-Map=rtthread.map -Os -Wl,--gc-sections -Wl,--cref -Wl,--entry=Reset_Handler -Wl,--no-enum-size-warning -Wl,--no-wchar-size-warning -T./rlx8711B-symbol-v02-img2_xip1.ld'
LFLAGS += ' -Wl,-wrap,rtl_printf'
@@ -48,7 +53,7 @@ if PLATFORM == 'gcc':
LPATH = ''
if BUILD == 'debug':
CFLAGS += ' -O0 -gdwarf-2'
CFLAGS += ' -Os -gdwarf-2'
AFLAGS += ' -gdwarf-2'
else:
CFLAGS += ' -O2'
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-21
View File
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<flash_board>
<pass>
<range>CODE 0x8000000 0x8004fff</range>
<loader>$PROJ_DIR$\packages\realtek_ameba-latest\sdk-ameba-v4.0b_without_NDA_GCC_V1.0.0\component\soc\realtek\8711b\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
<abs_offset>0x00000000</abs_offset>
</pass>
<pass>
<range>CODE 0x800b020 0x807ffff</range>
<loader>$PROJ_DIR$\packages\realtek_ameba-latest\sdk-ameba-v4.0b_without_NDA_GCC_V1.0.0\component\soc\realtek\8711b\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
<abs_offset>0xb020</abs_offset>
</pass>
<pass>
<range>CODE 0x10005000 0x10005A6B</range>
<loader>$PROJ_DIR$\packages\realtek_ameba-latest\sdk-ameba-v4.0b_without_NDA_GCC_V1.0.0\component\soc\realtek\8711b\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
<abs_offset>0xb000</abs_offset>
<args>--concat</args>
</pass>
<ignore>CODE 0x10005a6c 0x1003dfff</ignore>
</flash_board>