04-24-2024 03:19 PM
I'm working with a cRIO-9047 (Linux RT) with an SD Card for saving data files. It seems I have to go through the following steps to be able to save to the SD Card:
I tried this with both a 32GB and 256GB SD Card. (for some reason I was unable to save data files using FAT32 for the 32GB card)
This article indicates that FAT32 should work for the 32GB card: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P7iaSAC&l=en-US
This article indicates that 32GB is capacity limit for SD Cards when working with cRIO: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000001E9b7CAC&l=en-US
Are there any risks using the 256GB SD Card with the ext4 file system format? (this seems to be working so far)
Any thoughts on why FAT32 format didn't work (no write access) for the 32GB SD Card?
Software versions:
04-25-2024 08:08 AM
I think the problem mentioned in the article stems from the fact that SDXC mandates using exFAT as the file system, which is not supported by NI Linux RT (because it incurs license costs?). So if you reformat it, is technically no longer an SDXC card in the strict sense?
Anyway, I did not encounter problems with SDXC cards reformatted to ext4.
Does the 32GB card have a write protection slider by any chance?
04-25-2024 11:36 AM
Thanks for the response.
The 32GB card does have the slider but I did verify it was in the unlocked position. (I formatted it to NTFS at one point and created a dummy txt file on Windows.)
And thanks for sharing that you have been able to use ext4 format without issues. Its nice to know I'm not the only one doing this.
06-03-2024 06:40 PM
After using this for a while, I noticed that on a power cycle or reboot the mount didn't persist when using the 256GB SD Card.
Finally got a chance to look into this and updating the etc/fstab file as follows allowed for the mount to persist on power cycles/reboots:
Before
/dev/mmcblk0p1 /media/sd auto defaults,sync,noauto,umask=000 0 0
After
/dev/mmcblk0p1 /media/sd auto defaults 0 0
My assumption is that the options listed in the Before snippet is not valid for ext4 file systems.
08-01-2024 10:34 AM
Congrats David.yamagata, you now have "extensive Linux knowledge" to quote the NI writeup.
If you want to use exFAT, you can. Takes a little more gyrations.
Microsoft published the exFAT specification in 2019.
(source: https://opensource.microsoft.com/blog/2019/08/28/exfat-linux-kernel/)
Support for exFAT has been incorporated into the Linux kernel since Linux 5.7
(source: https://www.phoronix.com/news/Linux-6.2-exFAT)
Current NI Linux RT is kernel 6.1.59, but the stock distribution doesn't include the exFAT driver.
How to build exFAT kernel module for NI LINUX RT:
Download code "Download ZIP" from https://github.com/namjaejeon/linux-exfat-oot
Unzip and copy that folder onto the cRIO in /home/lvuser (exact location not important.)
ssh into cRIO as admin
cd into that folder
run these commands
admin@NI-CRIO-0123ABC:/home/lvuser/linux-exfat-oot-master# make
admin@NI-CRIO-0123ABC:/home/lvuser/linux-exfat-oot-master# make install
admin@NI-CRIO-0123ABC:/home/lvuser/linux-exfat-oot-master# modprobe exfat
Now you can, for example:
admin@NI-cRIO-9047-0123ABC:/home/lvuser/linux-exfat-oot-master# mkdir /mnt/sdb
admin@NI-cRIO-9047-0123ABC:/home/lvuser/linux-exfat-oot-master# mount /dev/mmcblk0p1 /mnt/sdb
I'm sure I'll need to modify /etc/fstab for the mount to persist after reboot.
Actually, mounting as root makes the owner/group admin, so lvuser can't write files there.
Better to do:
admin@NI-cRIO-9047-0123ABC:/home/lvuser/linux-exfat-oot-master# mount -o uid=lvuser,gid=ni /dev/mmcblk0p1 /mnt/sdb
Now here's an interesting observation. This 512GB microSD I stuck in appears to write data faster than the cRIO-9047 builtin drive.
Specifically I can write 160 MB to this card in about 1 second.
When writing a 160MB file to /home/lvuser I get about 1 second the first time, but it takes about 4 seconds if I overwrite an existing file.
But with the SD card in the slot, it's about 1 second to write 160MB, no matter if it's a new file or overwriting an existing file.
Writing 320 MB to SD card takes about 2.5 seconds, whether creating or overwriting.
Writing 320 MB to /home/lvuser takes about 2 seconds first time, but 8 seconds when overwriting.