feat(arm): add initrd props to dtb at build time

Add initrd properties to the device tree blob at build time, giving
users the ability to run a linux kernel and successfully boot it to
the terminal. Users can boot a linux kernel in a normal flow as well
as in RESET_TO_BL31. This function is an extension of the build time
option "ARM_LINUX_KERNEL_AS_BL33=1".

The build time options INITRD_SIZE or INITRD_PATH will trigger the
insertion of initrd properties in to the DTB. If both options are
provided then the INITRD_SIZE will take precedence.

The available options are:
INITRD_SIZE: Provide the initrd size in dec or hex (hex format must
precede with '0x'.
Example: INITRD_SIZE=0x1000000

INITRD_PATH: Provide an initrd path for the build time to find its
exact size.

INITRD_BASE: A required build time option that sets the initrd base
address in hex format. A default value can be set by the platform.
Example: INITRD_BASE=0x90000000

Change-Id: Ief8de5f00c453509bcc6e978e0a95d768f1f509c
Signed-off-by: Salman Nabi <salman.nabi@arm.com>
This commit is contained in:
Salman Nabi 2024-12-12 17:38:54 +00:00
parent 936a78b581
commit 1c08ff3277
3 changed files with 20 additions and 1 deletions

View file

@ -1638,6 +1638,21 @@ endif #(NEED_BL2U)
# Expand build macros for the different images
ifeq (${NEED_FDT},yes)
$(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
ifneq (${INITRD_SIZE}${INITRD_PATH},)
ifndef INITRD_BASE
$(error INITRD_BASE must be set when inserting initrd properties to the DTB.)
endif
INITRD_SIZE ?= $(shell printf "0x%x\n" $$(stat -Lc %s $(INITRD_PATH)))
initrd_end = $(shell printf "0x%x\n" $$(expr $$(($(INITRD_BASE) + $(INITRD_SIZE)))))
define $(HW_CONFIG)-after +=
$(s)echo " INITRD $(HW_CONFIG)"
$(q)fdtput -t x $@ /chosen linux,initrd-start $(INITRD_BASE)
$(q)fdtput -t x $@ /chosen linux,initrd-end $(initrd_end)
endef
endif
endif #(NEED_FDT)
# Add Secure Partition packages

View file

@ -604,6 +604,7 @@ $(DPRE): $(2) | $$$$(@D)/
$(DOBJ): $(DPRE) $(filter-out %.d,$(MAKEFILE_LIST)) | $$$$(@D)/
$$(s)echo " DTC $$<"
$$(q)$($(ARCH)-dtc) $$(DTC_FLAGS) -d $(DTBDEP) -o $$@ $$<
$$($$@-after)
-include $(DTBDEP)
-include $(DTSDEP)

View file

@ -367,6 +367,10 @@ FVP_HW_CONFIG_DTS := fdts/${FVP_DT_PREFIX}.dts
FDT_SOURCES += ${FVP_HW_CONFIG_DTS}
$(eval FVP_HW_CONFIG := ${BUILD_PLAT}/$(patsubst %.dts,%.dtb,$(FVP_HW_CONFIG_DTS)))
HW_CONFIG := ${FVP_HW_CONFIG}
# Set default initrd base 128MiB offset of the default kernel address in FVP
INITRD_BASE ?= 0x90000000
ifeq (${TRANSFER_LIST}, 0)
FDT_SOURCES += $(addprefix plat/arm/board/fvp/fdts/, \
@ -419,7 +423,6 @@ ifeq (${TRANSFER_LIST}, 1)
include lib/transfer_list/transfer_list.mk
ifeq ($(RESET_TO_BL31), 1)
HW_CONFIG := ${FVP_HW_CONFIG}
FW_HANDOFF_SIZE := 20000
TRANSFER_LIST_DTB_OFFSET := 0x20