Quantcast
Viewing all articles
Browse latest Browse all 4447

Compute Module • using SD1card blocks all IO on CM4 using bcm2835-sdhost.c

Hopefully someone smarter then me can help me out of a hole! I’m working on a data logger using the CM4.

We are running the OS from the internal EMMC, we are using the on board WiFi module to upload data, we’ve got an SD card connected to:

SD0_DAT0 GPIO24
SD0_DAT1 GPIO25
SD0_DAT2 GPIO26
SD0_DAT3 GPIO27
SD0_CLK GPIO22
SD0_CMD GPIO23

We are running this overlay:

fragment@0 {
target = <&sdhost>;
frag0: __overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&sdhost_pins>;
bus-width = <4>;
brcm,overclock-50 = <0>;
brcm,pio-limit = <1>;
status = "okay";
};
};

fragment@1 {
target = <&gpio>;
__overlay__ {
sdhost_pins: sdhost_pins {
brcm,pins = <22 23 24 25 26 27>;
brcm,function = <4 4 4 4 4 4>; /* ALT0: SD0 */
brcm,pull = <0 2 2 2 2 2>; /* pull up all except clk */
};
};
};

__overrides__ {
overclock_50 = <&frag0>,"brcm,overclock-50:0";
force_pio = <&frag0>,"brcm,force-pio?";
pio_limit = <&frag0>,"brcm,pio-limit:0";
debug = <&frag0>,"brcm,debug?";
};

And everything appears to work very nicely. WiFi appears to be fine, and we can get fast and stable read/writes to the SD card. However, there is an issue! When writing to an SD card, there are occasional very long delays in the range of nearly a second. This is normal with SD cards, and as we have large RAM buffers so not a concern – however during these “SD write pauses” all other IO on the RPI is completely blocked. Hence, the system is dropping bytes from the serial ports, and the GPIO pins stop changing state. To be clear the CPU continues to run, but IO is blocked. We tried changing some SD card settings, but the issue remains. It looks like when the SD card driver is waiting for the SD controller to complete an operation, all other RPI IO operations (or maybe ISRs) are blocked. The only complete solution we could find was an overlay file like this:

dtoverlay=sdio,poll_once=off

In this case the SD card was operating perfectly - however, that stops Wifi working. Note that we also tried with our original overlay file, but with WiFi completely disabled, but the IO blocking issue was still there.

Additional information: You can add that these pauses happen during cache flushing, we can observe this by reading /proc/meminfo and looking at the “Dirty” line. Setting vm.dirty_background_bytes to 64k reduces the issue, but it’s still present.

Any suggestions on how we might resolve this issue? Our work around it to use an external USB to WiFi convertor, but I’ve no spare USB ports in the design, so that’s problematic!

Kind regards, Andy

Statistics: Posted by AndyGPS — Wed Dec 11, 2024 4:59 pm — Replies 0 — Views 9



Viewing all articles
Browse latest Browse all 4447

Trending Articles