First time use - PeterWone/vscode-arduino-cli GitHub Wiki
Preparation
Automatic installation of arduino-cli is not yet implemented. In the interim you need to do this manually.
You must also provide the path to
arduino-cli.exe
in extension settings (see manual installation instructions).
When you open an arduino project that you have not previously opened with this extension, VS Code will look like the following illustration. Look at the right hand end of the status bar.
M:undefined
means you have yet to set a serial monitor port.Choose a board
means what it says.
Click on Choose a board
to make QuickPick list appear:
Type the name of your board. VS Code will do fancy progressive matching until you find and click your board.
I have a Nano:
Notice that the vanilla Nano says it uses arduino:avr
whereas other flavours say they will install other cores. This is because I have already installed the arduino:avr
core. If you select a board that requires a core that isn't installed the extension will install it.
Now that the extension knows what board you have it will prompt you to pick a serial port. Currently this fails to populate the list. Click on M:undefined
and it will retry successfully. If you click on D:NOT SET
you will get a list of deployment methods which includes all the hardware programmers supported by your board and all the detected USB serial ports.
When you open the INO file, Compile
and Deploy
commands should appear at top right, like this:
The Flash command will not appear until you specify a hardware programmer because you can't flash the bootloader without one. Notice that I have already selected the USBasp
programmer in this snap.
Now check that everything works
Compile
With the extension installed and an INO file open, click Compile
. When the dust settles, you should see something similar to this.
In the OUTPUT pane compilation results are displayed. In settings you can request verbose compiler output.
Deploy
Deploy compiles before it deploys. You don't need to compile first.
With the extension installed and an INO file open, click Deploy
.
As with Compile
, results are displayed in the OUTPUT pane.
Deploy results are always verbose because in addition to providing better feedback in a potentially slow operation, the extension is supposed to detect failure/retry and abort instead of silently retrying ten times. (This was working but is currently broken.)
Success using programmer
Here is a sample successful deployment using a USBasp
programmer.
Sketch uses 9452 bytes (30%) of program storage space. Maximum is 30720 bytes.
Global variables use 884 bytes (43%) of dynamic memory, leaving 1164 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -cusbasp -Pusb "-Uflash:w:d:\Arduino\ArduinoPumpController\build\arduino.avr.nano/ArduinoPumpController.ino.hex:i"
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : usb
Using Programmer : usbasp
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : usbasp
Description : USBasp, http://www.fischl.de/usbasp/
avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
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: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "d:\Arduino\ArduinoPumpController\build\arduino.avr.nano/ArduinoPumpController.ino.hex"
avrdude: writing flash (9452 bytes):
Writing | ################################################## | 100% 6.16s
avrdude: 9452 bytes of flash written
avrdude done. Thank you.
Failure using programmer
A failure looks similar when your programmer is connected to the computer but not to the board, but it ends like this.
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
Error during Upload: programming error: uploading error: exit status 1
Failure using serial
Generally when you see this sort of output it means you have an older version of the bootloader running a different baudrate. You may have noticed from the sample output that arduino-cli
is in turn using avrdude
and astute users will no doubt want to know why there's no setting for baudrate. The answer (according to issues for arduino-cli) is that arduino-cli knows the correct baudrate based on the FQBN (fully qualified board name) you specified. When you choose a board in the extension you are effectively picking an FQBN from a list of boards. There is sometimes a nearly identical board name along the lines of Nano (old)
, and you should choose this to get the baudrate for the old firmware.
If you have a programmer you can at this point simply flash the bootloader and the firmware you specified would be installed. But if you had a programmer you could just program it using that.
So... if you have a programmer you can fix a problem that isn't a problem because you have a programmer. Handy! But seriously, get a programmer. They're $5 from eBay.
Sketch uses 9452 bytes (30%) of program storage space. Maximum is 30720 bytes.
Global variables use 884 bytes (43%) of dynamic memory, leaving 1164 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM9" -b115200 -D "-Uflash:w:d:\Arduino\ArduinoPumpController\build\arduino.avr.nano/ArduinoPumpController.ino.hex:i"
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM9
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x0d
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x0a
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x44
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x45
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x46
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x45
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x52
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x52
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x45
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x44
avrdude done. Thank you.
Error during Upload: uploading error: uploading error: exit status 1