usb 4.1.1 MSD example for KL25Z - Disk does not format - No drive data

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

usb 4.1.1 MSD example for KL25Z - Disk does not format - No drive data

1,459 Views
mjg8t
Contributor IV

Hi There,

I am trying to better understand the USB stack and wanted to work with some prebuilt applications to best understand the stack.  In the end I need to have MSD and CDC so I am looking at the individual MSD project from the 4.1.1 examples library. "Freescale USB Stack v4.1.1\Source\Device\app\msd\cw10\kinetis_l2k"  .  The project was built for the tower board, but it seems that it should run on the FRDM-KL25Z board with no problems as only LEDs/SW, which don't acutall do anything in the application (kbi_stat is set with the values of switches, but is never read in the application)- it appears to be left over code from the HID demo or some other.  I have disabled any possible conflicting IO states by disabling the sw/led io initializaition and let the USB code run as normal.

When running the code the drive appears, but it cannot be formatted and the system hangs when trying to open it (MSD not working correctly).  The USBUG states that the drive should be able to formatted and then opened.

Any ideas?  Very difficult to create an application with the examples don't work.....  If I'm doing something wrong I'm happy to hear about it. 

Thanks.

0 Kudos
4 Replies

902 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello M J:

With this example, the KL25 enumerates as a 1 KB disk by default (2 blocks of 512 bytes). This causes the error when trying to format because when a disk is formatted on FAT16, the FAT table itself requires 16 KB approx.

If you refer to the file "disk.h" of the MSD example, you will find the macros "TOTAL_LOGICAL_BLOCKS_ADDRESS" and "LENGTH_OF_EACH_LBA". For other supported boards you can change these macros so that formatting works and you can use the disk, but unfortunately KL25 device does not have enough RAM, and most probably you will get linker errors.

I hope this helps to clarify the situation.


Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

902 Views
mjg8t
Contributor IV

Hi Jorge,

Thank you for the information.  What you bring up makes sense in terms of being able to format the "disk".  Indeed there are linker errors when trying to create a large disk size.

I guess I do not understand how this demo is supposed to work if there is not enough room for the disk to be accessible from the PC.  It seems it would need to be pre-formatted with a file system running on the MCU in order to be seen? 

There are other demos that use this same code, for example the MSD/CDC composite USB example.  There is a .ini "file" that is supposed to be able to be mounted on the MSD disk, but there is the same issue in this example, in that the disk never mounts and thus the .ini file is never accessible.  So the same question would apply to this demo:

So, how is the disk formatted and accessible from a pc?  The USB _UG CDC/MSD composiste demo that uses the same code shows that the drive just shows up on the PC with no further work.

Thanks for the clarification.

0 Kudos

902 Views
mjbcswitzerland
Specialist V

Hi

It sounds as though these demonstrations are restricted to showing the enumeration in action and not necessary a working MSD device.

MSD devices are often used togther with an SD card connected via SPI or as boot loader where files uploaded are saved to the internal Flash (FAT emulation).

The uTasker project contains both of these for the FRDM-KL25Z: http://www.utasker.com/kinetis.html

The SD card connection that is used on this board by default is:

SPI1_CS   PTD-4 (J1-6) [VDD J9-4 / 0V J9-14]

SPI1_SCK  PTD-5 (J2-4)

SPI1_MOSI PTD-6 (J2-17)

SPI1_MISO PTD-7 (J2-19)

Notes: This topic has been discussed previously here: Re: Need USB Mass Storage on FRDM-KL25Z Platform

See also Having fun with the FRDM-K25Z for SPI-SD-Card/USB-MSD on the K25, including a simulation of the board and the operation.

Regards

Mark

0 Kudos

902 Views
mjg8t
Contributor IV

Hi Mark,

Thanks for your  reference links and the great material you provide there as well!  This looks like a good excercise of getting a fully working MSD example based on 4.1.1 exmaples.  I will get an SD card breakout as use your examples as reference to get it working.  I won't mark the thread as answered yet, as I will likely have some follow on questions.

Cheers!

MJ

0 Kudos