EmbeddedRelated.com
Forums

USB stack footprint

Started by Luis Filipe Rossi May 19, 2012
Hi, i am developing a project and we are still discussing if we should
include USB on our device. My main concern is about the USB stack
footprint. I will need to implement a very very simple HID device just to
trasfer data. Why to not use bulk? Becouse i dont need that transfer rate
so HID is more suitable as i wont need to develop a driver. I will probably
be using a MSP430F5 device with 16K of flash so i would need just a raw
estimative of the stack footprint with no optimizations (thse TI stack for
instance). Any one got that number?

Thank you!

--
Lu Filipe Rossi
Electrical Engineer
Biomechatronics Lab. / Grupo de Sensores Integreis e Sistemas
Escola Politnica
Universidade de S Paulo
Cel. +55 (11) 7662-9234


Beginning Microcontrollers with the MSP430

If all you want is simple UART comms then it depends on the size of data
you want to transfer in each packet. The code to initialise the UART,
including enabling receive immediately is 8 instructions maximum. The
code to handle a transmit ISR is 7 instructions, including maintaining
the buffer pointer, RETI, and end of message handling. The code to
receive through the ISR is as little as 5 instructions when handling
single byte commands but 7 instructions lets you handle longer packets
before having to pass them to the main program.

the bulk of the code space is in handling commands etc, if you don't
have an external command set, ie messages to set up parameter tables etc
then to initiate a transmission takes around 4 instructions. If you have
a reasonably complex set of commands available then it grows
accordingly. For example one of my systems has up to 40 different
commands to handle and uses a 128 byte packet size, so it uses 136 bytes
of RAM and around 0.8K of code space to process all the commands.

All in assembler though.

Cheers

Al

On 20/05/2012 7:26 AM, Luis Filipe Rossi wrote:
> Hi, i am developing a project and we are still discussing if we should
> include USB on our device. My main concern is about the USB stack
> footprint. I will need to implement a very very simple HID device just to
> trasfer data. Why to not use bulk? Becouse i dont need that transfer rate
> so HID is more suitable as i wont need to develop a driver. I will probably
> be using a MSP430F5 device with 16K of flash so i would need just a raw
> estimative of the stack footprint with no optimizations (thse TI stack for
> instance). Any one got that number?
>
> Thank you!
>
Or I am not understanding your answer completely or we are talking about
different things. I want to implement a HID class device (interrupt
endpoint). The transfer size will be 64 bytes. What i am asking is how much
flash and RAM implementing such device will be used when using TI USB
stack. It is not a Virtual COM port (CDC class) or any bulk endpoint
transfer.
Sorry if i was not clear.
Thank you for your help!
Regards,

On Sun, May 20, 2012 at 6:05 AM, Onestone wrote:

> **
> If all you want is simple UART comms then it depends on the size of data
> you want to transfer in each packet. The code to initialise the UART,
> including enabling receive immediately is 8 instructions maximum. The
> code to handle a transmit ISR is 7 instructions, including maintaining
> the buffer pointer, RETI, and end of message handling. The code to
> receive through the ISR is as little as 5 instructions when handling
> single byte commands but 7 instructions lets you handle longer packets
> before having to pass them to the main program.
>
> the bulk of the code space is in handling commands etc, if you don't
> have an external command set, ie messages to set up parameter tables etc
> then to initiate a transmission takes around 4 instructions. If you have
> a reasonably complex set of commands available then it grows
> accordingly. For example one of my systems has up to 40 different
> commands to handle and uses a 128 byte packet size, so it uses 136 bytes
> of RAM and around 0.8K of code space to process all the commands.
>
> All in assembler though.
>
> Cheers
>
> Al
> On 20/05/2012 7:26 AM, Luis Filipe Rossi wrote:
> > Hi, i am developing a project and we are still discussing if we should
> > include USB on our device. My main concern is about the USB stack
> > footprint. I will need to implement a very very simple HID device just to
> > trasfer data. Why to not use bulk? Becouse i dont need that transfer rate
> > so HID is more suitable as i wont need to develop a driver. I will
> probably
> > be using a MSP430F5 device with 16K of flash so i would need just a raw
> > estimative of the stack footprint with no optimizations (thse TI stack
> for
> > instance). Any one got that number?
> >
> > Thank you!
> >
>

--
Lu Filipe Rossi
Electrical Engineer
Biomechatronics Lab. / Grupo de Sensores Integreis e Sistemas
Escola Politnica
Universidade de S Paulo
Cel. +55 (11) 7662-9234


Hi Luis. no you were clear enough, except that if you really want simple
then why not a Virtual COM port. I run mine at 460800baud quite happily,
and it easily meets most situations I need, including plenty of space to
run even in the tiniest micros.

Al

On 20/05/2012 10:49 PM, Luis Filipe Rossi wrote:
> Or I am not understanding your answer completely or we are talking about
> different things. I want to implement a HID class device (interrupt
> endpoint). The transfer size will be 64 bytes. What i am asking is how much
> flash and RAM implementing such device will be used when using TI USB
> stack. It is not a Virtual COM port (CDC class) or any bulk endpoint
> transfer.
> Sorry if i was not clear.
> Thank you for your help!
> Regards,
>
> On Sun, May 20, 2012 at 6:05 AM, Onestone wrote:
>
>> **
>> If all you want is simple UART comms then it depends on the size of data
>> you want to transfer in each packet. The code to initialise the UART,
>> including enabling receive immediately is 8 instructions maximum. The
>> code to handle a transmit ISR is 7 instructions, including maintaining
>> the buffer pointer, RETI, and end of message handling. The code to
>> receive through the ISR is as little as 5 instructions when handling
>> single byte commands but 7 instructions lets you handle longer packets
>> before having to pass them to the main program.
>>
>> the bulk of the code space is in handling commands etc, if you don't
>> have an external command set, ie messages to set up parameter tables etc
>> then to initiate a transmission takes around 4 instructions. If you have
>> a reasonably complex set of commands available then it grows
>> accordingly. For example one of my systems has up to 40 different
>> commands to handle and uses a 128 byte packet size, so it uses 136 bytes
>> of RAM and around 0.8K of code space to process all the commands.
>>
>> All in assembler though.
>>
>> Cheers
>>
>> Al
>> On 20/05/2012 7:26 AM, Luis Filipe Rossi wrote:
>>> Hi, i am developing a project and we are still discussing if we should
>>> include USB on our device. My main concern is about the USB stack
>>> footprint. I will need to implement a very very simple HID device just to
>>> trasfer data. Why to not use bulk? Becouse i dont need that transfer rate
>>> so HID is more suitable as i wont need to develop a driver. I will
>> probably
>>> be using a MSP430F5 device with 16K of flash so i would need just a raw
>>> estimative of the stack footprint with no optimizations (thse TI stack
>> for
>>> instance). Any one got that number?
>>>
>>> Thank you!
>>>
Hi,

There are a few main reasons. First with HID transfer i will get a packet
based communication with no extra overhead. Second, with HID i can make my
application at the PC recognize when the the device is connected. With COM
port the user would need to check which COM port was created. And finally,
there is no need of driver at all for HID devices (it is embedded on the
OS). So it is very portable.

Just to make sure, your whole USB Virtual COM port implementation at a
MSP430 uses 0.8K of flash?? Thats with no optimizations right?

Any big difference on the code fro mthe TI examples?

Thank you!

On Sun, May 20, 2012 at 10:54 AM, Onestone wrote:

> **
> Hi Luis. no you were clear enough, except that if you really want simple
> then why not a Virtual COM port. I run mine at 460800baud quite happily,
> and it easily meets most situations I need, including plenty of space to
> run even in the tiniest micros.
>
> Al
> On 20/05/2012 10:49 PM, Luis Filipe Rossi wrote:
> > Or I am not understanding your answer completely or we are talking about
> > different things. I want to implement a HID class device (interrupt
> > endpoint). The transfer size will be 64 bytes. What i am asking is how
> much
> > flash and RAM implementing such device will be used when using TI USB
> > stack. It is not a Virtual COM port (CDC class) or any bulk endpoint
> > transfer.
> >
> >
> > Sorry if i was not clear.
> >
> >
> > Thank you for your help!
> >
> >
> > Regards,
> >
> > On Sun, May 20, 2012 at 6:05 AM, Onestone
> wrote:
> >
> >> **
>
> >>
> >>
> >> If all you want is simple UART comms then it depends on the size of data
> >> you want to transfer in each packet. The code to initialise the UART,
> >> including enabling receive immediately is 8 instructions maximum. The
> >> code to handle a transmit ISR is 7 instructions, including maintaining
> >> the buffer pointer, RETI, and end of message handling. The code to
> >> receive through the ISR is as little as 5 instructions when handling
> >> single byte commands but 7 instructions lets you handle longer packets
> >> before having to pass them to the main program.
> >>
> >> the bulk of the code space is in handling commands etc, if you don't
> >> have an external command set, ie messages to set up parameter tables etc
> >> then to initiate a transmission takes around 4 instructions. If you have
> >> a reasonably complex set of commands available then it grows
> >> accordingly. For example one of my systems has up to 40 different
> >> commands to handle and uses a 128 byte packet size, so it uses 136 bytes
> >> of RAM and around 0.8K of code space to process all the commands.
> >>
> >> All in assembler though.
> >>
> >> Cheers
> >>
> >> Al
> >>
> >>
> >> On 20/05/2012 7:26 AM, Luis Filipe Rossi wrote:
> >>> Hi, i am developing a project and we are still discussing if we should
> >>> include USB on our device. My main concern is about the USB stack
> >>> footprint. I will need to implement a very very simple HID device just
> to
> >>> trasfer data. Why to not use bulk? Becouse i dont need that transfer
> rate
> >>> so HID is more suitable as i wont need to develop a driver. I will
> >> probably
> >>> be using a MSP430F5 device with 16K of flash so i would need just a raw
> >>> estimative of the stack footprint with no optimizations (thse TI stack
> >> for
> >>> instance). Any one got that number?
> >>>
> >>> Thank you!
> >>>
> >>
> >>
> >
> >
>

--
Lu Filipe Rossi
Electrical Engineer
Biomechatronics Lab. / Grupo de Sensores Integreis e Sistemas
Escola Politnica
Universidade de S Paulo
Cel. +55 (11) 7662-9234


Hi Luis, packet based comms with no overhead on the MSP end can be done
with the UART, well, there is a little overhead when receiving and
compiling the data, but that applies in all cases. To me it seemed so
much simpler, but then I don't use any of the larger MSP430 devices. The
entire communication system, which includes set up, isrs, to handle TX
and RX and handling and execution of the entire remote command set sits
in 794 bytes of code space. There is no optimisation other than what I
do in my head, since this is assembler.

The comm handler does:-
byte by byte header qualification
packet length and EOM detection
CRC calculation
interprets received command and acknowledges
sends any of 4 parameter blocks
receives and reprograms those blocks
sends 8 different alarm messages
handles PING timing
manages storage or real time transmission of data and commands to do this
handles stop/start/pause cmds and actions
handles various data read modes, last block, single sector dump mem and
download parsed log
handles lost comm logic
message transmission and acknowledge
acknowledge with data packet
status updates
and a few other things I can't remember right now.

For smaller micros I have a stripped down version in 434 bytes that
handles things like:-

start/stop/pause
log real time
log to memory
update/read param table
change sample rates on the fly
status
download log
set binary or ascii hex data mode
converts raw data to normalised format in ASCII mode
does the ascii hex conversion and formatting to *.csv compatible mode

It too can run at 460kb

Al

On 20/05/2012 11:53 PM, Luis Filipe Rossi wrote:
> Hi,
>
> There are a few main reasons. First with HID transfer i will get a packet
> based communication with no extra overhead. Second, with HID i can make my
> application at the PC recognize when the the device is connected. With COM
> port the user would need to check which COM port was created. And finally,
> there is no need of driver at all for HID devices (it is embedded on the
> OS). So it is very portable.
>
> Just to make sure, your whole USB Virtual COM port implementation at a
> MSP430 uses 0.8K of flash?? Thats with no optimizations right?
>
> Any big difference on the code fro mthe TI examples?
>
> Thank you!
>
> On Sun, May 20, 2012 at 10:54 AM, Onestone wrote:
>
>> **
>> Hi Luis. no you were clear enough, except that if you really want simple
>> then why not a Virtual COM port. I run mine at 460800baud quite happily,
>> and it easily meets most situations I need, including plenty of space to
>> run even in the tiniest micros.
>>
>> Al
>> On 20/05/2012 10:49 PM, Luis Filipe Rossi wrote:
>>> Or I am not understanding your answer completely or we are talking about
>>> different things. I want to implement a HID class device (interrupt
>>> endpoint). The transfer size will be 64 bytes. What i am asking is how
>> much
>>> flash and RAM implementing such device will be used when using TI USB
>>> stack. It is not a Virtual COM port (CDC class) or any bulk endpoint
>>> transfer.
>>>
>>>
>>> Sorry if i was not clear.
>>>
>>>
>>> Thank you for your help!
>>>
>>>
>>> Regards,
>>>
>>> On Sun, May 20, 2012 at 6:05 AM, Onestone
>> wrote:
>>>> **
>>>>
>>>> If all you want is simple UART comms then it depends on the size of data
>>>> you want to transfer in each packet. The code to initialise the UART,
>>>> including enabling receive immediately is 8 instructions maximum. The
>>>> code to handle a transmit ISR is 7 instructions, including maintaining
>>>> the buffer pointer, RETI, and end of message handling. The code to
>>>> receive through the ISR is as little as 5 instructions when handling
>>>> single byte commands but 7 instructions lets you handle longer packets
>>>> before having to pass them to the main program.
>>>>
>>>> the bulk of the code space is in handling commands etc, if you don't
>>>> have an external command set, ie messages to set up parameter tables etc
>>>> then to initiate a transmission takes around 4 instructions. If you have
>>>> a reasonably complex set of commands available then it grows
>>>> accordingly. For example one of my systems has up to 40 different
>>>> commands to handle and uses a 128 byte packet size, so it uses 136 bytes
>>>> of RAM and around 0.8K of code space to process all the commands.
>>>>
>>>> All in assembler though.
>>>>
>>>> Cheers
>>>>
>>>> Al
>>>>
>>>>
>>>> On 20/05/2012 7:26 AM, Luis Filipe Rossi wrote:
>>>>> Hi, i am developing a project and we are still discussing if we should
>>>>> include USB on our device. My main concern is about the USB stack
>>>>> footprint. I will need to implement a very very simple HID device just
>> to
>>>>> trasfer data. Why to not use bulk? Becouse i dont need that transfer
>> rate
>>>>> so HID is more suitable as i wont need to develop a driver. I will
>>>> probably
>>>>> be using a MSP430F5 device with 16K of flash so i would need just a raw
>>>>> estimative of the stack footprint with no optimizations (thse TI stack
>>>> for
>>>>> instance). Any one got that number?
>>>>>
>>>>> Thank you!
>>>>>
>>>>
>>>