Coder Social home page Coder Social logo

hue-platform's Introduction

Running native code on Hue Bridge 2.X

Once rooted, the OpenWrt-based Hue Bridge 2.X can run external binaries compiled for it.

Note if anything goes wrong, it should be possible to undo any damage with a factory reset.

Prerequisites

  • Root bridge using the pin2pwn method
  • Create an ssh key pair for dropbear on dev machine and manually copy public key onto Bridge over serial terminal, followed by a command to install it. Store private key locally in ~/.ssh/id_rsa_hue
    echo "PUBLIC KEY CONTENTS" > /root/key
    ssh-factory-key -r /root/key
  • Create links for shared libraries if they will be used
  • Ensure opkg is available on Bridge. Use instructions below to install if missing (later firmware removes binary)
  • Docker must be installed on dev machine

Building and executing custom C binary

./build

If successful, this will

  • download the appropriate Docker image with the OpenWrt SDK installed
  • copy source and cross compile into package
  • copy built package to working directory and across to Bridge via scp
  • install package onto Bridge

Then via ssh using root or new user account, the binary can be executed directly on the Bridge, it will be in the PATH.

Additional instructions

Restore Opkg removed in new firmware

It is likely necessary to set up missing library links before the copied binary will execute.

Prerequisites

The opkg command will now be available on the Bridge

opkg update

Setup limited user account

It is always a good idea to avoid using the root account as soon as possible on a system. Sudo can also be installed to provide privileged access when needed.

On the bridge,

  • Install user management packages
    opkg install sudo shadow-groupadd shadow-useradd
  • Create group and user and home directory. This will end with a prompt for a new password
    USERNAME=<your own username>
    groupadd --system sudo
    useradd -s /bin/ash -G sudo $USERNAME
    mkdir /home/$USERNAME
    chown $USERNAME /home/$USERNAME
    passwd $USERNAME
  • Configure sudo. Using vi, uncomment the sudo group line
    visudo
    - # %sudo ALL=(ALL) ALL
    + %sudo ALL=(ALL) ALL

It should now be possible to log in over SSH using the new username and password.

Create links for shared libraries

Some library files are not found with the same names expected by a standard OpenWrt Chaos Calmer 15.05.1 build. This prevents most packages (and in fact opkg itself) from executing. However, it appears the libraries are included with the system.

Thanks to the instructions found on blog.andreibanaru.ro for this step. It is extended here to include all shared libraries.

  • SSH into the Bridge and run the following commands
    cd /lib
    ln -s libm-1.0.14.so libm.so.0
    ln -s libuClibc-1.0.14.so libc.so.0
    ln -s libutil-1.0.14.so libutil.so.0
    ln -s libdl-1.0.14.so libdl.so.0
    ln -s libcrypt-1.0.14.so libcrypt.so.0
    ln -s libpthread-1.0.14.so libpthread.so.0
    ln -s librt-1.0.14.so librt.so.0
    ln -s libuClibc-1.0.14.so libuClibc.so.0

References

https://github.com/Tristan79/HUEHack

https://blog.andreibanaru.ro/2018/03/27/philips-hue-2-1-enabling-wifi/

http://colinoflynn.com/2016/07/getting-root-on-philips-hue-bridge-2-0/

https://github.com/Rocka84/pushing-hue

https://www.gargoyle-router.com/old-openwrt-coding.html

https://openwrt.org/docs/guide-developer/obtain.firmware.sdk

https://openwrt.org/docs/guide-developer/packages

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.