Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teensy / Bootloader/Reset (via Shift + Shift + Pause) doesn't put the teensy in boot mode. #532

Closed
jasonm23 opened this issue Jul 17, 2016 · 44 comments

Comments

@jasonm23
Copy link
Contributor

jasonm23 commented Jul 17, 2016

I've found that the doing Shift + Shift + Pause isn't putting the teensy 2.0 into bootloader / flashing mode properly. TMK worked fine.

I've looked at #164 and ensured the USB is unplugged/plugged in again to ensure this isn't the cause.

Teensy CLI and the GUI both fail to see it in bootloader mode.

As a side note the keyboard simply begins registering key strokes again in a few seconds after doing Shift + Shift + Pause

@jasonm23
Copy link
Contributor Author

I reflashed the Teensy after a hardware reset and now the Shift + Shift + Pause is working ok.

@jasonm23
Copy link
Contributor Author

Setting up a short on the teensy GND / RST that I can trigger easily without opening the case seems like a reasonable long term solution.

@jasonm23
Copy link
Contributor Author

@jackhumbert are there options for software based reset?

@jasonm23 jasonm23 reopened this Jul 18, 2016
@jasonm23
Copy link
Contributor Author

@jackhumbert one other related question, why does the regular keyboard firmware kick in after 3 or so seconds? Makes me think it's not really going to the bootloader.

@TerryMathews
Copy link
Contributor

@jasonm23 What kind of options are you looking for? You can put RESET on your keymap and the sky is basically the limit. I have mine bound to Fn + Backspace.

@jasonm23
Copy link
Contributor Author

Hi @TerryMathews I'm basically looking to have keyboard based access to the bootloader.

Shift - Shift - Pause is unreliable, and often necessitates opening up the case. (Sorry if I didn't explain that.)

If mapping RESET on the keymap is possible, and that's identical in operation to pressing the hw button on the teensy, I think I'll be set.

@TerryMathews
Copy link
Contributor

Look at the keymap in Phantom for an example of what RESET looks like.

On Jul 25, 2016 12:22 AM, "JasonM23" [email protected] wrote:

Hi @TerryMathews https://github.com/TerryMathews I'm basically looking
to have keyboard based access to the bootloader.

Shift - Shift - Pause is unreliable, and often necessitates opening up the
case. (Sorry if I didn't explain that.)

If mapping RESET on the keymap is possible, and that's identical in
operation to pressing the hw button on the teensy, I think I'll be set.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#532 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB4VBQAfPmT5BoSDqc3k4UNLLhOrdej5ks5qZDoSgaJpZM4JOM9B
.

@jasonm23
Copy link
Contributor Author

jasonm23 commented Jul 25, 2016 via email

@jasonm23
Copy link
Contributor Author

jasonm23 commented Jul 25, 2016

Place RESET on a keymap position.

The code / pre tags make a big difference in read/cognition (read: certainty) for me.

@jasonm23
Copy link
Contributor Author

jasonm23 commented Jul 25, 2016

@TerryMathews - so I mapped up RESET on FN0 + Pause which is happening, hid_listen borks as expected when it's triggered, but then a few seconds later the keyboard is running the QMK firmware again, and appears to auto-reboot.

This isn't what happens when doing a HW reset and that's what I'm really after.

Is it possible? Am I doing something else wrong? Really at a loss to understand if (a) I have unreasonable expectations of what software reset can/should do. (b) I'm missing some info (c) ???

@TerryMathews
Copy link
Contributor

You have something wrong in your source then. Reset should be taking you to
the bootloader. If it is not, the bootloader size in Makefile is likely
wrong for the device you're using.

Which, by the way, what device are you working on and can you upload the
source your using to GitHub so we can look at it?

On Jul 25, 2016 2:21 AM, "JasonM23" [email protected] wrote:

@TerryMathews https://github.com/TerryMathews - so I mapped up RESET on
FN0 + Pause which is happening, hid_listen borks as expected when it's
triggered, but then a few seconds later the keyboard is running the QMK
firmware again, and appears to auto-reboot.

This isn't what happens when doing a HW reset and that's what I'm really
after.

Is it possible? Am I doing something else wrong? Really at a loss to
understand if (a) I have unreasonable expectations of what software reset
can/should do. (b) I'm missing some info (c) ???


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#532 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB4VBXQbjGZ6ec4DLbgNVDgtj1MYK1qmks5qZFXXgaJpZM4JOM9B
.

@jasonm23
Copy link
Contributor Author

@TerryMathews
Copy link
Contributor

The Teensy code in Phantom uses 4096 for bootloader size, and I can vouch
that it works correctly on a genuine Teensy 2.0. Try that.

On Jul 25, 2016 10:58 AM, "JasonM23" [email protected] wrote:

https://github.com/jasonm23/qmk_firmware/tree/ocodo-handwired/keyboards/handwired/tenkeyless

It's a Teensy.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#532 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB4VBXSdj3dX1vbPhRsVkWVqjv0ScDCyks5qZM8lgaJpZM4JOM9B
.

@jackhumbert
Copy link
Member

@TerryMathews really? The bootloader size for the Teensy 2.0 should be 512 :) Maybe it'd work if the bytes before that are all zeros? I'm not entirely sure how the MCU would handle that.

@TerryMathews
Copy link
Contributor

Phantom drops reliably into Bootloader using 4096. I have to take my
keyboard apart to hit the switch, so making sure RESET worked was a top
priority for me.

I built the Phantom code from Satan, so the bootloader jump carried over as
well and since it worked I didn't alter it. Maybe it's a bit/byte issue
since 4096/8=512?

I can't explain why it works, but it works on both Teensy 2.0s I have.

On Jul 25, 2016 11:16 AM, "Jack Humbert" [email protected] wrote:

@TerryMathews https://github.com/TerryMathews really? The bootloader
size for the Teensy 2.0 should be 512 :) Maybe it'd work if the bytes
before that are all zeros? I'm not entirely sure how the MCU would handle
that.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#532 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB4VBRw9Nfr3FRtsPJxnhsNw3-cKQMHNks5qZNM7gaJpZM4JOM9B
.

@jasonm23
Copy link
Contributor Author

jasonm23 commented Jul 26, 2016

@TerryMathews @jackhumbert the Teensy is indeed a 512kb memory (I assume that includes the actual bootloader itself.)

Regardless: (reflashing via hardware reset - SW reset not working.)

Teensy Loader, Command Line, Version 2.0
Read "handwired_tenkeyless_default.hex": 23094 bytes, 71.6% usage
Waiting for Teensy device...
 (hint: press the reset button)
Found HalfKay Bootloader
Read "handwired_tenkeyless_default.hex": 23094 bytes, 71.6% usage
Programming.....................................................................................................................................................................................
Booting

Even though my firmware is only ~23Kb it's reported as 71%.

If I compile the Phantom firmware (let's do that now...)

And load it onto the teensy...

teensy_loader_cli -mmcu=atmega32u4 -w -v phantom_default.hex 
Teensy Loader, Command Line, Version 2.0
Read "phantom_default.hex": 24118 bytes, 74.8% usage
Waiting for Teensy device...
 (hint: press the reset button)
Found HalfKay Bootloader
Read "phantom_default.hex": 24118 bytes, 74.8% usage
Programming.............................................................................................................................................................................................
Booting

it's also close to 24kb so maybe that clears up the numbers.

@jasonm23
Copy link
Contributor Author

jasonm23 commented Jul 26, 2016

After recompiling my handwired tenkeyless firmware both the RESET and the SHIFT-SHIFT-PAUSE default bootloader trigger are working as expected. Although that's not the first time.

The difference is that I'm at another location and using a different Mac (from the machine I was using when I opened the issue). I'll experiment and see if I can make it fail again. (without changing machines)

Edit: For reference: failing machine is an iMac (2015) and the machine I'm using now is a MBPRetina 13" early 2015. Note: as above, the SW reset wasn't working until reflashing on the MBPRetina.


I'm also going to change the vendor id / product id so that the mac sees it as a new board, just to see if the USB host has any issues. (A wild stab in the dark TBH, but not much else to do right now.)


Done, no effect, SW reset is working. I'll hook it back up to the iMac tomorrow and see if I can get the fault to repeat. Worst case, at least I'll have narrowed down to the iMac. (BTW there are multiple iMacs at the other site and I've had this experience with at least 2 of them.)

@jasonm23
Copy link
Contributor Author

jasonm23 commented Jul 26, 2016

BTW @TerryMathews I'm not sure why your Makefile / bootloader size is working at 4096, mine's unchanged as 512 for the teensy.

No idea why yours is working, because it shouldn't!

@jasonm23
Copy link
Contributor Author

Tested with both sizes. Makes zero difference. SW reset continues to work. (still on the MBPRet)

@jasonm23
Copy link
Contributor Author

Ah well, it's not a specific Mac. I un-plugged the board and reconnected it and SW RESET no longer works.

I'm going to try connecting to another host machine now and see how it goes.

@jasonm23
Copy link
Contributor Author

Connected to a much older Macbookpro early 2011. SW Reset not working.

Can remedy only with HW reset. Annoying. :(

@TerryMathews
Copy link
Contributor

I know why the bootloader size works - learned a ton about ATmega32u4 last night trying to fix a clone Pro Micro.

The bootloader address jump isn't controlled by the software the controller is running, it's controlled by software fuses. Setting the bootloader size bigger than needed shortchanges the availabile program size but ensures maximum comparability.

To your issue, I wonder if your Mac devices that aren't handling soft reset correctly are dropping power to the USB port when the device resets. Do you have a powered USB hub you can use in between the device and the Mac to test?

@jasonm23
Copy link
Contributor Author

Hi @TerryMathews after flashing, up until disconnection, the SW reset feature works. As soon as I disconnect USB or power down the host, SW reset no longer works and a HW reset is required.

No changes on the hardware end affect this. (all Macs; powered/unpowered USB hubs etc.)

@TerryMathews
Copy link
Contributor

TerryMathews commented Jul 28, 2016

I cannot explain that. That has not been my experience on three Teensy 2.0 based keyboards - 2 Phantoms and a Neutrino.

Do you have a powered USB hub you can try in the middle? I think at this point we've narrowed it down to either the Teensy itself or the behavior of the Macs you have it connected to.

@jasonm23
Copy link
Contributor Author

@TerryMathews I have found the answer to this issue, and it turns out to be
a hardware problem.

The Teensy 2.0s that I have been using are apparently clone devices
and not original PJRC Teensies. I just fitted out a new Phantom TKL
with an official Teensy sourced from mechanicalkeyboards.com.

Notable differences are gold contacts on the pads/through holes and an
orange LED (vs a green LED on the clones)

These were sold on eBay as Teensy 2.0 and come in a solid plastic
packaging, with foam mount and a USB cable included, priced at $10-$15
from a number of vendors, I've also seen them on AliExpress.

They seem to work exactly as a Teensy 2.0 except for this particular
feature.

Hopefully this information will prove useful to someone in the future.

@jasonm23
Copy link
Contributor Author

jasonm23 commented Aug 12, 2016

For reference https://www.pjrc.com/teensy/counterfeit.html

@TerryMathews
Copy link
Contributor

Glad to hear it. Since you've isolated the issue and determined that it's not related to QMK you should close this and the other issue you have open.

I'd be curious to know if there's something fundamentally flawed in the hardware on that clone or if it's just a bad implementation of the Teensy bootloader. Would you be willing to pass it on to me for shipping cost? I've got the hardware to flash a different bootloader on via ISP and see if it behaves any better.

@jasonm23
Copy link
Contributor Author

I have a few of them, so I'd be happy to send one to you. ping me via my username at Google's popular email system.

@jasonm23
Copy link
Contributor Author

jasonm23 commented Aug 17, 2016

BTW verified - Teensy genuine the bootloader size set to 2048 works.

512, 1024, 4096 do not work. All tested.

AMtel bootloader and the LUFA bootloader: 4096

@Yoobe
Copy link

Yoobe commented Oct 9, 2016

Hi @jasonm23 ,

I built my first neutrino this week end and I have the same issue for reset of the teensy.. I came here to understand that I dont have a copy of teensy 2.0 :(
Did you find a solution for the fake teensy reset?
I cannot find a genuine version of teensy 2.0 anymore. All sellers are out of stock.

@TerryMathews
Copy link
Contributor

You can make the clone Teensy work reliably if you reflash the bootloader.
I have one that should work I can send you, but you need an ISP programmer.

On Oct 9, 2016 2:35 PM, "Yoobe" [email protected] wrote:

Hi @jasonm23 https://github.com/jasonm23 ,

I built my first neutrino this week end and I have the same issue for
reset of the teensy.. I came here to understand that I dont have a copy of
teensy 2.0 :(
Did you find a solution for the fake teensy reset?
I cannot find a genuine version of teensy 2.0 anymore. All sellers are out
of stock.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#532 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB4VBYGx79J9_jchtIj2PKDVeqpiC1Pfks5qyTQLgaJpZM4JOM9B
.

@Yoobe
Copy link

Yoobe commented Oct 9, 2016

I have a JLINK and a ST-link.. don't think they are compatible with AVR boards :(
Any usb/ttl board is not useful? I have some FTDI boards...

@Yoobe
Copy link

Yoobe commented Oct 9, 2016

Maybe I could use an arduino board as ISP

I have a Arduino Nano V3.0 and based on this website (https://www.arduino.cc/en/Tutorial/ArduinoISP) I can try to flash the boatloader..

Yes I am interested by the bootloader you have

@jasonm23
Copy link
Contributor Author

jasonm23 commented Oct 9, 2016

Yoobe the amtel bootloader is fine, you can get it from their site.

http://www.atmel.com/devices/atmega32u4.aspx?tab=documents

Sent from my iPhone

@TerryMathews
Copy link
Contributor

Yoobe, what's your e-mail? I can send you what I sent to JasonM23 that he
was able to successfully flash and use his cloned Teensy normally. I should
point out that you won't be using the Teensy tools anymore, this is an
Atmel bootloader and as such you'd be using DFU to flash going forward.

On Sun, Oct 9, 2016 at 3:03 PM, Yoobe [email protected] wrote:

Maybe I could use an arduino board as ISP

I have a Arduino Nano V3.0 and based on this website (
https://www.arduino.cc/en/Tutorial/ArduinoISP) I can try to flash the
boatloader..

Yes I am interested by the bootloader you have


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#532 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB4VBT-vK-pa2mLFMbr_u0fQM7Fi9rM1ks5qyTpkgaJpZM4JOM9B
.

@jasonm23
Copy link
Contributor Author

jasonm23 commented Oct 10, 2016 via email

@jasonm23
Copy link
Contributor Author

jasonm23 commented Oct 10, 2016 via email

@TerryMathews
Copy link
Contributor

It's not from Atmel, it's from http://www.stanleylio.com/home/usblufa

And yes it is modified, because as-is it wasn't reliably soft resetting
into Bootloader. I had to flip the logic on the default state based on the
way my Pro Micro clones were wired. It seemed to work for you as well.

Finally, no I didn't receive the clone you mailed me. I didn't think it was
worth mentioning.

On Oct 9, 2016 10:34 PM, "Jason Milkins" [email protected] wrote:

Terry did you modify it? Yoobe should just download it from amtel.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#532 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB4VBdlvGOqoEkqJ6bu_tnvOr9IMf1O-ks5qyaQqgaJpZM4JOM9B
.

@Yoobe
Copy link

Yoobe commented Oct 10, 2016

here is my email: [email protected]
Thanks for the bootloader.

Based on your work, do you know if there is a chance to change the firmware code to have the reset working as expected? Matter of address?

@stefanadelbert
Copy link

stefanadelbert commented Apr 19, 2017

I am having this same problem with a "Teensy 2.0" bought from AliExpress. If I perform a hardware reset then I am able to perform software resets until I unplug. On replugging, software resets no longer jump successfully to the bootloader - it seems that the firmware does get restarted though even though it doesn't jump to the bootloader. Using the magic bootloader command on powerup (space + b) also didn't jump to the bootloader. I was getting similar behaviour with TMK. I have tried a few different values for BOOTLOADER_SIZE (4096, 1024, 512).

@jasonm23
Copy link
Contributor Author

jasonm23 commented May 2, 2017

@TerryMathews Sorry for the late reply. It was sent tracked and according to the carrier it was delivered / received. I wonder what happened to it !?

@jasonm23
Copy link
Contributor Author

jasonm23 commented May 2, 2017

@stefanadelbert as you'll read above these Teensy's from AliExpress are not the real deal, so you need to reprogram them with a USB-ISP programmer.

They look something like this.

Just google for 'usb isp programmer' and you will get a bunch of options to buy one. They are cheap, often less than $10.

You can then re-flash the bootloader as per Terry's instructions and my notes above.

@stefanadelbert
Copy link

stefanadelbert commented May 2, 2017

@TerryMathews Thanks for the reply - I really appreciate it. I ended up drilling a hole in the bottom of my keyboard so that I could access the reset pushbutton on the "Teensy". It's a shame, but it works. Next time around I will get myself the real thing instead of the knockoff.

@jasonm23
Copy link
Contributor Author

jasonm23 commented Aug 19, 2017

NOTE: using a BOOTSIZE of 4096 with these teensy clones allows soft reset using LShift + RShift + Pause

jiaxin96 pushed a commit to Oh-My-Mechanical-Keyboard/qmk_firmware that referenced this issue Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants