[Betaflight] 黑盒子功能認不到SD卡 Fatal Error

想在新買的 Omnibus F4 V3S 上,啟用 Betaflight v4.2.3 黑盒子紀錄功能,以便之後能更深入了解飛控的技術細節。沒想到預計一件簡單的事情,也能花上數小時的時間找問題。剛插入 SD 卡就遇到 SD卡 (TF) 認不到的問題。畫面顯示 Fatal error Reboot to retry:


In the beginning, I acted like an idiot due to the useless instructions on the Blackbox setting screen. After tens of reboots, I still cannot make my SD Card working in Betaflight. I even checked the solder point, when I doubt the solder point of pin headers may probably shorted the SD socket. But finally nothing found.看到不少網友遇到一樣的問題,獲得的診斷詢問、回答,大多都是「你用的 SD 卡是什麼?」、「要麼試試其他的SD卡?」、「你怎麼Format的?確定是用 FAT32 檔案系統,而不是NTFS?」、「你是用Windows的Format程式嗎?不行喔,因為Windows程式的 Format會把一個保護區域刪掉,你得用 SD卡專用的 Format程式」...這些鬼話連篇的解答。

但我這個傻瓜,把這些方法一一試了,結果,完全沒用。你知道,當你在Format程式中,勾選全部抹除這個選項,要等多久才,能獲得一片完全空白的SD卡嗎?是的,我也試了。後來甚至連顯微鏡都上場,因為我懷疑是焊接排針的時候,也許不小心讓銲錫短路到SD卡的鐵殼之類的。

寶貴的時間都花在這些鳥事上....誰叫這個韌體,經過這麼多年,還是叫 Beta xxxx呢?若不是只想業餘玩玩,或者用公款補助買的話,直接買有客服的DJI,就簡單了。但也少了很多研究的樂趣。

當今SD卡的容量大多都超過 4Gb

經過數小時的試誤,才知道問題出在於SD卡儲存區不能在 DMA 模式下運作。後來發現,當我把SD Card的DMA關掉,問題就解了。不過詭異的是,Betaflight 成功建立了一個 4GB的 FREESPACE.E 的檔案,就再也沒辦法讓SD卡在DMA模式下存取。目前我找不到任何一片小於4Gb容量的SD卡,沒辦法驗證小於 4GB的時候會發生什麼事情。在Betaflight 原始碼中,看到 DMA 的設定,根據 config->mode 的定義,決定是 DMA (SPI) 還是 DIO。


Disable 停用SD卡的 DMA 模式

其實,剛重灌 Betaflight 的韌體後,你在 CLI 輸入 set sdcard,可以看到本來 sdcard_dma 就是 off 了,但是還是得重新執行以下設定指令,問題才會解決。

To disable the DMA mode, you can simple execute the below command in the CLI screen:

set sdcard_dma = off

Betaflight will reboot the board after you saved the setting.

在 CLI 執行了以上這個指令,把 DMA 模式關掉以後,馬上可以看到在黑盒子的設定中,程式已經開始建立一個 4Gb 的檔案。據說這個檔案,是要預留4GB的空間,讓單一個儲存 Session 使用。如果最後 SD卡裝到小於 4GB,這個檔的大小會小於 4GB (看國外網友講的,我自己沒試)

我試過把 SD card 格式化成為 Ext4 檔案系統,但這樣不行,SD卡的檔案系統必須是 FAT32 才行。


After system reboot, you will see the above screen. The file system creating process is on-going.  And the SD card icon became blue color. Until now, I've realized that many Internet answers from the Internet were wrong. The trouble is not from the SD card type (perhaps 4Gb SD card will be fine, but how can I find a 4Gb card today?), nor the original types of file system, nor the formatting software. It is simply Betaflight file system creating process cannot work on DMA mode, and the default setting is sdcard_dma = on, although it showed sdcard_dma = off.

問題解決,黑盒子可以開始紀錄飛行資料

Finally, the blackbox tab recognized the SD card with 4Gb reserved for data log, and the rest of the space are wasted.


最後,SD卡的圖示顯示綠色,已經可以正常執行。不過,詭異的是,當我把 SD 卡移除,試著恢復 DMA mode,重新執行 set sdcard_dma = ON,無論怎麼重設都不行。Reboot之後,sdcard_dma都還是OFF. 看起來這裡有蟲。看起來開發者有發現要讓 sdcard_dma 預設是 off,但是顯然 v4.2.3 的 binary 檔案,裡面原來是 ON,雖然 CLI 指令顯示預設是OFF。
查看原始碼,似乎預設也是 config->useDma = false,沒有啟動DMA,但是 flash 中卻是 ON,猜測是因為這兩者的衝突,造成開始 Fatal Error 的結果。



在 Driver 的原始碼中,SD卡的初始化過程,也沒看到有關 DMA 通道初始化相關設定動作,看來原始碼中根本沒有相關 DMA 的操作:

I've tried to re-enable sdcard_dma to ON again. However, after removed the SD card. It is still not possible, although I've set sdcard_dma to ON. After system reboot, it is always became OFF. I think for some reasons, this part of firmware has only OFF selection, but the binary file set it ON originally.

After removed the SD card, I've tried to reset the value of sdcard_dma to ON. But no matter how I set this value, it becomes OFF after reboot.
# Building AutoComplete Cache ... Done!
# set sdcard_dma
sdcard_dma = OFF
Allowed values: OFF, ON

# set sdcard_dma = ON
sdcard_dma set to ON
# set sdcard_dma
sdcard_dma = ON
Allowed values: OFF, ON
Default value: OFF

It changed to OFF again after reboot. No way to return to the original ON setting.



黑盒子專用的檔案系統,是以Image的形式,存在於 FAT32 的 SD卡中:



SD卡仍然是16Gb,但空間少了 4Gb,被上面這個檔案佔了。

把 Omnibus F4 V3S 的 SD卡,變成行動碟

最後,你可以按下黑盒子畫面中的Activate Mass Storage Device Mode,Betafight 可以把上面的那個 Image檔案,掛載成一個 FAT32的行動碟,這樣你就可以直接存取 Betaflight 所紀錄的飛航資料了。



沒有留言:

張貼留言