[Request] U-Boot with ext4 capabilities



I’ve just noticed that stock u-boot is able to load files from fat filesystems only. I’d like to have support for ext4 filesystems as well. Simply adding CONFIG_FS_EXT4 and CONFIG_CMD_EXT4 to configs/kvim_defconfig doesn’t seem to have any effect, since make kvim_defconfig produces a /build/.config without these options enabled.



You have to add this into board/khadas/configs/kvim.h using #define directive instead of kvim_defconfig.


What do I have to install in order to build U-Boot natively on arm64:

make[2]: arm-none-eabi-cpp: Command not found
make[2]: arm-none-eabi-cpp: Command not found
Makefile:104: recipe for target '/home/ubuntu/khadas/u-boot/build/scp_task/task_entry.s' failed
make[2]: *** [/home/ubuntu/khadas/u-boot/build/scp_task/task_entry.s] Error 127
make[2]: *** Waiting for unfinished jobs....
Makefile:109: recipe for target '/home/ubuntu/khadas/u-boot/build/scp_task/user_task.lds' failed
make[2]: *** [/home/ubuntu/khadas/u-boot/build/scp_task/user_task.lds] Error 127
        CPP misc.s
make[2]: arm-none-eabi-cpp: Command not found
Makefile:99: recipe for target '/home/ubuntu/khadas/u-boot/build/scp_task/misc.s' failed
make[2]: *** [/home/ubuntu/khadas/u-boot/build/scp_task/misc.s] Error 127
gcc-5: error: unrecognized command line option ‘-mthumb’
gcc-5: error: unrecognized command line option ‘-mno-sched-prolog’
Makefile:84: recipe for target '/home/ubuntu/khadas/u-boot/build/scp_task/user_task.o' failed
make[2]: *** [/home/ubuntu/khadas/u-boot/build/scp_task/user_task.o] Error 1
/home/ubuntu/khadas/u-boot/Makefile:896: recipe for target 'bl301.bin' failed
make[1]: *** [bl301.bin] Error 2
Makefile:147: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2


You need to install the tool in your host pc

sudo apt-get install gcc-arm-none-eabi

About more information, you can reference to our document web site


The best way is applying patch like follow:

diff -b --unified -Nr u-boot-aml-2015.01-20170107-orig/arch/arm/cpu/armv8/gxb/firmware/scp_task/Makefile u-boot-aml-2015.01-20170107/arch/arm/cpu/armv8/gxb/firmware/scp_task/Makefile
--- u-boot-aml-2015.01-20170107-orig/arch/arm/cpu/armv8/gxb/firmware/scp_task/Makefile	2017-02-02 01:09:40.000000000 +0300
+++ u-boot-aml-2015.01-20170107/arch/arm/cpu/armv8/gxb/firmware/scp_task/Makefile	2017-02-12 01:21:59.030365797 +0300
@@ -6,7 +6,7 @@
 include $(buildtree)/.config
 # Select ARMv7-m bare-metal toolchain
diff -b --unified -Nr u-boot-aml-2015.01-20170107-orig/arch/arm/cpu/armv8/gxl/firmware/scp_task/Makefile u-boot-aml-2015.01-20170107/arch/arm/cpu/armv8/gxl/firmware/scp_task/Makefile
--- u-boot-aml-2015.01-20170107-orig/arch/arm/cpu/armv8/gxl/firmware/scp_task/Makefile	2017-02-02 01:08:40.000000000 +0300
+++ u-boot-aml-2015.01-20170107/arch/arm/cpu/armv8/gxl/firmware/scp_task/Makefile	2017-02-12 01:21:59.030365797 +0300
@@ -6,7 +6,7 @@
 include $(buildtree)/.config
 # Select ARMv7-m bare-metal toolchain
diff -b --unified -Nr u-boot-aml-2015.01-20170107-orig/arch/arm/cpu/armv8/gxtvbb/firmware/scp_task/Makefile u-boot-aml-2015.01-20170107/arch/arm/cpu/armv8/gxtvbb/firmware/scp_task/Makefile
--- u-boot-aml-2015.01-20170107-orig/arch/arm/cpu/armv8/gxtvbb/firmware/scp_task/Makefile	2017-02-02 01:09:22.000000000 +0300
+++ u-boot-aml-2015.01-20170107/arch/arm/cpu/armv8/gxtvbb/firmware/scp_task/Makefile	2017-02-12 01:21:59.070367526 +0300
@@ -6,7 +6,7 @@
 include $(buildtree)/.config
 # Select ARMv7-m bare-metal toolchain
diff -b --unified -Nr u-boot-aml-2015.01-20170107-orig/arch/arm/cpu/armv8/txl/firmware/scp_task/Makefile u-boot-aml-2015.01-20170107/arch/arm/cpu/armv8/txl/firmware/scp_task/Makefile
--- u-boot-aml-2015.01-20170107-orig/arch/arm/cpu/armv8/txl/firmware/scp_task/Makefile	2017-02-02 01:09:02.000000000 +0300
+++ u-boot-aml-2015.01-20170107/arch/arm/cpu/armv8/txl/firmware/scp_task/Makefile	2017-02-12 01:21:59.070367526 +0300
@@ -6,7 +6,7 @@
 include $(buildtree)/.config
 # Select ARMv7-m bare-metal toolchain

And use needed toolchain by defining the FIRMWARE_CROSS_COMPILE variable.

Also you can take toolchains at ftp://ftp.radix.pro/toolchains/x86_64/1.1.2/

And look at this Makefile as example.


Hi Andrey,

if you’ve already build an u-boot firmware with these feature enabled, I’d be happy to test it instead of getting my own build environment up and running. Have you even tried to build a non-android mainline u-boot for the kvim?



Hi, Uli:
I think the easiest way is what Terry post above, and what you need to do is just install cross compiler on your Host PC:

$ sudo apt-get install gcc-arm-none-eabi

Check Install Extra Toolchains for Amlogic Platform for details.

And, similar with Andrey mentioned, our official U-Boot source code setup CROSS_COMPILE_BL301 as:

commit 2de9e18bb834148403fd76cfa6b55676d81e68fb
Author: Gouwa <gouwa@khadas.com>
Date:   Thu Jul 7 11:52:55 2016 +0800

    BL301: setup the specified cross-compiler for bl301
    TODO: use the unified cross-compiler
    Tips: note to install 'arm-none-eabi-', version 4.8.2 has been verified

diff --git a/arch/arm/cpu/armv8/gxl/firmware/scp_task/Makefile b/arch/arm/cpu/armv8/gxl/firmware/scp_task/Makefile
index 62df876..29221e8 100644
--- a/arch/arm/cpu/armv8/gxl/firmware/scp_task/Makefile
+++ b/arch/arm/cpu/armv8/gxl/firmware/scp_task/Makefile
@@ -6,13 +6,13 @@ include $(buildtree)/include/autoconf.mk
 include $(buildtree)/.config
 # Select ARMv7-m bare-metal toolchain

Btw: If needed, we can compile a new u-boot for you. :slight_smile:


There are two branches for U-Boot on Github:

  • Vim branch for Android OS
  • ubuntu branch for Linux Distro

And the ubuntu branch has already got EXT4 supported.


Hi Gouwa,

this would be really nice if you could provide a ubuntu flavoured u-boot image for sd/emmc which has built-in ext4/ext2 support. I assume the ubuntu flavour uses a different storage scheme which allows modifications to the u-boot environment via fw_printenv/fw_setenv. If yes I’d be happy to know the right environment offset and size.


Booting a 4.10 mainline kernel

Check this Link for the loader bin, which is compile from the latest commit of ubuntu branch on the Github.


Hi Gouwa,

this one works like a charm, thank you very much. What is the difference between these two branches?
This firmware still knows about the Android partitions:

Partition table get from SPL is :
        name                        offset              size              flag
   0: bootloader                         0            400000                  0
   1: reserved                     2400000           4000000                  0
   2: cache                        6c00000                 0                  0
   3: env                          7400000            800000                  0
   4: logo                         8400000           2000000                  1
   5: ramdisk                      ac00000           2000000                  1
   6: rootfs                       d400000         396a00000                  4

so the first effective partition shouldn’t start before sector 0x6A000 (=0xd400000 / 0x200).



Currently, we keep Vim branch same with Amlogic official code style for android.

What do you mean here? do you mean the cache partitions for Android?


OK, and the ubuntu branch? How does it differ w.t.r. to the Vim branch?

The Android partitions occupy the first 212 MB of the storage device, which cannot be used elsewhere. The only purpose is to store the 64kB u-boot environment. Other u-boot versions use the space below sector 2048 to store the u-boot environment, which doesn’t conflict with the standard Linux partitioning scheme (but doesn’t work to boot Android).


Basically, we create a new ubuntu branch is for Linux Distro, and as you can seen, ubuntu branch comes with more simple and brief U-Boot ENV for Linux Distro.

More difference can run this for details:

gouwa@Server:~/project/khadas/ubuntu/u-boot$ git diff Vim..ubuntu  --stat
 arch/arm/include/asm/arch-gxl/reboot.h           |   2 ++
 board/khadas/configs/kvim.h                      | 197 +++++++++++++++++++-------------------------------------------------------------------------------------------
 board/khadas/kvim/firmware/scp_task/dvfs_board.c |   2 +-
 board/khadas/kvim/firmware/scp_task/pwr_ctrl.c   |   6 +---
 board/khadas/kvim/kvim.c                         | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
 common/cmd_reboot.c                              |  14 ++++++++
 scripts/Makefile.autoconf                        |   9 +++--
 7 files changed, 163 insertions(+), 222 deletions(-)

The first five[0-4] partitions except cache partition is needed for every OS included both Android and Linux Distro on Amlogic platform, note that the U-Boot can load and display the LOGO if logo partition got the specified picture format stored on it.


Hm, HK has two different u-boot flavours for the C2 using different disk layouts.


Hi all,

We can reduce the partitions size and remove cache partition by following two patches:


diff -b --unified -Nr u-boot-aml-2015.01-20170107-orig/common/cmd_aml_mmc.c u-boot-aml-2015.01-20170107/common/cmd_aml_mmc.c
--- u-boot-aml-2015.01-20170107-orig/common/cmd_aml_mmc.c	2017-01-29 16:34:06.000000000 +0300
+++ u-boot-aml-2015.01-20170107/common/cmd_aml_mmc.c	2017-03-07 02:01:54.757376978 +0300
@@ -217,7 +217,6 @@
                                 int dev;
                                 u32 n=0;
                                 bool is_part = false;//is argv[2] partition name
-                                bool protect_cache = false;
                                 bool non_loader = false;
                                 int blk_shift;
                                 u64 cnt=0, blk =0,start_blk =0;
@@ -230,7 +229,6 @@
                                         }else if(!strcmp(argv[2], "non_cache")){
                                                 name = "logo";
                                                 dev = find_dev_num_by_partition_name (name);
-                                                protect_cache = true;
                                         else if(!strcmp(argv[2], "non_loader")){
                                                 dev = 1;
@@ -318,12 +316,6 @@
                                                 if (n == 0) { // not error
                                                         // (2) erase all the area after reserve-partition
-                                                        if (protect_cache) {
-                                                                part_info = find_mmc_partition_by_name(MMC_CACHE_NAME);
-                                                                if (part_info == NULL) {
-                                                                        return 1;
-                                                                }
-                                                        }
                                                         start_blk = (part_info->offset + part_info->size + PARTITION_RESERVED) >> blk_shift;
                                                         u64 erase_cnt = (mmc->capacity >> blk_shift) - 1 - start_blk;
                                                         n = mmc->block_dev.block_erase(dev, start_blk, erase_cnt);
diff -b --unified -Nr u-boot-aml-2015.01-20170107-orig/drivers/mmc/emmc_partitions.c u-boot-aml-2015.01-20170107/drivers/mmc/emmc_partitions.c
--- u-boot-aml-2015.01-20170107-orig/drivers/mmc/emmc_partitions.c	2016-11-24 09:48:28.000000000 +0300
+++ u-boot-aml-2015.01-20170107/drivers/mmc/emmc_partitions.c	2017-03-07 02:01:54.757376978 +0300
@@ -89,7 +89,7 @@
     /* prior partitions, same partition name with dts*/
     /* partition size will be overide by dts*/
diff -b --unified -Nr u-boot-aml-2015.01-20170107-orig/include/emmc_partitions.h u-boot-aml-2015.01-20170107/include/emmc_partitions.h
--- u-boot-aml-2015.01-20170107-orig/include/emmc_partitions.h	2016-11-24 09:48:38.000000000 +0300
+++ u-boot-aml-2015.01-20170107/include/emmc_partitions.h	2017-03-07 02:01:54.756376932 +0300
@@ -27,22 +27,22 @@
 #define     MAX_MMC_PART_NAME_LEN           16
-#define     PARTITION_RESERVED              (8*SZ_1M)  // 8MB
-#define     MMC_BOOT_PARTITION_RESERVED     (32*SZ_1M) // 32MB
+#define     PARTITION_RESERVED              (0)         /* default 8MB: size reserver after each partition */
+#define     MMC_BOOT_PARTITION_RESERVED     (0x2*SZ_1M) /* default 32MB: size reserved after 'bootloader' partition */
 #define     MMC_BOOT_NAME                   "bootloader"
-#define     MMC_BOOT_DEVICE_SIZE            (0x4*SZ_1M)
+#define     MMC_BOOT_DEVICE_SIZE            (0x2*SZ_1M) /* currently U-Boot size is approximately 920K */
 #define     MMC_RESERVED_NAME               "reserved"
 #define     MMC_RESERVED_SIZE               (64*SZ_1M)
 #define		MMC_BOTTOM_RSV_SIZE				(0)
-#define     MMC_CACHE_NAME                  "cache"
+// #define     MMC_CACHE_NAME                  "cache"
 // #define     MMC_CACHE_SIZE                  (512*SZ_1M) // this is not used and should be get from spl
 #define     MMC_ENV_NAME                    "env"
-#define     MMC_ENV_SIZE                    (8*SZ_1M)
+#define     MMC_ENV_SIZE                    (0x4*SZ_1M)
 // #define     MMC_KEY_NAME                    "key"
 #define     MMC_KEY_SIZE                    (256*1024)


diff -b --unified -Nr linux-aml-3.14.29-20170119-orig/include/linux/mmc/emmc_partitions.h linux-aml-3.14.29-20170119/include/linux/mmc/emmc_partitions.h
--- linux-aml-3.14.29-20170119-orig/include/linux/mmc/emmc_partitions.h	2016-11-24 09:47:47.000000000 +0300
+++ linux-aml-3.14.29-20170119/include/linux/mmc/emmc_partitions.h	2017-03-07 02:00:29.391523283 +0300
@@ -25,10 +25,10 @@
 #define     SZ_1M                           0x00100000
 /* the size of bootloader partition */
-#define     MMC_BOOT_PARTITION_SIZE         (4*SZ_1M)
+#define     MMC_BOOT_PARTITION_SIZE         (2*SZ_1M)
 /* the size of reserve space behind bootloader partition */
-#define     MMC_BOOT_PARTITION_RESERVED     (32*SZ_1M)
+#define     MMC_BOOT_PARTITION_RESERVED     (2*SZ_1M)
 #define     RESULT_OK                       0
 #define     RESULT_FAIL                     1

Reserved partition is strongly needed for DTB and u-boot partition table structures. I don’t known can we reduce the size of reserved partitions.

I didn’t made pull request because it is specific changed and only Gouwa can make decision about implementation of this into ubuntu branches of Linux and u-boot repositories.

Andrey K.


Hi, Andrey:
I agree that cache partition is not quite needed for Linux Distro, so can you make a pull request and I will take some test then merge into ubuntu branch.



Hi all,

instead of patching the BSP/Android flavoured u-boot source tree, wouldn’t it be better to put some effort to achieve mainline u-boot support. Some recent work related to the Odroid C2 can be found here and here.



Hi Gouwa,

The pull request will take a lot of time because I have to create some organization on GitHub for it. Because I have to make some decision about CM policy. You known that on GitHub you cannot create subdirectories and for splitting projects we have to create organizations and teams. Currently I have to careate three: first for Khadas VIM, second for mainline kernel and third for Amlogic (from their FTP placed tarball).

If you strongly need the pull request I will create mirror on github from a fake temporary account. But these patches very small and I want to warmly ask you to do it by yourself.

Also we need to investigate which is a minimal size of reserved partition.to create final patch.

Best Regards,
Andrey K.


OK, I will do it. (I just wanna keep you name on the commit :slight_smile: )