RT-Thread Nano is configured in rtconfig.h to enable or disable certain functions by switching macro definitions, which are then described in the following configuration file.
Head file RTE_Components.h
is generated by Keil MDK for which only defines one macro RTE_USING_FINSH
that opens the FinSH component.
#if defined (__CC_ARM) || (__CLANG_ARM)
#include "RTE_Components.h" /* Used to switch finSH components, only the MDK can generate this file */
#if defined(RTE_USING_FINSH)
#define RT_USING_FINSH
#endif //RTE_USING_FINSH
#endif //(__CC_ARM) || (__CLANG_ARM)
This header file is not required for a non Keil MDK generated project, and if the FinSH component needs to be enabled, the FinSH component can be opened directly by manually defining RT_USING_FINSH
in rtconfig.h.
#define RT_THREAD_PRIORITY_MAX 8
#define RT_TICK_PER_SECOND 100
#define RT_ALIGN_SIZE 4
#define RT_NAME_MAX 8
#define RT_USING_COMPONENTS_INIT
RT_USING_USER_MAIN
macro to turn on the user_main function, it needs to turn on by default, in order to call RT-Thread's startup code, the stack size of Main thread is default as 256, and it is available for modifying.#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 256
Define the RT_DEBUG
macro to enable debug mode. If the system debugging is enabled, the system LOG can be printed.
//#define RT_DEBUG // Disable debug
#define RT_DEBUG_INIT 0 // Enable the component initialization debug configuration, set to 1 to print the function name that is automatically initialized
//#define RT_USING_OVERFLOW_CHECK // 关闭栈溢出检查Disable stack overflow checks
Set whether to use the hook function, which is disabled by default.
//#define RT_USING_HOOK // Whether enable system hook function
//#define RT_USING_IDLE_HOOK // Whether enable the idle thread hook function
Set whether the software timer is enabled, and the configuration of the relevant parameters is turned off by default.
#define RT_USING_TIMER_SOFT 0 // Disable the software timer function, number 1 presents it gets enbaled.
#if RT_USING_TIMER_SOFT == 0
#undef RT_USING_TIMER_SOFT
#endif
#define RT_TIMER_THREAD_PRIO 4 // Setting the priority of the software timer thread defaults to 4
#define RT_TIMER_THREAD_STACK_SIZE 512 // Setting the stack size of the software timer thread defaults to 512 bytes
The IPC supported by the system is: semaphore, mutex, event set, mailbox, message queue. Enable or disable the IPC by defining the appropriate macro.
#define RT_USING_SEMAPHORE // Set whether to use semaphor
//#define RT_USING_MUTEX // Set whether to use mutex
//#define RT_USING_EVENT // Set whether to use event set
#define RT_USING_MAILBOX // Set whether to use mailbox
//#define RT_USING_MESSAGEQUEUE // Set whether to use message queue
RT-Thread memory management includes: memory pools, memory heaps, small memory algorithms. Use the appropriate functionality by enabling the appropriate macro definition.
//#define RT_USING_MEMPOOL // Whether to use memory pools
//#define RT_USING_HEAP // Whether to use memory heaps
#define RT_USING_SMALL_MEM // Whether to use small memory algorithms
//#define RT_USING_TINY_SIZE // Whether to use small memory algorithms, it depneds on the size that rt_memset, rt_memcpy generated
Define RT_USING_CONSOLE to enable console functionality, disable the macro can turn off the console, then the print is also disabled. Modify the RT_CONSOLEBUF_SIZE can configure the buffer size of the console.
#define RT_USING_CONSOLE // Console macro enable/ disable
#define RT_CONSOLEBUF_SIZE 128 // Set the console data buffer size to 128 byte by default
FinSH components can be enabled by defining RT_USING_FINSH, which allows to modify the configuration of FinSH related components parameters, and the value of FINSH_THREAD_STACK_SIZE is relatively small by default.
#if defined (RT_USING_FINSH) // Enable/ Disable FinSH Component
#define FINSH_USING_MSH // Use FinSH component MSH mode
#define FINSH_USING_MSH_ONLY // Only use MSH mode
#define __FINSH_THREAD_PRIORITY 5 // Set the finSH component priority, configure the value, and calculate it using the following formula
#define FINSH_THREAD_PRIORITY (RT_THREAD_PRIORITY_MAX / 8 * __FINSH_THREAD_PRIORITY + 1)
#define FINSH_THREAD_STACK_SIZE 512 // Set FinSH thread stack size, available from 1-4096
#define FINSH_HISTORY_LINES 1 // Set the FinSH component to record the number of historical commands, with values ranging from 1-32
#define FINSH_USING_SYMTAB // Using the symbol table, which is enabled by default
#endif
Q: Hard fault appears after the porting is complete.
A: By default, the various thread stack sizes configured by the system are small, and if they do not function properly, it is likely that the stack is not sufficient and the stack value can be increased. For example, the main thread stack size defaults to 256, in actual use, main may be added to other code and cause the lack of the stack, FinSH component thread tshell defaults to 512 stack is also relatively small, can be adjusted when using.