LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cRIO-9047 and SD Card

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:

 

  1. ssh into cRIO
  2. "lsblk" to list available drives
    • the SD Card shows up as "mmcblk0p1" for me
  3. "mount" to list where SD card is mounted
    • if mounted, the SD card shows up as "/dev/mmcblk0p1 on /media/sd"
  4. if the SD Card is mounted, "umount /media/sd" to unmount
  5. "mkfs.ext4 /media/sd" to format the SD Card
  6. "mount /dev/mmcblk0p1 /media/sd" to mount SD Card
  7. "chmod 777 /media/sd" to update access premissions

 

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:

  • LabVIEW 2023 Q3
  • NI-RIO 2023 Q4
Message 1 of 5
(853 Views)

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?

 

Message 2 of 5
(810 Views)

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.

 

Message 3 of 5
(797 Views)

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.

Message 4 of 5
(694 Views)

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.

 

0 Kudos
Message 5 of 5
(560 Views)