Shop OBEX P1 Docs P2 Docs Learn Events
Bug/inconsistency with propeller detection on Linux — Parallax Forums

Bug/inconsistency with propeller detection on Linux

pedwardpedward Posts: 1,642
edited 2012-06-14 07:14 in Propeller 1
I tried 3 different boards, the PropKEY and Quickstart reliably only detect every other attempt. I hit "run", it works, "hit run", no worky, "hit run", it works, etc. The Protoboard USB worked about 3 times in a row, then got a not-detected error.

I'm putting this out there to see if anyone has any ideas or suggestions of what the root problem is, I plan on tracking it down. I've written reliable serial code for Linux before, so that's not a stretch for me.

Comments

  • RossHRossH Posts: 5,511
    edited 2012-06-12 01:54
    pedward wrote: »
    I tried 3 different boards, the PropKEY and Quickstart reliably only detect every other attempt. I hit "run", it works, "hit run", no worky, "hit run", it works, etc. The Protoboard USB worked about 3 times in a row, then got a not-detected error.

    I'm putting this out there to see if anyone has any ideas or suggestions of what the root problem is, I plan on tracking it down. I've written reliable serial code for Linux before, so that's not a stretch for me.

    With Catalina, the main problem on Linux appears to be a simple timing issue. I have found that using the "nice" command (and also being more generous with read timeouts) ups the reliability to near 100%. Without that, I see similar results to those you are reporting.

    For example, instead of:
    payload program
    
    On Linux I generally have to say:
    nice -10 payload program -t 1000
    

    (Note that payload is a Catalina-specific command, and the -t option sets the read timeout in ms - I don't know the equivalent PropGCC commands).

    Ross.
  • jazzedjazzed Posts: 11,803
    edited 2012-06-12 06:46
    I recently committed a change for more reliable Quickstart programming for propeller-load. Are you using a distribution or did you compile from scratch?
  • pedwardpedward Posts: 1,642
    edited 2012-06-12 11:04
    Ross, why aren't you using select for turnaround? You can specify a timeout with select, like 5 seconds, for "not detected", but in normal operation it will return as soon as data is available on the fd.

    Steve, I'm using a distro, so it looks like I should update the distro and try again.

    Does propeller-load use select for comms detection and timeout?
  • jazzedjazzed Posts: 11,803
    edited 2012-06-12 11:46
    pedward wrote: »
    Steve, I'm using a distro, so it looks like I should update the distro and try again.

    Does propeller-load use select for comms detection and timeout?

    Yes, it does.

    I have intermediate distributions or just propeller-load binaries if you want to try that.
  • RossHRossH Posts: 5,511
    edited 2012-06-12 19:19
    pedward wrote: »
    Ross, why aren't you using select for turnaround? You can specify a timeout with select, like 5 seconds, for "not detected", but in normal operation it will return as soon as data is available on the fd.

    I don't think the timing issue is related to sending or receiving individual characters - the normal buffering takes care of that adequately. I think the timing problem is related to the timing of things like toggling DTR and then sending the calibration bytes and then waiting for the response. Perhaps a more judicious use of buffer flushing would help, but select wouldn't make any difference.

    Ross.
  • Daniel HarrisDaniel Harris Posts: 207
    edited 2012-06-13 11:20
    I have experienced this problem too. The issue stems from the Propeller's ROM booter - during part of the handshake sequence, the Propeller lets the TX line to the PC float. The buffer chip between the Propeller and FTDI chip on the Quickstart and other boards can send some garbage back to the PC, which gets misinterpreted as a malformed handshake.

    A hardware solution is to use a 10K resistor to weakly pull P30 (TX) up to Vdd. A software solution would be to have the PC receive everything during the handshake sequence, and search for the correct handshake sub-string. Jazzed's recent loader changes implement the software solution. Jeff has updated the Propeller Tool to fix this problem, too. Those Propeller Tool fixes will be rolled out with the next release of the Propeller Tool software.
  • pedwardpedward Posts: 1,642
    edited 2012-06-13 12:16
    Hmm, I have the FTDI directly connected to 30/31, so no buffer (it's USB powered, so they both always have power).

    I will look at adding the pullup and see if that fixes it. Just tried the 10k pullup, and that doesn't fix it.

    I do note that every time it fails, SIDE is flushing a number of characters from the serial port, so SIDE is seeing something.

    Perhaps the *real* problem is that the serial buffer has data in it on the OS and the port needs to be flushed first.

    Perhaps:

    Raise DTR
    Flush
    Lower DTR
    Raise DTR
    Detect

    Curiously, because of the inline cap, you can't hold the prop in reset while you flush the port.
  • jazzedjazzed Posts: 11,803
    edited 2012-06-13 17:19
    I have been able to reproduce this issue on Fedora17 in my VM and am looking at it.
    The first load always fails after some idle time, then all loads pass after that.
    This is not the Quickstart oscillator problem.
  • pedwardpedward Posts: 1,642
    edited 2012-06-13 17:29
    In my case, the behavior is like a flip flop. With the Propkey, every other load attempt fails.
  • jazzedjazzed Posts: 11,803
    edited 2012-06-13 17:56
    Try this. Only good for x86_64 linux. Compiled on Fedora-17 x86_64.

    --Steve
  • RossHRossH Posts: 5,511
    edited 2012-06-13 18:01
    I have experienced this problem too. The issue stems from the Propeller's ROM booter - during part of the handshake sequence, the Propeller lets the TX line to the PC float. The buffer chip between the Propeller and FTDI chip on the Quickstart and other boards can send some garbage back to the PC, which gets misinterpreted as a malformed handshake.

    A hardware solution is to use a 10K resistor to weakly pull P30 (TX) up to Vdd. A software solution would be to have the PC receive everything during the handshake sequence, and search for the correct handshake sub-string. Jazzed's recent loader changes implement the software solution. Jeff has updated the Propeller Tool to fix this problem, too. Those Propeller Tool fixes will be rolled out with the next release of the Propeller Tool software.

    Thanks for the update Daniel - I'll do some experiments to check out your suggested fix. I have never experienced any problems with the Propeller tool, and on Linux I can make it very nearly as reliable without any hardware changes or buffer flushing just by tweaking the timing. But I suppose changing the timing could also change the likelihood of receiving garbage bytes back during the handshake sequence.

    Ross.
  • jazzedjazzed Posts: 11,803
    edited 2012-06-13 18:07
    Ross, do you actually have a Quickstart board?
  • RossHRossH Posts: 5,511
    edited 2012-06-13 19:07
    jazzed wrote: »
    Ross, do you actually have a Quickstart board?

    No - sorry, does the hardware fix mentioned by Daniel apply only to that board? That might explain why I've not seen it.

    Ross.
  • jazzedjazzed Posts: 11,803
    edited 2012-06-13 20:16
    RossH wrote: »
    No - sorry, does the hardware fix mentioned by Daniel apply only to that board? That might explain why I've not seen it.

    Ross.


    Yes ... so far. Quickstart is a unique and interesting board. There is much written about it here.

    We must flush the garbage between sending the magic LFSR sync-up and the transmit-back serial streams.
  • RossHRossH Posts: 5,511
    edited 2012-06-13 23:58
    jazzed wrote: »
    Yes ... so far. Quickstart is a unique and interesting board. There is much written about it here.

    We must flush the garbage between sending the magic LFSR sync-up and the transmit-back serial streams.

    Ok - thanks. I've not heard reports of any problems using Payload with the Quickstart, but I'll add a buffer flush in the next release (and make it optional).

    Ross.
  • jazzedjazzed Posts: 11,803
    edited 2012-06-14 07:14
    pedward wrote: »
    In my case, the behavior is like a flip flop. With the Propkey, every other load attempt fails.


    Let me know if you get a chance to try that loader. It solves my Fedora-17 issues.
Sign In or Register to comment.