Browse Source

Merge branch 'RT-Thread:master' into develop

陈迎春 3 years ago
parent
commit
f0c963bf53

+ 0 - 192
bsp/stm32/stm32f767-fire-challenger/project.uvoptx

@@ -1,192 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
-<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
-
-  <SchemaVersion>1.0</SchemaVersion>
-
-  <Header>### uVision Project, (C) Keil Software</Header>
-
-  <Extensions>
-    <cExt>*.c</cExt>
-    <aExt>*.s*; *.src; *.a*</aExt>
-    <oExt>*.obj; *.o</oExt>
-    <lExt>*.lib</lExt>
-    <tExt>*.txt; *.h; *.inc</tExt>
-    <pExt>*.plm</pExt>
-    <CppX>*.cpp</CppX>
-    <nMigrate>0</nMigrate>
-  </Extensions>
-
-  <DaveTm>
-    <dwLowDateTime>0</dwLowDateTime>
-    <dwHighDateTime>0</dwHighDateTime>
-  </DaveTm>
-
-  <Target>
-    <TargetName>rt-thread</TargetName>
-    <ToolsetNumber>0x4</ToolsetNumber>
-    <ToolsetName>ARM-ADS</ToolsetName>
-    <TargetOption>
-      <CLKADS>12000000</CLKADS>
-      <OPTTT>
-        <gFlags>1</gFlags>
-        <BeepAtEnd>1</BeepAtEnd>
-        <RunSim>0</RunSim>
-        <RunTarget>1</RunTarget>
-        <RunAbUc>0</RunAbUc>
-      </OPTTT>
-      <OPTHX>
-        <HexSelection>1</HexSelection>
-        <FlashByte>65535</FlashByte>
-        <HexRangeLowAddress>0</HexRangeLowAddress>
-        <HexRangeHighAddress>0</HexRangeHighAddress>
-        <HexOffset>0</HexOffset>
-      </OPTHX>
-      <OPTLEX>
-        <PageWidth>79</PageWidth>
-        <PageLength>66</PageLength>
-        <TabStop>8</TabStop>
-        <ListingPath>.\build\keil\List\</ListingPath>
-      </OPTLEX>
-      <ListingPage>
-        <CreateCListing>1</CreateCListing>
-        <CreateAListing>1</CreateAListing>
-        <CreateLListing>1</CreateLListing>
-        <CreateIListing>0</CreateIListing>
-        <AsmCond>1</AsmCond>
-        <AsmSymb>1</AsmSymb>
-        <AsmXref>0</AsmXref>
-        <CCond>1</CCond>
-        <CCode>0</CCode>
-        <CListInc>0</CListInc>
-        <CSymb>0</CSymb>
-        <LinkerCodeListing>0</LinkerCodeListing>
-      </ListingPage>
-      <OPTXL>
-        <LMap>1</LMap>
-        <LComments>1</LComments>
-        <LGenerateSymbols>1</LGenerateSymbols>
-        <LLibSym>1</LLibSym>
-        <LLines>1</LLines>
-        <LLocSym>1</LLocSym>
-        <LPubSym>1</LPubSym>
-        <LXref>0</LXref>
-        <LExpSel>0</LExpSel>
-      </OPTXL>
-      <OPTFL>
-        <tvExp>1</tvExp>
-        <tvExpOptDlg>0</tvExpOptDlg>
-        <IsCurrentTarget>1</IsCurrentTarget>
-      </OPTFL>
-      <CpuCode>18</CpuCode>
-      <DebugOpt>
-        <uSim>0</uSim>
-        <uTrg>1</uTrg>
-        <sLdApp>1</sLdApp>
-        <sGomain>1</sGomain>
-        <sRbreak>1</sRbreak>
-        <sRwatch>1</sRwatch>
-        <sRmem>1</sRmem>
-        <sRfunc>1</sRfunc>
-        <sRbox>1</sRbox>
-        <tLdApp>1</tLdApp>
-        <tGomain>1</tGomain>
-        <tRbreak>1</tRbreak>
-        <tRwatch>1</tRwatch>
-        <tRmem>1</tRmem>
-        <tRfunc>0</tRfunc>
-        <tRbox>1</tRbox>
-        <tRtrace>1</tRtrace>
-        <sRSysVw>1</sRSysVw>
-        <tRSysVw>1</tRSysVw>
-        <sRunDeb>0</sRunDeb>
-        <sLrtime>0</sLrtime>
-        <bEvRecOn>1</bEvRecOn>
-        <bSchkAxf>0</bSchkAxf>
-        <bTchkAxf>0</bTchkAxf>
-        <nTsel>3</nTsel>
-        <sDll></sDll>
-        <sDllPa></sDllPa>
-        <sDlgDll></sDlgDll>
-        <sDlgPa></sDlgPa>
-        <sIfile></sIfile>
-        <tDll></tDll>
-        <tDllPa></tDllPa>
-        <tDlgDll></tDlgDll>
-        <tDlgPa></tDlgPa>
-        <tIfile></tIfile>
-        <pMon>Segger\JL2CM3.dll</pMon>
-      </DebugOpt>
-      <TargetDriverDllRegistry>
-        <SetRegEntry>
-          <Number>0</Number>
-          <Key>JL2CM3</Key>
-          <Name>-U59400616 -O14 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight JTAG-DP") -D00(5BA00477) -L00(4) -N01("Unknown JTAG device") -D01(06451041) -L01(5) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20020000 -FC1000 -FN1 -FF0STM32F7x_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F767IGTx$CMSIS\Flash\STM32F7x_1024.FLM)</Name>
-        </SetRegEntry>
-        <SetRegEntry>
-          <Number>0</Number>
-          <Key>UL2CM3</Key>
-          <Name>UL2CM3(-S0 -C0 -P0 )  -FN2 -FC1000 -FD20020000 -FF0STM32F7x_1024 -FF1STM32F7x_1024dual -FL0100000 -FL1100000 -FS08000000 -FS18000000 -FP0($$Device:STM32F767IGTx$CMSIS\Flash\STM32F7x_1024.FLM) -FP1($$Device:STM32F767IGTx$CMSIS\Flash\STM32F7x_1024dual.FLM)</Name>
-        </SetRegEntry>
-      </TargetDriverDllRegistry>
-      <Breakpoint/>
-      <Tracepoint>
-        <THDelay>0</THDelay>
-      </Tracepoint>
-      <DebugFlag>
-        <trace>0</trace>
-        <periodic>0</periodic>
-        <aLwin>0</aLwin>
-        <aCover>0</aCover>
-        <aSer1>0</aSer1>
-        <aSer2>0</aSer2>
-        <aPa>0</aPa>
-        <viewmode>0</viewmode>
-        <vrSel>0</vrSel>
-        <aSym>0</aSym>
-        <aTbox>0</aTbox>
-        <AscS1>0</AscS1>
-        <AscS2>0</AscS2>
-        <AscS3>0</AscS3>
-        <aSer3>0</aSer3>
-        <eProf>0</eProf>
-        <aLa>0</aLa>
-        <aPa1>0</aPa1>
-        <AscS4>0</AscS4>
-        <aSer4>0</aSer4>
-        <StkLoc>0</StkLoc>
-        <TrcWin>0</TrcWin>
-        <newCpu>0</newCpu>
-        <uProt>0</uProt>
-      </DebugFlag>
-      <LintExecutable></LintExecutable>
-      <LintConfigFile></LintConfigFile>
-      <bLintAuto>0</bLintAuto>
-      <bAutoGenD>0</bAutoGenD>
-      <LntExFlags>0</LntExFlags>
-      <pMisraName></pMisraName>
-      <pszMrule></pszMrule>
-      <pSingCmds></pSingCmds>
-      <pMultCmds></pMultCmds>
-      <pMisraNamep></pMisraNamep>
-      <pszMrulep></pszMrulep>
-      <pSingCmdsp></pSingCmdsp>
-      <pMultCmdsp></pMultCmdsp>
-      <DebugDescription>
-        <Enable>1</Enable>
-        <EnableFlashSeq>0</EnableFlashSeq>
-        <EnableLog>0</EnableLog>
-        <Protocol>2</Protocol>
-        <DbgClock>10000000</DbgClock>
-      </DebugDescription>
-    </TargetOption>
-  </Target>
-
-  <Group>
-    <GroupName>Source Group 1</GroupName>
-    <tvExp>0</tvExp>
-    <tvExpOptDlg>0</tvExpOptDlg>
-    <cbSel>0</cbSel>
-    <RteFlg>0</RteFlg>
-  </Group>
-
-</ProjectOpt>

+ 83 - 29
bsp/x86/.config

@@ -23,10 +23,16 @@ CONFIG_IDLE_THREAD_STACK_SIZE=2048
 CONFIG_RT_USING_TIMER_SOFT=y
 CONFIG_RT_TIMER_THREAD_PRIO=4
 CONFIG_RT_TIMER_THREAD_STACK_SIZE=2048
+
+#
+# kservice optimization
+#
+# CONFIG_RT_KSERVICE_USING_STDLIB is not set
+# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
+# CONFIG_RT_USING_ASM_MEMCPY is not set
 CONFIG_RT_DEBUG=y
 CONFIG_RT_DEBUG_COLOR=y
-CONFIG_RT_DEBUG_INIT_CONFIG=y
-CONFIG_RT_DEBUG_INIT=1
+# CONFIG_RT_DEBUG_INIT_CONFIG is not set
 # CONFIG_RT_DEBUG_THREAD_CONFIG is not set
 # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
 # CONFIG_RT_DEBUG_IPC_CONFIG is not set
@@ -68,7 +74,8 @@ CONFIG_RT_USING_DEVICE=y
 CONFIG_RT_USING_CONSOLE=y
 CONFIG_RT_CONSOLEBUF_SIZE=256
 CONFIG_RT_CONSOLE_DEVICE_NAME="console"
-CONFIG_RT_VER_NUM=0x40003
+# CONFIG_RT_PRINTF_LONGLONG is not set
+CONFIG_RT_VER_NUM=0x40004
 # CONFIG_RT_USING_CPU_FFS is not set
 CONFIG_ARCH_IA32=y
 # CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
@@ -139,8 +146,6 @@ 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
 
 #
 # Device Drivers
@@ -151,6 +156,8 @@ CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
 CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=2048
 CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23
 CONFIG_RT_USING_SERIAL=y
+CONFIG_RT_USING_SERIAL_V1=y
+# CONFIG_RT_USING_SERIAL_V2 is not set
 CONFIG_RT_SERIAL_USING_DMA=y
 CONFIG_RT_SERIAL_RB_BUFSZ=64
 # CONFIG_RT_USING_CAN is not set
@@ -190,6 +197,7 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_RT_USING_PTHREADS is not set
 # CONFIG_RT_USING_POSIX is not set
 # CONFIG_RT_USING_MODULE is not set
+CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
 
 #
 # Network
@@ -226,6 +234,12 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_RT_USING_RYM is not set
 # CONFIG_RT_USING_ULOG is not set
 # CONFIG_RT_USING_UTEST is not set
+# CONFIG_RT_USING_RT_LINK is not set
+
+#
+# RT-Thread Utestcases
+#
+# CONFIG_RT_USING_UTESTCASES is not set
 
 #
 # RT-Thread online packages
@@ -294,8 +308,6 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_PKG_USING_LIBRWS is not set
 # CONFIG_PKG_USING_TCPSERVER is not set
 # CONFIG_PKG_USING_PROTOBUF_C is not set
-# CONFIG_PKG_USING_ONNX_PARSER is not set
-# CONFIG_PKG_USING_ONNX_BACKEND is not set
 # CONFIG_PKG_USING_DLT645 is not set
 # CONFIG_PKG_USING_QXWZ is not set
 # CONFIG_PKG_USING_SMTP_CLIENT is not set
@@ -310,6 +322,12 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_PKG_USING_BTSTACK is not set
 # CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
 # CONFIG_PKG_USING_WAYZ_IOTKIT is not set
+# CONFIG_PKG_USING_MAVLINK is not set
+# CONFIG_PKG_USING_RAPIDJSON is not set
+# CONFIG_PKG_USING_BSAL is not set
+# CONFIG_PKG_USING_AGILE_MODBUS is not set
+# CONFIG_PKG_USING_AGILE_FTP is not set
+# CONFIG_PKG_USING_EMBEDDEDPROTO is not set
 
 #
 # security packages
@@ -335,9 +353,12 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_PKG_USING_STEMWIN is not set
 # CONFIG_PKG_USING_WAVPLAYER is not set
 # CONFIG_PKG_USING_TJPGD is not set
+# CONFIG_PKG_USING_PDFGEN is not set
 # CONFIG_PKG_USING_HELIX is not set
 # CONFIG_PKG_USING_AZUREGUIX is not set
 # CONFIG_PKG_USING_TOUCHGFX2RTT is not set
+# CONFIG_PKG_USING_NUEMWIN is not set
+# CONFIG_PKG_USING_MP3PLAYER is not set
 
 #
 # tools packages
@@ -346,6 +367,7 @@ CONFIG_RT_USING_LIBC=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_SEGGER_RTT 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
@@ -374,14 +396,36 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_PKG_USING_ANV_MEMLEAK is not set
 # CONFIG_PKG_USING_ANV_TESTSUIT is not set
 # CONFIG_PKG_USING_ANV_BENCH is not set
+# CONFIG_PKG_USING_DEVMEM is not set
+# CONFIG_PKG_USING_REGEX is not set
+# CONFIG_PKG_USING_MEM_SANDBOX is not set
+# CONFIG_PKG_USING_SOLAR_TERMS is not set
+# CONFIG_PKG_USING_GAN_ZHI is not set
 
 #
 # system packages
 #
+
+#
+# acceleration: Assembly language or algorithmic acceleration packages
+#
+# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
+# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
+# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
+# CONFIG_PKG_USING_QFPLIB_M3 is not set
+
+#
+# Micrium: Micrium software products porting for RT-Thread
+#
+# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
+# CONFIG_PKG_USING_UCOSII_WRAPPER is not set
+# CONFIG_PKG_USING_UC_CRC is not set
+# CONFIG_PKG_USING_UC_CLK is not set
+# CONFIG_PKG_USING_UC_COMMON is not set
+# CONFIG_PKG_USING_UC_MODBUS is not set
 # 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_FLASHDB is not set
@@ -391,6 +435,9 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_PKG_USING_CMSIS is not set
 # CONFIG_PKG_USING_DFS_YAFFS is not set
 # CONFIG_PKG_USING_LITTLEFS is not set
+# CONFIG_PKG_USING_DFS_JFFS2 is not set
+# CONFIG_PKG_USING_DFS_UFFS is not set
+# CONFIG_PKG_USING_LWEXT4 is not set
 # CONFIG_PKG_USING_THREAD_POOL is not set
 # CONFIG_PKG_USING_ROBOTS is not set
 # CONFIG_PKG_USING_EV is not set
@@ -400,24 +447,12 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_PKG_USING_RAMDISK is not set
 # CONFIG_PKG_USING_MININI is not set
 # CONFIG_PKG_USING_QBOOT is not set
-
-#
-# Micrium: Micrium software products porting for RT-Thread
-#
-# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
-# CONFIG_PKG_USING_UCOSII_WRAPPER is not set
-# CONFIG_PKG_USING_UC_CRC is not set
-# CONFIG_PKG_USING_UC_CLK is not set
-# CONFIG_PKG_USING_UC_COMMON is not set
-# CONFIG_PKG_USING_UC_MODBUS is not set
 # CONFIG_PKG_USING_PPOOL is not set
 # CONFIG_PKG_USING_OPENAMP is not set
 # CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set
-# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
-# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
-# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
-# CONFIG_PKG_USING_QFPLIB_M3 is not set
 # CONFIG_PKG_USING_LPM is not set
+# CONFIG_PKG_USING_TLSF is not set
+# CONFIG_PKG_USING_EVENT_RECORDER is not set
 
 #
 # peripheral libraries and drivers
@@ -442,7 +477,6 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_PKG_USING_WM_LIBRARIES is not set
 # CONFIG_PKG_USING_KENDRYTE_SDK is not set
 # CONFIG_PKG_USING_INFRARED is not set
-# CONFIG_PKG_USING_ROSSERIAL is not set
 # CONFIG_PKG_USING_AGILE_BUTTON is not set
 # CONFIG_PKG_USING_AGILE_LED is not set
 # CONFIG_PKG_USING_AT24CXX is not set
@@ -480,6 +514,28 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
 # CONFIG_PKG_USING_VDEVICE is not set
 # CONFIG_PKG_USING_SGM706 is not set
+# CONFIG_PKG_USING_STM32WB55_SDK is not set
+# CONFIG_PKG_USING_RDA58XX is not set
+# CONFIG_PKG_USING_LIBNFC is not set
+# CONFIG_PKG_USING_MFOC is not set
+# CONFIG_PKG_USING_TMC51XX is not set
+# CONFIG_PKG_USING_TCA9534 is not set
+# CONFIG_PKG_USING_KOBUKI is not set
+# CONFIG_PKG_USING_ROSSERIAL is not set
+# CONFIG_PKG_USING_MICRO_ROS is not set
+
+#
+# AI packages
+#
+# CONFIG_PKG_USING_LIBANN is not set
+# CONFIG_PKG_USING_NNOM is not set
+# CONFIG_PKG_USING_ONNX_BACKEND is not set
+# CONFIG_PKG_USING_ONNX_PARSER is not set
+# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
+# CONFIG_PKG_USING_ELAPACK is not set
+# CONFIG_PKG_USING_ULAPACK is not set
+# CONFIG_PKG_USING_QUEST is not set
+# CONFIG_PKG_USING_NAXOS is not set
 
 #
 # miscellaneous packages
@@ -494,6 +550,7 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
 # CONFIG_PKG_USING_CANFESTIVAL is not set
 # CONFIG_PKG_USING_ZLIB is not set
+# CONFIG_PKG_USING_MINIZIP is not set
 # CONFIG_PKG_USING_DSTR is not set
 # CONFIG_PKG_USING_TINYFRAME is not set
 # CONFIG_PKG_USING_KENDRYTE_DEMO is not set
@@ -511,24 +568,21 @@ CONFIG_RT_USING_LIBC=y
 # CONFIG_PKG_USING_HELLO is not set
 # CONFIG_PKG_USING_VI is not set
 # CONFIG_PKG_USING_KI is not set
-# CONFIG_PKG_USING_NNOM is not set
-# CONFIG_PKG_USING_LIBANN is not set
-# CONFIG_PKG_USING_ELAPACK is not set
 # CONFIG_PKG_USING_ARMv7M_DWT is not set
 # CONFIG_PKG_USING_VT100 is not set
-# CONFIG_PKG_USING_ULAPACK is not set
 # CONFIG_PKG_USING_UKAL is not set
 # CONFIG_PKG_USING_CRCLIB is not set
 
 #
-# games: games run on RT-Thread console
+# entertainment: terminal games and other interesting software packages
 #
 # CONFIG_PKG_USING_THREES is not set
 # CONFIG_PKG_USING_2048 is not set
 # CONFIG_PKG_USING_SNAKE is not set
 # CONFIG_PKG_USING_TETRIS is not set
+# CONFIG_PKG_USING_DONUT is not set
+# CONFIG_PKG_USING_ACLOCK is not set
 # CONFIG_PKG_USING_LWGPS is not set
-# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
 # CONFIG_PKG_USING_STATE_MACHINE is not set
 # CONFIG_PKG_USING_MCURSES is not set
 # CONFIG_PKG_USING_COWSAY is not set

+ 73 - 0
bsp/x86/README.md

@@ -0,0 +1,73 @@
+# RT-Thread for x86
+
+这是一份基础的RT-Thread针对x86的版本、移植,主要是能够在qemu中执行。以下说明主要针对Linux的环境,如果是Windows环境,请使用Env工具,同时请自行处理生成iso的方法。
+
+## 编译
+
+编译RT-Thread for x86版本,还需要一份支持newlib的工具链,可以通过以下地址获得:
+
+*[i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2](http://117.143.63.254:9012/www/rt-smart/i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2)
+
+下载后解压,然后在rtconfig.py中配置其中的EXEC_PATH变量
+
+```python
+if  CROSS_TOOL == 'gcc':
+    PLATFORM    = 'gcc'
+    EXEC_PATH   = os.getenv('RTT_EXEC_PATH') or 'E:/Program Files/CodeSourcery/Sourcery_CodeBench_Lite_for_IA32_ELF/bin'
+
+```
+
+然后在x86 bsp目录下执行scons命令来编译:
+
+```bash
+scons
+```
+
+### 配置
+
+RT-Thread for x86的版本也支持menuconfig的配置方式,在Linux下可以使用`scons --menuconfig`的方式进行配置。
+
+因为menuconfig是一份字符界面的配置(Kconfig),在ubuntu下需要安装ncurses5的库
+
+```bash
+sudo apt install libncurses5-dev
+```
+
+## 运行
+
+在ubuntu下运行,请确保你安装了`qemu-system-i386`,`grub` 以及 `xorriso`软件包:
+
+```bash
+sudo apt install qemu-system-x86 grub-common xorriso
+```
+
+然后执行`./run.sh`命令可以使用qemu来模拟执行(它也会生成可启动的iso文件)
+
+```bash
+~/workspace/rt-thread/bsp/x86$ ./run.sh
+xorriso 1.4.8 : RockRidge filesystem manipulator, libburnia project.
+
+Drive current: -outdev 'stdio:bootable.iso'
+Media current: stdio file, overwriteable
+Media status : is blank
+Media summary: 0 sessions, 0 data blocks, 0 data,  135g free
+Added to ISO image: directory '/'='/tmp/grub.uLz91i'
+xorriso : UPDATE : 578 files added in 1 seconds
+Added to ISO image: directory '/'='/home/bernard/workspace/rt-thread/bsp/x86/root'
+xorriso : UPDATE : 582 files added in 1 seconds
+xorriso : NOTE : Copying to System Area: 512 bytes from file '/usr/lib/grub/i386-pc/boot_hybrid.img'
+ISO image produced: 6007 sectors
+Written to medium : 6007 sectors at LBA 0
+Writing to 'stdio:bootable.iso' completed successfully.
+
+
+ \ | /
+- RT -     Thread Operating System
+ / | \     4.0.4 build Aug 22 2021
+ 2006 - 2021 Copyright by rt-thread team
+Floppy Inc : NEC765B controller  Floppy Type : 2.88MB
+hello!
+msh />
+```
+
+在qemu下可以按Ctrl-A + X退出qemu。

+ 3 - 3
bsp/x86/applications/mnt.c

@@ -11,7 +11,7 @@ extern int rt_floppy_init(void);
 
 int mnt_init(void)
 {
-    rt_floppy_init();
-
-    return 0;
+    return rt_floppy_init();
 }
+INIT_ENV_EXPORT(mnt_init);
+

+ 4 - 0
bsp/x86/dbg.sh

@@ -0,0 +1,4 @@
+cp rtthread.elf root
+grub-mkrescue -o bootable.iso root
+
+qemu-system-i386 -cdrom bootable.iso -boot d -nographic -S -s

+ 7 - 0
bsp/x86/root/boot/grub/grub.cfg

@@ -0,0 +1,7 @@
+set timeout=0
+set default=0
+
+menuentry "boot RT-Thread" {
+    multiboot /rtthread.elf
+    boot
+}

+ 15 - 4
bsp/x86/rtconfig.h

@@ -19,10 +19,11 @@
 #define RT_USING_TIMER_SOFT
 #define RT_TIMER_THREAD_PRIO 4
 #define RT_TIMER_THREAD_STACK_SIZE 2048
+
+/* kservice optimization */
+
 #define RT_DEBUG
 #define RT_DEBUG_COLOR
-#define RT_DEBUG_INIT_CONFIG
-#define RT_DEBUG_INIT 1
 
 /* Inter-Thread communication */
 
@@ -45,7 +46,7 @@
 #define RT_USING_CONSOLE
 #define RT_CONSOLEBUF_SIZE 256
 #define RT_CONSOLE_DEVICE_NAME "console"
-#define RT_VER_NUM 0x40003
+#define RT_VER_NUM 0x40004
 #define ARCH_IA32
 
 /* RT-Thread Components */
@@ -105,6 +106,7 @@
 #define RT_SYSTEM_WORKQUEUE_STACKSIZE 2048
 #define RT_SYSTEM_WORKQUEUE_PRIORITY 23
 #define RT_USING_SERIAL
+#define RT_USING_SERIAL_V1
 #define RT_SERIAL_USING_DMA
 #define RT_SERIAL_RB_BUFSZ 64
 #define RT_USING_PIN
@@ -115,6 +117,7 @@
 /* POSIX layer and C standard library */
 
 #define RT_USING_LIBC
+#define RT_LIBC_DEFAULT_TIMEZONE 8
 
 /* Network */
 
@@ -136,6 +139,9 @@
 /* Utilities */
 
 
+/* RT-Thread Utestcases */
+
+
 /* RT-Thread online packages */
 
 /* IoT - internet of things */
@@ -166,6 +172,8 @@
 
 /* system packages */
 
+/* acceleration: Assembly language or algorithmic acceleration packages */
+
 
 /* Micrium: Micrium software products porting for RT-Thread */
 
@@ -173,13 +181,16 @@
 /* peripheral libraries and drivers */
 
 
+/* AI packages */
+
+
 /* miscellaneous packages */
 
 
 /* samples: kernel and components samples */
 
 
-/* games: games run on RT-Thread console */
+/* entertainment: terminal games and other interesting software packages */
 
 #define IA32
 

+ 5 - 18
bsp/x86/rtconfig.py

@@ -3,36 +3,23 @@ import os
 # toolchains options
 ARCH='ia32'
 CPU=''
-CROSS_TOOL='gcc'
-
-if os.getenv('RTT_CC'):
-    CROSS_TOOL = os.getenv('RTT_CC')
+CROSS_TOOL= os.getenv('RTT_CC') or 'gcc'
 
 # cross_tool provides the cross compiler
 # EXEC_PATH is the compiler execute path, for example, CodeSourcery,
 
 if  CROSS_TOOL == 'gcc':
     PLATFORM    = 'gcc'
-    EXEC_PATH   = 'E:/Program Files/CodeSourcery/Sourcery_CodeBench_Lite_for_IA32_ELF/bin'
-elif CROSS_TOOL == 'keil':
-    print('================ERROR============================')
-    print('Not support keil yet!')
-    print('=================================================')
-    exit(0)
-elif CROSS_TOOL == 'iar':
-    print('================ERROR============================')
-    print('Not support iar yet!')
-    print('=================================================')
+    EXEC_PATH   = os.getenv('RTT_EXEC_PATH') or 'E:/Program Files/CodeSourcery/Sourcery_CodeBench_Lite_for_IA32_ELF/bin'
+else:
+    print('Unknown toolchains, only support GCC')
     exit(0)
 
-if os.getenv('RTT_EXEC_PATH'):
-    EXEC_PATH = os.getenv('RTT_EXEC_PATH')
-
 BUILD = 'debug'
 
 if PLATFORM == 'gcc':
     # toolchains
-    PREFIX = 'i686-elf-'
+    PREFIX = 'i386-unknown-elf-'
     CC = PREFIX + 'gcc'
     AS = PREFIX + 'gcc'
     AR = PREFIX + 'ar'

+ 4 - 0
bsp/x86/run.sh

@@ -0,0 +1,4 @@
+cp rtthread.elf root
+grub-mkrescue -o bootable.iso root
+
+qemu-system-i386 -cdrom bootable.iso -boot d -nographic

+ 0 - 28
bsp/x86/src/extract.sh

@@ -1,28 +0,0 @@
-#! /bin/sh
-
-
-imap=$1
-iout=$2
-
-echo "!!! extract symbol from $imap to $iout !!!"
-
-symlist="rt_kprintf \
-rt_kputs \
-rt_vsprintf \
-rt_sprintf \
-rt_snprintf \
-rt_thread_create \
-"
-
-echo "#ifndef RT_THREAD_SYM_H_H" > $iout
-echo "#define RT_THREAD_SYM_H_H" >> $iout
-
-for sym in $symlist
-do
-dlim=`echo $sym | cut -b 1`
-addr=`cat $imap | grep $sym | head -n 1 | cut -d $dlim -f 1`
-
-echo "#define __abs_$sym $addr" >> $iout
-done
-
-echo "#endif /* RT_THREAD_SYM_H_H */" >> $iout

+ 0 - 36
bsp/x86/src/hello.c

@@ -1,36 +0,0 @@
-
-#include <stdio.h>
-const char* g_str = "Hello World!";
-
-static int a = 1234;
-int b = 5678;
-
-extern void rt_kprintf(const char* fmt,...);
-
-int add(int a, int b)
-{
-    return a+b;
-}
-
-int main(int argc, char* argv[])
-{
-    int i;
-    char str[32] = "Hello World\n";
-
-    for(i=0; i<argc; i++)
-    {
-        printf("argv[%d]='%s'\n", i, argv[i]);
-    }
-
-    printf(str);
-
-    printf("g_str address is %ph\n",g_str);
-    puts(g_str);
-
-    rt_kprintf("\nnative rt_kprintf a(%ph)=%d, b(%ph)=%d\n", &a, a, &b, b);
-
-    printf("%d+%d=%d\n", 4, 5, add(4, 5));
-
-    return 0xdeadbeef;
-}
-

+ 0 - 18
bsp/x86/src/stdio.h

@@ -1,18 +0,0 @@
-#ifndef __STDIO_H_H
-#define __STDIO_H_H
-
-#include <rt_thread_sym.h>
-
-typedef unsigned int size_t;
-
-typedef int (*sprintf_fcn_t)(char *buf ,const char *format, ...);
-typedef int (*snprintf_fcn_t)(char *buf, size_t size, const char *format, ...);
-typedef void (*puts_fcn_t)(const char *str);
-typedef void (*printf_fcn_t)(const char *fmt, ...);
-
-#define printf ((printf_fcn_t)__abs_rt_kprintf)
-#define puts ((printf_fcn_t)__abs_rt_kputs)
-#define sprintf ((printf_fcn_t)__abs_rt_sprintf)
-#define snprintf ((printf_fcn_t)__abs_rt_snprintf)
-
-#endif

+ 8 - 0
components/drivers/include/ipc/ringbuffer.h

@@ -5,6 +5,7 @@
  *
  * Change Logs:
  * Date           Author       Notes
+ * 2021-08-14     Jackistang   add comments for function interface.
  */
 #ifndef RINGBUFFER_H__
 #define RINGBUFFER_H__
@@ -80,6 +81,13 @@ struct rt_ringbuffer* rt_ringbuffer_create(rt_uint16_t length);
 void rt_ringbuffer_destroy(struct rt_ringbuffer *rb);
 #endif
 
+/**
+ * @brief Get the buffer size of the ring buffer object.
+ *
+ * @param rb        A pointer to the ring buffer object.
+ *
+ * @return  Buffer size.
+ */
 rt_inline rt_uint16_t rt_ringbuffer_get_size(struct rt_ringbuffer *rb)
 {
     RT_ASSERT(rb != RT_NULL);

+ 8 - 0
components/drivers/include/ipc/workqueue.h

@@ -6,6 +6,7 @@
  * Change Logs:
  * Date           Author       Notes
  * 2021-08-01     Meco Man     remove rt_delayed_work_init() and rt_delayed_work structure
+ * 2021-08-14     Jackistang   add comments for rt_work_init()
  */
 #ifndef WORKQUEUE_H__
 #define WORKQUEUE_H__
@@ -67,6 +68,13 @@ rt_err_t rt_work_submit(struct rt_work *work, rt_tick_t time);
 rt_err_t rt_work_cancel(struct rt_work *work);
 #endif /* RT_USING_SYSTEM_WORKQUEUE */
 
+/**
+ * @brief Initialize a work item, binding with a callback function.
+ *
+ * @param work          A pointer to the work item object.
+ * @param work_func     A callback function that will be called when this work item is executed.
+ * @param work_data     A user data passed to the callback function as the second parameter.
+ */
 rt_inline void rt_work_init(struct rt_work *work, void (*work_func)(struct rt_work *work, void *work_data),
                             void *work_data)
 {

+ 84 - 17
components/drivers/src/ringbuffer.c

@@ -9,6 +9,7 @@
  * 2013-05-08     Grissiom     reimplement
  * 2016-08-18     heyuanjie    add interface
  * 2021-07-20     arminker     fix write_index bug in function rt_ringbuffer_put_force
+ * 2021-08-14     Jackistang   add comments for function interface.
  */
 
 #include <rtthread.h>
@@ -27,6 +28,13 @@ rt_inline enum rt_ringbuffer_state rt_ringbuffer_status(struct rt_ringbuffer *rb
     return RT_RINGBUFFER_HALFFULL;
 }
 
+/**
+ * @brief Initialize the ring buffer object.
+ *
+ * @param rb        A pointer to the ring buffer object.
+ * @param pool      A pointer to the buffer.
+ * @param size      The size of the buffer in bytes.
+ */
 void rt_ringbuffer_init(struct rt_ringbuffer *rb,
                         rt_uint8_t           *pool,
                         rt_int16_t            size)
@@ -45,7 +53,13 @@ void rt_ringbuffer_init(struct rt_ringbuffer *rb,
 RTM_EXPORT(rt_ringbuffer_init);
 
 /**
- * put a block of data into ring buffer
+ * @brief Put a block of data into the ring buffer. If the capacity of ring buffer is insufficient, it will discard out-of-range data.
+ *
+ * @param rb            A pointer to the ring buffer object.
+ * @param ptr           A pointer to the data buffer.
+ * @param length        The size of data in bytes.
+ *
+ * @return Return the data size we put into the ring buffer.
  */
 rt_size_t rt_ringbuffer_put(struct rt_ringbuffer *rb,
                             const rt_uint8_t     *ptr,
@@ -92,9 +106,13 @@ rt_size_t rt_ringbuffer_put(struct rt_ringbuffer *rb,
 RTM_EXPORT(rt_ringbuffer_put);
 
 /**
- * put a block of data into ring buffer
+ * @brief Put a block of data into the ring buffer. If the capacity of ring buffer is insufficient, it will overwrite the existing data in the ring buffer.
+ *
+ * @param rb            A pointer to the ring buffer object.
+ * @param ptr           A pointer to the data buffer.
+ * @param length        The size of data in bytes.
  *
- * When the buffer is full, it will discard the old data.
+ * @return Return the data size we put into the ring buffer.
  */
 rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb,
                             const rt_uint8_t     *ptr,
@@ -149,7 +167,13 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb,
 RTM_EXPORT(rt_ringbuffer_put_force);
 
 /**
- *  get data from ring buffer
+ * @brief Get data from the ring buffer.
+ *
+ * @param rb            A pointer to the ring buffer.
+ * @param ptr           A pointer to the data buffer.
+ * @param length        The size of the data we want to read from the ring buffer.
+ *
+ * @return Return the data size we read from the ring buffer.
  */
 rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb,
                             rt_uint8_t           *ptr,
@@ -196,7 +220,14 @@ rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb,
 RTM_EXPORT(rt_ringbuffer_get);
 
 /**
- *  peak data from ring buffer
+ * @brief Get the first readable byte of the ring buffer.
+ *
+ * @param rb        A pointer to the ringbuffer.
+ * @param ptr       When this function return, *ptr is a pointer to the first readable byte of the ring buffer.
+ *
+ * @note It is recommended to read only one byte, otherwise it may cause buffer overflow.
+ *
+ * @return Return the size of the ring buffer.
  */
 rt_size_t rt_ringbuffer_peak(struct rt_ringbuffer *rb, rt_uint8_t **ptr)
 {
@@ -230,7 +261,12 @@ rt_size_t rt_ringbuffer_peak(struct rt_ringbuffer *rb, rt_uint8_t **ptr)
 RTM_EXPORT(rt_ringbuffer_peak);
 
 /**
- * put a character into ring buffer
+ * @brief Put a byte into the ring buffer. If ring buffer is full, this operation will fail.
+ *
+ * @param rb        A pointer to the ring buffer object.
+ * @param ch        A byte put into the ring buffer.
+ *
+ * @return Return the data size we put into the ring buffer. The ring buffer is full if returns 0. Otherwise, it will return 1.
  */
 rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer *rb, const rt_uint8_t ch)
 {
@@ -258,9 +294,12 @@ rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer *rb, const rt_uint8_t ch)
 RTM_EXPORT(rt_ringbuffer_putchar);
 
 /**
- * put a character into ring buffer
+ * @brief Put a byte into the ring buffer. If ring buffer is full, it will discard an old data and put into a new data.
+ *
+ * @param rb        A pointer to the ring buffer object.
+ * @param ch        A byte put into the ring buffer.
  *
- * When the buffer is full, it will discard one old data.
+ * @return Return the data size we put into the ring buffer. Always return 1.
  */
 rt_size_t rt_ringbuffer_putchar_force(struct rt_ringbuffer *rb, const rt_uint8_t ch)
 {
@@ -295,7 +334,13 @@ rt_size_t rt_ringbuffer_putchar_force(struct rt_ringbuffer *rb, const rt_uint8_t
 RTM_EXPORT(rt_ringbuffer_putchar_force);
 
 /**
- * get a character from a ringbuffer
+ * @brief Get a byte from the ring buffer.
+ *
+ * @param rb        The pointer to the ring buffer object.
+ * @param ch        A pointer to the buffer, used to store one byte.
+ *
+ * @return 0    The ring buffer is empty.
+ * @return 1    Success
  */
 rt_size_t rt_ringbuffer_getchar(struct rt_ringbuffer *rb, rt_uint8_t *ch)
 {
@@ -305,7 +350,7 @@ rt_size_t rt_ringbuffer_getchar(struct rt_ringbuffer *rb, rt_uint8_t *ch)
     if (!rt_ringbuffer_data_len(rb))
         return 0;
 
-    /* put character */
+    /* put byte */
     *ch = rb->buffer_ptr[rb->read_index];
 
     if (rb->read_index == rb->buffer_size-1)
@@ -323,7 +368,11 @@ rt_size_t rt_ringbuffer_getchar(struct rt_ringbuffer *rb, rt_uint8_t *ch)
 RTM_EXPORT(rt_ringbuffer_getchar);
 
 /**
- * get the size of data in rb
+ * @brief Get the size of data in the ring buffer in bytes.
+ *
+ * @param rb        The pointer to the ring buffer object.
+ *
+ * @return Return the size of data in the ring buffer in bytes.
  */
 rt_size_t rt_ringbuffer_data_len(struct rt_ringbuffer *rb)
 {
@@ -335,16 +384,22 @@ rt_size_t rt_ringbuffer_data_len(struct rt_ringbuffer *rb)
         return rb->buffer_size;
     case RT_RINGBUFFER_HALFFULL:
     default:
-        if (rb->write_index > rb->read_index)
-            return rb->write_index - rb->read_index;
+    {
+        rt_size_t wi = rb->write_index, ri = rb->read_index;
+
+        if (wi > ri)
+            return wi - ri;
         else
-            return rb->buffer_size - (rb->read_index - rb->write_index);
-    };
+            return rb->buffer_size - (ri - wi);
+    }
+    }
 }
 RTM_EXPORT(rt_ringbuffer_data_len);
 
 /**
- * empty the rb
+ * @brief Reset the ring buffer object, and clear all contents in the buffer.
+ *
+ * @param rb        A pointer to the ring buffer object.
  */
 void rt_ringbuffer_reset(struct rt_ringbuffer *rb)
 {
@@ -359,7 +414,14 @@ RTM_EXPORT(rt_ringbuffer_reset);
 
 #ifdef RT_USING_HEAP
 
-struct rt_ringbuffer* rt_ringbuffer_create(rt_uint16_t size)
+/**
+ * @brief Create a ring buffer object with a given size.
+ *
+ * @param size      The size of the buffer in bytes.
+ *
+ * @return Return a pointer to ring buffer object. When the return value is RT_NULL, it means this creation failed.
+ */
+struct rt_ringbuffer *rt_ringbuffer_create(rt_uint16_t size)
 {
     struct rt_ringbuffer *rb;
     rt_uint8_t *pool;
@@ -386,6 +448,11 @@ exit:
 }
 RTM_EXPORT(rt_ringbuffer_create);
 
+/**
+ * @brief Destroy the ring buffer object, which is created by rt_ringbuffer_create() .
+ *
+ * @param rb        A pointer to the ring buffer object.
+ */
 void rt_ringbuffer_destroy(struct rt_ringbuffer *rb)
 {
     RT_ASSERT(rb != RT_NULL);

+ 87 - 0
components/drivers/src/workqueue.c

@@ -7,6 +7,7 @@
  * Date           Author       Notes
  * 2017-02-27     Bernard      fix the re-work issue.
  * 2021-08-01     Meco Man     remove rt_delayed_work_init()
+ * 2021-08-14     Jackistang   add comments for function interface.
  */
 
 #include <rthw.h>
@@ -209,6 +210,15 @@ static void _delayed_work_timeout_handler(void *parameter)
     }
 }
 
+/**
+ * @brief Create a work queue with a thread inside.
+ *
+ * @param name          The name of the work queue thread.
+ * @param stack_size    The stack size of the work queue thread.
+ * @param priority      The priority of the work queue thread.
+ *
+ * @return Return A pointer to the workqueue object. It will return RT_NULL if failed.
+ */
 struct rt_workqueue *rt_workqueue_create(const char *name, rt_uint16_t stack_size, rt_uint8_t priority)
 {
     struct rt_workqueue *queue = RT_NULL;
@@ -236,6 +246,13 @@ struct rt_workqueue *rt_workqueue_create(const char *name, rt_uint16_t stack_siz
     return queue;
 }
 
+/**
+ * @brief Destroy a work queue.
+ *
+ * @param queue         A pointer to the workqueue object.
+ *
+ * @return RT_EOK       Success.
+ */
 rt_err_t rt_workqueue_destroy(struct rt_workqueue *queue)
 {
     RT_ASSERT(queue != RT_NULL);
@@ -248,6 +265,15 @@ rt_err_t rt_workqueue_destroy(struct rt_workqueue *queue)
     return RT_EOK;
 }
 
+/**
+ * @brief Submit a work item to the work queue without delay.
+ *
+ * @param queue         A pointer to the workqueue object.
+ * @param work          A pointer to the work item object.
+ *
+ * @return RT_EOK       Success.
+ * @return -RT_EBUSY    This work item is executing.
+ */
 rt_err_t rt_workqueue_dowork(struct rt_workqueue *queue, struct rt_work *work)
 {
     RT_ASSERT(queue != RT_NULL);
@@ -256,6 +282,17 @@ rt_err_t rt_workqueue_dowork(struct rt_workqueue *queue, struct rt_work *work)
     return _workqueue_submit_work(queue, work, 0);
 }
 
+/**
+ * @brief Submit a work item to the work queue with a delay.
+ *
+ * @param queue     A pointer to the workqueue object.
+ * @param work      A pointer to the work item object.
+ * @param time      The delay time (unit: OS ticks) for the work item to be submitted to the work queue.
+ *
+ * @return RT_EOK       Success.
+ * @return -RT_EBUSY    This work item is executing.
+ * @return -RT_ERROR    The time parameter is invalid.
+ */
 rt_err_t rt_workqueue_submit_work(struct rt_workqueue *queue, struct rt_work *work, rt_tick_t time)
 {
     RT_ASSERT(queue != RT_NULL);
@@ -264,6 +301,14 @@ rt_err_t rt_workqueue_submit_work(struct rt_workqueue *queue, struct rt_work *wo
     return _workqueue_submit_work(queue, work, time);
 }
 
+/**
+ * @brief Submit a work item to the work queue without delay. This work item will be executed after the current work item.
+ *
+ * @param queue     A pointer to the workqueue object.
+ * @param work      A pointer to the work item object.
+ *
+ * @return RT_EOK   Success.
+ */
 rt_err_t rt_workqueue_critical_work(struct rt_workqueue *queue, struct rt_work *work)
 {
     rt_base_t level;
@@ -291,6 +336,15 @@ rt_err_t rt_workqueue_critical_work(struct rt_workqueue *queue, struct rt_work *
     return RT_EOK;
 }
 
+/**
+ * @brief Cancel a work item in the work queue.
+ *
+ * @param queue     A pointer to the workqueue object.
+ * @param work      A pointer to the work item object.
+ *
+ * @return RT_EOK       Success.
+ * @return -RT_EBUSY    This work item is executing.
+ */
 rt_err_t rt_workqueue_cancel_work(struct rt_workqueue *queue, struct rt_work *work)
 {
     RT_ASSERT(work != RT_NULL);
@@ -298,6 +352,14 @@ rt_err_t rt_workqueue_cancel_work(struct rt_workqueue *queue, struct rt_work *wo
     return _workqueue_cancel_work(queue, work);
 }
 
+/**
+ * @brief Cancel a work item in the work queue. If the work item is executing, this function will block until it is done.
+ *
+ * @param queue     A pointer to the workqueue object.
+ * @param work      A pointer to the work item object.
+ *
+ * @return RT_EOK       Success.
+ */
 rt_err_t rt_workqueue_cancel_work_sync(struct rt_workqueue *queue, struct rt_work *work)
 {
     RT_ASSERT(queue != RT_NULL);
@@ -316,6 +378,13 @@ rt_err_t rt_workqueue_cancel_work_sync(struct rt_workqueue *queue, struct rt_wor
     return RT_EOK;
 }
 
+/**
+ * @brief This function will cancel all work items in work queue.
+ *
+ * @param queue     A pointer to the workqueue object.
+ *
+ * @return RT_EOK       Success.
+ */
 rt_err_t rt_workqueue_cancel_all_work(struct rt_workqueue *queue)
 {
     struct rt_work *work;
@@ -343,11 +412,29 @@ rt_err_t rt_workqueue_cancel_all_work(struct rt_workqueue *queue)
 #ifdef RT_USING_SYSTEM_WORKQUEUE
 static struct rt_workqueue *sys_workq;
 
+/**
+ * @brief Submit a work item to the system work queue with a delay.
+ *
+ * @param work      A pointer to the work item object.
+ * @param time      The delay time (unit: OS ticks) for the work item to be submitted to the work queue.
+ *
+ * @return RT_EOK       Success.
+ * @return -RT_EBUSY    This work item is executing.
+ * @return -RT_ERROR    The time parameter is invalid.
+ */
 rt_err_t rt_work_submit(struct rt_work *work, rt_tick_t time)
 {
     return rt_workqueue_submit_work(sys_workq, work, time);
 }
 
+/**
+ * @brief Cancel a work item in the system work queue.
+ *
+ * @param work      A pointer to the work item object.
+ *
+ * @return RT_EOK       Success.
+ * @return -RT_EBUSY    This work item is executing.
+ */
 rt_err_t rt_work_cancel(struct rt_work *work)
 {
     return rt_workqueue_cancel_work(sys_workq, work);

+ 1 - 1
components/drivers/watchdog/watchdog.c

@@ -89,7 +89,7 @@ rt_err_t rt_hw_watchdog_register(struct rt_watchdog_device *wtd,
 
     device = &(wtd->parent);
 
-    device->type        = RT_Device_Class_Miscellaneous;
+    device->type        = RT_Device_Class_Security;
     device->rx_indicate = RT_NULL;
     device->tx_complete = RT_NULL;
 

+ 1 - 0
components/finsh/cmd.c

@@ -822,6 +822,7 @@ static char *const device_type_str[] =
     "Sensor Device",
     "Touch Device",
     "Phy Device",
+    "Security Device",
     "Unknown"
 };
 

+ 4 - 4
components/finsh/shell.c

@@ -164,7 +164,7 @@ void finsh_set_prompt_mode(rt_uint32_t prompt_mode)
     shell->prompt_mode = prompt_mode;
 }
 
-static int finsh_getchar(void)
+char finsh_getchar(void)
 {
 #ifdef RT_USING_DEVICE
 #ifdef RT_USING_POSIX
@@ -176,7 +176,7 @@ static int finsh_getchar(void)
     while (rt_device_read(shell->device, -1, &ch, 1) != 1)
         rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER);
 
-    return (int)ch;
+    return ch;
 #endif
 #else
     extern char rt_hw_console_getchar(void);
@@ -329,7 +329,7 @@ static void finsh_wait_auth(void)
             while (1)
             {
                 /* read one character from device */
-                ch = finsh_getchar();
+                ch = (int)finsh_getchar();
                 if (ch < 0)
                 {
                     continue;
@@ -541,7 +541,7 @@ void finsh_thread_entry(void *parameter)
 
     while (1)
     {
-        ch = finsh_getchar();
+        ch = (int)finsh_getchar();
         if (ch < 0)
         {
             continue;

+ 1 - 0
components/finsh/shell.h

@@ -97,6 +97,7 @@ rt_uint32_t finsh_get_echo(void);
 int finsh_system_init(void);
 void finsh_set_device(const char* device_name);
 const char* finsh_get_device(void);
+char finsh_getchar(void);
 
 rt_uint32_t finsh_get_prompt_mode(void);
 void finsh_set_prompt_mode(rt_uint32_t prompt_mode);

+ 40 - 0
components/utilities/utest/utest.c

@@ -46,12 +46,17 @@ static rt_uint8_t utest_log_lv = UTEST_LOG_ALL;
 static utest_tc_export_t tc_table = RT_NULL;
 static rt_size_t tc_num;
 static rt_uint32_t tc_loop;
+static rt_uint8_t *tc_fail_list;
 static struct utest local_utest = {UTEST_PASSED, 0, 0};
 
 #if defined(__ICCARM__) || defined(__ICCRX__)         /* for IAR compiler */
 #pragma section="UtestTcTab"
 #endif
 
+#define TC_FAIL_LIST_SIZE                (RT_ALIGN(tc_num, 8) / 8)
+#define TC_FAIL_LIST_MARK_FAILED(index)  (tc_fail_list[RT_ALIGN(index, 8) / 8] |= (1UL << (index % 8)))
+#define TC_FAIL_LIST_IS_FAILED(index)    (tc_fail_list[RT_ALIGN(index, 8) / 8] &  (1UL << (index % 8)))
+
 void utest_log_lv_set(rt_uint8_t lv)
 {
     if (lv == UTEST_LOG_ALL || lv == UTEST_LOG_ASSERT)
@@ -80,6 +85,14 @@ int utest_init(void)
 
     LOG_I("utest is initialize success.");
     LOG_I("total utest testcase num: (%d)", tc_num);
+    if (tc_num > 0)
+    {
+        tc_fail_list = rt_malloc(TC_FAIL_LIST_SIZE);
+        if(!tc_fail_list)
+        {
+            LOG_E("no memory, tc_fail_list init failed!");
+        }
+    }
     return tc_num;
 }
 INIT_COMPONENT_EXPORT(utest_init);
@@ -147,6 +160,8 @@ static void utest_run(const char *utest_name)
     rt_size_t i;
     rt_uint32_t index;
     rt_bool_t is_find;
+    rt_uint32_t tc_fail_num = 0;
+    rt_uint32_t tc_run_num = 0;
 
     rt_thread_mdelay(1000);
 
@@ -154,6 +169,14 @@ static void utest_run(const char *utest_name)
     {
         i = 0;
         is_find = RT_FALSE;
+
+        tc_fail_num = 0;
+        tc_run_num = 0;
+        if (tc_fail_list)
+        {
+            memset(tc_fail_list, 0, TC_FAIL_LIST_SIZE);
+        }
+
         LOG_I("[==========] [ utest    ] loop %d/%d", index + 1, tc_loop);
         LOG_I("[==========] [ utest    ] started");
         while(i < tc_num)
@@ -192,6 +215,8 @@ static void utest_run(const char *utest_name)
                 }
                 else
                 {
+                    TC_FAIL_LIST_MARK_FAILED(i);
+                    tc_fail_num ++;
                     LOG_E("[  FAILED  ] [ result   ] testcase (%s)", tc_table[i].name);
                 }
             }
@@ -212,6 +237,7 @@ static void utest_run(const char *utest_name)
     __tc_continue:
             LOG_I("[----------] [ testcase ] (%s) finished", tc_table[i].name);
 
+            tc_run_num ++;
             i++;
         }
 
@@ -223,6 +249,20 @@ static void utest_run(const char *utest_name)
         }
 
         LOG_I("[==========] [ utest    ] finished");
+        LOG_I("[==========] [ utest    ] %d tests from %d testcase ran.", tc_run_num, tc_num);
+        LOG_I("[  PASSED  ] [ result   ] %d tests.", tc_run_num - tc_fail_num);
+
+        if(tc_fail_list && (tc_fail_num > 0))
+        {
+            LOG_E("[  FAILED  ] [ result   ] %d tests, listed below:", tc_fail_num);
+            for(i = 0; i < tc_num; i ++)
+            {
+                if (TC_FAIL_LIST_IS_FAILED(i))
+                {
+                    LOG_E("[  FAILED  ] [ result   ] %s", tc_table[i].name);
+                }
+            }
+        }
     }
 }
 

+ 2 - 1
examples/utest/configs/kernel/ipc.conf

@@ -1,4 +1,5 @@
 CONFIG_UTEST_SEMAPHORE_TC=y
-
+CONFIG_UTEST_EVENT_TC=y
 # dependencies
 CONFIG_RT_USING_SEMAPHORE=y
+CONFIG_RT_USING_EVENT=y

+ 9 - 0
examples/utest/testcases/kernel/Kconfig

@@ -5,9 +5,18 @@ config UTEST_MEMHEAP_TC
     default y
     depends on RT_USING_MEMHEAP
 
+config UTEST_IRQ_TC
+    bool "IRQ test"
+    default n
+
 config UTEST_SEMAPHORE_TC
     bool "semaphore test"
     default n
     depends on RT_USING_SEMAPHORE
 
+config UTEST_EVENT_TC
+    bool "event test"
+    default n
+    depends on RT_USING_EVENT
+
 endmenu

+ 6 - 0
examples/utest/testcases/kernel/SConscript

@@ -8,9 +8,15 @@ src     = Split('''
 if GetDepend(['UTEST_MEMHEAP_TC']):
     src += ['memheap_tc.c']
 
+if GetDepend(['UTEST_IRQ_TC']):
+    src += ['irq_tc.c']
+    
 if GetDepend(['UTEST_SEMAPHORE_TC']):
     src += ['semaphore_tc.c']
 
+if GetDepend(['UTEST_EVENT_TC']):
+    src += ['event_tc.c']
+
 CPPPATH = [cwd]
 
 group = DefineGroup('utestcases', src, depend = [], CPPPATH = CPPPATH)

+ 344 - 0
examples/utest/testcases/kernel/event_tc.c

@@ -0,0 +1,344 @@
+/*
+ * Copyright (c) 2006-2019, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2021-08-15     liukang     the first version
+ */
+
+#include <rtthread.h>
+#include "utest.h"
+#include <stdlib.h>
+
+#define EVENT_FLAG3 (1 << 3)
+#define EVENT_FLAG5 (1 << 5)
+
+static struct rt_event static_event = {0};
+#ifdef RT_USING_HEAP
+static rt_event_t dynamic_event = RT_NULL;
+static rt_uint32_t dynamic_event_recv_thread_finish = 0, dynamic_event_send_thread_finish = 0;
+
+ALIGN(RT_ALIGN_SIZE)
+static char thread3_stack[1024];
+static struct rt_thread thread3;
+
+ALIGN(RT_ALIGN_SIZE)
+static char thread4_stack[1024];
+static struct rt_thread thread4;
+#endif /* RT_USING_HEAP */
+
+static rt_uint32_t recv_event_times1 = 0, recv_event_times2 = 0;
+static rt_uint32_t static_event_recv_thread_finish = 0, static_event_send_thread_finish = 0;
+
+ALIGN(RT_ALIGN_SIZE)
+static char thread1_stack[1024];
+static struct rt_thread thread1;
+
+ALIGN(RT_ALIGN_SIZE)
+static char thread2_stack[1024];
+static struct rt_thread thread2;
+
+#define THREAD_PRIORITY      9
+#define THREAD_TIMESLICE     5
+
+static void test_event_init(void)
+{
+    rt_err_t result;
+
+    result = rt_event_init(&static_event, "event", RT_IPC_FLAG_PRIO);
+    if (result != RT_EOK)
+    {
+        uassert_false(1);
+    }
+    result = rt_event_detach(&static_event);
+    if (result != RT_EOK)
+    {
+        uassert_false(1);
+    }
+
+    result = rt_event_init(&static_event, "event", RT_IPC_FLAG_FIFO);
+    if (result != RT_EOK)
+    {
+        uassert_false(1);
+    }
+    result = rt_event_detach(&static_event);
+    if (result != RT_EOK)
+    {
+        uassert_false(1);
+    }
+
+    uassert_true(1);
+}
+
+static void test_event_detach(void)
+{
+    rt_err_t result = RT_EOK;
+
+    result = rt_event_init(&static_event, "event", RT_IPC_FLAG_PRIO);
+    if (result != RT_EOK)
+    {
+        uassert_false(1);
+    }
+
+    result = rt_event_detach(&static_event);
+    if (result != RT_EOK)
+    {
+        uassert_false(1);
+    }
+
+    uassert_true(1);
+}
+
+static void thread1_recv_static_event(void *param)
+{
+    rt_uint32_t e;
+
+    if (rt_event_recv(&static_event, (EVENT_FLAG3 | EVENT_FLAG5),
+                      RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
+                      RT_WAITING_FOREVER, &e) != RT_EOK)
+    {
+        return;
+    }
+
+    recv_event_times1 = e;
+
+    rt_thread_mdelay(50);
+
+    if (rt_event_recv(&static_event, (EVENT_FLAG3 | EVENT_FLAG5),
+                      RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR,
+                      RT_WAITING_FOREVER, &e) != RT_EOK)
+    {
+        return;
+    }
+    recv_event_times2 = e;
+
+    static_event_recv_thread_finish = 1;
+}
+
+static void thread2_send_static_event(void *param)
+{
+    rt_event_send(&static_event, EVENT_FLAG3);
+    rt_thread_mdelay(10);
+
+    rt_event_send(&static_event, EVENT_FLAG5);
+    rt_thread_mdelay(10);
+
+    rt_event_send(&static_event, EVENT_FLAG3);
+
+    static_event_send_thread_finish = 1;
+}
+
+
+static void test_static_event_send_recv(void)
+{
+    rt_err_t result = RT_EOK;
+
+    result  = rt_event_init(&static_event, "event", RT_IPC_FLAG_PRIO);
+    if (result  != RT_EOK)
+    {
+        uassert_false(1);
+    }
+
+    rt_thread_init(&thread1,
+                   "thread1",
+                   thread1_recv_static_event,
+                   RT_NULL,
+                   &thread1_stack[0],
+                   sizeof(thread1_stack),
+                   THREAD_PRIORITY - 1, THREAD_TIMESLICE);
+    rt_thread_startup(&thread1);
+
+    rt_thread_init(&thread2,
+                   "thread2",
+                   thread2_send_static_event,
+                   RT_NULL,
+                   &thread2_stack[0],
+                   sizeof(thread2_stack),
+                   THREAD_PRIORITY, THREAD_TIMESLICE);
+    rt_thread_startup(&thread2);
+
+    while (static_event_recv_thread_finish != 1 || static_event_send_thread_finish != 1)
+    {
+        rt_thread_delay(1);
+    }
+
+    if (recv_event_times1 == EVENT_FLAG3 && recv_event_times2 == (EVENT_FLAG3 | EVENT_FLAG5))
+    {
+        if (rt_event_detach(&static_event) != RT_EOK)
+        {
+            uassert_false(1);
+        }
+        uassert_true(1);
+    }
+    else
+    {
+        if (rt_event_detach(&static_event) != RT_EOK)
+        {
+            uassert_false(1);
+        }
+        uassert_false(1);
+    }
+
+    return;
+}
+
+#ifdef RT_USING_HEAP
+static void test_event_create(void)
+{
+    rt_err_t result = RT_EOK;
+
+    dynamic_event = rt_event_create("dynamic_event", RT_IPC_FLAG_FIFO);
+    if (dynamic_event == RT_NULL)
+    {
+        uassert_false(1);
+    }
+
+    result = rt_event_delete(dynamic_event);
+    if (result != RT_EOK)
+    {
+        uassert_false(1);
+    }
+
+    uassert_true(1);
+}
+
+static void test_event_delete(void)
+{
+    rt_err_t result;
+
+    dynamic_event = rt_event_create("dynamic_event", RT_IPC_FLAG_FIFO);
+    if (dynamic_event == RT_NULL)
+    {
+        uassert_false(1);
+    }
+
+    result = rt_event_delete(dynamic_event);
+    if (result != RT_EOK)
+    {
+        uassert_false(1);
+    }
+
+    uassert_true(1);
+}
+
+static void thread3_recv_dynamic_event(void *param)
+{
+    rt_uint32_t e;
+
+    if (rt_event_recv(dynamic_event, (EVENT_FLAG3 | EVENT_FLAG5),
+                      RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
+                      RT_WAITING_FOREVER, &e) != RT_EOK)
+    {
+        return;
+    }
+
+    recv_event_times1 = e;
+
+    rt_thread_mdelay(50);
+
+    if (rt_event_recv(dynamic_event, (EVENT_FLAG3 | EVENT_FLAG5),
+                      RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR,
+                      RT_WAITING_FOREVER, &e) != RT_EOK)
+    {
+        return;
+    }
+    recv_event_times2 = e;
+
+    dynamic_event_recv_thread_finish = 1;
+}
+
+static void thread4_send_dynamic_event(void *param)
+{
+    rt_event_send(dynamic_event, EVENT_FLAG3);
+    rt_thread_mdelay(10);
+
+    rt_event_send(dynamic_event, EVENT_FLAG5);
+    rt_thread_mdelay(10);
+
+    rt_event_send(dynamic_event, EVENT_FLAG3);
+
+    dynamic_event_send_thread_finish = 1;
+}
+
+static void test_dynamic_event_send_recv(void)
+{
+    dynamic_event = rt_event_create("dynamic_event", RT_IPC_FLAG_PRIO);
+    if (dynamic_event == RT_NULL)
+    {
+        uassert_false(1);
+    }
+
+    rt_thread_init(&thread3,
+                   "thread3",
+                   thread3_recv_dynamic_event,
+                   RT_NULL,
+                   &thread3_stack[0],
+                   sizeof(thread3_stack),
+                   THREAD_PRIORITY - 1, THREAD_TIMESLICE);
+    rt_thread_startup(&thread3);
+
+    rt_thread_init(&thread4,
+                   "thread4",
+                   thread4_send_dynamic_event,
+                   RT_NULL,
+                   &thread4_stack[0],
+                   sizeof(thread4_stack),
+                   THREAD_PRIORITY, THREAD_TIMESLICE);
+    rt_thread_startup(&thread4);
+
+    while (dynamic_event_recv_thread_finish != 1 || dynamic_event_send_thread_finish != 1)
+    {
+        rt_thread_delay(1);
+    }
+
+    if (recv_event_times1 == EVENT_FLAG3 && recv_event_times2 == (EVENT_FLAG3 | EVENT_FLAG5))
+    {
+        if (rt_event_delete(dynamic_event) != RT_EOK)
+        {
+            uassert_false(1);
+        }
+        uassert_true(1);
+    }
+    else
+    {
+        if (rt_event_delete(dynamic_event) != RT_EOK)
+        {
+            uassert_false(1);
+        }
+        uassert_false(1);
+    }
+
+    return;
+}
+#endif
+
+static rt_err_t utest_tc_init(void)
+{
+    static_event_recv_thread_finish = 0;
+    static_event_send_thread_finish = 0;
+#ifdef RT_USING_HEAP
+    dynamic_event_recv_thread_finish = 0;
+    dynamic_event_send_thread_finish = 0;
+#endif
+    return RT_EOK;
+}
+
+static rt_err_t utest_tc_cleanup(void)
+{
+    return RT_EOK;
+}
+
+static void testcase(void)
+{
+    UTEST_UNIT_RUN(test_event_init);
+    UTEST_UNIT_RUN(test_event_detach);
+    UTEST_UNIT_RUN(test_static_event_send_recv);
+#ifdef RT_USING_HEAP
+    UTEST_UNIT_RUN(test_event_create);
+    UTEST_UNIT_RUN(test_event_delete);
+    UTEST_UNIT_RUN(test_dynamic_event_send_recv);
+#endif
+}
+UTEST_TC_EXPORT(testcase, "src.ipc.event_tc", utest_tc_init, utest_tc_cleanup, 60);

+ 78 - 0
examples/utest/testcases/kernel/irq_tc.c

@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2021-08-15     supperthomas add irq_test
+ */
+
+#include <rtthread.h>
+#include "utest.h"
+#include "rthw.h"
+
+#define UTEST_NAME "irq_tc"
+static uint32_t irq_count = 0;
+static uint32_t max_get_nest_count = 0;
+
+static void irq_callback()
+{
+    if(rt_interrupt_get_nest() >  max_get_nest_count)
+    {
+        max_get_nest_count = rt_interrupt_get_nest();
+    }
+    irq_count ++;
+}
+
+static void irq_test(void)
+{
+    irq_count = 0;
+    rt_interrupt_enter_sethook(irq_callback);
+    rt_interrupt_leave_sethook(irq_callback);
+    rt_thread_mdelay(2);
+    LOG_D("%s test irq_test! irq_count %d  max_get_nest_count %d\n", UTEST_NAME, irq_count, max_get_nest_count);
+    uassert_int_not_equal(0, irq_count);
+    uassert_int_not_equal(0, max_get_nest_count);
+    rt_interrupt_enter_sethook(RT_NULL);
+    rt_interrupt_leave_sethook(RT_NULL);
+    LOG_D("irq_test OK!\n");
+}
+
+static rt_err_t utest_tc_init(void)
+{
+    irq_count = 0;
+    max_get_nest_count = 0;
+    return RT_EOK;
+}
+
+static rt_err_t utest_tc_cleanup(void)
+{
+    return RT_EOK;
+}
+
+static void interrupt_test(void)
+{
+    rt_base_t level;
+    uint32_t i = 1000;
+
+    rt_interrupt_enter_sethook(irq_callback);
+    rt_interrupt_leave_sethook(irq_callback);
+    irq_count = 0;
+    level = rt_hw_interrupt_disable();
+    while(i)
+    {
+        i --;
+    }
+    uassert_int_equal(0, irq_count);
+    rt_hw_interrupt_enable(level);
+    rt_interrupt_enter_sethook(RT_NULL);
+    rt_interrupt_leave_sethook(RT_NULL);
+
+}
+static void testcase(void)
+{
+    UTEST_UNIT_RUN(irq_test);
+    UTEST_UNIT_RUN(interrupt_test);
+}
+UTEST_TC_EXPORT(testcase, "testcases.kernel.irq_tc", utest_tc_init, utest_tc_cleanup, 10);

+ 2 - 0
include/rtdef.h

@@ -34,6 +34,7 @@
  * 2019-12-20     Bernard      change version number to v4.0.3
  * 2020-08-10     Meco Man     add macro for struct rt_device_ops
  * 2020-10-23     Meco Man     define maximum value of ipc type
+ * 2021-03-19     Meco Man     add security devices
  * 2021-05-10     armink       change version number to v4.0.4
  */
 
@@ -920,6 +921,7 @@ enum rt_device_class_type
     RT_Device_Class_Sensor,                             /**< Sensor device */
     RT_Device_Class_Touch,                              /**< Touch device */
     RT_Device_Class_PHY,                                /**< PHY device */
+    RT_Device_Class_Security,                           /**< Security device */
     RT_Device_Class_Unknown                             /**< unknown device */
 };
 

+ 41 - 41
src/timer.c

@@ -23,7 +23,7 @@
 #include <rthw.h>
 
 /* hard timer list */
-static rt_list_t rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL];
+static rt_list_t _timer_list[RT_TIMER_SKIP_LIST_LEVEL];
 
 #ifdef RT_USING_TIMER_SOFT
 
@@ -39,12 +39,12 @@ static rt_list_t rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL];
 #endif /* RT_TIMER_THREAD_PRIO */
 
 /* soft timer status */
-static rt_uint8_t soft_timer_status = RT_SOFT_TIMER_IDLE;
+static rt_uint8_t _soft_timer_status = RT_SOFT_TIMER_IDLE;
 /* soft timer list */
-static rt_list_t rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL];
-static struct rt_thread timer_thread;
+static rt_list_t _soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL];
+static struct rt_thread _timer_thread;
 ALIGN(RT_ALIGN_SIZE)
-static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE];
+static rt_uint8_t _timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE];
 #endif /* RT_USING_TIMER_SOFT */
 
 #ifdef RT_USING_HOOK
@@ -98,7 +98,7 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer))
  * @param time the tick of timer
  * @param flag the flag of timer
  */
-static void _rt_timer_init(rt_timer_t timer,
+static void _timer_init(rt_timer_t timer,
                            void (*timeout)(void *parameter),
                            void      *parameter,
                            rt_tick_t  time,
@@ -132,7 +132,7 @@ static void _rt_timer_init(rt_timer_t timer,
  *
  * @return rt_tick_t the point of timer
  */
-static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[])
+static rt_tick_t _timer_list_next_timeout(rt_list_t timer_list[])
 {
     struct rt_timer *timer;
     register rt_base_t level;
@@ -159,7 +159,7 @@ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[])
  *
  * @param timer the point of timer
  */
-rt_inline void _rt_timer_remove(rt_timer_t timer)
+rt_inline void _timer_remove(rt_timer_t timer)
 {
     int i;
 
@@ -176,7 +176,7 @@ rt_inline void _rt_timer_remove(rt_timer_t timer)
  * @param timer
  * @return int the count
  */
-static int rt_timer_count_height(struct rt_timer *timer)
+static int _timer_count_height(struct rt_timer *timer)
 {
     int i, cnt = 0;
 
@@ -203,7 +203,7 @@ void rt_timer_dump(rt_list_t timer_heads[])
         struct rt_timer *timer = rt_list_entry(list,
                                                struct rt_timer,
                                                row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
-        rt_kprintf("%d", rt_timer_count_height(timer));
+        rt_kprintf("%d", _timer_count_height(timer));
     }
     rt_kprintf("\n");
 }
@@ -238,7 +238,7 @@ void rt_timer_init(rt_timer_t  timer,
     /* timer object initialization */
     rt_object_init(&(timer->parent), RT_Object_Class_Timer, name);
 
-    _rt_timer_init(timer, timeout, parameter, time, flag);
+    _timer_init(timer, timeout, parameter, time, flag);
 }
 RTM_EXPORT(rt_timer_init);
 
@@ -260,7 +260,7 @@ rt_err_t rt_timer_detach(rt_timer_t timer)
     /* disable interrupt */
     level = rt_hw_interrupt_disable();
 
-    _rt_timer_remove(timer);
+    _timer_remove(timer);
     /* stop timer */
     timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
 
@@ -300,7 +300,7 @@ rt_timer_t rt_timer_create(const char *name,
         return RT_NULL;
     }
 
-    _rt_timer_init(timer, timeout, parameter, time, flag);
+    _timer_init(timer, timeout, parameter, time, flag);
 
     return timer;
 }
@@ -325,7 +325,7 @@ rt_err_t rt_timer_delete(rt_timer_t timer)
     /* disable interrupt */
     level = rt_hw_interrupt_disable();
 
-    _rt_timer_remove(timer);
+    _timer_remove(timer);
     /* stop timer */
     timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
 
@@ -362,7 +362,7 @@ rt_err_t rt_timer_start(rt_timer_t timer)
     /* stop timer firstly */
     level = rt_hw_interrupt_disable();
     /* remove timer from list */
-    _rt_timer_remove(timer);
+    _timer_remove(timer);
     /* change status of timer */
     timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
 
@@ -379,13 +379,13 @@ rt_err_t rt_timer_start(rt_timer_t timer)
     if (timer->parent.flag & RT_TIMER_FLAG_SOFT_TIMER)
     {
         /* insert timer to soft timer list */
-        timer_list = rt_soft_timer_list;
+        timer_list = _soft_timer_list;
     }
     else
 #endif /* RT_USING_TIMER_SOFT */
     {
         /* insert timer to system timer list */
-        timer_list = rt_timer_list;
+        timer_list = _timer_list;
     }
 
     row_head[0]  = &timer_list[0];
@@ -448,11 +448,11 @@ rt_err_t rt_timer_start(rt_timer_t timer)
     if (timer->parent.flag & RT_TIMER_FLAG_SOFT_TIMER)
     {
         /* check whether timer thread is ready */
-        if ((soft_timer_status == RT_SOFT_TIMER_IDLE) &&
-           ((timer_thread.stat & RT_THREAD_STAT_MASK) == RT_THREAD_SUSPEND))
+        if ((_soft_timer_status == RT_SOFT_TIMER_IDLE) &&
+           ((_timer_thread.stat & RT_THREAD_STAT_MASK) == RT_THREAD_SUSPEND))
         {
             /* resume timer thread to check soft timer */
-            rt_thread_resume(&timer_thread);
+            rt_thread_resume(&_timer_thread);
             rt_schedule();
         }
     }
@@ -485,7 +485,7 @@ rt_err_t rt_timer_stop(rt_timer_t timer)
     /* disable interrupt */
     level = rt_hw_interrupt_disable();
 
-    _rt_timer_remove(timer);
+    _timer_remove(timer);
     /* change status */
     timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
 
@@ -576,9 +576,9 @@ void rt_timer_check(void)
     /* disable interrupt */
     level = rt_hw_interrupt_disable();
 
-    while (!rt_list_isempty(&rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]))
+    while (!rt_list_isempty(&_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]))
     {
-        t = rt_list_entry(rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
+        t = rt_list_entry(_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
                           struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
 
         /*
@@ -590,7 +590,7 @@ void rt_timer_check(void)
             RT_OBJECT_HOOK_CALL(rt_timer_enter_hook, (t));
 
             /* remove timer from timer list firstly */
-            _rt_timer_remove(t);
+            _timer_remove(t);
             if (!(t->parent.flag & RT_TIMER_FLAG_PERIODIC))
             {
                 t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
@@ -636,7 +636,7 @@ void rt_timer_check(void)
  */
 rt_tick_t rt_timer_next_timeout_tick(void)
 {
-    return rt_timer_list_next_timeout(rt_timer_list);
+    return _timer_list_next_timeout(_timer_list);
 }
 
 #ifdef RT_USING_TIMER_SOFT
@@ -658,9 +658,9 @@ void rt_soft_timer_check(void)
     /* disable interrupt */
     level = rt_hw_interrupt_disable();
 
-    while (!rt_list_isempty(&rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]))
+    while (!rt_list_isempty(&_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]))
     {
-        t = rt_list_entry(rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
+        t = rt_list_entry(_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
                             struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
 
         current_tick = rt_tick_get();
@@ -674,7 +674,7 @@ void rt_soft_timer_check(void)
             RT_OBJECT_HOOK_CALL(rt_timer_enter_hook, (t));
 
             /* remove timer from timer list firstly */
-            _rt_timer_remove(t);
+            _timer_remove(t);
             if (!(t->parent.flag & RT_TIMER_FLAG_PERIODIC))
             {
                 t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
@@ -682,7 +682,7 @@ void rt_soft_timer_check(void)
             /* add timer to temporary list  */
             rt_list_insert_after(&list, &(t->row[RT_TIMER_SKIP_LIST_LEVEL - 1]));
 
-            soft_timer_status = RT_SOFT_TIMER_BUSY;
+            _soft_timer_status = RT_SOFT_TIMER_BUSY;
             /* enable interrupt */
             rt_hw_interrupt_enable(level);
 
@@ -695,7 +695,7 @@ void rt_soft_timer_check(void)
             /* disable interrupt */
             level = rt_hw_interrupt_disable();
 
-            soft_timer_status = RT_SOFT_TIMER_IDLE;
+            _soft_timer_status = RT_SOFT_TIMER_IDLE;
             /* Check whether the timer object is detached or started again */
             if (rt_list_isempty(&list))
             {
@@ -723,14 +723,14 @@ void rt_soft_timer_check(void)
  *
  * @param parameter
  */
-static void rt_thread_timer_entry(void *parameter)
+static void _timer_thread_entry(void *parameter)
 {
     rt_tick_t next_timeout;
 
     while (1)
     {
         /* get the next timeout tick */
-        next_timeout = rt_timer_list_next_timeout(rt_soft_timer_list);
+        next_timeout = _timer_list_next_timeout(_soft_timer_list);
         if (next_timeout == RT_TICK_MAX)
         {
             /* no software timer exist, suspend self. */
@@ -767,9 +767,9 @@ void rt_system_timer_init(void)
 {
     int i;
 
-    for (i = 0; i < sizeof(rt_timer_list) / sizeof(rt_timer_list[0]); i++)
+    for (i = 0; i < sizeof(_timer_list) / sizeof(_timer_list[0]); i++)
     {
-        rt_list_init(rt_timer_list + i);
+        rt_list_init(_timer_list + i);
     }
 }
 
@@ -784,24 +784,24 @@ void rt_system_timer_thread_init(void)
     int i;
 
     for (i = 0;
-         i < sizeof(rt_soft_timer_list) / sizeof(rt_soft_timer_list[0]);
+         i < sizeof(_soft_timer_list) / sizeof(_soft_timer_list[0]);
          i++)
     {
-        rt_list_init(rt_soft_timer_list + i);
+        rt_list_init(_soft_timer_list + i);
     }
 
     /* start software timer thread */
-    rt_thread_init(&timer_thread,
+    rt_thread_init(&_timer_thread,
                    "timer",
-                   rt_thread_timer_entry,
+                   _timer_thread_entry,
                    RT_NULL,
-                   &timer_thread_stack[0],
-                   sizeof(timer_thread_stack),
+                   &_timer_thread_stack[0],
+                   sizeof(_timer_thread_stack),
                    RT_TIMER_THREAD_PRIO,
                    10);
 
     /* startup */
-    rt_thread_startup(&timer_thread);
+    rt_thread_startup(&_timer_thread);
 #endif /* RT_USING_TIMER_SOFT */
 }