How to install on SD from Android

Hi all ELEC-users!
I want to suggest a way to install *ELEC .img.gz on an external sd-card from the android terminal emulator.

  1. Load tv-box into Android
  2. Insert and formatting sd-card
  3. Installing terminal emulator from Google Play store.
  4. Donwnload file of rom *.img.gz in empty directory
  5. Open terminal and input code:
cd /sdcard/<folder with rom>
su
gunzip -c ./*.img.gz | dd of=/dev/block/mmcblk1 bs=4096
  1. Extract/insert sd-card, going into root sd and copy your device tree (dtb.img)
cd /storage/<mount dir>/device_trees
cp -fv ./<your dtb> ../dtb.img
reboot update
  1. Enjoy! Your device will reboot into ELEC system…
2 Likes

Important Note: /dev/block/mmcblk1 is device specific and might not be the same on other devices.
And if it somehow refers to the bootloader partition, you’ll brick your android device.
dd command is dangerous for those who don’t know what they are doing.

1 Like

No, mmcblk1 is the standard partition table for the external sdcard, as well as mmcblk0 for the internal one. This rule is suitable for all android devices from version 1.6 and up to 8.0

How can we mount the internal eMMC filesystem so that we can see it from coreelec?

Using a loop block device.

dmesg | grep blk0

will show you the offsets and sizes of the partitions

CoreELEC:/dev # dmesg | grep blk0
[ 0.870401@2] mmcblk0: emmc:0001 032G74 29.1 GiB
[ 0.870655@2] mmcblk0boot0: emmc:0001 032G74 partition 1 4.00 MiB
[ 0.874913@2] mmcblk0boot1: emmc:0001 032G74 partition 2 4.00 MiB
[ 0.879201@2] mmcblk0rpmb: emmc:0001 032G74 partition 3 4.00 MiB
[ 0.882486@2] meson-mmc: [mmcblk0p01] bootloader offset 0x000000000000, size 0x000000400000
[ 0.882931@2] meson-mmc: [mmcblk0p02] reserved offset 0x000002400000, size 0x000004000000
[ 0.882966@2] meson-mmc: [mmcblk0p03] cache offset 0x000006c00000, size 0x000046000000
[ 0.886751@2] meson-mmc: [mmcblk0p04] env offset 0x00004d400000, size 0x000000800000
[ 0.886842@2] meson-mmc: [mmcblk0p05] logo offset 0x00004e400000, size 0x000000800000
[ 0.886854@2] meson-mmc: [mmcblk0p06] recovery offset 0x00004f400000, size 0x000001800000
[ 0.886866@2] meson-mmc: [mmcblk0p07] misc offset 0x000051400000, size 0x000000800000
[ 0.887052@2] meson-mmc: [mmcblk0p08] dtbo offset 0x000052400000, size 0x000000800000
[ 0.887066@2] meson-mmc: [mmcblk0p09] cri_data offset 0x000053400000, size 0x000000800000
[ 0.887076@2] meson-mmc: [mmcblk0p10] param offset 0x000054400000, size 0x000001000000
[ 0.887086@2] meson-mmc: [mmcblk0p11] boot offset 0x000055c00000, size 0x000001000000
[ 0.887097@2] meson-mmc: [mmcblk0p12] rsv offset 0x000057400000, size 0x000001000000
[ 0.887109@2] meson-mmc: [mmcblk0p13] metadata offset 0x000058c00000, size 0x000001000000
[ 0.887119@2] meson-mmc: [mmcblk0p14] vbmeta offset 0x00005a400000, size 0x000000200000
[ 0.887130@2] meson-mmc: [mmcblk0p15] tee offset 0x00005ae00000, size 0x000002000000
[ 0.887141@2] meson-mmc: [mmcblk0p16] vendor offset 0x00005d600000, size 0x000046000000
[ 0.887152@2] meson-mmc: [mmcblk0p17] odm offset 0x0000a3e00000, size 0x000008000000
[ 0.887310@2] meson-mmc: [mmcblk0p18] system offset 0x0000ac600000, size 0x000050000000
[ 0.887329@2] meson-mmc: [mmcblk0p19] product offset 0x0000fce00000, size 0x000008000000
[ 0.887341@2] meson-mmc: [mmcblk0p20] data offset 0x000105600000, size 0x000642600000
[ 1.128228@0] hdmitx: edid: blk0 raw data
[ 39.016250@1] hdmitx: edid: blk0 raw data

They are on hex, convert to decimal and create a loop device

For instance, mounting the data partition of the android, wich is the bigest one, of my system on /tmp/mnt

#finding the offset of the data partition
printf “%d\n” $(dmesg | grep mmcblk | grep ’ data’ | awk ‘{ print $7}’| sed “s/.$//g” | head -n 1)
4385144832
#creating de mount point
mkdir /tmp/mnt
#creating de loop device
losetup -f -o 4385144832 /dev/mmcblk0
#mounting the loop device
mount /dev/loop1 /tmp/mnt

Thats it!

After using …

#unmounting
umount /tmp/mnt
#erase the mount point
rm -r /tmp/mnt
#and finaly delete loop device
losetup -D

1 Like