USB device with MFS ramdisk

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB device with MFS ramdisk

Jump to solution
1,816 Views
t_k
Contributor II

Hi,

I'm trying to integrate the USB MSD demo with the MFS Ramdisk demo.   I thought I had everything working smoothly since I can write a file onto the Ramdisk and see it when I connect the USB to my pc,  however when I try to write a file from the USB side of things, I can't seem to find it on the ramdisk.

when setting up the ramdisk, I called     

mqx_status = _io_mem_install("mfs_writedisk:", (uchar_ptr) g_disk.storage_disk, (_file_size) sizeof(g_disk.storage_disk));  

using the DISK_STRUCT from the usb device demo, and after setting up the mfs I called

ioctl(a_fd_ptr, IO_IOCTL_DEFAULT_FORMAT, NULL);

before setting up the usb device so I wouldn't require the pc to format my device.

Tags (3)
0 Kudos
1 Solution
886 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Travis,

I think that what you want to achieve is this:

C:\Program Files\Freescale\Freescale MQX 3.8\usb\device\examples\msd\disk

Regards,

-Garabo

View solution in original post

0 Kudos
6 Replies
886 Views
t_k
Contributor II

what I would like to achieve would be to use that demo and be able to read and write files off of it using MQX.  I'm assuming to do this that I have to install MFS and have the USB access it.

I wish there was an example similar to C:\Freescale\Freescale_MQX_4_0\mfs\examples\sdcard only using a USB device instead of an sdcard.

Thanks,

Travis

0 Kudos
886 Views
DavidS
NXP Employee
NXP Employee

Hi Travis,

Please look at following thread that Garbo and I responded to:

move or copy a file between multiple MFS (over SD and USB)

Also there is MFS USB example:

C:\Freescale\Freescale_MQX_4_0\mfs\examples\mfs_usb

Hope this helps.

Regards,

David

0 Kudos
886 Views
t_k
Contributor II

Hi,

I believe the problem I'm having is that I'm trying to use a USB Device, and all the examples seem to be using a USB Host.

Using the demo Garabo mentioned,  once the usb device is attached, enumerated, and had a file written to it via PC, how do I read the file off using MQX?

thanks,

Travis

0 Kudos
886 Views
DavidS
NXP Employee
NXP Employee

Hi Travis,

If I understand your question fully (Being able to connect tower MCU with USB device MSD enabled so that a file from a PC can be copied to the tower MCU ramdisk.  Then copy/move it from SRAM to some other location.  Correct?).

I'm using the TWR-K60D100M with TWR-MEM card that has MRAM.

I modified the msd_disk_twrk60d100m example to also mount the MRAM as MFS.

C:\Freescale\Freescale_MQX_4_0\usb\device\examples\msd\disk

Actually the application is always opening up the ram disk and checking if it is formatted or not.  I just choose to ignore the MQX application and use the PC to load the ram disk with file as shown below.  So at this point in time both the MQX application and PC want to format the ram disk.  I choose to have the PC app do it for this example (read observations below).

When the application first runs, I plug the TWR USB cable to PC, PC will want to format it, I format it, then copy (drag-n-drop) a file to the TWR ram disk.

ScreenHunter_04 Feb. 25 11.22.gif

ScreenHunter_05 Feb. 25 11.22.gif

ScreenHunter_03 Feb. 25 11.21.gif

ScreenHunter_06 Feb. 25 11.23.gif

I now eject the USB disk and disconnect the USB cable from PC and do a POR (power on reset) of the TWR.

The application will then see the ram disk with MFS and see that it has been formatted.

Using the serial concole I can copy/move the file from ram disk to MRAM.

ScreenHunter_02 Feb. 25 11.16.gif

Note the "a:" is the ram disk and "b:" is the MRAM disk.

Please note this is currently a hack and just proves that it can be done.  I'm sure others can enhance it to better respond to USB attach/detach events so as not to have to do a POR to refresh the FAT table.

Observations:

When formatting the ram disk with Win7 64-bit machine, it initially sees the drive as 30KBytes but after the format only 10KBytes is present.  I'm guessing extra overhead of Windows formatting???

When I format using the MQX application I get the expected 25KBytes.  If Windows looks at this ram disk it does see all 25KBytes.  So clearly we have a difference in formatting the FAT32 from MQX to Windows.

My project source is attached for disk.c and Shell_Task.c (file I added to the project).  Also I had to add MFS and Shell  libraries to the project "properties" paths for compiler and linker.

Regards,

David

886 Views
t_k
Contributor II

most of what you've described I have working, however I never attempted to try a POR to refresh the FAT table.   

Hopefully that is the step I've been missing.   Ideally, I'd prefer not to have to do a POR as I'm trying to use the USB filesystem to enter configuration data to the device.

thanks,

Travis

0 Kudos
887 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Travis,

I think that what you want to achieve is this:

C:\Program Files\Freescale\Freescale MQX 3.8\usb\device\examples\msd\disk

Regards,

-Garabo

0 Kudos