USB Mass Storage demo on LPC-P2148

Hello,

On the olimex website it says “USB mass storage device demo code with Secure digital and MMC card support (coming soon)”.

Will this demo be available soon, or should I just start coding it myself ;)?

Thanks,

Amir

Amir,

thanks for catching this

this demo was done, but as commercial product for customer, we’ll not be able to put it on our web for downloading and I’ll remove this.

Tsvetan

We are working on a USB mass storage device as well. There was some example code from Keil… Oh yea, here it is:

http://www.keil.com/download/docs/307.asp

We haven’t got it working yet, but it’s a great place to start from. Let us know if you figure it out :wink:

-Nathan

just don’t count so much on Keil example, it doesn’t handle the interrupts correct and USB communication may/will freeze while working

Tsvetan

I’m also working on a USB stack for the LPC214x. I plan to open-source it (I can do this because I wrote it from scratch). The intent is that anyone can use it in binary and source form, but improvements have to be made public so they can be integrated back, LGPL looks fitting for this.

Currently I have the basic USB outlines of the driver, but it’s not working very well yet.

The project page for this is (for the time being) http://wiki.sikken.nl/index.php?title=LPCUSB

Hello,

Too bad about olimex’s msd example :wink:

I checked out the Keil example, and it is the most horrific code I have ever looked at. Their code relies heavily on ‘goto’ statements, and it seems they are using the LPC’s interrupt endpoint istead of one of its bulk endpoints for the msd bulk out pipe. I would not buy a compiler from a company that writes code this badly!!

Right now, I am working off of some HID examples and using efsl- http://sourceforge.net/projects/efsl/ to get the usb-msd up and running.

-Amir

Amir,

My (soon to be open-source) USB code is coming to life, with USB enumeration working now.

Would you be willing to open-source your msd code so I can combine it with my USB stack?

I can do that, but it will be a little while until my code is ready.

-Amir

I released the first version of the LPC214x USB stack yesterday. It’s at:

https://sourceforge.net/projects/lpcusb

I plan to work out some examples to run on top of it, like a simple USB HID and USB mass storage.

bertrik:
I released the first version of the LPC214x USB stack yesterday.

Well, it's been some since anything happened here, but I just started playing with my 2148 a few days ago. I downloaded the latest version of the USB stack, adjusted it to run from RAM (I don't have a serial port, so I can't use the ISP to load to Flash yet) and tried it out.

It may be running correctly. At least, it doesn’t run off into space or restart or anything; it just stays in the infinite loop at the end of main(). However, I don’t know how to talk to the driver with Linux. Should I expect to see a new device connect? It would be ideal if it connected as a serial device, so I could use minicom to talk to it.

Any help on that front?

Yes, you should see a new device connect with vendor id 0xFFFF and product id 0x0001. Currently the default build creates a simple joystick HID example, so on Linux you should see a message about a joystick in /var/log/messages or dmesg. The HID device implementation may not be completely correct yet because I’m also quite new to USB HID devices myself.

The software expects that P0.31 has some circuitry attached that causes a pull-up to be connected to the D+ line when P0.31 is low. P0.23 should be connected to the VBUS line.

The USB stack demo application currently does not use interrupts. Instead it polls the interrupt bits in a tight loop. Not using interrupts makes the early parts of development easier, IMO.

bertrik:
The software expects that P0.31 has some circuitry attached that causes a pull-up to be connected to the D+ line when P0.31 is low. P0.23 should be connected to the VBUS line.

This looks like what I have on my header board:

http://www.mersenne.com/images/circuit.png

I didn’t see a joystick (or other device) connect, though. Is there a way to reset/rescan the USB bus? I can’t unplug/replug the header board, because it’s powered from USB – if I unplug it, it resets and the RAM gets cleared.

I guess my next project is to get the code written to Flash using GDB and the JTAG interface.

The circuitry looks very much like what I have in my hardware, so I think that is not the problem.

Does the USB_LINK LED light up?

I think that under Linux, the bus can be reset by unloading and loading the USB host controller module, something like ‘sudo modprobe -r uhci_hcd && sudo modprobe uhci_hcd’. (Or perhaps substitute uhci_hcd with ohci_hcd).

bertrik:
Does the USB_LINK LED light up?

No, when I load the binary into RAM and start it, the LED actually goes off. I think the Flash currently has a demo USB program in it (when I plug the module into a Windows box, the cursor starts moving in a square). So that's probably what runs when I power the module up (not the ISP bootloader). On Linux, the module doesn't seem to be recognized as an HID device, but the LINK light does go on. Anyway, running your code seems to turn the light off.

I’ll have to check the assembler startup function that you got from Jim Lynch’s tutorial. There might be some things in there that aren’t right when you’re running from RAM. I’m still getting up to speed, though, so don’t hold your breath!

AFAIK, the LED should light when both P0.23 (VBUS) is high AND the software has set the CONNECT bit during LPCUSB initialisation, even before any USB communication takes place.

I tried running my code from RAM (simply by updating the linker file) a couple of times and it seemed to work.

It could be that the built-in USB demo makes some USB setting that interferes with the LPCUSB stack (perhaps because the LPCUSB code misses some initialisation).

Is there any other circuitry on P0.23 or EXT1-24?

Sorry for the delay in replying – I only have a few hours each week to hack even under the best of circumstances, and sometimes I’m too busy to do anything fun at all.

bertrik:
Is there any other circuitry on P0.23 or EXT1-24?

The circuit diagram above shows everything as far as I know.

Have you found any references that describe using the 2148 USB target? The User’s Manual lists all the registers, of course, but it doesn’t provide much help for getting a complete program running. I’d guess an Application Note-style document would be more useful.

[After poking around the Philips website some more…]

Here we go: [How To Make a Virtual COM Port Driver Using 2148 USB](http://www.semiconductors.philips.com/acrobat_download/applicationnotes/AN10420_1.pdf)

The USB controller in the LPC214x is very similar (though not identical) to the “D12”, or PDIUSBD12 USB device controller. Knowing this helped a lot. There is a lot of sample code and documentation available for the D12.

For your board, getting the LED to light when the device is connected to a PC is an essential first step. It could be that there is still some missing default configuration, so perhaps it’s a good idea to do a complete powerdown/powerup of the USB controller during init.