Visual studio code настройка для arduino
В этой статье приведены пошаговые инструкции по установке и настройке расширения PlatformIO в Visual Studio Code для дальнейшего программирования Arduino, ESP32, ESP8266, Maixduino, Raspberry Pi и не только.
Visual Studio Code
Visual Studio Code — редактор исходного кода (IDE, Integrated Development Environment), основан на Electron, разработанный Microsoft для Windows, Linux и macOS. Позиционируется как «лёгкий» редактор кода для кроссплатформенной разработки веб- и облачных приложений. Включает в себя отладчик, инструменты для работы с Git, подсветку синтаксиса, IntelliSense и средства для рефакторинга. Имеет широкие возможности для кастомизации: пользовательские темы, сочетания клавиш и файлы конфигурации. Распространяется бесплатно, разрабатывается как программное обеспечение с открытым исходным кодом.
VS Code также имеет множество доступных расширений, которые улучшают его функциональные возможности. Одним из таких расширений является PlatformIO.
Установка Visual Studio Code
Загрузить VS Code можно бесплатно с официального сайта, Здесь вы можете выбрать, на какую операционную систему вы хотите установить VS Code.
Как только IDE будет загружена, дважды щелкните на exe-файл для установки. При нажатии на исполняемый файл должно отобразиться следующее лицензионное соглашение:
Выберите I accept the agreement и нажмите Next.
Здесь можно сохранить значения по умолчанию. Нажмите Next.
Если установка прошла успешно, вы должны увидеть диалоговое окно — см. выше.
При первом запуске вы увидите такое окно (см. ниже):
PlatformIO
PlatformIO — это open-source экосистема для разработки. Поддерживает множество платформ, с подробным списком которых вы можете ознакомиться на официальном сайте (во вкладке Boards (см. ниже) вы сможете найти список всех поддерживаемых устройств), в нем присутствуют все основные популярные микроконтроллеры: Arduino, PIC32, AVR, ESP32, ESP8266, Maixduino, Raspberry Pi и т.п..
PlatformIO может использоваться с VS Code для предоставления мощного набора инструментов, которые помогут вам в разработке на Ардуино. Из этого материала вы узнаете как установить расширение PlatformIO для дальнейшей разработки под платы Arduino.
Установка PlatformIO в VS Code
Чтобы установить расширение PlatformIO, нужно Открыть средство просмотра расширений, нажав Ctrl+Shift+X и набрать PlatformIO в строке поиска, выбрать первый найденный результат и установить, нажав кнопку Install, как показано на рисунке ниже.
Установка PlatformIO может занять немного времени. Во время установки PlatformIO может запросить установку Python (появится уведомление в нижнем правом углу, см. ниже).
Нажмите Install Python, чтобы начать установку Python.
Нажмите Open, чтобы открыть ссылку с инструкциями по установке Python. Пожалуйста, выберите Add Python to Path (см. ниже), в противном случае команда python будет недоступна.
Вернитесь в окно Visual Studio Code и нажмите кнопку Try again (см. ниже).
После завершения установки появится уведомление в нижнем правом углу (см. ниже), что нужно перезагрузить IDE для завершения процесса.
После перезагрузки значок PlatformIO (см. ниже) должен появиться в левом поле Visual Studio Code.
Установка Arduino Framework
Следующим шагом является загрузка платформы Atmel AVR (Arduino), Espressif 32 (ESP32) и т.п. в Visual Studio Code. Нажмите на значок PlatformIO в левом поле, чтобы открыть меню Quick Access (или нажмите на домик в самом низу). Выберите Platforms, а затем Embedded, как показано на рисунке ниже.
При нажатии на Atmel AVR откроется страница установки (см. ниже), нажмите кнопку Install для продолжения.
Установка библиотек
Создание и загрузка примера Blink
PlatformIO может автоматически определять, на каком порту установлен ваш Arduino Uno. Чтобы всё работало, нам необходимо подключить нашу плату к USB-порту до запуска Visual Studio Code.
Вы можете получить доступ к стандартному набору примеров Arduino, выбрав PIO Home в меню быстрого доступа платформы (см. ниже), а затем выбрав Project Examples.
После чего открывается выпадающий список, в котором перечислены все примеры. Выберите arduino-blink и нажмите Import.
Visual Studio Code теперь должен открыть проект blink. Структура папок отличается от структуры стандартного проекта Arduino, где расширение файлов .ino. Основной файл исходного кода называется blink.cpp и хранится в папке src (см. ниже).
Выбрав Devices в меню быстрого доступа платформы (см. ниже), вы сможете найти список COM-портов.
В конце нужно будет редактировать файл platformio.ini. Выберите этот файл в проводнике и замените его содержимое следующим:
Если у вас подключено несколько плат Arduino, вам нужно явно указать COM-порт платы, для загрузки.
Сборка и загрузка
Существуют удобные ярлыки для создания и загрузки скетча, доступные на нижней синей панели Visual Studio Code. Просто наведите курсор мыши на значок, чтобы увидеть его функциональность (см. ниже).
Чтобы собрать (скомпилировать) проект, нажмите значок галочки, а чтобы загрузить его на свою плату — значок стрелки. Результаты отображаются в терминале. На панели задач также есть ярлык для последовательного монитора.
Visual Studio Code extension for Arduino
Welcome to the Visual Studio Code extension for Arduino preview ! The Arduino extension makes it easy to develop, build, deploy and debug your Arduino sketches in Visual Studio Code, with a rich set of functionalities. These include:
- IntelliSense and syntax highlighting for Arduino sketches
- Verify and upload your sketches in Visual Studio Code
- Built-in board and library manager
- Built-in example list
- Built-in serial monitor
- Snippets for sketches
- Automatic Arduino project scaffolding
- Command Palette ( F1 ) integration of frequently used commands (e.g. Verify, Upload. )
- Integrated Arduino Debugging New
Either the Arduino IDE or Arduino CLI are required.
The Arduino IDE can be installed the Arduino download page.
- The supported Arduino IDE versions are 1.6.x and later.
- The Windows Store's version of the Arduino IDE is not supported because of the sandbox environment that the application runs in.
- Note: Arduino IDE 1.8.7 had some breaking changes, causing board package and library installation failures. These failures were corrected in 1.8.8 and later.
The Arduino CLI can be downloaded from the repository's release page
- The extension has only been tested with v0.13.0.
- If you use the CLI you will have to set arduino.path since the CLI does not have a default path.
Open VS Code and press F1 or Ctrl + Shift + P or Cmd + Shift + P to open command palette, select Install Extension and type vscode-arduino .
Or launch VS Code Quick Open ( Ctrl + P or Cmd + P ), paste the following command, and press enter.
You can also install directly from the Marketplace within Visual Studio Code, searching for Arduino .
You can find code samples and tutorials each time that you connect a supported device. Alternatively you can visit our IoT Developer Blog Space or Get Started Tutorials.
This extension provides several commands in the Command Palette ( F1 or Ctrl + Shift + P or Cmd + Shift + P ) for working with *.ino files:
- Arduino: Board Manager: Manage packages for boards. You can add 3rd party Arduino board by configuring Additional Board Manager URLs in the board manager.
- Arduino: Change Baud Rate: Change the baud rate of the selected serial port.
- Arduino: Change Board Type: Change board type or platform.
- Arduino: Change Timestamp Format: Change format of timestamp printed before each line of Serial Monitor output.
- Arduino: Close Serial Monitor: Stop the serial monitor and release the serial port.
- Arduino: Examples: Show list of examples.
- Arduino: Initialize: Scaffold a VS Code project with an Arduino sketch.
- Arduino: Library Manager: Explore and manage libraries.
- Arduino: Open Serial Monitor: Open the serial monitor in the integrated output window.
- Arduino: Select Serial Port: Change the current serial port.
- Arduino: Send Text to Serial Port: Send a line of text via the current serial port.
- Arduino: Upload: Build sketch and upload to Arduino board.
- Arduino: CLI Upload: Upload complied code without building sketch (CLI only).
- Arduino: Upload Using Programmer: Upload using an external programmer.
- Arduino: CLI Upload Using Programmer: Upload using an external programmer without building sketch (CLI only).
- Arduino: Verify: Build sketch.
- Arduino: Rebuild IntelliSense Configuration: Forced/manual rebuild of the IntelliSense configuration. The extension analyzes Arduino's build output and sets the IntelliSense include paths, defines, compiler arguments accordingly.
- Arduino: Upload Alt + Cmd + U or Alt + Ctrl + U
- Arduino: Verify Alt + Cmd + R or Alt + Ctrl + R
- Arduino: Rebuild IntelliSense Configuration Alt + Cmd + I or Alt + Ctrl + I
The following Visual Studio Code settings are available for the Arduino extension. These can be set in global user preferences Ctrl + , or Cmd + , or workspace settings ( .vscode/settings.json ). The latter overrides the former.
Note: You only need to set arduino.path in Visual Studio Code settings, other options are not required.
The following settings are as per sketch settings of the Arduino extension. You can find them in .vscode/arduino.json under the workspace.
- sketch - The main sketch file name of Arduino.
- port - Name of the serial port connected to the device. Can be set by the Arduino: Select Serial Port command. For Mac users could be "/dev/cu.wchusbserial1420".
- board - Currently selected Arduino board alias. Can be set by the Arduino: Change Board Type command. Also, you can find the board list there.
- output - Arduino build output path. If not set, Arduino will create a new temporary output folder each time, which means it cannot reuse the intermediate result of the previous build leading to long verify/upload time, so it is recommended to set the field. Arduino requires that the output path should not be the workspace itself or in a subfolder of the workspace, otherwise, it may not work correctly. By default, this option is not set. It's worth noting that the contents of this file could be deleted during the build process, so pick (or create) a directory that will not store files you want to keep.
- debugger - The short name of the debugger that will be used when the board itself does not have a debugger and there is more than one debugger available. You can find the list of debuggers here. By default, this option is not set.
- prebuild - External command which will be invoked before any sketch build (verify, upload, . ). For details see the Pre- and Post-Build Commands section.
- postbuild - External command to be run after the sketch has been built successfully. See the afore mentioned section for more details.
- intelliSenseGen - Override the global setting for auto-generation of the IntelliSense configuration (i.e. .vscode/c_cpp_properties.json ). Three options are available:
- "global" : Use the global settings (default)
- "disable" : Disable the auto-generation even if globally enabled
- "enable" : Enable the auto-generation even if globally disabled
Pre- and Post-Build Commands
On Windows the commands run within a cmd -, on Linux and OSX within a bash -instance. Therefore your command can be anything what you can run within those shells. Instead of running a command you can invoke a script. This makes writing more complex pre-/post-build mechanisms much easier and opens up the possibility to run python or other scripting languages. The commands run within the workspace root directory and vscode-arduino sets the following environment variables: VSCA_BUILD_MODE The current build mode, one of Verifying , Uploading , Uploading (programmer) or Analyzing . This allows you to run your script on certain build modes only. VSCA_SKETCH The sketch file relative to your workspace root directory. VSCA_BOARD Your board and configuration, e.g. arduino:avr:nano:cpu=atmega328 . VSCA_WORKSPACE_DIR The absolute path of your workspace root directory. VSCA_LOG_LEVEL The current log level. This allows you to control the verbosity of your scripts. VSCA_SERIAL The serial port used for uploading. Not set if you haven't set one in your arduino.json . VSCA_BUILD_DIR The build directory. Not set if you haven't set one in your arduino.json .
For example under Windows the following arduino.json setup
vscode-arduino auto-configures IntelliSense by default. vscode-arduino analyzes Arduino's compiler output by running a separate build and generates the corresponding configuration file at .vscode/c_cpp_properties.json . vscode-arduino tries as hard as possible to keep things up to date, e.g. it runs the analysis when switching the board or the sketch.
It doesn't makes sense though to run the analysis repeatedly. Therefore if the workspace reports problems ("squiggles") - for instance after adding new includes from a new library - run the analysis manually:
Manual rebuild: Arduino: Rebuild IntelliSense Configuration, Keybindings: Alt + Cmd + I or Alt + Ctrl + I
When the analysis is invoked manually it ignores any global and project specific disable.
This system allows you to setup and use own IntelliSense configurations in parallel to the automatically generated configurations provided through vscode-arduino. Just add your configuration to c_cpp_properties.json and name it differently from the default configuration ( Arduino ), e.g. My awesome configuration and select it from the status bar or via the command palette command C/C++: Select a Configuration.
Debugging Arduino Code preview
Before you start to debug your Arduino code, please read this document to learn about the basic mechanisms of debugging in Visual Studio Code. Also see debugging for C++ in VSCode for further reference.
Make sure that your Arduino board can work with STLink, Jlink or EDBG. The debugging support is currently fully tested with the following boards:
Steps to start debugging:
- Plug in your board to your development machine properly. For those boards that do not have an on-board debugging chip, you need to use a STLink or JLink connector.
- Go to the Debug View ( Ctrl + Shift + D or Cmd + Shift + D ). and set breakpoints in your source files.
- Press F5 to select your debugging environment.
- When your breakpoint is hit, you can see variables and add expression(s) to watch on the Debug Side Bar.
To learn more about how to debug Arduino code, visit our team blog.
See the Change log for details about the changes in each version.
Supported Operating Systems
Currently this extension supports the following operating systems:
- Windows 7 and later (32-bit and 64-bit)
- macOS 10.10 and later
- Ubuntu 16.04
- The extension might work on other Linux distributions, as reported by other users, but without guarantee.
You can find the full list of issues on the Issue Tracker. You can submit a bug or feature suggestion, and participate in community driven discussions.
To run and develop, do the following:
To test, press F5 in VS Code with the "Launch Tests" debug configuration.
Code of Conduct
The Microsoft Enterprise and Developer Privacy Statement describes the privacy statement of this software.
This extension is licensed under the MIT License. Please see the Third Party Notice file for additional copyright notices and terms.
If you would like to help build the best Arduino experience with VS Code, you can reach us directly at gitter chat room.
Using Visual Studio Code as an Arduino IDE
The arduino IDE is great to get a project configured and started quickly, but its built-in code editor leaves a lot to be desired. Even though an external editor can be used instead, the experience could still be improved upon. With the release of Visual Studio Code for Linux, Windows and Mac OS, there's an opportunity to make coding for arduino enjoyable while preserving the ability to compile and upload sketches directly from the editor. Keep in mind that you'll still need to use the arduino environment at least once to manage a project's imported libraries, target boards settings, serial port settings, etc.
The following document describes how this can be accomplished in three easy steps.
1. Making the 'arduino' executable available
By default, the arduino environment on Linux is not visible outside of its installation directory and needs to be exposed as a command for Visual Studio Code to invoke it when compiling and uploading arduino sketches.
Skip this step if the arduino environment is already available from anywhere.
The following step creates a symbolic link to the arduino environment so that it can be accessed from anywhere. It is assumed that the arduino environment was installed in the user's /home directory, such as:
Switch to the /usr/local/bin folder and create a symbolic link named arduino pointing to the arduino installation folder.
Check that the symbolic link is correct by starting the arduino IDE from the command line. The arduino IDE should start normally. Just close it when done.
On Windows, just ensure that the arduino environment is part of the PATH.
2. Copy the ino folder to your local Visual Studio Code extension folder
The ino folder in this repository provides Visual Studio Code with the arduino keyword definitions needed for syntax highlighting. It also specifies that .ino files should be handled as C/C++ files.
The repository contains the following files & folders:
Copy the ino folder to the hidden .vscode/extensions folder that Visual Studio Code created at the root of your home folder the first time it was started.
3. Adding the Visual Studio Code Task Runners supporting arduino
From Visual Studio Code, do the following:
- Open the File menu and select Open Folder. .
- Navigate to the folder containing your arduino projects.
- Bring up the command palette with Ctrl+Shift+P.
- Type task in the command window.
- Select Configure Task Runner. This will create a hidden folder named .vscode at the root of the arduino projects folder selected in step 2.
- Replace .vscode/tasks.json with ~/VisualStudioCodeArduino/tasks.json.
- Restart Visual Studio Code
The configuration of Visual Studio Code is now complete and it is ready for use with arduino .ino project files.
- Open a .ino project file.
- Bring up the command palette with Ctrl+Shift+P
- Type task in the command window.
- Select Run Task
Select --verify to verify/compile the arduino project. Alternatively you can use Ctrl+Shift+B as a shortcut.
If problems occur when compiling the project, they will be visible in the lower-left corner of the editor
Clicking on the error or warning icon will bring up the list of problems
Clicking on a problem will highlight it within the .ino file.
Alternatively, bringing up the output with Ctrl+Shift+P + view: show ouput will show the complete, verbose, compilation results.
Select --upload or Shift+Ctrl+T to verify/compile & upload the arduino sketch to the target board. This will always bring up the output.
Finally, there's currently no good way to bring up the native arduino serial monitor externally. Instead, bring up a terminal window with Ctrl+Shift+C and use a different terminal emulator, such as minicom.
This procedure has been validated to work with the following configuration:
VSCode has an Arduino plugin available in preview. Use it. Put your Arduino desktop application in cold-storage. Comparing the two is like comparing a beaver with a 2 ton backhoe.
VSCode Advantages
- Lots of useful key-stroke sequences, fully programmable.
- Integrated with Git.
- Intellisense that works.
- Jump to definition and mouseover display in-line help.
- Hugely useful on-screen click objects.
- Full support for folder trees.
- Plugin support.
- Seriously have you used the Arduino IDE? Who needs a list?
VSCode Disadvantages
- For now you can’t type into the serial monitor window. That’s not cool. — Update: the latest version of the Arduino plugin now lets you send a string to the serial monitor. It’s clumsier than a modem program but very usable.
Prerequisites
- A working version of Arduino desktop that can build.
- Visual Studio Code with Microsoft’s Arduino Extension installed. Install it from the Extensions tab (below the debug button on the far left).
Process
Assume you have a working project you want to convert to VSCode. Just
- Run VSCode and open the project folder.
- (optional but recommended) Use the source control tab to initialize a new git repository and check in your existing code.
- From the command palette run: Arduino: Initialize
- Edit the project files (see below) for any workspace-specific project variables (such as includes).
Once the Arduino extension is enabled for your project there are some tricks to make life better.
Use a src folder to hold your code folders
Take a look at the picture at the start and make sure your source tree looks like:
Add an ‘output’ option to arduino.json
Depending on how the plugin works today, you may not get an output option defined in the arduino.json settings file. Add this line just above the closing brace:
Here I’ve defined the output folder as build. It will create a build folder in the project root where the caching of all the Arduino stuff takes place. That has two advantages:
- It will decrease build time substantially. Strangely if you don’t set output you don’t get caching.
- Since Arduino is kind of bad at figuring out caches you can just delete the entire build folder contents to force a clean build.
Warning: from what I can tell putting the build folder inside your project tree sometimes causes issues. This is documented in the Arduino source. A better solution is to build in a folder outside of the project.
Investigate the buttons at the bottom
In typical new-age dumb software fashion there are lots of useful buttons on the bottom of the display that aren’t obvious but that you should totally learn to use.
Mouse over them and you’ll see all sorts of easy ways to change stuff.
The meat of the matter. There are four project settings files related to visual studio code and to Arduino. They can be confusing and you can often change them in more than one place. I’m going to skip tasks.json but discuss the rest.
Start by running Arduino Initialize from the Command Palette (Ctrl-Shift-P)
This will create a .vscode folder if there isn’t one. It will also add the current Arduino settings to a file named arduino.json placed into the .vscode folder.
The following discussion refers to files found in the .vscode folder in your project. Add them there if they don’t exist.
arduino.json
This contains Arduino-specific settings. Most are set when you make changes with buttons and the Command Palette. Only the “output” folder did I notice as needing manual maintenance.
Add to your arduino.json (see above):
c_cpp_properties.json
This file determines what gets linked and how intellisense finds files. Builds will still work but your mouseover helps and go-to-definitions and etc will be wrong if this is wrong.
My c_cpp_properties.json starts with workspaceRoot and the next three lines point at the standard ESP32 libraries (since this projects uses an ESP32) and then generically points at the default sketch library set and the local arduino packages. C:/Sr/Sketch is my Arduino Sketch folder.
Note the Local Appdata folder. This is the standard Windows location (with my name Mark). In many systems this folder is hidden or marked ‘system’ and in either case you won’t see it in a browse tree. You can type cd %appdata% to go the remote appdata folder.
settings.json
This is the normal VSCode settings file. You can change it in workspace settings (File / Preferences / Settings and then the Workspace Settings tab) or you can use an editor.
User Settings for Arduino
Turn off enableUSBDetection or it will (at least in my case) constantly nag you to change your board to what it thinks it reads from USB. If you mistakenly click Ok it will delete your current settings and use that incorrect driver to boot (sigh). So, turn it off.
Workspace Settings for Arduino
I set the external boards URL for the ESP32 supported boards:
How to Remove a Board Library
It’s not obvious how to get rid of a library (or two) and sometimes arduino seems to choke. The easiest thing to do is to delete most of the contents of the arduino appdata folder (look in %appdata%\..\local for an Arduino15 folder). One of these files is the settings. Keep that.
After you delete the rest of the files all the installed board libraries will disappear and you get to start over (usually a good thing).
Debugger works, however, strange to that although the globalVar variable has been initialised to 0 , it shows 1 in the loop() method, even if the command globalVar++ has not been executed yet. See this screenshot.
localVar behaves as expected.
How can this be explained?
Hi. It could be that the code already ran through the loop one time before it stopped in the debugger. The problem is that the debugger always connects to a running target - when you upload a program, it starts to run immediately. When you click the debug button the debugger will start to communicate with the target program and send it the command to insert breakpoints etc.
So, for example, the breakpoint at debug_init() in setup() will never be reached - the program is past this line when debugger connects. It may also run through the loop several times before the breakpoint in loop() is actually set after connection is established.
To verify if this is the case you could call function breakpoint() after the debug_init() . This is hard-coded breakpoint that should stop the program. Or try to insert something like delay(5000) at the end of setup(), so that the debugger connects before the program reaches the loop.
Thanks for sharing the tip with preLaunchTask . Perhaps it is something that appeared in newer version in VS Code. I now use PlatformIO rather than the Arduino plugin with VS Code and it is much more comfortable to debug with it. Also there is much less setup needed to enable the debugging. If you want to try it, see here.
I tried with the breakpoint() method (added in the setup() function) and indeed, when doing this the values of the variables are correct. It is now even possible to put a BP in the setup() function/line if you put the BP on a function/line which is located after the two function calls debug_init() and breakpoint() in the setup() function, which is great!
Can you elaborate a bit more on that one (debugging with PlatformIO, that is. )?
I also added both debug_init() as well as breakpoint() to the setup() function, but the breakpoint I've set in loop() doesn't get triggered. My software, however, runs.
This is my code:
I've put a breakpoint on the first SPI command in the loop() function, but the debugger doesn't stop at that location. Am I missing something here?
Hi,
I edited the link in the previous post, it should now point to the correct page on PlatformIO website.
There is no hardware needed; it should work in Platform IO the same as with Arduino plugin. The advantage is that you can just click the Debug button to upload and start debugging, no need to upload separately and then start debugging. Plus it should be only few lines in platformio.ini to configure the program for debugging.I don't see any problem in your program and if it builds then there should not be any problem with the debugger library either. So maybe you are not starting the debug session somehow but just uploading the program or something in the Platform IO configuration is not correct.
Here is part of the platformio.ini file with configuration:
Thanks for the update.
I modified my platform.io file and it now looks like this:
So, I added your content too, but unfortunately it still doesn't work.
But when I look to the DEBUG CONSOLE window, I see the following platformio error (I overlooked that error before, sorry for this. ):
- fetched the latest PlatformIO through pip install -U platformio (first recommendation at the bottom of the above error message)
- fetched the pywin32_bootstrap module using the command pip install --ignore-installed pywin32 to be sure to have it installed and have the latest version installed
- fetched the twisted module using the command pip install --ignore-installed twisted to be sure to have it installed and have the latest version installed
- tried to see if pywin32_bootstrap is available through the test command python -c "import pywin32_bootstrap" and it didn't give me any error, so it's for sure available on my PC
- tried to see if twisted.internet is available through the test command python -c "import twisted.internet" and it didn't give me any error, so it's for sure available on my PC
- restarted Visual Studio Code to make sure the latest changes are taken into account
I will raise this issue on the PlatformIO website, as suggested in the latest recommendation at the bottom of the above error message.
Hi, yes, it will be best to raise the issue on PlatformIO website as this looks like some error in the PIO installation. The error messages don't make much sense to me. I hope the debugger will work when this is solved.
Do you think this would work on a NodeMCU esp 8266 board?
I've followed the tutorial but after including the avr-debug library it fails with the following error:
I searched for "io.h" in my arduino home folder and the libraries folder with no luck. Is this because I'm using an unsupported board?
Many thanks for the library, as well as your excellent walkthrough and your very helpful comments.
I just got this working on macOS (Catalina 10.15.7), which had some specific pitfalls I'd like to record in case anyone else ends up combing through the comments in frustration.
The primary issue I ran into was that, in configuring the VSCode arduino library, the command palette forces you to select as a serial port /dev/tty.* (where * is the serial port id). However, GDB will not be able to attach unless you use /dev/cu.* as the serial port. Evidently, tty.* is for receiving serial data and cu.* is for sending it, roughly speaking.
This needs to be done manually by setting the port field of the arduino.json file to
Whatever replaces the * will vary by user, hardware, and even physical serial port. For me, it was "usbmodem141101."
From what I know of working with serial devices on Linux I think the above will similarly apply to those systems as well. Aside from that the only macOS specific information to note is that the application files live (by default) in /Applications/Arduino.app/Contents/Java instead of C:\\Program Files\\Arduino . Taking that into account the installation instructions are the same.
Читайте также: