risc-v/bl602: Add wifi and ble support

tcpip ok

update wifi demo configuration

fix tcpip input cause misalign fault

change some api definetions in nuttx

fix wifi manager strlen copy without suffix null character

fix 602 network buf allocation issue

wifi scan works

[ble] Add controller code

[BLE] Add nuttx adapt code for blecontroller .

[BLE] modified include file path, to fix cflag is too long.

[ble]Test ble peripheral pass, save code.

[ble] Organize the code

[BLE] Add blecontroller config for nuttx

[BLE] Add config for ble example

fix tcp lost packet when rx

support wpa3.

Copy default config from wifi default config. Create ble for local test and ble tester for autopts.

Add config for local test.

Add pts teset config for host test

Add config for mesh test

Create task to init blecontroller

Delete blecontroller rx thread.

using idle task to receive hci command from host

Set ble device name to /dev/ble, and fix code.

1.fix a ke schedule risk 2. CFG_HOST is enabled only in the case that CONFIG_BLE_HOST_DISABLE is not enabled, by lanlan

rm _sp_main stack.

change h/l workq_stack_size 6K

change l workq_stack_size 3K.

[ble] delete file_detach

color idle stack.

clear bl602 netdev code

SCAN is sorted according to RSSI

enlarge nsh command line buffer

fixup stack overflow check checkfail when startup

arch/risc-v/BL602:fix reboot cause crash

reboot default use romapi.

riscv/bl602:netdev support defered input, remove wifi_tx function

risc-v/bl602:fix sem_timedwait usage error in bl_cmds

risc-v/bl602:fix memory access out of bounds when copy ssid

remove ble and wifi source, download when build

add bl602 blob gitignore

risc-v/bl602:remove ble-pts defconfig

Fix some typos in NuttX style naming

Fix the replacement of tab to space

fix wlan interface down still receive packet

fix wapi crash, rx when ifdown,and ble_hci_rx_do

change system reset to rom dirver

change ble hci interval to 50ms

NuttX support wifi enable/disable log via KConfig

support country code configuration in Kconfig

fix ap tx not work
This commit is contained in:
Virus.V 2020-12-22 16:42:04 +08:00 committed by Xiang Xiao
parent cf2aed1810
commit 7c80826c21
22 changed files with 2879 additions and 99 deletions

View File

@ -199,7 +199,7 @@
/* Total number of IRQs */
#define NR_IRQS (64 + 16)
#define NR_IRQS (64 + 16 + 16)
/****************************************************************************
* Public Types

2
arch/risc-v/src/bl602/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/bl_blob
/*.zip

View File

@ -68,4 +68,28 @@ config BL602_MTD_SIZE
endmenu # BL602_SPIFLASH
config BL602_WIRELESS
bool "Wireless & WiFi Support"
depends on SCHED_HPWORK
depends on SCHED_LPWORK
default n
config BL602_WIRELESS_DEBUG
bool "Wireless Debug Log"
depends on BL602_WIRELESS
default n
config BL602_WIRELESS_CONTRY_CODE
string "WiFi Contry Code"
depends on BL602_WIRELESS
default "CN"
config BL602_BLE_CONTROLLER
bool "ble controller support"
default n
depends on PSEUDOTERM
depends on PSEUDOTERM_SUSV1
depends on !DISABLE_MQUEUE
depends on SCHED_HPWORK
depends on BL602_WIRELESS
endmenu

View File

@ -78,5 +78,44 @@ endif
CHIP_CSRCS += bl602_glb.c bl602_gpio.c bl602_hbn.c bl602_systemreset.c
# INCLUDES += ${shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)hardware}
ifeq ($(CONFIG_BL602_WIRELESS),y)
WIRELESS_DRV_UNPACK = bl_blob
WIRELESS_DRV_VERSION = v1.6.19
WIRELESS_DRV_ID = main
WIRELESS_DRV_ZIP = $(WIRELESS_DRV_ID).zip
WIRELESS_DRV_URL = https://github.com/bouffalolab/bl_blob/archive
$(WIRELESS_DRV_ZIP):
$(Q) echo "Downloading: BL602 Wireless Drivers"
$(Q) curl -L $(WIRELESS_DRV_URL)/$(WIRELESS_DRV_ZIP) -o chip/$(WIRELESS_DRV_ZIP)
chip/$(WIRELESS_DRV_UNPACK): $(WIRELESS_DRV_ZIP)
$(Q) echo "Unpacking: BL602 Wireless Drivers"
$(Q) mkdir -p chip/$(WIRELESS_DRV_UNPACK)
$(Q) unzip -oqq chip/$(WIRELESS_DRV_ZIP) -d chip/
$(Q) mv chip/$(WIRELESS_DRV_UNPACK)-$(WIRELESS_DRV_ID)/* chip/$(WIRELESS_DRV_UNPACK)
$(Q) touch chip/$(WIRELESS_DRV_UNPACK)
context:: chip/$(WIRELESS_DRV_UNPACK)
clean_context::
$(call DELFILE, chip/$(WIRELESS_DRV_ZIP))
$(call DELDIR, chip/$(WIRELESS_DRV_UNPACK))
INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(WIRELESS_DRV_UNPACK)$(DELIM)includes$(DELIM)$(WIRELESS_DRV_VERSION)$(DELIM)BL602$(DELIM)nuttx)
CHIP_CSRCS += bl602_netdev.c
EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(WIRELESS_DRV_UNPACK)$(DELIM)libs$(DELIM)$(WIRELESS_DRV_VERSION)$(DELIM)BL602$(DELIM)nuttx
EXTRA_LIBS += -lbl602_wifi -lblecontroller
# Due to some Wi-Fi related libraries, the option is need to avoid linking too much
# unused functions.
LDFLAGS += --gc-sections
ifeq ($(CONFIG_BL602_WIRELESS_DEBUG),y)
LDFLAGS += -defsym _wifi_log_flag=1
endif
endif

View File

@ -23,6 +23,7 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#include <nuttx/arch.h>
@ -34,6 +35,8 @@
extern uint8_t _heap_start;
extern uint8_t _heap_size;
extern uint8_t _heap_wifi_start;
extern uint8_t _heap_wifi_size;
/****************************************************************************
* Public Functions
@ -72,6 +75,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
#if CONFIG_MM_REGIONS > 1
void riscv_addregion(void)
{
kumm_addregion(&_heap_wifi_start, (uint32_t)(&_heap_wifi_size));
}
#endif

View File

@ -22,6 +22,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <arch/csr.h>
.section .init
@ -43,7 +44,22 @@ bl602_start:
la gp, __global_pointer$
.option pop
la sp, _sp_main
la sp, g_idle_stack
add s11, sp, zero
li t0, CONFIG_IDLETHREAD_STACKSIZE
add sp, sp, t0
andi sp, sp, ~0xF
la t0, g_idle_stack
li t1, CONFIG_IDLETHREAD_STACKSIZE
li t2, 0xdeadbeef
color_idle_stack:
addi t1, t1, -4
add t3, t1, t0
sw t2, 0(t3)
bnez t1, color_idle_stack
#ifndef RUN_IN_RAM

View File

@ -95,3 +95,22 @@ uint8_t bl602_glb_get_bclk_div(void)
return (uint8_t)tmp_val;
}
/****************************************************************************
* Name: bl602_set_em_sel
*
* Description:
* Set how much wifi ram is allocated to ble.
*
* Input Parameters:
* em_type: memory size type
*
* Returned Value:
* None
*
****************************************************************************/
void bl602_set_em_sel(int em_type)
{
modifyreg32(BL602_SEAM_MISC, SEAM_MISC_EM_SEL_MASK, em_type);
}

View File

@ -29,6 +29,10 @@
#include <stdint.h>
#define BL602_GLB_EM_0KB 0x0 /* 0KB */
#define BL602_GLB_EM_8KB 0x3 /* 8KB */
#define BL602_GLB_EM_16KB 0xF /* 16KB */
/****************************************************************************
* Public Data
****************************************************************************/
@ -80,6 +84,22 @@ void bl602_swrst_ahb_slave1(uint32_t slave1);
uint8_t bl602_glb_get_bclk_div(void);
/****************************************************************************
* Name: bl602_set_em_sel
*
* Description:
* Set how much wifi ram is allocated to ble.
*
* Input Parameters:
* em_type: memory size type
*
* Returned Value:
* None
*
****************************************************************************/
void bl602_set_em_sel(int em_type);
#undef EXTERN
#if defined(__cplusplus)
}

View File

@ -58,3 +58,9 @@ void bl602_set_uart_clk_sel(int clk_sel)
modifyreg32(BL602_HBN_GLB, HBN_GLB_HBN_UART_CLK_SEL, 0);
}
}
void bl602_aon_pad_iesmt_cfg(uint8_t pad_cfg)
{
modifyreg32(BL602_HBN_IRQ_MODE, HBN_IRQ_MODE_REG_AON_PAD_IE_SMT,
pad_cfg << 8);
}

View File

@ -90,6 +90,9 @@ exception_common:
lui sp, %hi(g_intstackbase)
addi sp, sp, %lo(g_intstackbase)
#ifdef CONFIG_STACK_OVERFLOW_CHECK
la s11, g_intstackalloc
#endif
#endif
/* Call interrupt handler in C */

View File

@ -41,7 +41,7 @@
* Public Data
****************************************************************************/
volatile uint32_t *g_current_regs;
volatile uint32_t *g_current_regs = NULL;
/****************************************************************************
* Public Functions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,134 @@
/****************************************************************************
* arch/risc-v/src/bl602/bl602_netdev.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef _BL602_NETDEV_H__
#define _BL602_NETDEV_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define PRESERVE_80211_HEADER_LEN 128
#define BL602_NET_EVT_TX_DONE (0x1 << 0x0)
#define BL602_NET_EVT_RX (0x1 << 0x1)
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: bl602_netdev_alloc_txbuf
*
* Description:
* Allocate wifi transmit buffer
*
* Input Parameters:
* None
*
* Returned Value:
* Non-zero: Buffer address, otherwise error.
*
****************************************************************************/
uint8_t *bl602_netdev_alloc_txbuf(void);
/****************************************************************************
* Name: bl602_netdev_free_txbuf
*
* Description:
* Free wifi transmit buffer
*
* Input Parameters:
* buf: The address of the buffer to be released.
*
* Returned Value:
* None.
*
****************************************************************************/
void bl602_netdev_free_txbuf(uint8_t *buf);
/****************************************************************************
* Name: bl602_net_notify
*
* Description:
* BL602 WiFi notify handler, similar interrupt function
*
* Input Parameters:
* event: notify type, tx done or received new data
* data: The data of the event, may be NULL
* len: data length
*
* Returned Value:
* OK on success; a negated errno on failure
*
****************************************************************************/
int bl602_net_notify(uint32_t event, uint8_t *data, int len);
/****************************************************************************
* Name: bl602_net_event
*
* Description:
* BL602 WiFi event handler, called by BL602 wifi manager private library
*
* Input Parameters:
* event: event number
* val: the value of the event
*
* Returned Value:
* OK on success; a negated errno on failure
*
****************************************************************************/
void bl602_net_event(int evt, int val);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_ASSERT_H */
#endif /* _BL602_NETDEV_H__ */

View File

@ -35,6 +35,8 @@
#include <nuttx/irq.h>
#include <nuttx/serial/serial.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/serial/tioctl.h>
#include "bl602_lowputc.h"
#include "bl602_gpio.h"
@ -461,25 +463,25 @@ static int bl602_ioctl(struct file *filep, int cmd, unsigned long arg)
/* Return parity */
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
((priv->parity == 1) ? PARODD : 0);
termiosp->c_cflag = ((priv->config.parity != 0) ? PARENB : 0) |
((priv->config.parity == 1) ? PARODD : 0);
/* Return stop bits */
termiosp->c_cflag |= (priv->stop_bits) ? CSTOPB : 0;
termiosp->c_cflag |= (priv->config.stop_bits) ? CSTOPB : 0;
/* Return flow control */
termiosp->c_cflag |= (priv->iflow_ctl) ? CRTS_IFLOW : 0;
termiosp->c_cflag |= (priv->oflow_ctl) ? CCTS_OFLOW : 0;
termiosp->c_cflag |= (priv->config.iflow_ctl) ? CRTS_IFLOW : 0;
termiosp->c_cflag |= (priv->config.oflow_ctl) ? CCTS_OFLOW : 0;
/* Return baud */
cfsetispeed(termiosp, priv->baud);
cfsetispeed(termiosp, priv->config.baud);
/* Return number of bits */
switch (priv->data_bits)
switch (priv->config.data_bits)
{
case 5:
termiosp->c_cflag |= CS5;
@ -563,7 +565,7 @@ static int bl602_ioctl(struct file *filep, int cmd, unsigned long arg)
/* Decode flow control */
if (priv->idx == 0)
if (priv->config.idx == 0)
{
#if CONFIG_UART0_IFLOWCONTROL
config.iflow_ctl = (termiosp->c_cflag & CRTS_IFLOW) != 0;
@ -594,9 +596,9 @@ static int bl602_ioctl(struct file *filep, int cmd, unsigned long arg)
* implement TCSADRAIN / TCSAFLUSH
*/
tmp_val = getreg32(BL602_UART_INT_MASK(config->idx));
tmp_val = getreg32(BL602_UART_INT_MASK(config.idx));
bl602_uart_configure(&config);
putreg32(tmp_val, BL602_UART_INT_MASK(config->idx));
putreg32(tmp_val, BL602_UART_INT_MASK(config.idx));
}
}
while (0);

View File

@ -30,6 +30,10 @@
#include <nuttx/arch.h>
#include <arch/board/board.h>
#ifdef CONFIG_STACK_OVERFLOW_CHECK
# include "sched/sched.h"
#endif
#include "riscv_arch.h"
#include "riscv_internal.h"
#include "chip.h"
@ -47,7 +51,7 @@
#define showprogress(c)
#endif
#define BL602_IDLESTACK_SIZE (CONFIG_IDLETHREAD_STACKSIZE & ~3)
#define BL602_IDLESTACK_SIZE (CONFIG_IDLETHREAD_STACKSIZE)
/****************************************************************************
* Private Data
@ -63,20 +67,21 @@
* address.
*/
static uint8_t g_idle_stack[BL602_IDLESTACK_SIZE];
uint8_t g_idle_stack[BL602_IDLESTACK_SIZE]
__attribute__((section(".noinit_idle_stack")));
/* Dont change the name of variable, since we refer this
* g_boot2_partition_table in linker script
*/
static struct boot2_partition_table_s g_boot2_partition_table \
__attribute__((used));
static struct boot2_partition_table_s g_boot2_partition_table
__attribute__((used));
/****************************************************************************
* Public Data
****************************************************************************/
uint32_t g_idle_topstack = (uintptr_t)g_idle_stack + BL602_IDLESTACK_SIZE;
uint32_t g_idle_topstack = 0;
/****************************************************************************
* Public Functions
@ -90,7 +95,7 @@ extern void bl602_boardinitialize(void);
* Name: boot2_get_flash_addr
****************************************************************************/
uint32_t boot2_get_flash_addr(void)
uint32_t __attribute__((no_instrument_function)) boot2_get_flash_addr(void)
{
extern uint8_t __boot2_flash_cfg_src;
@ -99,6 +104,56 @@ uint32_t boot2_get_flash_addr(void)
g_boot2_partition_table.table.table.entry_cnt));
}
#ifdef CONFIG_STACK_OVERFLOW_CHECK
void __attribute__((no_instrument_function, section(".tcm_code")))
__cyg_profile_func_enter(void *this_fn, void *call_site)
{
register uintptr_t *sp;
register uintptr_t *stack_base;
__asm__("add %0, x0, sp" : "=r"(sp));
__asm__("add %0, x0, s11" : "=r"(stack_base));
if (sp <= stack_base)
{
#if CONFIG_TASK_NAME_SIZE > 0
struct tcb_s *rtcb;
#endif
__asm volatile("csrc mstatus, 8");
__asm__("li s11, 0");
#if CONFIG_TASK_NAME_SIZE > 0
/* get current task */
rtcb = running_task();
syslog(LOG_EMERG,
"task %s stack overflow detected! base:0x%x >= sp:0x%x\r\n",
rtcb->name,
stack_base,
sp);
#else
syslog(LOG_EMERG,
"stack overflow detected! base:0x%x >= sp:0x%x\r\n",
stack_base,
sp);
#endif
/* PANIC(); */
while (1)
;
}
return;
}
void __attribute__((no_instrument_function, section(".tcm_code")))
__cyg_profile_func_exit(void *this_fn, void *call_site)
{
return;
}
#endif
/****************************************************************************
* Name: bfl_main
****************************************************************************/
@ -109,6 +164,10 @@ void bfl_main(void)
asm volatile("csrw mtvec, %0" ::"r"((uintptr_t)exception_common + 2));
/* Configure IDLE stack */
g_idle_topstack = ((uint32_t)g_idle_stack + BL602_IDLESTACK_SIZE);
/* Configure the UART so we can get debug output */
bl602_lowsetup();

View File

@ -30,69 +30,22 @@
#include "hardware/bl602_glb.h"
#include "hardware/bl602_hbn.h"
/* We choose to use ROM driver here.
*
* Because BL602 will reset the XIP Flash controller when performing
* reset, this part of the code cannot be placed on the XIP Flash.
*/
typedef void (*bl602_romdrv_reset_system) (void);
typedef void (*bl602_romdrv_reset_sw_cpu) (void);
typedef void (*bl602_romdrv_reset_por) (void);
#define ROM_APITABLE ((uint32_t *)0x21010800)
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: bl602_chip_reset
*
* Description:
* Control the different reset modes
*
* Input Parameters:
* mask - Reset bitmask use these defines
* SWRST_CFG2_CTRL_SYS_RESET, SWRST_CFG2_CTRL_CPU_RESET,
* SWRST_CFG2_CTRL_PWRON_RST
*
****************************************************************************/
static void bl602_chip_reset(uint32_t mask)
{
/* Reset the root clock */
modifyreg32(BL602_HBN_GLB, HBN_GLB_HBN_ROOT_CLK_SEL_MASK, 0);
/* Clear root clock dividers */
modifyreg32(
BL602_CLK_CFG0,
CLK_CFG0_REG_BCLK_DIV_MASK | CLK_CFG0_REG_HCLK_DIV_MASK,
0
);
/* This register should toggled on-off on changes to root clock.
* details of this register are not documented, but is clear from ROM
*/
putreg32(1, 0x40000ffc);
putreg32(0, 0x40000ffc);
/* Trigger reset
* NOTE: The reset seems to be rising _edge_ triggered so the reset
* bit should be cleared first otherwise the reset will not
* trigger if it has previously fired.
*/
modifyreg32(
BL602_SWRST_CFG2,
(SWRST_CFG2_CTRL_SYS_RESET | SWRST_CFG2_CTRL_CPU_RESET | \
SWRST_CFG2_CTRL_PWRON_RST),
0
);
modifyreg32(
BL602_SWRST_CFG2,
(SWRST_CFG2_CTRL_SYS_RESET | SWRST_CFG2_CTRL_CPU_RESET | \
SWRST_CFG2_CTRL_PWRON_RST),
mask
);
/* Wait for the reset */
for (; ; );
}
/****************************************************************************
* Public Functions
****************************************************************************/
@ -107,7 +60,11 @@ static void bl602_chip_reset(uint32_t mask)
void up_systemreset(void)
{
bl602_chip_reset(SWRST_CFG2_CTRL_SYS_RESET | SWRST_CFG2_CTRL_CPU_RESET);
/* When perform reset before, MUST disable interrupt */
asm volatile("csrci mstatus, 8");
((bl602_romdrv_reset_system)(*(ROM_APITABLE + 47)))();
}
/****************************************************************************
@ -120,7 +77,11 @@ void up_systemreset(void)
void bl602_cpu_reset(void)
{
bl602_chip_reset(SWRST_CFG2_CTRL_CPU_RESET);
/* When perform reset before, MUST disable interrupt */
asm volatile("csrci mstatus, 8");
((bl602_romdrv_reset_sw_cpu)(*(ROM_APITABLE + 48)))();
}
/****************************************************************************
@ -133,8 +94,9 @@ void bl602_cpu_reset(void)
void bl602_por_reset(void)
{
bl602_chip_reset(
SWRST_CFG2_CTRL_SYS_RESET | \
SWRST_CFG2_CTRL_CPU_RESET | \
SWRST_CFG2_CTRL_PWRON_RST);
/* When perform reset before, MUST disable interrupt */
asm volatile("csrci mstatus, 8");
((bl602_romdrv_reset_por)(*(ROM_APITABLE + 49)))();
}

View File

@ -164,5 +164,11 @@ void up_initialize(void)
ptmx_register();
#endif
#ifdef CONFIG_NET_LOOPBACK
/* Initialize the local loopback device */
localhost_initialize();
#endif
board_autoled_on(LED_IRQSENABLED);
}

View File

@ -0,0 +1,110 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_DISABLE_POSIX_TIMERS is not set
# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set
# CONFIG_NSH_DISABLEBG is not set
# CONFIG_NSH_DISABLE_LOSMART is not set
# CONFIG_NSH_DISABLE_UNAME is not set
CONFIG_ARCH="risc-v"
CONFIG_ARCH_BOARD="bl602evb"
CONFIG_ARCH_BOARD_BL602EVB=y
CONFIG_ARCH_CHIP="bl602"
CONFIG_ARCH_CHIP_BL602=y
CONFIG_ARCH_INTERRUPTSTACK=8192
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BINFMT_DISABLE=y
CONFIG_BL602_BLE_CONTROLLER=y
CONFIG_BL602_HAVE_UART0=y
CONFIG_BL602_WIRELESS=y
CONFIG_BOARD_LOOPSPERMSEC=10000
CONFIG_BUILTIN=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_SMALL=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_IEEE80211=y
CONFIG_DRIVERS_WIRELESS=y
CONFIG_EXAMPLES_DHCPD=y
CONFIG_EXAMPLES_NETTEST=y
CONFIG_EXAMPLES_NETTEST_DEVNAME="wlan0"
CONFIG_EXAMPLES_NETTEST_PERFORMANCE=y
CONFIG_EXAMPLES_TCPBLASTER=y
CONFIG_EXAMPLES_TCPBLASTER_DEVNAME="wlan0"
CONFIG_EXAMPLES_TCPBLASTER_SERVERIP=0xc0a85802
CONFIG_FS_PROCFS=y
CONFIG_IDLETHREAD_STACKSIZE=8192
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_PERROR_STDOUT=y
CONFIG_LIBC_STRERROR=y
CONFIG_MAX_TASKS=16
CONFIG_MQ_MAXMSGSIZE=1024
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDEV_PHY_IOCTL=y
CONFIG_NETDEV_WIRELESS_IOCTL=y
CONFIG_NETINIT_NETLOCAL=y
CONFIG_NETINIT_WAPI_PASSPHRASE="bouffalolab2016"
CONFIG_NETINIT_WAPI_SSID="bouffalolab"
CONFIG_NETUTILS_DHCPD=y
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_DELAYED_ACK=y
CONFIG_NET_TCP_KEEPALIVE=y
CONFIG_NET_UDP=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_DISABLE_CD=y
CONFIG_NSH_DISABLE_CP=y
CONFIG_NSH_DISABLE_MKDIR=y
CONFIG_NSH_DISABLE_RM=y
CONFIG_NSH_DISABLE_RMDIR=y
CONFIG_NSH_DISABLE_UMOUNT=y
CONFIG_NSH_FILEIOSIZE=64
CONFIG_NSH_STRERROR=y
CONFIG_PREALLOC_TIMERS=0
CONFIG_PSEUDOTERM=y
CONFIG_PTHREAD_MUTEX_TYPES=y
CONFIG_PTHREAD_STACK_DEFAULT=8192
CONFIG_RAM_SIZE=134217728
CONFIG_RAM_START=0xc0800000
CONFIG_RAW_BINARY=y
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=200
CONFIG_RV32IM_CUSTOM_IRQ_SUPPORT=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SIG_EVTHREAD=y
CONFIG_SPINLOCK=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=20
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2020
CONFIG_STDIO_DISABLE_BUFFERING=y
CONFIG_SYSTEM_DHCPC_RENEW=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=12
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=8192
CONFIG_TESTING_MM=y
CONFIG_TESTING_OSTEST=y
CONFIG_UART0_BAUD=2000000
CONFIG_UART0_RXBUFSIZE=128
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_UART0_TXBUFSIZE=128
CONFIG_USERMAIN_STACKSIZE=8192
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WIRELESS_WAPI=y
CONFIG_WIRELESS_WAPI_CMDTOOL=y

View File

@ -0,0 +1,136 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_DISABLE_ENVIRON is not set
# CONFIG_DISABLE_POSIX_TIMERS is not set
# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set
# CONFIG_NSH_DISABLEBG is not set
# CONFIG_NSH_DISABLESCRIPT is not set
# CONFIG_NSH_DISABLE_DF is not set
# CONFIG_NSH_DISABLE_DIRNAME is not set
# CONFIG_NSH_DISABLE_LOSMART is not set
# CONFIG_NSH_DISABLE_REBOOT is not set
# CONFIG_NSH_DISABLE_UNAME is not set
CONFIG_ARCH="risc-v"
CONFIG_ARCH_BOARD="bl602evb"
CONFIG_ARCH_BOARD_BL602EVB=y
CONFIG_ARCH_CHIP="bl602"
CONFIG_ARCH_CHIP_BL602=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BINFMT_DISABLE=y
CONFIG_BL602_HAVE_UART0=y
CONFIG_BL602_WIRELESS=y
CONFIG_BOARDCTL_RESET=y
CONFIG_BOARD_LOOPSPERMSEC=10000
CONFIG_BUILTIN=y
CONFIG_DEBUG_ERROR=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEBUG_WARN=y
CONFIG_DEFAULT_SMALL=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_IEEE80211=y
CONFIG_DRIVERS_WIRELESS=y
CONFIG_EXAMPLES_DHCPD=y
CONFIG_EXAMPLES_DISCOVER=y
CONFIG_EXAMPLES_IPERF=y
CONFIG_EXAMPLES_NETTEST=y
CONFIG_EXAMPLES_NETTEST_DEVNAME="wlan0"
CONFIG_EXAMPLES_NETTEST_PERFORMANCE=y
CONFIG_EXAMPLES_TCPBLASTER=y
CONFIG_EXAMPLES_TCPBLASTER_DEVNAME="wlan0"
CONFIG_EXAMPLES_TCPBLASTER_SERVERIP=0xc0a85802
CONFIG_FS_PROCFS=y
CONFIG_HAVE_CXX=y
CONFIG_IDLETHREAD_STACKSIZE=800
CONFIG_INTELHEX_BINARY=y
CONFIG_IOB_BUFSIZE=146
CONFIG_IOB_NBUFFERS=64
CONFIG_IOB_NCHAINS=32
CONFIG_IOB_THROTTLE=10
CONFIG_LIBCXX=y
CONFIG_LIBC_LOCALTIME=y
CONFIG_LIBC_PERROR_STDOUT=y
CONFIG_LIBC_STRERROR=y
CONFIG_LIBM=y
CONFIG_MAX_TASKS=16
CONFIG_MEMCPY_VIK=y
CONFIG_MEMSET_OPTSPEED=y
CONFIG_MM_REGIONS=2
CONFIG_MQ_MAXMSGSIZE=224
CONFIG_MTD=y
CONFIG_MTD_PARTITION=y
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDEV_PHY_IOCTL=y
CONFIG_NETDEV_WIRELESS_IOCTL=y
CONFIG_NETINIT_NETLOCAL=y
CONFIG_NETINIT_WAPI_PASSPHRASE="bouffalolab2016"
CONFIG_NETINIT_WAPI_SSID="bouffalolab"
CONFIG_NETUTILS_DHCPD=y
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_KEEPALIVE=y
CONFIG_NET_TCP_NOTIFIER=y
CONFIG_NET_UDP=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=64
CONFIG_NSH_LINELEN=128
CONFIG_NSH_STRERROR=y
CONFIG_PREALLOC_TIMERS=0
CONFIG_PSEUDOTERM=y
CONFIG_PTHREAD_MUTEX_TYPES=y
CONFIG_PTHREAD_SPINLOCKS=y
CONFIG_RAM_SIZE=134217728
CONFIG_RAM_START=0xc0800000
CONFIG_RAW_BINARY=y
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=200
CONFIG_RV32IM_CUSTOM_IRQ_SUPPORT=y
CONFIG_SCHED_ATEXIT=y
CONFIG_SCHED_HAVE_PARENT=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKSTACKSIZE=2040
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_LPWORKSTACKSIZE=5100
CONFIG_SCHED_WAITPID=y
CONFIG_SIG_EVTHREAD=y
CONFIG_SPINLOCK=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=20
CONFIG_START_MONTH=3
CONFIG_START_YEAR=2020
CONFIG_STDIO_DISABLE_BUFFERING=y
CONFIG_SYSTEM_DHCPC_RENEW=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_NSH_PRIORITY=50
CONFIG_SYSTEM_NSH_STACKSIZE=2500
CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=12
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=8192
CONFIG_TESTING_MM=y
CONFIG_TESTING_OSTEST=y
CONFIG_TESTING_OSTEST_FPUSIZE=132
CONFIG_UART0_BAUD=2000000
CONFIG_UART0_RXBUFSIZE=128
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_UART0_TXBUFSIZE=128
CONFIG_USEC_PER_TICK=1000
CONFIG_USERMAIN_STACKSIZE=1800
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WIRELESS_WAPI=y
CONFIG_WIRELESS_WAPI_CMDTOOL=y

View File

@ -41,21 +41,25 @@ endif
MAXOPTIMIZATION = -Os
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce
endif
ARCHCPUFLAGS = -march=rv32imfc -mabi=ilp32f -mno-relax
ARCHCFLAGS = -fno-builtin -ffunction-sections -fdata-sections
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
ARCHCPUFLAGS = -march=rv32imafc -mabi=ilp32f -mno-relax
ARCHCFLAGS = -fno-builtin -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -fshort-enums -fno-omit-frame-pointer
ARCHCXXFLAGS = -fno-builtin -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -fshort-enums -fno-omit-frame-pointer -fno-exceptions -fcheck-new -std=c++17 -D__NuttX__ -pipe -nostdinc++
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
ifeq ($(CONFIG_STACK_OVERFLOW_CHECK),y)
ARCHCFLAGS += -finstrument-functions -ffixed-s11
endif
ARCHDEFINES += -DARCH_RISCV
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS)
@ -76,5 +80,6 @@ else
LDELFFLAGS += -T $(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld
endif
LDFLAGS += --gc-sections -melf32lriscv
LDFLAGS += --gc-sections -melf32lriscv --cref
LDFLAGS += -Map=$(TOPDIR)/nuttx.map

View File

@ -8,13 +8,13 @@ MEMORY
{
rom (rxai!w) : ORIGIN = 0x21015000, LENGTH = 44K
flash (rxai!w) : ORIGIN = 0x23000000, LENGTH = 4M
ram_tcm (wxa) : ORIGIN = 0x4200C000, LENGTH = (16K + 16K + 48K + 64K + 64K + 8K - __EM_SIZE) /*put itcm with dtam and also OCRAM*/
ram_wifi (wxa) : ORIGIN = 0x42042000 - __EM_SIZE, LENGTH = (8K + 104K - 64K - 8K) /*leave 8K left for BLE*/
ram_tcm (wxa) : ORIGIN = 0x4200E000, LENGTH = (32K + 48K + 64K - 8K) /* itcm_32 + dtcm_48 + ocram_64 */
ram_wifi (wxa) : ORIGIN = 0x42030000, LENGTH = (112K - 8K) /* 8K left for em */
}
SECTIONS
{
__stack_size = DEFINED(__stack_size) ? __stack_size : 2K;
/* __stack_size = DEFINED(__stack_size) ? __stack_size : 2K; */
BOOT2_PT_ADDR = 0x42049C00;
BOOT2_FLASHCFG_ADDR = 0x42049c18;
@ -25,10 +25,12 @@ SECTIONS
.text :
{
PROVIDE(_stext = .);
*(.text.unlikely .text.unlikely.*)
*(.text.startup .text.startup.*)
*(.text .text.*)
*(.gnu.linkonce.t.*)
PROVIDE(_etext = .);
} > flash
.rodata :
@ -46,6 +48,25 @@ SECTIONS
*(.gnu.linkonce.r.*)
} > flash
.preinit_array :
{
. = ALIGN(4);
__preinit_array_start = .;
KEEP (*(.preinit_array))
__preinit_array_end = .;
} > flash
.init_array :
{
. = ALIGN(4);
__init_array_start = .;
_sinit = .;
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
KEEP (*(.init_array))
__init_array_end = .;
_einit = .;
} > flash
/*put wifibss in the first place*/
.wifibss (NOLOAD) :
{
@ -126,6 +147,12 @@ SECTIONS
PROVIDE ( __boot2_flash_cfg_end = . );
} > ram_tcm
.noinit (NOLOAD) :
{
. = ALIGN(16);
*(.noinit_idle_stack*)
} > ram_tcm
.bss (NOLOAD) :
{
PROVIDE( __bss_start = ADDR(.bss) );
@ -144,10 +171,12 @@ SECTIONS
PROVIDE( _heap_start = . );
PROVIDE( _heap_size = ADDR(.stack) - _heap_start );
.stack ORIGIN(ram_tcm) + LENGTH(ram_tcm) - __stack_size (NOLOAD) :
/* .stack ORIGIN(ram_tcm) + LENGTH(ram_tcm) - __stack_size (NOLOAD) : */
.stack ORIGIN(ram_tcm) + LENGTH(ram_tcm) (NOLOAD) :
{
. = . + __stack_size;
PROVIDE( _sp_main = . );
PROVIDE( _sp_irq_base = . );
/* . = . + __stack_size; */
/* PROVIDE( _sp_main = . ); */
} >ram_tcm
/*CFG FW used in code*/

View File

@ -28,17 +28,21 @@
#include <sys/mount.h>
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
#include <syslog.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#include <nuttx/fs/fs.h>
#include <nuttx/wdog.h>
#include <nuttx/wqueue.h>
#include <nuttx/input/buttons.h>
#include <bl602_tim_lowerhalf.h>
#include <bl602_oneshot_lowerhalf.h>
#include <bl602_pwm_lowerhalf.h>
#include <bl602_wdt_lowerhalf.h>
#include <bl602_glb.h>
#include <bl602_gpio.h>
#include <bl602_i2c.h>
#include <bl602_spi.h>
@ -60,10 +64,42 @@
#include "chip.h"
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
#if defined(CONFIG_BL602_BLE_CONTROLLER)
static void bl602_net_poll_work(FAR void *arg);
static void ble_hci_rx_poll_expiry(wdparm_t arg);
#endif
/****************************************************************************
* Private Data
****************************************************************************/
#if defined(CONFIG_BL602_BLE_CONTROLLER)
/* BLE HCI timer */
static struct wdog_s g_ble_hci_rx_poll;
/* For deferring poll work to the work queue */
static struct work_s g_ble_hci_rx_work;
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
#if defined(CONFIG_BL602_WIRELESS)
extern int bl602_net_initialize(int intf);
#endif
#if defined(CONFIG_BL602_BLE_CONTROLLER)
extern void bl602_hci_uart_init(uint8_t uartid);
extern int ble_hci_do_rx(void);
#endif
/****************************************************************************
* Name: bl602_bringup
****************************************************************************/
@ -98,6 +134,17 @@ int bl602_bringup(void)
}
#endif
#ifdef CONFIG_FS_TMPFS
/* Mount the tmpfs file system */
ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at %s: %d\n",
CONFIG_LIBC_TMPDIR, ret);
}
#endif
#if defined(CONFIG_TIMER)
#if defined(CONFIG_BL602_TIMER0)
ret = bl602_timer_initialize("/dev/timer0", 0);
@ -211,17 +258,32 @@ int bl602_bringup(void)
/* Mount the SPIFFS file system */
#ifdef CONFIG_FS_LITTLEFS
ret = nx_mount(path, "/mnt/lfs", "littlefs", 0, "autoformat");
ret = nx_mount(path, "/data", "littlefs", 0, "autoformat");
if (ret < 0)
{
syslog(LOG_DEBUG,
"ERROR: Failed to mount littlefs at /mnt/llfs: %d\n", ret);
"ERROR: Failed to mount littlefs at /data: %d\n", ret);
return -1;
}
#endif /* CONFIG_FS_LITTLEFS */
#endif /* CONFIG_BL602_SPIFLASH */
#ifdef CONFIG_BL602_WIRELESS
bl602_set_em_sel(BL602_GLB_EM_8KB);
bl602_net_initialize(0);
#endif
#if defined(CONFIG_BL602_BLE_CONTROLLER)
bl602_hci_uart_init(0);
/* 50ms interval */
wd_start(&g_ble_hci_rx_poll,
1 * CLOCKS_PER_SEC / 20, ble_hci_rx_poll_expiry, (wdparm_t)NULL);
#endif /* CONFIG_BL602_BLE_CONTROLLER */
#ifdef CONFIG_FS_ROMFS
/* Create a ROM disk for the /sbin filesystem */
@ -250,3 +312,29 @@ int bl602_bringup(void)
return ret;
}
/****************************************************************************
* Private Functions
****************************************************************************/
#if defined(CONFIG_BL602_BLE_CONTROLLER)
static void bl602_net_poll_work(FAR void *arg)
{
ble_hci_do_rx();
/* 50ms interval */
wd_start(&g_ble_hci_rx_poll,
1 * CLOCKS_PER_SEC / 20, ble_hci_rx_poll_expiry, (wdparm_t)NULL);
}
static void ble_hci_rx_poll_expiry(wdparm_t arg)
{
UNUSED(arg);
if (work_available(&g_ble_hci_rx_work))
{
work_queue(LPWORK, &g_ble_hci_rx_work, bl602_net_poll_work, NULL, 0);
}
}
#endif