Jump to content

uniLoader

From postmarketOS Wiki
uniLoader
uniLoader screen example
uniLoader screen example
Name uniLoader
1st stage
Unavailable
2nd stage
Works
Resources source code

uniLoader is a secondary bootloader that is capable of loading Linux for Android and iOS based devices. Such bootloader embeds ramdisk, upstream kernel and dtb into its own binary image (named uniLoader, which is then copied into ram) and finally, after relocating upstream kernel, it jumps to the latter.

Porting

Use uniLoader commit history for porting examples (e.g. this one). Generally you'd need to edit/create these files:

  • board/Makefile
  • board/Kconfig
  • board/<your_vendor>/board-<your_boards_codename>.c
  • configs/<your_boards_codename>_defconfig

Defconfig options

CONFIG_PAYLOAD_ENTRY

Memory address where kernel is loaded.
How to calculate: take address of memory node in DTS and add (+ in hex calculator) deviceinfo_flash_offset_base value you get from pmbootstrap bootimg_analyze (it can be used either with twrp image, or an android image for that device).

CONFIG_RAMDISK_ENTRY

Memory address where ramdisk is loaded.
How to calculate: take linux,initrd-start property in downstream DTS.

CONFIG_TEXT_BASE

Memory address where uniLoader is loaded initially.
How to calculate:

  • Look at bootloader logs (e.g. booting Linux at 0xf00ba0).
  • Use this method from U-Boot. Didn't work on two Exynos devices.
  • Pick arbitrary address from System RAM (look at /proc/iomem in downstream)

CONFIG_POSITION_INDEPENDENT

CONFIG_LINUX_KRNL_HEADER_IMG

Play with these if your uniLoader port doesn't work.