How to mount TF card with XiaoZhi code

How to mount an SD card on the Huangshanpai Xiao Zhi?

I tried mounting a TF card on Xiao Zhi based on the SPI_TF example. The mounting shows success, but I cannot read the contents of the TF card. This issue only occurs on Xiao Zhi; other examples work normally.

image

image

After using sd_optimize, I get the following output. How should I modify it? The same card and same board work fine with other SPI examples, and the highlighted part shows 10MHz there.

image

The “12M” shown above was forcibly modified, but it still doesn’t work. Not sure if the modification was correct.

image

https://github.com/OpenSiFli/xiaozhi-sf32 The Xiao Zhi code was cloned from here.

image

I tried it—the exact same code compiles and successfully recognizes and reads the TF card on the 52LCD board, but not on the Huangshan Pi. My Huangshan Pi isn’t connected to a battery; could this be the reason? :face_with_monocle::face_with_monocle:

》》“Compilation fails on Huangshan Pai”
》》All other routines can be used normally
Hello, does it fail on Huangshan Pai itself, or does it fail specifically on Xiao Zhi’s routine on Huangshan Pai?

The XiaoZhi demo doesn’t work on HuangshanPi, only the XiaoZhi demo has this issue; other demos like the SPI_TF demo work fine on HuangshanPi.

》》But cannot read TF card content
What exactly does “cannot read TF card content” mean? Is it like this?

image

Have you tried it on the helloworld example? Have you enabled the macro switch related to spi_msd?

The spi_tf example program has the corresponding macro switch enabled by default.

image
The thing is, the same XiaoZhi code compiles and works normally on the LCD board without giving a “No such directory” error. I’ve also tested the same configuration in other routines, and they all work fine.

Oh, I found the cause. Huangshan Pai briefly cut off the 3V3 power at the moment the screen lost power.

WeChat Work Screenshot_17663899706770

The TF card is powered by 3V3.

WeChat Work Screenshot_17663898523502

The spi_tf example program doesn’t handle hot-plugging. Once the power is lost, even if power is restored, it won’t work anymore, hence the “fail” error.

If power consumption is not a concern, you can temporarily comment out the code at the arrow location in the image, as I did, to see if it helps. We will later use a better method to fix it.