Open zeechs opened 2 years ago
This board needs to be switched to bootloader mode by hitting the reset button twice before attempting to upload. In my case, there is no reset button(DFRobot Beetle). It can be done by opening the serial port at 1200 bauds and then closing it. The board is then ready for upload.
Edit: I'm leaving this ticket open and let you decide if this project needs to be updated to address the issue.
I needed to reset the Leonardo in an automated way, because I'm flashing and testing various Arduinos from a CI pipeline in the cloud.
As @zeechs says, you need to open the serial port (probably /dev/ttyACM0
) with a baud of 1200, and then close it. The LEDs will flash the same pattern as the reset button while the firmware is flashable. After resetting via the button or open/closing the serial port, the Leonardo is flashable for about 8 seconds.
Here's my GitHub Actions yaml for my flashing and testing:
jobs:
build:
steps:
- name: Upload Ardino hex to /dev/ttyACM0
run: |
./scripts/reset_leonardo.py /dev/ttyACM0
sleep 2
cmake --build ./build --target upload -- TARGET=leonardo_node SERIAL_PORT=/dev/ttyACM0
sleep 2
- name: Test Ardino
run: |
./firmware_test.py
And here's the contents of reset_leonardo.py
:
#!/usr/bin/env python3
################################################################################
#
# Copyright (C) 2021 Garrett Brown
# SPDX-License-Identifier: Apache-2.0
#
################################################################################
import serial
import sys
# Environment parameters
SERIAL_PORT = sys.argv[1]
# Open the Leonardo tty at 1200 baud and then close to reset into programming
# mode
print(f"Opening {SERIAL_PORT} at 1200 baud")
ser = serial.Serial(SERIAL_PORT, 1200)
print(f"Closing {SERIAL_PORT}")
ser.close()
print("Arduino Leonardo is now in reset mode for 8 seconds")
Hello,
First, thank you for sharing your work, it is very useful and appreciated. I used it successfully with an Arduino Uno board.
I am having trouble finding the cause of the upload failure using a Leonardo board. I am following these simple steps to configure, build and upload your hello_world example:
cmake .. -D CMAKE_TOOLCHAIN_FILE=path/to/Arduino-toolchain.cmake
BoardOptions.cmake
and uncomment the following line:cmake .
make
avrdude: Version 6.3-20190619 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch
Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding avrdude: butterfly_recv(): programmer is not responding avrdude: butterfly_recv(): programmer is not responding avrdude: butterfly_recv(): programmer is not responding avrdude: butterfly_recv(): programmer is not responding Found programmer: Id = "�"; type = Software Version = .; Hardware Version = . avrdude: butterfly_recv(): programmer is not responding avrdude: butterfly_recv(): programmer is not responding avrdude: error: buffered memory access not supported. Maybe it isn't a butterfly/AVR109 but a AVR910 device? avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check.
avrdude: butterfly_recv(): programmer is not responding avrdude: error: programmer did not respond to command: leave prog mode avrdude: butterfly_recv(): programmer is not responding avrdude: error: programmer did not respond to command: exit bootloader