Booting linux kernel with U-Boot on Hikey 620 LeMaker


#1

I am trying to boot linux kernel through U-Boot commandline.

Linux Compilation :

git clone https://github.com/suihkulokki/linux.git
git checkout -t origin/hikey-v4.15
export ARCH=arm64
export CROSS_COMPILE=/opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
make -j112

This gives me vmlinux. Now I did the following to generate a uImage :
${CROSS_COMPILE}-objcopy -O binary -R .note -R .comment -S vmlinux linux.bin
gzip -9 linux.bin
mkimage -A arm64 -O linux -T kernel -C gzip -a 0x80080000 -e 0x80080000 -n “Linux Kernel Image” -d linux.bin.gz uImage

Now I create 1 FAT32 partition (having uImgae) and 1 ext4 partition (having busybox rootfs)

Now in U-Boot console :
usb start
fatload usb 0:1 0x80080000 uImage
bootm 0x80080000

I get the following error :

“Synchronous Abort” handler, esr 0x96000210
elr: 0000000035019510 lr : 00000000350117cc (reloc)
elr: 000000003ef56510 lr : 000000003ef4e7cc
x0 : 0000000080080000 x1 : 0000000000000000
x2 : 0000000000000002 x3 : 0000000080080000
x4 : 000000003ef872e3 x5 : 0000000000000008
x6 : 0000000000000000 x7 : 0000000000000010
x8 : 0000000000000044 x9 : 0000000000000008
x10: 000000003e73d270 x11: 000000003e73e8a8
x12: 0000000000000000 x13: 0000000000000200
x14: 0000000000000000 x15: 00000000ffffffff
x16: 0000000000001110 x17: 0000000000000000
x18: 000000003e73ada8 x19: 000000003efa2f70
x20: 000000000000071f x21: 0000000000000001
x22: 000000003e73d3e8 x23: 0000000080080000
x24: 000000003ef98288 x25: 0000000000000000
x26: 000000003efa2000 x27: 0000000080080000
x28: 000000003efa2f70 x29: 000000003e738980

Resetting CPU …

I am not sure if the address 0x80080000 I am using is correct or not…


#2

Yes it seems this address is incorrect (looking at hikey memory map it doesn’t seems to be a valid RAM address) implied from following defines in include/configs/hikey.h:

#define PHYS_SDRAM_1                    0x00000000

/* 1008 MB (the last 16Mb are secured for TrustZone by ATF*/
#define PHYS_SDRAM_1_SIZE               0x3EFFFFFF

#define CONFIG_SYS_SDRAM_BASE           PHYS_SDRAM_1

So you should probably use 0x00080000 as kernel image load address.


#3

I rebuilt the uImage with load address and entry point as 0x80000. Now I see compression related error. Firstly I am not sure if ARCH64 supports compression. That I will check. Linux kernel itself does not have uImage target on arm64.

=> bootm 0x80000

Booting kernel from Legacy Image at 00080000 …

Image Name: Naveen Kernel
Image Type: AArch64 Linux Kernel Image (gzip compressed)
Data Size: 8015538 Bytes = 7.6 MiB
Load Address: 00080000
Entry Point: 00080000
Verifying Checksum … OK
Uncompressing Kernel Image … Error: inflate() returned -5
Image too large: increase CONFIG_SYS_BOOTM_LEN
Must RESET board to recover


#4

For convenience I also tried 32-bit compilation since for 32-bit linux kernel supports uImage target.

I get this :

=> bootm 0x80000

Booting kernel from Legacy Image at 00080000 …

Image Name: Linux-4.15.3-00154-gf449b3ca0861
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 8552960 Bytes = 8.2 MiB
Load Address: 00080000
Entry Point: 00080000
Verifying Checksum … OK
Loading Kernel Image … Image too large: increase CONFIG_SYS_BOOTM_LEN

Don’t know why the image size is being reported as large. My uImage has 8.2M size in total.


#5

@insanecoder It looks like CONFIG_SYS_BOOTM_LEN is not defined for hikey platform in u-boot. So it defaults to 8M size. So I would suggest you to define

#define CONFIG_SYS_BOOTM_LEN		(16 << 20)

in include/configs/hikey.h file. I think it should resolve issue with both 64-bit and 32-bit image.


#6

@insanecoder

FYI I’m currently working on converting Hikey MMC and USB drivers to driver model. Will fix these issues along the way and prepare a guide for booting Linux kernel from u-boot.

Thanks,
Mani


#7

@sumit.garg Thanks it helped.

I now get a different error :
=> bootm 0x80000

Booting kernel from Legacy Image at 00080000 …

Image Name: Linux-4.15.3-00154-gf449b3ca0861
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 8552960 Bytes = 8.2 MiB
Load Address: 00080000
Entry Point: 00080000
Verifying Checksum … OK
Loading Kernel Image … OK
FDT and ATAGS support not compiled in - hanging

ERROR ### Please RESET the board

@Mani It would be great if you would post the wiki now (even a rough version would help).

I honestly don’t want to spend time on these recursive errors popping up as I just received my board and I want to compile the uImage and test on my board. Any step-by-step guide would be appreciated.


#8

This is my first time I am working on an ARM architecture. After searching on google, I think I need .dtb file…but I don’t know howto create it. Secondly I read somewhere in u-boot configs that there is a default .dtb file specified.


#9

@insanecoder Will push out the guide by today or tomorrow.

Thanks,
Mani


#10

Hi,

I made some calculations and also built dtb. I now see kernel starting :

fatload usb 0:1 0x80000 uImage
18635328 bytes read in 9810 ms (1.8 MiB/s)
=> fatload usb 0:1 0x8400000 hi6220-hikey.dtb
37925 bytes read in 47 ms (787.1 KiB/s)
=> setenv bootargs 'console=tty1,115200n8 root=/dev/sda2'
=> bootm 0x80000 - 0x8400000
## Booting kernel from Legacy Image at 00080000 ...
   Image Name:   Linux kernel Image
   Image Type:   AArch64 Linux Kernel Image (uncompressed)
   Data Size:    18635264 Bytes = 17.8 MiB
   Load Address: 00080000
   Entry Point:  00080000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 08400000
   Booting using the fdt blob at 0x8400000
   Loading Kernel Image ... OK
   Using Device Tree in place at 0000000008400000, end 000000000840c424

Starting kernel ...

But I want kernel logs as well.

Now 2 questions here :

  1. What is the correct serial port to be specified as bootargs ? I tried ttyS0,ttyS1,ttyS2,tty0,tty1.

  2. While building kernel do I need to enable some configs in order to get logs. (I remember in x86 we need to enable LPSS to support UART and early_printk). Currently I used defconfig as mentioned in this wiki : https://github.com/96boards/documentation/blob/master/consumer/hikey/hikey620/build/linux-kernel.md. In addition to this defconfig generated, do I need to enable anything else from menuconfig?

    make defconfig distro.config
    make -j112


#11

Hi @insanecoder,

You can use below parameters for booting linux kernel from u-boot on HiKey:

setenv bootargs 'console=ttyAMA3,115200 root=/dev/mmcblk0p9';load mmc 1:1 $kernel_addr_r uImage;load mmc 1:1 $fdt_addr_r hi6220-hikey.dtb;bootm $kernel_addr_r - $fdt_addr_r

Basically, it just loads uImage and dtb from SD card partition 1 and starts the kernel. Regarding the serial console, HIKey UART driver in kernel names its ports as ttyAMA so, you should use ttyAMA3 which belongs to UART3. And for root device, you can use any EXT4/2 partition, I just used the eMMC partition 9.

I’m preparing a guide with all these instructions and some patches for u-boot ML.

Hope this helps!

Thanks,
Mani


#12

Aah…ttyAMA3 this is what I wanted. Which Hikey document contains this detail that its ttyAMA* ?

Able to get logs now…also works with BusyBox rootfs.


#13

https://elixir.bootlin.com/linux/v4.20-rc7/source/drivers/tty/serial/amba-pl011.c#L2404

Also, here is the guide I have prepared for booting Linux Kernel from U-Boot. This will show up in our official documentation repo soon.

U-Boot Patches:

https://patchwork.ozlabs.org/project/uboot/list/?submitter=71790