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

Please include hex flashing instructions for MAC #15

Open
southwood opened this issue Jun 8, 2020 · 1 comment
Open

Please include hex flashing instructions for MAC #15

southwood opened this issue Jun 8, 2020 · 1 comment

Comments

@southwood
Copy link

southwood commented Jun 8, 2020

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
@dolbyzerr
Copy link

Thank you very much for the script!

I've used a slightly different version though:
I've installed AVRDUDE through brew

brew install avrdude
#!/bin/bash

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
        avrdude \
            -v \
            -p atmega2560 \
            -c wiring \
            -P ${DEVICE_ID} \
            -b 115200 \
            -D \
            -U flash:w:${PROGRAM}:i
        break
    fi
done

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

2 participants