Dangerous Prototypes

In development => Project development, ideas, and suggestions => Open source USB stack => Topic started by: ian on August 29, 2011, 10:50:15 am

Title: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: ian on August 29, 2011, 10:50:15 am
Here is a simple echo demo using the JTR-Honken open source USB stack. It has been tested on the IR Toy (18F2550) and the Bus Pirate v4 (24FJ256GB106).

A lot of things are still a bit messy, especially the USB read buffer ported from the IR Toy, but it works! I hope by releasing this simple package we can get some other developers involved.

The key to a new port:
*Change hardware define in HardwareProfile.h, add a LED pin for your hardware
*Add setup code for your hardware in void SetupBoard(void) in main.c
*Add basic USB info for your hardware in cdc_config.h (copy an old one and modify if needed)
*Add your config words to configWords.h

If you try it please contribute any additional PIC support.

New vb:
*Double buffer output demo
*Interrupts (pic24F) demo

New vc:
*include fixes
*service loop fixes

Problems:
*on PIC 24F it will not work the first time (device error). Hit reset and it connects. This is consistent.
*on PIC 24F with interrupts enabled it will be device error about 2 out of 10 resets
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: tayken on August 29, 2011, 11:42:49 am
Fİrst I tried to compile it, the compiler gave all sorts of weird warnings. Especially about some comments (/* stuff, I really didn't care at that time), but my computer didn't recognize the device when I plug it in.

Then I used the supplied hex file with my BPv4, my computer (Vista) does not recognize the device when it is directly connected.

However, when I pressed "normal" button while plugging in. It recognized, installed drivers and assigned a COM port automatically.

Connected with PuTTY at baud rate 115200, echo is good, no glitches. Pressing "enter" puts the cursor at the beginning of the line.

Yay!!! :)
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: ian on August 29, 2011, 11:46:50 am
I get the comments warnings too.

Strange about the button thing, hum...

For me it is unrecognized when first plugged in. Pressing reset gets it to connect.

Hum, maybe a delay is needed?
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: tayken on August 29, 2011, 11:57:17 am
Oh yeah, sorry about that. I did the reset cycle with "normal" button pressed. This time I really plugged in while pressing "normal", nothing happened. Then I pressed reset and it worked.

There should be a solution. I'll start looking around. Will you be at IRC by any chance?
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: ian on August 29, 2011, 12:01:42 pm
Yeah, noticed that too. Quick plug and unplug will make it work too. I'm not worried because I can keep developing the Bus Pirate firmware because I only use ICD2 to reset and it works every time :)

Yeah, I'll jump in IRC.
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: ian on August 29, 2011, 12:03:07 pm
Also - I noticed it doesn't do it on the 18F version.

Also - no amount of delay anywhere in the setup fixes it...
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: Sjaak on August 29, 2011, 12:30:55 pm
[quote author="ian"]I get the comments warnings too.

Strange about the button thing, hum...

For me it is unrecognized when first plugged in. Pressing reset gets it to connect.

Hum, maybe a delay is needed?[/quote]

Isn't the brown-out protection and power on reset settings (config word) messing with you? A delay would temporary fix this.

Saw your update so i  guess this isnt the issue :)

how about a delay after initing the usbhardware? perhaps the bus needs some time to stabilize.
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: ian on August 29, 2011, 02:00:31 pm
There's an updated package attached above.
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: tayken on August 29, 2011, 02:37:03 pm
[quote author="ian"]There's an updated package attached above.[/quote]
hex file in the vb package works on my Vista PC with BPv4.
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: ian on August 29, 2011, 07:16:14 pm
vc uploaded with include fixes.
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: JTR on September 11, 2011, 10:30:38 am
Coming soon. A whole new, documented,  CDC stack with easy to use API.

        inByte = getc_cdc();
        putc_cdc(inByte);

With automatic double buffering, ZLP handling and timeout flush (adjustable in milliseconds increments), doesn't get much simpler than this. The new API also hides the low level CDC handling so that if/when hardware ping-pong is added (required for the PIC32 port) this will be invisible to the user app. It also runs equally well with interrupt mode or polled mode.
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: ian on September 12, 2011, 09:00:32 am
Very cool. I'm going to talk about [s:]your[/s:] JTR and Honken's work on the stack, as well as the Microchip editorial at the Open Hardware Summit this Thursday.
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: honken on September 12, 2011, 09:07:34 am
I think JTR deserves to be mentioned as well. He has found and corrected a lot of bugs while I have almost dropped the ball lately due to lack of time.
Title: Re: JTR-Honken USB stack echo demo for PIC 18F 24F
Post by: ian on September 12, 2011, 09:09:49 am
Sorry about that, I edited it to remove any confusion.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01602096616session_write_close ( )...(null):0
20.01632228208ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01632228984Database_MySQL->query( ).../DatabaseHandler.php:119
40.06062367720Database_MySQL->error( ).../Db-mysql.class.php:273