Can not launch the Android from the official Khadas-homepage

Which system do you use? Android, Ubuntu, OOWOW or others?

Android

Which version of system do you use? Please provide the version of the system here:

ATV V5.0

Please describe your issue below:

I have installed Lakka 4.3 using OOWOW into the eMMC. After that I have installed LibreELEC into a micro SD card and inserted the card into my Khadas VIM3 pro (with Lakka in eMMC). And it works - Khadas launches LibreELEC from the micro SD if the micro SD is inserted. But when I try to burn the ATV from the official homepage of Khadas(VIM3 OS Images [Khadas Docs] - see part “VIM3 Third-party OS Images”)- BalenaEtcher says that the image from “ATV for Khadas VIM3 – Google Drive“ is not bootable. If I try to burn this image using Raspberry Pi imager - it cancels and says - that the image has a wrong image size. After the burning process using BalenaEtcher (I hide the warning) - the Khadas doesn’t want to load from this micro SC. I can not understand - why Khadas can simple load LibreELEC from the micro SD, but Khadas doesn’t want to load the ATV from the same micro SD card? How can I install Android TV (or at least simple Android) in the micro SD card and automatically launch it by inserting the micro SD card and load Lakka, when I eject the micro SD card?

Post a console log of your issue below:




As explained to you in the other thread: If you put Lakka/LE images with mainline (upstream) u-boot on eMMC this will always be used to boot the board because eMMC has a hardcoded boot priority over SD/USB and upstream u-boot does not support the Amlogic proprietary partition scheme used with the Android image. In short; the Lakka/LE image cannot see/read the Android partitions and it cannot boot what it cannot see/read.

As also explained in the other thread, it can work the other way around using the Lakka ‘box’ image which is designed to work with Amlogic u-boot .. as long as you can figure out how to invoke the recovery boot step which causes Amlogic u-boot to look for s905_autoscript etc. on the SD card.

Explain me please some things:

  1. Why I can simple install LibreELEC on the micro SD and launch it by the inserting the micro SD card and launch back Lakka, when I eject the micro SD card?

  2. Why I can not simple replace the LibreELEC on the same micro SD card with Android and make same things?

  3. Why RaspberryPi Imager doesn’t want to burn the official by Khadas recomended ATV on the micro SD card and says: ““File size … is not a multiple of 512 bytes”“. And ImgBurn warns that the image is not bootable?

And one more point I think. I’m sure that even if I clear the eMMC and insert my micro SD with Android in Khadas - I can not load Anroid, but if I replace Android with some other OS - I can load the OS from the micro SD card normally. What do you think about it? I think I don’t need to find the problem in Lakka - something is wrong with Android from Khadas-homepage

  1. You can swap between LE and Lakka with either on eMMC or SD because they both use mainline u-boot that supports extlinux boot config that both distros use. In both scenarios the board boots from eMMC, but the u-boot on eMMC is compiled and configured to check for boot files on SD and eMMC (and if present, use them) else continue to boot from eMMC.
  2. Because a) upstream u-boot used by LE and Lakka does not support the downstream Amlogic proprietary partition scheme needed to boot the Android image, and b) even if it could boot them Amlogic sources for Android images are historically littered with hardcoded assumptions about being run from eMMC and those assumptions will need to be fixed for things to run without other problems.
  3. I’d guess because the Amlogic ROM “img” format for Android is a proprietary format and not the same raw dd copy of a block device “img” format that RPi tools expect. Linux block devices default to a 512-byte sector size so dd image copies of them will be 512 byte aligned too.

Nothing is ‘wrong’ with the Android image. It was simply created with the Amlogic SDK which outputs an Amlogic proprietary eMMC flashable Android ROM image. It uses u-boot which (despit being the downstream vendor-hacked version) means the boot flow (stored in the u-boot environment) can be adapted to do more if needed, and I’ve already explained at a high-level (twice) how LE and Lakka manipulate Android recovery boot via bootscripts to add persistent environment changes.

Correct me, if I didn’t understand right:

Even if I remove the content of the eMMC using OOWOW - I can not launch Android from the micro SD.

I wiil need manually to fill the path to the file “meson-g12b-khadas-vim3.dtb“ inside the file “uEnv.ini“ of the micro SD card.

BUT!

In this case I don’t need to find the hardware-buttons combination to enter the recovery mode - it will be launched by default, because there are no another OSes on the device.

Is it correct?

I am making an assumption, but most Android images are eMMC boot only, so that would be true.

Correct if using Android on eMMC and Lakka “box” image on the SD card. Incorrect if eMMC has been wiped as then you need to use the Lakka “vim3” image which provides u-boot and is pre-configured for extlinux boot.

If eMMC is wiped (and using the Lakka “vim3” image) this is correct.

I would figure out how to access the Android u-boot environment (from within Android) and read the s905_autoscript file from an SD card or USB stick to modify the boot flow. It’s not hard and then the “Android on eMMC” boot flow does what you want.

Well, I have made the dual boot.

I have installed Android on the eMMC and Lakka on micro SD.

To boot the installed-Lakka with corrected “uEnv.ini“ I have used the software “Reboot_to_LibreELEC.apk“ for Android. After that I have successfully booted Lakka. Now I can simple insert/eject the microSD to select one of the OSes. But not so simple - the micro SD card socket is located under the HDMI-cable. Are there any way to load the OS using the side buttons or maybe using a software?

Thanks!

This is not technically impossible but requires you to recompile the Android ROM with the vendor u-boot source modified to implement the desired function. As that’s unlikely to happen:

Put the Lakka image onto a USB stick instead of an SD card and it should be detected. NB: Some Amlogic u-boot implementations only check the USB OTG port for bootable media. I have no idea what the Khadas sources do.

It seems that I have found a solution:

I extract my micro SD with Lakka
I remove the file “aml_autoscript”
I rename the file “s905_autoscript” in "aml_autoscript "
I insert back the micro SD card.

When Android is completely launched - I launch “Reboot_to_LibreELEC” and boot Lakka.
Next reboot loads Android back. It is awesome!

And even when Lakka loads through the Android-launch - it is much faster as I launched before Pinn on Raspberry Pi 4B and selected Lakka from the list of the installed OSes and booted Lakka.
My problem is completely solved. My wife will never know - how I launch Lakka and play them on our TV!