0

I have no experience of embedded USB stacks so my question is, can I run it without an OS?

Of course it must be possible to run without OS, but will things be MUCH easier if I have one?

I want to use it to save data to a attached USB Mass Storage Device.

user2479653
  • 509
  • 5
  • 14
  • Which USB device you want to connect? It makes a difference if you want to add a USB to serial, a mass device or an audio device – jeb Jul 04 '13 at 18:51
  • Do you can choose also SD-Cards as mass device? As they are nearly trivial to access with a small footprint of code and ram – jeb Jul 04 '13 at 19:07
  • Is the USB controller on you processor? If so what is the processor. – Clifford Jul 04 '13 at 19:58
  • Maybe [LUFA](http://www.fourwalledcubicle.com/LUFA.php) can help you. I didn't use it yet, but needed to examine it already for a later project, and it seems like this library is possible to be used without an OS, that is, it may be possible to integrate it into an already existing project with an own kernel. – Jubatian Jul 06 '13 at 13:40

2 Answers2

2

If your USB device is on-chip, your chip vendor will almost certainly have example code for USB that may include mass storage. You won't need an OS, but interrupt handling will be necessary and a file system too.

Your USB controller will need host or OTG capability - if it is only device capable, then you cannot connect to another USB device, only a host.

The benefit of an OS - or at least a simple RTOS kernel - is that you can schedule file system activity concurrently with other processing tasks. The OS in that case would not necessarily make things easier, but it may make your system more responsive to critical tasks and events.

Clifford
  • 88,407
  • 13
  • 85
  • 165
  • My controller is a STM32F4 device with host capability. I tried the example code from ST, and put it into my scheduled system. Then I got time issues. File writing took too long time, so other tasks did not execute in time. – user2479653 Jul 04 '13 at 20:32
  • An RTOS might solve that problem so long as you have sufficient memory for buffering, so the actual writing can be performed in a low priority task. The performance of USB data transfer to a storage device may be limited by the storage device itself. – Clifford Jul 04 '13 at 21:51
  • 1
    Very often such operations will have a maximum speed above which they will stall, but no minimum speed, so something you may be able to do is to refactor the USB / filesystem code to only advance the process a little bit each time through your main system loop or each time it is scheduled. Any time it would wait for a time period or on a condition it should yield/return, and then on the next run see if the timeout/condition has been met. – Chris Stratton Jul 05 '13 at 13:29
0

I have used usb stacks in the past with PIC18F2550 (8 bits) and LPC1343 (32 bits ARM-Cortex M3) microcontrollers without any problems.

Fernando
  • 97
  • 4