Git Product home page Git Product logo

Comments (2)

zeechs avatar zeechs commented on June 14, 2024

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.

from arduino-cmake-toolchain.

eigendude avatar eigendude commented on June 14, 2024

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")

from arduino-cmake-toolchain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.