Skip to content

Porting kexec hardboot

Sumit Rajdev edited this page Sep 29, 2016 · 6 revisions

Notes

  • You're gonna need at least some knowledge about C language and kernel structure.

Porting the patch

This consists of simply taking the patch from some other device and trying to apply it as much as possible. Some SoC-specific parts will obviously fail, try to find their equivalents in your kernel tree:

Hard-reboot in arch/arm/kernel/relocate_kernel.S

Can be found here in the patch for mako. This can often be the hardest thing to find out. Try to look for restart.c or reboot.c or something like that in your device's arch/arm/mach-xxx folder and port the restart sequence from that file to assembler. If you are using Tegra 2/3 or MSM SoC, chances are reboot methods currently (or very similar to them) in the patch will work.

Reserving memory for kexec-hardboot page

Can be found here in the patch for mako. You need to find a place where reserving memory is safe, typicaly somewhere around where memory for ram_console is reserved. It probably will be in the board's file. I usually register the page just before the ram_console, which is before the end of the first memory bank.

Setting KEXEC_HB_PAGE_ADDR

Can be found here in the patch for mako. This is highly device-specific. Either apply the patch without this value (-> set it to beggining of the System RAM) and grep dmesg for the value you printk in memory reservation ("Hardboot page reserved at 0x%X") or look into /proc/iomem to see where the first bank of System RAM ends, substract size of ram_console ram and size of the hardboot page from that and you should get the right address.

Setting kexec_hardboot_hook

Can be found here in the patch for mako. This method should contain some device-specific code which needs to be executed during the reboot sequence. Again, can be found in restart.c or reboot.c or something like that in your device's arch/arm/mach-xxx. Chances are you don't need to set anything in here.

Configuring MultiROM's MR_KEXEC_MEM_MIN

Back to MultiROM's configuration in the BoardConfig.mk. This is the value where kernel and initrd are loaded before reboot. It has to be in the first 256MB of System RAM, and it must not be rewrote during the reboot. Again, look at /proc/iomem and select something reasonable, for example flo System RAM's first bank spans from 0x80200000 to 0x88dfffff and the mem-min value I've selected is 0x88dfffff. Now 0x88dfffff+1= 0x88E00000 so it will be defined as value of MR_KEXEC_MEM_MIN.

...
80200000-88dfffff : System RAM
  80208000-810ad21f : Kernel code
  8121e000-8163e293 : Kernel data
...

Clone this wiki locally