mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-06-13 04:33:18 +08:00
[bsp]add new bsp-bl808 (#6824)
* add new bsp-bl808 * support ARCH_RISCV_FPU_S && update rtconfig.py
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
# 博流智能 BL808板级支持包说明
|
||||
|
||||
## 1. 简介
|
||||
|
||||
BL808 是高度集成的 AIoT 芯片组,具有 Wi-Fi/BT/BLE/Zigbee 等无线互联单元,包含多个 CPU 以及音频编码译码器、视频编码译码器和 AI 硬件加速器,适用于各种高性能和低功耗应用领域。
|
||||
|
||||
BL808 系列芯片主要包含无线和多媒体两个子系统。
|
||||
|
||||
无线子系统包含一颗 RISC-V 32-bit 高性能 CPU(m0),集成 Wi-Fi/BT/Zigbee 无线子系统,可以实现多种无线连接和数据传输,提供多样化的连接与传输体验。
|
||||
多媒体子系统包含一颗 RISC-V 64-bit 超高性能 CPU(d0),集成 DVP/CSI/ H264/NPU 等视频处理模块,可以广泛应用于视频监控/智能音箱等多种 AI 领域
|
||||
|
||||
多媒体子系统组成部分如下:
|
||||
|
||||
- NPU HW NN 协处理器 (BLAI-100),适用于人工智能应用领域
|
||||
- 摄像头接口
|
||||
- 音频编码译码器
|
||||
- 视频编码解码器
|
||||
- 传感器
|
||||
- 显示接口
|
||||
|
||||
电源管理单元控制低功耗模式。此外,还支持各种安全功能。
|
||||
|
||||
外围接口包括 USB2.0、 Ethernet、 SD/MMC、 SPI、 UART、 I2C、 I2S、 PWM、 GPDAC/GPADC、 ACOMP、 PIR、 Touch、
|
||||
IR remote、 Display 和 GPIO。
|
||||
|
||||
支持灵活的 GPIO 配置, BL808 最多可达 40 个 GPIO。
|
||||
|
||||
芯片规格包括如下:
|
||||
|
||||
| 硬件 | 描述 |
|
||||
| -- | -- |
|
||||
|芯片型号| bl808 |
|
||||
|CPU| 三核异构RISC-V CPUs: <br />RV64GCV 480MHz<br/>RV32GCP 320MHz<br/>RV32EMC 160MHz |
|
||||
|RAM| 768KB SRAM + 64MB UHS PSRAM |
|
||||
| 外设 | 内嵌AES与SHA256算法加速器 |
|
||||
| AI NN 通用硬件加速器 | BLAI-100 用于视频/音频检测/识别,100GOPS 算力 |
|
||||
| 摄像头接口 | DVP 和 MIPI-CSI |
|
||||
| 显示接口 | SPI、DBI、DPI(RGB) |
|
||||
| 无线 | 支持 Wi-Fi 802.11 b/g/n<br/>支持 Bluetooth 5.x Dual-mode(BT+BLE)<br/>支持 Wi-Fi / 蓝牙 共存 |
|
||||
|
||||
## 2. 编译说明
|
||||
|
||||
BL808是多核异构架构,每个核需要单独编译,并烧录到对应的位置。
|
||||
|
||||
Windows下推荐使用[env工具][1],然后在console下进入bsp/bl808目录中,选择需要编译的核心,m0或d0,运行:
|
||||
|
||||
cd bsp/bl808/m0
|
||||
menuconfig
|
||||
pkgs --update
|
||||
|
||||
如果在Linux平台下,可以先执行
|
||||
|
||||
scons --menuconfig
|
||||
|
||||
它会自动下载env相关脚本到~/.env目录,然后执行
|
||||
|
||||
source ~/.env/env.sh
|
||||
|
||||
cd bsp/bl808/m0
|
||||
pkgs --update
|
||||
下载risc-v的工具链,[下载地址](https://occ.t-head.cn/community/download?id=4073475960903634944)或[下载地址](https://dl.sipeed.com/shareURL/others/toolchain)
|
||||
|
||||
更新完软件包后,在`rtconfig.py`中将risc-v工具链的本地路径加入文档。
|
||||
|
||||
然后执行scons编译:
|
||||
|
||||
```
|
||||
set RTT_EXEC_PATH=C:\Users\xxxx\Downloads\Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/bin
|
||||
scons
|
||||
```
|
||||
来编译这个板级支持包。
|
||||
|
||||
或者通过 `scons --exec-path="GCC工具链路径"` 命令,在指定工具链位置的同时直接编译。
|
||||
|
||||
如果编译正确无误,会产生rtthread.elf、rtthread_m0.bin文件。其中rtthread_m0.bin需要烧写到设备中进行运行。
|
||||
|
||||
## 3. 烧写及执行
|
||||
|
||||
连接好串口,然后使用[Bouffalo Lab Dev Cube](https://dev.bouffalolab.com/download)工具进行烧写bin文件。
|
||||
|
||||

|
||||
|
||||
### 3.1 运行结果
|
||||
|
||||
如果编译 & 烧写无误,当复位设备后,会在串口上看到RT-Thread的启动logo信息:
|
||||
|
||||

|
||||
|
||||
## 4. 驱动支持情况及计划
|
||||
|
||||
| 驱动 | 支持情况 | 备注 |
|
||||
| ------ | ---- | :------: |
|
||||
| UART | 支持 | UART0,用于shell,默认波特率2000000 |
|
||||
|
||||
## 5. 联系人信息
|
||||
|
||||
维护人:[flyingcys](https://github.com/flyingcys)
|
||||
|
||||
## 6. 支持开发板列表
|
||||
|
||||
| | 开发板型号 |
|
||||
| ------ | ---------- |
|
||||
| Sipeed | M1s Dock |
|
||||
| | |
|
||||
|
||||
|
||||
## 7. 参考
|
||||
* 芯片[datasheet][2]
|
||||
|
||||
[1]: https://www.rt-thread.org/page/download.html
|
||||
[2]: https://github.com/bouffalolab/bl_docs
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 137 KiB |
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
mainmenu "RT-Thread Project Configuration"
|
||||
|
||||
config BSP_DIR
|
||||
string
|
||||
option env="BSP_ROOT"
|
||||
default "."
|
||||
|
||||
config RTT_DIR
|
||||
string
|
||||
option env="RTT_ROOT"
|
||||
default "../../.."
|
||||
|
||||
config PKGS_DIR
|
||||
string
|
||||
option env="PKGS_ROOT"
|
||||
default "packages"
|
||||
|
||||
source "$RTT_DIR/Kconfig"
|
||||
source "$PKGS_DIR/Kconfig"
|
||||
source "drivers/Kconfig"
|
||||
@@ -0,0 +1,14 @@
|
||||
# for module compiling
|
||||
import os
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(d, 'SConscript'))
|
||||
|
||||
Return('objs')
|
||||
@@ -0,0 +1,36 @@
|
||||
import os
|
||||
import sys
|
||||
import rtconfig
|
||||
|
||||
from rtconfig import RTT_ROOT
|
||||
|
||||
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||
from building import *
|
||||
|
||||
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
|
||||
|
||||
DefaultEnvironment(tools=[])
|
||||
env = Environment(tools = ['mingw'],
|
||||
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
||||
CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
|
||||
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
|
||||
AR = rtconfig.AR, ARFLAGS = '-rc',
|
||||
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
||||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||
env['ASCOM'] = env['ASPPCOM']
|
||||
|
||||
Export('RTT_ROOT')
|
||||
Export('rtconfig')
|
||||
|
||||
# prepare building environment
|
||||
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
|
||||
|
||||
stack_size = 4096
|
||||
|
||||
stack_lds = open('link_stacksize.lds', 'w')
|
||||
if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
|
||||
stack_lds.write('__STACKSIZE__ = %d;' % stack_size)
|
||||
stack_lds.close()
|
||||
|
||||
# make a building
|
||||
DoBuilding(TARGET, objs)
|
||||
@@ -0,0 +1,9 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022/12/25 flyingcys first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
rt_kprintf("Hello, world\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
menu "BL808_M0 Hardware Drivers Config"
|
||||
config SOC_BL808
|
||||
bool
|
||||
select RT_USING_COMPONENTS_INIT
|
||||
select RT_USING_USER_MAIN
|
||||
select ARCH_RISCV_FPU_S
|
||||
default y
|
||||
|
||||
|
||||
config BSP_USING_JTAG_M0
|
||||
bool "Enable M0 JTAG "
|
||||
default n
|
||||
|
||||
menu "On-chip Peripheral Drivers"
|
||||
|
||||
config BSP_USING_GPIO
|
||||
bool "Enable GPIO"
|
||||
select RT_USING_PIN
|
||||
default y
|
||||
|
||||
menuconfig BSP_USING_UART
|
||||
bool "Enable UART"
|
||||
default y
|
||||
select RT_USING_SERIAL
|
||||
if BSP_USING_UART
|
||||
config BSP_USING_UART0
|
||||
bool "Enable UART0"
|
||||
default y
|
||||
|
||||
if BSP_USING_UART0
|
||||
config BSP_UART0_TXD_PIN
|
||||
int "uart0 TXD pin number"
|
||||
default 14
|
||||
|
||||
config BSP_UART0_RXD_PIN
|
||||
int "uart0 RXD pin number"
|
||||
default 15
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# RT-Thread building script for component
|
||||
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Split('''
|
||||
board.c
|
||||
''')
|
||||
|
||||
CPPPATH = [cwd]
|
||||
|
||||
if GetDepend(['RT_USING_SERIAL']):
|
||||
if GetDepend(['RT_USING_SERIAL_V2']):
|
||||
src += ['drv_uart_v2.c']
|
||||
else:
|
||||
src += ['drv_uart.c']
|
||||
|
||||
# if GetDepend('RT_USING_PIN'):
|
||||
# src += ['drv_gpio.c']
|
||||
|
||||
# if GetDepend('BSP_USING_LCD'):
|
||||
# src += ['drv_lcd.c']
|
||||
# src += ['drv_mpylcd.c']
|
||||
|
||||
# if GetDepend('RT_USING_HWTIMER'):
|
||||
# src += ['drv_hw_timer.c']
|
||||
|
||||
# if GetDepend('RT_USING_CPUTIME'):
|
||||
# src += ['drv_cputime.c']
|
||||
|
||||
# if GetDepend('RT_USING_I2C'):
|
||||
# src += ['drv_i2c.c']
|
||||
|
||||
# if GetDepend('RT_USING_SPI'):
|
||||
# src += ['drv_spi.c']
|
||||
|
||||
# if GetDepend('RT_USING_PWM'):
|
||||
# src += ['drv_pwm.c']
|
||||
|
||||
# if GetDepend('RT_USING_WDT'):
|
||||
# src += ['drv_wdt.c']
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
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')
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022/12/25 flyingcys first version
|
||||
*/
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "drv_uart.h"
|
||||
|
||||
static void sipeed_bl_sys_enabe_jtag(int cpuid)
|
||||
{
|
||||
GLB_GPIO_Cfg_Type gpio_cfg;
|
||||
|
||||
gpio_cfg.drive = 0;
|
||||
gpio_cfg.smtCtrl = 1;
|
||||
gpio_cfg.pullType = GPIO_PULL_NONE;
|
||||
|
||||
gpio_cfg.gpioMode = GPIO_MODE_AF;
|
||||
switch (cpuid) {
|
||||
case 0: {
|
||||
gpio_cfg.gpioFun = GPIO_FUN_JTAG_M0;
|
||||
} break;
|
||||
case 1: {
|
||||
gpio_cfg.gpioFun = GPIO_FUN_JTAG_D0;
|
||||
} break;
|
||||
default: {
|
||||
} break;
|
||||
}
|
||||
gpio_cfg.gpioPin = GLB_GPIO_PIN_0;
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.gpioPin = GLB_GPIO_PIN_1;
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.gpioPin = GLB_GPIO_PIN_2;
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.gpioPin = GLB_GPIO_PIN_3;
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
}
|
||||
|
||||
static void cmd_jtag_m0(void)
|
||||
{
|
||||
sipeed_bl_sys_enabe_jtag(0);
|
||||
}
|
||||
|
||||
static void cmd_jtag_cpu0(void)
|
||||
{
|
||||
sipeed_bl_sys_enabe_jtag(1);
|
||||
}
|
||||
|
||||
/* This is the timer interrupt service routine. */
|
||||
static void mtime_handler(void)
|
||||
{
|
||||
rt_tick_increase();
|
||||
|
||||
csi_coret_config(CPU_Get_MTimer_Clock() / RT_TICK_PER_SECOND, MTIME_IRQn);
|
||||
}
|
||||
|
||||
void rt_hw_board_init(void)
|
||||
{
|
||||
bl_sys_lowlevel_init();
|
||||
|
||||
csi_coret_config(CPU_Get_MTimer_Clock() / RT_TICK_PER_SECOND, MTIME_IRQn);
|
||||
bl_irq_register(MTIME_IRQn, mtime_handler);
|
||||
bl_irq_enable(MTIME_IRQn);
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
/* initialize memory system */
|
||||
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
|
||||
#endif
|
||||
|
||||
/* UART driver initialization is open by default */
|
||||
#ifdef RT_USING_SERIAL
|
||||
rt_hw_uart_init();
|
||||
#endif
|
||||
|
||||
/* Set the shell console output device */
|
||||
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_board_init();
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_JTAG_M0
|
||||
cmd_jtag_m0();
|
||||
#endif
|
||||
}
|
||||
|
||||
void rt_hw_cpu_reset(void)
|
||||
{
|
||||
bl_sys_reset_por();
|
||||
while(1);
|
||||
}
|
||||
|
||||
MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reboot, reset machine);
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022/12/25 flyingcys first version
|
||||
*/
|
||||
|
||||
#ifndef BOARD_H__
|
||||
#define BOARD_H__
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
#include "core_rv32.h"
|
||||
#include "bl_sys.h"
|
||||
#include "bl_irq.h"
|
||||
#include "bl808_clock.h"
|
||||
|
||||
#ifdef BL808
|
||||
#include "bl808.h"
|
||||
#elif defined(BL606P)
|
||||
#include "bl606p.h"
|
||||
#endif
|
||||
|
||||
extern uint8_t _heap_start;
|
||||
extern uint8_t _heap_size;
|
||||
|
||||
#define RT_HW_HEAP_BEGIN (void*)&_heap_start
|
||||
#define RT_HW_HEAP_END (void*)(&_heap_start + (rt_ubase_t)&_heap_size)
|
||||
|
||||
void rt_hw_board_init(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022/12/25 flyingcys first version
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "drv_uart.h"
|
||||
|
||||
|
||||
struct device_uart
|
||||
{
|
||||
struct rt_serial_device serial;
|
||||
uint8_t port;
|
||||
uint8_t tx_pin;
|
||||
uint8_t rx_pin;
|
||||
};
|
||||
|
||||
static void _uart_rx_irq(void *param)
|
||||
{
|
||||
struct device_uart *uart = (struct device_uart *)param;;
|
||||
|
||||
struct rt_serial_device *serial = &uart->serial;
|
||||
|
||||
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
|
||||
}
|
||||
|
||||
static int uart_signal_get(uint8_t pin)
|
||||
{
|
||||
//TODO no magic number is allowed here
|
||||
if (pin >= 12 && pin <=23) {
|
||||
return (pin + 6) % 12;
|
||||
} else if (pin >= 36 && pin <=45) {
|
||||
return (pin + 6) % 12;
|
||||
}
|
||||
return (pin % 12);
|
||||
}
|
||||
|
||||
static int uart_func_get(uint8_t id, GLB_UART_SIG_FUN_Type uartfunc)
|
||||
{
|
||||
switch (id) {
|
||||
case 0:
|
||||
return uartfunc;
|
||||
case 1:
|
||||
return (GLB_UART_SIG_FUN_UART1_RTS - GLB_UART_SIG_FUN_UART0_RTS) * 1 + uartfunc;
|
||||
case 2:
|
||||
return (GLB_UART_SIG_FUN_UART1_RTS - GLB_UART_SIG_FUN_UART0_RTS) * 1 + uartfunc;
|
||||
default:
|
||||
/*empty here*/
|
||||
//TODO should assert here?
|
||||
return uartfunc;
|
||||
}
|
||||
}
|
||||
static void uart_gpio_demo(uint8_t id, uint8_t tx_pin, uint8_t rx_pin, uint8_t cts_pin, uint8_t rts_pin)
|
||||
{
|
||||
GLB_GPIO_Cfg_Type gpio_cfg;
|
||||
uint8_t uart_func, uart_sig;
|
||||
|
||||
//FIXME SWAP set is NOT put here
|
||||
GLB_UART_Sig_Swap_Set(GLB_UART_SIG_SWAP_GRP_GPIO12_GPIO23, 1);
|
||||
GLB_UART_Sig_Swap_Set(GLB_UART_SIG_SWAP_GRP_GPIO36_GPIO45, 1);
|
||||
|
||||
//common GPIO cfg
|
||||
gpio_cfg.drive = 0;
|
||||
gpio_cfg.smtCtrl = 1;
|
||||
gpio_cfg.gpioMode = GPIO_MODE_AF;
|
||||
gpio_cfg.pullType = GPIO_PULL_UP;
|
||||
gpio_cfg.gpioFun = GPIO_FUN_UART;
|
||||
|
||||
//cfg for UART Tx
|
||||
gpio_cfg.gpioPin = GLB_GPIO_PIN_0 + tx_pin;
|
||||
uart_func = uart_func_get(id, GLB_UART_SIG_FUN_UART0_TXD);
|
||||
uart_sig = uart_signal_get(gpio_cfg.gpioPin);
|
||||
GLB_UART_Fun_Sel((GLB_UART_SIG_Type)uart_sig, (GLB_UART_SIG_FUN_Type)uart_func);
|
||||
GLB_UART_Fun_Sel((GLB_UART_SIG_Type)uart_func, (GLB_UART_SIG_FUN_Type)uart_sig);
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
|
||||
//cfg for UART Rx
|
||||
gpio_cfg.gpioPin = GLB_GPIO_PIN_0 + rx_pin;
|
||||
uart_func = uart_func_get(id, GLB_UART_SIG_FUN_UART0_RXD);
|
||||
uart_sig = uart_signal_get(gpio_cfg.gpioPin);
|
||||
GLB_UART_Fun_Sel((GLB_UART_SIG_Type)uart_sig, (GLB_UART_SIG_FUN_Type)uart_func);
|
||||
GLB_UART_Fun_Sel((GLB_UART_SIG_Type)uart_func, (GLB_UART_SIG_FUN_Type)uart_sig);
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
|
||||
//Enable UART clock
|
||||
GLB_Set_UART_CLK(1, 0, 0);
|
||||
}
|
||||
|
||||
static rt_err_t _uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
|
||||
{
|
||||
struct device_uart *uart;
|
||||
uint8_t id;
|
||||
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
RT_ASSERT(cfg != RT_NULL);
|
||||
|
||||
uart = serial->parent.user_data;
|
||||
RT_ASSERT(uart != RT_NULL);
|
||||
|
||||
id = uart->port;
|
||||
|
||||
UART_CFG_Type uart_cfg = {
|
||||
80*1000*1000, /*UART clock from XTAL*/
|
||||
2000000, /* baudrate */
|
||||
UART_DATABITS_8, /* data bits */
|
||||
UART_STOPBITS_1, /* stop bits */
|
||||
UART_PARITY_NONE, /* parity */
|
||||
DISABLE, /* Disable auto flow control */
|
||||
DISABLE, /* Disable rx input de-glitch function */
|
||||
DISABLE, /* Disable RTS output SW control mode */
|
||||
DISABLE, /* Disable tx output SW control mode */
|
||||
DISABLE, /* Disable tx lin mode */
|
||||
DISABLE, /* Disable rx lin mode */
|
||||
0, /* Tx break bit count for lin mode */
|
||||
UART_LSB_FIRST, /* UART each data byte is send out LSB-first */
|
||||
};
|
||||
|
||||
UART_FifoCfg_Type fifoCfg = {
|
||||
16, /* TX FIFO threshold */
|
||||
16, /* RX FIFO threshold */
|
||||
DISABLE, /* Disable tx dma req/ack interface */
|
||||
DISABLE /* Disable rx dma req/ack interface */
|
||||
};
|
||||
|
||||
/* init debug uart gpio first */
|
||||
uart_gpio_demo(id, uart->tx_pin, uart->rx_pin, 0xff, 0xff);
|
||||
|
||||
/* disable all interrupt */
|
||||
UART_IntMask(id, UART_INT_ALL, MASK);
|
||||
|
||||
/* disable uart before config */
|
||||
UART_Disable(id, UART_TXRX);
|
||||
|
||||
uart_cfg.baudRate = cfg->baud_rate;
|
||||
|
||||
switch (cfg->data_bits)
|
||||
{
|
||||
case DATA_BITS_5:
|
||||
uart_cfg.dataBits = UART_DATABITS_5;
|
||||
break;
|
||||
|
||||
case DATA_BITS_6:
|
||||
uart_cfg.dataBits = UART_DATABITS_6;
|
||||
break;
|
||||
|
||||
case DATA_BITS_7:
|
||||
uart_cfg.dataBits = UART_DATABITS_7;
|
||||
break;
|
||||
|
||||
case DATA_BITS_8:
|
||||
uart_cfg.dataBits = UART_DATABITS_8;
|
||||
break;
|
||||
|
||||
default:
|
||||
uart_cfg.dataBits = UART_DATABITS_8;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (cfg->stop_bits)
|
||||
{
|
||||
case STOP_BITS_1:
|
||||
uart_cfg.stopBits = UART_STOPBITS_1;
|
||||
break;
|
||||
|
||||
case STOP_BITS_2:
|
||||
uart_cfg.stopBits = UART_STOPBITS_2;
|
||||
break;
|
||||
|
||||
default:
|
||||
uart_cfg.stopBits = UART_STOPBITS_1;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (cfg->parity)
|
||||
{
|
||||
case PARITY_NONE:
|
||||
uart_cfg.parity = UART_PARITY_NONE;
|
||||
break;
|
||||
|
||||
case PARITY_ODD:
|
||||
uart_cfg.parity = UART_PARITY_ODD;
|
||||
break;
|
||||
|
||||
case PARITY_EVEN:
|
||||
uart_cfg.parity = UART_PARITY_EVEN;
|
||||
break;
|
||||
|
||||
default:
|
||||
uart_cfg.parity = UART_PARITY_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* uart init with configuration */
|
||||
UART_Init(id, &uart_cfg);
|
||||
|
||||
/* UART fifo configuration */
|
||||
UART_FifoConfig(id, &fifoCfg);
|
||||
|
||||
/* Enable tx free run mode */
|
||||
UART_TxFreeRun(id, ENABLE);
|
||||
|
||||
/* Set rx time-out value */
|
||||
UART_SetRxTimeoutValue(id, UART_DEFAULT_RTO_TIMEOUT);
|
||||
|
||||
/* enable uart */
|
||||
UART_AutoBaudDetection(id, 0);
|
||||
UART_Enable(id, UART_TXRX);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t _uart_control(struct rt_serial_device *serial, int cmd, void *arg)
|
||||
{
|
||||
struct device_uart *uart;
|
||||
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
|
||||
uart = serial->parent.user_data;
|
||||
RT_ASSERT(uart != RT_NULL);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
/* disable interrupt */
|
||||
case RT_DEVICE_CTRL_CLR_INT:
|
||||
bl_uart_int_disable(uart->port);
|
||||
bl_uart_int_rx_notify_unregister(uart->port, _uart_rx_irq, uart);
|
||||
break;
|
||||
|
||||
/* enable interrupt */
|
||||
case RT_DEVICE_CTRL_SET_INT:
|
||||
bl_uart_int_rx_notify_register(uart->port, _uart_rx_irq, uart);
|
||||
bl_uart_int_enable(uart->port);
|
||||
break;
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static int _uart_putc(struct rt_serial_device *serial, char c)
|
||||
{
|
||||
struct device_uart *uart;
|
||||
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
|
||||
uart = serial->parent.user_data;
|
||||
RT_ASSERT(uart != RT_NULL);
|
||||
|
||||
bl_uart_data_send(uart->port, c);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _uart_getc(struct rt_serial_device *serial)
|
||||
{
|
||||
int ch = -1;
|
||||
struct device_uart *uart;
|
||||
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = serial->parent.user_data;
|
||||
RT_ASSERT(uart != RT_NULL);
|
||||
|
||||
ch = bl_uart_data_recv(uart->port);
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
static const struct rt_uart_ops _uart_ops =
|
||||
{
|
||||
.configure = _uart_configure,
|
||||
.control = _uart_control,
|
||||
.putc = _uart_putc,
|
||||
.getc = _uart_getc,
|
||||
.dma_transmit = RT_NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* UART Initiation
|
||||
*/
|
||||
int rt_hw_uart_init(void)
|
||||
{
|
||||
rt_err_t result = 0;
|
||||
|
||||
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
|
||||
struct rt_serial_device *serial;
|
||||
struct device_uart *uart;
|
||||
|
||||
#ifdef BSP_USING_UART0
|
||||
static struct device_uart uart0;
|
||||
|
||||
serial = &uart0.serial;
|
||||
uart = &uart0;
|
||||
|
||||
serial->ops = &_uart_ops;
|
||||
serial->config = config;
|
||||
serial->config.baud_rate = 2000000;
|
||||
|
||||
uart->port = 0;
|
||||
uart->tx_pin = BSP_UART0_TXD_PIN;
|
||||
uart->rx_pin = BSP_UART0_RXD_PIN;
|
||||
|
||||
/* register USART device */
|
||||
result = rt_hw_serial_register(serial,
|
||||
"uart0",
|
||||
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
|
||||
uart);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022/12/25 flyingcys first version
|
||||
*/
|
||||
|
||||
#ifndef __DRV_USART_H__
|
||||
#define __DRV_USART_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "rtdevice.h"
|
||||
#include <rthw.h>
|
||||
|
||||
#include "bl_uart.h"
|
||||
#include "bl808_uart.h"
|
||||
|
||||
#include "uart_config.h"
|
||||
|
||||
int rt_hw_uart_init(void);
|
||||
|
||||
#endif /* __DRV_USART_H__ */
|
||||
@@ -0,0 +1,101 @@
|
||||
import os
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
# add general drivers
|
||||
src = Split('''
|
||||
platform/soc/bl808/startup_bl808/evb/src/startup_interrupt.c
|
||||
platform/soc/bl808/startup_bl808/evb/src/startup_bl606p.c
|
||||
platform/soc/bl808/startup_bl808/evb/src/debug.c
|
||||
platform/soc/bl808/startup_bl808/evb/src/boot/gcc/start_load.c
|
||||
platform/soc/bl808/startup_bl808/evb/src/boot/gcc/startup.S
|
||||
''')
|
||||
|
||||
path = [cwd,
|
||||
cwd + r'/platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/regs',
|
||||
cwd + r'/platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/startup/m0/source',
|
||||
cwd + r'/platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/inc',
|
||||
cwd + r'/platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/risc-v/Core/Include',
|
||||
cwd + r'/platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/hal_drv/default_config',
|
||||
cwd + r'/platform/soc/bl808/bl808_e907_std/common/misc',
|
||||
cwd + r'/platform/soc/bl808/bl808_e907_std/common/soft_crc']
|
||||
|
||||
src += Split("""
|
||||
stage/blog/blog.c
|
||||
utils/src/utils_log.c
|
||||
stage/blfdt/src/fdt.c
|
||||
stage/blfdt/src/fdt_ro.c
|
||||
stage/blfdt/src/fdt_wip.c
|
||||
stage/blfdt/src/fdt_sw.c
|
||||
stage/blfdt/src/fdt_rw.c
|
||||
stage/blfdt/src/fdt_strerror.c
|
||||
stage/blfdt/src/fdt_empty_tree.c
|
||||
stage/blfdt/src/fdt_addresses.c
|
||||
stage/blfdt/src/fdt_overlay.c
|
||||
""")
|
||||
|
||||
path += [cwd + r'/stage/blog',
|
||||
cwd + r'/stage/blfdt/inc',
|
||||
cwd + r'/utils/include'
|
||||
]
|
||||
|
||||
# platform/hosal/bl808_e907_hal/bl_pm.c
|
||||
# platform/hosal/bl808_e907_hal/bl_sec.c
|
||||
# platform/hosal/bl808_e907_hal/bl_timer.c
|
||||
# platform/hosal/bl808_e907_hal/hal_board.c
|
||||
# platform/hosal/bl808_e907_hal/hal_sdh.c
|
||||
# platform/hosal/bl808_e907_hal/hosal_adc.c
|
||||
# platform/hosal/bl808_e907_hal/hosal_dma.c
|
||||
# platform/hosal/bl808_e907_hal/hosal_pwm.c
|
||||
# platform/hosal/bl808_e907_hal/hosal_spi.c
|
||||
# platform/hosal/bl808_e907_hal/hosal_uart.c
|
||||
# platform/hosal/bl808_e907_hal/hal_sdh.c
|
||||
|
||||
|
||||
src += Split("""
|
||||
platform/hosal/bl808_e907_hal/bl_uart.c
|
||||
platform/hosal/bl808_e907_hal/bl_irq.c
|
||||
platform/hosal/bl808_e907_hal/bl_chip.c
|
||||
platform/hosal/bl808_e907_hal/bl_flash.c
|
||||
platform/hosal/bl808_e907_hal/bl_wifi.c
|
||||
platform/hosal/bl808_e907_hal/bl_efuse.c
|
||||
platform/hosal/bl808_e907_hal/bl_sys.c
|
||||
platform/hosal/bl808_e907_hal/bl_boot2.c
|
||||
platform/hosal/bl808_e907_hal/bl_ipc.c
|
||||
platform/hosal/bl808_e907_hal/bl_cam.c
|
||||
platform/hosal/bl808_e907_hal/bl_audio.c
|
||||
platform/hosal/bl808_e907_hal/bl_sdh.c
|
||||
platform/hosal/bl808_e907_hal/hal_boot2.c
|
||||
platform/hosal/bl808_e907_hal/hal_sys.c
|
||||
platform/hosal/bl808_e907_hal/bl_psram.c
|
||||
platform/hosal/bl808_e907_hal/bl_mm_clock.c
|
||||
platform/hosal/bl808_e907_hal/hal_board.c
|
||||
platform/soc/bl808/bl808_e907_std/common/misc/misc.c
|
||||
platform/soc/bl808/bl808_e907_std/common/soft_crc/softcrc.c
|
||||
""")
|
||||
|
||||
src += Split("""
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_common.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_clock.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_uart.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_glb.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_glb_gpio.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_pds.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_hbn.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_sflash.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_xip_sflash.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_sf_cfg.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_ef_ctrl.c
|
||||
platform/soc/bl808/bl808_e907_std/bl808_bsp_driver/std_drv/src/bl808_sf_ctrl.c
|
||||
""")
|
||||
|
||||
path += [cwd + r'/platform/hosal/bl808_e907_hal']
|
||||
|
||||
libpath = []
|
||||
libs = []
|
||||
|
||||
group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path, LIBS = libs, LIBPATH = libpath)
|
||||
|
||||
|
||||
Return('group')
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _HOSAL_ADAPTER_H_
|
||||
#define _HOSAL_ADAPTER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uintptr_t hosal_adpt_critical_enter(void);
|
||||
void hosal_adpt_critical_exit(uintptr_t);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "hosal_adapter.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
uintptr_t hosal_adpt_critical_enter(void)
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hosal_adpt_critical_exit(uintptr_t irq_state)
|
||||
{
|
||||
(void)irq_state;
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_AUDIO_H__
|
||||
#define __BL_AUDIO_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <bl808_dma.h>
|
||||
#include "bl808_audio.h"
|
||||
|
||||
typedef int (*audio_callback_rx_ready_t)(void *usrdata, uint8_t *audiodata, int len, int is_overflow);
|
||||
typedef int (*audio_callback_tx_ready_t)(void *uerdata, uint8_t *audiodata, int len, int is_underrun);
|
||||
|
||||
#define AUDIO_PLAY_DEFAULT_INITIAL_VOLUME 0x0
|
||||
#define AUDIO_TX_FIFO_ADDR AUDIO_BASE + 0x94
|
||||
#define AUDIO_RX_FIFO_ADDR AUDIO_BASE + 0x88
|
||||
#define AUDIO_DEFAULT_TX_DRQ_THR 8
|
||||
#define AUDIO_DEFAULT_RX_DRQ_THR 8
|
||||
|
||||
typedef enum {
|
||||
LEFT_CHANNEL = 1, /*!< select mono mode left only */
|
||||
RIGHT_CHANNEL = 2, /*!< select mono mode right only */
|
||||
STEREO_CHANNEL = 3, /*!< select stereo */
|
||||
THREE_CHANNEL = 7, /*!< select Three */
|
||||
} Audio_Channel_Type;
|
||||
|
||||
typedef enum {
|
||||
AUDIO_BIT_WIDTH_16, /*!< 16 bit */
|
||||
AUDIO_BIT_WIDTH_24, /*!< 24 bit */
|
||||
AUDIO_BIT_WIDTH_32, /*!< 32 bit */
|
||||
} Audio_BitWidth_Type;
|
||||
|
||||
typedef enum {
|
||||
AUDIO_8_KHZ, /*!< Audio DAC Clock set as 8KHZ */
|
||||
AUDIO_16_KHZ, /*!< Audio DAC Clock set as 16KHZ */
|
||||
AUDIO_24_KHZ, /*!< Audio DAC Clock set as 24KHZ */
|
||||
AUDIO_32_KHZ, /*!< Audio DAC Clock set as 32KHZ */
|
||||
AUDIO_48_KHZ, /*!< Audio DAC Clock set as 48KHZ */
|
||||
AUDIO_96_KHZ, /*!< Audio DAC Clock set as 96KHZ */
|
||||
AUDIO_192_KHZ, /*!< Audio DAC Clock set as 192KHZ */
|
||||
} Audio_Samplerate_Type;
|
||||
|
||||
typedef struct {
|
||||
uint8_t pingpang;
|
||||
DMA_LLI_Ctrl_Type lli_tx_list[2];
|
||||
DMA_LLI_Ctrl_Type lli_rx_list[2];
|
||||
uint8_t *lli_tx_buffer;
|
||||
uint32_t lli_tx_buffer_size;
|
||||
uint8_t *lli_rx_buffer;
|
||||
uint32_t lli_rx_buffer_size;
|
||||
|
||||
int is_underrun;
|
||||
int is_overflow;
|
||||
audio_callback_tx_ready_t usr_cb;
|
||||
audio_callback_rx_ready_t usr_rx_cb;
|
||||
void *p_usr_arg;
|
||||
void *p_usr_rx_arg;
|
||||
|
||||
Audio_Samplerate_Type samplerate;
|
||||
Audio_BitWidth_Type playBitWidth;
|
||||
Audio_Channel_Type tx_channel;
|
||||
Audio_Channel_Type rx_channel;
|
||||
uint8_t rx_enable;
|
||||
|
||||
} bl_audio_dev_t;
|
||||
|
||||
int bl_audio_init (bl_audio_dev_t *p_dev);
|
||||
|
||||
int bl_audio_deinit (bl_audio_dev_t *p_dev);
|
||||
|
||||
int bl_audio_start (bl_audio_dev_t *p_dev);
|
||||
|
||||
int bl_audio_stop (bl_audio_dev_t *p_dev);
|
||||
|
||||
int bl_audio_tx_buffer_config (bl_audio_dev_t *p_dev,
|
||||
void **ptr_mem,
|
||||
uint32_t bufsize);
|
||||
|
||||
int bl_audio_rx_buffer_config (bl_audio_dev_t *p_dev,
|
||||
void **ptr_mem,
|
||||
uint32_t bufsize);
|
||||
|
||||
int bl_audio_tx_ready_config(bl_audio_dev_t *p_dev,
|
||||
audio_callback_tx_ready_t cb,
|
||||
void *p_arg);
|
||||
|
||||
int bl_audio_rx_ready_config(bl_audio_dev_t *p_dev,
|
||||
audio_callback_rx_ready_t cb,
|
||||
void *p_arg);
|
||||
|
||||
int bl_audio_samplerate_set (bl_audio_dev_t *p_dev,
|
||||
Audio_Samplerate_Type samplerate);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <softcrc.h>
|
||||
#include <bl_flash.h>
|
||||
#include <bl_boot2.h>
|
||||
PtTable_Error_Type PtTable_Update_Entry(const SPI_Flash_Cfg_Type *pFlashCfg,
|
||||
PtTable_ID_Type targetTableID,
|
||||
PtTable_Stuff_Config *ptStuff,
|
||||
PtTable_Entry_Config *ptEntry)
|
||||
{
|
||||
uint32_t i=0;
|
||||
BL_Err_Type ret;
|
||||
uint32_t writeAddr;
|
||||
uint32_t entriesLen;
|
||||
PtTable_Config *ptTable;
|
||||
PtTable_Entry_Config *ptEntries;
|
||||
uint32_t *pCrc32;
|
||||
|
||||
if(ptEntry==NULL||ptStuff==NULL){
|
||||
return PT_ERROR_PARAMETER;
|
||||
}
|
||||
|
||||
ptTable=&ptStuff->ptTable;
|
||||
ptEntries=ptStuff->ptEntries;
|
||||
|
||||
if(targetTableID==PT_TABLE_ID_INVALID){
|
||||
return PT_ERROR_TABLE_NOT_VALID;
|
||||
}
|
||||
|
||||
if(targetTableID==PT_TABLE_ID_0){
|
||||
writeAddr=BFLB_PT_TABLE0_ADDRESS;
|
||||
}else{
|
||||
writeAddr=BFLB_PT_TABLE1_ADDRESS;
|
||||
}
|
||||
for (i=0; i < ptTable->entryCnt; i++) {
|
||||
if (ptEntries[i].type == ptEntry->type){
|
||||
memcpy(&ptEntries[i],ptEntry,sizeof(PtTable_Entry_Config));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i==ptTable->entryCnt){
|
||||
/* Not found this entry ,add new one */
|
||||
if(ptTable->entryCnt<PT_ENTRY_MAX){
|
||||
memcpy(&ptEntries[ptTable->entryCnt],ptEntry,sizeof(PtTable_Entry_Config));
|
||||
ptTable->entryCnt++;
|
||||
}else{
|
||||
return PT_ERROR_ENTRY_UPDATE_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare write back to flash */
|
||||
/* Update age */
|
||||
ptTable->age++;
|
||||
ptTable->crc32=BFLB_Soft_CRC32((uint8_t*)ptTable,sizeof(PtTable_Config)-4);
|
||||
|
||||
/* Update entries CRC */
|
||||
entriesLen=ptTable->entryCnt*sizeof(PtTable_Entry_Config);
|
||||
pCrc32=(uint32_t *)((uint32_t)ptEntries+entriesLen);
|
||||
*pCrc32=BFLB_Soft_CRC32((uint8_t *)&ptEntries[0],entriesLen);
|
||||
|
||||
/* Write back to flash */
|
||||
/* Erase flash first */
|
||||
ret=bl_flash_erase(writeAddr,sizeof(PtTable_Config)+entriesLen+4);
|
||||
if(ret!=SUCCESS){
|
||||
//MSG_ERR("Flash Erase error\r\n");
|
||||
return PT_ERROR_FALSH_WRITE;
|
||||
}
|
||||
/* Write flash */
|
||||
ret=bl_flash_write(writeAddr,(uint8_t *)ptStuff,sizeof(PtTable_Stuff_Config));
|
||||
if(ret!=SUCCESS){
|
||||
//MSG_ERR("Flash Write error\r\n");
|
||||
return PT_ERROR_FALSH_WRITE;
|
||||
}
|
||||
|
||||
return PT_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
PtTable_Error_Type PtTable_Get_Active_Entries(PtTable_Stuff_Config *ptStuff,
|
||||
PtTable_Entry_Type type,
|
||||
PtTable_Entry_Config *ptEntry)
|
||||
{
|
||||
uint32_t i=0;
|
||||
|
||||
if(ptStuff==NULL||ptEntry==NULL){
|
||||
return PT_ERROR_PARAMETER;
|
||||
}
|
||||
for (i=0; i < ptStuff->ptTable.entryCnt; i++) {
|
||||
if (ptStuff->ptEntries[i].type == type){
|
||||
memcpy(ptEntry,&ptStuff->ptEntries[i],sizeof(PtTable_Entry_Config));
|
||||
return PT_ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
return PT_ERROR_ENTRY_NOT_FOUND;
|
||||
}
|
||||
|
||||
PtTable_Error_Type PtTable_Get_Active_Entries_By_Name(PtTable_Stuff_Config *ptStuff,
|
||||
uint8_t *name,
|
||||
PtTable_Entry_Config *ptEntry)
|
||||
{
|
||||
uint32_t i=0;
|
||||
uint32_t len=strlen((char *)name);
|
||||
|
||||
if(ptStuff==NULL||ptEntry==NULL){
|
||||
return PT_ERROR_PARAMETER;
|
||||
}
|
||||
for (i=0; i < ptStuff->ptTable.entryCnt; i++) {
|
||||
if (strlen((char *)ptStuff->ptEntries[i].name) == len &&
|
||||
memcmp((char *)ptStuff->ptEntries[i].name,(char *)name,len) == 0){
|
||||
//BL602_MemCpy_Fast(ptEntry,&ptStuff->ptEntries[i],sizeof(PtTable_Entry_Config));
|
||||
/*FIXME :need fast memory copy*/
|
||||
memcpy(ptEntry,&ptStuff->ptEntries[i],sizeof(PtTable_Entry_Config));
|
||||
return PT_ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
return PT_ERROR_ENTRY_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __BL606_PARTITION_H__
|
||||
#define __BL606_PARTITION_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//FIXME no BL808/BL606p header file including is Allowed here
|
||||
#ifdef BL808
|
||||
#include <bl808_common.h>
|
||||
#include <bl808_sflash.h>
|
||||
#elif defined(BL606P)
|
||||
#include <bl606p_common.h>
|
||||
#include <bl606p_sflash.h>
|
||||
#else
|
||||
#error "Use CHIP BL808/BL606P for this module"
|
||||
#endif
|
||||
|
||||
/** @addtogroup BL606_Common_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup PARTITION
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup PARTITION_Public_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Partition table error type definition
|
||||
*/
|
||||
typedef enum {
|
||||
PT_ERROR_SUCCESS, /*!< Partition table error type:success */
|
||||
PT_ERROR_TABLE_NOT_VALID, /*!< Partition table error type:entry not found */
|
||||
PT_ERROR_ENTRY_NOT_FOUND, /*!< Partition table error type:entry not found */
|
||||
PT_ERROR_ENTRY_UPDATE_FAIL, /*!< Partition table error type:entry update fail */
|
||||
PT_ERROR_CRC32, /*!< Partition table error type:crc32 error */
|
||||
PT_ERROR_PARAMETER, /*!< Partition table error type:input parameter error */
|
||||
PT_ERROR_FALSH_READ, /*!< Partition table error type:flash read error */
|
||||
PT_ERROR_FALSH_WRITE, /*!< Partition table error type:flash write error */
|
||||
PT_ERROR_FALSH_ERASE, /*!< Partition table error type:flash erase error */
|
||||
}PtTable_Error_Type;
|
||||
|
||||
/**
|
||||
* @brief Partition id type definition
|
||||
*/
|
||||
typedef enum {
|
||||
PT_TABLE_ID_0, /*!< Partition table ID 0 */
|
||||
PT_TABLE_ID_1, /*!< Partition table ID 1 */
|
||||
PT_TABLE_ID_INVALID, /*!< Partition table ID invalid */
|
||||
}PtTable_ID_Type;
|
||||
|
||||
/**
|
||||
* @brief Partition id type definition
|
||||
*/
|
||||
typedef enum {
|
||||
PT_ENTRY_FW_CPU0, /*!< Partition entry type:CPU0 firmware */
|
||||
PT_ENTRY_FW_CPU1, /*!< Partition entry type:CPU1 firmware */
|
||||
PT_ENTRY_MAX=16, /*!< Partition entry type:Max */
|
||||
}PtTable_Entry_Type;
|
||||
|
||||
/**
|
||||
* @brief Partition table config definition
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t magicCode; /*!< Partition table magic code */
|
||||
uint16_t version; /*!< Partition table verdion */
|
||||
uint16_t entryCnt; /*!< Partition table entry count */
|
||||
uint32_t age; /*!< Partition table age */
|
||||
uint32_t crc32; /*!< Partition table CRC32 value */
|
||||
}PtTable_Config;
|
||||
|
||||
/**
|
||||
* @brief Partition table entry config definition
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t type; /*!< Partition entry type */
|
||||
uint8_t device; /*!< Partition entry device */
|
||||
uint8_t activeIndex; /*!< Partition entry active index */
|
||||
uint8_t name[9]; /*!< Partition entry name */
|
||||
uint32_t Address[2]; /*!< Partition entry start address */
|
||||
uint32_t maxLen[2]; /*!< Partition entry max length */
|
||||
uint32_t len; /*!< Partition entry length */
|
||||
uint32_t age; /*!< Partition entry age */
|
||||
}PtTable_Entry_Config;
|
||||
|
||||
/**
|
||||
* @brief Partition table stuff config definition
|
||||
*/
|
||||
typedef struct {
|
||||
PtTable_Config ptTable; /*!< Partition table */
|
||||
PtTable_Entry_Config ptEntries[PT_ENTRY_MAX]; /*!< Partition entries */
|
||||
uint32_t crc32; /*!< Partition entries crc32 */
|
||||
}PtTable_Stuff_Config;
|
||||
|
||||
/*@} end of group PARTITION_Public_Types */
|
||||
|
||||
/** @defgroup PARTITION_Public_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup PTTABLE_ERROR_TYPE
|
||||
* @{
|
||||
*/
|
||||
#define IS_PTTABLE_ERROR_TYPE(type) (((type) == PT_ERROR_SUCCESS) || \
|
||||
((type) == PT_ERROR_TABLE_NOT_VALID) || \
|
||||
((type) == PT_ERROR_ENTRY_NOT_FOUND) || \
|
||||
((type) == PT_ERROR_ENTRY_UPDATE_FAIL) || \
|
||||
((type) == PT_ERROR_CRC32) || \
|
||||
((type) == PT_ERROR_PARAMETER) || \
|
||||
((type) == PT_ERROR_FALSH_READ) || \
|
||||
((type) == PT_ERROR_FALSH_WRITE) || \
|
||||
((type) == PT_ERROR_FALSH_ERASE))
|
||||
|
||||
/** @defgroup PTTABLE_ID_TYPE
|
||||
* @{
|
||||
*/
|
||||
#define IS_PTTABLE_ID_TYPE(type) (((type) == PT_TABLE_ID_0) || \
|
||||
((type) == PT_TABLE_ID_1) || \
|
||||
((type) == PT_TABLE_ID_INVALID))
|
||||
|
||||
/** @defgroup PTTABLE_ENTRY_TYPE
|
||||
* @{
|
||||
*/
|
||||
#define IS_PTTABLE_ENTRY_TYPE(type) (((type) == PT_ENTRY_FW_CPU0) || \
|
||||
((type) == PT_ENTRY_FW_CPU1) || \
|
||||
((type) == PT_ENTRY_MAX))
|
||||
|
||||
/*@} end of group PARTITION_Public_Constants */
|
||||
|
||||
/** @defgroup PARTITION_Public_Macros
|
||||
* @{
|
||||
*/
|
||||
#define BFLB_PT_TABLE0_ADDRESS 0xE000
|
||||
#define BFLB_PT_TABLE1_ADDRESS 0xF000
|
||||
#define BFLB_PT_MAGIC_CODE 0x54504642
|
||||
typedef BL_Err_Type (*pPtTable_Flash_Erase)(uint32_t startaddr,uint32_t endaddr);
|
||||
typedef BL_Err_Type (*pPtTable_Flash_Write)(uint32_t addr,uint8_t *data, uint32_t len);
|
||||
typedef BL_Err_Type (*pPtTable_Flash_Read)(uint32_t addr,uint8_t *data, uint32_t len);
|
||||
|
||||
/*@} end of group PARTITION_Public_Macros */
|
||||
|
||||
/** @defgroup PARTITION_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
void PtTable_Set_Flash_Operation(pPtTable_Flash_Erase erase,pPtTable_Flash_Write write);
|
||||
PtTable_ID_Type PtTable_Get_Active_Partition(const SPI_Flash_Cfg_Type *pFlashCfg,
|
||||
PtTable_Stuff_Config ptStuff[2]);
|
||||
PtTable_Error_Type PtTable_Get_Active_Entries(PtTable_Stuff_Config *ptStuff,
|
||||
PtTable_Entry_Type type,
|
||||
PtTable_Entry_Config *ptEntry);
|
||||
PtTable_Error_Type PtTable_Update_Entry(const SPI_Flash_Cfg_Type *pFlashCfg,
|
||||
PtTable_ID_Type targetTableID,
|
||||
PtTable_Stuff_Config *ptStuff,
|
||||
PtTable_Entry_Config *ptEntry);
|
||||
PtTable_Error_Type PtTable_Create(const SPI_Flash_Cfg_Type *pFlashCfg,PtTable_ID_Type ptID);
|
||||
PtTable_Error_Type PtTable_Get_Active_Entries_By_Name(PtTable_Stuff_Config *ptStuff,
|
||||
uint8_t *name,
|
||||
PtTable_Entry_Config *ptEntry);
|
||||
|
||||
/*@} end of group PARTITION_Public_Functions */
|
||||
|
||||
/*@} end of group PARTITION */
|
||||
|
||||
/*@} end of group BL606_Common_Driver */
|
||||
|
||||
#endif /* __BL606_PARTITION_H__ */
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <bl808_mjpeg.h>
|
||||
#include "bl_cam.h"
|
||||
|
||||
#define MJPEG_DEFAULT_ADDR 0x80400000
|
||||
|
||||
int bl_cam_mjpeg_buffer_info_get(uint32_t *mjpeg_addr, uint32_t *mjpeg_size)
|
||||
{
|
||||
int ret = 0;
|
||||
uint32_t tmpVal;
|
||||
|
||||
*mjpeg_addr = BL_RD_REG(MJPEG_BASE, MJPEG_JPEG_FRAME_ADDR);
|
||||
if (*mjpeg_addr == MJPEG_DEFAULT_ADDR) {
|
||||
*mjpeg_addr = 0;
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
tmpVal = BL_RD_REG(MJPEG_BASE, MJPEG_CONTROL_1);
|
||||
tmpVal = BL_GET_REG_BITS_VAL(tmpVal, MJPEG_REG_W_XLEN);
|
||||
/*get memory brust size 0 sigle; 1 INCR4; 2 INCR8; 3 INCR16*/
|
||||
*mjpeg_size = BL_RD_REG(MJPEG_BASE, MJPEG_JPEG_STORE_MEMORY);
|
||||
*mjpeg_size = *mjpeg_size << (3 + tmpVal + (tmpVal > 0 ? 1 : 0));
|
||||
|
||||
exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bl_cam_mjpeg_get(uint8_t **ptr, uint32_t *len)
|
||||
{
|
||||
int ret = 0;
|
||||
MJPEG_Frame_Info mjpeg_info;
|
||||
MJPEG_Get_Frame_Info(&mjpeg_info);
|
||||
|
||||
if (mjpeg_info.validFrames > 0) {
|
||||
*ptr = (uint8_t *)(uintptr_t)mjpeg_info.curFrameAddr;
|
||||
*len = mjpeg_info.curFrameBytes;
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bl_cam_mjpeg_pop(void)
|
||||
{
|
||||
MJPEG_Pop_Frame();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_CAM_H__
|
||||
#define __BL_CAM_H__
|
||||
int bl_cam_mjpeg_get(uint8_t **ptr, uint32_t *len);
|
||||
int bl_cam_mjpeg_pop();
|
||||
int bl_cam_mjpeg_buffer_info_get(uint32_t *mjpeg_addr, uint32_t *mjpeg_size);
|
||||
#endif
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bl_chip.h"
|
||||
|
||||
static unsigned long _risc_isa_info(void)
|
||||
{
|
||||
volatile unsigned long misa = 0;
|
||||
|
||||
__asm volatile( "csrr %0, misa" : "=r"( misa ) );
|
||||
|
||||
return misa;
|
||||
}
|
||||
|
||||
|
||||
int bl_chip_info(char *info)
|
||||
{
|
||||
unsigned long misa;
|
||||
int i;
|
||||
i = sizeof(misa) * 8 - 2; // MXL field pos
|
||||
|
||||
misa = _risc_isa_info();
|
||||
|
||||
/*Get base ISA*/
|
||||
i = (misa >> i);
|
||||
switch (i) {
|
||||
case 1:
|
||||
{
|
||||
memcpy(info, "RV32", 4);
|
||||
info += 4;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
memcpy(info, "RV64", 4);
|
||||
info += 4;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
memcpy(info, "RV128", 5);
|
||||
info += 5;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
memcpy(info, "RVxx", 4);
|
||||
info += 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*add switch*/
|
||||
*(info++) = '-';
|
||||
|
||||
/*add feature set*/
|
||||
for (i = 0; i < 26; i++) {
|
||||
if (misa & (1 << i)) {
|
||||
/*Feature bit is set*/
|
||||
*(info++) = ('A' + i);
|
||||
}
|
||||
}
|
||||
*info = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char bannder_shadow_bl602[] = {
|
||||
0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88,
|
||||
0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x20, 0xe2, 0x96,
|
||||
0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96,
|
||||
0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x20, 0x20,
|
||||
0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88,
|
||||
0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x20, 0xe2, 0x96,
|
||||
0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96,
|
||||
0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x0a, 0x0d, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x95, 0x91, 0x20, 0x20, 0x20, 0x20, 0x20, 0xe2, 0x96,
|
||||
0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x90, 0xe2, 0x95,
|
||||
0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x9d, 0x20, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x90, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x95, 0x97, 0xe2, 0x95, 0x9a, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2,
|
||||
0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x95, 0x97, 0x0a, 0x0d, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88,
|
||||
0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94,
|
||||
0xe2, 0x95, 0x9d, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x91,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x95, 0x97, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88,
|
||||
0xe2, 0x95, 0x91, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94,
|
||||
0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x91, 0x20, 0xe2, 0x96,
|
||||
0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96,
|
||||
0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x9d, 0x0a, 0x0d, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x95, 0x91, 0x20, 0x20, 0x20, 0x20, 0x20, 0xe2, 0x96,
|
||||
0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x90, 0xe2, 0x95,
|
||||
0x90, 0xe2, 0x95, 0x90, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95,
|
||||
0x97, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96,
|
||||
0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x9d, 0xe2, 0x96, 0x88, 0xe2, 0x96,
|
||||
0x88, 0xe2, 0x95, 0x91, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95,
|
||||
0x94, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95,
|
||||
0x9d, 0x0a, 0x0d, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2,
|
||||
0x95, 0x9d, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x95, 0x97, 0xe2, 0x95, 0x9a, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x95, 0x94, 0xe2, 0x95, 0x9d, 0xe2, 0x95, 0x9a, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x9d, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
|
||||
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x0a, 0x0d, 0xe2, 0x95, 0x9a,
|
||||
0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90,
|
||||
0xe2, 0x95, 0x90, 0xe2, 0x95, 0x9d, 0x20, 0xe2, 0x95, 0x9a, 0xe2, 0x95,
|
||||
0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95,
|
||||
0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x9d, 0x20, 0xe2, 0x95, 0x9a, 0xe2,
|
||||
0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2,
|
||||
0x95, 0x90, 0xe2, 0x95, 0x9d, 0x20, 0x20, 0xe2, 0x95, 0x9a, 0xe2, 0x95,
|
||||
0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95,
|
||||
0x90, 0xe2, 0x95, 0x9d, 0x20, 0xe2, 0x95, 0x9a, 0xe2, 0x95, 0x90, 0xe2,
|
||||
0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2,
|
||||
0x95, 0x90, 0xe2, 0x95, 0x9d, 0x0a, 0x0d, 0x00
|
||||
};
|
||||
|
||||
int bl_chip_banner(const char **banner)
|
||||
{
|
||||
*banner = bannder_shadow_bl602;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_chip_memory_ram(int *num, unsigned int addr[], unsigned int size[], char desc[][6])
|
||||
{
|
||||
return -1;
|
||||
#if 0
|
||||
if (*num < 3) {
|
||||
/*only one block memory*/
|
||||
return -1;
|
||||
}
|
||||
*num = 3;
|
||||
|
||||
extern uint8_t _ld_ram_size0, _ld_ram_addr0;
|
||||
extern uint8_t _ld_ram_size1, _ld_ram_addr1;
|
||||
extern uint8_t _ld_ram_size2, _ld_ram_addr2;
|
||||
addr[0] = (unsigned int)&_ld_ram_addr0;
|
||||
size[0] = (unsigned int)&_ld_ram_size0;
|
||||
strcpy(desc[0], "flash");
|
||||
addr[1] = (unsigned int)&_ld_ram_addr1;
|
||||
size[1] = (unsigned int)&_ld_ram_size1;
|
||||
strcpy(desc[1], "tcm");
|
||||
addr[2] = (unsigned int)&_ld_ram_addr2;
|
||||
size[2] = (unsigned int)&_ld_ram_size2;
|
||||
strcpy(desc[2], "wifi");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_CHIP_H__
|
||||
#define __BL_CHIP_H__
|
||||
int bl_chip_info(char *info);
|
||||
int bl_chip_banner(const char **banner);
|
||||
int bl_chip_memory_ram(int *num, unsigned int addr[], unsigned int size[], char desc[][6]);
|
||||
#endif
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "bl_efuse.h"
|
||||
#ifdef BL808
|
||||
#include <bl808_ef_ctrl.h>
|
||||
#include "bl808_mfg_media.h"
|
||||
#include "bl808_glb.h"
|
||||
#endif
|
||||
|
||||
int bl_efuse_read_mac(uint8_t mac[6])
|
||||
{
|
||||
EF_Ctrl_Read_MAC_Address(mac);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_efuse_read_mac_factory(uint8_t mac[6])
|
||||
{
|
||||
// if (0 == mfg_media_read_macaddr(mac, 1)) {
|
||||
// return 0;
|
||||
//zys }
|
||||
return -1;
|
||||
}
|
||||
|
||||
int bl_efuse_read_capcode(uint8_t *capcode)
|
||||
{
|
||||
// if (0 == mfg_media_read_xtal_capcode(capcode, 1)) {
|
||||
// return 0;
|
||||
//zys }
|
||||
return -1;
|
||||
}
|
||||
|
||||
int bl_efuse_read_pwroft(int8_t poweroffset[14])
|
||||
{
|
||||
// if (0 == mfg_media_read_poweroffset(poweroffset, 1)) {
|
||||
// return 0;
|
||||
//}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int bl_efuse_ctrl_program_R0(uint32_t index, uint32_t *data, uint32_t len)
|
||||
{
|
||||
uint8_t hdiv=0, bdiv=0;
|
||||
HBN_MCU_ROOT_CLK_Type rtClk=(HBN_MCU_ROOT_CLK_Type)HBN_Get_MCU_Root_CLK_Sel();
|
||||
|
||||
// bdiv=GLB_Get_BCLK_Div();
|
||||
// hdiv=GLB_Get_HCLK_Div();
|
||||
hdiv = BL_GET_REG_BITS_VAL(BL_RD_REG(GLB_BASE, GLB_SYS_CFG0), GLB_REG_HCLK_DIV);
|
||||
bdiv = BL_GET_REG_BITS_VAL(BL_RD_REG(GLB_BASE, GLB_SYS_CFG0), GLB_REG_BCLK_DIV);
|
||||
|
||||
HBN_Set_MCU_Root_CLK_Sel(HBN_MCU_ROOT_CLK_XCLK);
|
||||
|
||||
EF_Ctrl_Program_Direct_R0(index, data, len);
|
||||
|
||||
GLB_Set_System_CLK_Div(hdiv, bdiv);
|
||||
HBN_Set_MCU_Root_CLK_Sel(rtClk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_efuse_ctrl_read_R0(uint32_t index, uint32_t *data, uint32_t len)
|
||||
{
|
||||
uint8_t hdiv=0, bdiv=0;
|
||||
HBN_MCU_ROOT_CLK_Type rtClk=(HBN_MCU_ROOT_CLK_Type)HBN_Get_MCU_Root_CLK_Sel();
|
||||
|
||||
// bdiv=GLB_Get_BCLK_Div();
|
||||
// hdiv=GLB_Get_HCLK_Div();
|
||||
hdiv = BL_GET_REG_BITS_VAL(BL_RD_REG(GLB_BASE, GLB_SYS_CFG0), GLB_REG_HCLK_DIV);
|
||||
bdiv = BL_GET_REG_BITS_VAL(BL_RD_REG(GLB_BASE, GLB_SYS_CFG0), GLB_REG_BCLK_DIV);
|
||||
|
||||
|
||||
HBN_Set_MCU_Root_CLK_Sel(HBN_MCU_ROOT_CLK_XCLK);
|
||||
|
||||
EF_Ctrl_Read_Direct_R0(index, data, len);
|
||||
|
||||
GLB_Set_System_CLK_Div(hdiv, bdiv);
|
||||
HBN_Set_MCU_Root_CLK_Sel(rtClk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_efuse_read_mac_opt(uint8_t slot, uint8_t mac[6], uint8_t reload)
|
||||
{
|
||||
uint8_t hdiv=0, bdiv=0;
|
||||
HBN_MCU_ROOT_CLK_Type rtClk=(HBN_MCU_ROOT_CLK_Type)HBN_Get_MCU_Root_CLK_Sel();
|
||||
|
||||
// bdiv=GLB_Get_BCLK_Div();
|
||||
// hdiv=GLB_Get_HCLK_Div();
|
||||
hdiv = BL_GET_REG_BITS_VAL(BL_RD_REG(GLB_BASE, GLB_SYS_CFG0), GLB_REG_HCLK_DIV);
|
||||
bdiv = BL_GET_REG_BITS_VAL(BL_RD_REG(GLB_BASE, GLB_SYS_CFG0), GLB_REG_BCLK_DIV);
|
||||
|
||||
HBN_Set_MCU_Root_CLK_Sel(HBN_MCU_ROOT_CLK_XCLK);
|
||||
|
||||
// EF_Ctrl_Read_MAC_Address_Opt(slot, mac, reload);
|
||||
EF_Ctrl_Read_MAC_Address_Raw(mac);
|
||||
|
||||
GLB_Set_System_CLK_Div(hdiv, bdiv);
|
||||
HBN_Set_MCU_Root_CLK_Sel(rtClk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_EFUSE_H__
|
||||
#define __BL_EFUSE_H__
|
||||
#include <stdint.h>
|
||||
int bl_efuse_read_mac(uint8_t mac[6]);
|
||||
int bl_efuse_read_mac_factory(uint8_t mac[6]);
|
||||
int bl_efuse_read_capcode(uint8_t *capcode);
|
||||
int bl_efuse_read_pwroft(int8_t poweroffset[14]);
|
||||
int bl_efuse_ctrl_program_R0(uint32_t index, uint32_t *data, uint32_t len);
|
||||
int bl_efuse_ctrl_read_R0(uint32_t index, uint32_t *data, uint32_t len);
|
||||
int bl_efuse_read_mac_opt(uint8_t slot, uint8_t mac[6], uint8_t reload);
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __ETHERNETIF_H__
|
||||
#define __ETHERNETIF_H__
|
||||
#include "hal_emac.h"
|
||||
#if CTX_TYPE
|
||||
#include <utils_list.h>
|
||||
#endif
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "ethernet_phy.h"
|
||||
|
||||
#define DHCP_OFF (uint8_t)0
|
||||
#define DHCP_START (uint8_t)1
|
||||
#define DHCP_WAIT_ADDRESS (uint8_t)2
|
||||
#define DHCP_ADDRESS_ASSIGNED (uint8_t)3
|
||||
#define DHCP_TIMEOUT (uint8_t)4
|
||||
#define DHCP_LINK_DOWN (uint8_t)5
|
||||
|
||||
#if CTX_TYPE
|
||||
#define ETH_MAX_BUFFER_SIZE (ETH_MAX_PACKET_SIZE)
|
||||
#define EMAC_TX_COMMON_FLAGS (EMAC_BD_FIELD_MSK(TX_RD) | \
|
||||
EMAC_BD_FIELD_MSK(TX_IRQ) | \
|
||||
EMAC_BD_FIELD_MSK(TX_PAD) | \
|
||||
EMAC_BD_FIELD_MSK(TX_CRC) | \
|
||||
EMAC_BD_FIELD_MSK(TX_EOF) )
|
||||
|
||||
struct unsent_item{
|
||||
struct utils_list_hdr hdr;
|
||||
struct pbuf *p;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct utils_list unsent;
|
||||
uint8_t Tx_free_bd_num;
|
||||
uint8_t Rx_free_bd_num;
|
||||
volatile uint16_t unsent_num;
|
||||
uint32_t tx_pkt_cnt;
|
||||
uint32_t rx_pkt_cnt;
|
||||
uint32_t out_tmr;
|
||||
uint32_t done_tmr;
|
||||
}eth_context;
|
||||
#endif
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
err_t ethernetif_init(struct netif *netif);
|
||||
void ethernet_link_check_state(struct netif *netif);
|
||||
void ethernet_link_status_updated(struct netif *netif);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <blog.h>
|
||||
#ifdef BL808
|
||||
#include <bl808_glb.h>
|
||||
#include <bl808_xip_sflash.h>
|
||||
#include <bl808_sf_cfg.h>
|
||||
#include <bl808_romdriver_e907.h>
|
||||
#elif defined(BL606P)
|
||||
#include <bl606p_glb.h>
|
||||
#include <bl606p_xip_sflash.h>
|
||||
#include <bl606p_sf_cfg.h>
|
||||
#include <bl606p_sf_cfg_ext.h>
|
||||
#include <bl606p_romdriver_e907.h>
|
||||
#else
|
||||
#error "Use CHIP BL808/BL606P for this module"
|
||||
#endif
|
||||
|
||||
#include "bl_irq.h"
|
||||
|
||||
#define XIP_START_ADDR (0x58000000)
|
||||
#define ADDR_LIMIT (0x1000000)
|
||||
|
||||
#define USER_UNUSED(a) ((void)(a))
|
||||
static SPI_Flash_Cfg_Type g_flash_cfg;
|
||||
|
||||
/**
|
||||
* @brief flash read data
|
||||
*
|
||||
* @param addr
|
||||
* @param data
|
||||
* @param len
|
||||
* @return BL_Err_Type
|
||||
*/
|
||||
int ATTR_TCM_SECTION bl_flash_read(uint32_t startaddr, void *data, uint32_t len)
|
||||
{
|
||||
BL_Err_Type stat;
|
||||
uint8_t isAesEnable=0;
|
||||
|
||||
GLOBAL_IRQ_SAVE();
|
||||
XIP_SFlash_Opt_Enter(&isAesEnable);
|
||||
stat = XIP_SFlash_Read_Need_Lock(&g_flash_cfg, startaddr, data, len, 0, 0);
|
||||
XIP_SFlash_Opt_Exit(isAesEnable);
|
||||
GLOBAL_IRQ_RESTORE();
|
||||
|
||||
return stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief flash write data
|
||||
*
|
||||
* @param addr
|
||||
* @param data
|
||||
* @param len
|
||||
* @return BL_Err_Type
|
||||
*/
|
||||
int ATTR_TCM_SECTION bl_flash_write(uint32_t startaddr, void *data, uint32_t len)
|
||||
{
|
||||
BL_Err_Type stat;
|
||||
uint8_t isAesEnable=0;
|
||||
|
||||
GLOBAL_IRQ_SAVE();
|
||||
XIP_SFlash_Opt_Enter(&isAesEnable);
|
||||
stat = XIP_SFlash_Write_Need_Lock(&g_flash_cfg, startaddr, data, len, 0, 0);
|
||||
XIP_SFlash_Opt_Exit(isAesEnable);
|
||||
GLOBAL_IRQ_RESTORE();
|
||||
|
||||
return stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief flash erase
|
||||
*
|
||||
* @param startaddr
|
||||
* @param endaddr
|
||||
* @return BL_Err_Type
|
||||
*/
|
||||
int ATTR_TCM_SECTION bl_flash_erase(uint32_t startaddr, uint32_t len)
|
||||
{
|
||||
BL_Err_Type stat;
|
||||
uint8_t isAesEnable=0;
|
||||
|
||||
GLOBAL_IRQ_SAVE();
|
||||
XIP_SFlash_Opt_Enter(&isAesEnable);
|
||||
stat = XIP_SFlash_Erase_Need_Lock(&g_flash_cfg, startaddr, len-1, 0, 0);
|
||||
XIP_SFlash_Opt_Exit(isAesEnable);
|
||||
GLOBAL_IRQ_RESTORE();
|
||||
|
||||
return stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief flash read from xip
|
||||
*
|
||||
* @param xip addr
|
||||
* @param dst
|
||||
* @param len
|
||||
* @return BL_Err_Type
|
||||
*/
|
||||
int bl_flash_read_byxip(uint32_t addr, uint8_t *dst, int len)
|
||||
{
|
||||
uint32_t offset;
|
||||
uint32_t xipaddr;
|
||||
|
||||
offset = RomDriver_SF_Ctrl_Get_Flash_Image_Offset(0, 0);
|
||||
|
||||
if ((addr < offset) || (addr >= ADDR_LIMIT)) {
|
||||
// not support or arg err ?
|
||||
return -1;
|
||||
}
|
||||
|
||||
xipaddr = XIP_START_ADDR - offset + addr;
|
||||
memcpy(dst, (void *)xipaddr, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief multi flash adapter
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*/
|
||||
int ATTR_TCM_SECTION bl_flash_init(void)
|
||||
{
|
||||
uint8_t isAesEnable=0;
|
||||
|
||||
/* Get flash config identify */
|
||||
GLOBAL_IRQ_SAVE();
|
||||
XIP_SFlash_Opt_Enter(&isAesEnable);
|
||||
SF_Cfg_Flash_Identify_Ext(1, 0x80, 0, &g_flash_cfg, 0, 0);
|
||||
XIP_SFlash_Opt_Exit(isAesEnable);
|
||||
GLOBAL_IRQ_RESTORE();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _dump_flash_config()
|
||||
{
|
||||
extern uint8_t __boot2_flashCfg_src;
|
||||
|
||||
USER_UNUSED(__boot2_flashCfg_src);
|
||||
|
||||
blog_info("======= FlashCfg magiccode @%p=======\r\n", &__boot2_flashCfg_src);
|
||||
blog_info("mid \t\t0x%X\r\n", g_flash_cfg.mid);
|
||||
blog_info("clkDelay \t0x%X\r\n", g_flash_cfg.clkDelay);
|
||||
blog_info("clkInvert \t0x%X\r\n", g_flash_cfg.clkInvert);
|
||||
blog_info("sector size\t%uKBytes\r\n", g_flash_cfg.sectorSize);
|
||||
blog_info("page size\t%uBytes\r\n", g_flash_cfg.pageSize);
|
||||
blog_info("---------------------------------------------------------------\r\n");
|
||||
}
|
||||
|
||||
int bl_flash_config_update(void)
|
||||
{
|
||||
_dump_flash_config();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_FLASH_H__
|
||||
#define __BL_FLASH_H__
|
||||
#include <stdint.h>
|
||||
|
||||
int bl_flash_erase(uint32_t addr, int len);
|
||||
int bl_flash_write(uint32_t addr, void *src, int len);
|
||||
int bl_flash_read(uint32_t addr, void *dst, int len);
|
||||
int bl_flash_config_update(void);
|
||||
void* bl_flash_get_flashCfg(void);
|
||||
|
||||
int bl_flash_read_byxip(uint32_t addr, uint8_t *dst, int len);
|
||||
int bl_flash_init(void);
|
||||
#endif
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "bl_ipc.h"
|
||||
|
||||
//FIXME no BL808/BL606p header file including is Allowed here
|
||||
#ifdef BL808
|
||||
#include <bl808_glb.h>
|
||||
#include <bl808_ipc.h>
|
||||
#elif defined(BL606P)
|
||||
#include <bl606p_glb.h>
|
||||
#include <bl606p_ipc.h>
|
||||
#else
|
||||
#error "Use CHIP BL808/BL606P for this module"
|
||||
#endif
|
||||
|
||||
|
||||
extern void IPC_Common_Interrupt_Handler(uint32_t irqStatus, ipcIntCallback *callBack[GLB_CORE_ID_MAX -1]);
|
||||
extern ipcIntCallback *m0IpcIntCbfArra[GLB_CORE_ID_MAX - 1];
|
||||
|
||||
static void ipc_m0_handler(void)
|
||||
{
|
||||
uint32_t irqStatus;
|
||||
irqStatus = IPC_M0_Get_Int_Raw_Status();
|
||||
IPC_Common_Interrupt_Handler(irqStatus, m0IpcIntCbfArra);
|
||||
IPC_M0_Clear_Int_By_Word(irqStatus);
|
||||
}
|
||||
//FIXME no BL808/BL606p header file including is Allowed here
|
||||
#ifdef BL808
|
||||
#include <bl808_glb.h>
|
||||
#elif defined(BL606P)
|
||||
#include <bl606p_glb.h>
|
||||
#else
|
||||
#error "Use CHIP BL808/BL606P for this module"
|
||||
#endif
|
||||
|
||||
void ipc_m0_init(ipcIntCallback *onLPTriggerCallBack,
|
||||
ipcIntCallback *onD0TriggerCallBack)
|
||||
{
|
||||
IPC_M0_Init(onLPTriggerCallBack, onD0TriggerCallBack);
|
||||
|
||||
#ifdef BFLB_USE_HAL_DRIVER
|
||||
Interrupt_Handler_Register(IPC_M0_IRQn, ipc_m0_handler);
|
||||
#endif
|
||||
|
||||
System_NVIC_SetPriority(IPC_M0_IRQn, 5, 0);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_IPC_H__
|
||||
#define __BL_IPC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
typedef void(ipcIntCallback)(uint32_t src);
|
||||
void ipc_m0_init(ipcIntCallback *onLPTriggerCallBack, ipcIntCallback *onD0TriggerCallBack);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,418 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
|
||||
//FIXME no BL808/BL606p header file including is Allowed here
|
||||
#ifdef BL808
|
||||
#include <bl808.h>
|
||||
#elif defined(BL606P)
|
||||
#include <bl606p.h>
|
||||
#else
|
||||
#error "Use CHIP BL808/BL606P for this module"
|
||||
#endif
|
||||
|
||||
#include "clic.h"
|
||||
|
||||
#include <blog.h>
|
||||
#include "bl_irq.h"
|
||||
|
||||
#ifdef SYS_ENABLE_COREDUMP
|
||||
#include <bl_coredump.h>
|
||||
#endif
|
||||
|
||||
void CPU_Interrupt_Enable(uint32_t irq_num);
|
||||
void CPU_Interrupt_Disable(uint32_t irq_num);
|
||||
void bl_irq_enable(unsigned int source)
|
||||
{
|
||||
CPU_Interrupt_Enable(source);
|
||||
//*(volatile uint8_t*)(CLIC_HART0_ADDR + CLIC_INTIE + source) = 1;
|
||||
}
|
||||
|
||||
void bl_irq_disable(unsigned int source)
|
||||
{
|
||||
CPU_Interrupt_Disable(source);
|
||||
//*(volatile uint8_t*)(CLIC_HART0_ADDR + CLIC_INTIE + source) = 0;
|
||||
}
|
||||
|
||||
void bl_irq_pending_set(unsigned int source)
|
||||
{
|
||||
*(volatile uint8_t*)(CLIC_HART0_ADDR + CLIC_INTIP + source) = 1;
|
||||
}
|
||||
|
||||
void bl_irq_pending_clear(unsigned int source)
|
||||
{
|
||||
*(volatile uint8_t*)(CLIC_HART0_ADDR + CLIC_INTIP + source) = 0;
|
||||
}
|
||||
|
||||
void bl_irq_exception_trigger(BL_IRQ_EXCEPTION_TYPE_T type, void *ptr)
|
||||
{
|
||||
uint32_t val = 0x12345678;;
|
||||
|
||||
switch (type) {
|
||||
case BL_IRQ_EXCEPTION_TYPE_LOAD_MISALIGN:
|
||||
{
|
||||
val = *(uint32_t*)ptr;
|
||||
}
|
||||
break;
|
||||
case BL_IRQ_EXCEPTION_TYPE_STORE_MISALIGN:
|
||||
{
|
||||
*(uint32_t*)ptr = val;
|
||||
}
|
||||
break;
|
||||
case BL_IRQ_EXCEPTION_TYPE_ACCESS_ILLEGAL:
|
||||
{
|
||||
*(uint32_t*)ptr = val;
|
||||
}
|
||||
break;
|
||||
case BL_IRQ_EXCEPTION_TYPE_ILLEGAL_INSTRUCTION:
|
||||
{
|
||||
uint32_t fun_val = 0;
|
||||
typedef void (*ins_ptr_t)(void);
|
||||
ins_ptr_t func = (ins_ptr_t)&fun_val;
|
||||
|
||||
func();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
/*nothing here*/
|
||||
}
|
||||
}
|
||||
printf("Trigger exception val is %08lx\r\n", val);
|
||||
}
|
||||
|
||||
void bl_irq_default(void)
|
||||
{
|
||||
while (1) {
|
||||
/*dead loop*/
|
||||
}
|
||||
}
|
||||
|
||||
static void (*handler_list[2][16 + 64])(void) = {
|
||||
|
||||
};
|
||||
|
||||
|
||||
static inline void _irq_num_check(int irqnum)
|
||||
{
|
||||
if (irqnum < 0 || irqnum >= sizeof(handler_list[0])/sizeof(handler_list[0][0])) {
|
||||
blog_error("illegal irqnum %d\r\n", irqnum);
|
||||
while (1) {
|
||||
/*Deap loop here, TODO ass blog_assert*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bl_irq_register_with_ctx(int irqnum, void *handler, void *ctx)
|
||||
{
|
||||
_irq_num_check(irqnum);
|
||||
if (handler_list[0][irqnum] && handler_list[0][irqnum] != handler) {
|
||||
blog_warn("IRQ %d already registered with %p \r\n",
|
||||
irqnum,
|
||||
handler_list[0][irqnum]
|
||||
);
|
||||
}
|
||||
|
||||
if (handler == NULL) {
|
||||
blog_error("handler is NULL pointer! \r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (NULL == ctx) {
|
||||
handler_list[0][irqnum] = handler;
|
||||
handler_list[1][irqnum] = NULL;
|
||||
}
|
||||
else {
|
||||
handler_list[0][irqnum] = handler;
|
||||
handler_list[1][irqnum] = ctx;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void bl_irq_ctx_get(int irqnum, void **ctx)
|
||||
{
|
||||
_irq_num_check(irqnum);
|
||||
*ctx = handler_list[1][irqnum];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
struct irq_ctx **bl_irq_ctx_list(int *num)
|
||||
{
|
||||
*num = 16 + 64;
|
||||
return (struct irq_ctx **)handler_list[1];
|
||||
}
|
||||
|
||||
void bl_irq_ctx_count_cost(int irqnum, uint64_t cost)
|
||||
{
|
||||
struct irq_ctx *ctx;
|
||||
_irq_num_check(irqnum);
|
||||
if(handler_list[0][irqnum] != NULL) {
|
||||
ctx = (struct irq_ctx *)(handler_list[1][irqnum]);
|
||||
ctx->irq_run_time += cost;
|
||||
}
|
||||
}
|
||||
|
||||
//void Interrupt_Handler_Register(IRQn_Type irq,void * interruptFun);
|
||||
void Interrupt_Handler_Register(IRQn_Type irq,pFunc interruptFun);
|
||||
void bl_irq_register(int irqnum, void *handler)
|
||||
{
|
||||
|
||||
Interrupt_Handler_Register(irqnum, handler);
|
||||
//bl_irq_register_with_ctx(irqnum, handler, NULL);
|
||||
}
|
||||
|
||||
void bl_irq_unregister(int irqnum, void *handler)
|
||||
{
|
||||
#if 0
|
||||
_irq_num_check(irqnum);
|
||||
if (handler_list[0][irqnum] != handler) {
|
||||
blog_warn("IRQ %d:%p Not match with registered %p\r\n",
|
||||
irqnum,
|
||||
handler,
|
||||
handler_list[0][irqnum]
|
||||
);
|
||||
}
|
||||
handler_list[0][irqnum] = handler;
|
||||
#endif
|
||||
}
|
||||
|
||||
void interrupt_entry(uint32_t mcause)
|
||||
{
|
||||
void *handler = NULL;
|
||||
mcause &= 0x7FFFFFF;
|
||||
if (mcause < sizeof(handler_list[0])/sizeof(handler_list[0][0])) {
|
||||
handler = handler_list[0][mcause];
|
||||
}
|
||||
if (handler) {
|
||||
if (handler_list[1][mcause]) {
|
||||
((void (*)(void *))handler)(handler_list[1][mcause]);//handler(ctx)
|
||||
}
|
||||
else {
|
||||
((void (*)(void))handler)();
|
||||
}
|
||||
} else {
|
||||
printf("Cannot handle mcause 0x%lx:%lu, adjust to externel(0x%lx:%lu)\r\n",
|
||||
mcause,
|
||||
mcause,
|
||||
mcause - 16,
|
||||
mcause - 16
|
||||
);
|
||||
while (1) {
|
||||
/*dead loop now*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void __dump_exception_code_str(uint32_t code)
|
||||
{
|
||||
printf("Exception code: %lu\r\n", code);
|
||||
switch (code) {
|
||||
case 0x00:
|
||||
/*Instruction address misaligned*/
|
||||
{
|
||||
puts(" msg: Instruction address misaligned\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x01:
|
||||
/*Instruction access fault*/
|
||||
{
|
||||
puts(" msg: Instruction access fault\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x02:
|
||||
/*Illegal instruction*/
|
||||
{
|
||||
puts(" msg: Illegal instruction\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x03:
|
||||
/*Breakpoint*/
|
||||
{
|
||||
puts(" msg: Breakpoint\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x04:
|
||||
/*Load address misaligned*/
|
||||
{
|
||||
puts(" msg: Load address misaligned\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x05:
|
||||
/*Load access fault*/
|
||||
{
|
||||
puts(" msg: Load access fault\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
/*Store/AMO access misaligned*/
|
||||
{
|
||||
puts(" msg: Store/AMO access misaligned\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x07:
|
||||
/*Store/AMO access fault*/
|
||||
{
|
||||
puts(" msg: Store/AMO access fault\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x08:
|
||||
/*Environment call from U-mode*/
|
||||
{
|
||||
puts(" msg: Environment call from U-mode\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x09:
|
||||
/*Environment call from S-mode*/
|
||||
{
|
||||
puts(" msg: Environment call from S-mode\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x0a:
|
||||
case 0x0e:
|
||||
/*Reserved*/
|
||||
{
|
||||
puts(" msg: Reserved\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x0b:
|
||||
/*Environment call from M-mode*/
|
||||
{
|
||||
puts(" msg: Environment call from M-mode\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x0c:
|
||||
/*Instruction page fault*/
|
||||
{
|
||||
puts(" msg: Instruction page fault\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x0d:
|
||||
/*Load page fault*/
|
||||
{
|
||||
puts(" msg: Load page fault\r\n");
|
||||
}
|
||||
break;
|
||||
case 0x0f:
|
||||
/*Store/AMO page fault*/
|
||||
{
|
||||
puts(" msg: Store/AMO page fault\r\n");
|
||||
}
|
||||
break;
|
||||
default:{
|
||||
puts(" msg: Reserved default exception\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern void misaligned_load_trap(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc);
|
||||
extern void misaligned_store_trap(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc);
|
||||
|
||||
#define EXCPT_LOAD_MISALIGNED 4
|
||||
#define EXCPT_STORE_MISALIGNED 6
|
||||
|
||||
#ifdef DBG_RECORD_EXCEP_VAL
|
||||
struct{
|
||||
uint32_t mcause;
|
||||
uint32_t mepc;
|
||||
uint32_t mtval;
|
||||
}rval[4];
|
||||
int rval_idx;
|
||||
#endif /* DBG_RECORD_EXCEP_VAL */
|
||||
|
||||
void exception_entry(uint32_t mcause, uint32_t mepc, uint32_t mtval, uintptr_t *regs)
|
||||
{
|
||||
#ifdef DBG_RECORD_EXCEP_VAL
|
||||
rval[rval_idx&0x3].mcause = mcause;
|
||||
rval[rval_idx&0x3].mepc = mepc;
|
||||
rval[rval_idx&0x3].mtval = mtval;
|
||||
rval_idx++;
|
||||
#endif /* DBG_RECORD_EXCEP_VAL */
|
||||
if ((mcause & 0x3ff) == EXCPT_LOAD_MISALIGNED) {
|
||||
//misaligned_load_trap(regs, mcause, mepc);
|
||||
} else if ((mcause & 0x3ff) == EXCPT_STORE_MISALIGNED){
|
||||
//misaligned_store_trap(regs, mcause, mepc);
|
||||
}
|
||||
{
|
||||
//registerdump(tasksp);
|
||||
puts("Exception Entry--->>>\r\n");
|
||||
blog_info("mcause %08lx, mepc %08lx, mtval %08lx\r\n",
|
||||
mcause,
|
||||
mepc,
|
||||
mtval
|
||||
);
|
||||
__dump_exception_code_str(mcause & 0xFFFF);
|
||||
//backtrace_now_task((int (*)(const char *s))puts, regs);
|
||||
while (1) {
|
||||
/*Deap loop now*/
|
||||
#ifdef SYS_ENABLE_COREDUMP
|
||||
/* For stack check */
|
||||
extern uintptr_t _sp_main, _sp_base;
|
||||
|
||||
/* XXX change sp to irq stack base */
|
||||
__asm__ volatile("add sp, x0, %0" ::"r"(&_sp_main));
|
||||
bl_coredump_run();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int bl_irq_save(void)
|
||||
{
|
||||
uint32_t oldstat;
|
||||
|
||||
/* Read mstatus & clear machine interrupt enable (MIE) in mstatus */
|
||||
__asm volatile("csrrc %0, mstatus, %1" : "=r"(oldstat) : "r"(8));
|
||||
return oldstat;
|
||||
}
|
||||
|
||||
void bl_irq_restore(int flags)
|
||||
{
|
||||
__asm volatile("csrw mstatus, %0"
|
||||
: /* no output */
|
||||
: "r"(flags));
|
||||
}
|
||||
void bl_irq_init(void)
|
||||
{
|
||||
uint32_t ptr;
|
||||
|
||||
// puts("[IRQ] Clearing and Disable all the pending IRQ...\r\n");
|
||||
|
||||
/*clear mask*/
|
||||
for (ptr = 0x02800400; ptr < 0x02800400 + 128; ptr++) {
|
||||
*(uint8_t*)ptr = 0;
|
||||
}
|
||||
/*clear pending*/
|
||||
for (ptr = 0x02800000; ptr < 0x02800000 + 128; ptr++) {
|
||||
*(uint8_t*)ptr = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_IRQ_H__
|
||||
#define __BL_IRQ_H__
|
||||
void bl_irq_enable(unsigned int source);
|
||||
void bl_irq_disable(unsigned int source);
|
||||
typedef enum {
|
||||
BL_IRQ_EXCEPTION_TYPE_LOAD_MISALIGN,
|
||||
BL_IRQ_EXCEPTION_TYPE_STORE_MISALIGN,
|
||||
BL_IRQ_EXCEPTION_TYPE_ACCESS_ILLEGAL,
|
||||
BL_IRQ_EXCEPTION_TYPE_ILLEGAL_INSTRUCTION,
|
||||
} BL_IRQ_EXCEPTION_TYPE_T;
|
||||
|
||||
struct irq_ctx {
|
||||
char *name;
|
||||
int irqnum;
|
||||
uint64_t irq_run_time;
|
||||
};
|
||||
|
||||
struct irq_ctx **bl_irq_ctx_list(int *num);
|
||||
void bl_irq_exception_trigger(BL_IRQ_EXCEPTION_TYPE_T type, void *ptr);
|
||||
|
||||
void bl_irq_init(void);
|
||||
/*The following section define the IRQ handler for other files*/
|
||||
void bl_sec_aes_IRQHandler(void);
|
||||
void bl_sec_sha_IRQHandler(void);
|
||||
void bl_sec_pka_IRQHandler(void);
|
||||
void bl_dma_IRQHandler(void);
|
||||
void intc_irq(void);//MAC IRQ
|
||||
void bl_irq_handler(void);//IPC host IRQ
|
||||
void bl_irq_register_with_ctx(int irqnum, void *handler, void *ctx);
|
||||
void bl_irq_register(int irqnum, void *handler);
|
||||
void bl_irq_unregister(int irqnum, void *handler);
|
||||
void bl_irq_ctx_get(int irqnum, void **ctx);
|
||||
|
||||
|
||||
int bl_irq_save(void);
|
||||
void bl_irq_restore(int flags);
|
||||
void __attribute__((noreturn)) bl_sys_abort(const char *details);
|
||||
|
||||
#define GLOBAL_IRQ_SAVE() if (1) { \
|
||||
int ____global_prev_mie_irq____ = bl_irq_save();
|
||||
|
||||
#define GLOBAL_IRQ_RESTORE() \
|
||||
bl_irq_restore(____global_prev_mie_irq____ ); \
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "bl_mm_clock.h"
|
||||
//FIXME no BL808/BL606p header file including is Allowed here
|
||||
#ifdef BL808
|
||||
#include <bl808_glb.h>
|
||||
#include <mm_glb_reg.h>
|
||||
#elif defined(BL606P)
|
||||
//TODO BL606P H FILE
|
||||
#include <bl606p_glb.h>
|
||||
#include <mm_glb_reg.h>
|
||||
#else
|
||||
#error "Use CHIP BL808/BL606P for this module"
|
||||
#endif
|
||||
|
||||
static void get_mm_xclk(uint32_t reg_val)
|
||||
{
|
||||
uint32_t cpu_pll_clk = 0;
|
||||
cpu_pll_clk = BL_GET_REG_BITS_VAL(reg_val, MM_GLB_REG_XCLK_CLK_SEL);
|
||||
|
||||
switch (cpu_pll_clk) {
|
||||
case 0:
|
||||
printf("XCLK select RC32M\r\n");
|
||||
break;
|
||||
case 1:
|
||||
printf("XCLK select XTAL\r\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void get_mm_cpu_pll_clk(uint32_t reg_val)
|
||||
{
|
||||
uint32_t cpu_pll_clk = 0;
|
||||
cpu_pll_clk = BL_GET_REG_BITS_VAL(reg_val, MM_GLB_REG_CPU_CLK_SEL);
|
||||
|
||||
switch (cpu_pll_clk) {
|
||||
case 0:
|
||||
printf("MM CPU select 240Mhz\r\n");
|
||||
break;
|
||||
case 1:
|
||||
printf("MM CPU select 320Mhz\r\n");
|
||||
break;
|
||||
case 2:
|
||||
printf("MM CPU select 400Mhz\r\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void dump_mm_cpu_clk(void)
|
||||
{
|
||||
uint32_t tmpVal = 0, cpu_root_clk = 0;
|
||||
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
cpu_root_clk = BL_GET_REG_BITS_VAL(tmpVal, MM_GLB_REG_CPU_ROOT_CLK_SEL);
|
||||
switch (cpu_root_clk) {
|
||||
case 0:
|
||||
printf("MM CPU select XCLK--->");
|
||||
get_mm_xclk(tmpVal);
|
||||
break;
|
||||
case 1:
|
||||
printf("MM CPU select PLL--->");
|
||||
get_mm_cpu_pll_clk(tmpVal);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_mm_bus_clk(void)
|
||||
{
|
||||
uint32_t tmpVal = 0, mm_bus_clk = 0;
|
||||
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
mm_bus_clk = BL_GET_REG_BITS_VAL(tmpVal, MM_GLB_REG_BCLK1X_SEL);
|
||||
|
||||
switch (mm_bus_clk) {
|
||||
case 0:
|
||||
printf("MM BUS CLK select XCLK--->");
|
||||
get_mm_xclk(tmpVal);
|
||||
break;
|
||||
case 2:
|
||||
printf("MM BUS CLK select 160Mhz\r\n");
|
||||
break;
|
||||
case 3:
|
||||
printf("MM BUS CLK select 240Mhz\r\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void dump_mm_xclk(void)
|
||||
{
|
||||
uint32_t tmpVal = 0;
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
get_mm_xclk(tmpVal);
|
||||
}
|
||||
|
||||
static void dump_mm_uart_clk(void)
|
||||
{
|
||||
uint32_t tmpVal = 0, mm_uart_clk = 0;
|
||||
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
mm_uart_clk = BL_GET_REG_BITS_VAL(tmpVal, MM_GLB_REG_UART_CLK_SEL);
|
||||
|
||||
switch (mm_uart_clk) {
|
||||
case 0:
|
||||
printf("UART CLK select MM BUS CLK--->");
|
||||
dump_mm_bus_clk();
|
||||
break;
|
||||
case 1:
|
||||
printf("UART CLK select 160Mhz\r\n");
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
printf("UART CLK select MM XCLK--->");
|
||||
get_mm_xclk(tmpVal);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_mm_i2c_clk(void)
|
||||
{
|
||||
uint32_t tmpVal = 0, mm_i2c_clk = 0;
|
||||
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
mm_i2c_clk = BL_GET_REG_BITS_VAL(tmpVal, MM_GLB_REG_I2C_CLK_SEL);
|
||||
|
||||
switch (mm_i2c_clk) {
|
||||
case 0:
|
||||
printf("I2C CLK select MM BUS CLK--->");
|
||||
dump_mm_bus_clk();
|
||||
break;
|
||||
case 1:
|
||||
printf("I2C CLK select MM XCLK--->");
|
||||
get_mm_xclk(tmpVal);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_mm_spi_clk(void)
|
||||
{
|
||||
uint32_t tmpVal = 0, mm_spi_clk = 0;
|
||||
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
mm_spi_clk = BL_GET_REG_BITS_VAL(tmpVal, MM_GLB_REG_SPI_CLK_SEL);
|
||||
|
||||
switch (mm_spi_clk) {
|
||||
case 0:
|
||||
printf("SPI CLK select 160Mhz\r\n");
|
||||
break;
|
||||
case 1:
|
||||
printf("SPI CLK select MM XCLK--->");
|
||||
get_mm_xclk(tmpVal);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void bl_mm_clk_dump(void)
|
||||
{
|
||||
dump_mm_cpu_clk();
|
||||
dump_mm_uart_clk();
|
||||
dump_mm_i2c_clk();
|
||||
dump_mm_spi_clk();
|
||||
dump_mm_bus_clk();
|
||||
dump_mm_xclk();
|
||||
}
|
||||
|
||||
void bl_mm_xclk_config(mm_xclk_type xclk_num)
|
||||
{
|
||||
uint32_t tmpVal;
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, MM_GLB_REG_XCLK_CLK_SEL, xclk_num);
|
||||
|
||||
BL_WR_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU, tmpVal);
|
||||
}
|
||||
|
||||
void bl_mm_bclk_config(mm_bclk_type bclk_num)
|
||||
{
|
||||
uint32_t tmpVal;
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, MM_GLB_REG_BCLK1X_SEL, bclk_num);
|
||||
|
||||
BL_WR_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU, tmpVal);
|
||||
}
|
||||
|
||||
void bl_mm_cpu_root_clk_config(mm_cpu_root_clk_type cpu_root_clk_num)
|
||||
{
|
||||
uint32_t tmpVal;
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, MM_GLB_REG_CPU_ROOT_CLK_SEL, cpu_root_clk_num);
|
||||
|
||||
BL_WR_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU, tmpVal);
|
||||
}
|
||||
|
||||
void bl_mm_cpu_clk_config(mm_cpu_clk_type cpu_clk_num)
|
||||
{
|
||||
uint32_t tmpVal;
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, MM_GLB_REG_CPU_CLK_SEL, cpu_clk_num);
|
||||
|
||||
BL_WR_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU, tmpVal);
|
||||
}
|
||||
|
||||
void bl_mm_spi_clk_config(mm_spi_clk_type spi_clk_num)
|
||||
{
|
||||
uint32_t tmpVal;
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, MM_GLB_REG_SPI_CLK_SEL, spi_clk_num);
|
||||
|
||||
BL_WR_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU, tmpVal);
|
||||
}
|
||||
|
||||
void bl_mm_i2c_clk_config(mm_i2c_clk_type i2c_clk_num)
|
||||
{
|
||||
uint32_t tmpVal;
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, MM_GLB_REG_I2C_CLK_SEL, i2c_clk_num);
|
||||
|
||||
BL_WR_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU, tmpVal);
|
||||
}
|
||||
|
||||
void bl_mm_uart_clk_config(mm_uart_clk_type uart_clk_num)
|
||||
{
|
||||
uint32_t tmpVal;
|
||||
tmpVal = BL_RD_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, MM_GLB_REG_UART_CLK_SEL, uart_clk_num);
|
||||
|
||||
BL_WR_REG(CLKRST_CTRL_BASE, MM_GLB_MM_CLK_CTRL_CPU, tmpVal);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_MM_CLOCK__
|
||||
#define __BL_MM_CLOCK__
|
||||
/*MM XCLK select*/
|
||||
typedef enum {
|
||||
XCLK_RC32M = 0,
|
||||
XCLK_XTAL,
|
||||
}mm_xclk_type;
|
||||
|
||||
/*MM BCLK1x select*/
|
||||
typedef enum {
|
||||
BCLK_XCLK = 0,
|
||||
BCLK_MUXPLL_160M = 2,
|
||||
BCLK_MUXPLL_240M = 3,
|
||||
}mm_bclk_type;
|
||||
|
||||
/*MM CPU PLL select*/
|
||||
typedef enum {
|
||||
CPU_CLK_MUXPLL_240M = 0,
|
||||
CPU_CLK_MUXPLL_320M,
|
||||
CPU_CLK_MUXPLL_400M,
|
||||
}mm_cpu_clk_type;
|
||||
|
||||
/*MM CPU ROOT CLK select*/
|
||||
typedef enum {
|
||||
CPU_ROOT_CLK_XCLK = 0,
|
||||
CPU_ROOT_CLK_PLL,
|
||||
}mm_cpu_root_clk_type;
|
||||
|
||||
/*MM SPI CLK select*/
|
||||
typedef enum {
|
||||
SPI_CLK_MUXPLL_160M = 0,
|
||||
SPI_CLK_XCLK,
|
||||
}mm_spi_clk_type;
|
||||
|
||||
/*MM I2C CLK select*/
|
||||
typedef enum {
|
||||
I2C_CLK_BCLK = 0,
|
||||
I2C_CLK_XCLK,
|
||||
}mm_i2c_clk_type;
|
||||
|
||||
/*MM UART CLK select*/
|
||||
typedef enum {
|
||||
UART_CLK_BCLK = 0,
|
||||
UART_CLK_MUXPLL_160M,
|
||||
UART_CLK_XCLK1, //2 or 3 all select MM XCLK
|
||||
UART_CLK_XCLK2,
|
||||
}mm_uart_clk_type;
|
||||
|
||||
void bl_mm_clk_dump(void);
|
||||
void bl_mm_xclk_config(mm_xclk_type xclk_num);
|
||||
void bl_mm_bclk_config(mm_bclk_type bclk_num);
|
||||
void bl_mm_cpu_clk_config(mm_cpu_clk_type cpu_clk_num);
|
||||
void bl_mm_cpu_root_clk_config(mm_cpu_root_clk_type cpu_root_clk_num);
|
||||
void bl_mm_spi_clk_config(mm_spi_clk_type spi_clk_num);
|
||||
void bl_mm_i2c_clk_config(mm_i2c_clk_type i2c_clk_num);
|
||||
void bl_mm_uart_clk_config(mm_uart_clk_type uart_clk_num);
|
||||
#endif
|
||||
@@ -0,0 +1,489 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <semphr.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <utils_list.h>
|
||||
#include <blog.h>
|
||||
#include "bl_pm.h"
|
||||
#include <assert.h>
|
||||
|
||||
enum PM_STATE {
|
||||
PM_STATE_INITED = 0,
|
||||
PM_STATE_STOP,
|
||||
PM_STATE_START,
|
||||
PM_STATE_STOPPED,
|
||||
PM_STATE_RUNNING,
|
||||
};
|
||||
|
||||
union ps_cap {
|
||||
uint32_t cap;
|
||||
struct {
|
||||
unsigned int uapsd_mode : 1;
|
||||
unsigned int mac_idle : 1;
|
||||
unsigned int ma_doze : 1;
|
||||
unsigned int rf_onoff : 1;
|
||||
unsigned int pti_pta_config : 1;
|
||||
unsigned int force_sleep : 1;
|
||||
} bits;
|
||||
};
|
||||
|
||||
struct pm_env
|
||||
{
|
||||
uint32_t level;
|
||||
union ps_cap wlan_capacity;
|
||||
union ps_cap bt_capacity;
|
||||
enum PM_STATE state;
|
||||
SemaphoreHandle_t pm_mux;
|
||||
utils_dlist_t *pm_list;
|
||||
};
|
||||
|
||||
struct pm_node
|
||||
{
|
||||
utils_dlist_t dlist_item;
|
||||
enum PM_EVEMT event;
|
||||
uint32_t code;
|
||||
uint16_t priority;
|
||||
uint32_t cap_bit;
|
||||
bl_pm_cb_t ops;
|
||||
enum PM_EVENT_ABLE enable;
|
||||
void *ctx;
|
||||
};
|
||||
|
||||
static struct pm_env *gp_pm_env = NULL;
|
||||
|
||||
static int pm_env_init(void)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
assert(!gp_pm_env);
|
||||
|
||||
gp_pm_env = pvPortMalloc(sizeof(struct pm_env));
|
||||
assert(gp_pm_env);
|
||||
|
||||
memset(gp_pm_env, 0, sizeof(struct pm_env));
|
||||
gp_pm_env->pm_list = pvPortMalloc(sizeof(utils_dlist_t) * PM_EVENT_MAX);
|
||||
assert(gp_pm_env->pm_list);
|
||||
|
||||
memset(gp_pm_env->pm_list, 0, sizeof(bl_pm_cb_t) * PM_EVENT_MAX);
|
||||
|
||||
gp_pm_env->pm_mux = xSemaphoreCreateMutex();
|
||||
assert(gp_pm_env->pm_mux);
|
||||
|
||||
for (i = 0; i < PM_EVENT_MAX; i++) {
|
||||
INIT_UTILS_DLIST_HEAD(&(gp_pm_env->pm_list)[i]);
|
||||
}
|
||||
|
||||
gp_pm_env->state = PM_STATE_INITED;
|
||||
|
||||
///for debug
|
||||
gp_pm_env->bt_capacity.cap = 0xffff;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pm_node_delete(utils_dlist_t *queue)
|
||||
{
|
||||
struct pm_node *node = NULL;
|
||||
utils_dlist_t *tmp;
|
||||
|
||||
utils_dlist_for_each_entry_safe(queue, tmp, node, struct pm_node, dlist_item) {
|
||||
xSemaphoreTake(gp_pm_env->pm_mux, portMAX_DELAY);
|
||||
utils_dlist_del(&(node->dlist_item));
|
||||
vPortFree(node);
|
||||
xSemaphoreGive(gp_pm_env->pm_mux);
|
||||
}
|
||||
}
|
||||
|
||||
static int pm_deinit(void)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
assert(gp_pm_env);
|
||||
|
||||
for (i = 0; i < PM_EVENT_MAX; i++) {
|
||||
pm_node_delete(&(gp_pm_env->pm_list)[i]);
|
||||
}
|
||||
|
||||
vPortFree(gp_pm_env->pm_list);
|
||||
gp_pm_env->pm_list = NULL;
|
||||
|
||||
vSemaphoreDelete(gp_pm_env->pm_mux);
|
||||
gp_pm_env->pm_mux = NULL;
|
||||
|
||||
vPortFree(gp_pm_env);
|
||||
gp_pm_env = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pm_set_wlan_capacity(uint32_t capacity)
|
||||
{
|
||||
assert(gp_pm_env);
|
||||
|
||||
gp_pm_env->wlan_capacity.cap = capacity;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pm_set_state(enum PM_STATE state)
|
||||
{
|
||||
gp_pm_env->state = state;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum PM_STATE pm_get_state(void)
|
||||
{
|
||||
return gp_pm_env->state;
|
||||
}
|
||||
|
||||
static void pm_node_add(struct pm_node *pnode, utils_dlist_t *queue)
|
||||
{
|
||||
struct pm_node *node = NULL;
|
||||
utils_dlist_t *tmp;
|
||||
utils_dlist_t *pre_save;
|
||||
|
||||
pre_save = queue;
|
||||
utils_dlist_for_each_entry_safe(queue, tmp, node, struct pm_node, dlist_item) {
|
||||
if (pnode->priority < node->priority) {
|
||||
xSemaphoreTake(gp_pm_env->pm_mux, portMAX_DELAY);
|
||||
utils_dlist_add(&(pnode->dlist_item), pre_save);
|
||||
xSemaphoreGive(gp_pm_env->pm_mux);
|
||||
break;
|
||||
}
|
||||
|
||||
pre_save = &(node->dlist_item);
|
||||
}
|
||||
|
||||
if (&(node->dlist_item) == queue) {
|
||||
xSemaphoreTake(gp_pm_env->pm_mux, portMAX_DELAY);
|
||||
utils_dlist_add_tail(&(pnode->dlist_item), queue);
|
||||
xSemaphoreGive(gp_pm_env->pm_mux);
|
||||
}
|
||||
}
|
||||
|
||||
static int pm_node_ops_exec(struct pm_node *node)
|
||||
{
|
||||
if (node->ops == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return node->ops(node->ctx);
|
||||
}
|
||||
|
||||
static int pm_state_exec_func_check(enum PM_EVEMT event, uint32_t code)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if ((WLAN_PM_EVENT_CONTROL == event) || (PM_STATE_RUNNING == gp_pm_env->state)) {
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int pm_pmlist_traverse(enum PM_EVEMT event, utils_dlist_t *queue, uint32_t code, uint32_t *retval)
|
||||
{
|
||||
struct pm_node *node = NULL;
|
||||
int ret = 0;
|
||||
utils_dlist_t *tmp;
|
||||
|
||||
if (retval) {
|
||||
*retval = 0;
|
||||
}
|
||||
|
||||
utils_dlist_for_each_entry_safe(queue, tmp, node, struct pm_node, dlist_item) {
|
||||
if ((node->enable) && (code == node->code) && (gp_pm_env->wlan_capacity.cap & node->cap_bit) &&
|
||||
(gp_pm_env->bt_capacity.cap & node->cap_bit)) {
|
||||
|
||||
if (pm_state_exec_func_check(event, code)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = pm_node_ops_exec(node);
|
||||
if (ret && retval) {
|
||||
*retval |= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pm_internal_process_event(enum PM_EVEMT event, uint32_t code)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (event) {
|
||||
case WLAN_PM_EVENT_CONTROL:
|
||||
{
|
||||
switch (code) {
|
||||
case WLAN_CODE_PM_NOTIFY_START:
|
||||
{
|
||||
if ((PM_STATE_INITED != pm_get_state()) && (PM_STATE_STOPPED != pm_get_state())) {
|
||||
blog_error("pm not init or is running.\r\n");
|
||||
ret = -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
pm_set_state(PM_STATE_START);
|
||||
}
|
||||
break;
|
||||
|
||||
case WLAN_CODE_PM_NOTIFY_STOP:
|
||||
{
|
||||
if (PM_STATE_RUNNING != pm_get_state()) {
|
||||
blog_error("pm is not running.\r\n");
|
||||
ret = -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
pm_set_state(PM_STATE_STOP);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pm_post_event(enum PM_EVEMT event, uint32_t code, uint32_t *retval)
|
||||
{
|
||||
if (!gp_pm_env) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pm_pmlist_traverse(event, &(gp_pm_env->pm_list)[event], code, retval);
|
||||
pm_internal_process_event(event, code);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_pm_event_register(enum PM_EVEMT event, uint32_t code, uint32_t cap_bit, uint16_t priority, bl_pm_cb_t ops, void *arg, enum PM_EVENT_ABLE enable)
|
||||
{
|
||||
struct pm_node *p_node;
|
||||
|
||||
if (!gp_pm_env) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
p_node = pvPortMalloc(sizeof(struct pm_node));
|
||||
assert(p_node);
|
||||
|
||||
memset(p_node, 0, sizeof(struct pm_node));
|
||||
p_node->event = event;
|
||||
p_node->code = code;
|
||||
p_node->cap_bit = cap_bit;
|
||||
p_node->priority = priority;
|
||||
p_node->ops = ops;
|
||||
p_node->ctx = arg;
|
||||
p_node->enable = enable;
|
||||
|
||||
pm_node_add(p_node, &(gp_pm_env->pm_list)[event]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_pm_event_switch(enum PM_EVEMT event, uint32_t code, enum PM_EVENT_ABLE enable)
|
||||
{
|
||||
struct pm_node *node = NULL;
|
||||
utils_dlist_t *tmp;
|
||||
utils_dlist_t *queue;
|
||||
int ret = -1;
|
||||
|
||||
if (!gp_pm_env) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
queue = &(gp_pm_env->pm_list)[event];
|
||||
|
||||
utils_dlist_for_each_entry_safe(queue, tmp, node, struct pm_node, dlist_item) {
|
||||
if (code == node->code) {
|
||||
node->enable = enable;
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bl_pm_state_run(void)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!gp_pm_env) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (gp_pm_env->state) {
|
||||
case PM_STATE_INITED:
|
||||
{
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_STATE_START:
|
||||
{
|
||||
pm_set_state(PM_STATE_RUNNING);
|
||||
pm_post_event(WLAN_PM_EVENT_CONTROL, WLAN_CODE_PM_START, NULL);;
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_STATE_STOP:
|
||||
{
|
||||
pm_set_state(PM_STATE_STOPPED);
|
||||
pm_post_event(WLAN_PM_EVENT_CONTROL, WLAN_CODE_PM_STOP, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_STATE_RUNNING:
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_STATE_STOPPED:
|
||||
{
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bl_pm_capacity_set(enum PM_LEVEL level)
|
||||
{
|
||||
uint32_t capacity = 0;
|
||||
|
||||
switch (level) {
|
||||
case PM_MODE_STA_NONE:
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_MODE_STA_IDLE:
|
||||
{
|
||||
capacity |= NODE_CAP_BIT_UAPSD_MODE;
|
||||
capacity |= NODE_CAP_BIT_MAC_IDLE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_MODE_STA_MESH:
|
||||
{
|
||||
capacity |= NODE_CAP_BIT_UAPSD_MODE;
|
||||
capacity |= NODE_CAP_BIT_MAC_IDLE;
|
||||
capacity |= NODE_CAP_BIT_WLAN_BLE_ABORT;
|
||||
capacity |= NODE_CAP_BIT_FORCE_SLEEP;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_MODE_STA_DOZE:
|
||||
{
|
||||
capacity |= NODE_CAP_BIT_UAPSD_MODE;
|
||||
capacity |= NODE_CAP_BIT_MAC_IDLE;
|
||||
capacity |= NODE_CAP_BIT_MAC_DOZE;
|
||||
capacity |= NODE_CAP_BIT_RF_ONOFF;
|
||||
capacity |= NODE_CAP_BIT_FORCE_SLEEP;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_MODE_STA_COEX:
|
||||
{
|
||||
capacity |= NODE_CAP_BIT_UAPSD_MODE;
|
||||
capacity |= NODE_CAP_BIT_MAC_IDLE;
|
||||
capacity |= NODE_CAP_BIT_MAC_DOZE;
|
||||
capacity |= NODE_CAP_BIT_RF_ONOFF;
|
||||
capacity |= NODE_CAP_BIT_WLAN_BLE_ABORT;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_MODE_STA_DOWN:
|
||||
{
|
||||
capacity |= NODE_CAP_BIT_MAC_IDLE;
|
||||
capacity |= NODE_CAP_BIT_MAC_DOZE;
|
||||
capacity |= NODE_CAP_BIT_RF_ONOFF;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_MODE_AP_IDLE:
|
||||
{
|
||||
capacity |= NODE_CAP_BIT_MAC_IDLE;
|
||||
capacity |= NODE_CAP_BIT_MAC_DOZE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
pm_set_wlan_capacity(capacity);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_pm_init(void)
|
||||
{
|
||||
pm_env_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_pm_deinit(void)
|
||||
{
|
||||
pm_deinit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_PM_H__
|
||||
#define __BL_PM_H__
|
||||
#include <stdint.h>
|
||||
#include <utils_list.h>
|
||||
|
||||
#define NODE_CAP_BIT_UAPSD_MODE (1 << 0)
|
||||
#define NODE_CAP_BIT_MAC_IDLE (1 << 1)
|
||||
#define NODE_CAP_BIT_MAC_DOZE (1 << 2)
|
||||
#define NODE_CAP_BIT_RF_ONOFF (1 << 3)
|
||||
#define NODE_CAP_BIT_WLAN_BLE_ABORT (1 << 4)
|
||||
#define NODE_CAP_BIT_FORCE_SLEEP (1 << 5)
|
||||
#define NODE_CAP_BIT_ALL_ALLOWED (0xffff)
|
||||
|
||||
enum PM_EVENT_ABLE {
|
||||
PM_DISABLE = 0,
|
||||
PM_ENABLE,
|
||||
};
|
||||
|
||||
enum WLAN_CODE_SLEEP_CONTROL {
|
||||
WLAN_CODE_PM_NOTIFY_START = 0,
|
||||
WLAN_CODE_PM_NOTIFY_STOP,
|
||||
WLAN_CODE_PM_START,
|
||||
WLAN_CODE_PM_STOP,
|
||||
};
|
||||
|
||||
enum WLAN_CODE_ENTER_SLEEP {
|
||||
WLAN_CODE_PM_ENTER_SLEEP_PRE = 0,
|
||||
WLAN_CODE_PM_ENTER_SLEEP,
|
||||
};
|
||||
|
||||
enum WLAN_CODE_EXIT_SLEEP {
|
||||
WLAN_CODE_PM_ENTER_SLEEP_PRE_FAILED = 0,
|
||||
WLAN_CODE_PM_EXIT_SLEEP_PRE,
|
||||
WLAN_CODE_PM_EXIT_SLEEP,
|
||||
};
|
||||
|
||||
enum WLAN_CODE_BEACON_LOSS {
|
||||
WLAN_CODE_BEACON_LOSS = 0,
|
||||
};
|
||||
|
||||
enum WLAN_CODE_SEND_NULLDATA {
|
||||
WLAN_CODE_PM_PAUSE = 0,
|
||||
WLAN_CODE_PM_NULLDATA_NOACK,
|
||||
WLAN_CODE_PM_NULLDATA_SEND_ERROR,
|
||||
};
|
||||
|
||||
enum BLE_CODE_BLE_CONTROL {
|
||||
BLE_CODE_PM_TURNON_RF = 0,
|
||||
BLE_CODE_PM_TURNOFF_RF,
|
||||
};
|
||||
|
||||
enum PM_LEVEL{
|
||||
PM_MODE_STA_NONE = 0,
|
||||
PM_MODE_STA_IDLE,
|
||||
PM_MODE_STA_MESH,
|
||||
PM_MODE_STA_DOZE,
|
||||
PM_MODE_STA_COEX,
|
||||
PM_MODE_STA_DOWN,
|
||||
PM_MODE_AP_IDLE,
|
||||
PM_MODE_MAX,
|
||||
};
|
||||
|
||||
enum PM_EVEMT{
|
||||
WLAN_PM_EVENT_CONTROL = 0,
|
||||
WLAN_PM_EVENT_ENTER_SLEEP,
|
||||
WLAN_PM_EVENT_EXIT_SLEEP,
|
||||
WLAN_PM_EVENT_BEACON_LOSS,
|
||||
WLAN_PM_EVENT_SEND_NULLDATA,
|
||||
BLE_PM_EVENT_CONTROL,
|
||||
PM_EVENT_MAX,
|
||||
};
|
||||
|
||||
typedef int (*bl_pm_cb_t)(void *arg);
|
||||
|
||||
int bl_pm_init(void);
|
||||
int bl_pm_event_register(enum PM_EVEMT event, uint32_t code, uint32_t cap_bit, uint16_t pirority, bl_pm_cb_t ops, void *arg, enum PM_EVENT_ABLE enable);
|
||||
int bl_pm_deinit(void);
|
||||
int bl_pm_state_run(void);
|
||||
int bl_pm_capacity_set(enum PM_LEVEL level);
|
||||
int pm_post_event(enum PM_EVEMT event, uint32_t code, uint32_t *retval);
|
||||
int bl_pm_event_switch(enum PM_EVEMT event, uint32_t code, enum PM_EVENT_ABLE enable);
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "bl_psram.h"
|
||||
#ifdef BL808
|
||||
#include <bl808_psram_uhs.h>
|
||||
#include <bl808_glb.h>
|
||||
|
||||
int bl_psram_init(void)
|
||||
{
|
||||
GLB_Config_UHS_PLL(GLB_XTAL_40M, uhsPllCfg_2000M);
|
||||
Psram_UHS_x16_Init(2000);
|
||||
printf("Done. \r\nData @0x5000_0000 is %08lx\r\n", *(uint32_t*)0x50000000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(BL606P)
|
||||
#include <bl606p_glb.h>
|
||||
int bl_psram_init(void)
|
||||
{
|
||||
puts("--> dummy PSRAM init implemented\r\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_PSRAM_H__
|
||||
#define __BL_PSRAM_H__
|
||||
|
||||
int bl_psram_init(void);
|
||||
#endif
|
||||
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
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_SEC_H__
|
||||
#define __BL_SEC_H__
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <semphr.h>
|
||||
|
||||
/* copied SEC_Eng_SHA256_Ctx from stddrv */
|
||||
typedef struct {
|
||||
uint32_t total[2];
|
||||
uint32_t *shaBuf;
|
||||
uint32_t *shaPadding;
|
||||
uint8_t shaFeed;
|
||||
} _bl_sha_SEC_Eng_SHA256_Ctx_t;
|
||||
|
||||
/* copied SEC_ENG_SHA_Type from stddrv, SHA1_RSVD removed */
|
||||
typedef enum {
|
||||
BL_SHA256,
|
||||
BL_SHA224,
|
||||
BL_SHA1,
|
||||
} bl_sha_type_t;
|
||||
|
||||
typedef struct bl_sha_ctx {
|
||||
_bl_sha_SEC_Eng_SHA256_Ctx_t sha_ctx;
|
||||
uint32_t tmp[16];
|
||||
uint32_t pad[16];
|
||||
} bl_sha_ctx_t;
|
||||
|
||||
extern SemaphoreHandle_t g_bl_sec_sha_mutex;
|
||||
|
||||
int bl_sec_init(void);
|
||||
int bl_sec_test(void);
|
||||
int bl_pka_test(void);
|
||||
int bl_sec_aes_init(void);
|
||||
int bl_sec_aes_enc(uint8_t *key, int keysize, uint8_t *input, uint8_t *output);
|
||||
int bl_sec_aes_test(void);
|
||||
uint32_t bl_sec_get_random_word(void);
|
||||
void bl_rand_stream(uint8_t *buf, int len);
|
||||
int bl_rand(void);
|
||||
/*SHA Engine API*/
|
||||
int bl_sec_sha_test(void);
|
||||
|
||||
int bl_sha_mutex_take();
|
||||
int bl_sha_mutex_give();
|
||||
void bl_sha_init(bl_sha_ctx_t *ctx, const bl_sha_type_t type);
|
||||
int bl_sha_update(bl_sha_ctx_t *ctx, const uint8_t *input, uint32_t len);
|
||||
int bl_sha_finish(bl_sha_ctx_t *ctx, uint8_t *hash);
|
||||
int bl_sec_ccm_encrypt_and_tag(const uint8_t *key, unsigned int key_bytelen, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len,
|
||||
const unsigned char *input, unsigned char *output, unsigned char *tag, size_t tag_len);
|
||||
int bl_sec_ccm_auth_decrypt(const uint8_t *key, unsigned int key_bytelen, size_t length,const unsigned char *iv, size_t iv_len, const unsigned char *add,
|
||||
size_t add_len, const unsigned char *input, unsigned char *output, const unsigned char *tag, size_t tag_len);
|
||||
int bl_sec_aes_ecb_encrypt(const uint8_t *key, unsigned int key_bytelen, size_t length, const unsigned char *input, unsigned char *output);
|
||||
int bl_sec_aes_ecb_decrypt(const uint8_t *key, unsigned int key_bytelen, size_t length, const unsigned char *input, unsigned char *output);
|
||||
#endif
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include <bl606p_sec_eng.h>
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <semphr.h>
|
||||
|
||||
#include "bl_irq.h"
|
||||
#include "bl_sec.h"
|
||||
|
||||
#include <blog.h>
|
||||
|
||||
typedef struct sha256_link_item {
|
||||
SEC_Eng_SHA256_Link_Ctx ctx;
|
||||
SEC_Eng_SHA_Link_Config_Type linkCfg;
|
||||
uint32_t tmp[16];
|
||||
uint32_t pad[16];
|
||||
} sha256_link_item_t;
|
||||
|
||||
#define BL_SHA_ID SEC_ENG_SHA_ID0 // this is the only valid value
|
||||
|
||||
int bl_sha_mutex_take()
|
||||
{
|
||||
if (pdPASS != xSemaphoreTake(g_bl_sec_sha_mutex, portMAX_DELAY)) {
|
||||
blog_error("sha semphr take failed\r\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_sha_mutex_give()
|
||||
{
|
||||
if (pdPASS != xSemaphoreGive(g_bl_sec_sha_mutex)) {
|
||||
blog_error("sha semphr give failed\\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bl_sha_init(bl_sha_ctx_t *ctx, const bl_sha_type_t type)
|
||||
{
|
||||
const SEC_ENG_SHA_Type sha_type = (SEC_ENG_SHA_Type)type; // bl_sha_type_t is the same as SEC_ENG_SHA_Type in driver
|
||||
|
||||
Sec_Eng_SHA256_Init((SEC_Eng_SHA256_Ctx *)&ctx->sha_ctx, BL_SHA_ID, sha_type, ctx->tmp, ctx->pad);
|
||||
Sec_Eng_SHA_Start(BL_SHA_ID);
|
||||
}
|
||||
|
||||
int bl_sha_update(bl_sha_ctx_t *ctx, const uint8_t *input, uint32_t len)
|
||||
{
|
||||
return Sec_Eng_SHA256_Update((SEC_Eng_SHA256_Ctx *)&ctx->sha_ctx, BL_SHA_ID, input, len);
|
||||
}
|
||||
|
||||
int bl_sha_finish(bl_sha_ctx_t *ctx, uint8_t *hash)
|
||||
{
|
||||
return Sec_Eng_SHA256_Finish((SEC_Eng_SHA256_Ctx *)&ctx->sha_ctx, BL_SHA_ID, hash);
|
||||
}
|
||||
|
||||
static const uint8_t shaSrcBuf1[64] =
|
||||
{
|
||||
'1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
|
||||
'1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
|
||||
'1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
|
||||
'1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
|
||||
};
|
||||
|
||||
static void SHA_Compare_Data(const uint8_t *expected, const uint8_t *input, uint32_t len)
|
||||
{
|
||||
int i = 0, is_failed = 0;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (input[i] != expected[i]) {
|
||||
is_failed = 1;
|
||||
blog_print("%s[%02d], %02x %02x\r\n",
|
||||
input[i] ==expected[i] ? "S" : "F",
|
||||
i,
|
||||
input[i],
|
||||
expected[i]
|
||||
);
|
||||
}
|
||||
}
|
||||
if (is_failed) {
|
||||
blog_print("====== Failed %lu Bytes======\r\n", len);
|
||||
} else {
|
||||
blog_print("====== Success %lu Bytes=====\r\n", len);
|
||||
}
|
||||
}
|
||||
|
||||
void sha256_test_case0(void)
|
||||
{
|
||||
SEC_ENG_SHA_ID_Type shaId = SEC_ENG_SHA_ID0;
|
||||
sha256_link_item_t sha256_link = {
|
||||
.linkCfg.shaMode = SEC_ENG_SHA256,
|
||||
.linkCfg.shaHashSel = 0,
|
||||
.linkCfg.shaIntClr = 0,
|
||||
.linkCfg.shaIntSet = 1,
|
||||
.linkCfg.shaMsgLen = 1,
|
||||
.linkCfg.shaSrcAddr = 0x50020000,
|
||||
};
|
||||
static const uint8_t sha256_test_result[] =
|
||||
{
|
||||
0x31, 0x38, 0xbb, 0x9b, 0xc7, 0x8d, 0xf2, 0x7c, 0x47, 0x3e, 0xcf, 0xd1, 0x41, 0x0f, 0x7b, 0xd4,
|
||||
0x5e, 0xba, 0xc1, 0xf5, 0x9c, 0xf3, 0xff, 0x9c, 0xfe, 0x4d, 0xb7, 0x7a, 0xab, 0x7a, 0xed, 0xd3,
|
||||
};
|
||||
|
||||
|
||||
#define SEC_SHA_IRQn (IRQ_NUM_BASE+14)
|
||||
|
||||
bl_irq_register(SEC_SHA_IRQn, bl_sec_sha_IRQHandler);
|
||||
bl_irq_enable(SEC_SHA_IRQn);
|
||||
|
||||
Sec_Eng_SHA_Enable_Link(shaId);
|
||||
Sec_Eng_SHA256_Link_Init(&sha256_link.ctx, shaId,
|
||||
(uint32_t)&sha256_link.linkCfg,
|
||||
sha256_link.tmp,
|
||||
sha256_link.pad
|
||||
);
|
||||
Sec_Eng_SHA256_Link_Update(&sha256_link.ctx, shaId,
|
||||
shaSrcBuf1,
|
||||
64
|
||||
);
|
||||
//FIXME Request to change driver API
|
||||
Sec_Eng_SHA256_Link_Finish(&sha256_link.ctx, shaId, (uint8_t*)sha256_link.linkCfg.result);
|
||||
Sec_Eng_SHA_Disable_Link(shaId);
|
||||
|
||||
SHA_Compare_Data((const uint8_t*)sha256_link.linkCfg.result, sha256_test_result, sizeof(sha256_test_result));
|
||||
}
|
||||
|
||||
int bl_sec_sha_test(void)
|
||||
{
|
||||
puts("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n");
|
||||
puts("^^^^^^^^^^^^^^^^^^^^^^^SHA256 TEST CASE^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n");
|
||||
sha256_test_case0();
|
||||
puts("------------------------------------------------------------------------------------\r\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
static void _clear_sha_int()
|
||||
{
|
||||
uint32_t SHAx = SEC_ENG_BASE;
|
||||
uint32_t val;
|
||||
|
||||
val = BL_RD_REG(SHAx, SEC_ENG_SE_SHA_0_CTRL);
|
||||
val = BL_SET_REG_BIT(val, SEC_ENG_SE_SHA_0_INT_CLR_1T);
|
||||
BL_WR_REG(SHAx, SEC_ENG_SE_SHA_0_CTRL, val);
|
||||
}
|
||||
|
||||
void bl_sec_sha_IRQHandler(void)
|
||||
{
|
||||
puts("--->>> SHA IRQ\r\n");
|
||||
_clear_sha_int();
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
// #include <blog.h>
|
||||
#include <bl_irq.h>
|
||||
#include <bl_flash.h>
|
||||
#include <hal_boot2.h>
|
||||
#include <hal_board.h>
|
||||
//FIXME no BL808/BL606p header file including is Allowed here
|
||||
#ifdef BL808
|
||||
#include <bl808_glb.h>
|
||||
#include <bl808_pds.h>
|
||||
#elif defined(BL606P)
|
||||
#include <bl606p_glb.h>
|
||||
#include <bl606p_pds.h>
|
||||
#else
|
||||
#error "Use CHIP BL808/BL606P for this module"
|
||||
#endif
|
||||
#include "bl_sys.h"
|
||||
|
||||
#define MFG_CONFIG_REG (0x4000F100)
|
||||
#define MFG_CONFIG_VAL ("0mfg")
|
||||
|
||||
#define REASON_WDT (0x77646F67) // watchdog reboot wdog
|
||||
#define REASON_SOFTWARE (0x736F6674) // software soft
|
||||
#define REASON_POWEROFF (0x0) // software soft
|
||||
|
||||
#define RST_REASON (*((volatile uint32_t *)0x40010000)) // use 4 Bytes
|
||||
|
||||
static BL_RST_REASON_E s_rst_reason = BL_RST_POWER_OFF;
|
||||
|
||||
static char *RST_REASON_ARRAY[] = {
|
||||
"BL_RST_POWER_OFF",
|
||||
"BL_RST_HARDWARE_WATCHDOG",
|
||||
"BL_RST_FATAL_EXCEPTION",
|
||||
"BL_RST_SOFTWARE_WATCHDOG",
|
||||
"BL_RST_SOFTWARE"
|
||||
};
|
||||
extern volatile bool sys_log_all_enable;//XXX in debug.c
|
||||
|
||||
BL_RST_REASON_E bl_sys_rstinfo_get(void)
|
||||
{
|
||||
BL_RST_REASON_E ret = s_rst_reason;
|
||||
|
||||
s_rst_reason = REASON_POWEROFF;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bl_sys_rstinfo_set(BL_RST_REASON_E val)
|
||||
{
|
||||
if (val == BL_RST_SOFTWARE_WATCHDOG) {
|
||||
RST_REASON = REASON_WDT;
|
||||
} else if (val == BL_RST_SOFTWARE) {
|
||||
RST_REASON = REASON_SOFTWARE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bl_sys_rstinfo_init(void)
|
||||
{
|
||||
if (RST_REASON == REASON_WDT) {
|
||||
s_rst_reason = BL_RST_SOFTWARE_WATCHDOG;
|
||||
} else if (RST_REASON == REASON_SOFTWARE) {
|
||||
s_rst_reason = BL_RST_SOFTWARE;
|
||||
} else {
|
||||
s_rst_reason = BL_RST_POWER_OFF;
|
||||
}
|
||||
|
||||
bl_sys_rstinfo_set(BL_RST_SOFTWARE_WATCHDOG);
|
||||
}
|
||||
|
||||
int bl_sys_rstinfo_getsting(char *info)
|
||||
{
|
||||
memcpy(info, (char *)RST_REASON_ARRAY[s_rst_reason], strlen(RST_REASON_ARRAY[s_rst_reason]));
|
||||
*(info + strlen(RST_REASON_ARRAY[s_rst_reason])) = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_sys_logall_enable(void)
|
||||
{
|
||||
sys_log_all_enable = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_sys_logall_disable(void)
|
||||
{
|
||||
sys_log_all_enable = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bl_sys_mfg_config(void)
|
||||
{
|
||||
#if 0
|
||||
union _reg_t {
|
||||
uint8_t byte[4];
|
||||
uint32_t word;
|
||||
} mfg = {
|
||||
.byte = MFG_CONFIG_VAL,
|
||||
};
|
||||
|
||||
*(volatile uint32_t*)(MFG_CONFIG_REG) = mfg.word;
|
||||
#else
|
||||
puts("WARN: bl_sys_mfg_config is NOT implemented\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
int bl_sys_reset_por(void)
|
||||
{
|
||||
#if 0
|
||||
bl_sys_rstinfo_set(BL_RST_SOFTWARE);
|
||||
__disable_irq();
|
||||
GLB_SW_POR_Reset();
|
||||
while (1) {
|
||||
/*empty dead loop*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
puts("WARN: bl_sys_rstinfo_set is NOT implemented\r\n");
|
||||
__disable_irq();
|
||||
GLB_SW_POR_Reset();
|
||||
while (1) {
|
||||
/*empty dead loop*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void bl_sys_reset_system(void)
|
||||
{
|
||||
__disable_irq();
|
||||
GLB_SW_System_Reset();
|
||||
while (1) {
|
||||
/*empty dead loop*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int bl_sys_em_config(void)
|
||||
{
|
||||
#if 0
|
||||
extern uint8_t __LD_CONFIG_EM_SEL;
|
||||
volatile uint32_t em_size;
|
||||
|
||||
em_size = (uint32_t)&__LD_CONFIG_EM_SEL;
|
||||
|
||||
switch (em_size) {
|
||||
case 0 * 1024:
|
||||
{
|
||||
GLB_Set_EM_Sel(GLB_EM_0KB);
|
||||
}
|
||||
break;
|
||||
case 8 * 1024:
|
||||
{
|
||||
GLB_Set_EM_Sel(GLB_EM_8KB);
|
||||
}
|
||||
break;
|
||||
case 16 * 1024:
|
||||
{
|
||||
GLB_Set_EM_Sel(GLB_EM_16KB);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
/*nothing here*/
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
puts("WARN: bl_sys_em_config is NOT implemented\r\n");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int bl_sys_early_init(void)
|
||||
{
|
||||
#if 0
|
||||
extern BL_Err_Type HBN_Aon_Pad_IeSmt_Cfg(uint8_t padCfg);
|
||||
HBN_Aon_Pad_IeSmt_Cfg(1);
|
||||
|
||||
extern void freertos_risc_v_trap_handler(void); //freertos_riscv_ram/portable/GCC/RISC-V/portASM.S
|
||||
write_csr(mtvec, &freertos_risc_v_trap_handler);
|
||||
|
||||
/* reset here for use wtd first then init hwtimer later*/
|
||||
GLB_AHB_Slave1_Reset(BL_AHB_SLAVE1_TMR);
|
||||
/*debuger may NOT ready don't print anything*/
|
||||
return 0;
|
||||
#else
|
||||
puts("WARN: bl_sys_early_init is NOT implemented\r\n");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int bl_sys_init(void)
|
||||
{
|
||||
bl_sys_em_config();
|
||||
bl_sys_rstinfo_get();
|
||||
bl_sys_rstinfo_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bl_sys_isxipaddr(uint32_t addr)
|
||||
{
|
||||
//XXX is 0xD000_0000 Address Range is really used
|
||||
if ( ((addr & 0xFF000000) == 0x58000000) || ((addr & 0xFF000000) == 0x5C000000) ||
|
||||
((addr & 0xFF000000) == 0xD8000000) || ((addr & 0xFF000000) == 0xDC000000)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bl_enable_cpu0(void)
|
||||
{
|
||||
PDS_Power_On_MM_System();
|
||||
}
|
||||
|
||||
void bl_boot_cpu0(uint32_t start_addr)
|
||||
{
|
||||
GLB_Halt_CPU(GLB_CORE_ID_D0);
|
||||
GLB_Set_CPU_Reset_Address(GLB_CORE_ID_D0, start_addr);
|
||||
GLB_Release_CPU(GLB_CORE_ID_D0);
|
||||
}
|
||||
|
||||
void bl_halt_cpu0(void)
|
||||
{
|
||||
GLB_Halt_CPU(GLB_CORE_ID_D0);
|
||||
}
|
||||
|
||||
void bl_release_cpu0(void)
|
||||
{
|
||||
GLB_Release_CPU(GLB_CORE_ID_D0);
|
||||
}
|
||||
|
||||
void bl_sys_enabe_jtag(int cpuid)
|
||||
{
|
||||
GLB_GPIO_Cfg_Type gpio_cfg;
|
||||
|
||||
gpio_cfg.drive = 0;
|
||||
gpio_cfg.smtCtrl = 1;
|
||||
gpio_cfg.pullType = GPIO_PULL_NONE;
|
||||
|
||||
gpio_cfg.gpioMode = GPIO_MODE_AF;
|
||||
gpio_cfg.gpioFun = GPIO_FUN_JTAG_D0;
|
||||
switch (cpuid) {
|
||||
case 0:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
puts("Enable CPU1 (D0/C906) on PIN6/PIN7/PIN12/PIN13\r\n");
|
||||
gpio_cfg.gpioPin = GLB_GPIO_PIN_6;
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.gpioPin = GLB_GPIO_PIN_7;
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.gpioPin = GLB_GPIO_PIN_12;
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.gpioPin = GLB_GPIO_PIN_13;
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void bl_sys_reduce_mcu2ext(void)
|
||||
{
|
||||
uint32_t tmpVal;
|
||||
tmpVal = BL_RD_WORD(MCU_MISC_BASE + MCU_MISC_MCU_BUS_CFG1_OFFSET);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, MCU_MISC_REG_X_WTHRE_MCU2EXT, 3);
|
||||
BL_WR_WORD(MCU_MISC_BASE + MCU_MISC_MCU_BUS_CFG1_OFFSET, tmpVal);
|
||||
}
|
||||
|
||||
void bl_sys_lowlevel_init(void)
|
||||
{
|
||||
bl_sys_reduce_mcu2ext();
|
||||
// blog_init();
|
||||
bl_irq_init();
|
||||
bl_flash_init();
|
||||
hal_boot2_init();
|
||||
hal_board_cfg(0);
|
||||
#ifndef NO_BLE_CONFIG
|
||||
GLB_Set_EM_Sel(GLB_WRAM96KB_EM64KB);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __BL_SYS_H__
|
||||
#define __BL_SYS_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
BL_RST_POWER_OFF = 0,
|
||||
BL_RST_HARDWARE_WATCHDOG,
|
||||
BL_RST_FATAL_EXCEPTION,
|
||||
BL_RST_SOFTWARE_WATCHDOG,
|
||||
BL_RST_SOFTWARE,
|
||||
} BL_RST_REASON_E;
|
||||
|
||||
BL_RST_REASON_E bl_sys_rstinfo_get(void);
|
||||
int bl_sys_rstinfo_set(BL_RST_REASON_E val);
|
||||
int bl_sys_rstinfo_getsting(char *info);
|
||||
void bl_sys_rstinfo_init(void);
|
||||
int bl_sys_logall_enable(void);
|
||||
int bl_sys_logall_disable(void);
|
||||
void bl_sys_mfg_config(void);
|
||||
int bl_sys_reset_por(void);
|
||||
void bl_sys_reset_system(void);
|
||||
int bl_sys_isxipaddr(uint32_t addr);
|
||||
int bl_sys_early_init(void);
|
||||
int bl_sys_init(void);
|
||||
void bl_enable_cpu0(void);
|
||||
void bl_boot_cpu0(uint32_t start_addr);
|
||||
void bl_halt_cpu0(void);
|
||||
void bl_release_cpu0(void);
|
||||
void bl_sys_enabe_jtag(int cpuid);
|
||||
void bl_sys_lowlevel_init(void);
|
||||
#endif
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2022 Bouffalolab.
|
||||
*
|
||||
* This file is part of
|
||||
* *** Bouffalolab Software Dev Kit ***
|
||||
* (see www.bouffalolab.com).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "bl_timer.h"
|
||||
#ifdef BL808
|
||||
#include <bl808_clock.h>
|
||||
#include <bl808_glb.h>
|
||||
#elif defined(BL606P)
|
||||
#include <bl606p_clock.h>
|
||||
#include <bl606p_glb.h>
|
||||
#else
|
||||
#error "Use CHIP BL808/BL606P for this module"
|
||||
#endif
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
|
||||
uint32_t bl_timer_now_us(void)
|
||||
{
|
||||
return xTaskGetTickCount() * 1000000 / configTICK_RATE_HZ;
|
||||
}
|
||||
|
||||
uint32_t bl_system_core_clock_get(GLB_CORE_ID_Type core)
|
||||
{
|
||||
uint32_t clockVal = 0;
|
||||
|
||||
switch (core) {
|
||||
case GLB_CORE_ID_M0:
|
||||
clockVal = Clock_System_Clock_Get(BL_SYSTEM_CLOCK_MCU_CLK);
|
||||
break;
|
||||
case GLB_CORE_ID_D0:
|
||||
clockVal = Clock_System_Clock_Get(BL_SYSTEM_CLOCK_DSP_CLK);
|
||||
break;
|
||||
case GLB_CORE_ID_LP:
|
||||
clockVal = Clock_System_Clock_Get(BL_SYSTEM_CLOCK_LP_CLK);
|
||||
break;
|
||||
default:
|
||||
clockVal = 0;
|
||||
break;
|
||||
}
|
||||
clockVal = clockVal ? clockVal : (32 * 1000 * 1000);
|
||||
|
||||
return clockVal;
|
||||
}
|
||||
|
||||
BL_Err_Type bl_cpu_set_core_mtimer_clk(GLB_CORE_ID_Type core, uint8_t enable, uint16_t div)
|
||||
{
|
||||
uint32_t tmpVal = 0;
|
||||
uint32_t address = 0;
|
||||
|
||||
CHECK_PARAM((div <= 0x3FF));
|
||||
|
||||
switch (core) {
|
||||
case GLB_CORE_ID_M0:
|
||||
address = MCU_MISC_BASE + MCU_MISC_MCU_E907_RTC_OFFSET;
|
||||
break;
|
||||
case GLB_CORE_ID_D0:
|
||||
address = MM_MISC_BASE + MM_MISC_CPU_RTC_OFFSET;
|
||||
break;
|
||||
case GLB_CORE_ID_LP:
|
||||
address = PDS_BASE + PDS_CPU_CORE_CFG8_OFFSET;
|
||||
break;
|
||||
default:
|
||||
address = MCU_MISC_BASE + MCU_MISC_MCU_E907_RTC_OFFSET;
|
||||
break;
|
||||
}
|
||||
|
||||
/* disable rtc first */
|
||||
/* MCU RTC_EN is [31] */
|
||||
/* DSP RTC_EN is [31] */
|
||||
/* LP RTC_EN is [31] */
|
||||
tmpVal = BL_RD_WORD(address);
|
||||
tmpVal = BL_CLR_REG_BIT(tmpVal, MCU_MISC_REG_MCU_RTC_EN);
|
||||
BL_WR_WORD(address, tmpVal);
|
||||
|
||||
/* set div */
|
||||
/* MCU RTC_DIV is [9:0] */
|
||||
/* DSP RTC_DIV is [9:0] */
|
||||
/* LP RTC_DIV is [9:0] */
|
||||
tmpVal = BL_RD_WORD(address);
|
||||
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, MCU_MISC_REG_MCU_RTC_DIV, div);
|
||||
BL_WR_WORD(address, tmpVal);
|
||||
|
||||
/* enable or not */
|
||||
/* MCU RTC_EN is [31] */
|
||||
/* DSP RTC_EN is [31] */
|
||||
/* LP RTC_EN is [31] */
|
||||
tmpVal = BL_RD_WORD(address);
|
||||
if (enable) {
|
||||
tmpVal = BL_SET_REG_BIT(tmpVal, MCU_MISC_REG_MCU_RTC_EN);
|
||||
} else {
|
||||
tmpVal = BL_CLR_REG_BIT(tmpVal, MCU_MISC_REG_MCU_RTC_EN);
|
||||
}
|
||||
BL_WR_WORD(address, tmpVal);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void bl_mtimer_c906_clock_init(void)
|
||||
{
|
||||
uint32_t clockVal = 0;
|
||||
clockVal = bl_system_core_clock_get(GLB_CORE_ID_D0);
|
||||
|
||||
/* Set MTimer clock source 10M */
|
||||
bl_cpu_set_core_mtimer_clk(GLB_CORE_ID_D0, 1, (clockVal / 1000 / 1000 / 10) - 1);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user