最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

platformio 開發(fā)esp32/esp8266問題診斷

2023-03-06 04:22 作者:云逸之  | 我要投稿

主要是幫助以arduino 框架開發(fā)的同學(xué)。解決異常棧無法查看 。 日志不夠詳細,報錯不明顯。庫的日志 沒有打印,等問題。以及debug調(diào)試相關(guān)可能有幫助的事項。


新建一個用調(diào)試分析的env


platformio顯著的特性 可以配置多個環(huán)境(env)配置??梢杂糜诰幾g上傳不同固件,監(jiān)控不同的串口使用。我們可以在不動原有配置情況下新增一個用調(diào)試分析的env。

env的名字 但要符合文件夾命名規(guī)范和cmake或者其他編譯器能識別的規(guī)范上一次加了空格出問題了

這個時候需要調(diào)用這個配置燒錄 監(jiān)控 等 使用 pio 命令時 使用 `-e ?for_debug` 指定env

例如: `pio run -t upload -e for_debug`。

當(dāng)然使用 vscode和clion可以z直接在樹上選擇對應(yīng)節(jié)點。clion如果沒有樹形gui,請在插件市場搜索 Platformio Plus。推薦2022以后的版本 ,精力有限 最新的功能只兼容了2022.*的版本。

該插件可以通過以下方式選中需要的環(huán)境配置項。

設(shè)置esp32-hal-log的日志工具的日志級別

比如使用其提供的宏記錄info級別日志

日志會把 時間:[ ? ?198] , 級別:[I] info級別?,文件名和行號:?[CamQuadruped.cpp:77]?函數(shù)名:?setup() :? 日志內(nèi)容打出來?

而arduino -esp32 內(nèi)置庫的日志打印均是這一套宏 ,只是日志級別不同。同時我們也能使用該日志工具記錄日志。如果日志級別設(shè)對了,常規(guī)esp32使用串口都能看到這個日志打印。


也可以使用USB來查看這種日志打印。這樣的話合宙esp32C3簡約版則可以直接使用這種log_i log_d log_e log_v log_w log_e 等宏來打印日志。


設(shè)置日志級別,則需要設(shè)置這個宏?CORE_DEBUG_LEVEL??

在build_flags中添加以下設(shè)置

-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO

注意單個 -Dkey=value 不要有空格。個人習(xí)慣每個宏獨占一行。

可選值有 6 種?默認不設(shè)置則是關(guān)閉。

這里我們將其設(shè)置為詳細:ARDUHAL_LOG_LEVEL_VERBOSE

看看arduino 下esp32 wifi連接日志。

如果連接失敗會有原因打印,也借助日志打印進入對應(yīng)的代碼看看其中的內(nèi)容。clion復(fù)制文件名和行號。按ctrl shift n 搜索跳轉(zhuǎn)到對應(yīng)文件具體行。

這個日志級別建議真正使用的時候設(shè)置為info級別,不然verbose打印的日志太多了。


esp32/esp8266異常棧的十六進制 轉(zhuǎn)為對應(yīng)的代碼調(diào)用棧


對于這種例如問題 abort() was called at PC 0xxxx on core x。?

Backtrace: 0x40377c6e:0x3fc96680 0x4037d519:0x3fc966a0 0x403838c9:0x3fc966c0 0x42015f98:0x3fc96740 0x40379065:0x3fc96760 0x400559dd:0x3fcabb20 |<-CORRUPTED

在arduino開發(fā)esp32 esp8266遇到之后很難去定位,很多時候可以需要串口打印二分法,逼近出錯的行?;蛘遝sp32采用debug調(diào)試找到出錯的行。


platformio集成該棧的十六進制解碼功能。在串口監(jiān)控時。添加過濾器,調(diào)用編譯信息中生成的表,對應(yīng)相關(guān)調(diào)用信息。所以有時候會提示需要重新編譯。

設(shè)置?monitor_filters?

monitor_filters = esp32_exception_decoder, time

這里我加了 一個time, 會在行首把任何打印加上時間戳。

如果是解析esp8266的異常棧,則需要esp8266_exception_decoder 。

修改之后會提示需要重新編譯,因為需要一份詳細的映射表,映射棧與代碼。

有時候棧出現(xiàn)不全的情況,可能是需要重新編譯一下。


所有的platformio已內(nèi)置的過濾器:

  1. default :Remove typical terminal control codes from input

  2. colorize: Apply different colors for received and echo

  3. debug :Print what is sent and received

  4. direct :Do-nothing: forward all data unchanged

  5. hexlify :Show a hexadecimal representation of the data (code point of each character)

  6. log2file :Log data to a file “platformio-device-monitor-%date%.log” located in the current working directory

  7. nocontrol :Remove all control codes, incl. CR+LF

  8. printable :Show decimal code for all non-ASCII characters and replace most control codes

  9. time :Add timestamp with milliseconds for each new line

  10. send_on_enter :?Send a text to device on ENTER

  11. esp32_exception_decoder?:Custom filter for?Espressif 32?which decodes crash exception

  12. esp8266_exception_decoder?:Custom filter for?Espressif 8266?which decodes crash exception

?當(dāng)然也有第三方過濾器,你也可以自己指定??梢詤⒖脊俜轿臋n。


設(shè)置build_type為debug

?buid_type 支持??release??test?debug?將 buid_type 設(shè)置為debug 可以打印詳細信息。

再搭配上一段的過濾器使用。


效果如下

紅色的部分則是 RX的內(nèi)容,當(dāng)然其實在串口打印上還是一樣存在,但它時間細分更加精細。

有時候一行串口打印的一個字符也帶上了時間。

build_type可選項如下:

  1. release:

    Default configuration. A “release” configuration of your firmware/program does not contain symbolic debug information and is optimized for the firmware size or speed (depending on?Development Platforms)

  2. test:

    A “test” configuration extends a build environment with?macro and with extra flags provided by the?Unit Testing?frameworkPIO_UNIT_TESTING

  3. debug:

    A “debug” configuration of your firmware/program is compiled with full symbolic debug information and no optimization. Optimization complicates debugging because the relationship between source code and generated instructions is more complex.



debug斷點調(diào)試

這里以esp32s3 usb接口 +? clion為例。

只需要點擊一個debug按鈕,則可以debug。但有些需要注意跳過對debug適配不好的代碼,可以正常查看 單步執(zhí)行 , 查看變量。 簡單查看線程。

和GDB控制臺等。





platformio 開發(fā)esp32/esp8266問題診斷的評論 (共 條)

分享到微博請遵守國家法律
棋牌| 罗平县| 庆安县| 河南省| 炎陵县| 涞水县| 南京市| 永寿县| 黔西| 泾川县| 合川市| 营口市| 长沙县| 依兰县| 黄大仙区| 板桥市| 荔浦县| 万山特区| 芷江| 龙川县| 长葛市| 乐清市| 嘉荫县| 庆阳市| 玛纳斯县| 长汀县| 新蔡县| 神农架林区| 达州市| 祥云县| 华宁县| 集贤县| 锡林郭勒盟| 甘孜| 商丘市| 浦城县| 西华县| 梁河县| 龙江县| 韩城市| 崇信县|