Skip to content

Please include hex flashing instructions for MAC #15

@southwood

Description

@southwood

Here is an example using AVRDUDE, based on the way Arduino IDE flashes after compilation.

Save the script to flash.sh, run chmod +x flash.sh, then call it like ./flash.sh firmware.hex. If avr is not installed, first install it with brew tap osx-cross/avr and brew install avr-gcc. Make sure to close uArmStudio and ArduinoIDE as they might interfere with the connection while flashing is in progress.

#!/bin/bash

# default location from `brew tap osx-cross/avr` and `brew install avr-gcc`
export AVR_PATH=/Applications/Arduino.app/Contents/Java/hardware/tools/avr/
export PROGRAM="$1"

# search for connected device
for i in $(seq 1 10); do
    export DEVICE_ID=$(ls /dev/tty.usb* 2>&1 | grep -v "No such")
    if [ -z "$DEVICE_ID" ]; then
        echo -ne "[$i of 10] Looking for device, connect USB and double tap the button to put it in flash mode \033[0K\r"
        sleep 1.5
    else
        echo "Found device, flashing ${PROGRAM} to ${DEVICE_ID}"
        # flash the hex program to the device
        $AVR_PATH/bin/avrdude \
            -C$AVR_PATH/etc/avrdude.conf \
            -v \
            -patmega2560 \
            -cwiring \
            -P${DEVICE_ID} \
            -b115200 \
            -D \
            -Uflash:w:${PROGRAM}:i
        break
    fi
done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions