Build code from console/shell in Windows

In development, I already get used to build and load code from command line. I can do this comfortably on any Linux based OS, however sometimes I need to do development on Windows OS.

Is there anyway to do this in Windows? I have been trying to run Makefile manually from git bash for windows but stuck in this error. I tried to debug, no luck and give up as taking too much of my time.

$ make -f 'C:\Users\parhusip.particle\toolchains\buildscripts\1.9.2\Makefile' compile-all -s
1 [main] make (12704) C:\Users\parhusip.particle\toolchains\buildtools\1.1.1\bin\make.exe: *** fatal error - cygheap base mismatch detected - 0x180340408/0x18032D408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search for cygwin1.dll using the Windows Start->Find/Search facility
and delete all but the most recent version. The most recent version should
reside in x:\cygwin\bin, where 'x' is the drive on which you have
installed the cygwin distribution. Rebooting is also suggested if you
are unable to find another cygwin DLL.

You may be interested in trying neopo, a Python utility for local Particle development I developed that uses the same toolchain files as Workbench.

The universal install one-liner currently only works on Linux/macOS, but neopo can be installed manually in Cygwin on Windows.

After installation, configuring, building or flashing projects becomes very straightforward. Here is the quick reference, and here is the complete reference.

Thank you @nrobinson2000, it sounds great. But can it work on mingw instead?

1 Like

Probably. I haven't tested with mingw although.

Ok will give it a try.

Anyway, I saw the docs, it says it can work on WSL? My understanding WSL does not support 32 bit architecture and no support for USB? Just wondering whether neopo can build and load code via usb which is my norm in development.

I wasn't able to get WSL working with the 32bit gcc-arm compiler, so realistically neopo does not work in WSL. Neopo works impressively on native Linux or in a Linux VM however.

Since neopo uses the same tools and Makefile as Workbench, it excels at building projects and flashing firmware over USB.

On Windows, after installing neopo in Cygwin I was able to get it working within command prompt, so I have high hopes for mingw.

With some adaptions on the installation step, I managed to install neopo on git bash (mingw)

Installing neopo...
Finding Workbench extension URL...
Downloading Workbench extension...
Downloading dependency deviceOS version 1.5.4-rc.1...

Skipped previously installed dependencies:
gcc-arm@5.3.1, buildtools@1.1.1, buildscripts@1.9.2, openocd@0.11.2-adhoc6ea4372.0

Finished installation. To create a project use:
neopo create

Question:

  1. I already have existing code base, not from 'nepo create '. How do I build the code?
  2. In the installation log, it says to install deviceOS version 1.5.4-rc.1 which is version that I dont want. I want particular rev e.g. 1.5.0, how can I do it? In which folder the toolchains installation done?
1 Like

To build a project either cd into it or specify it as an argument to neopo build. If the project was created with workbench the settings in the project will be used.
https://neopo.xyz/docs/full-docs#compile

If you are in the project you can just run:

neopo build

Otherwise you would need to do something like:

neopo build path/to/your/project

To change the settings for a project you can use the neopo configure command, which will download and apply the toolchain automatically.
https://neopo.xyz/docs/full-docs#configure

In your case you would do something like:

neopo configure argon 1.5.0

The toolchain install folder is the same as Workbench. (~/.particle/toolchains)

I cd into my code base run this but with error:

$ ~/repo/neopo/bin/neopo build
Traceback (most recent call last):
File "C:/Users/parhusip/repo/neopo/bin/neopo", line 947, in main
commandsargs[1]
File "C:/Users/parhusip/repo/neopo/bin/neopo", line 681, in compile_command
buildCommand("compile-user", 2, args)
File "C:/Users/parhusip/repo/neopo/bin/neopo", line 610, in buildCommand
build(project, command, False, verbosity)
File "C:/Users/parhusip/repo/neopo/bin/neopo", line 555, in build
devicePlatform, firmwareVersion = getSettings(projectPath)
File "C:/Users/parhusip/repo/neopo/bin/neopo", line 498, in getSettings
return (data["particle.targetPlatform"], data["particle.firmwareVersion"])
KeyError: 'particle.targetPlatform'
An unexpected error occurred!
To report this error on GitHub, please open an issue:
Issues · nrobinson2000/neopo · GitHub

Thanks for finding a bug. It likely occurred because .vscode/settings.json exists in the project but the Particle settings are not in the file.

I will fix that edge case soon.

To resolve the problem try configuring the project with neopo configure before building. Please delete .vscode/settings.json before doing so.

Still not successfull after these steps:

1. remove .vsvode/settings.json
2. $ ~/repo/neopo/bin/neopo configure electron 1.5.0
Configured project C:\Users\parhusip\prj\bernina\BerninaDevice:
        particle.targetPlatform: electron
        particle.firmwareVersion: 1.5.0
3. $ ~/repo/neopo/bin/neopo build
      1 [main] echo (3032) C:\Program Files\Git\usr\bin\echo.exe: *** fatal error - cygheap base mismatch detected - 0x18032D408/0x180340408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search for cygwin1.dll using the Windows Start->Find/Search facility
and delete all but the most recent version.  The most recent version *should*
reside in x:\cygwin\bin, where 'x' is the drive on which you have
installed the cygwin distribution.  Rebooting is also suggested if you
are unable to find another cygwin DLL.
make: *** [C:\Users\parhusip\.particle\toolchains\buildscripts\1.9.2\Makefile:53: compile-user] Error 127
Failed with code 2
````Preformatted text`