I have been using MDK to view and compile the RTT source code. In the past few days, I am bored to remember that RTT officially provided the scons tool to compile RTT. So I would like to try this method and take this note for reference by beginners.
Note
1 download and install python2.7
Many people in the Forum said that RTT only supports python2.7. Therefore, download this version.
Open Web: http://www.python.org/getit/
Download and install version 2.7.5. The installation directory cannot contain spaces. Therefore, it is best to install it by default or under the D: \ python27 directory. Here, install it in the D: \ python27 directory.
2. Download and install scons
: Http://www.scons.org/download.php
Download Windows Installer scons 2.2.0-setup.exe from this page.
Because scons is a python plug-in, it is good to install "Next" all the way, it will identify the python Security
Directory.
3. Configure Environment Variables
Right-click my computer on the desktop, set properties, select Advanced and environment variables, locate the PATH variable under system variables, and add two paths:
D: \ python27; D: \ python27 \ scripts, and then click OK to close the dialog box.
Finally, open CMD and enter the path to check whether the two paths are included.
4. Download and decompress RTT source code
Here to download RTT v1.1.1 as an example,: https://rt-thread.googlecode.com/files/RT-Thread_1.1.1.7z
Decompress.
5. Modify the compilation configuration file
Open any BSP.Stm32f10xFor example, use the MDK compilation tool to compile.
First, use a text editing tool such as rtconfig. py opened by notepad or ue in the stm32f10x directory. Modify the following:
ARCH='arm'CPU='cortex-m3'CROSS_TOOL='keil'if os.getenv('RTT_CC'):CROSS_TOOL = os.getenv('RTT_CC')#device options# STM32_TYPE = # 'STM32F10X_LD','STM32F10X_LD_VL',# 'STM32F10X_MD','STM32F10X_MD_VL',# 'STM32F10X_HD','STM32F10X_HD_VL',# 'STM32F10X_XL','STM32F10X_CL'STM32_TYPE = 'STM32F10X_HD'# lcd panel options# 'FMT0371','ILI932X', 'SSD1289'RT_USING_LCD_TYPE = 'SSD1289'# cross_tool provides the cross compiler# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IARif CROSS_TOOL == 'gcc':PLATFORM = 'gcc'EXEC_PATH = 'D:/SourceryGCC/bin'elif CROSS_TOOL == 'keil':PLATFORM = 'armcc'EXEC_PATH = r'D:/Keil'elif CROSS_TOOL == 'iar':PLATFORM = 'iar'IAR_PATH = 'C:/Program Files/IAR Systems/Embedded Workbench 6.0 Evaluation'
The content of the above 3rd rows and 28th actions to be modified.
Row 3rd: cross_tool = 'keil 'indicates that MDK is used for compilation,
Row 28th: exec_path = r'd:/Keil ', which indicates the installation path of the MDK.
Next, modify the sconstruct file.
Find the sconstruct file in the current directory, open it with notepad or ue, and find the following text:
if os.getenv('RTT_ROOT'): RTT_ROOT = os.getenv('RTT_ROOT')else: RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
Modify it:
RTT_ROOT = r'E:\projects\other\RT-Thread_1.1.1'
That is, your RTT source code directory.
The path here is actually used on the Internet:
Rtt_root = 'e: \ projects \ other \ RT-Thread_1.1.1'
Rtt_root = 'e:/projects/other/RT-Thread_1.1.1'
Rtt_root = r 'e: \ projects \ other \ RT-Thread_1.1.1'
Rtt_root = r 'e:/projects/other/RT-Thread_1.1.1'
You can use either of these methods. I have tried either of them.
The value of the rtt_root variable must be set to the RTT source code root directory.
The environment is configured. You can use scons to compile the environment.
6. Use scons to compile RTT
Open CMD and CD to the current BSP directory:
cd /d E:\projects\other\RT-Thread_1.1.1\bsp\stm32f10x
Then input scons to compile.
scons -j4
-J4 indicates that four threads are used for compilation at the same time, which can accelerate the compilation of large projects. Of course, RTT is not a large project and you do not need to input-j4.
To generate an MDK project, run the "scons -- target = mdk4-s" command (note that the two "-" signs are in front of the target) to generate the MDK project, the "project. uvproj, click to open it with MDK for compilation, download, simulation, and so on.
scons --target=mdk4 -s
OK!