Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled

This commit is contained in:
domenico
2025-06-24 12:51:15 +02:00
commit 27c9d80f51
10493 changed files with 1885777 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2016 Jiang Yutang <jiangyutang1978@gmail.com>
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
LS_SD_KERNELPART_SIZE = 40
LS_SD_KERNELPART_OFFSET = 16
LS_SD_ROOTFSPART_OFFSET = 64
ifeq ($(DUMP),)
LS_SD_IMAGE_SIZE = $(shell echo $$((($(LS_SD_ROOTFSPART_OFFSET) + \
$(CONFIG_TARGET_ROOTFS_PARTSIZE)))))
endif
# The limitation of flash sysupgrade.bin is 1MB dtb + 16MB kernel + 32MB rootfs
LS_SYSUPGRADE_IMAGE_SIZE = 49m
define Image/Prepare
# Build .dtb for all boards we may run on
$(foreach dts,$(DEVICE_DTS_LIST),
$(call Image/BuildDTB,$(DTS_DIR)/$(dts).dts,$(DTS_DIR)/$(dts).dtb)
)
endef
define Build/ls-clean
rm -f $@
endef
define Build/ls-append
dd if=$(STAGING_DIR_IMAGE)/$(1) >> $@
endef
define Build/ls-append-dtb
dd if=$(DEVICE_DTS_DIR)/$(1).dtb >> $@
endef
define Build/ls-append-kernel
mkdir -p $@.tmp && \
cp $(IMAGE_KERNEL) $@.tmp/fitImage && \
make_ext4fs -J -L kernel -l "$(LS_SD_KERNELPART_SIZE)M" \
$(if $(SOURCE_DATE_EPOCH),-T $(SOURCE_DATE_EPOCH)) \
"$@.kernel.part" "$@.tmp" && \
dd if=$@.kernel.part >> $@ && \
rm -rf $@.tmp && \
rm -f $@.kernel.part
endef
define Build/ls-append-sdhead
./gen_sdcard_head_img.sh $(STAGING_DIR_IMAGE)/$(1)-sdcard-head.img \
$(LS_SD_KERNELPART_OFFSET) $(LS_SD_KERNELPART_SIZE) \
$(LS_SD_ROOTFSPART_OFFSET) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
dd if=$(STAGING_DIR_IMAGE)/$(1)-sdcard-head.img >> $@
endef
define Build/traverse-fit-ls1088
./mkits-multiple-config.sh -o $@.its -A $(LINUX_KARCH) \
-v $(LINUX_VERSION) -k $@ -a $(KERNEL_LOADADDR) \
-e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
-C gzip -c 1 -c 2 \
-d $(DTS_DIR)/freescale/fsl-ls1088a-ten64.dtb \
-D "TEN64" -n "ten64" -a $(FDT_LOADADDR) -c 1 \
-d $(DTS_DIR)/freescale/fsl-ls1088a-rdb.dtb \
-D "LS1088ARDB" -n "ls1088ardb" -a $(FDT_LOADADDR) -c 2
PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
@mv -f $@.new $@
endef
define Device/fix-sysupgrade
DEVICE_COMPAT_VERSION := 2.0
DEVICE_COMPAT_MESSAGE := DTB was added to sysupgrade. Image format is different. \
To use sysupgrade You need to change firmware partition in bootargs to "49m@0xf00000(firmware)" and saveenv. \
After that, You can use "sysupgrade -F".
endef
define Device/rework-sdcard-images
DEVICE_COMPAT_VERSION := 2.0
DEVICE_COMPAT_MESSAGE := SD-card images were changed to squashfs + ext4 overlay combined images. \
It is required to flash the entire sd-card again and manually copy config.
endef
include $(SUBTARGET).mk
$(eval $(call BuildImage))

View File

@@ -0,0 +1,83 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright 2018-2020 NXP
define Device/Default
PROFILES := Default
FILESYSTEMS := squashfs
IMAGES := firmware.bin sysupgrade.bin
ifdef CONFIG_LINUX_6_1
DEVICE_DTS_DIR := $(DTS_DIR)
else
DEVICE_DTS_DIR := $(DTS_DIR)/nxp/ls
endif
KERNEL := kernel-bin | uImage none
KERNEL_INITRAMFS = kernel-bin | gzip | fit gzip $$(DEVICE_DTS_DIR)/$$(DEVICE_DTS).dtb
KERNEL_NAME := zImage
KERNEL_LOADADDR := 0x80008000
DEVICE_DTS = $(lastword $(subst _, ,$(1)))
IMAGE_SIZE := 64m
IMAGE/sysupgrade.bin = \
ls-append-dtb $$(DEVICE_DTS) | pad-to 1M | \
append-kernel | pad-to 17M | \
append-rootfs | pad-rootfs | \
check-size $(LS_SYSUPGRADE_IMAGE_SIZE) | append-metadata
endef
define Device/fsl-sdboot
KERNEL = kernel-bin | gzip | fit gzip $$(DEVICE_DTS_DIR)/$$(DEVICE_DTS).dtb
IMAGES := sdcard.img.gz sysupgrade.bin
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
define Device/fsl_ls1021a-twr
$(Device/fix-sysupgrade)
DEVICE_VENDOR := NXP
DEVICE_MODEL := TWR-LS1021A
DEVICE_VARIANT := Default
DEVICE_PACKAGES += layerscape-rcw
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-rcw.bin | pad-to 1M | \
ls-append $(1)-uboot.bin | pad-to 3M | \
ls-append $(1)-uboot-env.bin | pad-to 15M | \
ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
append-kernel | pad-to 32M | \
append-rootfs | pad-rootfs | check-size
endef
TARGET_DEVICES += fsl_ls1021a-twr
define Device/fsl_ls1021a-twr-sdboot
$(Device/rework-sdcard-images)
$(Device/fsl-sdboot)
DEVICE_VENDOR := NXP
DEVICE_MODEL := TWR-LS1021A
DEVICE_VARIANT := SD Card Boot
DEVICE_DTS := ls1021a-twr
IMAGE/sdcard.img.gz := \
ls-clean | \
ls-append-sdhead $(1) | pad-to 4K | \
ls-append $(1)-uboot.bin | pad-to 3M | \
ls-append $(1)-uboot-env.bin | pad-to 16M | \
ls-append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
append-rootfs | pad-to $(LS_SD_IMAGE_SIZE)M | gzip
endef
TARGET_DEVICES += fsl_ls1021a-twr-sdboot
define Device/fsl_ls1021a-iot-sdboot
$(Device/rework-sdcard-images)
$(Device/fsl-sdboot)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS1021A-IoT
DEVICE_VARIANT := SD Card Boot
DEVICE_DTS := ls1021a-iot
SUPPORTED_DEVICES :=
IMAGE/sdcard.img.gz := \
ls-clean | \
ls-append-sdhead $(1) | pad-to 4K | \
ls-append $(1)-uboot.bin | pad-to 1M | \
ls-append $(1)-uboot-env.bin | pad-to 16M | \
ls-append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
append-rootfs | pad-to $(LS_SD_IMAGE_SIZE)M | gzip
endef
TARGET_DEVICES += fsl_ls1021a-iot-sdboot

View File

@@ -0,0 +1,450 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright 2018-2020 NXP
define Device/Default
PROFILES := Default
IMAGES := firmware.bin sysupgrade.bin
DEVICE_DTS_DIR := $(DTS_DIR)/freescale
DEVICE_DTS = $(subst _,-,$(1))
FILESYSTEMS := squashfs
KERNEL := kernel-bin | gzip | uImage gzip
KERNEL_INITRAMFS = kernel-bin | gzip | fit gzip $$(DEVICE_DTS_DIR)/$$(DEVICE_DTS).dtb
KERNEL_LOADADDR := 0x80000000
IMAGE_SIZE := 64m
IMAGE/sysupgrade.bin = \
ls-append-dtb $$(DEVICE_DTS) | pad-to 1M | \
append-kernel | pad-to 17M | \
append-rootfs | pad-rootfs | \
check-size $(LS_SYSUPGRADE_IMAGE_SIZE) | append-metadata
endef
define Device/fsl-sdboot
KERNEL = kernel-bin | gzip | fit gzip $$(DEVICE_DTS_DIR)/$$(DEVICE_DTS).dtb
IMAGES := sdcard.img.gz sysupgrade.bin
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
define Device/fsl_ls1012a-frdm
DEVICE_VENDOR := NXP
DEVICE_MODEL := FRDM-LS1012A
DEVICE_PACKAGES += \
layerscape-ppfe \
trusted-firmware-a-ls1012a-frdm \
kmod-ppfe
BLOCKSIZE := 256KiB
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 10M | \
ls-append pfe.itb | pad-to 15M | \
ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
append-kernel | pad-to $$(BLOCKSIZE) | \
append-rootfs | pad-rootfs | check-size
IMAGE/sysupgrade.bin := \
append-kernel | pad-to $$(BLOCKSIZE) | \
append-rootfs | pad-rootfs | \
check-size $(LS_SYSUPGRADE_IMAGE_SIZE) | append-metadata
KERNEL := kernel-bin | gzip | fit gzip $$(DEVICE_DTS_DIR)/$$(DEVICE_DTS).dtb
endef
TARGET_DEVICES += fsl_ls1012a-frdm
define Device/fsl_ls1012a-rdb
$(Device/fix-sysupgrade)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS1012A-RDB
DEVICE_PACKAGES += \
layerscape-ppfe \
trusted-firmware-a-ls1012a-rdb \
kmod-hwmon-ina2xx \
kmod-iio-fxas21002c-i2c \
kmod-iio-fxos8700-i2c \
kmod-ppfe
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 10M | \
ls-append pfe.itb | pad-to 15M | \
ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
append-kernel | pad-to 32M | \
append-rootfs | pad-rootfs | check-size
endef
TARGET_DEVICES += fsl_ls1012a-rdb
define Device/fsl_ls1012a-frwy-sdboot
$(Device/rework-sdcard-images)
$(Device/fsl-sdboot)
DEVICE_VENDOR := NXP
DEVICE_MODEL := FRWY-LS1012A
DEVICE_PACKAGES += \
layerscape-ppfe \
trusted-firmware-a-ls1012a-frwy-sdboot \
kmod-ppfe
DEVICE_DTS := fsl-ls1012a-frwy
IMAGES += firmware.bin
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-bl2.pbl | pad-to 128K | \
ls-append pfe.itb | pad-to 384K | \
ls-append $(1)-fip.bin | pad-to 1856K | \
ls-append $(1)-uboot-env.bin | pad-to 2048K | \
check-size 2097153
IMAGE/sdcard.img.gz := \
ls-clean | \
ls-append-sdhead $(1) | pad-to 16M | \
ls-append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
append-rootfs | pad-to $(LS_SD_IMAGE_SIZE)M | gzip
endef
TARGET_DEVICES += fsl_ls1012a-frwy-sdboot
define Device/fsl_ls1028a-rdb
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS1028A-RDB
DEVICE_VARIANT := Default
KERNEL = kernel-bin | gzip | fit gzip $$(DEVICE_DTS_DIR)/$$(DEVICE_DTS).dtb
DEVICE_PACKAGES += \
trusted-firmware-a-ls1028a-rdb \
kmod-hwmon-ina2xx \
kmod-hwmon-lm90 \
kmod-rtc-pcf2127
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 16M | \
append-kernel | \
append-rootfs | pad-rootfs | check-size
IMAGE/sysupgrade.bin := \
append-kernel | \
append-rootfs | pad-rootfs | \
check-size $(LS_SYSUPGRADE_IMAGE_SIZE) | append-metadata
endef
TARGET_DEVICES += fsl_ls1028a-rdb
define Device/fsl_ls1028a-rdb-sdboot
$(Device/fsl-sdboot)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS1028A-RDB
DEVICE_VARIANT := SD Card Boot
DEVICE_DTS := fsl-ls1028a-rdb
DEVICE_PACKAGES += \
trusted-firmware-a-ls1028a-rdb-sdboot \
kmod-hwmon-ina2xx \
kmod-hwmon-lm90 \
kmod-rtc-pcf2127
IMAGE/sdcard.img.gz := \
ls-clean | \
ls-append-sdhead $(1) | pad-to 4K | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 16M | \
ls-append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
append-rootfs | pad-to $(LS_SD_IMAGE_SIZE)M | gzip
endef
TARGET_DEVICES += fsl_ls1028a-rdb-sdboot
define Device/fsl_ls1043a-rdb
$(Device/fix-sysupgrade)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS1043A-RDB
DEVICE_VARIANT := Default
DEVICE_PACKAGES += \
layerscape-fman \
trusted-firmware-a-ls1043a-rdb \
fmc fmc-eth-config \
kmod-ahci-qoriq \
kmod-hwmon-ina2xx \
kmod-hwmon-lm90
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 9M | \
ls-append $(1)-fman.bin | pad-to 15M | \
ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
append-kernel | pad-to 32M | \
append-rootfs | pad-rootfs | check-size
endef
TARGET_DEVICES += fsl_ls1043a-rdb
define Device/fsl_ls1043a-rdb-sdboot
$(Device/rework-sdcard-images)
$(Device/fsl-sdboot)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS1043A-RDB
DEVICE_VARIANT := SD Card Boot
DEVICE_PACKAGES += \
layerscape-fman \
trusted-firmware-a-ls1043a-rdb-sdboot \
fmc fmc-eth-config \
kmod-ahci-qoriq \
kmod-hwmon-ina2xx \
kmod-hwmon-lm90
DEVICE_DTS := fsl-ls1043a-rdb
IMAGE/sdcard.img.gz := \
ls-clean | \
ls-append-sdhead $(1) | pad-to 4K | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 9M | \
ls-append fsl_ls1043a-rdb-fman.bin | pad-to 16M | \
ls-append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
append-rootfs | pad-to $(LS_SD_IMAGE_SIZE)M | gzip
endef
TARGET_DEVICES += fsl_ls1043a-rdb-sdboot
define Device/fsl_ls1046a-frwy
DEVICE_VENDOR := NXP
DEVICE_MODEL := FRWY-LS1046A
DEVICE_VARIANT := Default
DEVICE_PACKAGES += \
layerscape-fman \
trusted-firmware-a-ls1046a-frwy
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 9M | \
ls-append fsl_ls1046a-rdb-fman.bin | pad-to 15M | \
ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
append-kernel | pad-to 32M | \
append-rootfs | pad-rootfs | check-size
endef
TARGET_DEVICES += fsl_ls1046a-frwy
define Device/fsl_ls1046a-frwy-sdboot
$(Device/fsl-sdboot)
DEVICE_VENDOR := NXP
DEVICE_MODEL := FRWY-LS1046A
DEVICE_VARIANT := SD Card Boot
DEVICE_PACKAGES += \
layerscape-fman \
trusted-firmware-a-ls1046a-frwy-sdboot
DEVICE_DTS := fsl-ls1046a-frwy
IMAGE/sdcard.img.gz := \
ls-clean | \
ls-append-sdhead $(1) | pad-to 4K | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 9M | \
ls-append fsl_ls1046a-rdb-fman.bin | pad-to 16M | \
ls-append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
append-rootfs | pad-to $(LS_SD_IMAGE_SIZE)M | gzip
endef
TARGET_DEVICES += fsl_ls1046a-frwy-sdboot
define Device/fsl_ls1046a-rdb
$(Device/fix-sysupgrade)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS1046A-RDB
DEVICE_VARIANT := Default
DEVICE_PACKAGES += \
layerscape-fman \
trusted-firmware-a-ls1046a-rdb \
fmc fmc-eth-config \
kmod-ahci-qoriq \
kmod-hwmon-ina2xx \
kmod-hwmon-lm90
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 9M | \
ls-append $(1)-fman.bin | pad-to 15M | \
ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
append-kernel | pad-to 32M | \
append-rootfs | pad-rootfs | check-size
endef
TARGET_DEVICES += fsl_ls1046a-rdb
define Device/fsl_ls1046a-rdb-sdboot
$(Device/rework-sdcard-images)
$(Device/fsl-sdboot)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS1046A-RDB
DEVICE_VARIANT := SD Card Boot
DEVICE_PACKAGES += \
layerscape-fman \
trusted-firmware-a-ls1046a-rdb-sdboot \
fmc fmc-eth-config \
kmod-ahci-qoriq \
kmod-hwmon-ina2xx \
kmod-hwmon-lm90
DEVICE_DTS := fsl-ls1046a-rdb
IMAGE/sdcard.img.gz := \
ls-clean | \
ls-append-sdhead $(1) | pad-to 4K | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 9M | \
ls-append fsl_ls1046a-rdb-fman.bin | pad-to 16M | \
ls-append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
append-rootfs | pad-to $(LS_SD_IMAGE_SIZE)M | gzip
endef
TARGET_DEVICES += fsl_ls1046a-rdb-sdboot
define Device/fsl_ls1088a-rdb
$(Device/fix-sysupgrade)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS1088A-RDB
DEVICE_VARIANT := Default
DEVICE_PACKAGES += \
layerscape-mc \
layerscape-dpl \
trusted-firmware-a-ls1088a-rdb \
restool \
kmod-ahci-qoriq \
kmod-hwmon-ina2xx \
kmod-hwmon-lm90
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 10M | \
ls-append $(1)-mc.itb | pad-to 13M | \
ls-append $(1)-dpl.dtb | pad-to 14M | \
ls-append $(1)-dpc.dtb | pad-to 15M | \
ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
append-kernel | pad-to 32M | \
append-rootfs | pad-rootfs | check-size
endef
TARGET_DEVICES += fsl_ls1088a-rdb
define Device/fsl_ls1088a-rdb-sdboot
$(Device/rework-sdcard-images)
$(Device/fsl-sdboot)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS1088A-RDB
DEVICE_VARIANT := SD Card Boot
DEVICE_PACKAGES += \
layerscape-mc \
layerscape-dpl \
trusted-firmware-a-ls1088a-rdb-sdboot \
restool \
kmod-ahci-qoriq \
kmod-hwmon-ina2xx \
kmod-hwmon-lm90
DEVICE_DTS := fsl-ls1088a-rdb
IMAGE/sdcard.img.gz := \
ls-clean | \
ls-append-sdhead $(1) | pad-to 4K | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 10M | \
ls-append fsl_ls1088a-rdb-mc.itb | pad-to 13M | \
ls-append fsl_ls1088a-rdb-dpl.dtb | pad-to 14M | \
ls-append fsl_ls1088a-rdb-dpc.dtb | pad-to 16M | \
ls-append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
append-rootfs | pad-to $(LS_SD_IMAGE_SIZE)M | gzip
endef
TARGET_DEVICES += fsl_ls1088a-rdb-sdboot
define Device/fsl_ls2088a-rdb
$(Device/fix-sysupgrade)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LS2088ARDB
DEVICE_PACKAGES += \
layerscape-mc \
layerscape-dpl \
trusted-firmware-a-ls2088a-rdb \
restool \
kmod-ahci-qoriq
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 10M | \
ls-append $(1)-mc.itb | pad-to 13M | \
ls-append $(1)-dpl.dtb | pad-to 14M | \
ls-append $(1)-dpc.dtb | pad-to 15M | \
ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
append-kernel | pad-to 32M | \
append-rootfs | pad-rootfs | check-size
endef
TARGET_DEVICES += fsl_ls2088a-rdb
define Device/fsl_lx2160a-rdb
DEVICE_VENDOR := NXP
DEVICE_MODEL := LX2160A-RDB
DEVICE_VARIANT := Rev2.0 silicon
DEVICE_PACKAGES += \
layerscape-mc \
layerscape-dpl \
layerscape-ddr-phy \
trusted-firmware-a-lx2160a-rdb \
restool
IMAGE/firmware.bin := \
ls-clean | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 8M | \
ls-append $(1)-fip_ddr_all.bin | pad-to 10M | \
ls-append $(1)-mc.itb | pad-to 13M | \
ls-append $(1)-dpl.dtb | pad-to 14M | \
ls-append $(1)-dpc.dtb | pad-to 15M | \
ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
append-kernel | pad-to 32M | \
append-rootfs | pad-rootfs | check-size
endef
TARGET_DEVICES += fsl_lx2160a-rdb
define Device/fsl_lx2160a-rdb-sdboot
$(Device/fsl-sdboot)
DEVICE_VENDOR := NXP
DEVICE_MODEL := LX2160A-RDB
DEVICE_VARIANT := Rev2.0 silicon SD Card Boot
DEVICE_PACKAGES += \
layerscape-mc \
layerscape-dpl \
layerscape-ddr-phy \
trusted-firmware-a-lx2160a-rdb-sdboot \
restool
DEVICE_DTS := fsl-lx2160a-rdb
IMAGE/sdcard.img.gz := \
ls-clean | \
ls-append-sdhead $(1) | pad-to 4K | \
ls-append $(1)-bl2.pbl | pad-to 1M | \
ls-append $(1)-fip.bin | pad-to 5M | \
ls-append $(1)-uboot-env.bin | pad-to 8M | \
ls-append fsl_lx2160a-rdb-fip_ddr_all.bin | pad-to 10M | \
ls-append fsl_lx2160a-rdb-mc.itb | pad-to 13M | \
ls-append fsl_lx2160a-rdb-dpl.dtb | pad-to 14M | \
ls-append fsl_lx2160a-rdb-dpc.dtb | pad-to 16M | \
ls-append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
append-rootfs | pad-to $(LS_SD_IMAGE_SIZE)M | gzip
endef
TARGET_DEVICES += fsl_lx2160a-rdb-sdboot
define Device/traverse_ten64_mtd
DEVICE_VENDOR := Traverse
DEVICE_MODEL := Ten64 (NAND boot)
DEVICE_NAME := ten64-mtd
DEVICE_PACKAGES += \
uboot-envtools \
kmod-rtc-rx8025 \
kmod-sfp \
kmod-i2c-mux-pca954x \
restool
DEVICE_DESCRIPTION = \
Generate images for booting from NAND/ubifs on Traverse Ten64 (LS1088A) \
family boards. For disk (NVMe/USB/SD) boot, use the armvirt target instead.
FILESYSTEMS := squashfs
KERNEL_LOADADDR := 0x80000000
KERNEL_ENTRY_POINT := 0x80000000
FDT_LOADADDR := 0x90000000
KERNEL_SUFFIX := -kernel.itb
DEVICE_DTS := fsl-ls1088a-ten64
IMAGES := nand.ubi sysupgrade.bin
KERNEL := kernel-bin | gzip | traverse-fit-ls1088 gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb $$(FDT_LOADADDR)
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
IMAGE/nand.ubi := append-ubi
KERNEL_IN_UBI := 1
BLOCKSIZE := 128KiB
PAGESIZE := 2048
MKUBIFS_OPTS := -m $$(PAGESIZE) -e 124KiB -c 600
SUPPORTED_DEVICES = traverse,ten64
endef
TARGET_DEVICES += traverse_ten64_mtd

View File

@@ -0,0 +1,21 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright 2018 NXP
set -x
[ $# -eq 5 ] || {
echo "SYNTAX: $0 <file> <kernel part offset> <kernel size> <rootfs part offset> <rootfs size>"
exit 1
}
OUTPUT="$1"
KERNELOFFSET="$(($2 * 1024))"
KERNELSIZE="$3"
ROOTFSOFFSET="$(($4 * 1024))"
ROOTFSSIZE="$5"
head=4
sect=63
set $(ptgen -o $OUTPUT -h $head -s $sect -t 83 -p ${KERNELSIZE}M@${KERNELOFFSET} -p ${ROOTFSSIZE}M@${ROOTFSOFFSET})

View File

@@ -0,0 +1,600 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Author: Jason Wu <jason.hy.wu@gmail.com>
# with modifications for multi-DTB-same-image by:
# Mathew McBride <matt@traverse.com.au>
#
# U-Boot firmware supports the booting of images in the Flattened Image
# Tree (FIT) format. The FIT format uses a device tree structure to
# describe a kernel image, device tree blob, ramdisk, etc. This script
# creates an Image Tree Source (.its file) which can be passed to the
# 'mkimage' utility to generate an Image Tree Blob (.itb file). The .itb
# file can then be booted by U-Boot (or other bootloaders which support
# FIT images). See doc/uImage.FIT/howto.txt in U-Boot source code for
# additional information on FIT images.
#
# This tools supports:
# - multi-configuration
# - multi-image support - multiple kernel/fdt/ramdsik
# - per image configuration:
# - hash algorithm and generated required subnodes
# - compression
# - signature and generated required subnodes
#
set -e
# image config limit
MAX_IMG=50
# conf config limit
MAX_CONF=10
# declare main data array
declare -a img_array
declare -a conf_array
# initialize array with empty values
for (( index=1; index<=$MAX_IMG; index++ )); do
declare -a img$index
for i in {0..13}; do
eval img${index}[$i]=""
done
done
for (( index=1; index<=$MAX_CONF; index++ )); do
declare -a conf$index
for i in {0..9}; do
eval conf${index}[$i]=""
done
done
# imgX array index information
# 0: type of image - kernel, fdt, ramdsik
# 1: image location
# 2: image index
# 3: loadaddr of image
# 4: entrypoint of image
# 5: compression
# 6: hash algorithm
# 7: part of the configuration
# 8: Human friend name for the image
# 9: key file name
# 10: signature
# 11: conf friendly name
# confX array index information
# 0: conf number
# 1: kernel conf
# 2: fdt conf
# 3: rootfs conf
# 4: kernel key file
# 5: fdt key file
# 6: rootfs key file
# 7: kernel sign_algorithm
# 8: fdt sign_algorithm
# 9: rootfs sign_algorithm
# 10: conf friendly name
usage() {
echo "Usage: `basename $0` -A arch -v version -o its_file" \
"-k kernel -a addr -e entry [-C none] [-h sha1] [-c conf]"
echo -e "Example1:\n\tkernel image ker_img1 with no compression +"
echo -e "\tsha1 hash + fdt dtb1 with sha1 and crc32 hash for conf 1"
echo -e "\t $ `basename $0` -A arm -v 4.4 \ "
echo -e "\t -k ker_img1 -C none -h sha1 -e 0x8000 -a 0x8000 -c 1 \ "
echo -e "\t -d dtb1 -h sha1 -h crc32 -c 1\n"
echo "General settings:"
echo -e "\t-A ==> set architecture to 'arch'"
echo -e "\t-v ==> set kernel version to 'version'"
echo -e "\t-o ==> create output file 'its_file' [optional]"
echo "Input image type:"
echo -e "\t-k ==> kernel image 'kernel'"
echo -e "\t-d ==> Device Tree Blob 'dtb'"
echo -e "\t-r ==> ramdisk image 'ramdisk"
echo "Per image configurations:"
echo -e "\t-C ==> set compression type 'comp'"
echo -e "\t-c ==> set image config (multiple -c allowed)"
echo -e "\t-a ==> set load address to 'addr' (hex)"
echo -e "\t-e ==> set entry point to 'entry' (hex)"
echo -e "\t-D ==> human friendly 'name' (one word only)"
echo -e "\t-h ==> set hash algorithm (multiple -h allowed)"
echo -e "\t-s ==> set signature for given config image"
echo -e "\t-K ==> set key file for given config image"
exit 1
}
array_check()
{
local a=999
local max_a=0
local max_i=0
if echo $1 | grep -q img; then
max_a=$MAX_IMG
max_i=13
let a=$(echo $1 | awk -F "img" '{print $2}')
elif echo $1 | grep -q conf; then
max_a=$MAX_CONF
max_i=10
let a=$(echo $1 | awk -F "conf" '{print $2}')
fi
if [ ${a} -lt 0 -o ${a} -gt ${max_a} -o \
${2} -lt 0 -o ${2} -gt ${max_i} ]; then
echo "WARNING: Invalid array name, skipping!!!"
return 255
fi
}
#
# $1: array name
# $2: index
# $3: value
# $4: append operation
#
array_put()
{
# check if array is declared
array_check $1 $2 || return 0
if [ -z "$4" ]; then
eval $1[$2]=$3
else
eval $1[$2]=\"\${$1[$2]} $3\"
fi
}
#
# $1: array name
# $2: index
#
array_get()
{
local val
eval val=\${$1[$2]}
echo $val
}
parse_args() {
local i=-1 k=-1 d=-1 r=-1
while getopts ":A:a:C:c:D:d:e:h:k:K:o:v:r:s:n:" OPTION; do
case $OPTION in
A ) ARCH=$OPTARG;;
a ) array_put img$i 3 $OPTARG;;
C ) value_sanity_chk compression $OPTARG;
array_put img$i 5 $OPTARG;;
c ) array_put img$i 7 $OPTARG append;;
D ) array_put img$i 8 $OPTARG;;
d ) i=$(($i + 1));
d=$(($d + 1));
img_array[$i]=img$i;
array_put img$i 0 fdt;
array_put img$i 1 $OPTARG;
array_put img$i 2 $d;
;;
e ) array_put img$i 4 $OPTARG;;
h ) value_sanity_chk hash $OPTARG;
array_put img$i 6 $OPTARG append;;
k ) i=$(($i + 1));
k=$(($k + 1));
img_array[$i]=img$i;
array_put img$i 0 "kernel";
array_put img$i 1 $OPTARG;
array_put img$i 2 $k;
;;
K ) array_put img$i 9 $OPTARG;;
n ) array_put img$i 11 $OPTARG;;
o ) OUTPUT=$OPTARG;;
v ) VERSION=$OPTARG;;
r ) i=$(($i + 1));
r=$(($r + 1));
img_array[$i]=img$i;
array_put img$i 0 "ramdisk";
array_put img$i 1 $OPTARG;
array_put img$i 2 $r;
;;
s ) value_sanity_chk signature $OPTARG;
array_put img$i 10 $OPTARG;
;;
* ) echo "Invalid option passed to '$0' (options:$@)"
usage;;
esac
done
shift $(($OPTIND - 1))
[ $# -gt 0 ] && {
echo "Failed to parse all passed arguments (unrecognized: \"$@\")"
exit 1
}
[ -n "${OUTPUT}" ] || OUTPUT=fitimage.its
[ -n "${VERSION}" ] || VERSION="Unknown"
[ -n "${ARCH}" ] || ARCH=arm
}
#
# sanity check for signature, compression and hash
#
value_sanity_chk()
{
local valid=""
case $1 in
signature) valid="sha-1,rsa-2048 sha-256,rsa-2048 sha-256,rsa-4096";;
compression) valid="gzip bzip2 none";;
hash) valid="sha1 md5 crc32";;
esac
if ! echo $valid | grep -q "$2"; then
echo "Error: Invalid $1 provided '$2'"
echo "Valid options are: $valid"
exit 255
fi
}
#
# Emit the fitImage section bits
#
# $1: Section bit type: fitstart - its header
# imagestart - image section start
# confstart - configuration section start
# sectend - section end
# fitend - fitimage end
# $2: optional variable for confstart section
#
emit_its() {
case $1 in
fitstart)
cat << EOF > ${OUTPUT}
/dts-v1/;
/ {
description = "U-Boot fitImage for ${VERSION} kernel";
#address-cells = <1>;
EOF
;;
imagestart)
echo -e "\n\timages {" >> ${OUTPUT};;
confstart)
# echo -e "\tconfigurations {\n\t\tdefault = \"conf@${2:-0}\";" \
echo -e "\tconfigurations {\n" \
>> ${OUTPUT};;
sectend)
echo -e "\t};" >> ${OUTPUT};;
fitend)
echo -e "};" >> ${OUTPUT};;
esac
}
#
# Emit kernel image node
#
emit_kernel() {
local image=${1}
local count=${2:-${MAX_IMG}}
local loaddaddr=${3:-0x8000}
local entrypoint=${4:-0x8000}
local compresson=${5:-none}
local checksum=${6:-sha1}
local name=${7}
[ -z "${name}" ] || name=" ${name}"
cat << EOF >> ${OUTPUT}
kernel@${count} {
description = "Linux Kernel${name}";
data = /incbin/("${image}");
type = "kernel";
arch = "${ARCH}";
os = "linux";
compression = "${compresson}";
load = <${loaddaddr}>;
entry = <${entrypoint}>;
EOF
emit_cksum ${checksum}
if [ -z "$SIGN_IN_CONF" ] ; then
emit_signature "$9" "" "" "$8" "" ""
fi
echo " };" >> ${OUTPUT}
}
#
# Emit fdt node
#
emit_fdt() {
local image=${1}
local count=${2:-${MAX_IMG}}
local compresson=${3:-none}
local checksum=${4:-sha1}
local name=${5}
local loadaddr=${6}
[ -z "${name}" ] || name=" ${name}"
cat << EOF >> ${OUTPUT}
fdt@${count} {
description = "Flattened Device Tree blob${name}";
data = /incbin/("${image}");
type = "flat_dt";
arch = "${ARCH}";
load = <${loadaddr}>;
compression = "none";
EOF
emit_cksum ${checksum}
if [ -z "$SIGN_IN_CONF" ] ; then
emit_signature "" "$7" "" "" "$6" ""
fi
echo " };" >> ${OUTPUT}
}
#
# Emit ramdisk node
#
emit_ramdisk() {
local image=${1}
local count=${2:-${MAX_IMG}}
local compresson=${3:-none}
local checksum=${4:-sha1}
local name=${5}
[ -z "${name}" ] || name=" ${name}"
cat << EOF >> ${OUTPUT}
ramdisk@${count} {
description = "ramdisk${name}";
data = /incbin/("${image}");
type = "ramdisk";
arch = "${ARCH}";
os = "linux";
compression = "${compresson}";
EOF
emit_cksum ${checksum}
if [ -z "$SIGN_IN_CONF" ] ; then
emit_signature "" "" "$7" "" "" "$6"
fi
echo " };" >> ${OUTPUT}
}
#
# Emit check sum sub node
#
emit_cksum() {
csum_list=$@
count=1
for csum in ${csum_list}; do
cat << EOF >> ${OUTPUT}
hash@${count} {
algo = "${csum}";
};
EOF
count=`expr ${count} + 1`
done
}
#
# Emit signature sub node
#
emit_signature() {
local kernel=$1
local fdt=$2
local rootfs=$3
local kernel_key=$4
local fdt_key=$5
local rootfs_key=$6
local imgs=""
local count=0
local chk_list="" algo="" algos="" i=""
for i in kernel fdt rootfs; do
eval algo=\$$i
eval key=\$${i}_key
[ -n "$algo" ] || continue
if ! echo "$algos" | grep -q $algo; then
if [ -z "$algos" ]; then
algos=$algo
else
algos="${algos} $algo"
fi
fi
if ! echo "$keys" | grep -q $key; then
if [ -z "$keys" ]; then
keys=$key
else
keys="${keys} $key"
fi
fi
done
for algo in $algos; do
for key in $keys; do
img=""
for i in kernel fdt rootfs; do
eval tmp_algo=\$$i
eval tmp_key=\$${i}_key
[ "$tmp_algo" == "$algo" ] || continue
[ "$tmp_key" == "$key" ] || continue
if [ -z "$img" ]; then
img=$i
else
img=${img},$i
fi
done
[ -n "$img" ] || continue
cat << EOF >> ${OUTPUT}
signature@${count} {
algo = "${algo}";
key-name-hint = "${key}";
EOF
if [ -n "$SIGN_IN_CONF" ] ; then
echo " sign-images = \"$img\";" >> ${OUTPUT}
fi
echo " };" >> ${OUTPUT}
count=`expr ${count} + 1`
done
done
}
#
# Emit config sub nodes
#
emit_config() {
local conf_csum="sha1"
config_name="conf@${1}"
if [ ! -z "${11}" ]; then
config_name="${11}"
fi
if [ -z "${2}" ]; then
echo "Error: config has no kernel img, skipping conf node!"
return 0
fi
# Test if we have any DTBs at all
if [ -z "${3}" ] ; then
conf_desc="Boot Linux kernel"
fdt_line=""
else
conf_desc="Boot Linux kernel with FDT blob"
fdt_line="
fdt = \"fdt@${3}\";"
fi
# Test if we have any ROOTFS at all
if [ -n "${4}" ] ; then
conf_desc="$conf_desc + ramdisk"
fdt_line="${fdt_line}
ramdisk = \"ramdisk@${4}\";"
fi
kernel_line="kernel = \"kernel@${2}\";"
cat << EOF >> ${OUTPUT}
${config_name} {
description = "${conf_desc}";
${kernel_line}${fdt_line}
hash@1 {
algo = "${conf_csum}";
};
EOF
if [ -n "$SIGN_IN_CONF" ] ; then
emit_signature "$5" "$6" "$7" "$8" "$9" "${10}"
fi
echo " };" >> ${OUTPUT}
}
#
# remove prefix space
#
remove_prefix_space()
{
echo "$@" | sed "s:^ ::g"
}
#
# generate image nodes and its subnodes
#
emit_image_nodes()
{
local t img_c img_i img_index chk
local img_type img_path img_count img_loadadr img_entrypoint \
img_compression img_hash img_conf img_name img_key img_sign \
img_index
emit_its imagestart
for t in "kernel" "fdt" "ramdisk"; do
img_index=0
for a in ${img_array[@]}; do
img_type=$(array_get $a 0)
img_path=$(array_get $a 1)
img_count=$(array_get $a 2)
img_loadadr=$(array_get $a 3)
img_entrypoint=$(array_get $a 4)
img_compression=$(array_get $a 5)
img_hash=$(array_get $a 6)
img_conf=$(array_get $a 7)
img_name=$(array_get $a 8)
img_key=$(array_get $a 9)
img_sign=$(array_get $a 10)
img_cname=$(array_get $a 11)
img_conf=$(remove_prefix_space $img_conf)
img_hash=$(remove_prefix_space $img_hash)
[ "${img_type}" == $t ] || continue
# generate sub nodes
eval chk=\$DEF_$t
[ -n "${chk}" ] || eval DEF_$t=$img_count
case $t in
kernel) emit_kernel "$img_path" "$img_count" \
"$img_loadadr" "$img_entrypoint" \
"$img_compression" "$img_hash" \
"$img_name" "$img_key" "$img_sign";;
fdt) emit_fdt "$img_path" "$img_count" \
"$img_compression" "$img_hash" \
"$img_name" "$img_loadadr" "$img_key" "$img_sign" ;;
ramdisk) emit_ramdisk "$img_path" "$img_count" \
"$img_compression" "$img_hash" \
"$img_name" "$img_key" "$img_sign";;
esac
# set up configuration data
for img_c in $img_conf; do
img_i=""
#set up default configuration if its not set
[ -n "$DEF_CONFIG" ] || DEF_CONFIG=$img_c
[ -z "${img_c}" ] || conf_array[$img_c]=conf$img_c
array_put conf$img_c 0 ${img_c}
case $t in
kernel) img_i=1;;
fdt) img_i=2;;
ramdisk) img_i=3;;
esac
array_put conf$img_c $img_i $img_index
array_put conf$img_c $(($img_i + 3)) ${img_sign}
array_put conf$img_c $(($img_i + 6)) ${img_key}
array_put conf$img_c 10 $img_cname
done
img_index=$((img_index + 1))
done
done
emit_its sectend
}
#
# generate configuration node and its subnodes
#
emit_configuration_nodes ()
{
local count kernel fdt ramdisk ker_file fdt_file rfs_file ker_sign \
fdt_sign rfs_sign
emit_its confstart $DEF_CONFIG
for a in ${conf_array[@]}; do
count=$(array_get $a 0)
kernel=$(array_get $a 1)
fdt=$(array_get $a 2)
ramdisk=$(array_get $a 3)
er_file=$(array_get $a 4)
fdt_file=$(array_get $a 5)
rfs_file=$(array_get $a 6)
ker_sign=$(array_get $a 7)
fdt_sign=$(array_get $a 8)
rfs_sign=$(array_get $a 9)
cname=$(array_get $a 10)
emit_config "$count" "$kernel" "$fdt" "$ramdisk" "$ker_file" \
"$fdt_file" "$rfs_file" "$ker_sign" "$fdt_sign" \
"$rfs_sign" "${cname}"
done
if [ -z "${DEF_CONFIG}" ]; then
emit_config "0" "$DEF_kernel" "$DEF_fdt" "$DEF_ramdisk"
fi
emit_its sectend
}
# Set to none empty to create signature sub node under images node
SIGN_IN_CONF=${SIGN_IN_CONF:-""}
# Set to default config used
DEF_CONFIG=${DEF_CONFIG:-""}
parse_args $@
emit_its fitstart
emit_image_nodes
emit_configuration_nodes
emit_its fitend