diff --git a/bsp/CME_M7/rtconfig.h b/bsp/CME_M7/rtconfig.h index f981ad9a91..886c28cb9e 100644 --- a/bsp/CME_M7/rtconfig.h +++ b/bsp/CME_M7/rtconfig.h @@ -55,6 +55,7 @@ #define RT_USING_DEVICE #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* SECTION: Console options */ #define RT_USING_CONSOLE diff --git a/bsp/allwinner_tina/.config b/bsp/allwinner_tina/.config index 3a40f9d566..de547c5a34 100644 --- a/bsp/allwinner_tina/.config +++ b/bsp/allwinner_tina/.config @@ -120,6 +120,7 @@ CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/allwinner_tina/rtconfig.h b/bsp/allwinner_tina/rtconfig.h index 2fb7c07df3..25a1302b1a 100644 --- a/bsp/allwinner_tina/rtconfig.h +++ b/bsp/allwinner_tina/rtconfig.h @@ -111,6 +111,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/amebaz/.config b/bsp/amebaz/.config index 4a513007e7..9412058c8e 100644 --- a/bsp/amebaz/.config +++ b/bsp/amebaz/.config @@ -106,6 +106,7 @@ CONFIG_FINSH_ARG_MAX=10 CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/amebaz/rtconfig.h b/bsp/amebaz/rtconfig.h index 5d8ee1df02..92bac2d294 100644 --- a/bsp/amebaz/rtconfig.h +++ b/bsp/amebaz/rtconfig.h @@ -75,6 +75,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* Using WiFi */ diff --git a/bsp/apollo2/rtconfig.h b/bsp/apollo2/rtconfig.h index 5f94db4eff..dfa458bc4e 100644 --- a/bsp/apollo2/rtconfig.h +++ b/bsp/apollo2/rtconfig.h @@ -99,6 +99,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ #define RT_USING_I2C diff --git a/bsp/asm9260t/.config b/bsp/asm9260t/.config index ed77c0678d..e634c994c8 100644 --- a/bsp/asm9260t/.config +++ b/bsp/asm9260t/.config @@ -83,6 +83,7 @@ CONFIG_FINSH_CMD_SIZE=80 # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_I2C is not set diff --git a/bsp/asm9260t/rtconfig.h b/bsp/asm9260t/rtconfig.h index def7f36a71..bf1f76fefb 100644 --- a/bsp/asm9260t/rtconfig.h +++ b/bsp/asm9260t/rtconfig.h @@ -75,6 +75,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_I2C is not set */ diff --git a/bsp/at91sam9260/rtconfig.h b/bsp/at91sam9260/rtconfig.h index 62ceba4914..b9ec26f390 100755 --- a/bsp/at91sam9260/rtconfig.h +++ b/bsp/at91sam9260/rtconfig.h @@ -76,6 +76,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* SECTION: Console options */ #define RT_USING_CONSOLE diff --git a/bsp/beaglebone/.config b/bsp/beaglebone/.config index 0ff69f1164..409e89d18e 100644 --- a/bsp/beaglebone/.config +++ b/bsp/beaglebone/.config @@ -115,6 +115,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/beaglebone/rtconfig.h b/bsp/beaglebone/rtconfig.h index 5bc7ab92db..c49528049d 100644 --- a/bsp/beaglebone/rtconfig.h +++ b/bsp/beaglebone/rtconfig.h @@ -77,6 +77,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using USB */ diff --git a/bsp/ck802/.config b/bsp/ck802/.config index 4284658f94..e91f93fd0e 100644 --- a/bsp/ck802/.config +++ b/bsp/ck802/.config @@ -97,6 +97,7 @@ CONFIG_FINSH_ARG_MAX=10 # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/ck802/rtconfig.h b/bsp/ck802/rtconfig.h index 3eb48b11f0..076d48e534 100644 --- a/bsp/ck802/rtconfig.h +++ b/bsp/ck802/rtconfig.h @@ -71,6 +71,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using USB */ diff --git a/bsp/dm365/.config b/bsp/dm365/.config index 30dc0871e5..6974ff8ae0 100644 --- a/bsp/dm365/.config +++ b/bsp/dm365/.config @@ -134,6 +134,7 @@ CONFIG_RT_NFS_HOST_EXPORT="192.168.1.5:/" CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/dm365/rtconfig.h b/bsp/dm365/rtconfig.h index ae16abdca6..4f3698f124 100644 --- a/bsp/dm365/rtconfig.h +++ b/bsp/dm365/rtconfig.h @@ -125,6 +125,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/fh8620/rtconfig.h b/bsp/fh8620/rtconfig.h index cefbff053c..01a2d2d45c 100644 --- a/bsp/fh8620/rtconfig.h +++ b/bsp/fh8620/rtconfig.h @@ -74,6 +74,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // #define RT_UART_RX_BUFFER_SIZE 64 // diff --git a/bsp/frdm-k64f/rtconfig.h b/bsp/frdm-k64f/rtconfig.h index d8e6f6dbc5..8d0ad639ce 100644 --- a/bsp/frdm-k64f/rtconfig.h +++ b/bsp/frdm-k64f/rtconfig.h @@ -63,6 +63,7 @@ #define RT_USING_DEVICE_IPC /* Using Serial Device Driver Framework" default="true" */ #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA //
#define RT_USING_COMPONENTS_INIT diff --git a/bsp/gd32303e-eval/.config b/bsp/gd32303e-eval/.config index 94c9a258f0..b61d310f03 100644 --- a/bsp/gd32303e-eval/.config +++ b/bsp/gd32303e-eval/.config @@ -120,6 +120,7 @@ CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/gd32303e-eval/rtconfig.h b/bsp/gd32303e-eval/rtconfig.h index 26f476db78..479ad99af5 100644 --- a/bsp/gd32303e-eval/rtconfig.h +++ b/bsp/gd32303e-eval/rtconfig.h @@ -87,6 +87,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_I2C #define RT_USING_PIN #define RT_USING_SPI diff --git a/bsp/gd32450z-eval/.config b/bsp/gd32450z-eval/.config index a04025b693..e2f00a07fc 100644 --- a/bsp/gd32450z-eval/.config +++ b/bsp/gd32450z-eval/.config @@ -131,6 +131,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/gd32450z-eval/rtconfig.h b/bsp/gd32450z-eval/rtconfig.h index 1eaeb4b827..500aab6290 100644 --- a/bsp/gd32450z-eval/rtconfig.h +++ b/bsp/gd32450z-eval/rtconfig.h @@ -88,6 +88,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using USB */ diff --git a/bsp/gkipc/.config b/bsp/gkipc/.config index b3a1cd2628..975b82b5b2 100644 --- a/bsp/gkipc/.config +++ b/bsp/gkipc/.config @@ -123,6 +123,7 @@ CONFIG_RT_NFS_HOST_EXPORT="192.168.10.82:/" # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/gkipc/rtconfig.h b/bsp/gkipc/rtconfig.h index 23df0f0704..2c0233cf29 100644 --- a/bsp/gkipc/rtconfig.h +++ b/bsp/gkipc/rtconfig.h @@ -114,6 +114,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/hifive1/.config b/bsp/hifive1/.config index 186ad3e8e3..9f66767320 100644 --- a/bsp/hifive1/.config +++ b/bsp/hifive1/.config @@ -107,6 +107,7 @@ CONFIG_FINSH_ARG_MAX=10 CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/hifive1/rtconfig.h b/bsp/hifive1/rtconfig.h index 762eb92df5..1d96bfc3db 100644 --- a/bsp/hifive1/rtconfig.h +++ b/bsp/hifive1/rtconfig.h @@ -74,6 +74,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* Using WiFi */ diff --git a/bsp/imx6sx/cortex-a9/.config b/bsp/imx6sx/cortex-a9/.config index cb857b4c0f..ce2e256f2c 100644 --- a/bsp/imx6sx/cortex-a9/.config +++ b/bsp/imx6sx/cortex-a9/.config @@ -116,6 +116,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/imx6sx/cortex-a9/rtconfig.h b/bsp/imx6sx/cortex-a9/rtconfig.h index 71f7cf4d9b..30de937b05 100644 --- a/bsp/imx6sx/cortex-a9/rtconfig.h +++ b/bsp/imx6sx/cortex-a9/rtconfig.h @@ -77,6 +77,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using USB */ diff --git a/bsp/imx6ul/rtconfig.h b/bsp/imx6ul/rtconfig.h index f37f620a9c..ee3857dcb8 100644 --- a/bsp/imx6ul/rtconfig.h +++ b/bsp/imx6ul/rtconfig.h @@ -72,6 +72,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // #define RT_UART_RX_BUFFER_SIZE 64 // diff --git a/bsp/imxrt/imxrt1050-ArchMix/.config b/bsp/imxrt/imxrt1050-ArchMix/.config index 3406bd3ee8..353f769594 100644 --- a/bsp/imxrt/imxrt1050-ArchMix/.config +++ b/bsp/imxrt/imxrt1050-ArchMix/.config @@ -135,6 +135,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set CONFIG_RT_USING_CPUTIME=y diff --git a/bsp/imxrt/imxrt1050-ArchMix/rtconfig.h b/bsp/imxrt/imxrt1050-ArchMix/rtconfig.h index 525013e73e..98c795a026 100644 --- a/bsp/imxrt/imxrt1050-ArchMix/rtconfig.h +++ b/bsp/imxrt/imxrt1050-ArchMix/rtconfig.h @@ -95,6 +95,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_CPUTIME #define RT_USING_CPUTIME_CORTEXM #define RT_USING_I2C diff --git a/bsp/imxrt/imxrt1050-evk/.config b/bsp/imxrt/imxrt1050-evk/.config index ba6c3d19ad..63fea7652c 100644 --- a/bsp/imxrt/imxrt1050-evk/.config +++ b/bsp/imxrt/imxrt1050-evk/.config @@ -136,6 +136,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set CONFIG_RT_USING_CPUTIME=y diff --git a/bsp/imxrt/imxrt1050-evk/rtconfig.h b/bsp/imxrt/imxrt1050-evk/rtconfig.h index b5e68cdab9..f1a7a6785a 100644 --- a/bsp/imxrt/imxrt1050-evk/rtconfig.h +++ b/bsp/imxrt/imxrt1050-evk/rtconfig.h @@ -95,6 +95,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_CPUTIME #define RT_USING_CPUTIME_CORTEXM #define RT_USING_I2C diff --git a/bsp/imxrt1052-evk/.config b/bsp/imxrt1052-evk/.config index ece9538595..88643d85b4 100644 --- a/bsp/imxrt1052-evk/.config +++ b/bsp/imxrt1052-evk/.config @@ -124,6 +124,7 @@ CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/imxrt1052-evk/rtconfig.h b/bsp/imxrt1052-evk/rtconfig.h index ef00ef09ff..d4298a93ca 100644 --- a/bsp/imxrt1052-evk/rtconfig.h +++ b/bsp/imxrt1052-evk/rtconfig.h @@ -91,6 +91,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_I2C #define RT_USING_I2C_BITOPS #define RT_USING_PIN diff --git a/bsp/k210/.config b/bsp/k210/.config new file mode 100644 index 0000000000..d1279d3b74 --- /dev/null +++ b/bsp/k210/.config @@ -0,0 +1,374 @@ +# +# Automatically generated file; DO NOT EDIT. +# RT-Thread Project Configuration +# + +# +# RT-Thread Kernel +# +CONFIG_RT_NAME_MAX=8 +# CONFIG_RT_USING_SMP is not set +CONFIG_RT_ALIGN_SIZE=8 +# CONFIG_RT_THREAD_PRIORITY_8 is not set +CONFIG_RT_THREAD_PRIORITY_32=y +# CONFIG_RT_THREAD_PRIORITY_256 is not set +CONFIG_RT_THREAD_PRIORITY_MAX=32 +CONFIG_RT_TICK_PER_SECOND=100 +CONFIG_RT_USING_OVERFLOW_CHECK=y +CONFIG_RT_USING_HOOK=y +CONFIG_RT_USING_IDLE_HOOK=y +CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 +CONFIG_IDLE_THREAD_STACK_SIZE=1024 +# CONFIG_RT_USING_TIMER_SOFT is not set +CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_INIT_CONFIG=y +CONFIG_RT_DEBUG_INIT=1 +# CONFIG_RT_DEBUG_THREAD_CONFIG is not set +# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set +# CONFIG_RT_DEBUG_IPC_CONFIG is not set +# CONFIG_RT_DEBUG_TIMER_CONFIG is not set +# CONFIG_RT_DEBUG_IRQ_CONFIG is not set +# CONFIG_RT_DEBUG_MEM_CONFIG is not set +# CONFIG_RT_DEBUG_SLAB_CONFIG is not set +# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set +# CONFIG_RT_DEBUG_MODULE_CONFIG is not set + +# +# Inter-Thread communication +# +CONFIG_RT_USING_SEMAPHORE=y +CONFIG_RT_USING_MUTEX=y +CONFIG_RT_USING_EVENT=y +CONFIG_RT_USING_MAILBOX=y +CONFIG_RT_USING_MESSAGEQUEUE=y +# CONFIG_RT_USING_SIGNALS is not set + +# +# Memory Management +# +CONFIG_RT_USING_MEMPOOL=y +# CONFIG_RT_USING_MEMHEAP is not set +# CONFIG_RT_USING_NOHEAP is not set +CONFIG_RT_USING_SMALL_MEM=y +# CONFIG_RT_USING_SLAB is not set +# CONFIG_RT_USING_MEMTRACE 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_INTERRUPT_INFO is not set +CONFIG_RT_USING_CONSOLE=y +CONFIG_RT_CONSOLEBUF_SIZE=128 +CONFIG_RT_CONSOLE_DEVICE_NAME="uarths" +CONFIG_RT_VER_NUM=0x40000 +CONFIG_ARCH_CPU_64BIT=y +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_RISCV64=y +# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set + +# +# RT-Thread Components +# +CONFIG_RT_USING_COMPONENTS_INIT=y +CONFIG_RT_USING_USER_MAIN=y +CONFIG_RT_MAIN_THREAD_STACK_SIZE=8192 +CONFIG_RT_MAIN_THREAD_PRIORITY=10 + +# +# C++ features +# +# CONFIG_RT_USING_CPLUSPLUS is not set + +# +# Command shell +# +CONFIG_RT_USING_FINSH=y +CONFIG_FINSH_THREAD_NAME="tshell" +CONFIG_FINSH_USING_HISTORY=y +CONFIG_FINSH_HISTORY_LINES=5 +CONFIG_FINSH_USING_SYMTAB=y +CONFIG_FINSH_USING_DESCRIPTION=y +# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set +CONFIG_FINSH_THREAD_PRIORITY=20 +CONFIG_FINSH_THREAD_STACK_SIZE=4096 +CONFIG_FINSH_CMD_SIZE=80 +# CONFIG_FINSH_USING_AUTH is not set +CONFIG_FINSH_USING_MSH=y +CONFIG_FINSH_USING_MSH_DEFAULT=y +CONFIG_FINSH_USING_MSH_ONLY=y +CONFIG_FINSH_ARG_MAX=10 + +# +# Device virtual file system +# +CONFIG_RT_USING_DFS=y +CONFIG_DFS_USING_WORKDIR=y +CONFIG_DFS_FILESYSTEMS_MAX=4 +CONFIG_DFS_FILESYSTEM_TYPES_MAX=4 +CONFIG_DFS_FD_MAX=16 +# CONFIG_RT_USING_DFS_MNTTABLE is not set +# CONFIG_RT_USING_DFS_ELMFAT is not set +CONFIG_RT_USING_DFS_DEVFS=y +# CONFIG_RT_USING_DFS_ROMFS is not set +# CONFIG_RT_USING_DFS_RAMFS is not set +# CONFIG_RT_USING_DFS_UFFS is not set +# CONFIG_RT_USING_DFS_JFFS2 is not set + +# +# Device Drivers +# +CONFIG_RT_USING_DEVICE_IPC=y +CONFIG_RT_PIPE_BUFSZ=512 +CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y +# CONFIG_RT_USING_CAN is not set +# CONFIG_RT_USING_HWTIMER is not set +# CONFIG_RT_USING_CPUTIME is not set +# CONFIG_RT_USING_I2C is not set +CONFIG_RT_USING_PIN=y +# CONFIG_RT_USING_ADC is not set +# CONFIG_RT_USING_PWM is not set +# CONFIG_RT_USING_MTD_NOR is not set +# CONFIG_RT_USING_MTD_NAND is not set +# CONFIG_RT_USING_MTD is not set +# CONFIG_RT_USING_PM is not set +# CONFIG_RT_USING_RTC is not set +# CONFIG_RT_USING_SDIO is not set +# CONFIG_RT_USING_SPI is not set +# CONFIG_RT_USING_WDT is not set +# CONFIG_RT_USING_AUDIO is not set + +# +# Using WiFi +# +# CONFIG_RT_USING_WIFI is not set + +# +# Using USB +# +# CONFIG_RT_USING_USB_HOST is not set +# CONFIG_RT_USING_USB_DEVICE is not set + +# +# POSIX layer and C standard library +# +CONFIG_RT_USING_LIBC=y +# CONFIG_RT_USING_PTHREADS is not set +CONFIG_RT_USING_POSIX=y +# CONFIG_RT_USING_POSIX_MMAP is not set +# CONFIG_RT_USING_POSIX_TERMIOS is not set +# CONFIG_RT_USING_POSIX_AIO is not set +# CONFIG_RT_USING_MODULE is not set + +# +# Network +# + +# +# Socket abstraction layer +# +# CONFIG_RT_USING_SAL is not set + +# +# light weight TCP/IP stack +# +# CONFIG_RT_USING_LWIP is not set + +# +# Modbus master and slave stack +# +# CONFIG_RT_USING_MODBUS is not set + +# +# AT commands +# +# CONFIG_RT_USING_AT is not set + +# +# VBUS(Virtual Software BUS) +# +# CONFIG_RT_USING_VBUS is not set + +# +# Utilities +# +# CONFIG_RT_USING_LOGTRACE is not set +# CONFIG_RT_USING_RYM is not set +# CONFIG_RT_USING_ULOG is not set +# CONFIG_RT_USING_UTEST is not set + +# +# RT-Thread online packages +# + +# +# IoT - internet of things +# +# CONFIG_PKG_USING_PAHOMQTT is not set +# CONFIG_PKG_USING_WEBCLIENT is not set +# CONFIG_PKG_USING_WEBNET is not set +# CONFIG_PKG_USING_MONGOOSE is not set +# CONFIG_PKG_USING_WEBTERMINAL is not set +# CONFIG_PKG_USING_CJSON is not set +# CONFIG_PKG_USING_JSMN is not set +# CONFIG_PKG_USING_LJSON is not set +# CONFIG_PKG_USING_EZXML is not set +# CONFIG_PKG_USING_NANOPB is not set + +# +# Wi-Fi +# + +# +# Marvell WiFi +# +# CONFIG_PKG_USING_WLANMARVELL is not set + +# +# Wiced WiFi +# +# CONFIG_PKG_USING_WLAN_WICED is not set +# CONFIG_PKG_USING_COAP is not set +# CONFIG_PKG_USING_NOPOLL is not set +# CONFIG_PKG_USING_NETUTILS is not set +# CONFIG_PKG_USING_AT_DEVICE is not set +# CONFIG_PKG_USING_WIZNET is not set + +# +# IoT Cloud +# +# CONFIG_PKG_USING_ONENET is not set +# CONFIG_PKG_USING_GAGENT_CLOUD is not set +# CONFIG_PKG_USING_ALI_IOTKIT is not set +# CONFIG_PKG_USING_AZURE is not set +# CONFIG_PKG_USING_TENCENT_IOTKIT is not set + +# +# security packages +# +# CONFIG_PKG_USING_MBEDTLS is not set +# CONFIG_PKG_USING_libsodium is not set +# CONFIG_PKG_USING_TINYCRYPT is not set + +# +# language packages +# +# CONFIG_PKG_USING_LUA is not set +# CONFIG_PKG_USING_JERRYSCRIPT is not set +# CONFIG_PKG_USING_MICROPYTHON is not set + +# +# multimedia packages +# +# CONFIG_PKG_USING_OPENMV is not set +# CONFIG_PKG_USING_MUPDF is not set + +# +# tools packages +# +# CONFIG_PKG_USING_CMBACKTRACE is not set +# CONFIG_PKG_USING_EASYFLASH is not set +# CONFIG_PKG_USING_EASYLOGGER is not set +# CONFIG_PKG_USING_SYSTEMVIEW is not set +# CONFIG_PKG_USING_RDB is not set +# CONFIG_PKG_USING_QRCODE is not set +# CONFIG_PKG_USING_ULOG_EASYFLASH is not set + +# +# system packages +# +# CONFIG_PKG_USING_GUIENGINE is not set +# CONFIG_PKG_USING_CAIRO is not set +# CONFIG_PKG_USING_PIXMAN is not set +# CONFIG_PKG_USING_LWEXT4 is not set +# CONFIG_PKG_USING_PARTITION is not set +# CONFIG_PKG_USING_FAL is not set +# CONFIG_PKG_USING_SQLITE is not set +# CONFIG_PKG_USING_RTI is not set +# CONFIG_PKG_USING_LITTLEVGL2RTT is not set +# CONFIG_PKG_USING_CMSIS is not set +# CONFIG_PKG_USING_DFS_YAFFS is not set +# CONFIG_PKG_USING_LITTLEFS is not set + +# +# peripheral libraries and drivers +# +# CONFIG_PKG_USING_REALTEK_AMEBA is not set +# CONFIG_PKG_USING_SHT2X is not set +# CONFIG_PKG_USING_AHT10 is not set +# CONFIG_PKG_USING_AP3216C is not set +# CONFIG_PKG_USING_STM32_SDIO is not set +# CONFIG_PKG_USING_ICM20608 is not set +# CONFIG_PKG_USING_U8G2 is not set +# CONFIG_PKG_USING_BUTTON is not set +# CONFIG_PKG_USING_MPU6XXX is not set +# CONFIG_PKG_USING_PCF8574 is not set +CONFIG_PKG_USING_KENDRYTE_SDK=y +CONFIG_PKG_KENDRYTE_SDK_PATH="/packages/peripherals/kendryte-sdk" +CONFIG_PKG_USING_KENDRYTE_SDK_V052=y +# CONFIG_PKG_USING_KENDRYTE_SDK_LATEST_VERSION is not set +CONFIG_PKG_KENDRYTE_SDK_VER="v0.5.2" + +# +# miscellaneous packages +# +# CONFIG_PKG_USING_LIBCSV is not set +# CONFIG_PKG_USING_OPTPARSE is not set +# CONFIG_PKG_USING_FASTLZ is not set +# CONFIG_PKG_USING_MINILZO is not set +# CONFIG_PKG_USING_QUICKLZ is not set +# CONFIG_PKG_USING_MULTIBUTTON is not set +# CONFIG_PKG_USING_CANFESTIVAL is not set +# CONFIG_PKG_USING_ZLIB is not set +# CONFIG_PKG_USING_DSTR is not set +# CONFIG_PKG_USING_TINYFRAME is not set + +# +# sample package +# + +# +# samples: kernel and components samples +# +# CONFIG_PKG_USING_KERNEL_SAMPLES is not set +# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set +# CONFIG_PKG_USING_NETWORK_SAMPLES is not set +# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set + +# +# example package: hello +# +# CONFIG_PKG_USING_HELLO is not set + +# +# Privated Packages of RealThread +# +# CONFIG_PKG_USING_CODEC is not set +# CONFIG_PKG_USING_PLAYER is not set +# CONFIG_PKG_USING_PERSIMMON_SRC is not set +# CONFIG_PKG_USING_JS_PERSIMMON is not set +# CONFIG_PKG_USING_JERRYSCRIPT_WIN32 is not set + +# +# Network Utilities +# +# CONFIG_PKG_USING_WICED is not set +# CONFIG_PKG_USING_CLOUDSDK is not set +# CONFIG_PKG_USING_COREMARK is not set +# CONFIG_PKG_USING_POWER_MANAGER is not set +# CONFIG_PKG_USING_RT_OTA is not set +# CONFIG_PKG_USING_RDBD_SRC is not set +# CONFIG_PKG_USING_RTINSIGHT is not set +# CONFIG_PKG_USING_SMARTCONFIG is not set +# CONFIG_PKG_USING_RTX is not set +CONFIG_BOARD_K210_EVB=y +CONFIG_BSP_USING_UART_HS=y +# CONFIG_BSP_USING_UART1 is not set +# 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 is not set +CONFIG___STACKSIZE__=4096 diff --git a/bsp/k210/Kconfig b/bsp/k210/Kconfig new file mode 100644 index 0000000000..ccb4adf6dc --- /dev/null +++ b/bsp/k210/Kconfig @@ -0,0 +1,31 @@ +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" + +config BOARD_K210_EVB + bool + select ARCH_RISCV64 + select PKG_USING_KENDRYTE_SDK + default y + +source "driver/Kconfig" + +config __STACKSIZE__ + int "stack size for interrupt" + default 4096 diff --git a/bsp/k210/README.md b/bsp/k210/README.md new file mode 100644 index 0000000000..6de922d7a2 --- /dev/null +++ b/bsp/k210/README.md @@ -0,0 +1,93 @@ +# Kendryte K210板级支持包说明 + +## 1. 简介 + +Kendryte K210 是集成机器视觉与机器听觉能力的系统级芯片(SoC)。使用台积电 (TSMC) 超低功耗的 28 纳米先进制程,具有双核64位处理器,拥有较好的功耗性能,稳定性与可靠性。该方案力求零门槛开发,可在最短时效部署于用户的产品中,赋予产品人工智能。 + +Kendryte K210 定位于AI与IoT市场的SoC,同时是使用非常方便的MCU。 + +Kendryte中文含义为勘智,而勘智取自勘物探智。这颗芯片主要应用领域为物联网领域,在物联网领域进行开发,因此为勘物;这颗芯片主要提供的是人工智能解决方案,在人工智能领域探索,因此为探智。 + +* 具备机器视觉能力 +* 具备机器听觉能力 +* 更好的低功耗视觉处理速度与准确率 +* 具备卷积人工神经网络硬件加速器KPU,可高性能进行卷积人工神经网络运算 +* TSMC 28nm先进制程,温度范围-40°C到125°C,稳定可靠 +* 支持固件加密,难以使用普通方法破解 +* 独特的可编程IO阵列,使产品设计更加灵活 +* 低电压,与相同处理能力的系统相比具有更低功耗 +* 3.3V/1.8V双电压支持,无需电平转换,节约成本 + +芯片规格包括如下: + +| 硬件 | 描述 | +| -- | -- | +|芯片型号| K210 | +|CPU| 双核RV64GC | +|主频| 400MHz | +|片内SRAM| 8MB | +| 外设 | 内嵌AES与SHA256算法加速器 | +| | DVP、JTAG、OTP、FPIOA、GPIO、UART、SPI、RTC、I²S、I²C、WDT、Timer与PWM | + +## 2. 编译说明 + +编译K210,需要先下载K210 BSP以及RT-Thread代码: + + git clone https://github.com/BernardXiong/K210.git + cd K210 + git submodule init + git submodule update + + git clone https://github.com/RT-Thread/rt-thread.git + cd rt-thread + git checkout -b dev-4.0.x origin/dev-4.0.x + +注意,因为RT-Thread整体代码太庞大,所以并未把RT-Thread git repo以一个submodule方式加入到K210 BSP git repo中, +而是需要把RT-Thread代码克隆到K210目录下,并切换到dev-4.0.x分支。 + +编译推荐使用[env工具][1],可以在console下进入到`K210`目录中,运行以下命令: + + set RTT_EXEC_PATH=your_toolchains + scons + +来编译这个板级支持包。如果编译正确无误,会产生rtthread.elf、rtthread.bin文件。其中rtthread.bin需要烧写到设备中进行运行。 + +## 3. 烧写及执行 + +连接好串口,然后使用[K-Flash](https://kendryte.com/downloads/)工具进行烧写bin文件。 + +![K-Flash](images/flash.png) + +### 3.1 运行结果 + +如果编译 & 烧写无误,当复位设备后,会在串口上看到RT-Thread的启动logo信息: + +![terminal](images/k210.png) + +## 4. 驱动支持情况及计划 + +| 驱动 | 支持情况 | 备注 | +| ------ | ---- | :------: | +| UART | 支持 | 高速UART,用于shell | + +## 5. 联系人信息 + +维护人:[bernard](https://github.com/BernardXiong) + +## 6. 注意事项 + +在进行系统menuconfig配置时,以下项是必选的 + +| 配置项 | 强制配置值 | +| ----- | --------- | +| Alignment size for CPU architecture data access | 8 | +| The stack size of idle thread | > 1024 | +| the device name for console | "uarths" | +| Set main thread stack size | 4096 | + +## 7. 参考 + +* 芯片[datasheet][2] + + [1]: https://www.rt-thread.org/page/download.html + [2]: https://s3.cn-north-1.amazonaws.com.cn/dl.kendryte.com/documents/kendryte_datasheet_20180919020633.pdf diff --git a/bsp/k210/SConscript b/bsp/k210/SConscript new file mode 100644 index 0000000000..c7ef7659ec --- /dev/null +++ b/bsp/k210/SConscript @@ -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') diff --git a/bsp/k210/SConstruct b/bsp/k210/SConstruct new file mode 100644 index 0000000000..dc55b29194 --- /dev/null +++ b/bsp/k210/SConstruct @@ -0,0 +1,35 @@ +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 + +env = Environment(tools = ['mingw'], + AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, + CC = rtconfig.CC, CCFLAGS = 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) diff --git a/bsp/k210/applications/SConscript b/bsp/k210/applications/SConscript new file mode 100644 index 0000000000..c583d3016e --- /dev/null +++ b/bsp/k210/applications/SConscript @@ -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') diff --git a/bsp/k210/applications/main.c b/bsp/k210/applications/main.c new file mode 100644 index 0000000000..b18163ef8d --- /dev/null +++ b/bsp/k210/applications/main.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/09/30 Bernard The first version + */ + +#include +#include + +int main(void) +{ + rt_kprintf("Hello, world\n"); + + return 0; +} diff --git a/bsp/k210/applications/mnt.c b/bsp/k210/applications/mnt.c new file mode 100644 index 0000000000..d528a7424d --- /dev/null +++ b/bsp/k210/applications/mnt.c @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + */ + +#include + +int mnt_init(void) +{ + return 0; +} diff --git a/bsp/k210/driver/Kconfig b/bsp/k210/driver/Kconfig new file mode 100644 index 0000000000..902d7c2444 --- /dev/null +++ b/bsp/k210/driver/Kconfig @@ -0,0 +1,25 @@ +config BSP_USING_UART_HS + bool "Enable High Speed UART" + default y + +config BSP_USING_UART1 + bool "Enable UART1 (GPIO0/1)" + default n + +config BSP_USING_UART2 + bool "Enable UART2 (GPIO0/1)" + default n + +config BSP_USING_UART3 + bool "Enable UART3 (GPIO0/1)" + default n + +config BSP_USING_I2C1 + bool "Enable I2C1 (GPIO0/1)" + select RT_USING_I2C + default n + +config BSP_USING_SPI1 + bool "Enable SPI1 (GPIO0/1)" + select RT_USING_SPI + default n diff --git a/bsp/k210/driver/SConscript b/bsp/k210/driver/SConscript new file mode 100644 index 0000000000..3ea01aa83f --- /dev/null +++ b/bsp/k210/driver/SConscript @@ -0,0 +1,38 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Split(''' +board.c +drv_uart.c +''') +CPPPATH = [cwd] + +if GetDepend('RT_USING_PIN'): + src += ['drv_gpio.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_RTC'): + src += ['drv_rtc.c'] + +if GetDepend('RT_USING_WDT'): + src += ['drv_wdt.c'] + +group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/k210/driver/board.c b/bsp/k210/driver/board.c new file mode 100644 index 0000000000..aac2adbc49 --- /dev/null +++ b/bsp/k210/driver/board.c @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + */ + +#include +#include + +#include "board.h" +#include "tick.h" + +#include "drv_uart.h" + +#include "encoding.h" +#include "fpioa.h" +#include "dmac.h" + +#include "uarths.h" +void rt_hw_console_output(const char *str) +{ + uarths_puts(str); + return ; +} + +void init_bss(void) +{ + unsigned int *dst; + + dst = &__bss_start; + while (dst < &__bss_end) + { + *dst++ = 0; + } +} + +void cpu_entry(int cpuid) +{ + extern void entry(void); + + /* disable global interrupt */ + rt_hw_interrupt_disable(); + if (cpuid == 0) + { + init_bss(); + entry(); + } + else + { + while (1) ; + } +} + +#include +#include + +int freq(void) +{ + rt_uint64_t value = 0; + + value = sysctl_clock_get_freq(SYSCTL_CLOCK_PLL0); + rt_kprintf("PLL0: %d\n", value); + value = sysctl_clock_get_freq(SYSCTL_CLOCK_PLL1); + rt_kprintf("PLL1: %d\n", value); + value = sysctl_clock_get_freq(SYSCTL_CLOCK_PLL2); + rt_kprintf("PLL2: %d\n", value); + value = sysctl_clock_get_freq(SYSCTL_CLOCK_CPU); + rt_kprintf("CPU : %d\n", value); + value = sysctl_clock_get_freq(SYSCTL_CLOCK_APB0); + rt_kprintf("APB0: %d\n", value); + value = sysctl_clock_get_freq(SYSCTL_CLOCK_APB1); + rt_kprintf("APB1: %d\n", value); + value = sysctl_clock_get_freq(SYSCTL_CLOCK_APB2); + rt_kprintf("APB2: %d\n", value); + value = sysctl_clock_get_freq(SYSCTL_CLOCK_HCLK); + rt_kprintf("HCLK: %d\n", value); + + value = clint_get_time(); + rt_kprintf("mtime: %d\n", value); + + return 0; +} +MSH_CMD_EXPORT(freq, show freq info); + +void rt_hw_board_init(void) +{ + /* Init FPIOA */ + fpioa_init(); + /* Dmac init */ + dmac_init(); + + /* initalize interrupt */ + rt_hw_interrupt_init(); + /* initialize hardware interrupt */ + rt_hw_uart_init(); + rt_hw_tick_init(); + +#ifdef RT_USING_CONSOLE + /* set console device */ + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); +#endif /* RT_USING_CONSOLE */ + +#ifdef RT_USING_HEAP + rt_kprintf("heap: [0x%08x - 0x%08x]\n", (rt_ubase_t) RT_HW_HEAP_BEGIN, (rt_ubase_t) RT_HW_HEAP_END); + /* initialize memory system */ + rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END); +#endif + +#ifdef RT_USING_COMPONENTS_INIT + rt_components_board_init(); +#endif +} diff --git a/bsp/k210/driver/board.h b/bsp/k210/driver/board.h new file mode 100644 index 0000000000..0d270abd2b --- /dev/null +++ b/bsp/k210/driver/board.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2017-5-30 Bernard the first version + */ + +#ifndef BOARD_H__ +#define BOARD_H__ + +extern unsigned int __bss_start; +extern unsigned int __bss_end; + +#define RT_HW_HEAP_BEGIN (void*)&__bss_end +#define RT_HW_HEAP_END (void*)(0x80000000 + 6 * 1024 * 1024) + +void rt_hw_board_init(void); + +#endif diff --git a/bsp/k210/driver/drv_uart.c b/bsp/k210/driver/drv_uart.c new file mode 100644 index 0000000000..74ba05e203 --- /dev/null +++ b/bsp/k210/driver/drv_uart.c @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + */ + +#include +#include +#include + +#include "board.h" +#include "drv_uart.h" + +#include + +// #include "uart.h" +#include "uarths.h" +#include "plic.h" + +struct device_uart +{ + rt_uint32_t hw_base; + rt_uint32_t irqno; +}; + +static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg); +static rt_err_t uart_control(struct rt_serial_device *serial, int cmd, void *arg); +static int drv_uart_putc(struct rt_serial_device *serial, char c); +static int drv_uart_getc(struct rt_serial_device *serial); + +static void uart_irq_handler(int irqno, void *param); + +const struct rt_uart_ops _uart_ops = +{ + uart_configure, + uart_control, + drv_uart_putc, + drv_uart_getc, + RT_NULL +}; + +/* + * UART Initiation + */ +int rt_hw_uart_init(void) +{ + struct rt_serial_device *serial; + struct device_uart *uart; + struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; + +#ifdef BSP_USING_UART_HS + { + static struct rt_serial_device serial_hs; + static struct device_uart uart_hs; + + serial = &serial_hs; + uart = &uart_hs; + + serial->ops = &_uart_ops; + serial->config = config; + serial->config.baud_rate = 115200; + + uart->hw_base = UARTHS_BASE_ADDR; + uart->irqno = IRQN_UARTHS_INTERRUPT; + + /* initialize UART HS */ + uarths_init(); + + rt_hw_serial_register(serial, + "uarths", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, + uart); + } +#endif + +#ifdef BSP_USING_UART1 + { + static struct rt_serial_device serial1; + static struct device_uart uart1; + + serial = &serial1; + uart = &uart1; + + serial->ops = &_uart_ops; + serial->config = config; + serial->config.baud_rate = 115200; + + uart->hw_base = UART1_BASE_ADDR; + uart->irqno = IRQN_UART1_INTERRUPT; + + rt_hw_serial_register(serial, + "uarths", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, + uart); + } +#endif + +#ifdef BSP_USING_UART2 +#endif + +#ifdef BSP_USING_UART3 +#endif + + return 0; +} + +/* + * UART interface + */ +static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg) +{ + rt_uint32_t baud_div; + struct device_uart *uart; + + RT_ASSERT(serial != RT_NULL); + serial->config = *cfg; + + uart = serial->parent.user_data; + RT_ASSERT(uart != RT_NULL); + + /* Init UART Hardware */ + + /* Enable UART clock */ + + /* Set both receiver and transmitter in UART mode (not SIR) */ + + /* Set databits, stopbits and parity. (8-bit data, 1 stopbit, no parity) */ + + /* set baudrate */ + + return (RT_EOK); +} + +static rt_err_t uart_control(struct rt_serial_device *serial, int cmd, void *arg) +{ + struct device_uart *uart; + + uart = serial->parent.user_data; + + RT_ASSERT(uart != RT_NULL); + + switch (cmd) + { + case RT_DEVICE_CTRL_CLR_INT: + /* Disable the UART Interrupt */ + rt_hw_interrupt_mask(uart->irqno); + break; + + case RT_DEVICE_CTRL_SET_INT: + /* install interrupt */ + rt_hw_interrupt_install(uart->irqno, uart_irq_handler, + serial, serial->parent.parent.name); + rt_hw_interrupt_umask(uart->irqno); + break; + } + + return (RT_EOK); +} + +static int drv_uart_putc(struct rt_serial_device *serial, char c) +{ + struct device_uart *uart; + + uart = serial->parent.user_data; + if (uart->hw_base == UARTHS_BASE_ADDR) + { + uarths_putchar(c); + } + else + { + /* other uart */ + } + + return (1); +} + +static int drv_uart_getc(struct rt_serial_device *serial) +{ + int ret = -1; + struct device_uart *uart = serial->parent.user_data; + + if (uart->hw_base == UARTHS_BASE_ADDR) + { + ret = uarths_getc(); + if (ret != EOF) return ret; + } + + /* Receive Data Available */ + + return (-1); +} + +/* UART ISR */ +static void uart_irq_handler(int irqno, void *param) +{ + rt_ubase_t isr; + struct rt_serial_device *serial = (struct rt_serial_device *)param; + struct device_uart *uart = serial->parent.user_data; + + /* read interrupt status and clear it */ + if (uart->hw_base == UARTHS_BASE_ADDR) + { + if (uarths->ip.rxwm) + rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); + } +} diff --git a/bsp/k210/driver/drv_uart.h b/bsp/k210/driver/drv_uart.h new file mode 100644 index 0000000000..deac702fe1 --- /dev/null +++ b/bsp/k210/driver/drv_uart.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/10/01 Bernard The first version + */ + +#ifndef __DRV_UART_H__ +#define __DRV_UART_H__ + +int rt_hw_uart_init(void); + +#endif /* __DRV_UART_H__ */ diff --git a/bsp/k210/images/flash.png b/bsp/k210/images/flash.png new file mode 100644 index 0000000000..2a3c6eaf61 Binary files /dev/null and b/bsp/k210/images/flash.png differ diff --git a/bsp/k210/images/k210.png b/bsp/k210/images/k210.png new file mode 100644 index 0000000000..2d59f3aa58 Binary files /dev/null and b/bsp/k210/images/k210.png differ diff --git a/bsp/k210/link.lds b/bsp/k210/link.lds new file mode 100644 index 0000000000..851861f19f --- /dev/null +++ b/bsp/k210/link.lds @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + */ + +INCLUDE "link_stacksize.lds" + +/* + * The OUTPUT_ARCH command specifies the machine architecture where the + * argument is one of the names used in the Kendryte library. + */ +OUTPUT_ARCH( "riscv" ) + +MEMORY +{ + /* 6M SRAM */ + SRAM : ORIGIN = 0x80000000, LENGTH = 0x600000 +} + +ENTRY(_start) +SECTIONS +{ + . = 0x80000000 ; + + /* __STACKSIZE__ = 4096; */ + + .start : + { + *(.start); + } > SRAM + + . = ALIGN(4); + + .text : + { + *(.text) /* remaining code */ + *(.text.*) /* remaining code */ + *(.rodata) /* read-only data (constants) */ + *(.rodata*) + *(.glue_7) + *(.glue_7t) + *(.gnu.linkonce.t*) + + /* section information for finsh shell */ + . = ALIGN(4); + __fsymtab_start = .; + KEEP(*(FSymTab)) + __fsymtab_end = .; + . = ALIGN(4); + __vsymtab_start = .; + KEEP(*(VSymTab)) + __vsymtab_end = .; + . = ALIGN(4); + + /* section information for initial. */ + . = ALIGN(4); + __rt_init_start = .; + KEEP(*(SORT(.rti_fn*))) + __rt_init_end = .; + . = ALIGN(4); + + . = ALIGN(4); + _etext = .; + } > SRAM + + .eh_frame_hdr : + { + *(.eh_frame_hdr) + *(.eh_frame_entry) + } > SRAM + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > SRAM + + . = ALIGN(4); + + .data : + { + *(.data) + *(.data.*) + + *(.data1) + *(.data1.*) + + . = ALIGN(8); + PROVIDE( __global_pointer$ = . + 0x800 ); + + *(.sdata) + *(.sdata.*) + } > SRAM + + /* stack for dual core */ + .stack : + { + . = ALIGN(64); + __stack_start__ = .; + + . += __STACKSIZE__; + __stack_cpu0 = .; + + . += __STACKSIZE__; + __stack_cpu1 = .; + } > SRAM + + .sbss : + { + __bss_start = .; + *(.sbss) + *(.sbss.*) + *(.dynsbss) + *(.scommon) + } > SRAM + + .bss : + { + *(.bss) + *(.bss.*) + *(.dynbss) + *(COMMON) + __bss_end = .; + } > SRAM + + _end = .; + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + * Symbols in the DWARF debugging sections are relative to the beginning + * of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } +} diff --git a/bsp/k210/link_stacksize.lds b/bsp/k210/link_stacksize.lds new file mode 100644 index 0000000000..1dd893422c --- /dev/null +++ b/bsp/k210/link_stacksize.lds @@ -0,0 +1 @@ +__STACKSIZE__ = 4096; \ No newline at end of file diff --git a/bsp/k210/rtconfig.h b/bsp/k210/rtconfig.h new file mode 100644 index 0000000000..629a34f31c --- /dev/null +++ b/bsp/k210/rtconfig.h @@ -0,0 +1,178 @@ +#ifndef RT_CONFIG_H__ +#define RT_CONFIG_H__ + +/* Automatically generated file; DO NOT EDIT. */ +/* RT-Thread Project Configuration */ + +/* RT-Thread Kernel */ + +#define RT_NAME_MAX 8 +#define RT_ALIGN_SIZE 8 +#define RT_THREAD_PRIORITY_32 +#define RT_THREAD_PRIORITY_MAX 32 +#define RT_TICK_PER_SECOND 100 +#define RT_USING_OVERFLOW_CHECK +#define RT_USING_HOOK +#define RT_USING_IDLE_HOOK +#define RT_IDEL_HOOK_LIST_SIZE 4 +#define IDLE_THREAD_STACK_SIZE 1024 +#define RT_DEBUG +#define RT_DEBUG_INIT_CONFIG +#define RT_DEBUG_INIT 1 + +/* Inter-Thread communication */ + +#define RT_USING_SEMAPHORE +#define RT_USING_MUTEX +#define RT_USING_EVENT +#define RT_USING_MAILBOX +#define RT_USING_MESSAGEQUEUE + +/* Memory Management */ + +#define RT_USING_MEMPOOL +#define RT_USING_SMALL_MEM +#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 0x40000 +#define ARCH_CPU_64BIT +#define ARCH_RISCV +#define ARCH_RISCV64 + +/* RT-Thread Components */ + +#define RT_USING_COMPONENTS_INIT +#define RT_USING_USER_MAIN +#define RT_MAIN_THREAD_STACK_SIZE 8192 +#define RT_MAIN_THREAD_PRIORITY 10 + +/* C++ features */ + + +/* Command shell */ + +#define RT_USING_FINSH +#define FINSH_THREAD_NAME "tshell" +#define FINSH_USING_HISTORY +#define FINSH_HISTORY_LINES 5 +#define FINSH_USING_SYMTAB +#define FINSH_USING_DESCRIPTION +#define FINSH_THREAD_PRIORITY 20 +#define FINSH_THREAD_STACK_SIZE 4096 +#define FINSH_CMD_SIZE 80 +#define FINSH_USING_MSH +#define FINSH_USING_MSH_DEFAULT +#define FINSH_USING_MSH_ONLY +#define FINSH_ARG_MAX 10 + +/* Device virtual file system */ + +#define RT_USING_DFS +#define DFS_USING_WORKDIR +#define DFS_FILESYSTEMS_MAX 4 +#define DFS_FILESYSTEM_TYPES_MAX 4 +#define DFS_FD_MAX 16 +#define RT_USING_DFS_DEVFS + +/* Device Drivers */ + +#define RT_USING_DEVICE_IPC +#define RT_PIPE_BUFSZ 512 +#define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA +#define RT_USING_PIN + +/* Using WiFi */ + + +/* Using USB */ + + +/* POSIX layer and C standard library */ + +#define RT_USING_LIBC +#define RT_USING_POSIX + +/* Network */ + +/* Socket abstraction layer */ + + +/* light weight TCP/IP stack */ + + +/* Modbus master and slave stack */ + + +/* AT commands */ + + +/* VBUS(Virtual Software BUS) */ + + +/* Utilities */ + + +/* RT-Thread online packages */ + +/* IoT - internet of things */ + + +/* Wi-Fi */ + +/* Marvell WiFi */ + + +/* Wiced WiFi */ + + +/* IoT Cloud */ + + +/* security packages */ + + +/* language packages */ + + +/* multimedia packages */ + + +/* tools packages */ + + +/* system packages */ + + +/* peripheral libraries and drivers */ + +#define PKG_USING_KENDRYTE_SDK +#define PKG_USING_KENDRYTE_SDK_V052 + +/* miscellaneous packages */ + + +/* sample package */ + +/* samples: kernel and components samples */ + + +/* example package: hello */ + + +/* Privated Packages of RealThread */ + + +/* Network Utilities */ + +#define BOARD_K210_EVB +#define BSP_USING_UART_HS +#define __STACKSIZE__ 4096 + +#endif diff --git a/bsp/k210/rtconfig.py b/bsp/k210/rtconfig.py new file mode 100644 index 0000000000..c2df896f4c --- /dev/null +++ b/bsp/k210/rtconfig.py @@ -0,0 +1,58 @@ +import os + +# toolchains options +ARCH ='risc-v' +CPU ='k210' +CROSS_TOOL ='gcc' + +if os.getenv('RTT_ROOT'): + RTT_ROOT = os.getenv('RTT_ROOT') +else: + RTT_ROOT = r'rt-thread' + +if os.getenv('RTT_CC'): + CROSS_TOOL = os.getenv('RTT_CC') + +if CROSS_TOOL == 'gcc': + PLATFORM = 'gcc' + EXEC_PATH = r'/opt/riscv64-unknown-elf-gcc-2018.07.0-x86_64-linux-ubuntu14/bin' +else: + print('Please make sure your toolchains is GNU GCC!') + exit(0) + +if os.getenv('RTT_EXEC_PATH'): + EXEC_PATH = os.getenv('RTT_EXEC_PATH') + +BUILD = 'release' + +if PLATFORM == 'gcc': + # toolchains + PREFIX = 'riscv-none-embed-' + # PREFIX = 'riscv64-unknown-elf-' + CC = PREFIX + 'gcc' + CXX = PREFIX + 'g++' + AS = PREFIX + 'gcc' + AR = PREFIX + 'ar' + LINK = PREFIX + 'gcc' + TARGET_EXT = 'elf' + SIZE = PREFIX + 'size' + OBJDUMP = PREFIX + 'objdump' + OBJCPY = PREFIX + 'objcopy' + + DEVICE = ' -mcmodel=medany' + CFLAGS = DEVICE + ' -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields ' + AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' + LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds' + CPATH = '' + LPATH = '' + + if BUILD == 'debug': + CFLAGS += ' -O0 -ggdb' + AFLAGS += ' -ggdb' + else: + CFLAGS += ' -O2' + + CXXFLAGS = CFLAGS + +DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n' +POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' diff --git a/bsp/lpc408x/.config b/bsp/lpc408x/.config index e10d9ce3f9..eed04f9c32 100644 --- a/bsp/lpc408x/.config +++ b/bsp/lpc408x/.config @@ -121,6 +121,7 @@ CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_USING_CAN=y # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/lpc408x/rtconfig.h b/bsp/lpc408x/rtconfig.h index 650dade6f0..0d5469786f 100644 --- a/bsp/lpc408x/rtconfig.h +++ b/bsp/lpc408x/rtconfig.h @@ -112,6 +112,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_CAN /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/lpc43xx/M0/rtconfig.h b/bsp/lpc43xx/M0/rtconfig.h index c48cf2525c..90531287dd 100644 --- a/bsp/lpc43xx/M0/rtconfig.h +++ b/bsp/lpc43xx/M0/rtconfig.h @@ -75,6 +75,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // #define RT_UART_RX_BUFFER_SIZE 256 // diff --git a/bsp/lpc43xx/M4/rtconfig.h b/bsp/lpc43xx/M4/rtconfig.h index 9bb1b656f2..0b30998cc0 100644 --- a/bsp/lpc43xx/M4/rtconfig.h +++ b/bsp/lpc43xx/M4/rtconfig.h @@ -74,6 +74,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // #define RT_UART_RX_BUFFER_SIZE 256 // diff --git a/bsp/lpc5410x/rtconfig.h b/bsp/lpc5410x/rtconfig.h index bd231931e3..c054bfabba 100644 --- a/bsp/lpc5410x/rtconfig.h +++ b/bsp/lpc5410x/rtconfig.h @@ -68,6 +68,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA //
//
diff --git a/bsp/lpc54114-lite/.config b/bsp/lpc54114-lite/.config index 0b7ccbf108..4fae2a9de6 100644 --- a/bsp/lpc54114-lite/.config +++ b/bsp/lpc54114-lite/.config @@ -138,6 +138,7 @@ CONFIG_RT_USING_DFS_ROMFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/lpc54114-lite/rtconfig.h b/bsp/lpc54114-lite/rtconfig.h index ca76f59014..4fc1054b7b 100644 --- a/bsp/lpc54114-lite/rtconfig.h +++ b/bsp/lpc54114-lite/rtconfig.h @@ -95,6 +95,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_I2C #define RT_USING_I2C_BITOPS #define RT_USING_PIN diff --git a/bsp/lpc54608-LPCXpresso/.config b/bsp/lpc54608-LPCXpresso/.config index 5aff9d0e48..85046e050d 100644 --- a/bsp/lpc54608-LPCXpresso/.config +++ b/bsp/lpc54608-LPCXpresso/.config @@ -136,6 +136,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/lpc54608-LPCXpresso/rtconfig.h b/bsp/lpc54608-LPCXpresso/rtconfig.h index 7738810b58..46855f7713 100644 --- a/bsp/lpc54608-LPCXpresso/rtconfig.h +++ b/bsp/lpc54608-LPCXpresso/rtconfig.h @@ -95,6 +95,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_I2C #define RT_USING_I2C_BITOPS #define RT_USING_PIN diff --git a/bsp/lpc824/rtconfig.h b/bsp/lpc824/rtconfig.h index 1426427b8d..ccc1a76d43 100644 --- a/bsp/lpc824/rtconfig.h +++ b/bsp/lpc824/rtconfig.h @@ -128,6 +128,7 @@ // Using Serial // Using Serial //#define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // // diff --git a/bsp/ls1cdev/.config b/bsp/ls1cdev/.config index e51b00e78e..30d3540c58 100644 --- a/bsp/ls1cdev/.config +++ b/bsp/ls1cdev/.config @@ -133,6 +133,7 @@ CONFIG_RT_DFS_ELM_REENTRANT=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_USING_CAN=y # CONFIG_RT_CAN_USING_HDR is not set # CONFIG_RT_USING_HWTIMER is not set diff --git a/bsp/ls1cdev/rtconfig.h b/bsp/ls1cdev/rtconfig.h index 889d051eef..7e140a731c 100644 --- a/bsp/ls1cdev/rtconfig.h +++ b/bsp/ls1cdev/rtconfig.h @@ -124,6 +124,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_CAN /* RT_CAN_USING_HDR is not set */ /* RT_USING_HWTIMER is not set */ diff --git a/bsp/mb9bf506r/rtconfig.h b/bsp/mb9bf506r/rtconfig.h index fa8f5a3014..9499045fd1 100644 --- a/bsp/mb9bf506r/rtconfig.h +++ b/bsp/mb9bf506r/rtconfig.h @@ -68,6 +68,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // #define RT_USING_UART0_0 // diff --git a/bsp/nrf51822/rtconfig.h b/bsp/nrf51822/rtconfig.h index 8731f29c30..b41bbdadfa 100644 --- a/bsp/nrf51822/rtconfig.h +++ b/bsp/nrf51822/rtconfig.h @@ -68,6 +68,7 @@ #define RT_USING_DEVICE_IPC // //#define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* SECTION: Console options */ #define RT_USING_CONSOLE diff --git a/bsp/nrf52832/rtconfig.h b/bsp/nrf52832/rtconfig.h index b8710f31c8..64349ec531 100644 --- a/bsp/nrf52832/rtconfig.h +++ b/bsp/nrf52832/rtconfig.h @@ -70,6 +70,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* SECTION: Console options */ #define RT_USING_CONSOLE diff --git a/bsp/nuvoton_m05x/.config b/bsp/nuvoton_m05x/.config index 38716c0942..07830e5c36 100644 --- a/bsp/nuvoton_m05x/.config +++ b/bsp/nuvoton_m05x/.config @@ -104,6 +104,7 @@ CONFIG_FINSH_ARG_MAX=10 CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/nuvoton_m05x/rtconfig.h b/bsp/nuvoton_m05x/rtconfig.h index 4d5ab6b201..db3cc679c8 100644 --- a/bsp/nuvoton_m05x/rtconfig.h +++ b/bsp/nuvoton_m05x/rtconfig.h @@ -96,6 +96,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/nuvoton_m451/rtconfig.h b/bsp/nuvoton_m451/rtconfig.h index 58cdfdcb24..cb4868725c 100644 --- a/bsp/nuvoton_m451/rtconfig.h +++ b/bsp/nuvoton_m451/rtconfig.h @@ -65,6 +65,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* SECTION: Console options */ #define RT_USING_CONSOLE diff --git a/bsp/nuvoton_m487/.config b/bsp/nuvoton_m487/.config index a20bd22939..2e12793338 100644 --- a/bsp/nuvoton_m487/.config +++ b/bsp/nuvoton_m487/.config @@ -118,6 +118,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=64 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/nuvoton_m487/rtconfig.h b/bsp/nuvoton_m487/rtconfig.h index 6e3b9c097e..5eb9dca57e 100644 --- a/bsp/nuvoton_m487/rtconfig.h +++ b/bsp/nuvoton_m487/rtconfig.h @@ -75,6 +75,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 64 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* Using WiFi */ diff --git a/bsp/nuvoton_nuc472/rtconfig.h b/bsp/nuvoton_nuc472/rtconfig.h index dccf59ecc8..9d1268a7ff 100644 --- a/bsp/nuvoton_nuc472/rtconfig.h +++ b/bsp/nuvoton_nuc472/rtconfig.h @@ -66,6 +66,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* SECTION: Console options */ #define RT_USING_CONSOLE diff --git a/bsp/nv32f100x/rtconfig.h b/bsp/nv32f100x/rtconfig.h index 0279e205ae..e5b146528e 100644 --- a/bsp/nv32f100x/rtconfig.h +++ b/bsp/nv32f100x/rtconfig.h @@ -66,6 +66,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_HOOK #define RT_USING_CPU_USAGE /* SECTION: Console options */ diff --git a/bsp/qemu-vexpress-a9/.config b/bsp/qemu-vexpress-a9/.config index f5709ced29..f0ce96e4e2 100644 --- a/bsp/qemu-vexpress-a9/.config +++ b/bsp/qemu-vexpress-a9/.config @@ -143,6 +143,7 @@ CONFIG_RT_USING_DFS_RAMFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/qemu-vexpress-a9/cpu/cpu.c b/bsp/qemu-vexpress-a9/cpu/cpu.c deleted file mode 100644 index 10099809a3..0000000000 --- a/bsp/qemu-vexpress-a9/cpu/cpu.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * File : cpu.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006, RT-Thread Develop Team - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE - * - * Change Logs: - * Date Author Notes - * 2011-09-15 Bernard first version - * 2018-11-22 Jesven add rt_hw_cpu_id() - */ - -#include -#include -#include - -#ifdef RT_USING_SMP -int rt_hw_cpu_id(void) -{ - int cpu_id; - __asm__ volatile ( - "mrc p15, 0, %0, c0, c0, 5" - :"=r"(cpu_id) - ); - cpu_id &= 0xf; - return cpu_id; -}; -#endif - -/** - * @addtogroup ARM CPU - */ -/*@{*/ - -/** shutdown CPU */ -void rt_hw_cpu_shutdown() -{ - rt_uint32_t level; - rt_kprintf("shutdown...\n"); - - level = rt_hw_interrupt_disable(); - while (level) - { - RT_ASSERT(0); - } -} - -/*@}*/ diff --git a/bsp/qemu-vexpress-a9/cpu/cpuport.c b/bsp/qemu-vexpress-a9/cpu/cpuport.c new file mode 100644 index 0000000000..22ba8346da --- /dev/null +++ b/bsp/qemu-vexpress-a9/cpu/cpuport.c @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2011-09-15 Bernard first version + * 2018-11-22 Jesven add rt_hw_cpu_id() + */ + +#include +#include +#include + +#ifdef RT_USING_SMP +int rt_hw_cpu_id(void) +{ + int cpu_id; + __asm__ volatile ( + "mrc p15, 0, %0, c0, c0, 5" + :"=r"(cpu_id) + ); + cpu_id &= 0xf; + return cpu_id; +}; + +void rt_hw_spin_lock(rt_hw_spinlock_t *lock) +{ + unsigned long tmp; + unsigned long newval; + rt_hw_spinlock_t lockval; + + __asm__ __volatile__( + "pld [%0]" + ::"r"(&lock->slock) + ); + + __asm__ __volatile__( + "1: ldrex %0, [%3]\n" + " add %1, %0, %4\n" + " strex %2, %1, [%3]\n" + " teq %2, #0\n" + " bne 1b" + : "=&r" (lockval), "=&r" (newval), "=&r" (tmp) + : "r" (&lock->slock), "I" (1 << 16) + : "cc"); + + while (lockval.tickets.next != lockval.tickets.owner) { + __asm__ __volatile__("wfe":::"memory"); + lockval.tickets.owner = *(volatile unsigned short *)(&lock->tickets.owner); + } + + __asm__ volatile ("dmb":::"memory"); +} + +void rt_hw_spin_unlock(rt_hw_spinlock_t *lock) +{ + __asm__ volatile ("dmb":::"memory"); + lock->tickets.owner++; + __asm__ volatile ("dsb ishst\nsev":::"memory"); +} + +#endif /*RT_USING_SMP*/ + +void idle_wfi(void) +{ + asm volatile ("wfi"); +} + +/** + * @addtogroup ARM CPU + */ +/*@{*/ + +/** shutdown CPU */ +void rt_hw_cpu_shutdown() +{ + rt_uint32_t level; + rt_kprintf("shutdown...\n"); + + level = rt_hw_interrupt_disable(); + while (level) + { + RT_ASSERT(0); + } +} + +/*@}*/ diff --git a/bsp/qemu-vexpress-a9/drivers/board.c b/bsp/qemu-vexpress-a9/drivers/board.c index 26aad5bda1..26445d33f1 100644 --- a/bsp/qemu-vexpress-a9/drivers/board.c +++ b/bsp/qemu-vexpress-a9/drivers/board.c @@ -19,10 +19,8 @@ #define SYS_CTRL __REG32(REALVIEW_SCTL_BASE) -void idle_wfi(void) -{ - asm volatile ("wfi"); -} +extern void idle_wfi(void); +extern void rt_hw_ipi_handler_install(int ipi_vector, rt_isr_handler_t ipi_isr_handler); /** * This function will initialize beaglebone board @@ -40,46 +38,8 @@ void rt_hw_board_init(void) rt_thread_idle_sethook(idle_wfi); #ifdef RT_USING_SMP - /* install IPI interrupt */ - rt_hw_interrupt_install(RT_SCHEDULE_IPI_IRQ, rt_scheduler_ipi_handler, RT_NULL, "ipi"); - rt_hw_interrupt_umask(RT_SCHEDULE_IPI_IRQ); + /* install IPI handle */ + rt_hw_ipi_handler_install(RT_SCHEDULE_IPI, rt_scheduler_ipi_handler); #endif } -#ifdef RT_USING_SMP -void rt_hw_spin_lock(rt_hw_spinlock_t *lock) -{ - unsigned long tmp; - unsigned long newval; - rt_hw_spinlock_t lockval; - - __asm__ __volatile__( - "pld [%0]" - ::"r"(&lock->slock) - ); - - __asm__ __volatile__( - "1: ldrex %0, [%3]\n" - " add %1, %0, %4\n" - " strex %2, %1, [%3]\n" - " teq %2, #0\n" - " bne 1b" - : "=&r" (lockval), "=&r" (newval), "=&r" (tmp) - : "r" (&lock->slock), "I" (1 << 16) - : "cc"); - - while (lockval.tickets.next != lockval.tickets.owner) { - __asm__ __volatile__("wfe":::"memory"); - lockval.tickets.owner = *(volatile unsigned short *)(&lock->tickets.owner); - } - - __asm__ volatile ("dmb":::"memory"); -} - -void rt_hw_spin_unlock(rt_hw_spinlock_t *lock) -{ - __asm__ volatile ("dmb":::"memory"); - lock->tickets.owner++; - __asm__ volatile ("dsb ishst\nsev":::"memory"); -} -#endif /*RT_USING_SMP*/ diff --git a/bsp/qemu-vexpress-a9/drivers/secondary_cpu.c b/bsp/qemu-vexpress-a9/drivers/secondary_cpu.c index b8b5436929..29bb9ec895 100644 --- a/bsp/qemu-vexpress-a9/drivers/secondary_cpu.c +++ b/bsp/qemu-vexpress-a9/drivers/secondary_cpu.c @@ -46,10 +46,6 @@ void secondary_cpu_c_start(void) rt_hw_interrupt_install(IRQ_PBA8_TIMER0_1, rt_hw_timer2_isr, RT_NULL, "tick"); rt_hw_interrupt_umask(IRQ_PBA8_TIMER0_1); - /* install IPI interrupt */ - rt_hw_interrupt_install(RT_SCHEDULE_IPI_IRQ, rt_scheduler_ipi_handler, RT_NULL, "ipi"); - rt_hw_interrupt_umask(RT_SCHEDULE_IPI_IRQ); - rt_system_scheduler_start(); } diff --git a/bsp/qemu-vexpress-a9/rtconfig.h b/bsp/qemu-vexpress-a9/rtconfig.h index 618aa5c599..2ebcd96019 100644 --- a/bsp/qemu-vexpress-a9/rtconfig.h +++ b/bsp/qemu-vexpress-a9/rtconfig.h @@ -134,6 +134,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/qemu-vexpress-gemini/.config b/bsp/qemu-vexpress-gemini/.config index 02c5ee7d12..425f9a1eae 100644 --- a/bsp/qemu-vexpress-gemini/.config +++ b/bsp/qemu-vexpress-gemini/.config @@ -118,6 +118,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/qemu-vexpress-gemini/rtconfig.h b/bsp/qemu-vexpress-gemini/rtconfig.h index a1dcba1248..7218fedca1 100644 --- a/bsp/qemu-vexpress-gemini/rtconfig.h +++ b/bsp/qemu-vexpress-gemini/rtconfig.h @@ -110,6 +110,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/raspi2/.config b/bsp/raspi2/.config index b9827ac3ed..7db26a7cb1 100644 --- a/bsp/raspi2/.config +++ b/bsp/raspi2/.config @@ -108,6 +108,7 @@ CONFIG_FINSH_ARG_MAX=10 CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/raspi2/rtconfig.h b/bsp/raspi2/rtconfig.h index 073c18bed2..d0b692f9ab 100644 --- a/bsp/raspi2/rtconfig.h +++ b/bsp/raspi2/rtconfig.h @@ -100,6 +100,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/realview-a8/rtconfig.h b/bsp/realview-a8/rtconfig.h index 2b196b4466..d06e81a0e1 100644 --- a/bsp/realview-a8/rtconfig.h +++ b/bsp/realview-a8/rtconfig.h @@ -72,6 +72,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // #define RT_UART_RX_BUFFER_SIZE 64 // diff --git a/bsp/rm48x50/rtconfig.h b/bsp/rm48x50/rtconfig.h index a4189b9308..f7d9235a5b 100644 --- a/bsp/rm48x50/rtconfig.h +++ b/bsp/rm48x50/rtconfig.h @@ -70,6 +70,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // #define RT_UART_RX_BUFFER_SIZE 64 //
diff --git a/bsp/rv32m1_vega/ri5cy/.config b/bsp/rv32m1_vega/ri5cy/.config index fec5225b63..d62e37947a 100644 --- a/bsp/rv32m1_vega/ri5cy/.config +++ b/bsp/rv32m1_vega/ri5cy/.config @@ -136,6 +136,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/rx/rtconfig.h b/bsp/rx/rtconfig.h index e1d6cb3fe8..364204696f 100644 --- a/bsp/rx/rtconfig.h +++ b/bsp/rx/rtconfig.h @@ -66,6 +66,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* SECTION: Console options */ #define RT_USING_CONSOLE diff --git a/bsp/samd21/rtconfig.h b/bsp/samd21/rtconfig.h index 1ccf6616a0..c22a5496e7 100644 --- a/bsp/samd21/rtconfig.h +++ b/bsp/samd21/rtconfig.h @@ -68,6 +68,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* SECTION: Console options */ #define RT_USING_CONSOLE diff --git a/bsp/simulator/.config b/bsp/simulator/.config index be55343ce7..dbb69fd390 100644 --- a/bsp/simulator/.config +++ b/bsp/simulator/.config @@ -117,6 +117,7 @@ CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/simulator/rtconfig.h b/bsp/simulator/rtconfig.h index 995ab93c3b..4955172df7 100755 --- a/bsp/simulator/rtconfig.h +++ b/bsp/simulator/rtconfig.h @@ -108,6 +108,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/stm32/libraries/templates/stm32f10x/.config b/bsp/stm32/libraries/templates/stm32f10x/.config index 1bfa29eca5..4a931cf1e2 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/.config +++ b/bsp/stm32/libraries/templates/stm32f10x/.config @@ -110,6 +110,7 @@ CONFIG_FINSH_ARG_MAX=10 CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32/libraries/templates/stm32f10x/rtconfig.h b/bsp/stm32/libraries/templates/stm32f10x/rtconfig.h index f213d2e34b..ed7bf5a5f7 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/rtconfig.h +++ b/bsp/stm32/libraries/templates/stm32f10x/rtconfig.h @@ -76,6 +76,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using WiFi */ diff --git a/bsp/stm32/libraries/templates/stm32f4xx/.config b/bsp/stm32/libraries/templates/stm32f4xx/.config index 1491b26f9a..935757f65a 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/.config +++ b/bsp/stm32/libraries/templates/stm32f4xx/.config @@ -110,6 +110,7 @@ CONFIG_FINSH_ARG_MAX=10 CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.h b/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.h index 2f9f7370d7..21d3064ad0 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.h +++ b/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.h @@ -76,6 +76,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using WiFi */ diff --git a/bsp/stm32/libraries/templates/stm32l4xx/.config b/bsp/stm32/libraries/templates/stm32l4xx/.config index fccf1fe55b..233ed0577f 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/.config +++ b/bsp/stm32/libraries/templates/stm32l4xx/.config @@ -110,6 +110,7 @@ CONFIG_FINSH_ARG_MAX=10 CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.h b/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.h index ceec0bd451..1b16eff99f 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.h +++ b/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.h @@ -76,6 +76,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using WiFi */ diff --git a/bsp/stm32f0x/rtconfig.h b/bsp/stm32f0x/rtconfig.h index bee200136a..0a71690b53 100644 --- a/bsp/stm32f0x/rtconfig.h +++ b/bsp/stm32f0x/rtconfig.h @@ -66,6 +66,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* SECTION: Console options */ #define RT_USING_CONSOLE diff --git a/bsp/stm32f107/.config b/bsp/stm32f107/.config index 855e8b01bd..b8e5092cf1 100644 --- a/bsp/stm32f107/.config +++ b/bsp/stm32f107/.config @@ -7,6 +7,7 @@ # RT-Thread Kernel # CONFIG_RT_NAME_MAX=8 +# CONFIG_RT_USING_SMP is not set CONFIG_RT_ALIGN_SIZE=4 # CONFIG_RT_THREAD_PRIORITY_8 is not set CONFIG_RT_THREAD_PRIORITY_32=y @@ -15,6 +16,7 @@ CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=1000 CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_USING_HOOK=y +CONFIG_RT_USING_IDLE_HOOK=y CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set @@ -61,16 +63,19 @@ CONFIG_RT_USING_DEVICE=y CONFIG_RT_USING_CONSOLE=y CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLE_DEVICE_NAME="uart2" -# CONFIG_RT_USING_MODULE is not set +CONFIG_RT_VER_NUM=0x40000 CONFIG_ARCH_ARM=y CONFIG_ARCH_ARM_CORTEX_M=y CONFIG_ARCH_ARM_CORTEX_M3=y +# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set # # RT-Thread Components # CONFIG_RT_USING_COMPONENTS_INIT=y -# CONFIG_RT_USING_USER_MAIN is not set +CONFIG_RT_USING_USER_MAIN=y +CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048 +CONFIG_RT_MAIN_THREAD_PRIORITY=10 # # C++ features @@ -99,35 +104,7 @@ CONFIG_FINSH_ARG_MAX=10 # # Device virtual file system # -CONFIG_RT_USING_DFS=y -CONFIG_DFS_USING_WORKDIR=y -CONFIG_DFS_FILESYSTEMS_MAX=2 -CONFIG_DFS_FILESYSTEM_TYPES_MAX=2 -CONFIG_DFS_FD_MAX=16 -# CONFIG_RT_USING_DFS_MNTTABLE is not set -CONFIG_RT_USING_DFS_ELMFAT=y - -# -# elm-chan's FatFs, Generic FAT Filesystem Module -# -CONFIG_RT_DFS_ELM_CODE_PAGE=437 -CONFIG_RT_DFS_ELM_WORD_ACCESS=y -# CONFIG_RT_DFS_ELM_USE_LFN_0 is not set -# CONFIG_RT_DFS_ELM_USE_LFN_1 is not set -# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set -CONFIG_RT_DFS_ELM_USE_LFN_3=y -CONFIG_RT_DFS_ELM_USE_LFN=3 -CONFIG_RT_DFS_ELM_MAX_LFN=255 -CONFIG_RT_DFS_ELM_DRIVES=2 -CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512 -# CONFIG_RT_DFS_ELM_USE_ERASE is not set -CONFIG_RT_DFS_ELM_REENTRANT=y -CONFIG_RT_USING_DFS_DEVFS=y -# CONFIG_RT_USING_DFS_ROMFS is not set -# CONFIG_RT_USING_DFS_RAMFS is not set -# CONFIG_RT_USING_DFS_UFFS is not set -# CONFIG_RT_USING_DFS_JFFS2 is not set -# CONFIG_RT_USING_DFS_NFS is not set +# CONFIG_RT_USING_DFS is not set # # Device Drivers @@ -135,21 +112,29 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set # CONFIG_RT_USING_I2C is not set CONFIG_RT_USING_PIN=y +# CONFIG_RT_USING_ADC is not set # CONFIG_RT_USING_PWM is not set # CONFIG_RT_USING_MTD_NOR is not set # CONFIG_RT_USING_MTD_NAND is not set +# CONFIG_RT_USING_MTD is not set +# CONFIG_RT_USING_PM is not set # CONFIG_RT_USING_RTC is not set # CONFIG_RT_USING_SDIO is not set # CONFIG_RT_USING_SPI is not set # CONFIG_RT_USING_WDT is not set -# CONFIG_RT_USING_WIFI is not set # CONFIG_RT_USING_AUDIO is not set +# +# Using WiFi +# +# CONFIG_RT_USING_WIFI is not set + # # Using USB # @@ -161,8 +146,6 @@ CONFIG_RT_USING_PIN=y # CONFIG_RT_USING_LIBC=y # CONFIG_RT_USING_PTHREADS is not set -# CONFIG_RT_USING_POSIX is not set -# CONFIG_RT_USING_LWP is not set # # Network @@ -176,54 +159,7 @@ CONFIG_RT_USING_LIBC=y # # light weight TCP/IP stack # -CONFIG_RT_USING_LWIP=y -# CONFIG_RT_USING_LWIP141 is not set -CONFIG_RT_USING_LWIP202=y -# CONFIG_RT_USING_LWIP_IPV6 is not set -CONFIG_RT_LWIP_IGMP=y -CONFIG_RT_LWIP_ICMP=y -# CONFIG_RT_LWIP_SNMP is not set -CONFIG_RT_LWIP_DNS=y -CONFIG_RT_LWIP_DHCP=y -CONFIG_IP_SOF_BROADCAST=1 -CONFIG_IP_SOF_BROADCAST_RECV=1 - -# -# Static IPv4 Address -# -CONFIG_RT_LWIP_IPADDR="192.168.1.30" -CONFIG_RT_LWIP_GWADDR="192.168.1.1" -CONFIG_RT_LWIP_MSKADDR="255.255.255.0" -CONFIG_RT_LWIP_UDP=y -CONFIG_RT_LWIP_TCP=y -# CONFIG_RT_LWIP_RAW is not set -# CONFIG_RT_LWIP_PPP is not set -CONFIG_RT_MEMP_NUM_NETCONN=8 -CONFIG_RT_LWIP_PBUF_NUM=16 -CONFIG_RT_LWIP_RAW_PCB_NUM=4 -CONFIG_RT_LWIP_UDP_PCB_NUM=4 -CONFIG_RT_LWIP_TCP_PCB_NUM=4 -CONFIG_RT_LWIP_TCP_SEG_NUM=40 -CONFIG_RT_LWIP_TCP_SND_BUF=8196 -CONFIG_RT_LWIP_TCP_WND=8196 -CONFIG_RT_LWIP_TCPTHREAD_PRIORITY=10 -CONFIG_RT_LWIP_TCPTHREAD_MBOX_SIZE=8 -CONFIG_RT_LWIP_TCPTHREAD_STACKSIZE=1024 -# CONFIG_LWIP_NO_RX_THREAD is not set -# CONFIG_LWIP_NO_TX_THREAD is not set -CONFIG_RT_LWIP_ETHTHREAD_PRIORITY=12 -CONFIG_RT_LWIP_ETHTHREAD_STACKSIZE=1024 -CONFIG_RT_LWIP_ETHTHREAD_MBOX_SIZE=8 -# CONFIG_RT_LWIP_REASSEMBLY_FRAG is not set -CONFIG_LWIP_NETIF_STATUS_CALLBACK=1 -CONFIG_SO_REUSE=1 -CONFIG_LWIP_SO_RCVTIMEO=1 -CONFIG_LWIP_SO_SNDTIMEO=1 -CONFIG_LWIP_SO_RCVBUF=1 -# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set -CONFIG_LWIP_NETIF_LOOPBACK=0 -# CONFIG_RT_LWIP_STATS is not set -# CONFIG_RT_LWIP_DEBUG is not set +# CONFIG_RT_USING_LWIP is not set # # Modbus master and slave stack @@ -234,7 +170,6 @@ CONFIG_LWIP_NETIF_LOOPBACK=0 # AT commands # # CONFIG_RT_USING_AT is not set -# CONFIG_LWIP_USING_DHCPD is not set # # VBUS(Virtual Software BUS) @@ -246,12 +181,15 @@ CONFIG_LWIP_NETIF_LOOPBACK=0 # # CONFIG_RT_USING_LOGTRACE is not set # CONFIG_RT_USING_RYM is not set +# CONFIG_RT_USING_ULOG is not set +# CONFIG_RT_USING_UTEST is not set # # ARM CMSIS # # CONFIG_RT_USING_CMSIS_OS is not set CONFIG_RT_USING_RTT_CMSIS=y +# CONFIG_RT_USING_LWP is not set # # RT-Thread online packages @@ -262,6 +200,7 @@ CONFIG_RT_USING_RTT_CMSIS=y # # CONFIG_PKG_USING_PAHOMQTT is not set # CONFIG_PKG_USING_WEBCLIENT is not set +# CONFIG_PKG_USING_WEBNET is not set # CONFIG_PKG_USING_MONGOOSE is not set # CONFIG_PKG_USING_WEBTERMINAL is not set # CONFIG_PKG_USING_CJSON is not set @@ -287,6 +226,7 @@ CONFIG_RT_USING_RTT_CMSIS=y # CONFIG_PKG_USING_NOPOLL is not set # CONFIG_PKG_USING_NETUTILS is not set # CONFIG_PKG_USING_AT_DEVICE is not set +# CONFIG_PKG_USING_WIZNET is not set # # IoT Cloud @@ -294,6 +234,8 @@ CONFIG_RT_USING_RTT_CMSIS=y # CONFIG_PKG_USING_ONENET is not set # CONFIG_PKG_USING_GAGENT_CLOUD is not set # CONFIG_PKG_USING_ALI_IOTKIT is not set +# CONFIG_PKG_USING_AZURE is not set +# CONFIG_PKG_USING_TENCENT_IOTKIT is not set # # security packages @@ -322,6 +264,9 @@ CONFIG_RT_USING_RTT_CMSIS=y # CONFIG_PKG_USING_EASYFLASH is not set # CONFIG_PKG_USING_EASYLOGGER is not set # CONFIG_PKG_USING_SYSTEMVIEW is not set +# CONFIG_PKG_USING_RDB is not set +# CONFIG_PKG_USING_QRCODE is not set +# CONFIG_PKG_USING_ULOG_EASYFLASH is not set # # system packages @@ -335,14 +280,24 @@ CONFIG_RT_USING_RTT_CMSIS=y # CONFIG_PKG_USING_SQLITE is not set # CONFIG_PKG_USING_RTI is not set # CONFIG_PKG_USING_LITTLEVGL2RTT is not set +# CONFIG_PKG_USING_CMSIS is not set +# CONFIG_PKG_USING_DFS_YAFFS is not set +# CONFIG_PKG_USING_LITTLEFS is not set # # peripheral libraries and drivers # -# CONFIG_PKG_USING_STM32F4_HAL is not set -# CONFIG_PKG_USING_STM32F4_DRIVERS is not set # CONFIG_PKG_USING_REALTEK_AMEBA is not set # CONFIG_PKG_USING_SHT2X is not set +# CONFIG_PKG_USING_AHT10 is not set +# CONFIG_PKG_USING_AP3216C is not set +# CONFIG_PKG_USING_STM32_SDIO is not set +# CONFIG_PKG_USING_ICM20608 is not set +# CONFIG_PKG_USING_U8G2 is not set +# CONFIG_PKG_USING_BUTTON is not set +# CONFIG_PKG_USING_MPU6XXX is not set +# CONFIG_PKG_USING_PCF8574 is not set +# CONFIG_PKG_USING_KENDRYTE_SDK is not set # # miscellaneous packages @@ -356,17 +311,19 @@ CONFIG_RT_USING_RTT_CMSIS=y # CONFIG_PKG_USING_CANFESTIVAL is not set # CONFIG_PKG_USING_ZLIB is not set # CONFIG_PKG_USING_DSTR is not set +# CONFIG_PKG_USING_TINYFRAME is not set # -# sample package -# -# CONFIG_PKG_USING_SAMPLES is not set - -# -# example package: hello +# samples: kernel and components samples # +# CONFIG_PKG_USING_KERNEL_SAMPLES is not set +# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set +# CONFIG_PKG_USING_NETWORK_SAMPLES is not set +# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set # CONFIG_PKG_USING_HELLO is not set CONFIG_SOC_STM32F1=y # CONFIG_RT_USING_UART1 is not set CONFIG_RT_USING_UART2=y # CONFIG_RT_USING_UART3 is not set +# CONFIG_BSP_USING_RTC is not set +CONFIG_BSP_USING_PIN=y diff --git a/bsp/stm32f107/applications/application.c b/bsp/stm32f107/applications/application.c deleted file mode 100644 index f220cb4917..0000000000 --- a/bsp/stm32f107/applications/application.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2009-01-05 Bernard the first version - * 2018-08-17 whj remove finsh_set_device add components - */ - -/** - * @addtogroup STM32 - */ -/*@{*/ - -#include -#include - -#ifdef RT_USING_DFS -#include -#include -#endif - -#ifdef RT_USING_LWIP -#include -#include -extern int lwip_system_init(void); -#endif - -#ifdef RT_USING_FINSH -#include -#include -#endif - -void rt_init_thread_entry(void* parameter) -{ -#ifdef RT_USING_COMPONENTS_INIT - /* initialization RT-Thread Components */ - rt_components_init(); -#endif - - { - extern void rt_platform_init(void); - rt_platform_init(); - } - - /* Filesystem Initialization */ -#if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT) - /* initialize the device file system */ - dfs_init(); - - /* initialize the elm chan FatFS file system*/ - elm_init(); - - /* mount sd card fat partition 1 as root directory */ - if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) - { - rt_kprintf("File System initialized!\n"); - } - else - { - rt_kprintf("File System initialzation failed!\n"); - } -#endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */ - -#ifdef RT_USING_LWIP - /* initialize lwip stack */ - /* register ethernetif device */ - eth_system_device_init(); - - /* initialize lwip system */ - lwip_system_init(); - rt_kprintf("TCP/IP initialized!\n"); -#endif - -} - -int rt_application_init(void) -{ - rt_thread_t tid; - - tid = rt_thread_create("init", - rt_init_thread_entry, RT_NULL, - 2048, RT_THREAD_PRIORITY_MAX/3, 20); - if (tid != RT_NULL) rt_thread_startup(tid); - - return 0; -} - -/*@}*/ diff --git a/bsp/stm32f107/applications/main.c b/bsp/stm32f107/applications/main.c new file mode 100644 index 0000000000..bf677172ad --- /dev/null +++ b/bsp/stm32f107/applications/main.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2009-01-05 Bernard the first version + * 2018-08-17 whj remove finsh_set_device add components + * 2018-12-17 whj Change the user interface to main + */ + +/** + * @addtogroup STM32 + */ +/*@{*/ + +#include +#include +#include + +int main(void) +{ + /* user app entry */ + return RT_EOK; +} + +/*@}*/ diff --git a/bsp/stm32f107/applications/startup.c b/bsp/stm32f107/applications/startup.c deleted file mode 100644 index d64943c32b..0000000000 --- a/bsp/stm32f107/applications/startup.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2006-08-31 Bernard first implementation - * 2011-06-05 Bernard modify for STM32F107 version - */ - -#include -#include -#include "board.h" - -/** - * @addtogroup STM32 - */ - -/*@{*/ - -extern int rt_application_init(void); - -#if defined(__CC_ARM) || defined(__CLANG_ARM) -extern int Image$$RW_IRAM1$$ZI$$Limit; -#define STM32_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit) -#elif __ICCARM__ -#pragma section="HEAP" -#define STM32_SRAM_BEGIN (__segment_end("HEAP")) -#else -extern int __bss_end; -#define STM32_SRAM_BEGIN (&__bss_end) -#endif - -/******************************************************************************* -* Function Name : assert_failed -* Description : Reports the name of the source file and the source line number -* where the assert error has occurred. -* Input : - file: pointer to the source file name -* - line: assert error line source number -* Output : None -* Return : None -*******************************************************************************/ -void assert_failed(u8* file, u32 line) -{ - rt_kprintf("\n\r Wrong parameter value detected on\r\n"); - rt_kprintf(" file %s\r\n", file); - rt_kprintf(" line %d\r\n", line); - - while (1) ; -} - -/** - * This function will startup RT-Thread RTOS. - */ -void rtthread_startup(void) -{ - /* init board */ - rt_hw_board_init(); - - /* show version */ - rt_show_version(); - - /* init tick */ - rt_system_tick_init(); - - /* init kernel object */ - rt_system_object_init(); - - /* init timer system */ - rt_system_timer_init(); - -#ifdef RT_USING_HEAP - rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END); -#endif - - /* init scheduler system */ - rt_system_scheduler_init(); - - /* init application */ - rt_application_init(); - - /* init timer thread */ - rt_system_timer_thread_init(); - - /* init idle thread */ - rt_thread_idle_init(); - - /* start scheduler */ - rt_system_scheduler_start(); - - /* never reach here */ - return ; -} - -int main(void) -{ - /* disable interrupt first */ - rt_hw_interrupt_disable(); - - /* startup RT-Thread RTOS */ - rtthread_startup(); - - return 0; -} - -/*@}*/ diff --git a/bsp/stm32f107/drivers/board.c b/bsp/stm32f107/drivers/board.c index 9013e5d07c..8896047d1f 100644 --- a/bsp/stm32f107/drivers/board.c +++ b/bsp/stm32f107/drivers/board.c @@ -6,7 +6,7 @@ * Change Logs: * Date Author Notes * 2009-01-05 Bernard first implementation - * 2018-08-17 whj add to new rt_console_set_device + * 2018-08-17 whj add to new rt_console_set_device */ #include @@ -44,13 +44,13 @@ void NVIC_Configuration(void) */ void SysTick_Handler(void) { - /* enter interrupt */ - rt_interrupt_enter(); + /* enter interrupt */ + rt_interrupt_enter(); - rt_tick_increase(); + rt_tick_increase(); - /* leave interrupt */ - rt_interrupt_leave(); + /* leave interrupt */ + rt_interrupt_leave(); } /** @@ -64,14 +64,18 @@ void rt_hw_board_init(void) /* Configure the SysTick */ SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND ); - rt_components_board_init(); - +#ifdef RT_USING_HEAP + rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END); +#endif + + rt_components_board_init(); + rt_hw_usart_init(); #ifdef RT_USING_CONSOLE rt_console_set_device(RT_CONSOLE_DEVICE_NAME); #endif - + } /*@}*/ diff --git a/bsp/stm32f107/drivers/board.h b/bsp/stm32f107/drivers/board.h index 9b5dff53e3..cd9187fe1a 100644 --- a/bsp/stm32f107/drivers/board.h +++ b/bsp/stm32f107/drivers/board.h @@ -36,7 +36,17 @@ #define STM32_SRAM_SIZE 64 #define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024) -#define RT_USING_UART1 +#if defined(__CC_ARM) || defined(__CLANG_ARM) +extern int Image$$RW_IRAM1$$ZI$$Limit; +#define STM32_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit) +#elif __ICCARM__ +#pragma section="HEAP" +#define STM32_SRAM_BEGIN (__segment_end("HEAP")) +#else +extern int __bss_end; +#define STM32_SRAM_BEGIN (&__bss_end) +#endif + #define RT_USING_SPI1 void rt_hw_board_init(void); diff --git a/bsp/stm32f107/drivers/stm32f10x_conf.h b/bsp/stm32f107/drivers/stm32f10x_conf.h index 69b3fd49c9..6f5c6cdff0 100644 --- a/bsp/stm32f107/drivers/stm32f10x_conf.h +++ b/bsp/stm32f107/drivers/stm32f10x_conf.h @@ -51,7 +51,7 @@ /* Exported constants --------------------------------------------------------*/ /* Uncomment the line below to expanse the "assert_param" macro in the Standard Peripheral Library drivers code */ -#define USE_FULL_ASSERT 1 +/*#define USE_FULL_ASSERT 1*/ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT diff --git a/bsp/stm32f107/project.uvprojx b/bsp/stm32f107/project.uvprojx index 27a78833df..e12a678b75 100644 --- a/bsp/stm32f107/project.uvprojx +++ b/bsp/stm32f107/project.uvprojx @@ -346,7 +346,7 @@ STM32F10X_CL, RT_USING_ARM_LIBC, USE_STDPERIPH_DRIVER - applications;.;drivers;Libraries\STM32F10x_StdPeriph_Driver\inc;Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x;..\..\components\CMSIS\Include;..\..\include;..\..\libcpu\arm\cortex-m3;..\..\libcpu\arm\common;..\..\components\dfs\include;..\..\components\dfs\filesystems\devfs;..\..\components\dfs\filesystems\elmfat;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\libc\compilers\armlibc;..\..\components\net\lwip-2.0.2\src;..\..\components\net\lwip-2.0.2\src\include;..\..\components\net\lwip-2.0.2\src\include\ipv4;..\..\components\net\lwip-2.0.2\src\arch\include;..\..\components\net\lwip-2.0.2\src\include\netif;..\..\components\net\lwip-2.0.2\src\include\posix + applications;.;drivers;Libraries\STM32F10x_StdPeriph_Driver\inc;Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x;..\..\components\CMSIS\Include;..\..\include;..\..\libcpu\arm\cortex-m3;..\..\libcpu\arm\common;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\libc\compilers\armlibc;..\..\components\libc\compilers\common @@ -387,16 +387,9 @@ Applications - application.c + main.c 1 - applications\application.c - - - - - startup.c - 1 - applications\startup.c + applications\main.c @@ -430,13 +423,6 @@ drivers\platform.c - - - stm32_eth.c - 1 - drivers\stm32_eth.c - - gpio.c @@ -639,6 +625,13 @@ ..\..\src\components.c + + + cpu.c + 1 + ..\..\src\cpu.c + + device.c @@ -769,65 +762,6 @@ - - Filesystem - - - dfs.c - 1 - ..\..\components\dfs\src\dfs.c - - - - - dfs_file.c - 1 - ..\..\components\dfs\src\dfs_file.c - - - - - dfs_fs.c - 1 - ..\..\components\dfs\src\dfs_fs.c - - - - - dfs_posix.c - 1 - ..\..\components\dfs\src\dfs_posix.c - - - - - devfs.c - 1 - ..\..\components\dfs\filesystems\devfs\devfs.c - - - - - dfs_elm.c - 1 - ..\..\components\dfs\filesystems\elmfat\dfs_elm.c - - - - - ff.c - 1 - ..\..\components\dfs\filesystems\elmfat\ff.c - - - - - ccsbcs.c - 1 - ..\..\components\dfs\filesystems\elmfat\option\ccsbcs.c - - - DeviceDrivers @@ -865,6 +799,13 @@ ..\..\components\drivers\src\pipe.c + + + ringblk_buf.c + 1 + ..\..\components\drivers\src\ringblk_buf.c + + ringbuffer.c @@ -1018,13 +959,6 @@ ..\..\components\libc\compilers\armlibc\mem_std.c - - - stdio.c - 1 - ..\..\components\libc\compilers\armlibc\stdio.c - - stubs.c @@ -1039,259 +973,11 @@ ..\..\components\libc\compilers\armlibc\time.c - - - lwIP - sys_arch.c + gmtime_r.c 1 - ..\..\components\net\lwip-2.0.2\src\arch\sys_arch.c - - - - - api_lib.c - 1 - ..\..\components\net\lwip-2.0.2\src\api\api_lib.c - - - - - api_msg.c - 1 - ..\..\components\net\lwip-2.0.2\src\api\api_msg.c - - - - - err.c - 1 - ..\..\components\net\lwip-2.0.2\src\api\err.c - - - - - netbuf.c - 1 - ..\..\components\net\lwip-2.0.2\src\api\netbuf.c - - - - - netdb.c - 1 - ..\..\components\net\lwip-2.0.2\src\api\netdb.c - - - - - netifapi.c - 1 - ..\..\components\net\lwip-2.0.2\src\api\netifapi.c - - - - - sockets.c - 1 - ..\..\components\net\lwip-2.0.2\src\api\sockets.c - - - - - tcpip.c - 1 - ..\..\components\net\lwip-2.0.2\src\api\tcpip.c - - - - - def.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\def.c - - - - - dns.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\dns.c - - - - - inet_chksum.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\inet_chksum.c - - - - - init.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\init.c - - - - - ip.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\ip.c - - - - - memp.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\memp.c - - - - - netif.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\netif.c - - - - - pbuf.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\pbuf.c - - - - - raw.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\raw.c - - - - - stats.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\stats.c - - - - - sys.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\sys.c - - - - - tcp.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\tcp.c - - - - - tcp_in.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\tcp_in.c - - - - - tcp_out.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\tcp_out.c - - - - - timeouts.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\timeouts.c - - - - - udp.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\udp.c - - - - - ethernet.c - 1 - ..\..\components\net\lwip-2.0.2\src\netif\ethernet.c - - - - - ethernetif.c - 1 - ..\..\components\net\lwip-2.0.2\src\netif\ethernetif.c - - - - - lowpan6.c - 1 - ..\..\components\net\lwip-2.0.2\src\netif\lowpan6.c - - - - - autoip.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\ipv4\autoip.c - - - - - dhcp.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\ipv4\dhcp.c - - - - - etharp.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\ipv4\etharp.c - - - - - icmp.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\ipv4\icmp.c - - - - - igmp.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\ipv4\igmp.c - - - - - ip4.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\ipv4\ip4.c - - - - - ip4_addr.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\ipv4\ip4_addr.c - - - - - ip4_frag.c - 1 - ..\..\components\net\lwip-2.0.2\src\core\ipv4\ip4_frag.c + ..\..\components\libc\compilers\common\gmtime_r.c diff --git a/bsp/stm32f107/rtconfig.h b/bsp/stm32f107/rtconfig.h index bc4e8e4232..b05fca7ed4 100644 --- a/bsp/stm32f107/rtconfig.h +++ b/bsp/stm32f107/rtconfig.h @@ -13,6 +13,7 @@ #define RT_TICK_PER_SECOND 1000 #define RT_USING_OVERFLOW_CHECK #define RT_USING_HOOK +#define RT_USING_IDLE_HOOK #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG @@ -38,6 +39,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "uart2" +#define RT_VER_NUM 0x40000 #define ARCH_ARM #define ARCH_ARM_CORTEX_M #define ARCH_ARM_CORTEX_M3 @@ -45,6 +47,9 @@ /* RT-Thread Components */ #define RT_USING_COMPONENTS_INIT +#define RT_USING_USER_MAIN +#define RT_MAIN_THREAD_STACK_SIZE 2048 +#define RT_MAIN_THREAD_PRIORITY 10 /* C++ features */ @@ -66,32 +71,18 @@ /* Device virtual file system */ -#define RT_USING_DFS -#define DFS_USING_WORKDIR -#define DFS_FILESYSTEMS_MAX 2 -#define DFS_FILESYSTEM_TYPES_MAX 2 -#define DFS_FD_MAX 16 -#define RT_USING_DFS_ELMFAT - -/* elm-chan's FatFs, Generic FAT Filesystem Module */ - -#define RT_DFS_ELM_CODE_PAGE 437 -#define RT_DFS_ELM_WORD_ACCESS -#define RT_DFS_ELM_USE_LFN_3 -#define RT_DFS_ELM_USE_LFN 3 -#define RT_DFS_ELM_MAX_LFN 255 -#define RT_DFS_ELM_DRIVES 2 -#define RT_DFS_ELM_MAX_SECTOR_SIZE 512 -#define RT_DFS_ELM_REENTRANT -#define RT_USING_DFS_DEVFS /* Device Drivers */ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN +/* Using WiFi */ + + /* Using USB */ @@ -106,42 +97,6 @@ /* light weight TCP/IP stack */ -#define RT_USING_LWIP -#define RT_USING_LWIP202 -#define RT_LWIP_IGMP -#define RT_LWIP_ICMP -#define RT_LWIP_DNS -#define RT_LWIP_DHCP -#define IP_SOF_BROADCAST 1 -#define IP_SOF_BROADCAST_RECV 1 - -/* Static IPv4 Address */ - -#define RT_LWIP_IPADDR "192.168.1.30" -#define RT_LWIP_GWADDR "192.168.1.1" -#define RT_LWIP_MSKADDR "255.255.255.0" -#define RT_LWIP_UDP -#define RT_LWIP_TCP -#define RT_MEMP_NUM_NETCONN 8 -#define RT_LWIP_PBUF_NUM 16 -#define RT_LWIP_RAW_PCB_NUM 4 -#define RT_LWIP_UDP_PCB_NUM 4 -#define RT_LWIP_TCP_PCB_NUM 4 -#define RT_LWIP_TCP_SEG_NUM 40 -#define RT_LWIP_TCP_SND_BUF 8196 -#define RT_LWIP_TCP_WND 8196 -#define RT_LWIP_TCPTHREAD_PRIORITY 10 -#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8 -#define RT_LWIP_TCPTHREAD_STACKSIZE 1024 -#define RT_LWIP_ETHTHREAD_PRIORITY 12 -#define RT_LWIP_ETHTHREAD_STACKSIZE 1024 -#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8 -#define LWIP_NETIF_STATUS_CALLBACK 1 -#define SO_REUSE 1 -#define LWIP_SO_RCVTIMEO 1 -#define LWIP_SO_SNDTIMEO 1 -#define LWIP_SO_RCVBUF 1 -#define LWIP_NETIF_LOOPBACK 0 /* Modbus master and slave stack */ @@ -196,12 +151,10 @@ /* miscellaneous packages */ -/* sample package */ - - -/* example package: hello */ +/* samples: kernel and components samples */ #define SOC_STM32F1 #define RT_USING_UART2 +#define BSP_USING_PIN #endif diff --git a/bsp/stm32f10x-HAL/.config b/bsp/stm32f10x-HAL/.config index 3f583f6b34..39706cd496 100644 --- a/bsp/stm32f10x-HAL/.config +++ b/bsp/stm32f10x-HAL/.config @@ -91,6 +91,7 @@ CONFIG_FINSH_USING_MSH_ONLY=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32f10x-HAL/rtconfig.h b/bsp/stm32f10x-HAL/rtconfig.h index ad9537c495..84514b603c 100644 --- a/bsp/stm32f10x-HAL/rtconfig.h +++ b/bsp/stm32f10x-HAL/rtconfig.h @@ -83,6 +83,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/stm32f10x/.config b/bsp/stm32f10x/.config index 360fa61320..7b1a9477ab 100644 --- a/bsp/stm32f10x/.config +++ b/bsp/stm32f10x/.config @@ -121,6 +121,7 @@ CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_USING_CAN=y CONFIG_RT_CAN_USING_HDR=y # CONFIG_RT_USING_HWTIMER is not set diff --git a/bsp/stm32f10x/rtconfig.h b/bsp/stm32f10x/rtconfig.h index e41cb5fc10..e1d38b4667 100644 --- a/bsp/stm32f10x/rtconfig.h +++ b/bsp/stm32f10x/rtconfig.h @@ -112,6 +112,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_CAN #define RT_CAN_USING_HDR /* RT_USING_HWTIMER is not set */ diff --git a/bsp/stm32f40x/.config b/bsp/stm32f40x/.config index b7945e1820..a6a47ac6f3 100644 --- a/bsp/stm32f40x/.config +++ b/bsp/stm32f40x/.config @@ -135,6 +135,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32f40x/rtconfig.h b/bsp/stm32f40x/rtconfig.h index 9482d19aa3..c855f42fad 100644 --- a/bsp/stm32f40x/rtconfig.h +++ b/bsp/stm32f40x/rtconfig.h @@ -93,6 +93,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using USB */ diff --git a/bsp/stm32f411-nucleo/.config b/bsp/stm32f411-nucleo/.config index a757505873..f300370a16 100644 --- a/bsp/stm32f411-nucleo/.config +++ b/bsp/stm32f411-nucleo/.config @@ -92,6 +92,7 @@ CONFIG_FINSH_USING_MSH_ONLY=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32f411-nucleo/rtconfig.h b/bsp/stm32f411-nucleo/rtconfig.h index e3b684271c..3a925c78b4 100644 --- a/bsp/stm32f411-nucleo/rtconfig.h +++ b/bsp/stm32f411-nucleo/rtconfig.h @@ -70,6 +70,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* Using USB */ diff --git a/bsp/stm32f429-apollo/.config b/bsp/stm32f429-apollo/.config index 45c584c188..604b56e5b2 100644 --- a/bsp/stm32f429-apollo/.config +++ b/bsp/stm32f429-apollo/.config @@ -132,6 +132,7 @@ CONFIG_RT_USING_DFS_ROMFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32f429-apollo/rtconfig.h b/bsp/stm32f429-apollo/rtconfig.h index 4de160fe17..9c28c2c959 100644 --- a/bsp/stm32f429-apollo/rtconfig.h +++ b/bsp/stm32f429-apollo/rtconfig.h @@ -90,6 +90,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_I2C #define RT_USING_I2C_BITOPS #define RT_USING_MTD_NAND diff --git a/bsp/stm32f429-armfly/.config b/bsp/stm32f429-armfly/.config index be7abc5df7..b001018a9f 100644 --- a/bsp/stm32f429-armfly/.config +++ b/bsp/stm32f429-armfly/.config @@ -134,6 +134,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32f429-armfly/rtconfig.h b/bsp/stm32f429-armfly/rtconfig.h index 0f302ccee4..b570ea5234 100644 --- a/bsp/stm32f429-armfly/rtconfig.h +++ b/bsp/stm32f429-armfly/rtconfig.h @@ -92,6 +92,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_I2C #define RT_USING_I2C_BITOPS #define RT_USING_PIN diff --git a/bsp/stm32f429-disco/.config b/bsp/stm32f429-disco/.config index a2d11a94c3..1a51abcea1 100644 --- a/bsp/stm32f429-disco/.config +++ b/bsp/stm32f429-disco/.config @@ -114,6 +114,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32f429-disco/rtconfig.h b/bsp/stm32f429-disco/rtconfig.h index 962f62bc55..91dd49c872 100644 --- a/bsp/stm32f429-disco/rtconfig.h +++ b/bsp/stm32f429-disco/rtconfig.h @@ -75,6 +75,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_I2C #define RT_USING_I2C_BITOPS #define RT_USING_PIN diff --git a/bsp/stm32f4xx-HAL/.config b/bsp/stm32f4xx-HAL/.config index 8be1f1789f..210efe60dc 100644 --- a/bsp/stm32f4xx-HAL/.config +++ b/bsp/stm32f4xx-HAL/.config @@ -88,6 +88,7 @@ CONFIG_FINSH_USING_MSH_ONLY=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_I2C is not set diff --git a/bsp/stm32f4xx-HAL/rtconfig.h b/bsp/stm32f4xx-HAL/rtconfig.h index 8fe06d171c..e490ee1f31 100644 --- a/bsp/stm32f4xx-HAL/rtconfig.h +++ b/bsp/stm32f4xx-HAL/rtconfig.h @@ -80,6 +80,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_I2C is not set */ diff --git a/bsp/stm32f7-disco/.config b/bsp/stm32f7-disco/.config index 36452791a8..9cdfcfa368 100644 --- a/bsp/stm32f7-disco/.config +++ b/bsp/stm32f7-disco/.config @@ -92,6 +92,7 @@ CONFIG_FINSH_USING_MSH_DEFAULT=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32f7-disco/rtconfig.h b/bsp/stm32f7-disco/rtconfig.h index abbe9d6f59..5d0a04aad7 100644 --- a/bsp/stm32f7-disco/rtconfig.h +++ b/bsp/stm32f7-disco/rtconfig.h @@ -70,6 +70,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using USB */ diff --git a/bsp/stm32h743-nucleo/.config b/bsp/stm32h743-nucleo/.config index bb13ccfc66..1576a11eff 100644 --- a/bsp/stm32h743-nucleo/.config +++ b/bsp/stm32h743-nucleo/.config @@ -116,6 +116,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32h743-nucleo/rtconfig.h b/bsp/stm32h743-nucleo/rtconfig.h index e341d043f9..173db7f63c 100644 --- a/bsp/stm32h743-nucleo/rtconfig.h +++ b/bsp/stm32h743-nucleo/rtconfig.h @@ -108,6 +108,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/stm32l072/rtconfig.h b/bsp/stm32l072/rtconfig.h index 57be51ea76..5e750f5d1f 100644 --- a/bsp/stm32l072/rtconfig.h +++ b/bsp/stm32l072/rtconfig.h @@ -66,6 +66,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_HOOK #define RT_USING_CPU_USAGE /* SECTION: Console options */ diff --git a/bsp/stm32l475-iot-disco/rtconfig.h b/bsp/stm32l475-iot-disco/rtconfig.h index 89428e1cf4..f7b00767d2 100644 --- a/bsp/stm32l475-iot-disco/rtconfig.h +++ b/bsp/stm32l475-iot-disco/rtconfig.h @@ -61,6 +61,7 @@ #define RT_USING_DEVICE_IPC /* Using serial framework */ #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_UART1 #define RT_USING_UART2 diff --git a/bsp/stm32l476-nucleo/.config b/bsp/stm32l476-nucleo/.config index 44a239f90d..529d8c5fb0 100644 --- a/bsp/stm32l476-nucleo/.config +++ b/bsp/stm32l476-nucleo/.config @@ -105,6 +105,7 @@ CONFIG_FINSH_ARG_MAX=10 CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/stm32l476-nucleo/rtconfig.h b/bsp/stm32l476-nucleo/rtconfig.h index 7be9f6b5b6..d1e5fd2e41 100644 --- a/bsp/stm32l476-nucleo/rtconfig.h +++ b/bsp/stm32l476-nucleo/rtconfig.h @@ -71,6 +71,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using USB */ diff --git a/bsp/tm4c129x/.config b/bsp/tm4c129x/.config index 65b5b05742..3dbea9e5ba 100644 --- a/bsp/tm4c129x/.config +++ b/bsp/tm4c129x/.config @@ -82,6 +82,7 @@ CONFIG_FINSH_CMD_SIZE=80 # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_I2C is not set diff --git a/bsp/tm4c129x/rtconfig.h b/bsp/tm4c129x/rtconfig.h index d9e6e561c9..17065905cd 100644 --- a/bsp/tm4c129x/rtconfig.h +++ b/bsp/tm4c129x/rtconfig.h @@ -74,6 +74,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_I2C is not set */ diff --git a/bsp/tms320f28379d/.config b/bsp/tms320f28379d/.config index ddc9fd302e..d62b1e40c8 100644 --- a/bsp/tms320f28379d/.config +++ b/bsp/tms320f28379d/.config @@ -104,6 +104,7 @@ CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/tms320f28379d/rtconfig.h b/bsp/tms320f28379d/rtconfig.h index f74783569c..b037295813 100644 --- a/bsp/tms320f28379d/rtconfig.h +++ b/bsp/tms320f28379d/rtconfig.h @@ -68,6 +68,7 @@ #define RT_USING_DEVICE_IPC #define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA #define RT_USING_PIN /* Using WiFi */ diff --git a/bsp/x1000/.config b/bsp/x1000/.config index e6698d1d90..9ac579ccd9 100644 --- a/bsp/x1000/.config +++ b/bsp/x1000/.config @@ -121,6 +121,7 @@ CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DEVICE_IPC=y CONFIG_RT_USING_SERIAL=y +CONFIG_RT_SERIAL_USING_DMA=y # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set diff --git a/bsp/x1000/rtconfig.h b/bsp/x1000/rtconfig.h index 30ccf9e409..6babbd0b15 100644 --- a/bsp/x1000/rtconfig.h +++ b/bsp/x1000/rtconfig.h @@ -112,6 +112,7 @@ #define RT_USING_DEVICE_IPC #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA /* RT_USING_CAN is not set */ /* RT_USING_HWTIMER is not set */ /* RT_USING_CPUTIME is not set */ diff --git a/bsp/xplorer4330/M0/rtconfig.h b/bsp/xplorer4330/M0/rtconfig.h index 8adbc4e576..ee849028f2 100644 --- a/bsp/xplorer4330/M0/rtconfig.h +++ b/bsp/xplorer4330/M0/rtconfig.h @@ -74,6 +74,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // #define RT_UART_RX_BUFFER_SIZE 256 // diff --git a/bsp/xplorer4330/M4/rtconfig.h b/bsp/xplorer4330/M4/rtconfig.h index 8adbc4e576..ee849028f2 100644 --- a/bsp/xplorer4330/M4/rtconfig.h +++ b/bsp/xplorer4330/M4/rtconfig.h @@ -74,6 +74,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // #define RT_UART_RX_BUFFER_SIZE 256 // diff --git a/bsp/zynq7000/rtconfig.h b/bsp/zynq7000/rtconfig.h index 4c042a88f6..ca304c6ac9 100644 --- a/bsp/zynq7000/rtconfig.h +++ b/bsp/zynq7000/rtconfig.h @@ -72,6 +72,7 @@ #define RT_USING_DEVICE_IPC // #define RT_USING_SERIAL +#define RT_SERIAL_USING_DMA // #define RT_UART_RX_BUFFER_SIZE 64 // diff --git a/components/drivers/spi/sfud/src/sfud.c b/components/drivers/spi/sfud/src/sfud.c index 6cfd1191ef..30e0d949f1 100644 --- a/components/drivers/spi/sfud/src/sfud.c +++ b/components/drivers/spi/sfud/src/sfud.c @@ -603,7 +603,8 @@ static sfud_err page256_or_1_byte_write(const sfud_flash *flash, uint32_t addr, const uint8_t *data) { sfud_err result = SFUD_SUCCESS; const sfud_spi *spi = &flash->spi; - uint8_t cmd_data[5 + SFUD_WRITE_MAX_PAGE_SIZE], cmd_size; + static uint8_t cmd_data[5 + SFUD_WRITE_MAX_PAGE_SIZE]; + uint8_t cmd_size; size_t data_size; SFUD_ASSERT(flash); diff --git a/components/drivers/wlan/wlan_dev.c b/components/drivers/wlan/wlan_dev.c index 387f65fde2..0beac52aae 100644 --- a/components/drivers/wlan/wlan_dev.c +++ b/components/drivers/wlan/wlan_dev.c @@ -145,7 +145,10 @@ rt_err_t rt_wlan_dev_ap_start(struct rt_wlan_device *device, struct rt_wlan_info rt_memset(&ap_info, 0, sizeof(struct rt_ap_info)); rt_memcpy(&ap_info.ssid, &info->ssid, sizeof(rt_wlan_ssid_t)); - rt_memcpy(ap_info.key.val, password, password_len); + if (password != RT_NULL) + { + rt_memcpy(ap_info.key.val, password, password_len); + } ap_info.key.len = password_len; ap_info.hidden = info->hidden; ap_info.channel = info->channel; @@ -184,13 +187,21 @@ rt_err_t rt_wlan_dev_ap_deauth(struct rt_wlan_device *device, rt_uint8_t mac[6]) int rt_wlan_dev_get_rssi(struct rt_wlan_device *device) { int rssi = 0; + rt_err_t result = RT_EOK; if (device == RT_NULL) { - return -RT_EIO; + rt_set_errno(-RT_EIO); + return 0; + } + + result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_RSSI, &rssi); + if (result != RT_EOK) + { + rt_set_errno(result); + return 0; } - rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_RSSI, &rssi); return rssi; } @@ -235,14 +246,20 @@ rt_err_t rt_wlan_dev_set_powersave(struct rt_wlan_device *device, int level) int rt_wlan_dev_get_powersave(struct rt_wlan_device *device) { - int level = 0; + int level = -1; + rt_err_t result = RT_EOK; if (device == RT_NULL) { + rt_set_errno(-RT_EIO); return -1; } - rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_POWERSAVE, &level); + result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_POWERSAVE, &level); + if (result != RT_EOK) + { + rt_set_errno(result); + } return level; } @@ -432,19 +449,21 @@ rt_err_t rt_wlan_dev_set_channel(struct rt_wlan_device *device, int channel) return result; } -rt_err_t rt_wlan_dev_get_channel(struct rt_wlan_device *device) +int rt_wlan_dev_get_channel(struct rt_wlan_device *device) { rt_err_t result = RT_EOK; - int channel; + int channel = -1; if (device == RT_NULL) { - return -RT_EIO; + rt_set_errno(-RT_EIO); + return -1; } result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_CHANNEL, &channel); if (result != RT_EOK) { + rt_set_errno(result); return -1; } @@ -466,17 +485,19 @@ rt_err_t rt_wlan_dev_set_country(struct rt_wlan_device *device, rt_country_code_ rt_country_code_t rt_wlan_dev_get_country(struct rt_wlan_device *device) { - int result = 0; + int result = RT_EOK; rt_country_code_t country_code = RT_COUNTRY_UNKNOWN; if (device == RT_NULL) { - return country_code; + rt_set_errno(-RT_EIO); + return RT_COUNTRY_UNKNOWN; } result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_COUNTRY, &country_code); if (result != RT_EOK) { + rt_set_errno(result); return RT_COUNTRY_UNKNOWN; } @@ -641,7 +662,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args) LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_SET_POWERSAVE, "RT_WLAN_CMD_SET_POWERSAVE"); if (wlan->ops->wlan_set_powersave) - wlan->ops->wlan_set_powersave(wlan, level); + err = wlan->ops->wlan_set_powersave(wlan, level); break; } case RT_WLAN_CMD_GET_POWERSAVE: @@ -659,7 +680,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args) LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_CFG_PROMISC, "RT_WLAN_CMD_CFG_PROMISC"); if (wlan->ops->wlan_cfg_promisc) - wlan->ops->wlan_cfg_promisc(wlan, start); + err = wlan->ops->wlan_cfg_promisc(wlan, start); break; } case RT_WLAN_CMD_CFG_FILTER: @@ -668,7 +689,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args) LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_CFG_FILTER, "RT_WLAN_CMD_CFG_FILTER"); if (wlan->ops->wlan_cfg_filter) - wlan->ops->wlan_cfg_filter(wlan, filter); + err = wlan->ops->wlan_cfg_filter(wlan, filter); break; } case RT_WLAN_CMD_SET_CHANNEL: @@ -676,7 +697,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args) int channel = *(int *)args; LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_SET_CHANNEL, "RT_WLAN_CMD_SET_CHANNEL"); if (wlan->ops->wlan_set_channel) - wlan->ops->wlan_set_channel(wlan, channel); + err = wlan->ops->wlan_set_channel(wlan, channel); break; } case RT_WLAN_CMD_GET_CHANNEL: @@ -694,7 +715,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args) LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_SET_COUNTRY, "RT_WLAN_CMD_SET_COUNTRY"); if (wlan->ops->wlan_set_country) - wlan->ops->wlan_set_country(wlan, country); + err = wlan->ops->wlan_set_country(wlan, country); break; } case RT_WLAN_CMD_GET_COUNTRY: @@ -711,7 +732,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args) LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_SET_MAC, "RT_WLAN_CMD_SET_MAC"); if (wlan->ops->wlan_set_mac) - wlan->ops->wlan_set_mac(wlan, mac); + err = wlan->ops->wlan_set_mac(wlan, mac); break; } case RT_WLAN_CMD_GET_MAC: @@ -720,7 +741,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args) LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_GET_MAC, "RT_WLAN_CMD_GET_MAC"); if (wlan->ops->wlan_get_mac) - wlan->ops->wlan_get_mac(wlan, mac); + err = wlan->ops->wlan_get_mac(wlan, mac); break; } default: diff --git a/components/drivers/wlan/wlan_dev.h b/components/drivers/wlan/wlan_dev.h index e3f0d3dc61..a9300be9d7 100644 --- a/components/drivers/wlan/wlan_dev.h +++ b/components/drivers/wlan/wlan_dev.h @@ -559,7 +559,7 @@ rt_err_t rt_wlan_dev_cfg_filter(struct rt_wlan_device *device, struct rt_wlan_fi * wlan device channel interface */ rt_err_t rt_wlan_dev_set_channel(struct rt_wlan_device *device, int channel); -rt_err_t rt_wlan_dev_get_channel(struct rt_wlan_device *device); +int rt_wlan_dev_get_channel(struct rt_wlan_device *device); /* * wlan device country interface diff --git a/components/drivers/wlan/wlan_mgnt.c b/components/drivers/wlan/wlan_mgnt.c index 1d0b0c4aa7..bdddac1fa2 100644 --- a/components/drivers/wlan/wlan_mgnt.c +++ b/components/drivers/wlan/wlan_mgnt.c @@ -1320,7 +1320,10 @@ rt_err_t rt_wlan_start_ap_adv(struct rt_wlan_info *info, const char *password) return -RT_EIO; } RT_WLAN_LOG_D("%s is run", __FUNCTION__); - password_len = rt_strlen(password); + if (password != RT_NULL) + { + password_len = rt_strlen(password); + } if (password_len > RT_WLAN_PASSWORD_MAX_LENGTH) { RT_WLAN_LOG_E("key is to long! len:%d", password_len); @@ -1358,16 +1361,16 @@ rt_err_t rt_wlan_start_ap_adv(struct rt_wlan_info *info, const char *password) return err; } -int rt_wlan_ap_is_active(void) +rt_bool_t rt_wlan_ap_is_active(void) { - int _active = 0; + rt_bool_t _active = RT_FALSE; if (_ap_is_null()) { - return 0; + return RT_FALSE; } - _active = _ap_mgnt.state & RT_WLAN_STATE_ACTIVE ? 1 : 0; + _active = _ap_mgnt.state & RT_WLAN_STATE_ACTIVE ? RT_TRUE : RT_FALSE; RT_WLAN_LOG_D("%s is run active:%s", __FUNCTION__, _active ? "Active" : "Inactive"); return _active; } diff --git a/components/drivers/wlan/wlan_mgnt.h b/components/drivers/wlan/wlan_mgnt.h index d11d9ee347..f4d9e0cff9 100644 --- a/components/drivers/wlan/wlan_mgnt.h +++ b/components/drivers/wlan/wlan_mgnt.h @@ -97,7 +97,7 @@ int rt_wlan_get_rssi(void); */ rt_err_t rt_wlan_start_ap(const char *ssid, const char *password); rt_err_t rt_wlan_start_ap_adv(struct rt_wlan_info *info, const char *password); -int rt_wlan_ap_is_active(void); +rt_bool_t rt_wlan_ap_is_active(void); rt_err_t rt_wlan_ap_stop(void); rt_err_t rt_wlan_ap_get_info(struct rt_wlan_info *info); int rt_wlan_ap_get_sta_num(void); diff --git a/include/rtdef.h b/include/rtdef.h index 6d5263ef62..49551de9ee 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -507,8 +507,8 @@ typedef siginfo_t rt_siginfo_t; #define RT_CPU_DETACHED RT_CPUS_NR /**< The thread not running on cpu. */ #define RT_CPU_MASK ((1 << RT_CPUS_NR) - 1) /**< All CPUs mask bit. */ -#ifndef RT_SCHEDULE_IPI_IRQ -#define RT_SCHEDULE_IPI_IRQ 0 +#ifndef RT_SCHEDULE_IPI +#define RT_SCHEDULE_IPI 0 #endif /** diff --git a/libcpu/risc-v/k210/interrupt.c b/libcpu/risc-v/k210/interrupt.c new file mode 100644 index 0000000000..6d8866c3f0 --- /dev/null +++ b/libcpu/risc-v/k210/interrupt.c @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/10/01 Bernard The first version + */ + +#include + +#include "tick.h" + +#include +#include +#include + +#define CPU_NUM 2 +#define MAX_HANDLERS IRQN_MAX + +static struct rt_irq_desc irq_desc[CPU_NUM][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; +} + +/** + * 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[cpuid][idx].handler = (rt_isr_handler_t)rt_hw_interrupt_handle; + irq_desc[cpuid][idx].param = RT_NULL; +#ifdef RT_USING_INTERRUPT_INFO + rt_snprintf(irq_desc[cpuid][idx].name, RT_NAME_MAX - 1, "default"); + irq_desc[idx][cpuid].counter = 0; +#endif + } + + /* 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) +{ + 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); + 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) +{ + int cpuid; + rt_isr_handler_t old_handler = RT_NULL; + + cpuid = current_coreid(); + + if(vector < MAX_HANDLERS) + { + old_handler = irq_desc[cpuid][vector].handler; + if (handler != RT_NULL) + { + irq_desc[cpuid][vector].handler = (rt_isr_handler_t)handler; + irq_desc[cpuid][vector].param = param; +#ifdef RT_USING_INTERRUPT_INFO + rt_snprintf(irq_desc[cpuid][vector].name, RT_NAME_MAX - 1, "%s", name); + irq_desc[cpuid][vector].counter = 0; +#endif + } + } + + return old_handler; +} + +uintptr_t handle_irq_m_ext(uintptr_t cause, uintptr_t epc) +{ + /* + * 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[core_id][int_num].handler) + { + irq_desc[core_id][int_num].handler(int_num, irq_desc[core_id][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; + } + else + { + rt_kprintf("unhandled trap!\n"); + } + + return epc; +} + +uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc) +{ + int cause = mcause & CAUSE_MACHINE_IRQ_REASON_MASK; + + if (mcause & (1UL << 63)) + { + switch (cause) + { + case IRQ_M_SOFT: + break; + case IRQ_M_EXT: + handle_irq_m_ext(mcause, epc); + break; + case IRQ_M_TIMER: + tick_isr(); + break; + } + } + else + { + rt_thread_t tid; + extern long list_thread(); + + rt_hw_interrupt_disable(); + + tid = rt_thread_self(); + rt_kprintf("\n"); + rt_kprintf("unhandled trap, epc => 0x%08x, INT[%d]\n", epc, rt_interrupt_get_nest()); + rt_kprintf("current thread: %.*s\n", RT_NAME_MAX, tid->name); +#ifdef RT_USING_FINSH + list_thread(); +#endif + while(1); + } + + return epc; +} diff --git a/libcpu/risc-v/k210/interrupt_gcc.S b/libcpu/risc-v/k210/interrupt_gcc.S new file mode 100644 index 0000000000..5783322237 --- /dev/null +++ b/libcpu/risc-v/k210/interrupt_gcc.S @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/10/02 Bernard The first version + */ + +#include "cpuport.h" + + .section .text.entry + .align 2 + .global trap_entry +trap_entry: + + /* save thread context to thread stack */ + addi sp, sp, -32 * REGBYTES + + STORE x1, 1 * REGBYTES(sp) + li t0, 0x80 + STORE t0, 2 * REGBYTES(sp) + + STORE x4, 4 * REGBYTES(sp) + STORE x5, 5 * REGBYTES(sp) + STORE x6, 6 * REGBYTES(sp) + STORE x7, 7 * REGBYTES(sp) + STORE x8, 8 * REGBYTES(sp) + STORE x9, 9 * REGBYTES(sp) + STORE x10, 10 * REGBYTES(sp) + STORE x11, 11 * REGBYTES(sp) + STORE x12, 12 * REGBYTES(sp) + STORE x13, 13 * REGBYTES(sp) + STORE x14, 14 * REGBYTES(sp) + STORE x15, 15 * REGBYTES(sp) + STORE x16, 16 * REGBYTES(sp) + STORE x17, 17 * REGBYTES(sp) + STORE x18, 18 * REGBYTES(sp) + STORE x19, 19 * REGBYTES(sp) + STORE x20, 20 * REGBYTES(sp) + STORE x21, 21 * REGBYTES(sp) + STORE x22, 22 * REGBYTES(sp) + STORE x23, 23 * REGBYTES(sp) + STORE x24, 24 * REGBYTES(sp) + STORE x25, 25 * REGBYTES(sp) + STORE x26, 26 * REGBYTES(sp) + STORE x27, 27 * REGBYTES(sp) + STORE x28, 28 * REGBYTES(sp) + STORE x29, 29 * REGBYTES(sp) + STORE x30, 30 * REGBYTES(sp) + STORE x31, 31 * REGBYTES(sp) + + /* switch to interrupt stack */ + move s0, sp + + /* get cpu id */ + csrr t0, mhartid + + /* switch interrupt stack of current cpu */ + la sp, __stack_start__ + addi t1, t0, 1 + li t2, __STACKSIZE__ + mul t1, t1, t2 + add sp, sp, t1 /* sp = (cpuid + 1) * __STACKSIZE__ + __stack_start__ */ + + /* handle interrupt */ + call rt_interrupt_enter + csrr a0, mcause + csrr a1, mepc + mv a2, sp + call handle_trap + call rt_interrupt_leave + + /* switch to from_thread stack */ + move sp, s0 + + /* need to switch new thread */ + la s0, rt_thread_switch_interrupt_flag + lw s2, 0(s0) + beqz s2, spurious_interrupt + sw zero, 0(s0) + + csrr a0, mepc + STORE a0, 0 * REGBYTES(sp) + + la s0, rt_interrupt_from_thread + LOAD s1, 0(s0) + STORE sp, 0(s1) + + la s0, rt_interrupt_to_thread + LOAD s1, 0(s0) + LOAD sp, 0(s1) + + LOAD a0, 0 * REGBYTES(sp) + csrw mepc, a0 + +spurious_interrupt: + LOAD x1, 1 * REGBYTES(sp) + + /* Remain in M-mode after mret */ + li t0, 0x00001800 + csrs mstatus, t0 + LOAD t0, 2 * REGBYTES(sp) + csrs mstatus, t0 + + LOAD x4, 4 * REGBYTES(sp) + LOAD x5, 5 * REGBYTES(sp) + LOAD x6, 6 * REGBYTES(sp) + LOAD x7, 7 * REGBYTES(sp) + LOAD x8, 8 * REGBYTES(sp) + LOAD x9, 9 * REGBYTES(sp) + LOAD x10, 10 * REGBYTES(sp) + LOAD x11, 11 * REGBYTES(sp) + LOAD x12, 12 * REGBYTES(sp) + LOAD x13, 13 * REGBYTES(sp) + LOAD x14, 14 * REGBYTES(sp) + LOAD x15, 15 * REGBYTES(sp) + LOAD x16, 16 * REGBYTES(sp) + LOAD x17, 17 * REGBYTES(sp) + LOAD x18, 18 * REGBYTES(sp) + LOAD x19, 19 * REGBYTES(sp) + LOAD x20, 20 * REGBYTES(sp) + LOAD x21, 21 * REGBYTES(sp) + LOAD x22, 22 * REGBYTES(sp) + LOAD x23, 23 * REGBYTES(sp) + LOAD x24, 24 * REGBYTES(sp) + LOAD x25, 25 * REGBYTES(sp) + LOAD x26, 26 * REGBYTES(sp) + LOAD x27, 27 * REGBYTES(sp) + LOAD x28, 28 * REGBYTES(sp) + LOAD x29, 29 * REGBYTES(sp) + LOAD x30, 30 * REGBYTES(sp) + LOAD x31, 31 * REGBYTES(sp) + + addi sp, sp, 32 * REGBYTES + mret diff --git a/libcpu/risc-v/k210/startup_gcc.S b/libcpu/risc-v/k210/startup_gcc.S new file mode 100644 index 0000000000..bc73f51e03 --- /dev/null +++ b/libcpu/risc-v/k210/startup_gcc.S @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018/10/01 Bernard The first version + */ + +#define MSTATUS_FS 0x00006000U /* initial state of FPU */ +#include + + .global _start + .section ".start", "ax" +_start: + j 1f + .word 0xdeadbeef +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.d.x f0, x0 + fmv.d.x f1, x0 + fmv.d.x f2, x0 + fmv.d.x f3, x0 + fmv.d.x f4, x0 + fmv.d.x f5, x0 + fmv.d.x f6, x0 + fmv.d.x f7, x0 + fmv.d.x f8, x0 + fmv.d.x f9, x0 + fmv.d.x f10,x0 + fmv.d.x f11,x0 + fmv.d.x f12,x0 + fmv.d.x f13,x0 + fmv.d.x f14,x0 + fmv.d.x f15,x0 + fmv.d.x f16,x0 + fmv.d.x f17,x0 + fmv.d.x f18,x0 + fmv.d.x f19,x0 + fmv.d.x f20,x0 + fmv.d.x f21,x0 + fmv.d.x f22,x0 + fmv.d.x f23,x0 + fmv.d.x f24,x0 + fmv.d.x f25,x0 + fmv.d.x f26,x0 + fmv.d.x f27,x0 + fmv.d.x f28,x0 + fmv.d.x f29,x0 + fmv.d.x f30,x0 + fmv.d.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, _cpu_entry + +#if 0 + /* clear bss section */ + la a0, __bss_start + la a1, __bss_end + bgeu a0, a1, 2f +1: + sw zero, (a0) + addi a0, a0, REGBYTES + bltu a0, a1, 1b +2: +#endif + +_cpu_entry: + csrr a0, mhartid + j cpu_entry diff --git a/libcpu/risc-v/k210/tick.c b/libcpu/risc-v/k210/tick.c new file mode 100644 index 0000000000..144f7f1fff --- /dev/null +++ b/libcpu/risc-v/k210/tick.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2006-2018, 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 +#include + +#include +#include +#include + +static volatile unsigned long tick_cycles = 0; +int 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/libcpu/risc-v/k210/tick.h b/libcpu/risc-v/k210/tick.h new file mode 100644 index 0000000000..0821004263 --- /dev/null +++ b/libcpu/risc-v/k210/tick.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2006-2018, 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/src/scheduler.c b/src/scheduler.c index 503639fa81..cd66284c7a 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -612,7 +612,7 @@ void rt_schedule_insert_thread(struct rt_thread *thread) rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]), &(thread->tlist)); cpu_mask = RT_CPU_MASK ^ (1 << cpu_id); - rt_hw_ipi_send(RT_SCHEDULE_IPI_IRQ, cpu_mask); + rt_hw_ipi_send(RT_SCHEDULE_IPI, cpu_mask); } else { @@ -629,7 +629,7 @@ void rt_schedule_insert_thread(struct rt_thread *thread) if (cpu_id != bind_cpu) { cpu_mask = 1 << bind_cpu; - rt_hw_ipi_send(RT_SCHEDULE_IPI_IRQ, cpu_mask); + rt_hw_ipi_send(RT_SCHEDULE_IPI, cpu_mask); } } diff --git a/tools/building.py b/tools/building.py index eb2da2fab9..90c1c871b6 100644 --- a/tools/building.py +++ b/tools/building.py @@ -813,6 +813,9 @@ def EndBuilding(target, program = None): if hasattr(rtconfig, 'BSP_LIBRARY_TYPE'): Env['bsp_lib_type'] = rtconfig.BSP_LIBRARY_TYPE + if hasattr(rtconfig, 'dist_handle'): + Env['dist_handle'] = rtconfig.dist_handle + Env.AddPostAction(target, rtconfig.POST_ACTION) # Add addition clean files Clean(target, 'cconfig.h') diff --git a/tools/mkdist.py b/tools/mkdist.py index e927417fc4..cf30e95284 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -196,6 +196,12 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env): bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) + # do bsp special dist handle + if 'dist_handle' in Env: + print("=> start dist handle") + dist_handle = Env['dist_handle'] + dist_handle(BSP_ROOT) + # get all source files from program for item in program: walk_children(item) @@ -316,7 +322,13 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env): bsp_copy_files(os.path.join(library_path, 'HAL_Drivers'), os.path.join(library_dir, 'HAL_Drivers')) bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) - + + # do bsp special dist handle + if 'dist_handle' in Env: + print("=> start dist handle") + dist_handle = Env['dist_handle'] + dist_handle(BSP_ROOT) + # copy tools directory print('=> components') do_copy_folder(os.path.join(RTT_ROOT, 'components'), os.path.join(target_path, 'components'))