How To: Easily Install Openhab2 on Odroid C2 ARM64

EDIT: The easiest way is to install ARMBIAN by flashing that onto a flash card and then running the armbian config program and selecting openHAB to be installed for you from the list of 3rd party software. It then fully installs. You can also use this script as an alternative on top of a clean Armbian.

http://pcmus.com/openhab/scripts/install-openhab-armbian.sh

For anyone not familiar with the Odroid C2, it is similar to the PI3 with the advantages that it has double the ram, true 1000mbps network, and more than twice the CPU grunt. The C2 is also one of the best budget devices to run KODI on due to the devs using it for testing and it supporting H265 playback at 4K 60 FPS (Pi3 can not do h265). You can have multiples of them around your house as spare parts running KODI set top boxes. For more info see https://libreelec.wiki/

How to auto install Openhab2 onto the Odroid C2

Download the image from Armbians website:
Use Etcher to flash the image you downloaded from the link above to a SD or EMMC card.
Insert and power on the Odroid C2 using a good power supply and cable.
SSH into the device using putty.

Now onto the fun stuff. Enter this into the linux terminal via putty or your favorite SSH client


wget http://pcmus.com/openhab/scripts/install-openhab-armbian.sh
nano install-openhab-armbian.sh

The nano step is optional and will open the script up where you can read every line if you wish, or edit any of the preferences in the script at the very start of the file. For example you may wish to opt out of installing mosquitto or opt in to installing the Real Time Clock support. Save if you make any changes and exit with Ctrl+X.
TIP: If you need to paste into the Putty screen you can use the right hand mouse button to paste by clicking anywhere in the screen.

Run the script using this command

sudo bash ./install-openhab-armbian

Sit back and answer any of the questions which are mostly timezone selection or entering in passwords you wish to use. If all goes well you will end up with a working system in around 20 minutes. If any issues occur the entire output is placed into a file called install.log for you to look back over.

4 Likes

What to buy when ordering the C2:

A case is needed as it will not fit directly into a Pi case.
You will need to cut the official C2 case to gain access to the micro SD slot so dont forget to do this before mounting and screwing it all together.
https://www.hardkernel.com/shop/odroid-c2-c1-case-clear/

RTC shield is only $4.50 which the price includes the battery. If your power fails stopping your internet connection, then it is possible openhab when it reboots may run rules with the wrong date/time. NTP does not solve all situations so this addon is worth getting and my script will auto setup this shield for you if you edit the prefferences.
https://www.hardkernel.com/shop/rtc-shield/

Whilst you can use a micro USB power supply to the OTG port, I recommend you run the C2 from the barrel plug as it draws 0.5 watt less power when at idle when doing this. Even if you plan to re-use a PI power supply, consider this cable as a backup as the cost is low.
https://www.hardkernel.com/shop/usb-dc-plug-cable-2-5x0-8mm/

Lastly this UPS addon is a good idea but personally I prefer to spend my money on a bigger UPS that can then power other gear as well and provide surge protection. A larger UPS is at least 5 times as much to purchase as this one but will provide a lot more features and power and is also a lot heavier and physically larger. A UPS is a must for any small computer that runs on flash based storage.
https://www.hardkernel.com/shop/ups3/

have you tried to install openHABian on your C2? Essentially it’s justs scripts you can install on any Unix. Now getting openHABian to support C2 as another HW would be a nice enhancement and way of making this available to more openHAB users.

1 Like

Yes, I have tried and the result is pasted below. It would be great to update openhabian with support as I do like the project and use it on my raspberry pi’s. I enjoy learning by doing things myself and since I like to document everything I do, it was easy to turn my documentation into a script to speed up re-installs. People are welcome to use it.

Here’s the result of doing it with openhabian using the documented manual install method:

  • Asks for user you login with. Since I’m playing the noob, i type in ‘root’ as this is the default and only user for my image. Possibly this could cause issue later on so I try this to see what will happen. After install is complete it tells me it is skipping the password checks when I exit the tool. If adding support for C2 this needs support added for checking and dealing with only a root account PLUS checking the default password for the root account is changed.
  • I then get a warning about a hotfix being needed, which surely the latest tool got downloaded with the clone but I still get that old message. I update the tool to ensure it is the latest. After updating the tool, on every start of the config-tool I get the warning again.
  • When doing a manual setup I am able to tick both STABLE and UNSTABLE openhab at the same time. Not sure if this will cause issues but if I was a noob I would tick all steps. I only tick the STABLE option.

The install goes on for 25+ minutes and fails with this


$ apt -y install zulu-embedded-8
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package zulu-embedded-8
FAILED

So I manually start the config tool again and bingo I get the old warning about needing a hot fix again !
Tool is showing [master]v1.4.1-411(ecf59c4)

I then re-run the manual setup again and this time select Oracle java instead.

Success, it appears to now work. But I get a minor error


FireMotD: Error: Template folder doesn't exist. ........

This should not stop Openhab from working.

FYI, I recently moved my openhab from RPI2 running on sd card to a RPI3 with no sd card and a 128 SSD. I installed latest version of openhabian on SSD using etcher then a backup restore. Everything went smooth but I had the FireMotD error. Not sure what caused the issue but I ran openhab for a few days with no problem before I fixed using:

openhabian@openHABianPi:/opt/FireMotD$ sudo ./FireMotD -I -v

Maybe something similar may help if your still having the FireMotD error.

1 Like

Ok, so as you’re essentially using the repositories you’ve setup the C2 with yourself and there’s apparently no Zulu Java package in those repositories, that’s to be expected, and the alternative (Oracle Java) seems to work. But Zulu is the openHABian install default.

You can edit the files on your machine to get that working (just don’t use the openhabian update function as that’ll overwrite/delete everything you change there).

Essentially see /opt/openhabian/openhabian-setup.sh call java_zulu_embedded for all unattended installs.
That would need to be replaced with something like
if is_odroidc2; then java_webupd8; else java_zulu_embedded; fi
and you would need to add a proper is_odroidc2() function to functions/helpers.sh
(guess you can parse /proc/cpuinfo just like the is_pi() and other functions do).

Is that hotfix specific to the C2 ? If so, you could add a routine odroidc2_fixes() or similar to functions/system.sh and place the commands to download + install the hotfix there.
Call it from openhabian-setup.sh, too (if is_odroid2() is true only, of course).

It’s no magic
 if you manage to get your local copy to install unattended, would you then be able and willing to produce a pull request to openHABian scripts on GitHub ?

A few comments:

  1. The hot fix message that keeps appearing is not created by C2 or this image, it is the openhabian tool creating the message in a popup style window. I believe it is to do with this as it looks the same from what I get when I load very old backup images on my PI

    Notice to all openHABian users: Please apply a fix asap!
    Possibly the method the tool uses to detect if the hotfix is applied is broken on this image, or it may in fact be valid.

  2. Really the openhabian tool is missing 2 things. First, a nice way to check and create an “everyday user” and ensure the root account password gets changed. Second, the ability to install ZULU java, which my script can be used to grab the manual method that works under this image. See this guide on how I am doing it

    How To: Install Zulu Embedded Java on Odroid C2 (ARM64)
    I could not get any package/repo to install ZULU despite methods being in manuals stating it could be done on azul’s website, only the manual method works as the repo complains it does not support arm64.

  3. Sure I am happy to release as opensource with any license you wish for someone else to pull apart and include whats needed. A lot of the script is from openhab’s documentation. I do not have the time as I have a new baby and am already trying to develop and improve 2 bindings to get my own setup working.

Let’s not mix things here, please.

On 1), that’s perfectly normal. It’ll update the openhabian-setup scripts (and sub-scripts) to their latest versions. Needs to be done on C2 as well as any other boxes. Whether it appears depends on the version you installed (or the version contained in the image you used for Pis). Just do.

On 2) when your openHABian unattended install succeeds, it’ll also add an “everyday user”.
Once the initial install finished, you do can install either Zulu or Oracle manually if you call openhabian-config and select option 63 at any time.
The initial (unattended) openHABian install will try installing Zulu on every HW.

Both (unattended and manual install) are effectively calling the java_zulu_embedded routine defined in /opt/openhabian/functions/java-jre.sh.
That didn’t work for your C2, but your linked guide essentially says that it would have worked if the install script had downloaded the proper package instead of doing whatever it did. Now that we could resolve by either using a repo to have the proper version (but we don’t know any such repo for the time being, right ?) or by inserting the commands (wget, dpkg) you used into the openhabian scripts, and call them if we’re on a C2.
That I was asking you for in my previous post:
Edit the scripts on your machine, and use option 63 of openhabian-config to call your modified code to verify it’s working.

Once you have working code, getting that into the openHABian master is fairly easy. Get a GitHub account,
browse the openhab/openhabian repo and “edit” the mentioned file. GitHub will tell you you don’t have write access and create your personal copy of the repo to contain your changes. Finally, it’ll offer you to create a Pull Request.
If you feel uncomfortable with using Github, you can as well send me your code and I’ll do that part.

SOLVED, The hotfix message kept appearing until after I had done a reboot. I’m sure when I have done it in the past with the PI, the moment the tool gets updated the message stops.

Fantastic news, but I’m guessing it will leave the root user account alone and not check that the user has changed the password? The openhabian tool already does password checks, hopefully just a matter of adding “root” and “odroid” to that script if C2?

Also I take it that to setup an unattended install you would need to create a modified IMG setup to do that? Is there a way to do something like

sudo openhabian-config unattended C2

EDIT: answered part of my question unattended is used in /opt/openhabian/openhabian-setup.sh so the $1 works, just can not see $2

Correct, I looked pretty much everywhere and could not find a repo that would work, perhaps next week they may change this or I am blind, but for now it appears manual install only. Downside is the version gets hard coded in.

Correct and that would be easy to do with the only hurdle I do not know how openhabian knows what device you own. If you already know the framework of openhabian and the best way to implement the device check, then great it will take you a fraction of the time it would take me.

I just checked the file /opt/openhabian/functions/java-jre.sh
It already has a section that is marked as unused at the bottom and it is a manual install method very similar to what I am doing.

Well yes if you want to install your C2 like your Pi then the updated script would need to be put into a (C2 specific) image, but I think it would be out of scope for the openHABian project to maintain various images
(these would need to contain the base OS as well which I think is pretty different for Odroids).

But you used a different method to install openHABian, and if we were to update the openHABian scripts to support C2, it’s these updated ones you or a user would download and start your install based upon.

Once up and running, you can also call /opt/openhabian/openhabian-setup.sh with option either “unattended” or “unattended_debug” (just look at the beginning of that script). Eventually you need to comment out parts that you already executed during your unattended run.
Not sure if that works or has side effects. Maybe @ThomDietrich you can comment on this.

I don’t have any C2 available to test against so it’s up to you.
See definition of is_pithree() in functions/helpers.sh, it’s essentially parsing the contents of /proc/cpuinfo.
According to some quick google responses, a C2 would show ‘Hardware : ODROID-C2’, so grep for the Hardware line in your check.

Thanks for the info, very helpful. Here is some code


grep line with the result underneath if I leave out the -q quiet option


grep -q "^Revision\s*:\s*[ ][0-9][0-9][0-9][a-z]" /proc/cpuinfo
Revision        : 020c
grep -q "^Hardware\s*:\s* ODROID-C2" /proc/cpuinfo
Hardware        : ODROID-C2

Guessing it needs to be return 0 if TRUE?

is_odroidc2() {
  if grep -q "^Hardware\s*:\s* ODROID-C2" /proc/cpuinfo; then
    return 0
  else
    return 1
  fi
}

@mstormi

OK, I have it working and can do a PR on github after some feedback as some changes are probably still needed
 Work done so far is forked here

Issue raised on openhabian github here.

If I try on a clean system to run unattended mode it complains I am missing a conf file, yet no message telling me what to do to create one. Recommend a nicer message to guide users.

So i launched the tool and ran manual/fresh setup (option 60) which did not trigger the archive method of installing zulu. Possible ways forward are to offer the manual archive method as a 3rd Java option, or to do a simple re-direct if it detects is_odroidc2. Thoughts? I probably prefer offering it as a 3rd option that way if other devices like odroid C1+, XU4 or other arm64 devices are used, the coding is already done.

After exiting I tried to run unattended and this time it worked all the way through with all steps giving OK output. The java_zulu_embedded_archive() ran instead.

1 Like

Well it’s usually not meant to be run like that. Just a wild guess is it looking for /etc/openhabian.conf ? If so, try copying your existing one. Well or read the script source what file it is looking for. You can also insert “set -x” after its first line.

Nah, I’d rather replace the zulu option because that wouldn’t work on the C2. See what routine that’s calling and insert if (is_odroidc2()) then <your install routine>. Maybe the person to review your PR (probably @ThomDietrich) will request you to change that but that’s how I would proceed.

And of course replace the zulu line of /opt/openhabian/openhabian-setup with another if (is_odroidc2()) then <your install_routine> if you haven’t done so yet.

Yes that is the one. Bottom line is as you say, it is not setup to install this way and hence it is far harder then simply using my script which now has the ability to install openhabian as part of the process.

Openhabian is in the middle of changing things to make it easier (great news), so any further changes until the framework is re-written is a waste of time.

@matt1 I am almost beaten trying to get Zulu onto my Android box.

I have a Beelink mxiii v2. Uses the S905X chipset and is fairly close to the Odroid C2 in spec. It has been running Debian Stretch with Home Assistant beautifully for a few months but I want to make the jump to Openhab.
I tried to load Zulu onto Debian and failed in every way. After seeing your troubles with ARM64 I tried Ubuntu 18.04 and had a bit more success but still cannot get it to work.
I tried your script with a couple of tweaks and it appears to get to the end but still Java gives “illegal instruction” when I check the version (java -version).
If I try running openhab the service keeps failing with illegal instruction errors. I have tried various versions of Zulu and all give the same result.

Do you have any ideas for how I can get a working Zulu installation on the thing please?

A. Pay Zulu for support and they probably know why and how to get it going.
B. Just buy an Odroid C2 as they have a big community to ask and also fix bugs in the base images they supply.
C. Try another java like Oracle or openjava, but since they are not the recommended ones to use you do raise the odds you will hit a unique bug in Openhab that no one else has seen.

Sorry I do not have any troubles, it took me a day to work out how to do a manual install of Zulu as there were no guides anywhere on how to do it step by step. My setup is working great for almost 6 months now and used daily


I posted this guide here as it takes you through the steps with more info on getting the java sorted. If java is not running right, then dont bother trying openhab.

Uploaded an updated version of the script today. It now uses a newer version of zulu java and fixed some issues with frontail loading. Steps are in the first post of this thread on how to find and use the script.

Updated and tested the script again as the key for a repo had expired in the ubuntu images created by Odroid and also now using newer Zulu JVM.

1 Like

Will the script also update key and java on an running Odroid C2 with Ubuntu ?
(maybe @MDAR got some interest in this).

The script will work omly on a new empty image, however the commands are easy to grab in any text editor as it is a bash script. Very easy to grab the steps you need out of it to use manually or you could create a java updating script from it.

I always setup from scratch to renew the entire sd cards contents with new reliable data.

1 Like