Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: Understand Prog pin in Teensy3.1

  1. #1
    Junior Member
    Join Date
    Sep 2015
    Posts
    1

    Understand Prog pin in Teensy3.1

    Hi,
    i am using the Teensy 3.1 + Dragino Yun Shield + Teensy3.1 Arduino adapter to test.
    Click image for larger version. 

Name:	Teensy3.1_YunShield.png 
Views:	155 
Size:	435.4 KB 
ID:	5151

    i am trying to upload the image from the Yun Shield to Teensy via USB. since i want all the process to be automatically. i want to use the Prog pin from Teensy. i tried to run below command to upload.
    root@dragino-ae097e:~# teensy_loader_cli -w -v -mmcu=mk20dx256 blink_slow_Teensy31.hex
    Teensy Loader, Command Line, Version 2.0
    Read "blink_slow_Teensy31.hex": 14324 bytes, 5.5% usage
    Found HalfKay Bootloader
    Programming..............
    Booting

    but i have inconsistent while using the Prog pin. the procedure i try is:
    1/ run teensy_loader_cli -w -v -mmcu=mk20dx256 blink_slow_Teensy31.hex . and the console will wait for the teensy boot into bootloader
    2/ set Prog to low and then set it high by commands.

    but the problem is that the Yun Shield can't see teensy from the USB port so can't upload the image. And after a reboot , i remove all signal from the Teensy Prog pin. and the uploader suddently can upload the image 100% without problem.

    How to use the Prog pin seems inconsistent to me. if some one can explain more. it will be great. Thank you.

    Best Regards,
    Edwin

  2. #2
    Hello,

    Which firmware did you use ?

    Did you looked at script run-teensy-loader + name_of_hex.hex ?

    I am looking for configuring same setup. I am not sure my update of the firmware is correct. I will do other try.

  3. #3
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,066
    what you wanted to do is to simulate a button press, right?
    now you pull down the prog line and release it after say 1s, AFTER releasing the prog line, the cli will start down loading.
    while prog line low, nothing will happen.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,774
    Quote Originally Posted by edwin View Post
    2/ set Prog to low and then set it high by commands.
    And how are you doing that? What exactly is manipulating this signal by commands? Better not be Teensy, since pulling this pin low causes Teensy to stop running!

  5. #5
    I suppose he used commands of this kind : echo 0 > /sys/class/gpio/gpio22/value with ssh connexion at yun board (see dragino script below).

    I have the dragino yun shield v1.1.6 and I am afraid during testing I did error : my teensy seems KO and the chip marked 66HVJ L120B is very hot (linear regulator ? cannot find reference in pjrc doc).
    Before this crash latests testings were changing the teensy prog pin from Miso to another : reset and after Mosi.

    The dragino tutorial ask to link teensy prog pin to yun Miso pin. I am not sure this Gpio22-Miso pin can drive the prog pin because of the buffer direction of Miso :
    Yun Gpio22 to O1 of 74VHC125 and Teensy prog pin to Miso/B1.
    Yun Gpio19 enable the buffer.
    Name:  74VHC125.png
Views: 252
Size:  23.0 KB
    I see that maximum DC Output current Iout is 25mA. I think it required less than 1mA.

    Also I do not understand fully the dragino script from /usr/bin/run-teensy-loader
    Code:
    #!/bin/sh
    
    #check reference profile to set up MCU type and fuse
    profile=`uci get sensor.mcu.board`
    
    #kill teensy_loader
    pid=`ps | grep "teensy_loader_cli" | grep -v grep | awk '{print $1}'`
    [ ! -z $pid ] && kill $pid
    
    #Check if GPIO19 is already exported
    if [ -d /sys/class/gpio/gpio19 ]; then
    GPIO19_EXPORTED='YES'
    fi
    
    if [ ! $GPIO19_EXPORTED ]; then
    	echo 19 > /sys/class/gpio/export
    	echo "high" > /sys/class/gpio/gpio19/direction
    fi
    
    echo 1 > /sys/class/gpio/gpio19/value
    
    #set GPIO22 to low to boot the Teensy to bootloader mode
    [ ! -d /sys/class/gpio/gpio22 ] && echo 22 > /sys/class/gpio/export
    echo "high" > /sys/class/gpio/gpio22/direction
    
    
    if [ $profile == 'teensy31' ]; then
       teensy_loader_cli -mmcu=mk20dx256 -w $1 -v
       result=$?
    fi
    
    echo 0 > /sys/class/gpio/gpio22/value
    echo 22 > /sys/class/gpio/unexport
    
    #disconnect SPI
    echo 0 > /sys/class/gpio/gpio19/value
    
    if [ $GPIO19_EXPORTED ]; then
    #it seems never reach this part
    	echo 19 > /sys/class/gpio/unexport
    fi
    
    exit $result
    I tried simply to drive manually Gpio22 without success.

    I cannot find the script in the git repository of dragino. this one is from firmware Dragino-v2 comon-2.0.7

    My plan is to get 3G connexion using this yun shield.
    Last edited by Vincenet; 02-15-2017 at 10:44 AM. Reason: add component schematic

  6. #6
    Finally, I confirm my doubt concerning pin to use to lower prog pin. I use pin4_MOSI of the ICSP connector of the yun board (instead of the MISO like in the tutorial Dragino).

    Also I updated the script /usr/bin/run-teensy-loader with this code :
    Code:
    #!/bin/sh
    
    #check reference profile to set up MCU type and fuse
    profile=`uci get sensor.mcu.board`
    
    #kill teensy_loader
    pid=`ps | grep "teensy_loader_cli" | grep -v grep | awk '{print $1}'`
    [ ! -z $pid ] && kill $pid
    
    #abort if profile not corresponding
    if [ $profile != 'teensy31' ]; then
    echo "wrong mcu type"
    exit
    fi
    
    #configure 21 to have no effect on prog pin
    if [ -d /sys/class/gpio/gpio21 ]; then                               
    echo "warning: gpio21 already exported"                                         
    GPIO21_EXPORTED='YES'
    else
    echo 21 > /sys/class/gpio/export
    fi 
    echo 0 > /sys/class/gpio/gpio21/active_low
    echo out > /sys/class/gpio/gpio21/direction
    echo 1 > /sys/class/gpio/gpio21/value
    
    #configure 19 to enable buffer
    if [ -d /sys/class/gpio/gpio19 ]; then
    GPIO19_EXPORTED='YES'                                         
    else                            
    echo "warning: need to export gpio19"          
    echo 19 > /sys/class/gpio/export
    fi 
    echo 0 > /sys/class/gpio/gpio19/active_low
    if [ -d /sys/class/gpio/gpio19/direction ]; then
    echo "warning: direction available for gpio19, configure as output"     
    echo out > /sys/class/gpio/gpio19/direction
    fi
    
    echo 1 > /sys/class/gpio/gpio19/value
    
    #launch teensy loader cli
    if [ $profile == 'teensy31' ]; then
    echo "call teensy_loader_cli"
       teensy_loader_cli -mmcu=mk20dx256 -w $1 -v &
       result=$?
    fi
    
    #trig prog pin
    echo 0 > /sys/class/gpio/gpio21/value
    sleep 1
    echo 1 > /sys/class/gpio/gpio21/value
    
    echo 0 > /sys/class/gpio/gpio19/value
    
    sleep 3
    
    if [ ! $GPIO21_EXPORTED ]; then
    echo 21 > /sys/class/gpio/unexport
    fi
    
    if [ ! $GPIO19_EXPORTED ]; then
    echo 19 > /sys/class/gpio/unexport
    fi
    
    
    echo $result
    exit $result
    I will probably add serial resistor to limit current of buffer when button of teensy is pressed. Also a pull up because I see some strange reset crashing the teensy when using multimeter on prog pin.
    I need also to work on yun start up script because it does not allow start up for teensy. I need to launch the above script.

    I wonder if GPIO20 /Reset pin of ICSP connector is may be more appropriate.
    Last edited by Vincenet; 02-15-2017 at 05:47 PM.

  7. #7
    I finally use the reset pin (gpio20) without any resistor.
    Just change /usr/bin/reset-mcu script to disable change of value for gpio20.
    Use following script when you need to update your sketch : cd /usr/bin ; run-teensy-loader_pin5_reset Blink.hex
    Code:
    root@dragino-16200c:/usr/bin# cat /usr/bin/run-teensy-loader_pin5_reset 
    #!/bin/sh
    
    #check reference profile to set up MCU type and fuse
    profile=`uci get sensor.mcu.board`
    
    #kill teensy_loader
    pid=`ps | grep "teensy_loader_cli" | grep -v grep | awk '{print $1}'`
    [ ! -z $pid ] && kill $pid
    
    #abort if profile not corresponding
    if [ $profile != 'teensy31' ]; then
    echo "wrong mcu type"
    exit
    fi
    
    #configure 20 to have no effect on prog pin
    if [ -d /sys/class/gpio/gpio20 ]; then                               
    echo "warning: gpio20 already exported"                                         
    GPIO20_EXPORTED='YES'
    else
    echo 20 > /sys/class/gpio/export
    fi 
    echo 1 > /sys/class/gpio/gpio20/active_low
    echo out > /sys/class/gpio/gpio20/direction
    echo 1 > /sys/class/gpio/gpio20/value
    
    #launch teensy loader cli
    if [ $profile == 'teensy31' ]; then
    echo "call teensy_loader_cli"
       teensy_loader_cli -mmcu=mk20dx256 -w $1 -v &
       result=$?
    fi
    
    #trig prog pin
    echo "info : trig prog pin... "  
    echo 0 > /sys/class/gpio/gpio20/value
    sleep 3
    echo 1 > /sys/class/gpio/gpio20/value
    echo "info : done"  
    
    sleep 1
    
    if [ ! $GPIO20_EXPORTED ]; then
    echo 20 > /sys/class/gpio/unexport
    fi
    
    echo $result
    exit $result
    Then, chose a 3g dongle to control it over internet ! (I chose a Sierra Wireless, find some steps here to configure it https://forum.openwrt.org/viewtopic....358155#p358155).
    Next step for me is to configure the open-vpn client to connect to my server at home. As alternate solution, I saw somewhere it exist a reverse ssh command.

  8. #8
    Hello,
    I have an issue with my teensy, that seems blocked. Watchdog enabled and does not help.
    I think it receive noise on the prog pin and then waiting for a sketch from teensy loader.
    Is there a way to add timeout on the bootloader?
    How can I filter the signal? Please find here the schematic of the yun :
    Click image for larger version. 

Name:	Capture du 2017-06-11 19:12:40.png 
Views:	60 
Size:	8.0 KB 
ID:	10790
    I linked /Reset to prog pin of the teensy.

    Otherway, if I link the /Reset to reset pin of teensy (instead of prog pin), does it still allow trig bootloader like with prog pin ?
    Last edited by Vincenet; 06-11-2017 at 06:25 PM.

  9. #9
    Yun 2.4 seems more sensitive than 1.6. Problem appear with minimum of sensor, leds... not with basic configuration on the desk.

    I am thinking adding a kind of filtering (one electrolytic capacitor ? is there other component against noise?).

    May be I should also retry with yun Mosi (gpio21).

    Edit: Finally, I am testing following schematic (no blocking after few hours testing):
    Click image for larger version. 

Name:	sparkfun_teensy_adapter_and_dragino_yun_shield.jpg 
Views:	84 
Size:	50.7 KB 
ID:	10946

    Any comment is welcomed.
    Last edited by Vincenet; 07-03-2017 at 05:23 PM. Reason: adding potential solution

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •