Booting Linux from a custom bootloader on IMX6DL

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Booting Linux from a custom bootloader on IMX6DL

1,410 Views
gennadiykiryukh
Contributor III

Hello,

I'm working on a custom bootloader for Linux. The final product will not have any common data interfaces like a network, an SD card, USB. The firmware update will be loaded though custom communication channel and because of that my bootloader will have a custom firmware update process.

I've implemented my own programmer tool that boots from SD card and writes the included Kernel, device tree, and RootFS to an SPI flash. It works with no problems.

The kernel image and the device tree in my test load fine when loaded by u-boot on imx6dl-sdb board.

My bootloader is loaded at 0x11000000. If no updates are present in flash, the bootloader reads SPI flash and loads the kernel at address 0x12000000 and the device tree at 0x18000000. I've added a simple checksum calculation once the images are in RAM and the checksums match the original files so that data appears to be intact.

After the images are loaded I branch of to kernel using:

typedef void (*theKernel)(int zero, int arch, uint32_t params);
#define KERNEL_ADDR 0x12000000 // zImage
#define DEVTREE_ADDR 0x18000000 // .dtb

((theKernel) KERNEL_ADDR) (0, 0, DEVTREE_ADDR);

Nothing happens after the call.

I've tried appending the device tree to the kernel image (with the proper options enabled in the kernel configuration) and create a tag structure in memory to boot the old fashion way with the same results. I've added instruction cache invalidation commands before the call with no improvements.  I've added bootargs = "console=ttymxc0,115200 nosmp root=/dev/mmcblk2p2 rootwait rw"; to the device tree ... still nothing.

I known that u-boot may update some records in the device tree such as memory to set the proper memory size and location. In my case the memory parameters are already set in the device tree.

Are there any special configurations steps required for the kernel start loading and printing messages in the terminal?

Thank you in advance.

Labels (3)
0 Kudos
5 Replies

1,023 Views
JayTu
NXP Employee
NXP Employee

You can also enable CONFIG_EARLY_PRINTK to see if any errors occurred before console is initialized.

There is an issue for it on Android N7, kernel: 4.1.15. It's ok if you are on other version of BSP.

See the patch below,

Fix kernel hang while enabling low level debug 

0 Kudos

1,023 Views
gennadiykiryukh
Contributor III

I don't see how the Falcon mode will help me. I still need to implement my firmware update.

I tried recompiling u-boot without network support and it fails to compile complaining about something related to usb and other times giving giving a bunch warnings and stopping at the following error:

drivers/spi/fsl_espi.c:14:28: fatal error: asm/immap_85xx.h: No such file or directory

SPL is not required on IMX6 platforms since DDR can be initialized using DCD block located in the boot device and u-boot can be loaded directly into DDR. If I could make u-boot do what I need, I would go with it.

Alexandre Belloni has a simple loader "whoosh" that is supposed to have a bare minimum to load the kernel. His method does not support a device tree and instead creates ATAG structure in the memory and loads the kernel.

Linux kernel is supposed to support device tree appended to the kernel image:

cat zImage my-dev-tree.dtb > zImage-dtb

I've tried loading this image using u-boot and it fails too. These are the commands that I ran from u-boot:

dhcp
run mmcargs
setenv machid F8C
setenv serverip "..server ip addr.."
tftpboot 0x12000000 zImage-dtb
bootz 0x12000000

Because device tree address is not specified I expect u-boot to create ATAG structure and boot the kernel. 

I don't see anything after "Starting kernel ...".

However, I can boot if I load the kernel and dtb into 0x12000000 and 0x18000000, respectively, and run

bootz 0x12000000 - 0x18000000.

Has anybody tried booting a combined kernel+device tree image on imx6dl ?

0 Kudos

1,023 Views
igorpadykov
NXP Employee
NXP Employee

Hi Gennadiy

one can try to debug it using AN4553 Using Open Source Debugging Tools for Linux on i.MX Processors
http://www.nxp.com/assets/documents/data/en/application-notes/AN4553.pdf

Best regards
igor

0 Kudos

1,023 Views
fabio_estevam
NXP Employee
NXP Employee

In my opinion U-Boot could fit well for your usecase.

It is possible to use it without network support.

I would suggest you to use U-Boot 2017.07 and report any issues you may face to the U-Boot list.

0 Kudos

1,023 Views
fabio_estevam
NXP Employee
NXP Employee

Why do you need a customr bootloader? It is much better if you can use an existing one, such as U-Boot or Barebox.

U-Boot is capable of running a small piece of code from the internal RAM, configure the DDR and then jump directly to the kernel. This is called Falcon mode and imx6sabresd boards have support for it.

Hope this helps.

0 Kudos