Mainline u-boot for khadas sbc


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…


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?

@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

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


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


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.


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


ok! its will useful for somebody - ADDED


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


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


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

same ubuntu

lets check prepare again

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

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.


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?

You just have to compile it on your host using my git.

Patch is already present.

Home assistant OS uses it for its use case.

ok added ! add cmd file into env · khadas/khadas-uboot@51f4f14 · GitHub
u can test it already !

1 Like

Hi @hyphop

As asked before can you please add the uboot upstream version used in readme

(GENERATED: Fri 12 Nov 2021 03:31:31 AM UTC)
Just like this can you inform the viewer the version you used.

Is the latest uboot based on U-Boot 2021.07 or U-Boot 2021.10 ?

already :wink:

UBOOT_VER: 2021.07+
UBOOT_SIZE:    1163776
ENV_OFFSET:    1331200
ENV_SIZE:      32768
SIZE_WITH_ENV: 1363968
MD5: 16ea19dd6a0a6c7fec07c998e9966f84
CHK_SUM: 7813209c1124336948c74954acfa5db2
DATE: Fri, 12 Nov 2021 11:30:45 +0800
TIME: 1636687845
GIT_COM_ID: 32764eeaacec6df95a2bb03b47c89f44a97607b6
GIT_COM_TAG: 0.16.4
1 Like

Just add it to readme so it’s easily visible.


OKY will be next time