-
Notifications
You must be signed in to change notification settings - Fork 48
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 3.2 cannot be programmed after first time, unless press reset button #41
Comments
@PaulStoffregen Could you explain upload scenario? Should we make "teensy_reboot" before uploading? Currently, Teensy CLI asks to press "Reset button...". |
@ivankravets It should reboot before program, because programming only can be done in bootloader mode. arduino ide reboot before program, it can success everytime. |
In Arduino, we run teensy_post_compile first, which sends a message to the (GUI-based) Teensy Loader to open the latest compiled file, and configure in auto mode. Then teensy_reboot is run, to send a request to the Teensy to reboot into bootloader mode. Because Teensy Loader is in auto mode, when the Teensy appears, it gets programmed by Teensy Loader. If you're using the CLI instead of GUI, you probably want to run teensy_reboot first. |
@PaulStoffregen thanks for the information, current official script using GUI loader, but not reboot |
REBOTTER=join(
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_reboot"),
UPLOADER=join(
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_post_compile"),
UPLOADERFLAGS=[
"-file=firmware",
'-path="$BUILD_DIR"',
'-tools="%s"' % join("$PIOPACKAGES_DIR", "tool-teensy")
],
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS & "$REBOTTER"' This is the final code, works perfectly. |
@424778940z by default PlatformIO uses Teensy Loader CLI. If you want to use Teensy Loader GUI, please place all files to
Arduino IDE
PlatformIO
|
em...that's strange. I install platformio IDE with touch any settings. it use GUI version by default ... |
@424778940z Do you see |
yes, it is there |
@424778940z Sorry, I've just remembered it... Teensy Loader CLI doesn't work on Windows 😞 See http://www.pjrc.com/teensy/loader_cli.html You can ask @PaulStoffregen to add support in this repo https://github.com/PaulStoffregen/teensy_loader_cli |
@PaulStoffregen we call |
@ivankravets PaulStoffregen is already answered above. This issue is already solved by modify platformio script. However, my way is a little bit lazy, just use & run them at one line. |
@424778940z I don't understand how does it work for you. Rebooter requires GUI to be run. In your case, you call Rebooter before Teensy GUI. Ok, I'll implement it. |
@ivankravets Problem is about second time upload, because GUI is already running, according to PaulStoffregen, it supposed to call teensy_post_compile fist tell GUI new file is ready, then call teensy_reboot reboot the hardware to bootloader mode allows GUI upload again. In current platformio official code, it only call teensy_post_compile, but no reboot. Therefore GUI knows there is a new file ready, but the hardware is not in bootloader mode, GUI cannot upload, if people press reset button on the board at this time, it will uoload. |
Here is the whole modified script # Copyright 2014-2016 Ivan Kravets <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Builder for Teensy boards
"""
from os.path import isfile, join
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
DefaultEnvironment, SConscript)
env = DefaultEnvironment()
if env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy":
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "baseavr.py")))
elif env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy3":
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
env.Append(
LINKFLAGS=[
"-Wl,--defsym=__rtc_localtime=$UNIX_TIME",
"-fsingle-precision-constant",
"--specs=nano.specs"
],
CCFLAGS=[
"-fsingle-precision-constant"
]
)
env.Append(
CPPDEFINES=[
"USB_SERIAL",
"LAYOUT_US_ENGLISH"
],
CXXFLAGS=[
"-std=gnu++0x",
"-felide-constructors"
]
)
if isfile(env.subst(join(
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"))):
env.Append(
UPLOADER=join(
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"),
UPLOADERFLAGS=[
"-mmcu=$BOARD_MCU",
"-w", # wait for device to apear
"-s", # soft reboot if device not online
"-v" # verbose output
],
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
)
else:
env.Append(
#BZH_FIXED
# UPLOADER=join(
# "$PIOPACKAGES_DIR", "tool-teensy", "teensy_post_compile"),
# UPLOADERFLAGS=[
# "-file=firmware",
# '-path="$BUILD_DIR"',
# '-tools="%s"' % join("$PIOPACKAGES_DIR", "tool-teensy")
# ],
# UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS'
REBOTTER=join(
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_reboot"),
UPLOADER=join(
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_post_compile"),
UPLOADERFLAGS=[
"-file=firmware",
'-path="$BUILD_DIR"',
'-tools="%s"' % join("$PIOPACKAGES_DIR", "tool-teensy")
],
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS & "$REBOTTER"'
)
#
# Target: Build executable and linkable firmware
#
target_elf = env.BuildProgram()
#
# Target: Build the firmware file
#
if "uploadlazy" in COMMAND_LINE_TARGETS:
target_firm = join("$BUILD_DIR", "firmware.hex")
else:
target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
#
# Target: Print binary size
#
target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD")
AlwaysBuild(target_size)
#
# Target: Upload by default firmware file
#
upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADHEXCMD")
AlwaysBuild(upload)
#
# Target: Define targets
#
Default([target_firm, target_size]) |
@424778940z Please re-test 2.9.0.dev0 http://docs.platformio.org/en/latest/installation.html#development-version |
@ivankravets Tested, it works perfectly. |
@424778940z thank you for the report and for the issue. 2.9.0 will be released next week. |
Looks like things were moved around, and this fix was undone. Where does teensy.py / teensy.py's functionality live now? |
@ivankravets |
Auto-reboot requires software to work correctly on both sides of the USB cable. Every Teensy has a button dedicated for entering bootloader mode, because plenty can go wrong on either side. To get an idea which side might be the problem, maybe try programming your Teensy using PlatformIO, so it has no code running that came from Arduino. Then quit PlatformIO and run Arduino again. Does auto-reboot work from Arduino on the first try, while the Teensy still has code that was created by PlatformIO? If that works, it's a good sign PlatformIO is putting good code onto the Teensy which properly listens for the auto-reboot request from your PC. Likewise, after Arduino has programmed the Teensy with known-good code, try running PlatformIO. This can serve as a double confirmation whether the problem is on the PC side not sending the auto-reboot request properly, or on the Teensy side not hearing it and entering bootloader mode. |
@PaulStoffregen which minimum version of Teensy Loader is required for Teensy 3.5? I see that the latest package in our repository is 1.41. |
@zmrubin the source code is here https://github.com/platformio/platform-teensy/blob/develop/builder/main.py#L197:L227 |
On that first try, perhaps Teensy is still running a program that was written by Arduino? When you switch to Arduino, is a button press needed for the first upload? Then does Arduino upload automatically? On that first Arduino upload the Teensy would still running be running code that was created by PlatformIO. If you can confirm both of these cases, that would suggest PlatformIO is indeed sending the reboot request properly, but creating images on the Teensy which do not respond to the request. |
OK.. i just uploaded a program to the board using PlatformIO (had to use the flash button). Right after this I opened Arduino and without even closing PlatformIO the Arduino IDE will auto-reboot and flash the Teensy with no issue, no button press necessary. |
Ok then, there goes that theory. Looks like PlatformIO is creating the correct code. Any chance this is Windows 7? (or XP or 8... anything before 10 there Microsoft finally fixed the surprise removal bugs) |
If it's one of those older buggy versions of Windows, maybe whether PlatformIO still have a handle to the COM port open could be playing a factor? |
Actually Mac Mojave, is that a problem? Should I try it on my windows 10 machine and see if I can replicate the failure? |
So far, the only problem I know on Mojave is a regression on ability to handle sustained maximum full speed incoming USB data. Still unknown whether it's a Java issue or something MacOS. To be realistic, it's on my to-do list for a few months from now. Currently working on an urgent profit (the kind that actually funds my time to do open source the rest of the year) so can't do a lot right now. But yeah, try Windows 10. Avoid earlier pre-10 versions of Windows. They all have USB bugs. Also, does PlatformIO support using the HID emulated serial? (like when you select MIDI or RawHID in Arduino Tools > USB Type) |
@PaulStoffregen could you take a look at what we actually do? See https://github.com/platformio/platform-teensy/blob/develop/builder/main.py#L214:L227
I see that in a case with CLI upload mode, we use |
Alright, I tested it on windows 10 and the same problems occur. I cant flash with platformio unless i press the flash button AND have the teensy flasher program up in front of the platformio window. When i open Arduino IDE and attempt to flash it works every time. |
I can confirm that is the correct approach. Sorry, can't do anything more at this moment. Big hardware project, already far behind schedule.... However, one thing that might help is comparing the exact commands. In Arduino, click File > Preferences and turn on verbose output while uploading. That should at least make the commands Arduino is using visible. |
just got email from this issue after 2 years lol. I think the problem still same as before, the teensy is not being rebooted, you could try write a simple bliking led code in pio, then load it to teensy. then keep try load it again, see if the led still blinking at the same time, if it does it means teensy it not being rebooted. then we could try copy the teense tools from arduino to pio folder see if their version works. |
Hey, I was hoping you'd chime in. I will give it a try and post my findings. |
@PaulStoffregen actually, you were right. I see that you use just 1 @scott620 @424778940z @zmrubin please re-test with the latest upstream version https://docs.platformio.org/en/latest/platforms/teensy.html#upstream Also, please don't forget to update all packages via |
Please update to the final 3.7.0 release https://community.platformio.org/t/teensy-dev-platform-v3-7-0/5975 |
Works perfectly now! |
sadly I don't have a treensy anymore, my teensy was losted with a drone project.... I cannot test it this time |
I'm using latest stable version platformio ide
This issue may caused by I set it to usb uart mode, and download script doesn't reboot it before program.
i did following change in this file: .atom\packages\platformio-ide\penv\Lib\site-packages\platformio\builder\scripts\teensy.py
start at: Line 68
before:
after:
it solve this issue for now but will have a error because delay between restart and program is not enough
error msg: "Teensy Loader is currently busy with another operation (p). Please try again in a few seconds, or restart Teensy Loader."
The text was updated successfully, but these errors were encountered: