Skip to main content
Topic: The missing piece: porting BPv4 to the open source USB stack (Read 13475 times) previous topic - next topic

Re: The missing piece: porting BPv4 to the open source USB s

Reply #15
Thanks guys,

Sjaak - good observations. If I change the 62 to 50, it acts a lot different. I get a whole bunch of repeating stuff before it crashes. I also added WaitInReady(); to UART1TX, but it didn't change anything.

Quote
OK, one question: I guess when we enable double buffer we first fill a buffer with all the characters, then burst it out in one time, but if we disable it, we send character by character, am I right?

Double buffer there are two buffers and we can fill one while the other goes to the PC. Single buffer is like the old stack, we can send an array of up to (64?) bytes, and then we have to wait for it to finish before sending more. Actually, my plan for today is just to implement a better single buffer mode and make a release. Eventually someone will want to fix up the double buffer :)

I'll be in IRC, but it only flashes a notice if you mention me so you might need to shout to be noticed ;)
Got a question? Please ask in the forum for the fastest answers.

Re: The missing piece: porting BPv4 to the open source USB s

Reply #16
I'm ashamed of you guys ;) You're both better coders than me, and more attentive :P I found the problem, and it was super amateur hour :D (just kidding about the shame part, ya'll are awesome!)

Code: [Select]
    lock = 1;
    *InPtr = c;
    InPtr++;
    CDC_In_count++;
    if (CDC_In_count > 62) {//62
    WaitInReady();
        SendCDC_In_ArmNext(CDC_In_count);
        FAST_usb_handler();
    }
    lock = 0;
    //setup timer to throw data if the buffer doesn't fill
    fcnt = 0;

Notice any glaring omission in this code? Here's a hint:

Code: [Select]
			CDC_In_count=0;

Yes. That's right. The byte counter is never reset. Actually it is, but only in the interrupt service loop and not the main loop when there are lots of characters processed.

Here's the fix:
Code: [Select]
	    *InPtr = c;
    InPtr++;
    CDC_In_count++;
    if (CDC_In_count > 62) {//62
    WaitInReady();
        SendCDC_In_ArmNext(CDC_In_count);
        FAST_usb_handler();
CDC_In_count=0;
    }

I'm going to test with bootloader and then upload a package to test.
Got a question? Please ask in the forum for the fastest answers.

Re: The missing piece: porting BPv4 to the open source USB s

Reply #17
You shouldn't be ashamed. You did lots of coding and gets blind after a while.

Great job!

I still had some issues that the BP isn't recognized the first time, replugging will get it recognized.

Re: The missing piece: porting BPv4 to the open source USB s

Reply #18
Fixed a minor error in the T1 interrupt that broke the firmware when used with the bootloader. The latest package is in a new thread here:
viewtopic.php?f=28&t=2724#p26605

Please let me know if you have a chance to test.

There is lots of little stuff that needs to be fixed, it will fall over quite easily. Most of it is pretty straightforward better buffering and changing the DIO subsystems of the Bus Pirate.

Also - it is beyond time to release a new firmware for v3.5. I couldn't get everything to fit before, maybe we could eliminate a big chunk like the BASIC interp. It could be a feature we only compile into v4.

-----

Saw your post: I think you read it wrong :) I was (jokingly) saying you should be ashamed because it was so simple. I have an excuse, I am a terrible coder ;)

Yes, that startup bug is a pain. It doesn't happen on 18F or the bootloader for the 24F.
Got a question? Please ask in the forum for the fastest answers.

Re: The missing piece: porting BPv4 to the open source USB s

Reply #19
I just compiled with the bootloader descriptor and tested, but it doesn't change the startup bug...

It would be _great_ to squash that one soon :)
Got a question? Please ask in the forum for the fastest answers.

Re: The missing piece: porting BPv4 to the open source USB s

Reply #20
[quote author="ian"]Saw your post: I think you read it wrong :) I was (jokingly) saying you should be ashamed because it was so simple. I have an excuse, I am a terrible coder ;)
[/quote]

Bleh.. I desperate need some coffee :)

Re: The missing piece: porting BPv4 to the open source USB s

Reply #21
[quote author="ian"]
Notice any glaring omission in this code? Here's a hint:

Code: [Select]
			CDC_In_count=0;

Yes. That's right. The byte counter is never reset. Actually it is, but only in the interrupt service loop and not the main loop when there are lots of characters processed.
[/quote]
Ok... I just assumed that it was being cleared, I was look at the code with 3 hours of sleep. :( After my hackerspace meeting, I'll drink a litre of coffee, log on to the IRC channel and start checking out the code. :)

Re: The missing piece: porting BPv4 to the open source USB s

Reply #22
More fix-ups coming. Please see here:
viewtopic.php?f=28&t=2724&start=15#p27199