Getting out of Arduino

Hello Guys,

I hope some of you did this already and I can just use his/her project as a template :slight_smile:

I’m trying to avoid using Arduino and instead use AtmelStudio or any other tool - I’m even fine with cmd line build. This way I can (carefully) use c++ code and have more flexibility.

I think we should be able to build our files, link with the SDK lib, add startup, …etc. Essentially doing what Arduino does but without preprocessor.

What do you think? Any body out there have this setup already?

I also hate the Arduino IDE! Personally, I usually type in my programs using Atmel Studio and then cut/paste into Arduino to finally download and run. Not a great workflow, but I am used it it.

For a while I had Visual Micro working, but then ran into some licensing issues so abandoned it.

Here is a slightly old post on getting everything to work with Visual Studio Code…


My guess is that this would be easier now, but I have not tried. If you do try, report back if you have any problems and we’ll try to work through them. My guess is that this will end up being the best solution for most people.

2 Likes

So I spent a little while playing with the Arduino add-in for Visual Studio Code and it is not clear to me how you configure custom board types. There should be some place were you can set the path of the board folder to use, but I can not find it. If anyone has luck figuring this out please report back!

Thanks a lot @bigjosh for the information and for pointing out vs code - it is my favorite editor by far. I’ll give this a try and will report back. Ironically can’t escape learning about Arduino in the process…its about time :slight_smile:

Thanks! Do not hesitate to ask if any questions come up!

tl;dr I got VS Code to be able to download sketches to a blink, but IntelliSense does not work for blinks-specific functions and there is other uglyness.


OK, I made some progress!

So I was able to add the Blink custom board to VS Code by…

  1. Add the Arduino add-in
  2. Add the Blink board URL in user settings.json as "arduino.additionalUrls": "https://github.com/bigjosh/Move38-Arduino-Platform/releases/latest/download/package_move38.com-blinks_index.json"
  3. Quit and reload VS code
  4. Go into “Arduino->Board Manager”, filter on “move38”
  5. Install the “Blinks by Move38.com” board
  6. Quit out and reload VS code
  7. Got to “Arduino->Board” and select the “Blinks by Move38.com
  8. Quit and reload one last time to be safe

Now you should be able to do “Arduino->Examples” and then “Examples->Blink” to see the list of blinks examples. Open one and you should be able to do “Arduino->Verify” and compile it. Use “Arduino->Select Programmer” to select your programmer (probably USBTinyISP) and then you should be able to do “Arduino->Upload”. Worked for me.

Problems:

  1. It is not picking up the include files so you get litter red squiggles under blinks functions like setColor(). Still compiles and works fine, but missing all the intellisense stuff sucks. I tried adding "C:\\Users\\passp\\AppData\\Local\\Arduino15\\packages\\move38\\hardware\\avr\\1.0.0\\**" to the includePath in c_cpp_properties.json but it does not seem to work. :confused: Worse, it seems like there are lines in here for all of the boards that have been loaded so even if it did work it would work with functions for other boards too which is just ugly and nasty.

  2. When you pick your programmer under “Arduino->Select Programmer”, it seems to only show you programmers from the built in Arduino programmers.txt rather than the programmers.txt for the blinks custom board. Yet somehow it still seems to work. I guess working is good, but this whole mess is bad and wrong.

Takeaway: I guess you can use this if you really like VS Code but man it is a mess. If you figure out how to get the C++ extention to use the right directory for #includes that would help a lot, but it is still ugly. VS Code sure does show its javascript/typescript worldview here. :frowning:

I’m using VS Code myself. I hit the occasional issue where auto complete stops working until I restart but other than that everything works fine. Easy build via CMD+SHIFT+R and upload via CMD+SHIFT+U plus all the expected intellisense / refactoring fun.

As far as I know the only set up I needed was the normal blinks lib install, VS Code + the Arduino Plugin and then these vscode settings (you can probably ignore settings.json and change the include path to find your blinks lib install path)

I tried this but, under Linux, it then fails to find the system include files (things like limits.h, stdint.h). As they seem not to be included in the Blinks repository, I assume they should be generic avr include files, so I added paths where I found them and now it works:

{
“arduino.path”: “/home/bga/development/arduino-1.8.13”,
“arduino.additionalUrls”: “https://github.com/bigjosh/Move38-Arduino-Platform/releases/latest/download/package_move38.com-blinks_index.json”,
“C_Cpp.default.systemIncludePath”: [
“/home/bga/development/arduino-1.8.13/hardware/Move38-Blinks-Library/avr/**”,
“/home/bga/development/arduino-1.8.13/hardware/tools/avr/avr/include”,
“/home/bga/development/arduino-1.8.13/hardware/tools/avr/lib/gcc/avr/7.3.0/include-fixed”

],
"C_Cpp.updateChannel": "Insiders",
"C_Cpp.default.includePath": []

}

Note that limits.h was found in 2 different paths, so I just picked one but I am not sure it was the correct one. Any ideas?

1 Like

I’m wondering, will this allow you to write C++ code? or just enjoy the convenience of VSCode editor? I’ll give it a try in this coming long weekend…can’t wait!

As I understand it (and I am just starting with Blinks development), you do not need anything special to use C++ (you can use it with the Arduino IDE. At least code I wrote compiled without issues). You just need to be mindful of the limit on storage space and memory. If you simply use C++ without consideration for that, you will most likely see issues.

1 Like

Ok, Thanks a lot guys for your help! I got this to work finally. It didn’t work out of the box and had to do the following:

Updated local settings to the following: c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "C:/Users/<USER>/Documents/Arduino/hardware/Move38-manual/avr/**",
                "C:/repos/Blinks/Blinks-SDK/cores/blinklib/**",
                "C:\\Users\\farbl\\Documents\\Arduino\\hardware\\Move38-manual\\avr\\**"
            ],
            "defines": [
                "F_CPU=8000000L",
                "ARDUINO=10813",
                "ARDUINO_AVR_BLINK",
                "ARDUINO_ARCH_AVR"
            ],
            "forcedInclude": [],
            "intelliSenseMode": "clang-x64",
            "compilerPath": "C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

Some of these are defaults, except:

  • Include path, added the SDK ones
  • Defines, copied them from SDK’s platform.txt (not sure if this is needed or not, but noticed these are used when using procmon)
  • Updated compiler path to point to Arduino

Also needed to change Intelli Sense engine to TagParser in settings.json as:

{
	"C_Cpp.intelliSenseEngine": "Tag Parser"
}

I then did CTRL+SHIFT+P to get Arduino commands and did init, select board, select programmer. This resulted in the following arduino.json:

{
    "sketch": "test.ino",
    "board": "Move38-manual:avr:blink",
    "programmer": "USBtinyISP",
    "port": "dummy"
}

Note the dummy port above I had to add later after upload was failing, looked at the extension source code and was checking for !dc.port, this dummy value seems to bypass this code block and upload worked after!

Also in the verify process I encountered the following warning:

blinklib.cpp:600:77: warning: invalid conversion from 'const volatile uint8_t* {aka const volatile unsigned char*}' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]

                             const uint8_t *datagramPayloadData =  packetData+1;    // Skip the packet header byte

                                                                   ~~~~~~~~~~^~

A cast seems to fix this:

const uint8_t *datagramPayloadData = (const uint8_t *) packetData+1; // Skip the packet header byte

One final note, that may be helpful, is instead of copying the SDK to Arduino folder, I created a symbolic link, like (windows):

cd %userprofile%\Documents\Arduino\hardware\Move38-manual
mklink /D avr C:\repos\Blinks\Blinks-SDK

Time to try some coding! :slight_smile:

Hmmmm, that’s interesting. What other files were missing? Apparently gcc knows where to find these, but VS Code does not? Maybe I can pull these into the board tree…

Cool! Ill give this a try next week and I’ll also look into that type warning.

Thanks for all the work getting this to work! :slight_smile:

1 Like

One more thing I encountered today is excessive debug logging coming to the output window making it difficult to scroll in case of compiler error. Fix was to add

-DDEBUG=false

to the C:\Program Files (x86)\Arduino\arduino_debug.l4j.ini

as described here.

Also needed to add this to arduino.json:

"output": "../out"

see this thread.