Mainline u-boot for khadas sbc

@hyphop

Can i boot a coreelec sdcard using mainline uboot ?

  1. u can try
  2. i think yes - but need some modification

I ask because Corelec Documentation states that stock android uboot must be in emmc to boot the coreelec SD/U-Disk.

I tried to boot Coreelec U-Disk using 3-press function key on mainline uboot but it didnt boot into it. Then i converted the U-Disk to fenix Ubuntu mainline and it booted successfully.

Currently I have a running Manjaro on EMMC and dont want to destroy EMMC and only use corelec through U-disk or SD. If you have some free time, please have a look if mainline uboot can boot coreelec with some modification.

Thanks for your efforts and support to khadas users, I really appreciate.

Regards
Yasir

Too much of customization will be needed, have you tried kodi on manjaro?

Coreelec uses legacy proprietary gpu/vpu driver which may or may not work with mainline uboot.

If you still want to use it then flash Android on emmc and flash Manjaro on 1 sd card and coreelc on another sd card. Use the cards when you want to switch os.

Good luck

2 Likes

Hi @Spikerguy

Thanks for the suggestion. I had earlier tried kodi on linux-vim and X11 however performance was very bad. Right now i tried kodi-wayland 19.0 again on linux-rc and mesa-git and seems to be much much faster. The UI is smooth now so maybe I’ll stick with it. I just wanted to check if Coreelec is something else than a glorified KODI or not. In Manjaro, at SDDM we have option to log in directly to KODI, I think that makes it effectively a Core/Libre Elec equivalent .

2 Likes

Mainline u-boot for khadas sbc was updated

  • check topic header Mainline u-boot for khadas sbc for more details and features
  • for last krescue Mainline u-boot image possible write without rewrite exist partition
    (its mean not destructive for emmc installed system - just update uboot area - (not for android)) + before use it please update your krescue to last version - Index of /Firmware/Krescue

meta usage example

curl https://dl.khadas.com/Firmware/uboot/main-line/VIM1.u-boot.sd.bin.meta

##UBOOT_META##
FILE: VIM1.u-boot.sd.bin
UBOOT_VER: 2021.01+
UBOOT_SIZE:    1163776
ENV_OFFSET:    1228800
ENV_SIZE:      32768
SIZE_WITH_ENV: 1261568
MD5: dbf5f960b7f231833640ac12c9693679
DATE: Tue, 27 Apr 2021 12:33:58 +0800
TIME: 1619498038
GIT_COM_ID: 390039c6f5b33e11f00546a3428be88c7edd84a0
GIT_COM_TAG: 0.10
GIT_DOWNLOAD: https://github.com/khadas/khadas-uboot/releases/tag/0.10
GIT_PAGE: https://github.com/khadas/khadas-uboot
DOWNLOAD_LAST: https://dl.khadas.com/Firmware/uboot/mainline/
##UBOOT-META##
##UBOOT##END#
4 Likes

@hyphop

Amazing work, now the ugly looking image which come just before loading the kernel is now fixed! :smiley:

Now the bootloader cleanly moves to load the kernel in this new uboot… Great work…

3 Likes

Can you clarify this point for me? It is impossible from SPI?
What is the general difference between uboot from SPI vs. emmc? What are the pros and cons?
Thank!

@dr_begemot SPI flash is just another tiny chunk of bootable storage present on the device, its advantage is that its completely isolated from your regular system, and if you eMMC is corrupted you can still boot from an external USB device as bootloader is still present on the system (i.e on the SPI flash)

there are no notable cons, other than perhaps corrupting the SPI flash can mean the boot process won’t work but its very easily fixable, the documentation is there to support it :slight_smile:

for the khadas environment there are more usages for the SPI flash than just bootloaders, you can also install krescue for backup inbuilt recovery, which is uber cool, considering this is a feature not many devices have

its your choice of how you want to select a boot pattern for your device :wink:

  • all is same - for SPI and eMMC
  • but we can fully rewrite emmc only if uboot stored in SPI
2 Likes

Thank you hyphop for the documentation - you pull things together in a way that helps me understand more.

3 Likes

Hello @hyphop

I tried compiling khadas vim1 uboot from GitHub - khadas/khadas-uboot: khadas-uboot
Getting error on prepare while compiling on amd64 host but it works fine when compiling it using aarch64 host.

LD dtc
         CC fdtdump.o
In file included from fdtdump.c:14:
fdtdump.c: In function ‘main’:
libfdt/libfdt.h:251:28: error: array subscript ‘struct fdt_header[0]’ is partly outside array bounds of ‘unsigned char[4]’ [-Werror=array-bounds]
  251 |                 fdth->name = cpu_to_fdt32(val); \
      |                 ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
libfdt/libfdt.h:253:1: note: in expansion of macro ‘fdt_set_hdr_’
  253 | fdt_set_hdr_(magic);
      | ^~~~~~~~~~~~
fdtdump.c:216:31: note: while referencing ‘smagic’
  216 |                 unsigned char smagic[FDT_MAGIC_SIZE];
      |                               ^~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:345: fdtdump.o] Error 1
[i] prepare tc DONE

Need to enable

CONFIG_CMD_SETEXPR=y
CONFIG_CMD_FILEENV=y

FileEnv patch here
as it is needed to try home assistant os.
If you can enable this for vim1 and vim3 then I can test home assistant on both the devices.

Thanks.

i will check next time how its works for other hosts - at this moment checked only for x86 amd64

CONFIG_CMD_SETEXPR=y

ok! its will useful for somebody - ADDED

CONFIG_CMD_FILEENV=y

i think no need

our uboot last version use only raw env in mmc/sd/spi by same offset - it make possible to use save/load env in any case (for exampe standalone uboot without any partitions and fs )

Currently needed. It will be helpful if you can add it for me to test.

I am not able to compile it myself as I think the Latest dependencies are causing compilation issue.

I am trying to compile dtc on Manjaro X86_64 where dtc compilation is failing with the error mentioned above.
I tried using the dtc I have on my local host but the uboot which is built is not initiating the board at all.

Hi @hyphop
Can you tell me which host os do you use to compile the uboots?

I will try that os to compile it with the patches. As it fails to compile dtc on manjaro x86_64 host

Thanks.

Tried it on Ubuntu 20.04 X86_64 server and it have missing pkgs, It will be helpful if you can share which are the deps and which host to be used to use your uboot compiling tool.

./make: 112: dtc: not found
./make: 115: dtc: not found

Dtc was compiled with prepare.
I have raised an issue on git

Thanks.

which host to be used to use your uboot compiling tool.

same ubuntu

lets check prepare again

scripts/prepare
opt/bin/dtc -v

Version: DTC 1.6.0-dirty

if u cant prepare dtc from source still possible to install dtc prom repos
sudo apt install device-tree-compiler

and check again

./make_all khadas-vim3
./make_all 

The make script uses python while ubuntu 20.04 calls it pyhton3 so its throwing python command not found too.

Ok thanks.
Will test it.

Ok will Use upstream version.

If you have 10mins then can you just compile from my git and share the vim1 binary?

It will be helpful but i will also try it myself again.

Please share the binary with those 2 patches.

Thanks.

already 1st options

Please compile it from my git for me ?
and share the binary

Thank You. :slight_smile:

i can test CONFIG_CMD_FILEENV options later

try to explain why u need FILEENV?