diff options
| author | flyingcys <[email protected]> | 2024-01-28 13:39:39 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-01-28 13:39:39 +0800 |
| commit | 3f41bd95d10bf02de049290434af587c5586fde5 (patch) | |
| tree | bd9a11aaccd590d2c9b804ec8827818bbdddc1e0 /bsp | |
| parent | b3da34b78435857e7a71d8525e38ca0074ab90a8 (diff) | |
add libcpu/risc-v/rv64 (#8511)
Diffstat (limited to 'bsp')
25 files changed, 790 insertions, 107 deletions
diff --git a/bsp/juicevm/.config b/bsp/juicevm/.config index 3783b3ef8d..ba412a120e 100755..100644 --- a/bsp/juicevm/.config +++ b/bsp/juicevm/.config @@ -9,8 +9,10 @@ CONFIG_RT_NAME_MAX=8 # CONFIG_RT_USING_ARCH_DATA_TYPE is not set # CONFIG_RT_USING_SMART is not set +# CONFIG_RT_USING_NANO is not set # CONFIG_RT_USING_AMP is not set # CONFIG_RT_USING_SMP is not set +CONFIG_RT_CPUS_NR=1 CONFIG_RT_ALIGN_SIZE=8 # CONFIG_RT_THREAD_PRIORITY_8 is not set CONFIG_RT_THREAD_PRIORITY_32=y @@ -20,6 +22,7 @@ CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_USING_HOOK=y CONFIG_RT_HOOK_USING_FUNC_PTR=y +# CONFIG_RT_USING_HOOKLIST is not set CONFIG_RT_USING_IDLE_HOOK=y CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 @@ -35,7 +38,7 @@ CONFIG_RT_KPRINTF_USING_LONGLONG=y CONFIG_RT_USING_DEBUG=y CONFIG_RT_DEBUGING_COLOR=y CONFIG_RT_DEBUGING_CONTEXT=y -# CONFIG_RT_DEBUGING_INIT is not set +# CONFIG_RT_DEBUGING_AUTO_INIT is not set # # Inter-Thread communication @@ -63,19 +66,16 @@ CONFIG_RT_USING_SMALL_MEM_AS_HEAP=y # CONFIG_RT_USING_MEMTRACE is not set # CONFIG_RT_USING_HEAP_ISR is not set CONFIG_RT_USING_HEAP=y - -# -# Kernel Device Object -# CONFIG_RT_USING_DEVICE=y # CONFIG_RT_USING_DEVICE_OPS is not set -# CONFIG_RT_USING_DM is not set # CONFIG_RT_USING_INTERRUPT_INFO is not set +# CONFIG_RT_USING_THREDSAFE_PRINTF is not set CONFIG_RT_USING_CONSOLE=y CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLE_DEVICE_NAME="uart0" -CONFIG_RT_VER_NUM=0x50002 +CONFIG_RT_VER_NUM=0x50100 # CONFIG_RT_USING_STDC_ATOMIC is not set +CONFIG_RT_BACKTRACE_LEVEL_MAX_NR=32 CONFIG_ARCH_CPU_64BIT=y # CONFIG_RT_USING_CACHE is not set # CONFIG_RT_USING_HW_ATOMIC is not set @@ -134,6 +134,7 @@ CONFIG_DFS_FILESYSTEM_TYPES_MAX=4 # # Device Drivers # +# CONFIG_RT_USING_DM is not set CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_UNAMED_PIPE_NUMBER=64 # CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set @@ -157,7 +158,6 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64 # CONFIG_RT_USING_MTD_NOR is not set # CONFIG_RT_USING_MTD_NAND is not set # CONFIG_RT_USING_PM is not set -# CONFIG_RT_USING_FDT is not set CONFIG_RT_USING_RTC=y # CONFIG_RT_USING_ALARM is not set # CONFIG_RT_USING_SOFT_RTC is not set @@ -241,6 +241,12 @@ CONFIG_RT_USING_POSIX_FS=y # CONFIG_RT_USING_AT is not set # +# Memory protection +# +# CONFIG_RT_USING_MEM_PROTECTION is not set +# CONFIG_RT_USING_HW_STACK_GUARD is not set + +# # Utilities # # CONFIG_RT_USING_RYM is not set @@ -317,6 +323,21 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # # CONFIG_PKG_USING_WLAN_WICED is not set # CONFIG_PKG_USING_RW007 is not set + +# +# CYW43012 WiFi +# +# CONFIG_PKG_USING_WLAN_CYW43012 is not set + +# +# BL808 WiFi +# +# CONFIG_PKG_USING_WLAN_BL808 is not set + +# +# CYW43439 WiFi +# +# CONFIG_PKG_USING_WLAN_CYW43439 is not set # CONFIG_PKG_USING_COAP is not set # CONFIG_PKG_USING_NOPOLL is not set # CONFIG_PKG_USING_NETUTILS is not set @@ -338,7 +359,6 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_JIOT-C-SDK is not set # CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set # CONFIG_PKG_USING_JOYLINK is not set -# CONFIG_PKG_USING_EZ_IOT_OS is not set # CONFIG_PKG_USING_IOTSHARP_SDK is not set # CONFIG_PKG_USING_NIMBLE is not set # CONFIG_PKG_USING_LLSYNC_SDK_ADAPTER is not set @@ -359,6 +379,7 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_NMEALIB is not set # CONFIG_PKG_USING_PDULIB is not set # CONFIG_PKG_USING_BTSTACK is not set +# CONFIG_PKG_USING_BT_CYW43012 is not set # CONFIG_PKG_USING_LORAWAN_ED_STACK is not set # CONFIG_PKG_USING_WAYZ_IOTKIT is not set # CONFIG_PKG_USING_MAVLINK is not set @@ -378,6 +399,8 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_ZFTP is not set # CONFIG_PKG_USING_WOL is not set # CONFIG_PKG_USING_ZEPHYR_POLLING is not set +# CONFIG_PKG_USING_MATTER_ADAPTATION_LAYER is not set +# CONFIG_PKG_USING_LHC_MODBUS is not set # # security packages @@ -486,7 +509,6 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # LVGL: powerful and easy-to-use embedded GUI library # # CONFIG_PKG_USING_LVGL is not set -# CONFIG_PKG_USING_LITTLEVGL2RTT is not set # CONFIG_PKG_USING_LV_MUSIC_DEMO is not set # CONFIG_PKG_USING_GUI_GUIDER_DEMO is not set @@ -561,6 +583,7 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # CONFIG_PKG_USING_HASH_MATCH is not set # CONFIG_PKG_USING_ARMV7M_DWT_TOOL is not set # CONFIG_PKG_USING_VOFA_PLUS is not set +# CONFIG_PKG_USING_ZDEBUG is not set # # system packages @@ -597,6 +620,8 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # CONFIG_PKG_USING_UC_COMMON is not set # CONFIG_PKG_USING_UC_MODBUS is not set # CONFIG_PKG_USING_FREERTOS_WRAPPER is not set +# CONFIG_PKG_USING_LITEOS_SDK is not set +# CONFIG_PKG_USING_TZ_DATABASE is not set # CONFIG_PKG_USING_CAIRO is not set # CONFIG_PKG_USING_PIXMAN is not set # CONFIG_PKG_USING_PARTITION is not set @@ -620,6 +645,7 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # CONFIG_PKG_USING_QBOOT is not set # CONFIG_PKG_USING_PPOOL is not set # CONFIG_PKG_USING_OPENAMP is not set +# CONFIG_PKG_USING_RPMSG_LITE is not set # CONFIG_PKG_USING_LPM is not set # CONFIG_PKG_USING_TLSF is not set # CONFIG_PKG_USING_EVENT_RECORDER is not set @@ -633,6 +659,11 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # CONFIG_PKG_USING_AGILE_UPGRADE is not set # CONFIG_PKG_USING_FLASH_BLOB is not set # CONFIG_PKG_USING_MLIBC is not set +# CONFIG_PKG_USING_TASK_MSG_BUS is not set +# CONFIG_PKG_USING_SFDB is not set +# CONFIG_PKG_USING_RTP is not set +# CONFIG_PKG_USING_REB is not set +# CONFIG_PKG_USING_R_RHEALSTONE is not set # # peripheral libraries and drivers @@ -697,6 +728,7 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # CONFIG_PKG_USING_BALANCE is not set # CONFIG_PKG_USING_SHT2X is not set # CONFIG_PKG_USING_SHT3X is not set +# CONFIG_PKG_USING_SHT4X is not set # CONFIG_PKG_USING_AD7746 is not set # CONFIG_PKG_USING_ADT74XX is not set # CONFIG_PKG_USING_MAX17048 is not set @@ -798,6 +830,10 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # CONFIG_PKG_USING_FINGERPRINT is not set # CONFIG_PKG_USING_BT_ECB02C is not set # CONFIG_PKG_USING_UAT is not set +# CONFIG_PKG_USING_ST7789 is not set +# CONFIG_PKG_USING_VS1003 is not set +# CONFIG_PKG_USING_X9555 is not set +# CONFIG_PKG_USING_SYSTEM_RUN_LED is not set # CONFIG_PKG_USING_SPI_TOOLS is not set # @@ -812,6 +848,7 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # CONFIG_PKG_USING_ULAPACK is not set # CONFIG_PKG_USING_QUEST is not set # CONFIG_PKG_USING_NAXOS is not set +# CONFIG_PKG_USING_R_TINYMAIX is not set # # Signal Processing and Control Algorithm Packages @@ -858,6 +895,7 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # CONFIG_PKG_USING_MINILZO is not set # CONFIG_PKG_USING_QUICKLZ is not set # CONFIG_PKG_USING_LZMA is not set +# CONFIG_PKG_USING_RALARAM is not set # CONFIG_PKG_USING_MULTIBUTTON is not set # CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set # CONFIG_PKG_USING_CANFESTIVAL is not set @@ -1042,6 +1080,7 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_GFX_LIBRARY is not set # CONFIG_PKG_USING_ARDUINO_U8G2 is not set +# CONFIG_PKG_USING_ARDUINO_TFT_ESPI is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ST7735 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SSD1306 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ILI9341 is not set @@ -1050,6 +1089,7 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # # Timing # +# CONFIG_PKG_USING_ARDUINO_RTCLIB is not set # CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set # CONFIG_PKG_USING_ARDUINO_TICKER is not set # CONFIG_PKG_USING_ARDUINO_TASKSCHEDULER is not set @@ -1086,7 +1126,6 @@ CONFIG_PKG_MICROPYTHON_VER_NUM=0x99999 # # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MFRC630 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI5351 is not set -# CONFIG_PKG_USING_ARDUINO_RTCLIB is not set # # Signal IO diff --git a/bsp/juicevm/.gitignore b/bsp/juicevm/.gitignore new file mode 100644 index 0000000000..7bdbb1b36c --- /dev/null +++ b/bsp/juicevm/.gitignore @@ -0,0 +1 @@ +*.asm
\ No newline at end of file diff --git a/bsp/juicevm/board/SConscript b/bsp/juicevm/board/SConscript index 687045e84c..db5cf7436b 100755 --- a/bsp/juicevm/board/SConscript +++ b/bsp/juicevm/board/SConscript @@ -4,7 +4,9 @@ from building import * cwd = GetCurrentDir() src = Split(''' -board.c + board.c + interrupt.c + startup_gcc.S ''') CPPPATH = [cwd] diff --git a/bsp/juicevm/board/interrupt.c b/bsp/juicevm/board/interrupt.c new file mode 100755 index 0000000000..24b8be7f0c --- /dev/null +++ b/bsp/juicevm/board/interrupt.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021/04/24 Juice The first version + */ + +#include <rthw.h> + +#include <board.h> + +typedef void (*irq_handler_t)(void); +extern const irq_handler_t isrTable[]; + +uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc, uintptr_t *sp) +{ + uint32_t intNum; + if (mcause & 0x80000000) /* For external interrupt. */ + { + } + else + { + intNum = mcause & 0x1FUL; + /* Now call the real irq handler for intNum */ + if (intNum <= 24) + { + if (isrTable[intNum])isrTable[intNum](); + } + } +} diff --git a/bsp/juicevm/board/startup_gcc.S b/bsp/juicevm/board/startup_gcc.S new file mode 100755 index 0000000000..1a41c731fb --- /dev/null +++ b/bsp/juicevm/board/startup_gcc.S @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021/04/24 Juice The first version + */ + + +.global _start +.section ".start", "ax" +_start: +.align 3 +csrw mideleg, 0 +csrw medeleg, 0 +csrw mie, 0 +csrw mip, 0 +la t0, trap_entry +csrw mtvec, t0 + +li x1, 0 +li x2, 0 +li x3, 0 +li x4, 0 +li x5, 0 +li x6, 0 +li x7, 0 +li x8, 0 +li x9, 0 +li x10, 0 +li x11, 0 +li x12, 0 +li x13, 0 +li x14, 0 +li x15, 0 +li x16, 0 +li x17, 0 +li x18, 0 +li x19, 0 +li x20, 0 +li x21, 0 +li x22, 0 +li x23, 0 +li x24, 0 +li x25, 0 +li x26, 0 +li x27, 0 +li x28, 0 +li x29, 0 +li x30, 0 +li x31, 0 + +/* set to initial state of FPU and disable interrupt */ +li t0, 0 +csrs mstatus, t0 + +.option push +.option norelax +la gp, __global_pointer$ +la sp, __stack +call entry +call exit +.option pop diff --git a/bsp/juicevm/link.lds b/bsp/juicevm/link.lds index 74d01910b0..224bb57fa4 100755 --- a/bsp/juicevm/link.lds +++ b/bsp/juicevm/link.lds @@ -103,6 +103,7 @@ SECTIONS . += __STACKSIZE__; __stack = .; + __rt_rvstack = .; } > SRAM .sbss : diff --git a/bsp/juicevm/link_stacksize.lds b/bsp/juicevm/link_stacksize.lds index 28438c7da1..1dd893422c 100755 --- a/bsp/juicevm/link_stacksize.lds +++ b/bsp/juicevm/link_stacksize.lds @@ -1 +1 @@ -__STACKSIZE__ = 4096; +__STACKSIZE__ = 4096;
\ No newline at end of file diff --git a/bsp/juicevm/rtconfig.h b/bsp/juicevm/rtconfig.h index f58a93990f..fe354f4a32 100755 --- a/bsp/juicevm/rtconfig.h +++ b/bsp/juicevm/rtconfig.h @@ -7,6 +7,7 @@ /* RT-Thread Kernel */ #define RT_NAME_MAX 8 +#define RT_CPUS_NR 1 #define RT_ALIGN_SIZE 8 #define RT_THREAD_PRIORITY_32 #define RT_THREAD_PRIORITY_MAX 32 @@ -39,14 +40,12 @@ #define RT_USING_SMALL_MEM #define RT_USING_SMALL_MEM_AS_HEAP #define RT_USING_HEAP - -/* Kernel Device Object */ - #define RT_USING_DEVICE #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "uart0" -#define RT_VER_NUM 0x50002 +#define RT_VER_NUM 0x50100 +#define RT_BACKTRACE_LEVEL_MAX_NR 32 #define ARCH_CPU_64BIT #define ARCH_RISCV #define ARCH_RISCV64 @@ -118,6 +117,9 @@ /* Network */ +/* Memory protection */ + + /* Utilities */ #define RT_USING_ULOG @@ -151,6 +153,15 @@ /* Wiced WiFi */ +/* CYW43012 WiFi */ + + +/* BL808 WiFi */ + + +/* CYW43439 WiFi */ + + /* IoT Cloud */ diff --git a/bsp/juicevm/rtconfig.py b/bsp/juicevm/rtconfig.py index 3091df663f..f2bae8257c 100755 --- a/bsp/juicevm/rtconfig.py +++ b/bsp/juicevm/rtconfig.py @@ -2,7 +2,7 @@ import os # toolchains options ARCH ='risc-v' -CPU ='juicevm' +CPU ='rv64' CROSS_TOOL ='gcc' if os.getenv('RTT_ROOT'): diff --git a/bsp/k210/.config b/bsp/k210/.config index 8f293d7cf3..44eca66d5e 100644 --- a/bsp/k210/.config +++ b/bsp/k210/.config @@ -9,6 +9,7 @@ CONFIG_RT_NAME_MAX=8 # CONFIG_RT_USING_ARCH_DATA_TYPE is not set # CONFIG_RT_USING_SMART is not set +# CONFIG_RT_USING_NANO is not set # CONFIG_RT_USING_AMP is not set CONFIG_RT_USING_SMP=y CONFIG_RT_CPUS_NR=2 @@ -21,6 +22,7 @@ CONFIG_RT_TICK_PER_SECOND=1000 CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_USING_HOOK=y CONFIG_RT_HOOK_USING_FUNC_PTR=y +# CONFIG_RT_USING_HOOKLIST is not set CONFIG_RT_USING_IDLE_HOOK=y CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=4096 @@ -37,7 +39,8 @@ CONFIG_RT_KPRINTF_USING_LONGLONG=y CONFIG_RT_USING_DEBUG=y CONFIG_RT_DEBUGING_COLOR=y CONFIG_RT_DEBUGING_CONTEXT=y -# CONFIG_RT_DEBUGING_INIT is not set +# CONFIG_RT_DEBUGING_AUTO_INIT is not set +# CONFIG_RT_DEBUGING_SPINLOCK is not set # # Inter-Thread communication @@ -67,19 +70,16 @@ CONFIG_RT_USING_SLAB_AS_HEAP=y # CONFIG_RT_USING_MEMTRACE is not set # CONFIG_RT_USING_HEAP_ISR is not set CONFIG_RT_USING_HEAP=y - -# -# Kernel Device Object -# CONFIG_RT_USING_DEVICE=y # CONFIG_RT_USING_DEVICE_OPS is not set -# CONFIG_RT_USING_DM is not set # CONFIG_RT_USING_INTERRUPT_INFO is not set +# CONFIG_RT_USING_THREDSAFE_PRINTF is not set CONFIG_RT_USING_CONSOLE=y CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLE_DEVICE_NAME="uarths" -CONFIG_RT_VER_NUM=0x50002 +CONFIG_RT_VER_NUM=0x50100 # CONFIG_RT_USING_STDC_ATOMIC is not set +CONFIG_RT_BACKTRACE_LEVEL_MAX_NR=32 CONFIG_ARCH_CPU_64BIT=y # CONFIG_RT_USING_CACHE is not set CONFIG_RT_USING_HW_ATOMIC=y @@ -151,6 +151,7 @@ CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096 # CONFIG_RT_DFS_ELM_USE_ERASE is not set CONFIG_RT_DFS_ELM_REENTRANT=y CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 +# CONFIG_RT_DFS_ELM_USE_EXFAT is not set CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DFS_ROMFS is not set # CONFIG_RT_USING_DFS_CROMFS is not set @@ -162,6 +163,7 @@ CONFIG_RT_USING_DFS_DEVFS=y # # Device Drivers # +# CONFIG_RT_USING_DM is not set CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_UNAMED_PIPE_NUMBER=64 # CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set @@ -185,7 +187,6 @@ CONFIG_RT_USING_PIN=y # CONFIG_RT_USING_MTD_NOR is not set # CONFIG_RT_USING_MTD_NAND is not set # CONFIG_RT_USING_PM is not set -# CONFIG_RT_USING_FDT is not set # CONFIG_RT_USING_RTC is not set # CONFIG_RT_USING_SDIO is not set CONFIG_RT_USING_SPI=y @@ -271,6 +272,12 @@ CONFIG_RT_USING_CPLUSPLUS=y # CONFIG_RT_USING_AT is not set # +# Memory protection +# +# CONFIG_RT_USING_MEM_PROTECTION is not set +# CONFIG_RT_USING_HW_STACK_GUARD is not set + +# # Utilities # # CONFIG_RT_USING_RYM is not set @@ -347,6 +354,21 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # # CONFIG_PKG_USING_WLAN_WICED is not set # CONFIG_PKG_USING_RW007 is not set + +# +# CYW43012 WiFi +# +# CONFIG_PKG_USING_WLAN_CYW43012 is not set + +# +# BL808 WiFi +# +# CONFIG_PKG_USING_WLAN_BL808 is not set + +# +# CYW43439 WiFi +# +# CONFIG_PKG_USING_WLAN_CYW43439 is not set # CONFIG_PKG_USING_COAP is not set # CONFIG_PKG_USING_NOPOLL is not set # CONFIG_PKG_USING_NETUTILS is not set @@ -368,7 +390,6 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_JIOT-C-SDK is not set # CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set # CONFIG_PKG_USING_JOYLINK is not set -# CONFIG_PKG_USING_EZ_IOT_OS is not set # CONFIG_PKG_USING_IOTSHARP_SDK is not set # CONFIG_PKG_USING_NIMBLE is not set # CONFIG_PKG_USING_LLSYNC_SDK_ADAPTER is not set @@ -389,6 +410,7 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_NMEALIB is not set # CONFIG_PKG_USING_PDULIB is not set # CONFIG_PKG_USING_BTSTACK is not set +# CONFIG_PKG_USING_BT_CYW43012 is not set # CONFIG_PKG_USING_LORAWAN_ED_STACK is not set # CONFIG_PKG_USING_WAYZ_IOTKIT is not set # CONFIG_PKG_USING_MAVLINK is not set @@ -408,6 +430,8 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_ZFTP is not set # CONFIG_PKG_USING_WOL is not set # CONFIG_PKG_USING_ZEPHYR_POLLING is not set +# CONFIG_PKG_USING_MATTER_ADAPTATION_LAYER is not set +# CONFIG_PKG_USING_LHC_MODBUS is not set # # security packages @@ -454,7 +478,6 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # LVGL: powerful and easy-to-use embedded GUI library # # CONFIG_PKG_USING_LVGL is not set -# CONFIG_PKG_USING_LITTLEVGL2RTT is not set # CONFIG_PKG_USING_LV_MUSIC_DEMO is not set # CONFIG_PKG_USING_GUI_GUIDER_DEMO is not set @@ -529,6 +552,7 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_HASH_MATCH is not set # CONFIG_PKG_USING_ARMV7M_DWT_TOOL is not set # CONFIG_PKG_USING_VOFA_PLUS is not set +# CONFIG_PKG_USING_ZDEBUG is not set # # system packages @@ -565,6 +589,8 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_UC_COMMON is not set # CONFIG_PKG_USING_UC_MODBUS is not set # CONFIG_PKG_USING_FREERTOS_WRAPPER is not set +# CONFIG_PKG_USING_LITEOS_SDK is not set +# CONFIG_PKG_USING_TZ_DATABASE is not set # CONFIG_PKG_USING_CAIRO is not set # CONFIG_PKG_USING_PIXMAN is not set # CONFIG_PKG_USING_PARTITION is not set @@ -588,6 +614,7 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_QBOOT is not set # CONFIG_PKG_USING_PPOOL is not set # CONFIG_PKG_USING_OPENAMP is not set +# CONFIG_PKG_USING_RPMSG_LITE is not set # CONFIG_PKG_USING_LPM is not set # CONFIG_PKG_USING_TLSF is not set # CONFIG_PKG_USING_EVENT_RECORDER is not set @@ -601,6 +628,11 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_AGILE_UPGRADE is not set # CONFIG_PKG_USING_FLASH_BLOB is not set # CONFIG_PKG_USING_MLIBC is not set +# CONFIG_PKG_USING_TASK_MSG_BUS is not set +# CONFIG_PKG_USING_SFDB is not set +# CONFIG_PKG_USING_RTP is not set +# CONFIG_PKG_USING_REB is not set +# CONFIG_PKG_USING_R_RHEALSTONE is not set # # peripheral libraries and drivers @@ -665,6 +697,7 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y # CONFIG_PKG_USING_BALANCE is not set # CONFIG_PKG_USING_SHT2X is not set # CONFIG_PKG_USING_SHT3X is not set +# CONFIG_PKG_USING_SHT4X is not set # CONFIG_PKG_USING_AD7746 is not set # CONFIG_PKG_USING_ADT74XX is not set # CONFIG_PKG_USING_MAX17048 is not set @@ -769,6 +802,10 @@ CONFIG_PKG_K210_SDK_VER="latest" # CONFIG_PKG_USING_FINGERPRINT is not set # CONFIG_PKG_USING_BT_ECB02C is not set # CONFIG_PKG_USING_UAT is not set +# CONFIG_PKG_USING_ST7789 is not set +# CONFIG_PKG_USING_VS1003 is not set +# CONFIG_PKG_USING_X9555 is not set +# CONFIG_PKG_USING_SYSTEM_RUN_LED is not set # CONFIG_PKG_USING_SPI_TOOLS is not set # @@ -783,6 +820,7 @@ CONFIG_PKG_K210_SDK_VER="latest" # CONFIG_PKG_USING_ULAPACK is not set # CONFIG_PKG_USING_QUEST is not set # CONFIG_PKG_USING_NAXOS is not set +# CONFIG_PKG_USING_R_TINYMAIX is not set # # Signal Processing and Control Algorithm Packages @@ -829,6 +867,7 @@ CONFIG_PKG_K210_SDK_VER="latest" # CONFIG_PKG_USING_MINILZO is not set # CONFIG_PKG_USING_QUICKLZ is not set # CONFIG_PKG_USING_LZMA is not set +# CONFIG_PKG_USING_RALARAM is not set # CONFIG_PKG_USING_MULTIBUTTON is not set # CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set # CONFIG_PKG_USING_CANFESTIVAL is not set @@ -1013,6 +1052,7 @@ CONFIG_PKG_K210_SDK_VER="latest" # # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_GFX_LIBRARY is not set # CONFIG_PKG_USING_ARDUINO_U8G2 is not set +# CONFIG_PKG_USING_ARDUINO_TFT_ESPI is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ST7735 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SSD1306 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ILI9341 is not set @@ -1021,6 +1061,7 @@ CONFIG_PKG_K210_SDK_VER="latest" # # Timing # +# CONFIG_PKG_USING_ARDUINO_RTCLIB is not set # CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set # CONFIG_PKG_USING_ARDUINO_TICKER is not set # CONFIG_PKG_USING_ARDUINO_TASKSCHEDULER is not set @@ -1057,7 +1098,6 @@ CONFIG_PKG_K210_SDK_VER="latest" # # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MFRC630 is not set # CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SI5351 is not set -# CONFIG_PKG_USING_ARDUINO_RTCLIB is not set # # Signal IO @@ -1091,30 +1131,7 @@ CONFIG_BSP_UART1_RXD_PIN=21 # CONFIG_BSP_USING_UART2 is not set # CONFIG_BSP_USING_UART3 is not set # CONFIG_BSP_USING_I2C1 is not set -CONFIG_BSP_USING_SPI1=y -# CONFIG_BSP_USING_SPI1_AS_QSPI is not set -CONFIG_BSP_SPI1_CLK_PIN=27 -CONFIG_BSP_SPI1_D0_PIN=28 -CONFIG_BSP_SPI1_D1_PIN=26 -CONFIG_BSP_SPI1_USING_SS0=y -CONFIG_BSP_SPI1_SS0_PIN=29 -# CONFIG_BSP_SPI1_USING_SS1 is not set -# CONFIG_BSP_SPI1_USING_SS2 is not set -# CONFIG_BSP_SPI1_USING_SS3 is not set -CONFIG_BSP_USING_LCD=y -CONFIG_BSP_LCD_CS_PIN=36 -CONFIG_BSP_LCD_WR_PIN=39 -CONFIG_BSP_LCD_DC_PIN=38 -CONFIG_BSP_LCD_RST_PIN=37 -CONFIG_BSP_LCD_BACKLIGHT_PIN=-1 -CONFIG_BSP_LCD_BACKLIGHT_ACTIVE_LOW=y -# CONFIG_BSP_LCD_BACKLIGHT_ACTIVE_HIGH is not set -CONFIG_BSP_LCD_CLK_FREQ=15000000 -# CONFIG_BSP_BOARD_KD233 is not set -CONFIG_BSP_BOARD_K210_OPENMV_TEST=y -# CONFIG_BSP_BOARD_K210_DRACO is not set -# CONFIG_BSP_BOARD_USER is not set -CONFIG_BSP_LCD_X_MAX=240 -CONFIG_BSP_LCD_Y_MAX=320 +# CONFIG_BSP_USING_SPI1 is not set +# CONFIG_BSP_USING_LCD is not set # CONFIG_BSP_USING_CAMERA is not set CONFIG___STACKSIZE__=4096 diff --git a/bsp/k210/board/SConscript b/bsp/k210/board/SConscript new file mode 100755 index 0000000000..fbeee8f9e1 --- /dev/null +++ b/bsp/k210/board/SConscript @@ -0,0 +1,9 @@ +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') + Glob('*.cpp') + Glob('*.S') +CPPPATH = [cwd] + +group = DefineGroup('board', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/k210/drivers/board.c b/bsp/k210/board/board.c index 861bde3488..861bde3488 100644..100755 --- a/bsp/k210/drivers/board.c +++ b/bsp/k210/board/board.c diff --git a/bsp/k210/drivers/board.h b/bsp/k210/board/board.h index 0464bad1f3..0464bad1f3 100644..100755 --- a/bsp/k210/drivers/board.h +++ b/bsp/k210/board/board.h diff --git a/bsp/k210/board/cpuport_smp.c b/bsp/k210/board/cpuport_smp.c new file mode 100755 index 0000000000..113df9b3e2 --- /dev/null +++ b/bsp/k210/board/cpuport_smp.c @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/12/23 Bernard The first version + * 2018/12/27 Jesven Add secondary cpu boot + */ + +#include <rthw.h> +#include <rtthread.h> +#include <stdint.h> + +#include "board.h" +#include <encoding.h> +#include <clint.h> +#include <atomic.h> + +#ifdef RT_USING_SMP + +int rt_hw_cpu_id(void) +{ + return read_csr(mhartid); +} + +void rt_hw_spin_lock_init(rt_hw_spinlock_t *lock) +{ + ((spinlock_t *)lock)->lock = 0; +} + +void rt_hw_spin_lock(rt_hw_spinlock_t *lock) +{ + spinlock_lock((spinlock_t *)lock); +} + +void rt_hw_spin_unlock(rt_hw_spinlock_t *lock) +{ + spinlock_unlock((spinlock_t *)lock); +} + +void rt_hw_ipi_send(int ipi_vector, unsigned int cpu_mask) +{ + int idx; + + for (idx = 0; idx < RT_CPUS_NR; idx ++) + { + if (cpu_mask & (1 << idx)) + { + clint_ipi_send(idx); + } + } +} + +extern rt_base_t secondary_boot_flag; +void rt_hw_secondary_cpu_up(void) +{ + mb(); + secondary_boot_flag = 0xa55a; +} + +extern void rt_hw_scondary_interrupt_init(void); +extern int rt_hw_tick_init(void); +extern int rt_hw_clint_ipi_enable(void); + +void secondary_cpu_c_start(void) +{ + rt_hw_spin_lock(&_cpus_lock); + + /* initialize interrupt controller */ + rt_hw_scondary_interrupt_init(); + + rt_hw_tick_init(); + + rt_hw_clint_ipi_enable(); + + rt_system_scheduler_start(); +} + +void rt_hw_secondary_cpu_idle_exec(void) +{ + asm volatile ("wfi"); +} +#endif /*RT_USING_SMP*/ diff --git a/bsp/k210/drivers/heap.c b/bsp/k210/board/heap.c index f1d6d2c27a..f1d6d2c27a 100644..100755 --- a/bsp/k210/drivers/heap.c +++ b/bsp/k210/board/heap.c diff --git a/bsp/k210/board/interrupt.c b/bsp/k210/board/interrupt.c new file mode 100755 index 0000000000..e4c9c53851 --- /dev/null +++ b/bsp/k210/board/interrupt.c @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/10/01 Bernard The first version + * 2018/12/27 Jesven Change irq enable/disable to cpu0 + */ + +#include <rtthread.h> + +#include "tick.h" + +#include <plic.h> +#include <clint.h> +#include <interrupt.h> + +#define CPU_NUM 2 +#define MAX_HANDLERS IRQN_MAX + +static struct rt_irq_desc irq_desc[MAX_HANDLERS]; + +static rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector, void *param) +{ + rt_kprintf("UN-handled interrupt %d occurred!!!\n", vector); + return RT_NULL; +} + +int rt_hw_clint_ipi_enable(void) +{ + /* Set the Machine-Software bit in MIE */ + set_csr(mie, MIP_MSIP); + return 0; +} + +int rt_hw_clint_ipi_disable(void) +{ + /* Clear the Machine-Software bit in MIE */ + clear_csr(mie, MIP_MSIP); + return 0; +} + +int rt_hw_plic_irq_enable(plic_irq_t irq_number) +{ + unsigned long core_id = 0; + + /* Check parameters */ + if (PLIC_NUM_SOURCES < irq_number || 0 > irq_number) + return -1; + /* Get current enable bit array by IRQ number */ + uint32_t current = plic->target_enables.target[core_id].enable[irq_number / 32]; + /* Set enable bit in enable bit array */ + current |= (uint32_t)1 << (irq_number % 32); + /* Write back the enable bit array */ + plic->target_enables.target[core_id].enable[irq_number / 32] = current; + return 0; +} + +int rt_hw_plic_irq_disable(plic_irq_t irq_number) +{ + unsigned long core_id = 0; + + /* Check parameters */ + if (PLIC_NUM_SOURCES < irq_number || 0 > irq_number) + return -1; + /* Get current enable bit array by IRQ number */ + uint32_t current = plic->target_enables.target[core_id].enable[irq_number / 32]; + /* Clear enable bit in enable bit array */ + current &= ~((uint32_t)1 << (irq_number % 32)); + /* Write back the enable bit array */ + plic->target_enables.target[core_id].enable[irq_number / 32] = current; + return 0; +} + +/** + * This function will initialize hardware interrupt + */ +void rt_hw_interrupt_init(void) +{ + int idx; + int cpuid; + + cpuid = current_coreid(); + + /* Disable all interrupts for the current core. */ + for (idx = 0; idx < ((PLIC_NUM_SOURCES + 32u) / 32u); idx ++) + plic->target_enables.target[cpuid].enable[idx] = 0; + + /* Set priorities to zero. */ + for (idx = 0; idx < PLIC_NUM_SOURCES; idx++) + plic->source_priorities.priority[idx] = 0; + + /* Set the threshold to zero. */ + plic->targets.target[cpuid].priority_threshold = 0; + + /* init exceptions table */ + for (idx = 0; idx < MAX_HANDLERS; idx++) + { + rt_hw_interrupt_mask(idx); + irq_desc[idx].handler = (rt_isr_handler_t)rt_hw_interrupt_handle; + irq_desc[idx].param = RT_NULL; +#ifdef RT_USING_INTERRUPT_INFO + rt_snprintf(irq_desc[idx].name, RT_NAME_MAX - 1, "default"); + irq_desc[idx].counter = 0; +#endif + } + + /* Enable machine external interrupts. */ + set_csr(mie, MIP_MEIP); +} + +void rt_hw_scondary_interrupt_init(void) +{ + int idx; + int cpuid; + + cpuid = current_coreid(); + + /* Disable all interrupts for the current core. */ + for (idx = 0; idx < ((PLIC_NUM_SOURCES + 32u) / 32u); idx ++) + plic->target_enables.target[cpuid].enable[idx] = 0; + + /* Set the threshold to zero. */ + plic->targets.target[cpuid].priority_threshold = 0; + + /* Enable machine external interrupts. */ + set_csr(mie, MIP_MEIP); +} + +/** + * This function will mask a interrupt. + * @param vector the interrupt number + */ +void rt_hw_interrupt_mask(int vector) +{ + rt_hw_plic_irq_disable(vector); +} + +/** + * This function will un-mask a interrupt. + * @param vector the interrupt number + */ +void rt_hw_interrupt_umask(int vector) +{ + plic_set_priority(vector, 1); + rt_hw_plic_irq_enable(vector); +} + +/** + * This function will install a interrupt service routine to a interrupt. + * @param vector the interrupt number + * @param new_handler the interrupt service routine to be installed + * @param old_handler the old interrupt service routine + */ +rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, + void *param, const char *name) +{ + rt_isr_handler_t old_handler = RT_NULL; + + if(vector < MAX_HANDLERS) + { + old_handler = irq_desc[vector].handler; + if (handler != RT_NULL) + { + irq_desc[vector].handler = (rt_isr_handler_t)handler; + irq_desc[vector].param = param; +#ifdef RT_USING_INTERRUPT_INFO + rt_snprintf(irq_desc[vector].name, RT_NAME_MAX - 1, "%s", name); + irq_desc[vector].counter = 0; +#endif + } + } + + return old_handler; +} + +static void plic_irq_handle(plic_irq_t irq) +{ + plic_instance_t (*plic_instance)[IRQN_MAX] = plic_get_instance(); + if (plic_instance[0][irq].callback) + { + plic_instance[0][irq].callback( + plic_instance[0][irq].ctx); + } + else if (plic_instance[1][irq].callback) + { + plic_instance[1][irq].callback( + plic_instance[1][irq].ctx); + } +} + +void rt_hw_soft_irq_isr(void) +{ + uint64_t core_id = current_coreid(); + + clint_ipi_clear(core_id); + rt_schedule(); +} + +void rt_hw_irq_isr(void) +{ + /* + * After the highest-priority pending interrupt is claimed by a target + * and the corresponding IP bit is cleared, other lower-priority + * pending interrupts might then become visible to the target, and so + * the PLIC EIP bit might not be cleared after a claim. The interrupt + * handler can check the local meip/heip/seip/ueip bits before exiting + * the handler, to allow more efficient service of other interrupts + * without first restoring the interrupted context and taking another + * interrupt trap. + */ + if (read_csr(mip) & MIP_MEIP) + { + /* Get current core id */ + uint64_t core_id = current_coreid(); + /* Get primitive interrupt enable flag */ + uint64_t ie_flag = read_csr(mie); + /* Get current IRQ num */ + uint32_t int_num = plic->targets.target[core_id].claim_complete; + /* Get primitive IRQ threshold */ + uint32_t int_threshold = plic->targets.target[core_id].priority_threshold; + /* Set new IRQ threshold = current IRQ threshold */ + plic->targets.target[core_id].priority_threshold = plic->source_priorities.priority[int_num]; + + /* Disable software interrupt and timer interrupt */ + clear_csr(mie, MIP_MTIP | MIP_MSIP); + + if (irq_desc[int_num].handler == (rt_isr_handler_t)rt_hw_interrupt_handle) + { + /* default handler, route to kendryte bsp plic driver */ + plic_irq_handle(int_num); + } + else if (irq_desc[int_num].handler) + { + irq_desc[int_num].handler(int_num, irq_desc[int_num].param); + } + + /* Perform IRQ complete */ + plic->targets.target[core_id].claim_complete = int_num; + /* Set MPIE and MPP flag used to MRET instructions restore MIE flag */ + set_csr(mstatus, MSTATUS_MPIE | MSTATUS_MPP); + /* Restore primitive interrupt enable flag */ + write_csr(mie, ie_flag); + /* Restore primitive IRQ threshold */ + plic->targets.target[core_id].priority_threshold = int_threshold; + } +} + diff --git a/bsp/k210/board/startup_gcc.S b/bsp/k210/board/startup_gcc.S new file mode 100755 index 0000000000..a860cf8dc4 --- /dev/null +++ b/bsp/k210/board/startup_gcc.S @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/10/01 Bernard The first version + * 2018/12/27 Jesven Add SMP support + */ + +#define __ASSEMBLY__ +#define MSTATUS_FS 0x00006000U /* initial state of FPU */ +#include <cpuport.h> + + .global _start + .section ".start", "ax" +_start: + j 1f + .word 0xdeadbeef + .align 3 + .global g_wake_up + g_wake_up: + .dword 1 + .dword 0 +1: + csrw mideleg, 0 + csrw medeleg, 0 + csrw mie, 0 + csrw mip, 0 + la t0, trap_entry + csrw mtvec, t0 + + li x1, 0 + li x2, 0 + li x3, 0 + li x4, 0 + li x5, 0 + li x6, 0 + li x7, 0 + li x8, 0 + li x9, 0 + li x10,0 + li x11,0 + li x12,0 + li x13,0 + li x14,0 + li x15,0 + li x16,0 + li x17,0 + li x18,0 + li x19,0 + li x20,0 + li x21,0 + li x22,0 + li x23,0 + li x24,0 + li x25,0 + li x26,0 + li x27,0 + li x28,0 + li x29,0 + li x30,0 + li x31,0 + + /* set to initial state of FPU and disable interrupt */ + li t0, MSTATUS_FS + csrs mstatus, t0 + + fssr x0 + fmv.w.x f0, x0 + fmv.w.x f1, x0 + fmv.w.x f2, x0 + fmv.w.x f3, x0 + fmv.w.x f4, x0 + fmv.w.x f5, x0 + fmv.w.x f6, x0 + fmv.w.x f7, x0 + fmv.w.x f8, x0 + fmv.w.x f9, x0 + fmv.w.x f10,x0 + fmv.w.x f11,x0 + fmv.w.x f12,x0 + fmv.w.x f13,x0 + fmv.w.x f14,x0 + fmv.w.x f15,x0 + fmv.w.x f16,x0 + fmv.w.x f17,x0 + fmv.w.x f18,x0 + fmv.w.x f19,x0 + fmv.w.x f20,x0 + fmv.w.x f21,x0 + fmv.w.x f22,x0 + fmv.w.x f23,x0 + fmv.w.x f24,x0 + fmv.w.x f25,x0 + fmv.w.x f26,x0 + fmv.w.x f27,x0 + fmv.w.x f28,x0 + fmv.w.x f29,x0 + fmv.w.x f30,x0 + fmv.w.x f31,x0 + +.option push +.option norelax + la gp, __global_pointer$ +.option pop + + /* get cpu id */ + csrr a0, mhartid + + la sp, __stack_start__ + addi t1, a0, 1 + li t2, __STACKSIZE__ + mul t1, t1, t2 + add sp, sp, t1 /* sp = (cpuid + 1) * __STACKSIZE__ + __stack_start__ */ + + /* other cpu core, jump to cpu entry directly */ + bnez a0, secondary_cpu_entry + tail primary_cpu_entry + +secondary_cpu_entry: +#ifdef RT_USING_SMP + la a0, secondary_boot_flag + ld a0, 0(a0) + li a1, 0xa55a + beq a0, a1, 1f +#endif + j secondary_cpu_entry + +#ifdef RT_USING_SMP +1: + tail secondary_cpu_c_start + +.data +.global secondary_boot_flag +.align 3 +secondary_boot_flag: + .dword 0 +#endif diff --git a/bsp/k210/board/tick.c b/bsp/k210/board/tick.c new file mode 100755 index 0000000000..50510cf7d3 --- /dev/null +++ b/bsp/k210/board/tick.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/10/28 Bernard The unify RISC-V porting code. + */ + +#include <rthw.h> +#include <rtthread.h> + +#include <encoding.h> +#include <clint.h> +#include <sysctl.h> + +static volatile unsigned long tick_cycles = 0; + +int rt_hw_tick_isr(void) +{ + uint64_t core_id = current_coreid(); + + clint->mtimecmp[core_id] += tick_cycles; + rt_tick_increase(); + + return 0; +} + +/* Sets and enable the timer interrupt */ +int rt_hw_tick_init(void) +{ + /* Read core id */ + unsigned long core_id = current_coreid(); + unsigned long interval = 1000/RT_TICK_PER_SECOND; + + /* Clear the Machine-Timer bit in MIE */ + clear_csr(mie, MIP_MTIP); + + /* calculate the tick cycles */ + tick_cycles = interval * sysctl_clock_get_freq(SYSCTL_CLOCK_CPU) / CLINT_CLOCK_DIV / 1000ULL - 1; + /* Set mtimecmp by core id */ + clint->mtimecmp[core_id] = clint->mtime + tick_cycles; + + /* Enable the Machine-Timer bit in MIE */ + set_csr(mie, MIP_MTIP); + + return 0; +} diff --git a/bsp/k210/board/tick.h b/bsp/k210/board/tick.h new file mode 100755 index 0000000000..0bfd6f62e8 --- /dev/null +++ b/bsp/k210/board/tick.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/10/28 Bernard The unify RISC-V porting code. + */ + +#ifndef TICK_H__ +#define TICK_H__ + +int tick_isr(void); +int rt_hw_tick_init(void); + +#endif diff --git a/bsp/k210/drivers/SConscript b/bsp/k210/drivers/SConscript index a118be7270..cc4dc0e26d 100644 --- a/bsp/k210/drivers/SConscript +++ b/bsp/k210/drivers/SConscript @@ -4,11 +4,8 @@ from building import * cwd = GetCurrentDir() src = Split(''' -board.c -heap.c drv_uart.c drv_io_config.c -drv_interrupt.c dmalock.c ''') CPPPATH = [cwd] @@ -19,6 +16,7 @@ if GetDepend('RT_USING_PIN'): if GetDepend('BSP_USING_LCD'): src += ['drv_lcd.c'] src += ['drv_mpylcd.c'] + src += ['test/lcd_test.c'] if GetDepend('RT_USING_HWTIMER'): src += ['drv_hw_timer.c'] diff --git a/bsp/k210/drivers/drv_interrupt.c b/bsp/k210/drivers/drv_interrupt.c deleted file mode 100644 index 12f582a113..0000000000 --- a/bsp/k210/drivers/drv_interrupt.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2019-03-19 ZYH first version - */ - -#include <plic.h> - -void plic_irq_handle(plic_irq_t irq) -{ - plic_instance_t (*plic_instance)[IRQN_MAX] = plic_get_instance(); - if (plic_instance[0][irq].callback) - { - plic_instance[0][irq].callback( - plic_instance[0][irq].ctx); - } - else if (plic_instance[1][irq].callback) - { - plic_instance[1][irq].callback( - plic_instance[1][irq].ctx); - } -} - diff --git a/bsp/k210/applications/lcd_test.c b/bsp/k210/drivers/test/lcd_test.c index 8dd32ed913..8dd32ed913 100644..100755 --- a/bsp/k210/applications/lcd_test.c +++ b/bsp/k210/drivers/test/lcd_test.c diff --git a/bsp/k210/link_stacksize.lds b/bsp/k210/link_stacksize.lds index 28438c7da1..1dd893422c 100644 --- a/bsp/k210/link_stacksize.lds +++ b/bsp/k210/link_stacksize.lds @@ -1 +1 @@ -__STACKSIZE__ = 4096; +__STACKSIZE__ = 4096;
\ No newline at end of file diff --git a/bsp/k210/rtconfig.h b/bsp/k210/rtconfig.h index 3666cf6230..7ef59e9877 100644 --- a/bsp/k210/rtconfig.h +++ b/bsp/k210/rtconfig.h @@ -45,14 +45,12 @@ #define RT_MEMHEAP_FAST_MODE #define RT_USING_SLAB_AS_HEAP #define RT_USING_HEAP - -/* Kernel Device Object */ - #define RT_USING_DEVICE #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "uarths" -#define RT_VER_NUM 0x50002 +#define RT_VER_NUM 0x50100 +#define RT_BACKTRACE_LEVEL_MAX_NR 32 #define ARCH_CPU_64BIT #define RT_USING_HW_ATOMIC #define ARCH_RISCV @@ -153,6 +151,9 @@ /* Network */ +/* Memory protection */ + + /* Utilities */ #define RT_USING_ULOG @@ -185,6 +186,15 @@ /* Wiced WiFi */ +/* CYW43012 WiFi */ + + +/* BL808 WiFi */ + + +/* CYW43439 WiFi */ + + /* IoT Cloud */ @@ -299,23 +309,6 @@ #define BSP_USING_UART1 #define BSP_UART1_TXD_PIN 20 #define BSP_UART1_RXD_PIN 21 -#define BSP_USING_SPI1 -#define BSP_SPI1_CLK_PIN 27 -#define BSP_SPI1_D0_PIN 28 -#define BSP_SPI1_D1_PIN 26 -#define BSP_SPI1_USING_SS0 -#define BSP_SPI1_SS0_PIN 29 -#define BSP_USING_LCD -#define BSP_LCD_CS_PIN 36 -#define BSP_LCD_WR_PIN 39 -#define BSP_LCD_DC_PIN 38 -#define BSP_LCD_RST_PIN 37 -#define BSP_LCD_BACKLIGHT_PIN -1 -#define BSP_LCD_BACKLIGHT_ACTIVE_LOW -#define BSP_LCD_CLK_FREQ 15000000 -#define BSP_BOARD_K210_OPENMV_TEST -#define BSP_LCD_X_MAX 240 -#define BSP_LCD_Y_MAX 320 #define __STACKSIZE__ 4096 #endif diff --git a/bsp/k210/rtconfig.py b/bsp/k210/rtconfig.py index 8536011fd9..2c44fdeb95 100755 --- a/bsp/k210/rtconfig.py +++ b/bsp/k210/rtconfig.py @@ -2,7 +2,7 @@ import os # toolchains options ARCH ='risc-v' -CPU ='k210' +CPU ='rv64' CROSS_TOOL ='gcc' if os.getenv('RTT_ROOT'): |
