namespace Filesystem
{
public class Program
{
private static void Main()
{
var sd = StorageController.FromName(@“GHIElectronics.TinyCLR.NativeApis.LPC17.SdCardStorageController\0”);
var drive = FileSystem.Mount(sd.Hdc);
var file = new FileStream($@"{drive.Name}Test.txt", FileMode.OpenOrCreate);
var bytes = Encoding.UTF8.GetBytes(DateTime.UtcNow.ToString() + Environment.NewLine);
file.Write(bytes, 0, bytes.Length);
file.Flush();
FileSystem.Flush(sd.Hdc);
}
}
Thanks for your reaction.
I formatted the card but that did not help, so I tried the same with a Panda III board and also
with a Cobra III board. These two worked well, so I am afraid that there might be a problem with my board,
although all the other options (PWM, CAN, ADC, IO’s) work well on this board.
Yes, it is a custom board. It is similar to the Cobra III board (it is built around the G120 module), but it has some customized stuff integrated on it like driver IC’s , a CAN transceiver, build in leds and connectors. Funny is that it worked with the previous version (preview 3), but not anymore. I am not sure if the hardware could be damaged in some way (other features work fine as indicated before). How can I load the preview 3 firmware on the board just to make sure if that makes any difference? TinyCLR just looks for the most recent version.
Thanks for your reaction. Unfortunately this did not help.
What SD cards are supported with which file system? I found out on the Cobra III board that the sample code worked with a micro SD of 2Gb formatted with FAT. A micro SD of 8Gb formatted as FAT32 did not work on the Cobra III either, that gave as well the same invalid operation exception. On my custom board neither of the micro SD cards work.
If you know the system is good but a specific card doesn’t work we can certainly look into the card to see why it didn’t work. You can send us the card to check or the model number so we can grab one.
I will check the system first. But since I noticed as well that not all cards are supported in the Panda III and Cobra III, I would like to know which ones are supported. What works on those boards is a 2Gb formatted as FAT. I don’t need a lot storage space, but the small ones are getting difficult to get and are even more expensive than the one with a larger capacity.
I had a misunderstanding with the developer of my customized board. I had to steer a FET open for the SD interface to get power. Writing to the board works fine now, sorry for the inconvenience.
Again I have problems writing the SD card.
With a small test app, it works fine, but in a bigger application I get the ‘System.InvalidOperationException’ in GHIElectronics.TinyCLR.IO.dll again.
I make use of pin P1.5 for PWM.
You mentioned this pin in your answer last year, but I don’t know what the connection is between this pin and the SD card.
I am betting it’s not the size of the app, it’s the code complexity… something cleaned up with a remaining reference, or some other code complexity issue, not the fact that it ended up in aproject that’s 100x larger