Home Private Cloud: A Hands-On Guide
To avoid distracting the kids from studying, our TV at home only gets turned on during holidays. When my wife wanted to binge a show, she’d have to sneak onto the computer – but sitting at a desk is no match for lounging on the couch. During the New Year break, I got the itch to set up Netflix on the TV. After half a day of research, I realized our LeTV wasn’t going to cut it. Time for a TV box.
The N1 Box
After browsing Taobao, I found the N1 box runs Android and can be flashed with custom firmware. I picked one up for about 150 RMB (with remote). These boxes used to be given away for free, but after the company went under, scarcity drove the price up from a few dozen to 150.
Connecting to Wi-Fi
The package arrived quickly – the seller even included a dual-male USB flashing cable and an HDMI cable. I plugged it into power, connected it to the TV, and found a customized Launcher showing only device info and network info. After connecting a mouse and configuring Wi-Fi, the device’s IP address appeared:
Enabling adb
Tap Firmware Version four times. Normally, a Toast message “adb enabled” should appear. From there, you can use adb on your computer to connect to the box remotely:
1 | adb connect 192.168.1.78 |
On success, adb outputs:
1 | connected to 192.168.1.78:5555 |
Once connected, you can install all sorts of apps via adb. For a TV, Kodi is definitely worth trying.
Kodi
For anyone who’s developed Android TV apps, not knowing Kodi is practically embarrassing. Kodi used to be called XBMC. It’s a cross-platform home media center supporting Windows, Linux, macOS, Android, and iOS – extremely powerful. Its cross-platform support is entirely built on a C++ GUI system with a custom XML layout specification. On Android, there’s minimal Java code – even the MainActivity extends NativeActivity. It also supports Python, Samba, UPnP, and more.
Bubble Cloud
Around 2010, cloud computing was all the hype and cloud storage services were popping up everywhere. One day, our boss demonstrated DropBox on his iPhone at an all-hands meeting. We were marveling at how great it was when he suddenly pivoted: “We’re going to build a private cloud!” Everyone was stunned.
Unlike public cloud, a private cloud stores data on devices at home. All end-to-end data access goes through an HTTP Relay Server, so the device doesn’t need a domain name to be accessible from outside the local network – it can even punch through firewalls.
I don’t know who came up with the name “Bubble Cloud,” but it was catchy enough to land on Baidu Baike. The box was built on AMLogic‘s platform. To reduce power consumption, the entire Android Framework was stripped out, leaving only the Kernel and root filesystem. We even modified init.rc – I remember getting stuck because a service wouldn’t start, and after reading through the source line by line, I discovered that service names couldn’t exceed 16 characters.
To better support SATA hard drive mounting, we also modified the Volume Daemon. For the private cloud server, we needed an app server. After evaluating options, we went with Python, porting Python 2.7 to the Android platform.
For LAN file sharing, we ported Samba – which was a nightmare. Android‘s C library is Bionic C, while Samba uses GNU C. Many APIs were missing from the NDK, so we had to implement them ourselves. That’s when I first learned about netlink. For someone three years out of college, that experience was a huge growth opportunity.
Switching to root
Normally, you switch to root via the su (switch user) command, but on the N1 it prompts:
1 | Please enter password! |
Nothing worked – the seller didn’t know, and the internet was no help. Eventually, I found the answer in an online flashing script. Turns out the N1 controls root access via system properties:
1 | adb shell setprop service.phiadb.root 1 |
Then restart the adb service and reconnect:
1 | adb kill-server |
Now running adb shell drops you into:
1 | p230:/ # |
The # prompt means you’re root (regular users see $). To confirm:
1 | p230:/ # whoami |
With root access, the real fun begins.
Flashing Armbian
Back then, a Bubble Cloud box retailed for around 500 RMB with a hardware cost of about 200 RMB. Compared to the N1, the N1 is a steal. One box for the TV wasn’t enough to play with, so I grabbed another. To run Docker, I decided to flash Armbian (Debian Linux for ARM). Before flashing, you’ll need:
- A computer, preferably Windows
Typically you’d use AMLogic‘s USB Burning Tools for a wired flash, but it only runs on Windows and Linux. On macOS, you’ll need to boot from a USB drive instead - A dual-male USB cable (only for wired flashing) – have a few spares
- An Armbian image file – easily found online
- At least one 8GB USB drive – some drives have compatibility issues; I went through a few before finding one that worked
- A bootable USB creator – balena Etcher (skip for wired flashing)
- A USB keyboard
- An HDMI cable
- A display/TV with an HDMI port
- An ethernet cable
Flashing on macOS is straightforward:
- Confirm the stock Android firmware has been downgraded (plenty of guides online)
- Create a bootable USB drive with balena Etcher
- Power off the N1
- Plug in the ethernet cable
- Connect the HDMI display
- Insert the USB drive
- Connect the USB keyboard
- Power on the N1
- Boot into the stock Android system, tap firmware version four times to enable ADB
- On your computer, connect to the N1 via adb:
1
adb connect 192.168.1.101
- Boot from USB:
1
adb shell reboot update
If you see Linux boot logs, the USB boot succeeded. Otherwise, try a different USB drive. After boot, you’ll be prompted to log in:
- Username: root
- Password: 1234
After logging in, you’ll see the AML S9XXX logo:
1 | _ __ __ _ ____ ___ |
At this point, you haven’t actually flashed yet – you’ve only booted from USB. To run Armbian without the USB drive, you need to write the USB contents to the eMMC storage. There are built-in scripts in the root directory:
1 | root@amlogic:~# ls -l |
Just run install-to-emmc.sh. If you want docker and zerotier too, install them first:
1 | ./install-docker.sh && ./install-zerotier.sh && ./install-to-emmc.sh |
If you’re not comfortable with the Docker command line, install portainer, a web-based Docker client:
1 | docker volume create portainer_data && docker run -d \ |
Watching Netflix in Peace
When using the N1 as a TV box for Netflix, I initially used Igniter, but it was unreliable – the network would drop mid-movie. To actually finish watching something, I set up a proxy server. I chose trojan as a SOCKS5 proxy, but many devices only support HTTP(S). To bridge this gap, I used privoxy to wrap HTTP(S) requests into the SOCKS5 protocol and forward them to trojan. See: https://github.com/johnsonlee/proxify – fully Dockerized. On the N1, just start it with docker-compose:
1 | git clone https://github.com/johnsonlee/proxify |
Default SOCKS5 port is 1080, HTTP(S) port is 1081.
Software Router
You could also flash openwrt for fun, but proxify covers most daily needs, so I didn’t bother.
- Blog Link: https://johnsonlee.io/2021/01/16/private-cloud-at-home.en/
- Copyright Declaration: 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
