layerscape: add SD card boot support
authorYangbo Lu <yangbo.lu@nxp.com>
Wed, 18 Jul 2018 06:14:40 +0000 (14:14 +0800)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 22 Sep 2018 19:20:57 +0000 (21:20 +0200)
NOR/QSPI Flash on Layerscape board only has limited 64MB memory size.
Since some boards (ls1043ardb/ls1046ardb/ls1088ardb/ls1021atwr)
could support SD card boot, we added SD boot support for them to put
all things on SD card to meet large memory requirement.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
package/boot/uboot-layerscape/Makefile
package/boot/uboot-layerscape/files/ls1021atwr-sdboot-uEnv.txt [new file with mode: 0644]
package/boot/uboot-layerscape/files/ls1043ardb-sdboot-uEnv.txt [new file with mode: 0644]
package/boot/uboot-layerscape/files/ls1046ardb-sdboot-uEnv.txt [new file with mode: 0644]
package/boot/uboot-layerscape/files/ls1088ardb-sdboot-uEnv.txt [new file with mode: 0644]
package/firmware/layerscape/ls-rcw/Makefile
target/linux/layerscape/Makefile
target/linux/layerscape/image/Makefile
target/linux/layerscape/image/armv7.mk
target/linux/layerscape/image/armv8_64b.mk
target/linux/layerscape/image/gen_sdcard_head_img.sh [new file with mode: 0755]

index 875e08f0e128a05ae90e5a081010241035f90957..ef456bfc7eb7bd0440592ac0ada90ebf74acec4c 100644 (file)
@@ -44,16 +44,34 @@ define U-Boot/ls1043ardb
   ENV_SIZE:=0x20000
 endef
 
+define U-Boot/ls1043ardb-sdboot
+  NAME:=NXP LS1043ARDB SD Card Boot
+  UBOOT_CONFIG:=ls1043ardb_sdcard
+  UBOOT_IMAGE:=u-boot-with-spl-pbl.bin
+endef
+
 define U-Boot/ls1046ardb
   NAME:=NXP LS1046ARDB
   UBOOT_CONFIG:=ls1046ardb_qspi
 endef
 
+define U-Boot/ls1046ardb-sdboot
+  NAME:=NXP LS1046ARDB SD Card Boot
+  UBOOT_CONFIG:=ls1046ardb_sdcard
+  UBOOT_IMAGE:=u-boot-with-spl-pbl.bin
+endef
+
 define U-Boot/ls1088ardb
   NAME:=NXP LS1088ARDB
   UBOOT_CONFIG:=ls1088ardb_qspi
 endef
 
+define U-Boot/ls1088ardb-sdboot
+  NAME:=NXP LS1088ARDB SD Card Boot
+  UBOOT_CONFIG:=ls1088ardb_sdcard_qspi
+  UBOOT_IMAGE:=u-boot-with-spl.bin
+endef
+
 define U-Boot/ls2088ardb
   NAME:=NXP LS2088ARDB
   UBOOT_CONFIG:=ls2080ardb
@@ -66,14 +84,26 @@ define U-Boot/ls1021atwr
   ENV_SIZE:=0x20000
 endef
 
+define U-Boot/ls1021atwr-sdboot
+  NAME:=NXP LS1021ATWR SD Card Boot
+  BUILD_SUBTARGET:=armv7
+  UBOOT_CONFIG:=ls1021atwr_sdcard_ifc
+  UBOOT_IMAGE:=u-boot-with-spl-pbl.bin
+  ENV_SIZE:=0x20000
+endef
+
 UBOOT_TARGETS := \
   ls1012ardb \
   ls1012afrdm \
   ls1043ardb \
+  ls1043ardb-sdboot \
   ls1046ardb \
+  ls1046ardb-sdboot \
   ls1088ardb \
+  ls1088ardb-sdboot \
   ls2088ardb \
-  ls1021atwr
+  ls1021atwr \
+  ls1021atwr-sdboot
 
 define Build/InstallDev
        $(INSTALL_DIR) $(STAGING_DIR_IMAGE)
diff --git a/package/boot/uboot-layerscape/files/ls1021atwr-sdboot-uEnv.txt b/package/boot/uboot-layerscape/files/ls1021atwr-sdboot-uEnv.txt
new file mode 100644 (file)
index 0000000..0a1a6bd
--- /dev/null
@@ -0,0 +1,8 @@
+fdtaddr=0x8f000000
+loadaddr=0x81000000
+fdt_high=0xffffffff
+initrd_high=0xffffffff
+sd_boot=mmc read $fdtaddr 7800 800;mmc read $loadaddr 8000 8000;bootm $loadaddr - $fdtaddr
+bootargs=root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200
+bootcmd=echo starting openwrt ...;run sd_boot
+bootdelay=3
diff --git a/package/boot/uboot-layerscape/files/ls1043ardb-sdboot-uEnv.txt b/package/boot/uboot-layerscape/files/ls1043ardb-sdboot-uEnv.txt
new file mode 100644 (file)
index 0000000..c1596b5
--- /dev/null
@@ -0,0 +1,9 @@
+fdtaddr=0x8f000000
+loadaddr=0x81000000
+fdt_high=0xffffffffffffffff
+initrd_high=0xffffffffffffffff
+hwconfig=fsl_ddr:bank_intlv=auto
+sd_boot=mmc read $fdtaddr 7800 800;mmc read $loadaddr 8000 8000;bootm $loadaddr - $fdtaddr
+bootargs=root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200
+bootcmd=echo starting openwrt ...;run sd_boot
+bootdelay=3
diff --git a/package/boot/uboot-layerscape/files/ls1046ardb-sdboot-uEnv.txt b/package/boot/uboot-layerscape/files/ls1046ardb-sdboot-uEnv.txt
new file mode 100644 (file)
index 0000000..c1596b5
--- /dev/null
@@ -0,0 +1,9 @@
+fdtaddr=0x8f000000
+loadaddr=0x81000000
+fdt_high=0xffffffffffffffff
+initrd_high=0xffffffffffffffff
+hwconfig=fsl_ddr:bank_intlv=auto
+sd_boot=mmc read $fdtaddr 7800 800;mmc read $loadaddr 8000 8000;bootm $loadaddr - $fdtaddr
+bootargs=root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200
+bootcmd=echo starting openwrt ...;run sd_boot
+bootdelay=3
diff --git a/package/boot/uboot-layerscape/files/ls1088ardb-sdboot-uEnv.txt b/package/boot/uboot-layerscape/files/ls1088ardb-sdboot-uEnv.txt
new file mode 100644 (file)
index 0000000..2d27f7e
--- /dev/null
@@ -0,0 +1,10 @@
+fdtaddr=0x8f000000
+loadaddr=0x81000000
+fdt_high=0xa0000000
+initrd_high=0xffffffffffffffff
+hwconfig=fsl_ddr:bank_intlv=auto
+mc_init=mmc read 80000000 5000 1800;mmc read 80300000 7000 800;fsl_mc start mc 80000000 80300000;mmc read 80400000 6800 800;fsl_mc apply dpl 80400000
+sd_boot=mmc read $fdtaddr 7800 800;mmc read $loadaddr 8000 8000;bootm $loadaddr - $fdtaddr
+bootargs=root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200
+bootcmd=echo starting openwrt ...;run mc_init;run sd_boot
+bootdelay=3
index d12bff9bbaa653707055b973cb41437ca129a1c7..13d015d251cdc966123b6187d1abcd0d529d2e21 100644 (file)
@@ -53,6 +53,11 @@ define Package/layerscape-rcw/ls1088ardb
   CONFIG:=ls1088ardb/FCQQQQQQQQ_PPP_H_0x1d_0x0d/rcw_1600_qspi.bin
 endef
 
+define Package/layerscape-rcw/ls1088ardb-sdboot
+  TITLE:=NXP LS1088ARDB SD card boot RCW binary
+  CONFIG:=ls1088ardb/FCQQQQQQQQ_PPP_H_0x1d_0x0d/rcw_1600_sd.bin
+endef
+
 define Package/layerscape-rcw/ls2088ardb
   TITLE:=NXP LS2088ARDB RCW binary
   CONFIG:=ls2088ardb/FFFFFFFF_PP_HH_0x2a_0x41/rcw_1800.bin
@@ -76,6 +81,7 @@ RCWS := \
   ls1043ardb \
   ls1046ardb \
   ls1088ardb \
+  ls1088ardb-sdboot \
   ls2088ardb \
   ls1021atwr
 
index 148c09814a0f6d6939608867f89a52770eac7c98..9b8ae4082ff910679078b4c1a08b4ec39f70daac 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 BOARD:=layerscape
 BOARDNAME:=NXP Layerscape
 KERNEL_PATCHVER:=4.9
-FEATURES:=squashfs nand usb pcie gpio fpu ubifs
+FEATURES:=squashfs nand usb pcie gpio fpu ubifs ext4
 SUBTARGETS:=armv8_64b armv8_32b armv7
 MAINTAINER:=Yangbo Lu <yangbo.lu@nxp.com>
 
index b275ef71cc282215d91e19444a52faa3d57baeda..a08cc2c2cbbc1b56bebe732c3dd4f47cd703988d 100644 (file)
@@ -9,6 +9,10 @@ include $(INCLUDE_DIR)/image.mk
 
 ITB_BOARDS = traverse-five64
 
+LS_SD_ROOTFSPART_OFFSET = 64
+LS_SD_IMAGE_SIZE = $(shell echo $$((($(LS_SD_ROOTFSPART_OFFSET) + \
+       $(CONFIG_TARGET_ROOTFS_PARTSIZE)) * 1024 * 1024)))
+
 define Build/ls-clean
        rm -f $@
 endef
@@ -22,6 +26,12 @@ define Build/ls-append-dtb
        dd if=$(DTS_DIR)/$(1).dtb >> $@
 endef
 
+define Build/ls-append-sdhead
+       ./gen_sdcard_head_img.sh $(STAGING_DIR_IMAGE)/$(1)-sdcard-head.img \
+               $(LS_SD_ROOTFSPART_OFFSET) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
+       dd if=$(STAGING_DIR_IMAGE)/$(1)-sdcard-head.img >> $@
+endef
+
 define Build/traverse-fit
        ./mkits-multiple-config.sh -o $@.its -A $(LINUX_KARCH) \
                -v $(LINUX_VERSION) -k $@ -a $(KERNEL_LOADADDR) \
index 59cc982017f7974566f52bb8fa8cb7442b37f9c7..7a582d79bf86f8f7f917ce02571220938b97dfd4 100644 (file)
@@ -29,3 +29,19 @@ define Device/ls1021atwr
     append-rootfs | pad-rootfs | check-size 67108865
 endef
 TARGET_DEVICES += ls1021atwr
+
+define Device/ls1021atwr-sdboot
+  DEVICE_TITLE := LS1021ATWR (SD Card Boot)
+  DEVICE_DTS := ls1021a-twr
+  FILESYSTEMS := ext4
+  IMAGES := sdcard.img
+  IMAGE/sdcard.img := \
+    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 15M | \
+    ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
+    append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
+    append-rootfs | check-size $(LS_SD_IMAGE_SIZE)
+endef
+TARGET_DEVICES += ls1021atwr-sdboot
index 15963eb912c3efff7f37709e493e25b35695ec39..a144fd0c663652e9fe08528b85cf5dd27c5cbba0 100644 (file)
@@ -85,6 +85,27 @@ define Device/ls1043ardb
 endef
 TARGET_DEVICES += ls1043ardb
 
+define Device/ls1043ardb-sdboot
+  DEVICE_TITLE := LS1043ARDB (SD Card Boot)
+  DEVICE_PACKAGES += \
+    layerscape-fman-ls1043ardb \
+    layerscape-ppa-ls1043ardb
+  DEVICE_DTS := freescale/fsl-ls1043a-rdb-sdk
+  FILESYSTEMS := ext4
+  IMAGES := sdcard.img
+  IMAGE/sdcard.img := \
+    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 4M | \
+    ls-append ls1043ardb-ppa.itb | pad-to 9M | \
+    ls-append ls1043ardb-fman.bin | pad-to 15M | \
+    ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
+    append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
+    append-rootfs | check-size $(LS_SD_IMAGE_SIZE)
+endef
+TARGET_DEVICES += ls1043ardb-sdboot
+
 define Device/ls1046ardb
   DEVICE_TITLE := LS1046ARDB
   DEVICE_PACKAGES += \
@@ -109,6 +130,27 @@ define Device/ls1046ardb
 endef
 TARGET_DEVICES += ls1046ardb
 
+define Device/ls1046ardb-sdboot
+  DEVICE_TITLE := LS1046ARDB (SD Card Boot)
+  DEVICE_PACKAGES += \
+    layerscape-fman-ls1046ardb \
+    layerscape-ppa-ls1046ardb
+  DEVICE_DTS := freescale/fsl-ls1046a-rdb-sdk
+  FILESYSTEMS := ext4
+  IMAGES := sdcard.img
+  IMAGE/sdcard.img := \
+    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 4M | \
+    ls-append ls1046ardb-ppa.itb | pad-to 9M | \
+    ls-append ls1046ardb-fman.bin | pad-to 15M | \
+    ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
+    append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
+    append-rootfs | check-size $(LS_SD_IMAGE_SIZE)
+endef
+TARGET_DEVICES += ls1046ardb-sdboot
+
 define Device/ls1088ardb
   DEVICE_TITLE := LS1088ARDB
   DEVICE_PACKAGES += \
@@ -137,6 +179,33 @@ define Device/ls1088ardb
 endef
 TARGET_DEVICES += ls1088ardb
 
+define Device/ls1088ardb-sdboot
+  DEVICE_TITLE := LS1088ARDB (SD Card Boot)
+  DEVICE_PACKAGES += \
+    layerscape-rcw-ls1088ardb-sdboot \
+    layerscape-mc-ls1088ardb \
+    layerscape-dpl-ls1088ardb \
+    layerscape-ppa-ls1088ardb \
+    restool
+  DEVICE_DTS := freescale/fsl-ls1088a-rdb
+  FILESYSTEMS := ext4
+  IMAGES := sdcard.img
+  IMAGE/sdcard.img := \
+    ls-clean | \
+    ls-append-sdhead $(1) | pad-to 4K | \
+    ls-append $(1)-rcw.bin | pad-to 1M | \
+    ls-append $(1)-uboot.bin | pad-to 3M | \
+    ls-append $(1)-uboot-env.bin | pad-to 4M | \
+    ls-append ls1088ardb-ppa.itb | pad-to 10M | \
+    ls-append ls1088ardb-mc.itb | pad-to 13M | \
+    ls-append ls1088ardb-dpl.dtb | pad-to 14M | \
+    ls-append ls1088ardb-dpc.dtb | pad-to 15M | \
+    ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \
+    append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \
+    append-rootfs | check-size $(LS_SD_IMAGE_SIZE)
+endef
+TARGET_DEVICES += ls1088ardb-sdboot
+
 define Device/ls2088ardb
   DEVICE_TITLE := LS2088ARDB
   DEVICE_PACKAGES += \
diff --git a/target/linux/layerscape/image/gen_sdcard_head_img.sh b/target/linux/layerscape/image/gen_sdcard_head_img.sh
new file mode 100755 (executable)
index 0000000..dc1efbb
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+#
+# Copyright 2018 NXP
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+set -x
+[ $# -eq 3 ] || {
+    echo "SYNTAX: $0 <file> <rootfs part offset> <rootfs size>"
+    exit 1
+}
+
+OUTPUT="$1"
+ROOTFSOFFSET="$(($2 * 1024))"
+ROOTFSSIZE="$3"
+
+head=4
+sect=16
+
+set `ptgen -o $OUTPUT -h $head -s $sect -l $ROOTFSOFFSET -t 83 -p ${ROOTFSSIZE}M`