add initial code

Signed-off-by: Andy Liu <jie.liu@telink-semi.com>
This commit is contained in:
Andy Liu
2022-05-21 23:09:19 +08:00
parent 21b05b0b62
commit c104a54ff3
18 changed files with 606 additions and 0 deletions
Executable
+27
View File
@@ -0,0 +1,27 @@
# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if (ohos_kernel_type == "liteos_m") {
import("//kernel/liteos_m/liteos.gni")
module_name = get_path_info(rebase_path("."), "name")
module_group(module_name) {
modules = [
"b91_devkit",
"drivers",
"hcs",
]
}
}
+17
View File
@@ -0,0 +1,17 @@
# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
orsource "*/Kconfig.liteos_m.board"
+16
View File
@@ -0,0 +1,16 @@
# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
orsource "*/Kconfig.liteos_m.defconfig.board"
+22
View File
@@ -0,0 +1,22 @@
# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if (ohos_kernel_type == "liteos_m") {
import("//kernel/liteos_m/liteos.gni")
module_name = get_path_info(rebase_path("."), "name")
module_group(module_name) {
modules = [ "liteos_m" ]
}
}
+18
View File
@@ -0,0 +1,18 @@
# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
config BOARD_B91_DEVKIT
bool "Select Board B91 Devkit"
depends on SOC_B91
+21
View File
@@ -0,0 +1,21 @@
# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if BOARD_B91_DEVKIT
config BOARD
string
default "b91_devkit"
endif # BOARD_B91_DEVKIT
+18
View File
@@ -0,0 +1,18 @@
# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
LOSCFG_BOARD_B91_DEVKIT=y
LOSCFG_SOC_SERIES_B91=y
LOSCFG_SOC_B91=y
+20
View File
@@ -0,0 +1,20 @@
# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//kernel/liteos_m/liteos.gni")
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
}
+69
View File
@@ -0,0 +1,69 @@
# Kernel type, e.g. "linux", "liteos_a", "liteos_m".
kernel_type = "liteos_m"
# Kernel version.
kernel_version = "3.0.0"
# Board CPU type, e.g. "cortex-a7", "riscv32".
board_cpu = ""
# Board arch, e.g. "armv7-a", "rv32imac".
board_arch = "rv32imafc"
# Toolchain name used for system compiling.
# E.g. gcc-arm-none-eabi, arm-linux-harmonyeabi-gcc, ohos-clang, riscv32-unknown-elf.
# Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toochain.
board_toolchain = "riscv32-elf"
use_board_toolchain = true
# The toolchain path instatlled, it's not mandatory if you have added toolchian path to your ~/.bashrc.
board_toolchain_path = getenv("TELINK_RISCV_TOOLCHAIN")
# Compiler prefix.
board_toolchain_prefix = "riscv32-elf-"
# Compiler type, "gcc" or "clang".
board_toolchain_type = "gcc"
# Board related common compile flags.
board_cflags = [
"-mcmodel=medium",
"-mcpu=d25f",
"-mext-dsp",
"-mabi=ilp32f",
"-ffunction-sections",
"-fdata-sections",
"-std=c99",
]
board_asmflags = [
"-mcmodel=medium",
"-mcpu=d25f",
"-mext-dsp",
"-mabi=ilp32f",
"-fdata-sections",
]
board_cxx_flags = board_cflags
board_ld_flags = [
"-nostartfiles",
"-fuse-ld=bfd",
"-specs=nosys.specs",
]
# Board related headfiles search path.
board_include_dirs = [
rebase_path("include"),
rebase_path("liteos_common_include"),
]
# Board adapter dir for OHOS components.
board_adapter_dir = "//device/soc/telink/b91/adapter"
# Sysroot path.
board_configed_sysroot = ""
# Board storage type, it used for file system generation.
storage_type = ""
+31
View File
@@ -0,0 +1,31 @@
/******************************************************************************
* Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************/
#pragma once
#define MASTER_MAX_NUM 4
#define SLAVE_MAX_NUM 4
///////////////////////// Feature Configuration////////////////////////////////////////////////
#define FLASH_SIZE_CONFIG FLASH_SIZE_2M //very important, user need confirm !!!
///////////////////////// DEBUG Configuration ////////////////////////////////////////////////
#define UART_PRINT_DEBUG_ENABLE 1 //printf
#include "../common/default_config.h"
+39
View File
@@ -0,0 +1,39 @@
/******************************************************************************
* Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************/
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H
#include <B91/gpio.h>
#define LED_BLUE_HDF 0
#define LED_GREEN_HDF 1
#define LED_WHITE_HDF 2
#define LED_RED_HDF 3
#define SW1_2_GPIO GPIO_PC2
#define SW3_4_GPIO GPIO_PC0
#define SW1_3_GPIO GPIO_PC3
#define SW2_4_GPIO GPIO_PC1
#define SW1_2_GPIO_HDF 6
#define SW3_4_GPIO_HDF 4
#define SW1_3_GPIO_HDF 7
#define SW2_4_GPIO_HDF 5
#endif // BOARD_CONFIG_H
+40
View File
@@ -0,0 +1,40 @@
/******************************************************************************
* Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************/
#ifndef _MEMMAP_CONFIG_H
#define _MEMMAP_CONFIG_H
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
extern UINT8 __los_heap_addr_start__[];
extern UINT8 __los_heap_addr_end__[];
extern UINT8 __los_heap_size__[];
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _MEMMAP_CONFIG_H */
+120
View File
@@ -0,0 +1,120 @@
/******************************************************************************
* Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************/
/**@defgroup los_config System configuration items
* @ingroup kernel
*/
#ifndef _TARGET_CONFIG_H
#define _TARGET_CONFIG_H
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#include "soc.h"
#include "memmap_config.h"
/*=============================================================================
System clock module configuration
=============================================================================*/
#define OS_SYS_CLOCK (32000)
#define LOSCFG_BASE_CORE_TICK_PER_SECOND (1000UL)
#define LOSCFG_BASE_CORE_TICK_HW_TIME 0
#define LOSCFG_BASE_CORE_TICK_WTIMER 1
/*=============================================================================
Hardware interrupt module configuration
=============================================================================*/
#define LOSCFG_PLATFORM_HWI 1
#define LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT 0
#define LOSCFG_PLATFORM_HWI_LIMIT OS_HWI_MAX_NUM
#define LOSCFG_PLATFORM_HWI_WITH_ARG 1
/*=============================================================================
Task module configuration
=============================================================================*/
#define LOSCFG_BASE_CORE_TSK_LIMIT 12
#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE (2048)
#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE (4096)
#define LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE (1024)
#define LOSCFG_BASE_CORE_TIMESLICE 1
#define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT 100000
#define LOSCFG_BASE_CORE_TICK_RESPONSE_MAX 0xFFFFFFFFFFFFFFF
/*=============================================================================
Semaphore module configuration
=============================================================================*/
#define LOSCFG_BASE_IPC_SEM 1
#define LOSCFG_BASE_IPC_SEM_LIMIT 48
/*=============================================================================
Mutex module configuration
=============================================================================*/
#define LOSCFG_BASE_IPC_MUX 1
#define LOSCFG_BASE_IPC_MUX_LIMIT 32
/*=============================================================================
Queue module configuration
=============================================================================*/
#define LOSCFG_BASE_IPC_QUEUE 1
#define LOSCFG_BASE_IPC_QUEUE_LIMIT 16
/*=============================================================================
Software timer module configuration
=============================================================================*/
#define LOSCFG_BASE_CORE_SWTMR 1
#define LOSCFG_BASE_CORE_SWTMR_ALIGN 1
#define LOSCFG_BASE_CORE_SWTMR_LIMIT 6
/*=============================================================================
Memory module configuration
=============================================================================*/
#define LOSCFG_SYS_HEAP_SIZE OS_SYS_MEM_SIZE
#define LOSCFG_SYS_EXTERNAL_HEAP 1
#define OS_SYS_MEM_SIZE ((UINT32)(__los_heap_size__))
#define LOSCFG_SYS_HEAP_ADDR (VOID *)(__los_heap_addr_start__)
#define LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK 0
#define LOSCFG_BASE_MEM_NODE_SIZE_CHECK 1
#define LOSCFG_MEM_MUL_POOL 0
#define OS_SYS_MEM_NUM 20
#define LOSCFG_KERNEL_MEM_SLAB 0
/*=============================================================================
Exception module configuration
=============================================================================*/
#define LOSCFG_PLATFORM_EXC 0
/* =============================================================================
printf module configuration
============================================================================= */
#define LOSCFG_KERNEL_PRINTF 1
/* =============================================================================
enable backtrace
============================================================================= */
#define LOSCFG_BACKTRACE_TYPE 0
#define LOSCFG_BACKTRACE_DEPTH 15
#define LOSCFG_FAMILY_B91 1
#define LOSCFG_TELINK_B91_CPU_FREQ 48000000
#define LOSCFG_POWER_MODE_LDO_1P4_LDO_1P8 1
#define LOSCFG_VBAT_TYPE_MAX_VALUE_GREATER_THAN_3V6 1
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _TARGET_CONFIG_H */
+43
View File
@@ -0,0 +1,43 @@
/******************************************************************************
* Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************/
#ifndef _RISCV_HAL_H
#define _RISCV_HAL_H
#include "los_compiler.h"
#include "los_context.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
extern VOID HalIrqDisable(UINT32 vector);
extern VOID HalIrqEnable(UINT32 vector);
extern VOID HalSetLocalInterPri(UINT32 vector, UINT16 prior);
//
// extern VOID HalClockInit(OS_TICK_HANDLER handler, UINT32 period);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif /* _RISCV_HAL_H */
+39
View File
@@ -0,0 +1,39 @@
/******************************************************************************
* Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************/
#ifndef _SOC_H
#define _SOC_H
#include "soc_common.h"
/*
* Get the response interrupt number via mcause.
* id = mcause & MCAUSE_INT_ID_MASK
*/
#define MCAUSE_INT_ID_MASK 0x7FFFFFF
#define MTIMERCMP 0xE6000008
#define MTIMER 0xE6000000
#define RISCV_SYS_MAX_IRQ 11
/*
* Because of strange implementation of los_interrupt.c in kernel sum of
* (RISCV_SYS_MAX_IRQ + RISCV_PLIC_VECTOR_CNT) should be at least 25
*/
#define RISCV_PLIC_VECTOR_CNT 14
#endif
+21
View File
@@ -0,0 +1,21 @@
# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if (ohos_kernel_type == "liteos_m") {
import("//kernel/liteos_m/liteos.gni")
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
}
}
Executable
+26
View File
@@ -0,0 +1,26 @@
# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if (ohos_kernel_type == "liteos_m") {
import("//drivers/adapter/khdf/liteos_m/hdf.gni")
module_name = get_path_info(rebase_path("."), "name")
hdf_driver(module_name) {
hcs_sources = [ "b91_devkit.hcs" ]
visibility += [
"$device_path",
".",
]
}
}
+19
View File
@@ -0,0 +1,19 @@
/******************************************************************************
* Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************/
#include "../../../soc/telink/b91/hcs/hdf.hcs"