[bsp]add bl808 wifi driver (#8294)

This commit is contained in:
flyingcys 2023-11-25 22:54:24 +08:00 committed by GitHub
parent 0396b52db0
commit 50f521b528
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1046 additions and 46 deletions

View File

@ -201,6 +201,7 @@ Windows下推荐使用[env工具][1]在console下进入bsp/bouffalo_lab/bl61x
| HWTIMER | 支持 | | | HWTIMER | 支持 | |
| FLASH | 支持 | | | FLASH | 支持 | |
| SDCARD | 支持 | | | SDCARD | 支持 | |
| Wi-Fi | 支持 | 仅 BL808 支持 |

238
bsp/bouffalo_lab/bl808/m0/.config Normal file → Executable file
View File

@ -6,10 +6,11 @@
# #
# RT-Thread Kernel # RT-Thread Kernel
# #
CONFIG_RT_NAME_MAX=8 CONFIG_RT_NAME_MAX=16
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set # CONFIG_RT_USING_ARCH_DATA_TYPE is not set
# CONFIG_RT_USING_AMP is not set # CONFIG_RT_USING_AMP is not set
# CONFIG_RT_USING_SMP is not set # CONFIG_RT_USING_SMP is not set
CONFIG_RT_CPUS_NR=1
CONFIG_RT_ALIGN_SIZE=8 CONFIG_RT_ALIGN_SIZE=8
# CONFIG_RT_THREAD_PRIORITY_8 is not set # CONFIG_RT_THREAD_PRIORITY_8 is not set
CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_32=y
@ -21,10 +22,10 @@ CONFIG_RT_USING_HOOK=y
CONFIG_RT_HOOK_USING_FUNC_PTR=y CONFIG_RT_HOOK_USING_FUNC_PTR=y
CONFIG_RT_USING_IDLE_HOOK=y CONFIG_RT_USING_IDLE_HOOK=y
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=1024 CONFIG_IDLE_THREAD_STACK_SIZE=2048
CONFIG_RT_USING_TIMER_SOFT=y CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4 CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=512 CONFIG_RT_TIMER_THREAD_STACK_SIZE=2048
# #
# kservice optimization # kservice optimization
@ -37,7 +38,7 @@ CONFIG_RT_KSERVICE_USING_STDLIB=y
CONFIG_RT_USING_DEBUG=y CONFIG_RT_USING_DEBUG=y
CONFIG_RT_DEBUGING_COLOR=y CONFIG_RT_DEBUGING_COLOR=y
CONFIG_RT_DEBUGING_CONTEXT=y CONFIG_RT_DEBUGING_CONTEXT=y
# CONFIG_RT_DEBUGING_INIT is not set # CONFIG_RT_DEBUGING_AUTO_INIT is not set
# #
# Inter-Thread communication # Inter-Thread communication
@ -65,19 +66,15 @@ CONFIG_RT_USING_SMALL_MEM_AS_HEAP=y
# CONFIG_RT_USING_MEMTRACE is not set # CONFIG_RT_USING_MEMTRACE is not set
# CONFIG_RT_USING_HEAP_ISR is not set # CONFIG_RT_USING_HEAP_ISR is not set
CONFIG_RT_USING_HEAP=y CONFIG_RT_USING_HEAP=y
#
# Kernel Device Object
#
CONFIG_RT_USING_DEVICE=y CONFIG_RT_USING_DEVICE=y
# CONFIG_RT_USING_DEVICE_OPS is not set # CONFIG_RT_USING_DEVICE_OPS is not set
# CONFIG_RT_USING_DM is not set
# CONFIG_RT_USING_INTERRUPT_INFO is not set # CONFIG_RT_USING_INTERRUPT_INFO is not set
CONFIG_RT_USING_CONSOLE=y CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLEBUF_SIZE=512
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0" CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
CONFIG_RT_VER_NUM=0x50002 CONFIG_RT_VER_NUM=0x50100
# CONFIG_RT_USING_STDC_ATOMIC is not set # CONFIG_RT_USING_STDC_ATOMIC is not set
CONFIG_RT_BACKTRACE_LEVEL_MAX_NR=32
# CONFIG_RT_USING_CACHE is not set # CONFIG_RT_USING_CACHE is not set
# CONFIG_RT_USING_HW_ATOMIC is not set # CONFIG_RT_USING_HW_ATOMIC is not set
# CONFIG_ARCH_ARM_BOOTWITH_FLUSH_CACHE is not set # CONFIG_ARCH_ARM_BOOTWITH_FLUSH_CACHE is not set
@ -148,20 +145,25 @@ CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512
# CONFIG_RT_DFS_ELM_USE_ERASE is not set # CONFIG_RT_DFS_ELM_USE_ERASE is not set
CONFIG_RT_DFS_ELM_REENTRANT=y CONFIG_RT_DFS_ELM_REENTRANT=y
CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
# CONFIG_RT_DFS_ELM_USE_EXFAT is not set
CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DFS_DEVFS=y
CONFIG_RT_USING_DFS_ROMFS=y CONFIG_RT_USING_DFS_ROMFS=y
# CONFIG_RT_USING_DFS_CROMFS is not set # CONFIG_RT_USING_DFS_CROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set # CONFIG_RT_USING_DFS_RAMFS is not set
# CONFIG_RT_USING_DFS_TMPFS is not set # CONFIG_RT_USING_DFS_TMPFS is not set
# CONFIG_RT_USING_DFS_MQUEUE is not set # CONFIG_RT_USING_DFS_MQUEUE is not set
# CONFIG_RT_USING_DFS_NFS is not set
# CONFIG_RT_USING_FAL is not set # CONFIG_RT_USING_FAL is not set
# #
# Device Drivers # Device Drivers
# #
# CONFIG_RT_USING_DM is not set
CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_UNAMED_PIPE_NUMBER=64 CONFIG_RT_UNAMED_PIPE_NUMBER=64
# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=8192
CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23
CONFIG_RT_USING_SERIAL=y CONFIG_RT_USING_SERIAL=y
CONFIG_RT_USING_SERIAL_V1=y CONFIG_RT_USING_SERIAL_V1=y
# CONFIG_RT_USING_SERIAL_V2 is not set # CONFIG_RT_USING_SERIAL_V2 is not set
@ -182,7 +184,6 @@ CONFIG_RT_USING_PWM=y
# CONFIG_RT_USING_MTD_NOR is not set # CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set # CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_PM is not set # CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_FDT is not set
CONFIG_RT_USING_RTC=y CONFIG_RT_USING_RTC=y
# CONFIG_RT_USING_ALARM is not set # CONFIG_RT_USING_ALARM is not set
# CONFIG_RT_USING_SOFT_RTC is not set # CONFIG_RT_USING_SOFT_RTC is not set
@ -203,7 +204,33 @@ CONFIG_RT_USING_WDT=y
# CONFIG_RT_USING_PULSE_ENCODER is not set # CONFIG_RT_USING_PULSE_ENCODER is not set
# CONFIG_RT_USING_INPUT_CAPTURE is not set # CONFIG_RT_USING_INPUT_CAPTURE is not set
# CONFIG_RT_USING_DEV_BUS is not set # CONFIG_RT_USING_DEV_BUS is not set
# CONFIG_RT_USING_WIFI is not set CONFIG_RT_USING_WIFI=y
CONFIG_RT_WLAN_DEVICE_STA_NAME="wlan0"
CONFIG_RT_WLAN_DEVICE_AP_NAME="wlan1"
CONFIG_RT_WLAN_SSID_MAX_LENGTH=32
CONFIG_RT_WLAN_PASSWORD_MAX_LENGTH=32
CONFIG_RT_WLAN_DEV_EVENT_NUM=2
CONFIG_RT_WLAN_MANAGE_ENABLE=y
CONFIG_RT_WLAN_SCAN_WAIT_MS=10000
CONFIG_RT_WLAN_CONNECT_WAIT_MS=10000
CONFIG_RT_WLAN_SCAN_SORT=y
CONFIG_RT_WLAN_MSH_CMD_ENABLE=y
CONFIG_RT_WLAN_AUTO_CONNECT_ENABLE=y
CONFIG_AUTO_CONNECTION_PERIOD_MS=2000
CONFIG_RT_WLAN_CFG_ENABLE=y
CONFIG_RT_WLAN_CFG_INFO_MAX=3
CONFIG_RT_WLAN_PROT_ENABLE=y
CONFIG_RT_WLAN_PROT_NAME_LEN=8
CONFIG_RT_WLAN_PROT_MAX=2
CONFIG_RT_WLAN_DEFAULT_PROT="lwip"
CONFIG_RT_WLAN_PROT_LWIP_ENABLE=y
CONFIG_RT_WLAN_PROT_LWIP_NAME="lwip"
CONFIG_RT_WLAN_PROT_LWIP_PBUF_FORCE=y
CONFIG_RT_WLAN_WORK_THREAD_ENABLE=y
CONFIG_RT_WLAN_WORKQUEUE_THREAD_NAME="wlan"
CONFIG_RT_WLAN_WORKQUEUE_THREAD_SIZE=8192
CONFIG_RT_WLAN_WORKQUEUE_THREAD_PRIO=15
# CONFIG_RT_WLAN_DEBUG is not set
# CONFIG_RT_USING_VIRTIO is not set # CONFIG_RT_USING_VIRTIO is not set
# CONFIG_RT_USING_KTIME is not set # CONFIG_RT_USING_KTIME is not set
@ -234,7 +261,17 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# #
# POSIX (Portable Operating System Interface) layer # POSIX (Portable Operating System Interface) layer
# #
# CONFIG_RT_USING_POSIX_FS is not set CONFIG_RT_USING_POSIX_FS=y
# CONFIG_RT_USING_POSIX_DEVIO is not set
# CONFIG_RT_USING_POSIX_STDIO is not set
CONFIG_RT_USING_POSIX_POLL=y
CONFIG_RT_USING_POSIX_SELECT=y
# CONFIG_RT_USING_POSIX_EVENTFD is not set
# CONFIG_RT_USING_POSIX_TIMERFD is not set
CONFIG_RT_USING_POSIX_SOCKET=y
# CONFIG_RT_USING_POSIX_TERMIOS is not set
# CONFIG_RT_USING_POSIX_AIO is not set
# CONFIG_RT_USING_POSIX_MMAN is not set
# CONFIG_RT_USING_POSIX_DELAY is not set # CONFIG_RT_USING_POSIX_DELAY is not set
# CONFIG_RT_USING_POSIX_CLOCK is not set # CONFIG_RT_USING_POSIX_CLOCK is not set
# CONFIG_RT_USING_POSIX_TIMER is not set # CONFIG_RT_USING_POSIX_TIMER is not set
@ -256,9 +293,87 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# #
# Network # Network
# #
# CONFIG_RT_USING_SAL is not set CONFIG_RT_USING_SAL=y
# CONFIG_RT_USING_NETDEV is not set CONFIG_SAL_INTERNET_CHECK=y
# CONFIG_RT_USING_LWIP is not set
#
# Docking with protocol stacks
#
CONFIG_SAL_USING_LWIP=y
# CONFIG_SAL_USING_AT is not set
CONFIG_SAL_USING_TLS=y
CONFIG_SAL_USING_POSIX=y
# CONFIG_SAL_USING_AF_UNIX is not set
CONFIG_RT_USING_NETDEV=y
CONFIG_NETDEV_USING_IFCONFIG=y
CONFIG_NETDEV_USING_PING=y
CONFIG_NETDEV_USING_NETSTAT=y
CONFIG_NETDEV_USING_AUTO_DEFAULT=y
# CONFIG_NETDEV_USING_IPV6 is not set
CONFIG_NETDEV_IPV4=1
CONFIG_NETDEV_IPV6=0
# CONFIG_NETDEV_IPV6_SCOPES is not set
CONFIG_RT_USING_LWIP=y
# CONFIG_RT_USING_LWIP_LOCAL_VERSION is not set
# CONFIG_RT_USING_LWIP141 is not set
# CONFIG_RT_USING_LWIP203 is not set
CONFIG_RT_USING_LWIP212=y
# CONFIG_RT_USING_LWIP_LATEST is not set
CONFIG_RT_USING_LWIP_VER_NUM=0x20102
# CONFIG_RT_USING_LWIP_IPV6 is not set
CONFIG_RT_LWIP_MEM_ALIGNMENT=4
CONFIG_RT_LWIP_IGMP=y
CONFIG_RT_LWIP_ICMP=y
# CONFIG_RT_LWIP_SNMP is not set
CONFIG_RT_LWIP_DNS=y
CONFIG_RT_LWIP_DHCP=y
CONFIG_IP_SOF_BROADCAST=1
CONFIG_IP_SOF_BROADCAST_RECV=1
#
# Static IPv4 Address
#
CONFIG_RT_LWIP_IPADDR="192.168.1.30"
CONFIG_RT_LWIP_GWADDR="192.168.1.1"
CONFIG_RT_LWIP_MSKADDR="255.255.255.0"
CONFIG_RT_LWIP_UDP=y
CONFIG_RT_LWIP_TCP=y
CONFIG_RT_LWIP_RAW=y
# CONFIG_RT_LWIP_PPP is not set
CONFIG_RT_MEMP_NUM_NETCONN=8
CONFIG_RT_LWIP_PBUF_NUM=16
CONFIG_RT_LWIP_RAW_PCB_NUM=4
CONFIG_RT_LWIP_UDP_PCB_NUM=4
CONFIG_RT_LWIP_TCP_PCB_NUM=4
CONFIG_RT_LWIP_TCP_SEG_NUM=40
CONFIG_RT_LWIP_TCP_SND_BUF=8196
CONFIG_RT_LWIP_TCP_WND=8196
CONFIG_RT_LWIP_TCPTHREAD_PRIORITY=10
CONFIG_RT_LWIP_TCPTHREAD_MBOX_SIZE=8
CONFIG_RT_LWIP_TCPTHREAD_STACKSIZE=4096
CONFIG_LWIP_NO_RX_THREAD=y
CONFIG_LWIP_NO_TX_THREAD=y
CONFIG_RT_LWIP_ETHTHREAD_PRIORITY=12
CONFIG_RT_LWIP_ETHTHREAD_STACKSIZE=4096
CONFIG_RT_LWIP_ETHTHREAD_MBOX_SIZE=8
# CONFIG_RT_LWIP_REASSEMBLY_FRAG is not set
CONFIG_LWIP_NETIF_STATUS_CALLBACK=1
CONFIG_LWIP_NETIF_LINK_CALLBACK=1
CONFIG_SO_REUSE=1
CONFIG_LWIP_SO_RCVTIMEO=1
CONFIG_LWIP_SO_SNDTIMEO=1
CONFIG_LWIP_SO_RCVBUF=1
CONFIG_LWIP_SO_LINGER=0
# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set
CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_RT_LWIP_STATS is not set
# CONFIG_RT_LWIP_USING_HW_CHECKSUM is not set
CONFIG_RT_LWIP_USING_PING=y
CONFIG_LWIP_USING_DHCPD=y
CONFIG_DHCPD_SERVER_IP="192.168.169.1"
# CONFIG_DHCPD_USING_ROUTER is not set
# CONFIG_LWIP_USING_CUSTOMER_DNS_SERVER is not set
# CONFIG_RT_LWIP_DEBUG is not set
# CONFIG_RT_USING_AT is not set # CONFIG_RT_USING_AT is not set
# #
@ -273,6 +388,17 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_RT_USING_RT_LINK is not set # CONFIG_RT_USING_RT_LINK is not set
# CONFIG_RT_USING_VBUS is not set # CONFIG_RT_USING_VBUS is not set
#
# Memory management
#
# CONFIG_RT_USING_MEMBLOCK is not set
#
# Memory protection
#
# CONFIG_RT_USING_MEM_PROTECTION is not set
# CONFIG_RT_USING_HW_STACK_GUARD is not set
# #
# RT-Thread Utestcases # RT-Thread Utestcases
# #
@ -313,6 +439,20 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# #
# CONFIG_PKG_USING_WLAN_WICED is not set # CONFIG_PKG_USING_WLAN_WICED is not set
# CONFIG_PKG_USING_RW007 is not set # CONFIG_PKG_USING_RW007 is not set
#
# CYW43012 WiFi
#
# CONFIG_PKG_USING_WLAN_CYW43012 is not set
#
# BL808 WiFi
#
CONFIG_PKG_USING_WLAN_BL808=y
CONFIG_PKG_WLAN_BL808_PATH="/packages/iot/WiFi/wlan_bl808"
CONFIG_PKG_USING_WLAN_BL808_LATEST_VERSION=y
# CONFIG_PKG_USING_WLAN_BL808_V001 is not set
CONFIG_PKG_WLAN_BL808_VER="latest"
# CONFIG_PKG_USING_COAP is not set # CONFIG_PKG_USING_COAP is not set
# CONFIG_PKG_USING_NOPOLL is not set # CONFIG_PKG_USING_NOPOLL is not set
# CONFIG_PKG_USING_NETUTILS is not set # CONFIG_PKG_USING_NETUTILS is not set
@ -334,7 +474,6 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_JIOT-C-SDK is not set # CONFIG_PKG_USING_JIOT-C-SDK is not set
# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set # CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set
# CONFIG_PKG_USING_JOYLINK is not set # CONFIG_PKG_USING_JOYLINK is not set
# CONFIG_PKG_USING_EZ_IOT_OS is not set
# CONFIG_PKG_USING_IOTSHARP_SDK is not set # CONFIG_PKG_USING_IOTSHARP_SDK is not set
# CONFIG_PKG_USING_NIMBLE is not set # CONFIG_PKG_USING_NIMBLE is not set
# CONFIG_PKG_USING_LLSYNC_SDK_ADAPTER is not set # CONFIG_PKG_USING_LLSYNC_SDK_ADAPTER is not set
@ -355,6 +494,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_NMEALIB is not set # CONFIG_PKG_USING_NMEALIB is not set
# CONFIG_PKG_USING_PDULIB is not set # CONFIG_PKG_USING_PDULIB is not set
# CONFIG_PKG_USING_BTSTACK is not set # CONFIG_PKG_USING_BTSTACK is not set
# CONFIG_PKG_USING_BT_CYW43012 is not set
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set # CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set # CONFIG_PKG_USING_WAYZ_IOTKIT is not set
# CONFIG_PKG_USING_MAVLINK is not set # CONFIG_PKG_USING_MAVLINK is not set
@ -374,11 +514,45 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_ZFTP is not set # CONFIG_PKG_USING_ZFTP is not set
# CONFIG_PKG_USING_WOL is not set # CONFIG_PKG_USING_WOL is not set
# CONFIG_PKG_USING_ZEPHYR_POLLING is not set # CONFIG_PKG_USING_ZEPHYR_POLLING is not set
# CONFIG_PKG_USING_MATTER_ADAPTATION_LAYER is not set
# CONFIG_PKG_USING_LHC_MODBUS is not set
# #
# security packages # security packages
# #
# CONFIG_PKG_USING_MBEDTLS is not set CONFIG_PKG_USING_MBEDTLS=y
#
# Select Root Certificate
#
# CONFIG_PKG_USING_MBEDTLS_USE_ALL_CERTS is not set
# CONFIG_PKG_USING_MBEDTLS_USER_CERTS is not set
# CONFIG_PKG_USING_MBEDTLS_THAWTE_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_VERSIGN_PBULIC_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_VERSIGN_UNIVERSAL_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_GEOTRUST_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_DIGICERT_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_GODADDY_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_COMODOR_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_DST_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_CLOBALSIGN_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_ENTRUST_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_AMAZON_ROOT_CA is not set
# CONFIG_PKG_USING_MBEDTLS_CERTUM_TRUSTED_NETWORK_ROOT_CA is not set
CONFIG_MBEDTLS_AES_ROM_TABLES=y
CONFIG_MBEDTLS_ECP_WINDOW_SIZE=2
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=3584
# CONFIG_PKG_USING_MBEDTLS_EXAMPLE is not set
# CONFIG_PKG_USING_MBEDTLS_DEBUG is not set
CONFIG_PKG_MBEDTLS_PATH="/packages/security/mbedtls"
CONFIG_PKG_USING_MBEDTLS_V2281=y
# CONFIG_PKG_USING_MBEDTLS_V27102 is not set
# CONFIG_PKG_USING_MBEDTLS_V27101 is not set
# CONFIG_PKG_USING_MBEDTLS_V2710 is not set
# CONFIG_PKG_USING_MBEDTLS_V261 is not set
# CONFIG_PKG_USING_MBEDTLS_V260 is not set
# CONFIG_PKG_USING_MBEDTLS_LATEST_VERSION is not set
CONFIG_PKG_MBEDTLS_VER="v2.28.1"
# CONFIG_PKG_USING_LIBSODIUM is not set # CONFIG_PKG_USING_LIBSODIUM is not set
# CONFIG_PKG_USING_LIBHYDROGEN is not set # CONFIG_PKG_USING_LIBHYDROGEN is not set
# CONFIG_PKG_USING_TINYCRYPT is not set # CONFIG_PKG_USING_TINYCRYPT is not set
@ -420,7 +594,6 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# LVGL: powerful and easy-to-use embedded GUI library # LVGL: powerful and easy-to-use embedded GUI library
# #
# CONFIG_PKG_USING_LVGL is not set # CONFIG_PKG_USING_LVGL is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
# CONFIG_PKG_USING_LV_MUSIC_DEMO is not set # CONFIG_PKG_USING_LV_MUSIC_DEMO is not set
# CONFIG_PKG_USING_GUI_GUIDER_DEMO is not set # CONFIG_PKG_USING_GUI_GUIDER_DEMO is not set
@ -476,6 +649,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_CPU_USAGE is not set # CONFIG_PKG_USING_CPU_USAGE is not set
# CONFIG_PKG_USING_GBK2UTF8 is not set # CONFIG_PKG_USING_GBK2UTF8 is not set
# CONFIG_PKG_USING_VCONSOLE is not set # CONFIG_PKG_USING_VCONSOLE is not set
# CONFIG_PKG_USING_MBEDTLS_BENCH is not set
# CONFIG_PKG_USING_KDB is not set # CONFIG_PKG_USING_KDB is not set
# CONFIG_PKG_USING_WAMR is not set # CONFIG_PKG_USING_WAMR is not set
# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set # CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set
@ -495,6 +669,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_HASH_MATCH is not set # CONFIG_PKG_USING_HASH_MATCH is not set
# CONFIG_PKG_USING_ARMV7M_DWT_TOOL is not set # CONFIG_PKG_USING_ARMV7M_DWT_TOOL is not set
# CONFIG_PKG_USING_VOFA_PLUS is not set # CONFIG_PKG_USING_VOFA_PLUS is not set
# CONFIG_PKG_USING_ZDEBUG is not set
# #
# system packages # system packages
@ -531,6 +706,8 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_UC_COMMON is not set # CONFIG_PKG_USING_UC_COMMON is not set
# CONFIG_PKG_USING_UC_MODBUS is not set # CONFIG_PKG_USING_UC_MODBUS is not set
# CONFIG_PKG_USING_FREERTOS_WRAPPER is not set # CONFIG_PKG_USING_FREERTOS_WRAPPER is not set
# CONFIG_PKG_USING_LITEOS_SDK is not set
# CONFIG_PKG_USING_TZ_DATABASE is not set
# CONFIG_PKG_USING_CAIRO is not set # CONFIG_PKG_USING_CAIRO is not set
# CONFIG_PKG_USING_PIXMAN is not set # CONFIG_PKG_USING_PIXMAN is not set
# CONFIG_PKG_USING_PARTITION is not set # CONFIG_PKG_USING_PARTITION is not set
@ -554,6 +731,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_QBOOT is not set # CONFIG_PKG_USING_QBOOT is not set
# CONFIG_PKG_USING_PPOOL is not set # CONFIG_PKG_USING_PPOOL is not set
# CONFIG_PKG_USING_OPENAMP is not set # CONFIG_PKG_USING_OPENAMP is not set
# CONFIG_PKG_USING_RPMSG_LITE is not set
# CONFIG_PKG_USING_LPM is not set # CONFIG_PKG_USING_LPM is not set
# CONFIG_PKG_USING_TLSF is not set # CONFIG_PKG_USING_TLSF is not set
# CONFIG_PKG_USING_EVENT_RECORDER is not set # CONFIG_PKG_USING_EVENT_RECORDER is not set
@ -567,6 +745,11 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_AGILE_UPGRADE is not set # CONFIG_PKG_USING_AGILE_UPGRADE is not set
# CONFIG_PKG_USING_FLASH_BLOB is not set # CONFIG_PKG_USING_FLASH_BLOB is not set
# CONFIG_PKG_USING_MLIBC is not set # CONFIG_PKG_USING_MLIBC is not set
# CONFIG_PKG_USING_TASK_MSG_BUS is not set
# CONFIG_PKG_USING_SFDB is not set
# CONFIG_PKG_USING_RTP is not set
# CONFIG_PKG_USING_REB is not set
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# #
# peripheral libraries and drivers # peripheral libraries and drivers
@ -631,6 +814,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_BALANCE is not set # CONFIG_PKG_USING_BALANCE is not set
# CONFIG_PKG_USING_SHT2X is not set # CONFIG_PKG_USING_SHT2X is not set
# CONFIG_PKG_USING_SHT3X is not set # CONFIG_PKG_USING_SHT3X is not set
# CONFIG_PKG_USING_SHT4X is not set
# CONFIG_PKG_USING_AD7746 is not set # CONFIG_PKG_USING_AD7746 is not set
# CONFIG_PKG_USING_ADT74XX is not set # CONFIG_PKG_USING_ADT74XX is not set
# CONFIG_PKG_USING_MAX17048 is not set # CONFIG_PKG_USING_MAX17048 is not set
@ -732,6 +916,10 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_FINGERPRINT is not set # CONFIG_PKG_USING_FINGERPRINT is not set
# CONFIG_PKG_USING_BT_ECB02C is not set # CONFIG_PKG_USING_BT_ECB02C is not set
# CONFIG_PKG_USING_UAT is not set # CONFIG_PKG_USING_UAT is not set
# CONFIG_PKG_USING_ST7789 is not set
# CONFIG_PKG_USING_VS1003 is not set
# CONFIG_PKG_USING_X9555 is not set
# CONFIG_PKG_USING_SYSTEM_RUN_LED is not set
# CONFIG_PKG_USING_SPI_TOOLS is not set # CONFIG_PKG_USING_SPI_TOOLS is not set
# #
@ -746,6 +934,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_ULAPACK is not set # CONFIG_PKG_USING_ULAPACK is not set
# CONFIG_PKG_USING_QUEST is not set # CONFIG_PKG_USING_QUEST is not set
# CONFIG_PKG_USING_NAXOS is not set # CONFIG_PKG_USING_NAXOS is not set
# CONFIG_PKG_USING_R_TINYMAIX is not set
# #
# Signal Processing and Control Algorithm Packages # Signal Processing and Control Algorithm Packages
@ -792,6 +981,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MINILZO is not set # CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ is not set # CONFIG_PKG_USING_QUICKLZ is not set
# CONFIG_PKG_USING_LZMA is not set # CONFIG_PKG_USING_LZMA is not set
# CONFIG_PKG_USING_RALARAM is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set # CONFIG_PKG_USING_MULTIBUTTON is not set
# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set # CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
# CONFIG_PKG_USING_CANFESTIVAL is not set # CONFIG_PKG_USING_CANFESTIVAL is not set
@ -976,6 +1166,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# #
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_GFX_LIBRARY is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_GFX_LIBRARY is not set
# CONFIG_PKG_USING_ARDUINO_U8G2 is not set # CONFIG_PKG_USING_ARDUINO_U8G2 is not set
# CONFIG_PKG_USING_ARDUINO_TFT_ESPI is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ST7735 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ST7735 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SSD1306 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SSD1306 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ILI9341 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ILI9341 is not set
@ -984,6 +1175,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# #
# Timing # Timing
# #
# CONFIG_PKG_USING_ARDUINO_RTCLIB is not set
# CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set # CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set
# CONFIG_PKG_USING_ARDUINO_TICKER is not set # CONFIG_PKG_USING_ARDUINO_TICKER is not set
# CONFIG_PKG_USING_ARDUINO_TASKSCHEDULER is not set # CONFIG_PKG_USING_ARDUINO_TASKSCHEDULER is not set
@ -1020,7 +1212,6 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# #
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MFRC630 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MFRC630 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI5351 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI5351 is not set
# CONFIG_PKG_USING_ARDUINO_RTCLIB is not set
# #
# Signal IO # Signal IO
@ -1041,6 +1232,9 @@ CONFIG_BSP_USING_BL808=y
CONFIG_BL808_CORE_M0=y CONFIG_BL808_CORE_M0=y
CONFIG_BSP_USING_TRIPLECORE=y CONFIG_BSP_USING_TRIPLECORE=y
CONFIG_BSP_USING_PSRAM=y CONFIG_BSP_USING_PSRAM=y
CONFIG_BSP_USING_WIFI=y
CONFIG_LWIP_SUPPORT_CUSTOM_PBUF=1
CONFIG_PBUF_LINK_ENCAPSULATION_HLEN=128
# #
# General Drivers Configuration # General Drivers Configuration

View File

@ -6,14 +6,20 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2022/12/25 flyingcys first version * 2022/12/25 flyingcys first version
* 2023/11/23 flyingcys add wifi driver
*/ */
#include <rtthread.h> #include <rtthread.h>
#include <stdio.h> #include <stdio.h>
#include <rtdevice.h>
int main(void) int main(void)
{ {
rt_kprintf("Hello, RISC-V!\n"); rt_kprintf("Hello, RISC-V!\n");
/* set wifi work mode */
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
return 0; return 0;
} }

View File

@ -19,3 +19,23 @@ config BSP_USING_TRIPLECORE
config BSP_USING_PSRAM config BSP_USING_PSRAM
bool "Enable PSRAM" bool "Enable PSRAM"
default n default n
config BSP_USING_WIFI
bool "Enable Wi-Fi"
default y
select PKG_USING_WLAN_BL808
select RT_USING_WIFI
select RT_WLAN_PROT_LWIP_PBUF_FORCE
select BSP_USING_PSRAM
select RT_USING_LWIP
config LWIP_SUPPORT_CUSTOM_PBUF
int
default 1
config PBUF_LINK_ENCAPSULATION_HLEN
int
default 128

View File

@ -6,4 +6,12 @@ CPPPATH = [cwd]
group = DefineGroup('Board', src, depend = [''], CPPPATH = CPPPATH) group = DefineGroup('Board', src, depend = [''], CPPPATH = CPPPATH)
Return('group') objs = [group]
list = os.listdir(cwd)
for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
objs = objs + SConscript(os.path.join(item, 'SConscript'))
Return('objs')

View File

@ -142,9 +142,25 @@ void rt_hw_board_init(void)
bflb_mtimer_config(CPU_Get_MTimer_Clock() / RT_TICK_PER_SECOND, systick_isr); bflb_mtimer_config(CPU_Get_MTimer_Clock() / RT_TICK_PER_SECOND, systick_isr);
#ifdef BSP_USING_PSRAM
if (uhs_psram_init() < 0)
{
rt_kprintf("uhs_psram_init failed!\n");
return;
}
extern uint32_t __psrambss_start__;
extern uint32_t __psrambss_end__;
uint32_t *pDest;
pDest = &__psrambss_start__;
for (; pDest < &__psrambss_end__;) {
*pDest++ = 0ul;
}
#endif
#ifdef RT_USING_HEAP #ifdef RT_USING_HEAP
/* initialize memory system */ /* initialize memory system */
rt_kprintf("RT_HW_HEAP_BEGIN:%x RT_HW_HEAP_END:%x size: %d\r\n", RT_HW_HEAP_BEGIN, RT_HW_HEAP_END, RT_HW_HEAP_END - RT_HW_HEAP_BEGIN);
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END); rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
#endif #endif
@ -153,13 +169,6 @@ void rt_hw_board_init(void)
rt_hw_uart_init(); rt_hw_uart_init();
#endif #endif
#ifdef BSP_USING_PSRAM
if (uhs_psram_init() < 0)
{
rt_kprintf("uhs_psram_init failed!\n");
}
#endif
/* Set the shell console output device */ /* Set the shell console output device */
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
rt_console_set_device(RT_CONSOLE_DEVICE_NAME); rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
@ -189,6 +198,10 @@ void rt_hw_board_init(void)
BL_WR_WORD(IPC_SYNC_ADDR2, IPC_SYNC_FLAG); BL_WR_WORD(IPC_SYNC_ADDR2, IPC_SYNC_FLAG);
L1C_DCache_Clean_By_Addr(IPC_SYNC_ADDR1, 8); L1C_DCache_Clean_By_Addr(IPC_SYNC_ADDR1, 8);
#endif #endif
#ifdef RT_USING_HEAP
rt_kprintf("RT_HW_HEAP_BEGIN:%x RT_HW_HEAP_END:%x size: %d\r\n", RT_HW_HEAP_BEGIN, RT_HW_HEAP_END, RT_HW_HEAP_END - RT_HW_HEAP_BEGIN);
#endif
} }
void rt_hw_cpu_reset(void) void rt_hw_cpu_reset(void)

View File

@ -26,9 +26,12 @@ MEMORY
xip_memory (rx) : ORIGIN = 0x58000000, LENGTH = 32M xip_memory (rx) : ORIGIN = 0x58000000, LENGTH = 32M
itcm_memory (rx) : ORIGIN = 0x62020000, LENGTH = 20K itcm_memory (rx) : ORIGIN = 0x62020000, LENGTH = 20K
dtcm_memory (rx) : ORIGIN = 0x62025000, LENGTH = 4K dtcm_memory (rx) : ORIGIN = 0x62025000, LENGTH = 4K
nocache_ram_memory (!rx) : ORIGIN = 0x22026000, LENGTH = 40K nocache_ram_memory (!rx) : ORIGIN = 0x22026000, LENGTH = 0K
ram_memory (!rx) : ORIGIN = 0x62030000, LENGTH = 160K + 64K - 20K - 4K - 40K ram_memory (!rx) : ORIGIN = 0x22026000, LENGTH = 40K
ram_wifi (!rx) : ORIGIN = 0x22030000, LENGTH = 96K
ram_dram (wxa) : ORIGIN = 0x3EF80000, LENGTH = 512K
xram_memory (!rx) : ORIGIN = 0x40000000, LENGTH = 16K xram_memory (!rx) : ORIGIN = 0x40000000, LENGTH = 16K
ram_psram (!rx) : ORIGIN = 0x50000000, LENGTH = 1M
} }
SECTIONS SECTIONS
@ -97,6 +100,12 @@ SECTIONS
*(.srodata) *(.srodata)
*(.srodata.*) *(.srodata.*)
/* static fw attribute entry */
. = ALIGN(4);
_bl_static_fw_cfg_entry_start = .;
KEEP(*(.wifi.cfg.entry))
_bl_static_fw_cfg_entry_end = .;
. = ALIGN(4); . = ALIGN(4);
__text_code_end__ = .; __text_code_end__ = .;
} > xip_memory } > xip_memory
@ -209,19 +218,74 @@ SECTIONS
__etext_final = (__ram_load_addr + SIZEOF (RAM_DATA)); __etext_final = (__ram_load_addr + SIZEOF (RAM_DATA));
ASSERT(__etext_final <= ORIGIN(xip_memory) + LENGTH(xip_memory), "code memory overflow") ASSERT(__etext_final <= ORIGIN(xip_memory) + LENGTH(xip_memory), "code memory overflow")
.wifibss (NOLOAD) :
{
PROVIDE( __wifi_bss_start = ADDR(.wifibss) );
PROVIDE( __wifi_bss_end = ADDR(.wifibss) + SIZEOF(.wifibss) );
*ipc_shared.o(COMMON)
*sdu_shared.o(COMMON)
*hal_desc.o(COMMON)
*txl_buffer_shared.o(COMMON)
*txl_frame_shared.o(COMMON)
*scan_shared.o(COMMON)
*scanu_shared.o(COMMON)
*mfp_bip.o(COMMON)
*me_mic.o(COMMON)
*bl_sta_mgmt_others.o(COMMON)
*bl_pmk_mgmt.o(COMMON)
*bl_pmk_mgmt_internal.o(COMMON)
*libwifi_drv.a:bl_utils.o(COMMON)
*libwifi_drv.a:bl_utils.o(.bss*)
*(.wifi_ram*)
. = ALIGN(16);
} > ram_wifi
.bss (NOLOAD) : .bss (NOLOAD) :
{ {
. = ALIGN(4); . = ALIGN(4);
__bss_start__ = .; __bss_start__ = .;
*(.bss*) *interrupt*.o*(.bss*)
*riscv_fpu*.o*(.bss*)
*start*.o*(.bss*)
*system_bl808*.o*(.bss*)
*vector*.o*(.bss*)
*bl808_*.o*(.bss*)
*bflb_*.o*(.bss*)
*(.sbss*) *(.sbss*)
*(COMMON)
. = ALIGN(4); . = ALIGN(4);
__bss_end__ = .; __bss_end__ = .;
} > ram_memory } > ram_memory
.drambss (NOLOAD) :
{
. = ALIGN(4);
__drambss_start__ = .;
. = ALIGN(4);
__drambss_end__ = .;
} > ram_dram
.psrambss (NOLOAD) :
{
. = ALIGN(4);
__psrambss_start__ = .;
*(EXCLUDE_FILE( *interrupt*.o* \
*riscv_fpu*.o* \
*start*.o* \
*system_bl808*.o* \
*vector*.o* \
*bl808_*.o* \
*bflb_*.o* ) .bss*)
*(COMMON)
. = ALIGN(4);
__psrambss_end__ = .;
} > ram_psram
.noinit_data (NOLOAD) : .noinit_data (NOLOAD) :
{ {
. = ALIGN(4); . = ALIGN(4);
@ -256,10 +320,15 @@ SECTIONS
. = ALIGN(4); . = ALIGN(4);
__HeapLimit = .; __HeapLimit = .;
} > ram_memory } > ram_psram
__HeapLimit = ORIGIN(ram_memory) + LENGTH(ram_memory); __HeapLimit = ORIGIN(ram_psram) + LENGTH(ram_psram);
ASSERT(__HeapLimit - __HeapBase >= HeapMinSize, "heap region overflow") ASSERT(__HeapLimit - __HeapBase >= HeapMinSize, "heap region overflow")
PROVIDE( _ld_ram_size2 = LENGTH(ram_wifi) );
PROVIDE( _ld_ram_addr2 = ORIGIN(ram_wifi) );
PROVIDE( _ld_bl_static_cfg_entry_start = _bl_static_fw_cfg_entry_start );
PROVIDE( _ld_bl_static_cfg_entry_end = _bl_static_fw_cfg_entry_end );
} }

View File

@ -0,0 +1,8 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c') + Glob('*.cpp')
CPPPATH = [cwd]
group = DefineGroup('drv_wifi', src, depend = [''], CPPPATH = CPPPATH)
Return('group')

View File

@ -0,0 +1,532 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023/11/23 flyingcys first version
*/
#include <rtthread.h>
#include <wlan_dev.h>
#define DBG_TAG "drv.wifi"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#include "drv_wifi.h"
#define MAX_ADDR_LEN 6
struct _bl_wifi
{
struct rt_wlan_device *wlan;
rt_uint8_t dev_addr[MAX_ADDR_LEN];
};
static struct _bl_wifi wifi_sta;
static struct _bl_wifi wifi_ap;
extern err_t bl_wifi_tx(uint8_t idx, struct pbuf* p);
void event_cb_wifi_event(input_event_t *event, void *private_data)
{
switch (event->code)
{
case CODE_WIFI_ON_INIT_DONE:
{
}
break;
case CODE_WIFI_ON_MGMR_DONE:
{
}
break;
case CODE_WIFI_ON_CONNECTED:
{
rt_wlan_dev_indicate_event_handle(wifi_sta.wlan, RT_WLAN_DEV_EVT_CONNECT, RT_NULL);
wifi_mgmr_api_ip_got();
}
break;
case CODE_WIFI_ON_DISCONNECT:
{
rt_wlan_dev_indicate_event_handle(wifi_sta.wlan, RT_WLAN_DEV_EVT_DISCONNECT, RT_NULL);
}
break;
case CODE_WIFI_ON_SCAN_DONE:
{
}
break;
case CODE_WIFI_ON_PRE_GOT_IP:
{
wifi_mgmr_api_ip_got();
}
break;
case CODE_WIFI_ON_AP_STARTED:
{
rt_wlan_dev_indicate_event_handle(wifi_ap.wlan, RT_WLAN_DEV_EVT_AP_START, RT_NULL);
}
break;
case CODE_WIFI_ON_AP_STOPPED:
{
rt_wlan_dev_indicate_event_handle(wifi_ap.wlan, RT_WLAN_DEV_EVT_AP_STOP, RT_NULL);
}
break;
default:
{
LOG_D(" unknow event code %d\r\n", event->code);
}
break;
}
}
static rt_err_t drv_wlan_init(struct rt_wlan_device *wlan)
{
static rt_bool_t init = RT_FALSE;
if (init == RT_TRUE)
{
return RT_EOK;
}
bl808_wifi_init(event_cb_wifi_event);
init = RT_TRUE;
return RT_EOK;
}
static rt_err_t drv_wlan_mode(struct rt_wlan_device *wlan, rt_wlan_mode_t mode)
{
LOG_D("set wlan mode: %d", mode);
return RT_EOK;
}
static void wifi_scan_complete_callback(uint32_t scan_total, void *scan_buffer, void *param)
{
struct rt_wlan_device *wlan = (struct rt_wlan_device *)param;
struct wifi_mgmr_scan_item *scan_item = (struct wifi_mgmr_scan_item *)scan_buffer;
struct rt_wlan_info wlan_info;
struct rt_wlan_buff buff = {0};
rt_uint32_t i;
for (i = 0; i < scan_total; i ++)
{
memset(&wlan_info, 0, sizeof(wlan_info));
wlan_info.security = SECURITY_OPEN;
switch (scan_item[i].auth)
{
case WIFI_EVENT_BEACON_IND_AUTH_WPA3_SAE:
{
}
break;
case WIFI_EVENT_BEACON_IND_AUTH_WPA2_PSK_WPA3_SAE:
{
}
break;
case WIFI_EVENT_BEACON_IND_AUTH_OPEN:
{
wlan_info.security = SECURITY_OPEN;
}
break;
case WIFI_EVENT_BEACON_IND_AUTH_WEP:
{
wlan_info.security = WEP_ENABLED;
}
break;
case WIFI_EVENT_BEACON_IND_AUTH_WPA_PSK:
{
wlan_info.security = SECURITY_WPA_TKIP_PSK;
}
break;
case WIFI_EVENT_BEACON_IND_AUTH_WPA2_PSK:
{
wlan_info.security = SECURITY_WPA2_TKIP_PSK;
}
break;
case WIFI_EVENT_BEACON_IND_AUTH_WPA_WPA2_PSK:
{
wlan_info.security = SECURITY_WPA2_MIXED_PSK;
}
break;
case WIFI_EVENT_BEACON_IND_AUTH_WPA_ENT:
{
}
break;
case WIFI_EVENT_BEACON_IND_AUTH_UNKNOWN:
{
}
break;
default:
{
wlan_info.security = SECURITY_OPEN;
}
break;
}
wlan_info.band = RT_802_11_BAND_2_4GHZ;
wlan_info.channel = scan_item[i].channel;
wlan_info.rssi = scan_item[i].rssi;
memcpy(wlan_info.bssid, scan_item[i].bssid, 6);
if (scan_item[i].ssid_len)
{
wlan_info.hidden == 0;
memcpy(wlan_info.ssid.val, scan_item[i].ssid, strlen(scan_item[i].ssid));
wlan_info.ssid.len = strlen(scan_item[i].ssid);
}
buff.data = &wlan_info;
buff.len = sizeof(wlan_info);
rt_wlan_dev_indicate_event_handle(wifi_sta.wlan, RT_WLAN_DEV_EVT_SCAN_REPORT, &buff);
}
rt_wlan_dev_indicate_event_handle(wlan, RT_WLAN_DEV_EVT_SCAN_DONE, RT_NULL);
}
static rt_err_t drv_wlan_scan(struct rt_wlan_device *wlan, struct rt_scan_info *scan_info)
{
int channel_input_num = 0;
uint8_t channel_input[MAX_FIXED_CHANNELS_LIMIT] = {0};
const char *ssid = NULL;
uint8_t bssid[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
uint8_t scan_mode = SCAN_ACTIVE;
uint32_t duration_scan_us = 0;
if (scan_info != NULL && scan_info->ssid.len > 0)
{
ssid = scan_info->ssid.val;
}
if (wifi_mgmr_scan_adv(wlan, wifi_scan_complete_callback, channel_input, channel_input_num, bssid, ssid, scan_mode, duration_scan_us) != 0)
return -RT_ERROR;
return RT_EOK;
}
static rt_err_t drv_wlan_join(struct rt_wlan_device *wlan, struct rt_sta_info *sta_info)
{
uint8_t channel_index = 0;
int bssid_set_flag = 0;
int quick_connect = 0;
uint32_t flags = 0;
int pci_en = 0;
int scan_mode = 0;
uint8_t pmf_flag = WIFI_MGMR_CONNECT_PMF_CAPABLE_BIT;
if (sta_info->bssid != NULL)
{
bssid_set_flag = 1;
}
if (quick_connect > 0)
{
flags |= WIFI_CONNECT_STOP_SCAN_CURRENT_CHANNEL_IF_TARGET_AP_FOUND;
}
if (scan_mode)
{
flags |= WIFI_CONNECT_STOP_SCAN_ALL_CHANNEL_IF_TARGET_AP_FOUND;
}
if (pci_en)
{
flags |= WIFI_CONNECT_PCI_EN;
}
if (pmf_flag & WIFI_MGMR_CONNECT_PMF_CAPABLE_BIT)
{
flags |= WIFI_CONNECT_PMF_CAPABLE;
} else
{
flags &= ~WIFI_CONNECT_PMF_CAPABLE;
}
if (pmf_flag & WIFI_MGMR_CONNECT_PMF_REQUIRED_BIT)
{
flags |= WIFI_CONNECT_PMF_REQUIRED;
} else {
flags &= ~WIFI_CONNECT_PMF_REQUIRED;
}
wifi_mgmr_mode_set(0);
wifi_mgmr_sta_connect_mid(RT_NULL, sta_info->ssid.val, (sta_info->key.len == 0) ? NULL : sta_info->key.val, NULL, bssid_set_flag ? sta_info->bssid : NULL, 0, channel_index, 1, flags);
return RT_EOK;
}
static rt_err_t drv_wlan_softap(struct rt_wlan_device *wlan, struct rt_ap_info *ap_info)
{
int ret;
uint8_t mac[6];
uint8_t hidden_ssid = 0;
char ssid_name[32 + 1];
char passwd[64 + 1];
int channel;
int max_sta_supported = -1;
memset(mac, 0, sizeof(mac));
bl_wifi_mac_addr_get(mac);
memset(ssid_name, 0, sizeof(ssid_name));
memset(passwd, 0, sizeof(passwd));
memcpy(ssid_name, ap_info->ssid.val, (ap_info->ssid.len > 32)? 32 : ap_info->ssid.len);
if (ap_info->hidden)
hidden_ssid = 1;
channel = ap_info->channel;
wifi_mgmr_mode_set(1);
//TODO未知原因导致 ap 有密码的情况下会crash
#if 0
if (ap_info->key.len > 0)
{
memcpy(passwd, ap_info->key.val, (ap_info->key.len > 64)? 64 : ap_info->key.len);
ret = wifi_mgmr_api_ap_start(ssid_name, passwd, channel, hidden_ssid, max_sta_supported, 1);
}
else
#endif
{
ret = wifi_mgmr_api_ap_start(ssid_name, NULL, channel, hidden_ssid, max_sta_supported, 1);
}
if (ret < 0)
return RT_ERROR;
return RT_EOK;
}
static rt_err_t drv_wlan_disconnect(struct rt_wlan_device *wlan)
{
wifi_mgmr_sta_disconnect();
rt_thread_mdelay(WIFI_MGMR_STA_DISCONNECT_DELAY);
wifi_mgmr_sta_disable(NULL);
return RT_EOK;
}
static rt_err_t drv_wlan_ap_stop(struct rt_wlan_device *wlan)
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
wifi_mgmr_api_ap_stop();
return RT_EOK;
}
static rt_err_t drv_wlan_ap_deauth(struct rt_wlan_device *wlan, rt_uint8_t mac[])
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
return RT_EOK;
}
static rt_err_t drv_wlan_scan_stop(struct rt_wlan_device *wlan)
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
return RT_EOK;
}
static int drv_wlan_get_rssi(struct rt_wlan_device *wlan)
{
int rssi;
wifi_mgmr_rssi_get(&rssi);
return rssi;
}
static rt_err_t drv_wlan_set_powersave(struct rt_wlan_device *wlan, int level)
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
return RT_EOK;
}
static int drv_wlan_get_powersave(struct rt_wlan_device *wlan)
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
return RT_EOK;
}
static void sniffer_cb(void *env, uint8_t *pkt, int len, struct bl_rx_info *info)
{
static unsigned int sniffer_counter, sniffer_last;
static unsigned int last_tick;
(void)sniffer_last;
(void)sniffer_counter;
sniffer_counter++;
if ((int)bl_os_get_tick() - (int)last_tick > 10 * 1000) {
bl_os_log_info("[SNIFFER] PKT Number is %d\r\n",
(int)sniffer_counter - (int)sniffer_last
);
last_tick = bl_os_get_tick();
sniffer_last = sniffer_counter;
}
}
static rt_err_t drv_wlan_cfg_promisc(struct rt_wlan_device *wlan, rt_bool_t start)
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
if (start)
{
wifi_mgmr_sniffer_register(RT_NULL, sniffer_cb);
wifi_mgmr_sniffer_enable();
}
else
{
wifi_mgmr_sniffer_disable();
wifi_mgmr_sniffer_register(RT_NULL, RT_NULL);
}
return RT_EOK;
}
static rt_err_t drv_wlan_cfg_filter(struct rt_wlan_device *wlan, struct rt_wlan_filter *filter)
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
return RT_EOK;
}
static rt_err_t drv_wlan_cfg_mgnt_filter(struct rt_wlan_device *wlan, rt_bool_t start)
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
return RT_EOK;
}
static rt_err_t drv_wlan_set_channel(struct rt_wlan_device *wlan, int channel)
{
wifi_mgmr_channel_set(channel, 0);
return RT_EOK;
}
static int drv_wlan_get_channel(struct rt_wlan_device *wlan)
{
int channel;
wifi_mgmr_channel_get(&channel);
return channel;
}
static rt_err_t drv_wlan_set_country(struct rt_wlan_device *wlan, rt_country_code_t country_code)
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
wifi_mgmr_set_country_code("CN");
return RT_EOK;
}
static rt_country_code_t drv_wlan_get_country(struct rt_wlan_device *wlan)
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
return RT_EOK;
}
static rt_err_t drv_wlan_set_mac(struct rt_wlan_device *wlan, rt_uint8_t mac[])
{
wifi_mgmr_sta_mac_set(mac);
return RT_EOK;
}
static rt_err_t drv_wlan_get_mac(struct rt_wlan_device *wlan, rt_uint8_t mac[])
{
wifi_mgmr_sta_mac_get(mac);
return RT_EOK;
}
int bl_wifi_rx(uint8_t idx, struct pbuf *p)
{
rt_err_t ret = RT_EOK;
if (idx == 0)
ret = rt_wlan_dev_report_data(wifi_sta.wlan, p, p->tot_len);
else
ret = rt_wlan_dev_report_data(wifi_ap.wlan, p, p->tot_len);
return ret;
}
static int drv_wlan_recv(struct rt_wlan_device *wlan, void *buff, int len)
{
LOG_D("%s %d", __FUNCTION__, __LINE__);
return RT_EOK;
}
static int drv_wlan_send(struct rt_wlan_device *wlan, void *buff, int len)
{
if (wlan->user_data == &wifi_sta)
bl_wifi_tx(0, (struct pbuf *)buff);
else
bl_wifi_tx(1, (struct pbuf *)buff);
return RT_EOK;
}
static const struct rt_wlan_dev_ops ops =
{
.wlan_init = drv_wlan_init,
.wlan_mode = drv_wlan_mode,
.wlan_scan = drv_wlan_scan,
.wlan_join = drv_wlan_join,
.wlan_softap = drv_wlan_softap,
.wlan_disconnect = drv_wlan_disconnect,
.wlan_ap_stop = drv_wlan_ap_stop,
.wlan_ap_deauth = drv_wlan_ap_deauth,
.wlan_scan_stop = drv_wlan_scan_stop,
.wlan_get_rssi = drv_wlan_get_rssi,
.wlan_set_powersave = drv_wlan_set_powersave,
.wlan_get_powersave = drv_wlan_get_powersave,
.wlan_cfg_promisc = drv_wlan_cfg_promisc,
.wlan_cfg_filter = drv_wlan_cfg_filter,
.wlan_cfg_mgnt_filter = drv_wlan_cfg_mgnt_filter,
.wlan_set_channel = drv_wlan_set_channel,
.wlan_get_channel = drv_wlan_get_channel,
.wlan_set_country = drv_wlan_set_country,
.wlan_get_country = drv_wlan_get_country,
.wlan_set_mac = drv_wlan_set_mac,
.wlan_get_mac = drv_wlan_get_mac,
.wlan_recv = drv_wlan_recv,
.wlan_send = drv_wlan_send,
};
int rt_hw_wifi_init(void)
{
rt_err_t ret = RT_EOK;
static struct rt_wlan_device wlan0;
static struct rt_wlan_device wlan1;
memset(&wifi_sta, 0, sizeof(wifi_sta));
ret = rt_wlan_dev_register(&wlan0, RT_WLAN_DEVICE_STA_NAME, &ops, 0, &wifi_sta);
wifi_sta.wlan = &wlan0;
memset(&wifi_ap, 0, sizeof(wifi_ap));
ret |= rt_wlan_dev_register(&wlan1, RT_WLAN_DEVICE_AP_NAME, &ops, 0, &wifi_ap);
wifi_ap.wlan = &wlan1;
return ret;
}
INIT_DEVICE_EXPORT(rt_hw_wifi_init);

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023/11/23 flyingcys first version
*/
#ifndef __DRV_WIFI_H__
#define __DRV_WIFI_H__
#include "bl808_wifi.h"
#endif /* __DRV_WIFI_H__ */

View File

@ -6,7 +6,8 @@
/* RT-Thread Kernel */ /* RT-Thread Kernel */
#define RT_NAME_MAX 8 #define RT_NAME_MAX 16
#define RT_CPUS_NR 1
#define RT_ALIGN_SIZE 8 #define RT_ALIGN_SIZE 8
#define RT_THREAD_PRIORITY_32 #define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32 #define RT_THREAD_PRIORITY_MAX 32
@ -16,10 +17,10 @@
#define RT_HOOK_USING_FUNC_PTR #define RT_HOOK_USING_FUNC_PTR
#define RT_USING_IDLE_HOOK #define RT_USING_IDLE_HOOK
#define RT_IDLE_HOOK_LIST_SIZE 4 #define RT_IDLE_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 1024 #define IDLE_THREAD_STACK_SIZE 2048
#define RT_USING_TIMER_SOFT #define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4 #define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512 #define RT_TIMER_THREAD_STACK_SIZE 2048
/* kservice optimization */ /* kservice optimization */
@ -42,14 +43,12 @@
#define RT_USING_SMALL_MEM #define RT_USING_SMALL_MEM
#define RT_USING_SMALL_MEM_AS_HEAP #define RT_USING_SMALL_MEM_AS_HEAP
#define RT_USING_HEAP #define RT_USING_HEAP
/* Kernel Device Object */
#define RT_USING_DEVICE #define RT_USING_DEVICE
#define RT_USING_CONSOLE #define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLEBUF_SIZE 512
#define RT_CONSOLE_DEVICE_NAME "uart0" #define RT_CONSOLE_DEVICE_NAME "uart0"
#define RT_VER_NUM 0x50002 #define RT_VER_NUM 0x50100
#define RT_BACKTRACE_LEVEL_MAX_NR 32
#define ARCH_RISCV #define ARCH_RISCV
#define ARCH_RISCV_FPU #define ARCH_RISCV_FPU
#define ARCH_RISCV_FPU_S #define ARCH_RISCV_FPU_S
@ -107,6 +106,9 @@
#define RT_USING_DEVICE_IPC #define RT_USING_DEVICE_IPC
#define RT_UNAMED_PIPE_NUMBER 64 #define RT_UNAMED_PIPE_NUMBER 64
#define RT_USING_SYSTEM_WORKQUEUE
#define RT_SYSTEM_WORKQUEUE_STACKSIZE 8192
#define RT_SYSTEM_WORKQUEUE_PRIORITY 23
#define RT_USING_SERIAL #define RT_USING_SERIAL
#define RT_USING_SERIAL_V1 #define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA #define RT_SERIAL_USING_DMA
@ -121,6 +123,32 @@
#define RT_MMCSD_THREAD_PREORITY 22 #define RT_MMCSD_THREAD_PREORITY 22
#define RT_MMCSD_MAX_PARTITION 16 #define RT_MMCSD_MAX_PARTITION 16
#define RT_USING_WDT #define RT_USING_WDT
#define RT_USING_WIFI
#define RT_WLAN_DEVICE_STA_NAME "wlan0"
#define RT_WLAN_DEVICE_AP_NAME "wlan1"
#define RT_WLAN_SSID_MAX_LENGTH 32
#define RT_WLAN_PASSWORD_MAX_LENGTH 32
#define RT_WLAN_DEV_EVENT_NUM 2
#define RT_WLAN_MANAGE_ENABLE
#define RT_WLAN_SCAN_WAIT_MS 10000
#define RT_WLAN_CONNECT_WAIT_MS 10000
#define RT_WLAN_SCAN_SORT
#define RT_WLAN_MSH_CMD_ENABLE
#define RT_WLAN_AUTO_CONNECT_ENABLE
#define AUTO_CONNECTION_PERIOD_MS 2000
#define RT_WLAN_CFG_ENABLE
#define RT_WLAN_CFG_INFO_MAX 3
#define RT_WLAN_PROT_ENABLE
#define RT_WLAN_PROT_NAME_LEN 8
#define RT_WLAN_PROT_MAX 2
#define RT_WLAN_DEFAULT_PROT "lwip"
#define RT_WLAN_PROT_LWIP_ENABLE
#define RT_WLAN_PROT_LWIP_NAME "lwip"
#define RT_WLAN_PROT_LWIP_PBUF_FORCE
#define RT_WLAN_WORK_THREAD_ENABLE
#define RT_WLAN_WORKQUEUE_THREAD_NAME "wlan"
#define RT_WLAN_WORKQUEUE_THREAD_SIZE 8192
#define RT_WLAN_WORKQUEUE_THREAD_PRIO 15
/* Using USB */ /* Using USB */
@ -138,6 +166,10 @@
/* POSIX (Portable Operating System Interface) layer */ /* POSIX (Portable Operating System Interface) layer */
#define RT_USING_POSIX_FS
#define RT_USING_POSIX_POLL
#define RT_USING_POSIX_SELECT
#define RT_USING_POSIX_SOCKET
/* Interprocess Communication (IPC) */ /* Interprocess Communication (IPC) */
@ -147,10 +179,77 @@
/* Network */ /* Network */
#define RT_USING_SAL
#define SAL_INTERNET_CHECK
/* Docking with protocol stacks */
#define SAL_USING_LWIP
#define SAL_USING_TLS
#define SAL_USING_POSIX
#define RT_USING_NETDEV
#define NETDEV_USING_IFCONFIG
#define NETDEV_USING_PING
#define NETDEV_USING_NETSTAT
#define NETDEV_USING_AUTO_DEFAULT
#define NETDEV_IPV4 1
#define NETDEV_IPV6 0
#define RT_USING_LWIP
#define RT_USING_LWIP212
#define RT_USING_LWIP_VER_NUM 0x20102
#define RT_LWIP_MEM_ALIGNMENT 4
#define RT_LWIP_IGMP
#define RT_LWIP_ICMP
#define RT_LWIP_DNS
#define RT_LWIP_DHCP
#define IP_SOF_BROADCAST 1
#define IP_SOF_BROADCAST_RECV 1
/* Static IPv4 Address */
#define RT_LWIP_IPADDR "192.168.1.30"
#define RT_LWIP_GWADDR "192.168.1.1"
#define RT_LWIP_MSKADDR "255.255.255.0"
#define RT_LWIP_UDP
#define RT_LWIP_TCP
#define RT_LWIP_RAW
#define RT_MEMP_NUM_NETCONN 8
#define RT_LWIP_PBUF_NUM 16
#define RT_LWIP_RAW_PCB_NUM 4
#define RT_LWIP_UDP_PCB_NUM 4
#define RT_LWIP_TCP_PCB_NUM 4
#define RT_LWIP_TCP_SEG_NUM 40
#define RT_LWIP_TCP_SND_BUF 8196
#define RT_LWIP_TCP_WND 8196
#define RT_LWIP_TCPTHREAD_PRIORITY 10
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8
#define RT_LWIP_TCPTHREAD_STACKSIZE 4096
#define LWIP_NO_RX_THREAD
#define LWIP_NO_TX_THREAD
#define RT_LWIP_ETHTHREAD_PRIORITY 12
#define RT_LWIP_ETHTHREAD_STACKSIZE 4096
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_LINK_CALLBACK 1
#define SO_REUSE 1
#define LWIP_SO_RCVTIMEO 1
#define LWIP_SO_SNDTIMEO 1
#define LWIP_SO_RCVBUF 1
#define LWIP_SO_LINGER 0
#define LWIP_NETIF_LOOPBACK 0
#define RT_LWIP_USING_PING
#define LWIP_USING_DHCPD
#define DHCPD_SERVER_IP "192.168.169.1"
/* Utilities */ /* Utilities */
/* Memory management */
/* Memory protection */
/* RT-Thread Utestcases */ /* RT-Thread Utestcases */
@ -167,11 +266,27 @@
/* Wiced WiFi */ /* Wiced WiFi */
/* CYW43012 WiFi */
/* BL808 WiFi */
#define PKG_USING_WLAN_BL808
#define PKG_USING_WLAN_BL808_LATEST_VERSION
/* IoT Cloud */ /* IoT Cloud */
/* security packages */ /* security packages */
#define PKG_USING_MBEDTLS
/* Select Root Certificate */
#define MBEDTLS_AES_ROM_TABLES
#define MBEDTLS_ECP_WINDOW_SIZE 2
#define MBEDTLS_SSL_MAX_CONTENT_LEN 3584
#define PKG_USING_MBEDTLS_V2281
/* language packages */ /* language packages */
@ -271,6 +386,9 @@
#define BL808_CORE_M0 #define BL808_CORE_M0
#define BSP_USING_TRIPLECORE #define BSP_USING_TRIPLECORE
#define BSP_USING_PSRAM #define BSP_USING_PSRAM
#define BSP_USING_WIFI
#define LWIP_SUPPORT_CUSTOM_PBUF 1
#define PBUF_LINK_ENCAPSULATION_HLEN 128
/* General Drivers Configuration */ /* General Drivers Configuration */

View File

@ -88,5 +88,11 @@ void start_load(void)
*pDest++ = 0ul; *pDest++ = 0ul;
} }
extern uint32_t __wifi_bss_start;
extern uint32_t __wifi_bss_end;
pDest = &__wifi_bss_start;
for ( ; pDest < &__wifi_bss_end ; ) {
*pDest++ = 0ul;
}
#endif #endif
} }

View File

@ -119,6 +119,15 @@ void System_Post_Init(void)
/* make D0 all ram avalable for mcu usage */ /* make D0 all ram avalable for mcu usage */
GLB_Set_DSP_L2SRAM_Available_Size(3, 1, 1, 1); GLB_Set_DSP_L2SRAM_Available_Size(3, 1, 1, 1);
extern uint32_t __drambss_start__;
extern uint32_t __drambss_end__;
uint32_t *pDest;
pDest = &__drambss_start__;
for (; pDest < &__drambss_end__;) {
*pDest++ = 0ul;
}
/* global IRQ enable */ /* global IRQ enable */
__enable_irq(); __enable_irq();
} }