aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm63xx/image
diff options
context:
space:
mode:
authorÁlvaro Fernández Rojas <noltari@gmail.com>2020-05-14 18:19:35 +0200
committerÁlvaro Fernández Rojas <noltari@gmail.com>2020-05-18 18:24:06 +0200
commit86583384ff4ce144c17997bd462ee0835e28310b (patch)
treea6af580ac8ccd1162bd41687de5e3c670527a1d6 /target/linux/bcm63xx/image
parentdcee4eaa4214dce19800ea04da0dd92ebf7af29a (diff)
downloadupstream-86583384ff4ce144c17997bd462ee0835e28310b.tar.gz
upstream-86583384ff4ce144c17997bd462ee0835e28310b.tar.bz2
upstream-86583384ff4ce144c17997bd462ee0835e28310b.zip
bcm63xx: smp: add NAND support
NAND controller is present on BCM6328, BCM6362, BCM6368 and BCM63268. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Diffstat (limited to 'target/linux/bcm63xx/image')
-rw-r--r--target/linux/bcm63xx/image/Makefile88
-rw-r--r--target/linux/bcm63xx/image/bcm63xx_nand.mk35
2 files changed, 123 insertions, 0 deletions
diff --git a/target/linux/bcm63xx/image/Makefile b/target/linux/bcm63xx/image/Makefile
index 321aec93a1..e392d99f2c 100644
--- a/target/linux/bcm63xx/image/Makefile
+++ b/target/linux/bcm63xx/image/Makefile
@@ -105,6 +105,79 @@ define Build/cfe-bin
$(CFE_EXTRAS) $(1)
endef
+define Build/cfe-jffs2
+ $(STAGING_DIR_HOST)/bin/mkfs.jffs2 \
+ --big-endian \
+ --pad \
+ --no-cleanmarkers \
+ --eraseblock=$(patsubst %k,%KiB,$(BLOCKSIZE)) \
+ --root=$(1) \
+ --output=$@ \
+ --compression-mode=none
+
+ $(call Build/pad-to,$(BLOCKSIZE))
+endef
+
+define Build/cfe-jffs2-cferam
+ mv $@ $@.kernel
+
+ rm -rf $@-cferam
+ mkdir -p $@-cferam
+
+ # CFE ROM checks JFFS2 dirent version of cferam.
+ # If version is not > 0 it will ignore the fs entry.
+ # JFFS2 sets version 0 to the first fs entry and increments
+ # it on the following ones, so let's create a dummy file that
+ # will have version 0 and let cferam be the second (version 1).
+ touch $@-cferam/1-openwrt
+ # Add cferam as the last file in the JFFS2 partition
+ cp $(KDIR)/bcm63xx-cfe/$(CFE_RAM_FILE) $@-cferam/$(CFE_RAM_JFFS2_NAME)
+
+ # The JFFS2 partition creation should result in the following
+ # layout:
+ # 1) 1-openwrt (version 0, ino 2)
+ # 2) cferam.000 (version 1, ino 3)
+ $(call Build/cfe-jffs2,$@-cferam)
+
+ # Some devices need padding between CFE RAM and kernel
+ $(if $(CFE_RAM_JFFS2_PAD),$(call Build/pad-to,$(CFE_RAM_JFFS2_PAD)))
+
+ # Append kernel
+ dd if=$@.kernel >> $@
+ rm -f $@.kernel
+endef
+
+define Build/cfe-jffs2-kernel
+ rm -rf $@-kernel
+ mkdir -p $@-kernel
+
+ # CFE RAM checks JFFS2 dirent version of vmlinux.
+ # If version is not > 0 it will ignore the fs entry.
+ # JFFS2 sets version 0 to the first fs entry and increments
+ # it on the following ones, so let's create a dummy file that
+ # will have version 0 and let cferam be the second (version 1).
+ touch $@-kernel/1-openwrt
+ # vmlinux is located on a different JFFS2 partition, but CFE RAM
+ # ignores it, so let's create another dummy file that will match
+ # the JFFS2 ino of cferam entry on the first JFFS2 partition.
+ # CFE RAM won't be able to find vmlinux if cferam has the same
+ # ino as vmlinux.
+ touch $@-kernel/2-openwrt
+ # Add vmlinux as the last file in the JFFS2 partition
+ $(TOPDIR)/scripts/cfe-bin-header.py \
+ --input-file $@ \
+ --output-file $@-kernel/vmlinux.lz \
+ --load-addr $(LOADER_ENTRY) \
+ --entry-addr $(LOADER_ENTRY)
+
+ # The JFFS2 partition creation should result in the following
+ # layout:
+ # 1) 1-openwrt (version 0, ino 2)
+ # 2) 2-openwrt (version 1, ino 3)
+ # 3) vmlinux.lz (version 2, ino 4)
+ $(call Build/cfe-jffs2,$@-kernel)
+endef
+
define Build/cfe-old-bin
$(TOPDIR)/scripts/brcmImage.pl -t -p \
-o $@ -b $(CFE_BOARD_ID) -c $(CFE_CHIP_ID) \
@@ -121,6 +194,17 @@ define Build/cfe-spw303v-bin
$(CFE_EXTRAS) $(1)
endef
+define Build/cfe-wfi-tag
+ $(TOPDIR)/scripts/cfe-wfi-tag.py \
+ --input-file $@ \
+ --output-file $@.new \
+ --version $(if $(1),$(1),$(CFE_WFI_VERSION)) \
+ --chip-id $(CFE_WFI_CHIP_ID) \
+ --flash-type $(CFE_WFI_FLASH_TYPE) \
+ $(if $(CFE_WFI_FLAGS),--flags $(CFE_WFI_FLAGS))
+ mv $@.new $@
+endef
+
define Build/spw303v-bin
$(STAGING_DIR_HOST)/bin/spw303v -i $@ -o $@.spw303v
mv $@.spw303v $@
@@ -170,4 +254,8 @@ USB2_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport
include bcm63xx.mk
+ifeq ($(SUBTARGET),smp)
+include bcm63xx_nand.mk
+endif
+
$(eval $(call BuildImage))
diff --git a/target/linux/bcm63xx/image/bcm63xx_nand.mk b/target/linux/bcm63xx/image/bcm63xx_nand.mk
new file mode 100644
index 0000000000..8e733f2b23
--- /dev/null
+++ b/target/linux/bcm63xx/image/bcm63xx_nand.mk
@@ -0,0 +1,35 @@
+#
+# BCM63XX NAND Profiles
+#
+
+DEVICE_VARS += CFE_RAM_FILE
+DEVICE_VARS += CFE_RAM_JFFS2_NAME CFE_RAM_JFFS2_PAD
+DEVICE_VARS += CFE_WFI_CHIP_ID CFE_WFI_FLASH_TYPE
+DEVICE_VARS += CFE_WFI_FLAGS CFE_WFI_VERSION
+
+# CFE expects a single JFFS2 partition with cferam and kernel. However,
+# it's possible to fool CFE into properly loading both cferam and kernel
+# from two different JFFS2 partitions by adding dummy files (see
+# cfe-jffs2-cferam and cfe-jffs2-kernel).
+# Separate JFFS2 partitions allow upgrading openwrt without reflashing cferam
+# JFFS2 partition, which is much safer in case anything goes wrong.
+define Device/bcm63xx-nand
+ FILESYSTEMS := squashfs ubifs
+ KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma | cfe-jffs2-kernel
+ KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-lzma elf
+ IMAGES := cfe.bin sysupgrade.bin
+ IMAGE/cfe.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | cfe-jffs2-cferam | append-ubi | cfe-wfi-tag
+ IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+ KERNEL_SIZE := 5120k
+ CFE_CHIP_ID :=
+ CFE_RAM_FILE :=
+ CFE_RAM_JFFS2_NAME :=
+ CFE_RAM_JFFS2_PAD :=
+ CFE_WFI_VERSION := 0x5731
+ CFE_WFI_CHIP_ID = 0x$$(CFE_CHIP_ID)
+ CFE_WFI_FLASH_TYPE :=
+ CFE_WFI_FLAGS :=
+ UBINIZE_OPTS := -E 5
+ DEVICE_PACKAGES += nand-utils
+ SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
+endef