tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
15.26k stars 901 forks source link

Arduino flash issues #1580

Closed pierreis closed 5 months ago

pierreis commented 3 years ago

On a Mac, I continuously get issues when flashing an Arduino Uno board via tinygo, with the usual error:

playground » tinygo flash -target arduino -port=$UNO_DEV_PATH -scheduler=coroutines ./main.go                                                                            ~/L/P/a/playground

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "/var/folders/rc/3gb9kzw52_l1bdyfb9pr9lh00000gn/T/tinygo969940853/main.hex"
avrdude: writing flash (6224 bytes):

Writing | ######                                             | 12% 0.12savrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
Writing | #######                                            | 14% 11.20savrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
[continued forever]

Note that the flashing sometimes works fine (but mostly doesn't).

I do not have any issues whatsoever flashing the board using the Arduino IDE ; only with tinygo from the command line.

pierreis commented 3 years ago

Thanks to some help on discord, I have tested using arduino-cli for flashing, which consistently works just fine:

tinygo build -scheduler=tasks -target=arduino -o /tmp/test.hex ./main.go && arduino-cli upload -b arduino:avr:uno -p $UNO_DEV_PATH -i /tmp/test.hex .

tinygo flash remains flaky at best though.

deadprogram commented 3 years ago

Perhaps you have an older version of avr-dude installed? That is what the tinygo flash command currently uses "under the hood". Did you install avr-dude via homebrew?

pierreis commented 3 years ago

I did install via homebrew indeed. Installed version is 6.3, which seems to be the latest.

deadprogram commented 3 years ago

Which macOS version?

pierreis commented 3 years ago

11.1

deadprogram commented 3 years ago

I am still running Catalina on my dev machine. I wonder if that is related?

pierreis commented 3 years ago

I suppose that is a possibility. Anything I could provide to help debug this?

aykevl commented 11 months ago

Oops, sorry I never got to this issue! I suspect this can be solved using -target=arduino-nano-new.

peritonow commented 5 months ago

indeed it does running on Windows 10 - going by tutorial on https://tinygo.org/docs/tutorials/blinky/ and https://tinygo.org/getting-started/install/windows/ steps for scoop. Thank you.

I am using linux (raspi) day to day as a main platform. This is my first intro to tinygo. :-)

peritonow commented 5 months ago

this issue can be close ...