Under construction
DebianOn is an effort to document how to install, configure and use Debian on some specific hardware. Therefore potential buyers would know if that hardware is supported and owners would know how get the best out of that hardware. The purpose is not to duplicate the Debian Official Documentation, but to document how to install Debian on some specific hardware. If you need help to get Debian running on your hardware, please have a look at our user support channels where you may find specific channels (mailing list, IRC channel) dedicated to certain types of hardware. |
Translation(s): none
Contents
Models covered
Xiaomi ?MiWifi mini
Specs:
MediaTek MT7620A (includes wifi b/n chip) MIPS SoC 580 MHz, RAM 128MB, Wi-Fi 802.11ac (?MediaTek MT7612), Flash 16MB, 100MiB Ethernet.
Overall Status
Core Components |
||
Boot Standard Kernel: |
|
|
Ethernet interface (): |
|
|
Hard drives: |
USB drives ok |
|
Extra Features |
||
Ethernet switch () |
|
|
WLAN interface Wi-Fi 802.11ac (?MediaTek MT7612) |
|
|
WLAN interface Wi-Fi 802.11b/g (?MediaTek MT7620A) |
|
|
Serial console (you have to solder it) |
|
|
LEDs |
|
Legend :
= OK ;
Unsupported(No Driver) ;
= Error (Couldn't get it working); [?] Unknown, Not Test ; [-] Not-applicable
= Configuration Required;
= Only works with a non-free driver and or firmware
Important Note
This Debian installation is based on the Open WRT kernel and it's modified init system. Please, read this article, it's pretty the same, but it uses old version of ?OpenWrt(without procd). The reason we cannot use approach with preinit scripts is simple: From the Barrier Breaker ?OpenWrt release, preinit system runs in compatibility mode, so it is not executed with PID 1. And we need init to be executed from the PID 1 process.That's why we have to modify init program's C code to spawn debian init instead of procd.
Install OpenWRT on your router and make sure it works before attempting to install Debian. A working and configured OpenWRT system on the internal flash also works as a backup. If the USB drive containing the rootfs breaks, you will lose your Debian server, but at least the network routing still works with OpenWRT. Remember backups.
Installation
Build a custom OpenWRT image
Get ?OpenWrt code
mkdir ~/wrt cd ~/wrt git clone git://github.com/openwrt/openwrt.git git checkout tags/v17.01.4
Configure ?OpenWrt build system
make menuconfig
Set image options:
/Target System->?MediaTek Ralink MIPS
/Subtarget->MT7620 based boards
/Target Profile->Xiaomi ?MiWiFi Mini
/Base system-> block-mount
/Global build settings -> Enable rfkill support
Kernel Modules/Other modules -> kmod-rfkill
This is for systemd
/Global build settings -> Compile kernel with device tmpfs enabled
/Global build settings -> Enable kernel cgroups
Set kernel options:
make kernel_menuconfig
/Kernel type->MIPS FPU Emulator
/File Systems->The Extended 4 (ext4) filesystem
Build ?OpenWrt system
make
Tweaking init
Now we need to patch init system, so that if debian root detected, we launch debian init.
cd openwrt/build_dir/target-mipsel_24kc_musl-1.1.16/procd-2017-08-08-66be6a23/initd
Create init patch. This patch will replace spawn_procd function with spawn_real_init. If debian root mounted, spawn_real_init function will execute debian init, else procd.
What the function spawn_real_init do? It checks, if debian root mounted, if yes - stops the watchdog timer, and exec debian init command. Otherwise it will exec procd.
cat <<EOF >> init_patch > 53c53 > < spawn_procd(struct uloop_process *proc, int ret) > --- > > spawn_real_init(struct uloop_process *proc, int ret) > 54a55,56 > > char *deb_init_args[] = { "/sbin/init", "3", NULL}; > > char *procd_args[] = { "/sbin/procd", NULL}; > 56d57 > < preinitchar *argv[] = { "/sbin/procd", NULL}; > 57a59 > > int is_extroot_mounted = !stat("/etc/debian_version", &s); > 70d71 > < preinitDEBUG(2, "Exec to real procd now\n"); > 79c80,88 > < preinitexecvp(argv[0], argv); > --- > > preinitif (is_extroot_mounted) { > > DEBUG(2, "Exec to debian init now\n"); > > watchdog_set_magicclose(true); > > watchdog_set_stopped(true); > > execvp(deb_init_args[0], deb_init_args); > > } else { > > DEBUG(2, "Exec to openwrt procd now\n"); > > execvp(procd_args[0], procd_args); > > } > 119c128 > < preinitpreinit_proc.cb = spawn_procd; > --- > > preinitpreinit_proc.cb = spawn_real_init; > EOF
Patching!
patch preinit.c init_patch
Build
Build ?OpenWrt again, with modified init.
make
Flash image
Use open wrt guide.
Create debian rootfs
mkdir ~/debian_root_fs cd ~/debian_root_fs debootstrap --arch mipsel stretch .
Configure debian rootfs
Follow the instructions from the above-mentioned article. Install sysvinit system instead of Systemd (I was not able to get Systemd working ). Also install ssh server and configure static network interface ip.
Prepare usb media
Use gparted, create ms-dos partition table on thumb drive, and create two partitions: ext4 partition for debian rootfs, and swap. Then copy created debian rootfs on flash drive.
mount /dev/sd*1 /mnt cp -r ~/debian_root_fs/* /mnt
Ok, now we have a router with Openwrt system, configured to launch debian init, if debian root is mounted (i.e. file /debian_version is present). And we have a debian root filesystem on the flash along with swap partition on it. What we need to do now is configure ?OpenWrt system to mount root filesystem from flash drive(if flash drive is plugged in the router) during the preinit stage. So we need to do some router configuration.
OpenWRT extroot configuration
Set up the external root FS in OpenWRT. The configuration file /etc/config/fstab should have this kind of section: config mount
option target '/'
option fstype 'ext4'
option options 'rw,sync'
option enabled '1'
option enabled_fsck '0'
option device '/dev/sda1'
Launch!
We are ready now. Switch off the router, plug in your flash drive, connect ethernet cable to any port of the router and to you computer, configure your network interface on the computer according to debian rootfs network interface configuration (i.e. both interfaces should be in the same subnet, and turn the router on. You should be able to connnect to the router through ssh.
WiFi
System Summary
lspci
lspci -nn
lsusb
lsusb -v | grep -E '\<(Bus|iProduct|bDeviceClass|bDeviceProtocol)' 2>/dev/null
Resources
Attachments
Some configuration files and sample outputs.
Useful Links
Credits