• 正文
  • 相關(guān)推薦
申請入駐 產(chǎn)業(yè)圖譜

e2 studio開發(fā)環(huán)境下串口printf編譯出錯問題解決方案

03/01 10:25
1788
加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點資訊討論

最近看到有一些網(wǎng)友在討論關(guān)于:瑞薩RA單片機在e2 studio環(huán)境下printf編譯出錯的問題。

這個問題我之前也遇到過,今天就來分享一下我得出的解決辦法。

問題點:在 e2 studio 集成開發(fā)環(huán)境下,使用串口 printf 打印時,會類似出現(xiàn)一個這樣的錯誤:

C:/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld.exe: C:/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/thumb/v8-m.main+dp/hardlibg_nano.a(libc_a-closer.o): in function `_close_r':closer.c:(.text._close_r+0xc): undefined reference to `_close'C:/Renesas/RA/e2studio_-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld.exe: C:/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/thumb/v8-m.main+dp/hardlibg_nano.a(libc_a-lseekr.o): in function `_lseek_r':lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'C:/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld.exe: C:/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/thumb/v8-m.main+dp/hardlibg_nano.a(libc_a-readr.o): in function `_read_r':readr.c:(.text._read_r+0x10): undefined reference to `_read'C:/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld.exe: C:/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/thumb/v8-m.main+dp/hardlibg_nano.a(libc_a-fstatr.o): in function `_fstat_r':fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'C:/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld.exe: C:/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/thumb/v8-m.main+dp/hardlibg_nano.a(libc_a-isattyr.o): in function `_isatty_r':isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty'collect2.exe: error: ld returned 1 exit statusmake: *** [makefile:96: RA8D1_DEBUG.elf] Error 1
Build Failed. 6 errors, 0 warnings. (took 190ms)

網(wǎng)上最多的解決辦法:在這個路徑下:

項目 -> C/C++ Project Settings -> C/C++構(gòu)建 -> 設(shè)置 -> GUU Arm Cross C Linker -> Miscellaneous

勾選【Use float with nano printf (-u _ printf float)】這個選項,并清空【Other linker flags】里面的內(nèi)容。

但是,在 e2 studio V5版本(比如:V5.6.0)環(huán)境下,這個解決方法“失效”了,編譯還是會出現(xiàn)【錯誤】。

然后,網(wǎng)上又有了一種解決辦法:在同樣的路徑下,勾選【Do not use syscalls (--specs=nosys.specs)】這個選項,如下圖:

這樣,確實能解決【編譯出錯】的問題,也能正常printf打印輸出。

但會出現(xiàn)【警告】,如下圖:

還有一種最理想的解決辦法:這個辦法不會錯誤,也不會警告,也是我在用。那就是在同樣的路徑下,【Other linker flags】這里添加:

--specs=rdimon.specs

警告這樣的配置之后,編譯就會:0錯誤,0警告。

這里的配置,在e2 studio 以前的老版本是默認的,但這后面的版本,這里的配置默認是“空”了,我也搞不懂為啥。

這個解決辦法在網(wǎng)上不容找到,我找到了一個地方:

https://community.renesas.com/mcu/ra/f/forum/32521/fsp5-0-0-cannot-print-data-to-uart-by-redirecting-printf

以上三種解決辦法,推薦用最后一種。

本文就分享到這里,希望對你有所幫助。

相關(guān)推薦

登錄即可解鎖
  • 海量技術(shù)文章
  • 設(shè)計資源下載
  • 產(chǎn)業(yè)鏈客戶資源
  • 寫文章/發(fā)需求
立即登錄

作者黃工,從事嵌入式軟件開發(fā)工作8年有余,高級嵌入式軟件工程師,業(yè)余維護公眾號『strongerHuang』,分享嵌入式軟硬件、單片機、物聯(lián)網(wǎng)等內(nèi)容。