SPI2.setup({mosi:B14,miso:B15,sck:B13,baud:1000000}); // maybe try 10x bigger/smaller values for baud rate and see what happens
E.connectSDCard(SPI2, A8);
My only guess right now is that there might be some issue with the wiring/SD card and the speed of communication. Software SPI might happen to be the right speed, but if there are pauses in it because of interrupts/etc then that might confuse the SD card and would account for your unreliability.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
As far as I can see it should be fine - the relevant code is here
However I notice you're using software SPI in your connectSD example - does it still work if you use hardware with:
and what if you try:
My only guess right now is that there might be some issue with the wiring/SD card and the speed of communication. Software SPI might happen to be the right speed, but if there are pauses in it because of interrupts/etc then that might confuse the SD card and would account for your unreliability.