Developing a using VScode & an emulator

Hey, I’ve just ordered an Arduboy FX (woop!) and I’ve just got my vscode setup with the necessary extensions and configured to work with the arduboy board.

I’m a total C++ noobie. Can I utilise the ProjectAbe emulator made by @FManga? Ideally I’d like to configure csvode to have this as a launch configuration. If anyone has done this could you share your launch.json file so I can replicate?

If it’s not possible to use ProjectAbe is there any other way to have a software only development & testing workflow?

Thanks!

Hi!

Sure you can use ProjectABE. Just drag and drop the compiled hex file from the .pioenvs folder onto the ProjectABE website. There is no automatic process though.

Thanks for the reply, how can I compile my project to get the hex? At the moment when I ‘run’ the project in vscode I get:

Cannot find the OpenOCD from the launch.json debugServerPath property. Please input the right path of OpenOCD.

I have installed openocd yet I still get this message. Just not sure what my launch config should look like. My launch.json file:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Arduino",
            "type": "arduino",
            "request": "launch",
            "program": "${file}",
            "cwd": "${workspaceFolder}",
            "MIMode": "gdb",
            "targetArchitecture": "arm",
            "miDebuggerPath": "",
            "debugServerPath": "",
            "debugServerArgs": "",
            "customLaunchSetupCommands": [
                {
                    "text": "target remote localhost:3333"
                },
                {
                    "text": "file \"${file}\""
                },
                {
                    "text": "load"
                },
                {
                    "text": "monitor reset halt"
                },
                {
                    "text": "monitor reset init"
                }
            ],
            "stopAtEntry": true,
            "serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
            "launchCompleteCommand": "exec-continue",
            "filterStderr": true,
            "args": []
        }

    ]
}

You might just be better off putting ProjectABE on your %PATH%/$PATH and using a tasks.json to provide a command for launching ABE.

(As much as I like VSCode as an editor, the documentation covering how to customise it is atrocious.)

To simply compile a hex, isn’t it just Ctrl-Shift-R? These are defined in the Keyboard Shortcuts:

Mine is a Mac.

Yes for me the same! the hex is then in the .pioenvs dir.

I don’t know what that is sorry.

1 Like

Thanks so much for the help everyone! I’ll give these suggestions a go when I get home on Monday.

For those using the Arduino plugin rather than PlatformIO:
the output usually defaults to a folder in the OS’s temporary area (e.g. %TEMP% on Windows), but you can explicitly specify an output folder by editing the /.vscode/arduino.json file (which is usually autogenerated if you’re already tried to compile before).

That file has several settings:

  • board - Specifies the target board/CPU. Mine is typically set to arduboy:avr:arduboy
  • sketch - Specifies which .ino file is the main .ino
  • port - Specifies the upload port, e.g. COM3, COM5 et cetera on Windows
  • output - This is the setting you can add to specify the output folder. If it’s a relative path it’ll be relative to the folder containing .vscode

E.g. my arduino.json for Sliding Tiles consists of:

{
    "board": "arduboy:avr:arduboy",
    "sketch": "SlidingTiles\\SlidingTiles.ino",
    "output": "Build",
    "port": "COM5"
}

Hence combining that with a tasks.json like this one:

{
	"version": "2.0.0",
	"tasks":
	[
		{
			"label": "Run Hex",
			"type": "process",
			"command": "ProjectABE Build\\SlidingTiles.ino.hex",
			"problemMatcher": [],
			"group":
			{
				"kind": "test",
				"isDefault": true
			}
		}
	]
}

should theoretically run ProjectABE when Tasks: Run Test Task is selected from the ‘command palette’ (i.e. the F1 menu).

(Assuming ProjectABE.exe is in one of the folders specified by %PATH%.)

You can then set up a keybind to the task command.
(I’ve recently done a similar thing for Haskell.)


There’s probably a better solution, but like I say, VSCode’s documentation is pretty atrocious so figuring out what kind of things are possible is a nuissance.

1 Like

Thanks for all the help, I managed to get it running nicely with debugging, intellisense + launch to emulator.

I created a template project and setup instructions to hopefully save someone time in the future:

2 Likes

Just so you know, package_arduboy_index.json is usually installed to I:/AppData/Local/Arduino15/package_arduboy_index.json on Windows when the Arduino IDE is set up to use https://arduboy.github.io/board-support/package_arduboy_index.json.

I thought I’d mention it in case anyone wants to avoid the extra internet usage for checking a resource that’s highly unlikely to change.