- 官方的RT-Thread Studio的用戶手冊:(界面介紹,編譯下載調(diào)試、導(dǎo)入工程等官方文檔說明)
RT-Thread Studio 用戶手冊
============================================================
1、RT-Thread studio下載安裝
1-1、官網(wǎng)下載安裝包:
RT-Thread 官方下載中心
文檔中心關(guān)于nano版本講了移植的幾種方式,打開使用RT-Thread_Studio移植,選擇安裝RT-Thread_Studio跳轉(zhuǎn)到官網(wǎng),拉到最底下,點(diǎn)擊RT-Thread nano,
選擇下載即可;
1-2、安裝:
勾選協(xié)議:
選擇自己想要安裝的位置:
開始安裝
v2.2.4版本安裝提示重命名某個(gè)文件失敗,。。。。。,下個(gè)v2.2.3版本試下:(v2.2.3版本還是一樣的報(bào)錯(cuò))
解決:最后發(fā)現(xiàn)是安裝路徑的問題。。。安裝在默認(rèn)的D盤根目錄下就成功安裝了,真是很無語!(這個(gè)現(xiàn)象在我自己的電腦上安裝是自定義的路徑,但是沒有出現(xiàn)這個(gè)錯(cuò)誤,不知道什么原因,解決了就好)
1-3、注冊登錄:
注冊好登錄,即可開始使用啦;
2、新建RT-Thread nano工程
2-1、新建nano工程
2-1-1、打開 文件—>新建—>RT-Thread Nano項(xiàng)目:
2-2-2、新建項(xiàng)目配置項(xiàng):
1>、設(shè)置工程名字
2>、工程保存路徑
3>、基于芯片創(chuàng)建、nano版本選擇
4>、芯片選擇
5>、串口控制臺(tái)與引腳配置
6>、調(diào)試配置
全部配置完成之后自動(dòng)生成了nano項(xiàng)目代碼;
注:
1、我選擇先在stm32f103c8t6上面先跑,所以第4和5項(xiàng)配置要根據(jù)實(shí)際情況配置
2、配置時(shí)鐘,默認(rèn)是用內(nèi)部的HSI時(shí)鐘,后續(xù)自己在文件drv_clk.c中修改;
stm32f103c8t6的串口1當(dāng)調(diào)試串口:
2-1-3、生成工程之后如下,選擇了小錘子debug后,編譯0 error,0 warning;
2-2、連接硬件,下載到板子上測試(選擇的是stm32f103c8t6)
2-2-1、下載到stm32f103c8t6最小系統(tǒng)板上
竟然彈出窗口然后一直下載中
問題解決:嗐,這臺(tái)電腦第一次用j-link ob,沒裝驅(qū)動(dòng),裝了驅(qū)動(dòng)之后,下載正常;
關(guān)于j-link的問題解決查看博客:j-link使用(持續(xù)更新)
2-2-2、打開RT-Thread studio中的串口終端,可以看到代碼中實(shí)現(xiàn)的輸出到串口的內(nèi)容;
生成的代碼main函數(shù)中定時(shí)打印字符串到串口,由于在配置工程時(shí)候配置了控制臺(tái)串口的串口號和引腳號,在工程中自動(dòng)實(shí)現(xiàn)了串口的驅(qū)動(dòng)和rt_hw_console_output(),默認(rèn)可以進(jìn)行打?。?br>
3、用RT-Thread studio創(chuàng)建的nano工程的文件解讀
待更新
4、基于RT-Thread nano添加Finsh(實(shí)現(xiàn)命令輸入)
4-1、什么是Finsh
RT-Thread FinSH 是 RT-Thread 的命令行組件(shell),提供一套供用戶在命令行調(diào)用的操作接口,主要用于調(diào)試或查看系統(tǒng)信息。它可以使用串口 / 以太網(wǎng) / USB 等與 PC 機(jī)進(jìn)行通信;
4-2、基于Nano添加FinSH(用RT-Thread studio)
4-2-1、雙擊 RT-Thread Settings 進(jìn)入配置,打開組件,勾選 FinSH Shell,保存配置。此操作將把 FinSH 組件的源碼加入工程中。其中,rt_hw_console_getchar() 已經(jīng)在 drv_uart.c 中實(shí)現(xiàn),無需再實(shí)現(xiàn)對接 FinSH 的代碼。
如下打開組件之后,就可用FinSH功能了
4-1-2、鏈接硬件,重新編譯下載時(shí)候,在RT-Thread studio軟件中的終端中按下tab鍵,可查看系統(tǒng)中的命令:
正常情況下是可以實(shí)現(xiàn)了命令行輸入,但是出現(xiàn)了tab鍵之后沒有反應(yīng)現(xiàn)象:
問題解決:
不屏蔽上圖中的 rt_thread_mdelay(1000);(應(yīng)該是程序陷入了死循環(huán),現(xiàn)在對RT-Thread不熟悉,后續(xù)回頭解答原因)
5、【問題】怎么用RT-Thread studio打開已經(jīng)創(chuàng)建好的RT-Thread項(xiàng)目工程;
問題描述:
問題解決:
RT-Thread studio【問題】怎么用RT-Thread studio打開已經(jīng)創(chuàng)建好的RT-Thread項(xiàng)目工程;
6、【問題】怎么查找打開指定內(nèi)容
1、搜索:
2、打開元素:
7、【問題】項(xiàng)目工程怎么添加自己的路徑和源文件頭文件(SConscript和SConstruct)(未完善)
見自己博客
8、 RT-Thread工程新建工程之后,用cubemx重新配置參數(shù)(時(shí)鐘,串口等)
參考博文鏈接:
RT-Thread Studio與CubeMX聯(lián)合編程(超級詳細(xì))
8-1、cubemx配置:
打開工程中的插件(要先安裝好stm32cubemx這個(gè)軟件)進(jìn)行配置,軟件的安裝和配置見下面的博文鏈接:
stm32cubeMX使用
配置好之后關(guān)閉cubemx這個(gè)軟件,然后進(jìn)入RT-Thread studio之后彈出這個(gè)窗口,提示
生成了stm32f1xx_hal_conf.h原來的文件重命名,調(diào)用cubemx生成的這個(gè)文件,點(diǎn)確定即可;
8-2、用cubemx生成工程后需要關(guān)閉軟件;
8-2-1、在RT-Thread studio軟件中打開cubemx插件配置工程之后,必須要關(guān)閉掉cubemx軟件,這樣在RT-Thread studio軟件上才能正常操作
8-3、用cubemx重新配置之后生成的文件分析:
如上圖,cubemx生成了文件夾cubemx下面包含頭文件和源文件,尤其是也有一個(gè)main.c,那到底用哪一個(gè)main.c執(zhí)行我們的用戶代碼呢?
先繼續(xù)下一步吧,先執(zhí)行編譯;
8-4、編譯后報(bào)錯(cuò)解決
直接編譯后報(bào)21個(gè)錯(cuò)誤。。。
解決的步驟:
8-4-1、需要用SConscript文件告訴編譯器cubemx生成的需要編譯
在cubumx文件夾下有生成SConscript文件,要是沒有自己創(chuàng)建一個(gè),自己生成的SConscript文件已經(jīng)實(shí)現(xiàn)了生成文件的路徑包含了
import os #引入os模塊
from building import * #導(dǎo)入building的所有模塊
cwd = GetCurrentDir() #獲取獲取當(dāng)前路徑,并保存至變量cwd
src = Glob('*.c') #獲取當(dāng)前目錄下的所有 C 文件,并保存至src變量
# add cubemx drivers
#由于RT-Thread工程中存在部分相同函數(shù)文件,所以對src重新賦值
#文件中的stm32g4xx_it.c 、 system_stm32g4xx.c不加入構(gòu)建
#其余文件按相同格式填寫到下述括號內(nèi)
src = Split('''
Src/stm32f1xx_hal_msp.c
Src/main.c
''')
path = [cwd] #創(chuàng)建路徑列表,并保存至path中
path += [cwd + '/Inc']
group = DefineGroup('cubemx', src, depend = [''], CPPPATH = path) #這是 RT-Thread 基于 SCons 擴(kuò)展的一個(gè)方法(函數(shù))。
Return('group')
8-4-2、右鍵SConscript更新軟件包
更新軟件包!非常重要!別漏了
8-5、weak掉cubemx生成的main函數(shù),然后在applications下調(diào)用cubemx生成的函數(shù):
8-5-1、weak掉cubemx生成的main函數(shù):
網(wǎng)上有說手動(dòng)_weak掉cubemx生成的main函數(shù),但是我這版本自動(dòng)生成好了;
8-5-2、將hal生成初始化函數(shù)在application的main下調(diào)用
將hal生成初始化函數(shù)在application的main下調(diào)用,如下,在applications下的main.c中去調(diào)用cubemx生成的hal函數(shù):(這里我用cubemx配置的外設(shè)很少,所有只有一個(gè)main。h頭文件)
然后重新編譯;
8-6【問題】做了SConscript腳本和weak cubemx生成的main函數(shù),還是編譯錯(cuò)誤
現(xiàn)象:
16:22:09 **** Incremental Build of configuration Debug for project test2 ****
make -j4 all
arm-none-eabi-gcc "../drivers/drv_usart.c"
../drivers/drv_usart.c:28:8: error: unknown type name 'UART_HandleTypeDef'
static UART_HandleTypeDef handle;
^
../drivers/drv_usart.c:380:30: error: unknown type name 'UART_HandleTypeDef'
__WEAK void HAL_UART_MspInit(UART_HandleTypeDef *huart)
^
../drivers/drv_usart.c: In function 'stm32_configure':
../drivers/drv_usart.c:393:11: error: request for member 'Instance' in something not a structure or union
handle.Instance = config->Instance;
^
../drivers/drv_usart.c:394:11: error: request for member 'Init' in something not a structure or union
handle.Init.BaudRate = 115200;
^
../drivers/drv_usart.c:395:11: error: request for member 'Init' in something not a structure or union
handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
^
../drivers/drv_usart.c:395:32: error: 'UART_HWCONTROL_NONE' undeclared (first use in this function)
handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
^
../drivers/drv_usart.c:395:32: note: each undeclared identifier is reported only once for each function it appears in
../drivers/drv_usart.c:396:11: error: request for member 'Init' in something not a structure or union
handle.Init.Mode = UART_MODE_TX_RX;
^
../drivers/drv_usart.c:396:32: error: 'UART_MODE_TX_RX' undeclared (first use in this function)
handle.Init.Mode = UART_MODE_TX_RX;
^
../drivers/drv_usart.c:397:11: error: request for member 'Init' in something not a structure or union
handle.Init.OverSampling = UART_OVERSAMPLING_16;
^
../drivers/drv_usart.c:397:32: error: 'UART_OVERSAMPLING_16' undeclared (first use in this function)
handle.Init.OverSampling = UART_OVERSAMPLING_16;
^
../drivers/drv_usart.c:398:11: error: request for member 'Init' in something not a structure or union
handle.Init.WordLength = UART_WORDLENGTH_8B;
^
../drivers/drv_usart.c:398:32: error: 'UART_WORDLENGTH_8B' undeclared (first use in this function)
handle.Init.WordLength = UART_WORDLENGTH_8B;
^
../drivers/drv_usart.c:399:11: error: request for member 'Init' in something not a structure or union
handle.Init.StopBits = UART_STOPBITS_1;
^
../drivers/drv_usart.c:399:32: error: 'UART_STOPBITS_1' undeclared (first use in this function)
handle.Init.StopBits = UART_STOPBITS_1;
^
../drivers/drv_usart.c:400:11: error: request for member 'Init' in something not a structure or union
handle.Init.Parity = UART_PARITY_NONE;
^
../drivers/drv_usart.c:400:32: error: 'UART_PARITY_NONE' undeclared (first use in this function)
handle.Init.Parity = UART_PARITY_NONE;
^
../drivers/drv_usart.c:402:9: warning: implicit declaration of function 'HAL_UART_Init' [-Wimplicit-function-declaration]
if (HAL_UART_Init(&handle) != HAL_OK)
^
../drivers/drv_usart.c: In function 'rt_hw_console_output':
../drivers/drv_usart.c:429:13: warning: implicit declaration of function 'HAL_UART_Transmit' [-Wimplicit-function-declaration]
HAL_UART_Transmit(&handle, (uint8_t *)&a, 1, 1);
^
../drivers/drv_usart.c: In function 'rt_hw_console_getchar':
../drivers/drv_usart.c:440:9: warning: implicit declaration of function '__HAL_UART_GET_FLAG' [-Wimplicit-function-declaration]
if (__HAL_UART_GET_FLAG(&handle, UART_FLAG_RXNE) != RESET)
^
../drivers/drv_usart.c:440:38: error: 'UART_FLAG_RXNE' undeclared (first use in this function)
if (__HAL_UART_GET_FLAG(&handle, UART_FLAG_RXNE) != RESET)
^
../drivers/drv_usart.c:447:20: error: request for member 'Instance' in something not a structure or union
ch = handle.Instance->DR & 0xff;
^
../drivers/drv_usart.c:452:41: error: 'UART_FLAG_ORE' undeclared (first use in this function)
if(__HAL_UART_GET_FLAG(&handle, UART_FLAG_ORE) != RESET)
^
../drivers/drv_usart.c:454:13: warning: implicit declaration of function '__HAL_UART_CLEAR_OREFLAG' [-Wimplicit-function-declaration]
__HAL_UART_CLEAR_OREFLAG(&handle);
^
../drivers/drv_usart.c: At top level:
../drivers/drv_usart.c:251:17: warning: 'stm32_gpio_configure' defined but not used [-Wunused-function]
static rt_err_t stm32_gpio_configure(struct stm32_uart_config *config)
^
make: *** [drivers/subdir.mk:27: drivers/drv_usart.o] Error 1
"make -j4 all" terminated with exit code 2. Build might be incomplete.
16:22:10 Build Failed. 20 errors, 5 warnings. (took 1s.459ms)
問題解決:其實(shí)是在cubemx配置的時(shí)候我沒有配置到用作RT-Thread studio終端用的usart1導(dǎo)致的問題,具體操作如下博文:
【rtt問題】RT-Thread studio用cubemx配置后提示串口錯(cuò)誤:error: unknown type name ‘UART_HandleTypeDef‘文章來源:http://www.zghlxwxcb.cn/news/detail-416921.html
9、【rtt問題】RT-Thread studio新建項(xiàng)目編譯成功,j-link下載失敗
【rtt問題】RT-Thread studio新建項(xiàng)目編譯成功,j-link下載失敗文章來源地址http://www.zghlxwxcb.cn/news/detail-416921.html
到了這里,關(guān)于RT-Thread studio使用(持續(xù)更新)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!