How To: Easily Install Openhab2 on Odroid C2 ARM64


(Skinah) #1

I have created an install script that will turn a fresh Ubuntu minimal 18.04 LTS image into a working Openhab2 setup. I have tested it to work with the Odroid C2 only, but it is possible that this will work with other ARM64 devices running Ubuntu 18.04 and newer. The PI range are not arm64 so please do not try this with a raspberry PI, instead use openhabian for those devices.

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 here:
https://wiki.odroid.com/odroid-c2/os_images/ubuntu/v3.0
The exact link I used is
https://odroid.in/ubuntu_18.04lts/ubuntu-18.04-3.16-minimal-odroid-c2-20180626.img.xz
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.
If the blue LED stops flashing after 16 seconds just pull the power and re-apply. The LED goes out after the card has finished expanding to fill your entire card on first boot and is normal.
SSH into the device using putty (The default login details are “root” as user and “odroid” for password)
The script will change the password for root in the very first step as it is important for security to never leave it as the default password.

Now on to the fun stuff, enter this into the linux terminal via putty or your favorite SSH client…

wget http://pcmus.com/openhab/scripts/install-openhab-arm64.sh
nano install-openhab-arm64.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. Save if you make any changes and then exit.

Run the script using this command

sudo bash ./install-openhab-arm64.sh

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.


How To: Install Zulu Embedded Java on Odroid C2 (ARM64)
Does open hab require raspberry pie or any other device to operate?
(Skinah) #2

What to buy when ordering the C2:

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/main/products/prdt_info.php?g_code=G146000366985

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 watts 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/main/products/prdt_info.php?g_code=G141637559827

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/main/products/prdt_info.php?g_code=G146068525665


(Markus Storm) #3

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.


(Skinah) #4

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.


(CM6.5 H102) #5

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.


(Markus Storm) #6

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 ?


(Skinah) #7

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.


(Markus Storm) #8

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.


(Skinah) #9

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.


(Markus Storm) #10

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.


(Skinah) #11

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
}


(Skinah) #12

@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.


(Markus Storm) #13

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.


(Skinah) #14

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.