OESF Portal | OESF Forum | OESF Wiki | LinuxPDA | #planetgemini chat on matrix.org | #gemini-pda chat on Freenode | #zaurus and #alarmz chat on Freenode | ELSI (coming soon) | Ibiblio


Welcome Guest ( Log In | Register )

Personal Photo
Personal Statement
jjrv doesn't have a personal statement currently.
Personal Info
Age Unknown
Gender Not Set
Location Unknown
Birthday Unknown
No Information
Joined: 23-January 20
Profile Views: 126*
Last Seen: 1st April 2020 - 05:24 AM
Local Time: Apr 7 2020, 02:35 PM
13 posts (0 per day)
Contact Information
AIM No Information
Yahoo No Information
ICQ No Information
MSN No Information
Contact Private
* Profile views updated each hour



My Content
4 Feb 2020
This is a minimal hassle (relatively speaking) way to run Android and Debian style Linux simultaneously on the Cosmo, with reasonably high performance.

Android apps will keep working the same as always, for example to make calls and use a mobile-optimized browser, but you can also use Linux desktop apps, installed normally using apt-get.

As a fan of Ubuntu and Debian I chose Devuan Linux because it doesn't depend on systemd. Other criticisms aside, it's a fact that systemd isn't particularly compatible with Android, which has its own nonstandard ways for handling some of the same features.

Some of the commands were shamelessly copied from this article on Medium.

I'm probably going to stick with this setup even if an official Linux distribution appears, although a desktop environment designed for the Cosmo would work better. Hopefully that would also be Debian-based without relying too heavily on systemd, allowing porting it to my setup for simultaneous access to Android apps.

The first step is to root the device. There are workarounds like PRoot used in Termux, but rooting the Cosmo is easy and improves performance and flexibility.

Easiest way for me, mostly using a Mac, was to unlock the bootloader, install Magisk Manager by opening this link to the APK on the device, get Ninji's rooted boot image and flash it (this file is for Planet-supplied firmware version 19 only):

fastboot flash boot boot_200118213137_magisk.img

Next you should get a Linux machine and partition an SD card in two primary partitions, first type c "W95 FAT32 (LBA)" and second type 83 (Linux). The purpose of the first partition is to use as additional storage for Android. You only have one SD card slot and it's good to give Android some extra space as well. I used a 500GB SD card, made the first partition 64GB and gave Linux the rest. Now create the filesystems using:

mkfs -t vfat /dev/sdx1
mkfs -t ext4 /dev/sdx2

Replace sdx with the correct device name in the previous and next snippets...

Now you can fetch the Devuan version of debootstrap and use it to transfer a base system installer to the SD card:

mount /dev/sdx2 /mnt
git clone https://git.devuan.org/devuan-packages/debootstrap.git

cd debootstrap
sudo DEBOOTSTRAP_DIR=`pwd` ./debootstrap --verbose --arch arm64 --foreign ascii /mnt http://auto.mirror.devuan.org/merged/

The best processor architecture to choose for the Cosmo is arm64. It works and is the most modern one with precompiled binaries available. For example the older 32-bit armel also works, but there's no precompiled Chromium available for it at the moment.

The --foreign flag omits running some setup commands inside the new system. They won't work on most PCs because all the binaries are for ARM processors. We'll run the second stage later, on the Cosmo.

Ascii is the name of the latest Devuan distribution version at the time of this writing.

Now you can insert the SD card in the Cosmo. The next steps can be done from the command line on any computer that has adb installed, with the Cosmo connected over USB (or locally from the Termux shell):

adb shell
mkdir /data/mnt
mount /dev/block/mmcblk1p2 /data/mnt

echo 'deb http://auto.mirror.devuan.org/merged ascii main contrib non-free' > /data/mnt/etc/apt/sources.list
for f in dev dev/pts proc sys; do mount -o bind /$f /data/mnt/$f; done

export TMPDIR=/tmp
export HOME=/root
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin:/system/bin:$PATH
chroot /data/mnt /bin/bash

debootstrap/debootstrap --second-stage

The new path is needed to find any commands inside the Devuan chroot, which has binaries in wildly different places. In the end it references the old path, so that the shell could find the next chroot command still in the Android directory tree.

It takes a while and in the end it should print:

I: Base system installed successfully.
I have no name!@localhost:/#

There's now a base system installed but it's pretty broken in some ways. Exit the Devuan environment back to Android shell to fix it from outside, then re-enter:


mkdir /data/mnt/dev/shm
mkdir /data/mnt/android
mount -o bind / /data/mnt/android
mount -o bind /data /data/mnt/android/data

echo nameserver `getprop net.dns1` > /data/mnt/etc/resolv.conf
ln -s /proc/mounts /data/mnt/etc/mtab

# You may need to re-run the earlier mount and for loop here if switching between adb shell and Termux.

chroot /data/mnt su -

The shm directory is required for example to avoid Chromium complaining it's out of memory. Mounting the android directory allows accessing the Android root filesystem from Linux. Fixing resolv.conf is necessary to get DNS lookups working during the setup. You may have to re-run the command when switching between mobile and wlan networks, or switch to using some public DNS server like Google's to keep it working longer term.

For some reason I cannot explain, all the mount commands seem to affect only Termux or adb but not both. So if you mount something in adb shell, it's not visible in Termux, and vice versa. Repeating the command in the other environment fixes this, so you may need to re-run the earlier for loop before the last chroot command.

The permissions are still wonky, the root user and apt-get have no Internet access. Let's fix them:

groupadd -g 3001 aid_net_bt_admin
groupadd -g 3002 aid_net_bt
groupadd -g 3003 aid_inet
groupadd -g 3004 aid_inet_raw
groupadd -g 3005 aid_inet_admin

gpasswd -a root aid_net_bt_admin
gpasswd -a root aid_net_bt
gpasswd -a root aid_inet
gpasswd -a root aid_inet_raw
gpasswd -a root aid_inet_admin

usermod -g 3003 _apt

Android has some extra layers of security based on groups, and adding the root user to those groups gives it additional privileges. Apt-get uses its own _apt user and moving it to the inet group is the easiest way to let it download packages. Now exit and re-enter the Devuan environment again to refresh the permissions and initialize apt-get:

chroot /data/mnt su -

apt-get update

You now have a reasonable command line Linux setup that can be entered from Termux by running su, the mount and export commands from the above snippets, followed by chroot /data/mnt su -

A graphical desktop environment would be a nice extra. The Play Store has a free and working SDL-based X server called XServer XSDL. This way the native Android will handle graphical rendering. After installing and starting it, here's how to set up and start a minimal Xfce from inside the Devuan chroot:

apt-get install xfce4-panel xfdesktop4 xfwm4 xfce4-settings xfce4-session xfce4-terminal


You can get Chromium working like this:

apt-get install chromium

ln -s /var/lib/dbus/machine-id /etc/machine-id
/etc/init.d/dbus start

chromium --disable-gpu --no-sandbox

Remaining steps to figure out are setting up a user account and fixing X windows issues: keyboard layout and theme, especially widget and text sizes.
2 Feb 2020
There's a whole thread about rooting on the hardware board but here's all the flashing unlocking steps in one place for a simple method that worked for me without downloading any unofficial tools or drivers.

This method will wipe all your data and settings. I did this immediately after getting my Cosmo so there was nothing to keep.

First in your Cosmo open Settings -> System -> Advanced -> About phone
Press 7 times on Build number.

You can now open a previously hidden menu: Settings -> System -> Advanced -> Developer options
Enable OEM unlocking and USB debugging

It might be a good idea to write down info from submenus under Settings -> Network & internet -> Mobile network -> Advanced -> Access Point Names

Now download This zip containing adb and fastboot.

Unzip it in the terminal and install the commands in your path or just change to the platform-tools directory and prepend ./ to all the following adb and fastboot commands.

Connect the Cosmo left side USB-C port to the Mac. I'm using a 16" MacBook Pro running macOS Catalina, version 10.15.2.

Each command to enter is listed in a CODE block and expected response in a QUOTE block:

adb devices

List of devices attached

There should also be a popup on the Cosmo screen:

Allow USB debugging?
The computer's RSA key fingerprint is: ...

Press OK and try again:

adb devices

List of devices attached

Note the change, unauthorized -> device

adb reboot bootloader

The Cosmo should now restart to a black background and tiny white text in the bottom left:

=> FASTBOOT mode...

Now the fastboot command should start working:

fastboot devices


fastboot flashing unlock

The Cosmo should now ask for confirmation in tiny white text. Press right side of fingerprint sensor button. This will confirm wiping your device! Afterwards, verify the unlocked status:

fastboot getvar unlocked

unlocked: yes
Finished. Total time: 0.001s

Now it's done. Reboot to get back to Android:

fastboot reboot

The planets will spin for quite some time while the device gets wiped.

Afterwards I couldn't get mobile data to work. The fix was to power down, remove the SIM card tray, power on (getting to the homescreen) and off again, reinsert the SIM tray and power on.
You can also compare APN settings (Access Point Names) if you wrote them down in the beginning.

Please reply if there's any problems with these instructions.
24 Jan 2020
I've found this article on how to use Android kernel and userland with Debian between them:
Running Debian Linux on Android device natively

It should set up an ordinary Debian system, with full access to Android that sits inside it while avoiding performance issues that PRoot-based approaches would have.

I mostly do web development and would like to have hardware accelerated WebGL for working on graphics stuff. Android kernel and browser seem like the most likely way to get that working, while otherwise trying to avoid some Android restrictions.

In Play Store there's a package called XServer XSDL (also on GitHub) that I'm hoping could render the Linux desktop without having to resort to VNC.

Could this work on the Cosmo? I'm eager to test myself but haven't received a device yet.

Probably OTA updates are unlikely to work in such a setup? I'm planning to update manually maybe yearly, and browse the web through a Debian-based browser to keep it up to date and avoid vulnerabilities. Android browser would mainly serve for local web app development and testing.
Last Visitors

4 Feb 2020 - 16:02

Other users have left no comments for jjrv.

There are no friends to display.
RSS Lo-Fi Version Time is now: 7th April 2020 - 04:35 AM