Another way for switching OS (CoreElec + Android).

Post Reply
auPilot
Posts: 29
Joined: Wed Jan 29, 2020 8:42 pm
languages_spoken: english, russian
ODROIDs: Odroid N2
Has thanked: 4 times
Been thanked: 11 times
Contact:

Another way for switching OS (CoreElec + Android).

Post by auPilot » Mon Feb 17, 2020 10:35 pm

How I did a switching between OS for myself.
Just for example.
And sorry for my English.

The main requirement:
- CoreELEC 9.2.1 on uSD
- Android TV (this version: viewtopic.php?f=178&t=35484 ) on eMMC
- switch OS without getting up from the couch (through the IR remote control - not HK IR remote).


How I do this:
1. Installing CoreELEC to uSD (without inserted eMMC).
2. Installing Android TV to eMMC (without inserted uSD).

Everything next was done with inserted eMMC and uSD.

Boot to Android (default boot while eMMC and uSD inserted).

3. Modify boot.ini on eMMC for add dual boot possibility.

/odm/boot.ini in Android:

Code: Select all

ODROIDN2-UBOOT-CONFIG

setenv bootlabel "Custom Dual Boot"

# -----------------------------------------
# local args & vars
# -----------------------------------------
setenv cboot_dev "0"
setenv cboot_ok "0"


# -----------------------------------------
# global args & vars
# -----------------------------------------
setenv max_freq_a73 "1800"
setenv governor_a73 "interactive"
setenv max_freq_a53 "1896"
setenv governor_a53 "interactive"
setenv hdmi_cec "1"
setenv remotewakeup "0xae517f80"
setenv decode_type "0"
setenv remotewakeupmask "0xffffffff"
setenv wol "0"
setenv heartbeat "1"
setenv emmc_timeout "0"
setenv hdmimode "1080p60hz"
setenv voutmode "hdmi"
setenv display_autodetect "true"
setenv osd_reverse "0"
setenv video_reverse "0"
setenv heartbeat "1"

setenv dtb_mem_addr 0x1000000
setenv uenv_addr 0x13000000
setenv display_layer "osd0"

setenv consoleopt "console=ttyS0,115200n8 no_console_suspend earlyprintk=aml-uart,0xff803000 quiet"

# -----------------------------------------
# check uSD presence
# -----------------------------------------
echo " --- Check uSD presence --- "
if load mmc 1 ${uenv_addr} boot.ini; then setenv cboot_ok "1"; fi;


# -----------------------------------------
# loading boot order
# -----------------------------------------
echo " --- Loading order detail --- "
if test "${cboot_ok}" = "1"; then if load mmc 0 ${uenv_addr} boot_order.ini; then env import -t ${uenv_addr} $filesize; fi; fi;


# -----------------------------------------
# run selected OS
# -----------------------------------------
if test "${cboot_dev}" = "0"; then

echo "---------------------------------------------"
echo " Starting Android"
echo "---------------------------------------------"

# -----------------
# Android
# -----------------
setenv mmc_dev "0"
setenv devno "0"
setenv devnum "0"

setenv disable_vu7 "false"
setenv touch_invert_x "false"
setenv touch_invert_y "false"
setenv zoom_rate "100"
setenv colorattribute "444,8bit"
setenv suspend_hdmiphy "1"
setenv sg_tablesize "2"
setenv test_mt_vid "0000"
setenv test_mt_pid "0000"
setenv backlight_pwm "no"

setenv remotewakeup "0x7f808a75"

# Init args
setenv rootopt "rootfstype=ramfs init=/init"
setenv ramoopsopt "ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000"
setenv displayopt "colorattribute=${colorattribute}"
setenv androidopt "androidboot.selinux=permissive androidboot.firstboot=${firstboot} jtag=disable androidboot.hardware=odroidn2 otg_device=1 buildvariant=eng"
setenv miscopt "disable_vu7=${disable_vu7} touch_invert_x=${touch_invert_x} touch_invert_y=${touch_invert_y} zoom_rate=${zoom_rate} test_mt_vid=${test_mt_vid} test_mt_pid=${test_mt_pid} backlight_pwm=${backlight_pwm} suspend_hdmiphy=${suspend_hdmiphy} usb-xhci.tablesize=${sg_tablesize}"
setenv irsetup "remotewakeup=${remotewakeup} decode_type=${decode_type} remotewakeupmask=${remotewakeupmask}"

# boot addr
setenv loadaddr 0x1080000

# Boot Arguments
if test "${display_autodetect}" = "true"; then hdmitx edid; fi
if test "${hdmimode}" = "custombuilt"; then setenv cmode "modeline=${modeline} customwidth=${customwidth} customheight=${customheight}"; fi

setenv initargs "${rootopt} ${consoleopt} ${ramoopsopt} max_freq_a73=${max_freq_a73} max_freq_a53=${max_freq_a53} ${cmode} ${miscopt}"
setenv bootargs "${initargs} ${androidopt} ${displayopt} ${irsetup} cvbsmode=${cvbsmode} hdmimode=${hdmimode} voutmode=${voutmode} cvbscable=${cvbscable} osd_reverse=${osd_reverse} video_reverse=${video_reverse} gpiopower=${gpiopower} enable_wol=${wol}"

movi read boot 0 ${loadaddr}
movi read dtbs 0 ${dtb_mem_addr}

else

# -----------------------------
# CoreELEC
# -----------------------------

echo "---------------------------------------------"
echo " Starting CoreELEC"
echo "---------------------------------------------"


setenv mmc_dev "1"
setenv devno "1"
setenv devnum "1"

setenv rootopt "BOOT_IMAGE=kernel.img boot=UUID=2911-4504 disk=UUID=d64f1eca-7a63-4904-9030-3446e096b23b"

# boot adr
setenv loadaddr 0x11000000

if load mmc ${mmc_dev}:1 ${uenv_addr} config.ini; then env import -t ${uenv_addr} $filesize; fi

if test "${hdmi_cec}" = "0"; then setenv cec "hdmitx=cec0"; fi
if test "${emmc_timeout}" = "1"; then sleep 30; mmc dev 1; mmc dev 0; fi
if test "${gpiopower}" != ""; then setenv gpiopower "gpiopower=${gpiopower}"; fi
if test "${use_rgb_to_yuv}" != ""; then setenv use_rgb_to_yuv "use_rgb_to_yuv=${use_rgb_to_yuv}"; fi
if test "${usbopts}" != ""; then setenv usbopts "usbopts=${usbopts}"; fi
if test "${usbpower}" != ""; then setenv usbpower "enable_system_power=${usbpower}"; fi
if test "${modeline}" != ""; then setenv cmode "modeline=${modeline}"; fi
setenv irsetup "remotewakeup=${remotewakeup} decode_type=${decode_type} remotewakeupmask=${remotewakeupmask}"

setenv initargs "${rootopt} ${consoleopt} max_freq_a53=${max_freq_a53} max_freq_a73=${max_freq_a73} enable_wol=${wol} ${cec} ${irsetup} ${usbpower} ${gpiopower} ${usbopts} ${cmode} hdmimode=${hdmimode} ${use_rgb_to_yuv}"
setenv bootargs "${initargs} ${displayopt}"

load mmc ${mmc_dev}:1 ${loadaddr} kernel.img
load mmc ${mmc_dev}:1 ${dtb_mem_addr} dtb.img

fi

fdt addr ${dtb_mem_addr}
if test "${heartbeat}" = "0"; then fdt set /leds/blueled linux,default-trigger "none"; fi
booti ${loadaddr} - ${dtb_mem_addr}
bootm
DO NOT COPY this boot.ini. In you CoreELEC there will be others UUID for uSD. If you copy this example you must change UUID for correct value (see it in you CoreELEC boot.ini)
This boot.ini support CoreELEC config.ini but not support showlogo function, because in CoreELEC u-boot this function is not the same as in Android TV u-boot.

OS switched by change cboot_dev in file boot_order.ini on eMMC (/odm/boot_order.ini)
If placed in this file cboot_dev=0 device booted from eMMC
If placed in this file cboot_dev=1 device booted from uSD
/odm always (by default) mounted to /media/VFAT in CoreELEC. And this place accessible in Android (via /odm) and in CoreELEC (via /media/VFAT).

4. For Android TV I wrote small app for power off or switch to CoreELEC.
See attachment. App only for ATV and need root. Source included, you may modify it as you need.
Install app and restart to CoreELEC from this app.

5. Add script run_android.sh to CoreELEC /storage forder (do not forget about chmod):

Code: Select all

#!/bin/sh

O_DIR="/media/VFAT"

if [ -d "$O_DIR" ]; then
  echo "cboot_dev=0" > "$O_DIR"/boot_order.ini
  kodi-send --action='Reboot()'
fi
6. In Kodi add custom menu for Shutdown with System.Exec("/storage/run_android.sh")

Thats all.
Currently possible restart from CoreELEC to Android and from Android to CoreELEC via IR remote without getting up from the couch.
By default (wakeup from IR or CEC) loaded latest selected (latest active) OS.

All files in attachment.
DualBoot.rar
(1.21 MiB) Downloaded 29 times
These users thanked the author auPilot for the post (total 4):
istanbulls (Tue Feb 18, 2020 1:11 am) • odroid (Tue Feb 18, 2020 9:29 am) • Gburas (Tue Feb 18, 2020 5:54 pm) • minoccio (Thu Feb 20, 2020 3:56 pm)

minoccio
Posts: 34
Joined: Thu Sep 12, 2019 3:20 pm
languages_spoken: Italian
ODROIDs: N2
Has thanked: 12 times
Been thanked: 4 times
Contact:

Re: Another way for switching OS (CoreElec + Android).

Post by minoccio » Tue Feb 18, 2020 3:51 pm

Very interesting, is it possible to do the opposite, Android on uSD and coreelec on eMMC?

auPilot
Posts: 29
Joined: Wed Jan 29, 2020 8:42 pm
languages_spoken: english, russian
ODROIDs: Odroid N2
Has thanked: 4 times
Been thanked: 11 times
Contact:

Re: Another way for switching OS (CoreElec + Android).

Post by auPilot » Tue Feb 18, 2020 4:22 pm

Android does not boot from uSD in my N2 if present eMMC with CoreELEC and system started from CoreELEC u-boot. :(
I think u-boot from CoreELEC (if CoreELEC installed to eMMC, their u-boot started first by default) does not support Android partitions.
I tried to run Android from uSD with CoreELEC in eMMC, but see this:

Code: Select all

[   11.714611@0] init: bool android::init::FirstStageMount::InitRequiredDevices(): partition(s) not found after polling timeout: odm, product, system, vendor
[   11.723012@0] init: Failed to mount required partitions early ...
[   11.857622@0] reboot: Restarting system with command 'bootloader'
And system restart again and again. :(
Maybe I was doing something wrong.
These users thanked the author auPilot for the post:
minoccio (Thu Feb 20, 2020 3:55 pm)

bright_plastik
Posts: 27
Joined: Tue Apr 21, 2020 9:22 am
languages_spoken: English, Italian, some French.
ODROIDs: N2
Has thanked: 10 times
Been thanked: 6 times
Contact:

Re: Another way for switching OS (CoreElec + Android).

Post by bright_plastik » Thu May 14, 2020 8:45 pm

Hello again auPilot,

I see you're doing a lot of what I'm trying to achieve with my N2.
The "couch bootselection" you made with combination of CE and Android is what I'm trying to do with CE and Ubuntu. I have working IR commands through a smartphone.

I have to admit I only partly understand the scripts you made, and the modifications to the .ini in the partitions.
Could you help me modifying the steps you made to make it work in linux as well?

I would keep CE and Ubuntu on eMMC, if possible, so to free up the uSD for future expandability.

boot.ini from Android and Ubuntu seem to be similar, so maybe I can copy and paste, but what changes are required using only one emmc?

Maybe I'm overseeing something important here. Hope you can help me out.

User avatar
tobetter
Posts: 5101
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 160 times
Been thanked: 494 times
Contact:

Re: Another way for switching OS (CoreElec + Android).

Post by tobetter » Thu May 14, 2020 9:23 pm

Out of curiosity, is there any reason not using the Petitboot in order to switch between install OS?
The Petitboot still has some issues but many of user is using it, I believe.

Paul69
Posts: 1
Joined: Sat Mar 09, 2019 11:11 pm
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: Another way for switching OS (CoreElec + Android).

Post by Paul69 » Fri May 15, 2020 12:00 am

@tobetter,
I think you can't use a IR remote control in Petitboot!
In Petitboot you can only use a Keyboard. ;)

User avatar
tobetter
Posts: 5101
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 160 times
Been thanked: 494 times
Contact:

Re: Another way for switching OS (CoreElec + Android).

Post by tobetter » Fri May 15, 2020 12:15 am

Paul69 wrote:
Fri May 15, 2020 12:00 am
@tobetter,
I think you can't use a IR remote control in Petitboot!
In Petitboot you can only use a Keyboard. ;)
Well...HK stock remote works. :)

User avatar
mad_ady
Posts: 7922
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 504 times
Been thanked: 350 times
Contact:

Re: Another way for switching OS (CoreElec + Android).

Post by mad_ady » Fri May 15, 2020 2:39 am

If you have a phone with ir blaster you can emulate the HK remote with irplus.

bright_plastik
Posts: 27
Joined: Tue Apr 21, 2020 9:22 am
languages_spoken: English, Italian, some French.
ODROIDs: N2
Has thanked: 10 times
Been thanked: 6 times
Contact:

Re: Another way for switching OS (CoreElec + Android).

Post by bright_plastik » Fri May 15, 2020 7:38 am

mad_ady wrote:
Fri May 15, 2020 2:39 am
If you have a phone with ir blaster you can emulate the HK remote with irplus.
Yes, that's exactly right what I found as well...
tobetter wrote:
Thu May 14, 2020 9:23 pm
Out of curiosity, is there any reason not using the Petitboot in order to switch between install OS?
The Petitboot still has some issues but many of user is using it, I believe.
It would be fantastic, but I think petitboot does not turn on the N2. It only recognizes inputs when turned on. That means plugging the power cord, or using a switch (what I'm doing at the moment).
I think something is missing with the code in petitboot to turn on. I will be happy to discover my assumptions are wrong! :lol:

User avatar
tobetter
Posts: 5101
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 160 times
Been thanked: 494 times
Contact:

Re: Another way for switching OS (CoreElec + Android).

Post by tobetter » Fri May 15, 2020 7:47 am

bright_plastik wrote:
Fri May 15, 2020 7:38 am
It would be fantastic, but I think petitboot does not turn on the N2. It only recognizes inputs when turned on. That means plugging the power cord, or using a switch (what I'm doing at the moment).
I think something is missing with the code in petitboot to turn on. I will be happy to discover my assumptions are wrong! :lol:
True, that lets people wake up from their couch instead of waking up ODROID-N2. I think it's worth to try the latest trial version 20200508. Technically, the suspend/resume functionality is supported...it works for me but waiting for confirmation it works form someone else. :D
viewtopic.php?f=182&t=33873&p=292297&hi ... ot#p291733
These users thanked the author tobetter for the post (total 2):
rooted (Fri May 15, 2020 11:28 am) • bright_plastik (Fri May 15, 2020 6:35 pm)

bright_plastik
Posts: 27
Joined: Tue Apr 21, 2020 9:22 am
languages_spoken: English, Italian, some French.
ODROIDs: N2
Has thanked: 10 times
Been thanked: 6 times
Contact:

Re: Another way for switching OS (CoreElec + Android).

Post by bright_plastik » Fri May 15, 2020 5:33 pm

tobetter wrote:
Fri May 15, 2020 7:47 am
I think it's worth to try the latest trial version 20200508.
Wow maestro. Will try straight away.
tobetter wrote:
Fri May 15, 2020 7:47 am
True, that lets people wake up from their couch instead of waking up ODROID-N2.
Either being lazy on a sofa, or a matter of organization... Now I can virtually hide all cables, fit the headless N2 on a shelf in the basement and let the box turn and launch scripts in Ubuntu with only a couple of clicks, without keyboard and mouse! You know I'm a wannabe monero freak!

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest