Presentation is loading. Please wait.

Presentation is loading. Please wait.

October 11, 20001. 2 Firmware for USB 2.0 Ryan Augustin Netchip Technology, Inc

Similar presentations


Presentation on theme: "October 11, 20001. 2 Firmware for USB 2.0 Ryan Augustin Netchip Technology, Inc"— Presentation transcript:

1 October 11, 20001

2 2 Firmware for USB 2.0 Ryan Augustin Netchip Technology, Inc ryan@netchip.com

3 October 11, 20003 Agenda USB 2.0 device-side programming w New USB 2.0 features: a programmer’s glossary w Choosing a chip from a programmer’s perspective w Performance: fast transfers, race conditions w Development aids: – Standard tools (USB analyzer) – Manufacturer’s Tools and support w Your “Rev 1” board: Tips, hints, steps to success

4 October 11, 20004 USB 2.0 Glossary, Features – For the Chip Programmer Glossary w CHIRP- Device/host: Who’s 2.0, who’s 1.1? w PING- Better way to NAK OUT packets w Micro-frame- 8 micro-frames per frame w?-w?-w?-w?- USB 2.0 features for chip programmers w 480 Mbit/s- 40 times faster than USB 1.1 w Bulk/Int: 512- Bulk and Interrupt MaxPkt now 512 w ISO: 1024- ISO MaxPkt now 1024 (up to 3 per micro frame)

5 October 11, 20005 USB 2.0 Max Packet Size 1024 (1,2 or 3 per µframe) 1023 (one per frame) ISO 64 8, 16, 32, 64 CONTROL (bMaxPacketSize0) 512 / 1024 8, 16, 32, 64 BULK / INTERRUPT USB 2.0 USB 1.1 wMaxPacketSize

6 October 11, 20006 Choosing a Chip – Programmers Perspective Get involved choosing the chip w Understand the hardware designer’s restrictions w Understand your task w Can the chip help you and the HW designer? – Pitfalls: e.g. The “endianism” problem w Can the chip maker help? – Development kits – Support policy

7 October 11, 20007 Choosing a Chip – Transfers and Hardware w Programmed I/O (Firmware transfer loop): – Transfer Rate: One pass of a “for” loop – End conditions: u Packet level: How much overhead? u Transfer level: ZLPs and dribble bytes – Write samples (Surprise!) w DMA – End conditions w Deep FIFOs – The “buzz” – Double depth (2 x 512 byte) minimum – FIFO allotment

8 October 11, 20008 Transfer Firmware – Programmed I/O w IN and OUT transfer firmware: – Interrupt handlers – Arbitrary length transfers (zero to a zillion+1) – Fast! (any type: Iso, Bulk, Interrupt, Control) w Critical considerations: – End of Transfer handling: Short Packets and ZLPs – Handling asynchronous nature of the USB – “Dribble” bytes (on 16 and 32 bit CPUs)

9 October 11, 20009 Transfer Firmware – IN Transfer Usb_Interrupt(): For arbitrary length IN transfer w Read IntStat – Which endpoint interrupted? w Write EpStat – Re-arm endpoint interrupt w Read EpStat – Check for Short Packet u (Short packet? Finish and return) w Read EpCount – Get available FIFO space w Copy – “for” loop w Return from Interrupt u Deep FIFOs

10 October 11, 200010 Transfer Firmware – OUT Transfer Usb_Interrupt(): For arbitrary length OUT transfer w Read IntStat – Which endpoint interrupted? w Write EpStat – Re-arm endpoint interrupt w Read EpCount– Get FIFO count (in bytes) w Read EpStat– Check for Short Packet u (Short Packet? Re-read EpCount) w Copy – “for” loop (32-bit) w Return from Interrupt u Short Packet (ZLP) detection u NAK OUTs after Short Packet

11 October 11, 200011 Transfer Firmware – Summary w Write critical transfer code to find weak spots – ZLPs – Dribble bytes – Race conditions w See for yourself: Get a development kit

12 October 11, 200012 Development Kits USB 2.0 Host USB 2.0 “Device” USB Cable NET2290 Development Kit for a USB 2.0 device PCI card with NET2290 Plugged into Windows PC

13 October 11, 200013 Development Kits – Highlights w Goals of the kit: – Show the chip in action – Provide a good HW platform for learning firmware – Provide “Ready to port” sample source code w Allows development without hardware: – Develop your firmware without hardware – Develop host drivers and apps without hardware – Prove concepts without hardware w Includes host-side and device-side tools

14 October 11, 200014 Development Kits – Device-Side Software Tools USB device-side monitor application w Interactive and intuitive w Comprehensive command set w Full control of: – Chip register content – Transfer content (fill, copy, compare, …) – Transfer size – EP0: Standard, Vendor Specific; Read and Write w Multiple commands w Can you repeat that?

15 October 11, 200015 Development Kits – Host-Side Software Tools USB Host-Side Monitor Application w Interactive and intuitive w Comprehensive command set w Full control over transfers: – Transfer content (fill, copy, compare, …) – Transfer size – EP0: Standard, Vendor Specific; Read and Write w Multiple commands w Can you repeat that? w Loopback tests

16 October 11, 200016 Your New USB 2.0 Device – Rev 1: Prototype Board w Relaxed board dimensions w Header pins w Diagnostic serial port w Room for emulator pod (if applicable) w Board layout and USB signal quality

17 October 11, 200017 Your New USB 2.0 Device Development Environment A good development environment is priceless w Tools: – USB bus analyzer – USB host-side program w printf() w History() – Minimal run-time penalty – Simple: It stores a text key and few parameters u Example History(“TxPk”, ExpectLen, GotLen, pBuf); – Call History() anywhere in your code – Make a HISTORY() macro (add or remove at compile time) – Examine History memory after problem occurs

18 October 11, 200018 Your New USB 2.0 Device – History() Module typedef struct _HISTORY_BUF { char* Text; Arg1; Arg2; Arg3; } HISTORY_BUF #define HISTORY_ENTRIES 1000// Number of historical events static HISTORY_BUF HistoBuf[HISTORY_ENTRIES];// History is recorded here static HistoryCount = 0;// Current historical event void History(char * Text, Arg1, Arg2, Arg3) { memcpy(&HistoBuf[HistoryCount].Text, Text, 4);// Text key (E.g. “TxCo” HistoBuf[HistoryCount].Arg1 = Arg1; HistoBuf[HistoryCount].Arg2 = Arg2; HistoBuf[HistoryCount].Arg3 = Arg3; HistoryCount++;// Prepare for next event if (HistoryCount >= HISTORY_ENTRIES) { if (HistoryCount >= HISTORY_ENTRIES) { HistoryCount = 0;// History rewrites itself } memset(&HistoBuf[HistoryCount], 0, sizeof(HISTORY_BUF));// “Easy to spot” terminator }

19 October 11, 200019 Your New USB 2.0 Device – Bringing up the Board Take small steps! w Prove register access w Prove interrupt subsystem w Vendor Specific enumeration w Basic IN and OUT transfers w Loopback transfers w Special transfers w Special enumeration

20 October 11, 200020 Your New USB 2.0 Device – Enumeration w Everything has to work at the same time w You can’t single step (except PDK) w Things that can cause enumeration failures: – Set Address request (gotcha!) – Signal quality – Descriptor content … and plenty more! w Use Vendor Specific enumeration first

21 October 11, 200021 Your New USB 2.0 Device: - Bringing up the Board Take small steps! w Prove register access w Prove interrupt subsystem w Vendor Specific enumeration w Basic IN and OUT transfers w Loopback transfers w Special transfers (Control, ISO, Interrupt) w Special enumeration (for class devices) Debugger “Gotcha”

22 October 11, 200022 NET2290 – A Few Special Features w Built-in Standard Request handlers “Automatic Enumeration” Class devices must handle Get Configuration w Self configuring FIFOs w Ready signal on FIFO access … and more!

23 October 11, 200023 ? ? Question and Answers www.netchip.com ? ? ? ? ? ? ? ? ? ? ? ? ? ?

24 October 11, 200024 Thank You! From Ryan Augustin and… NetChip Technology, Inc. www.netchip.com


Download ppt "October 11, 20001. 2 Firmware for USB 2.0 Ryan Augustin Netchip Technology, Inc"

Similar presentations


Ads by Google