RT-Thread Nano Configuration!

Created at 2020-12-10 17:47:24

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

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)

#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.

Basic Configuration

  1. Set the maximum priority for the system available from 8 to 256, the default value is 8 can be modified.
  1. Set RT-Thread operating system beat which representing how many ticks per second, for example, set the system beat into 100, which means a clock beat (os tick) lasts 10ms. The Common values of which are 100 and 1000. The faster the clock beat rate, the bigger the consumption spending on the system.
#define RT_TICK_PER_SECOND  100
  1. Byte alignment sets the number of aligned bytes, the number is default set as 4, often using ALIGN (RT_ALIGN_SIZE) for aligning the byte.
#define RT_ALIGN_SIZE   4
  1. Set the maximum length of the object name, 8 characters by default, generally do not need to modify.
#define RT_NAME_MAX    8
  1. Set the components automatic initialization use function, set need use by default, enable the macro can use automatic initialization function.
  1. Enable 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.

Kernel Debugging Configuration

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

Hook Function Configuration

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

software Timer Configuration

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. 

#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

IPC Configuration

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

Memory Configuration

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

FinSH Configuration

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_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



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.


0 Answer
There is no answer, come and add the answer

Write Your Answer

Log in to publish your answer.,Click here to log in.