Best way to crosscompile on Windows for Raspi

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
Hausautomatisierer
Posts: 5
Joined: Sunday 05 November 2017 18:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Best way to crosscompile on Windows for Raspi

Post by Hausautomatisierer »

I am very sorry, if this was already tackled somewhere, but i could not find anything yet.

Which is the best way to crosscompile Domoticz on Windows for a Raspi? Alternativly, is it easily possible to use the same method as the official Domoticz build uses on Github, just for my own repository? If yes, what would be the procedure?

(I have only very basic skills with Linux and associated tools)

Thanks for any help!
User avatar
waltervl
Posts: 5818
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Best way to crosscompile on Windows for Raspi

Post by waltervl »

I suppose with https://www.domoticz.com/wiki/Build_Dom ... th_Vagrant
But @Kiddigital or someone more experienced will hopefully help us here soon...
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Hausautomatisierer
Posts: 5
Joined: Sunday 05 November 2017 18:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Best way to crosscompile on Windows for Raspi

Post by Hausautomatisierer »

I saw the vagrant post and I think I could get it to work for Linux, but for Raspi, I am not so sure...
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Best way to crosscompile on Windows for Raspi

Post by kiddigital »

First I assume that your goal is to make changes to the Domoticz sourcecode yourself which you can use later to run on your ‘production’ Pi. Correct?

So to start making changes you always need to create your own github fork of the Domoticz repo.

That is the one you work with locally (git clone your fork) and where you can ‘push’ your changes (commits) to.

And if you think those changes are a good addition to Domoticz in general, then you create a Pull Request, which represents the changes to your fork and the main Development branch of Domoticz.

The above process is the same no matter on what platform you develop and/run.

What environment you use to develop is also up to you.

You can follow the instructions to setup a native Windows development environment.

The Vagrant way is also a relative easy way to start developing on Windows. You are using Windows OS and a Windows IDE (Visual Studio Code for example) but actually develop on Linux in a Virtual Machine.

It is not perse needed to either develop on a Pi or cross-compile for a Pi to develop functionality that runs on a Pi.

Personally I develop using my Windows machine using Vagrant to code and compile under Linux. But my main Domoticz machine is a Pi also. When things work as they should on Linux, chances are 99.9% that they will work also on a Pi. So I develop for Linux and test changes on it and once my Pull Request makes it into the main Domoticz Development branch, a just update my Pi to use the new beta version (which has been compiled for the Pi by the Domotiz team).

But yes, that means quite some time can pass between when I coded something and actually use it on my Pi.

Setting up a cross-compile environment is not an easy task (yet), or at least not to me at the moment. But it is something I would like to get working sometime but it requires investing quite some time (for me at least) to get it right (work in progress). My current line-of-thinking is to setup a cross-compile environment using qemu, as it has support voor ARMv7, under Linux which runs in a VM on my Windows machine. So VM in a VM…

Another in between ‘solution’ could be, but probably requires a spare Pi, to develop on Linux and once you are done, clone your fork on the spare Pi and compile it directly on that Pi. But remember that compiling on a Pi takes a few hours (and not minutes as on Linux). The ‘advantage’ is that you only have to do it once you are done with your changes and testing (on Linux) and not for every code change. And you can copy the compiled binary to your production Pi after compiling has succeeded.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
Hausautomatisierer
Posts: 5
Joined: Sunday 05 November 2017 18:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Best way to crosscompile on Windows for Raspi

Post by Hausautomatisierer »

Thanks @kiddigital, for your detailed reply. In principle, what you describe is exactly what I do / would like to do, with the exception, that I do compile in Visual Studio. My problem is really to bring the changes to the Raspi and not being dependent on the beta releases. Vagrant seems no option to me, since all provided images require virtual box, which is incompatible with HyperV which I am running on my PC (I need it for various reasons).

Of course, I can setup a HyperV VM for Raspian, but my best guess is that anything compiled on it will not run on a Raspi, but I'll try, that should be easy while watching TV or so...
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Best way to crosscompile on Windows for Raspi

Post by kiddigital »

You are not bound to VirtualBox to use Vagrant. You can use HyperV as well. Most boxes are available for HyperV as well.

When you compile under Visual Studio using the VS windows compiler, there is a very small change that it will not compile under Linux (gcc compiler) and Raspian (also gcc). But most likely for 99% it will work just fine.

Although compiling on a (spare) Pi will take much longer than in a cross-compiler environment using a much more powerful Windows machine, it is a relative easy way to build your local Pi version. Just use your fork of the Domoticz repo on both.

Looking forward to your additions (and Pull Request) to Domoticz
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
Hausautomatisierer
Posts: 5
Joined: Sunday 05 November 2017 18:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Best way to crosscompile on Windows for Raspi

Post by Hausautomatisierer »

Well, the first PR is there, see Github user Igitigit2 ;)
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Best way to crosscompile on Windows for Raspi

Post by kiddigital »

Nice
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest