aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mediatek/image
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-02-27 14:17:09 +0000
committerDaniel Golle <daniel@makrotopia.org>2021-02-28 04:15:44 +0000
commitdfa0a38d1f4d5bbac768569e3769ae4438a57e73 (patch)
tree04d8c630c07e74bc94db6f429a861dda1a9806ec /target/linux/mediatek/image
parentb102e281a4de8f177adcabbff07072a3c926c367 (diff)
downloadupstream-dfa0a38d1f4d5bbac768569e3769ae4438a57e73.tar.gz
upstream-dfa0a38d1f4d5bbac768569e3769ae4438a57e73.tar.bz2
upstream-dfa0a38d1f4d5bbac768569e3769ae4438a57e73.zip
mediatek: rework support for BananaPi BPi-R64
**What's new** * Bring support for the Bananapi BPi-R64 to the level desirable for a nice hackable routerboard. * Use ARM Trusted Firmware A from source. (goodbye binary preloader) * Use Das U-Boot from source. (see previous commit) * Assemble SD-card image using OpenWrt image-commands. (no gen_sd_cruz_foo.sh added, this is not Raspbian) * Updated kernel options to support root filesystem. * Updated DTS to match OpenWrt LAN ports, known LEDs, buttons, ... * Detect root device, handle sysupgrade, config restore, ... * Wire up (known) LEDs and buttons in OpenWrt-fashion. * Build one set of images from SD-card and eMMC. * Hopefully provide a good example of how things can be done right from scratch. **Installation and images** * Have an empty SD-card at hand * Write stuff to the card, as root (card device is /dev/mmcblkX) - write header, gpt, bl2, atf, u-boot and recovery kernel: `cat *bpi-r64-boot-sdcard.img *bpi-r64-initramfs-recovery.fit > /dev/mmcblkX` - rescan partitions: `blockdev --rereadpt /dev/mmcblkX` - write main system to production partition: `cat *bpi-r64-squashfs-sysupgrade.fit > /dev/mmcblkXp5` * Installation to eMMC works using SD-card bootloader via TFTP When running OpenWrt of SD-card, issue this to trigger installation to eMMC: `fw_setenv bootcmd run emmc_init` Be prepared to serve the content of bin/targets/mediatek/mt7622 on TFTP server address 192.168.1.254. **What's missing** * The red LED is always on, probably a hardware bug. * AHCI (probably needs DTS changes) * Ship SD-card image ready with every needed for eMMC install. * The eMMC has a second, currently unused boot partition. This would be ideal to store the WiFi EEPROM and Ethernet MAC address(es). @sinovoip ideas? Thanks to Thomas Hühn @thuehn for providing the hardware! Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'target/linux/mediatek/image')
-rwxr-xr-xtarget/linux/mediatek/image/gen_mt7622_emmc_img.sh19
-rw-r--r--target/linux/mediatek/image/mt7622.mk63
2 files changed, 43 insertions, 39 deletions
diff --git a/target/linux/mediatek/image/gen_mt7622_emmc_img.sh b/target/linux/mediatek/image/gen_mt7622_emmc_img.sh
deleted file mode 100755
index d74068c7b1..0000000000
--- a/target/linux/mediatek/image/gen_mt7622_emmc_img.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-OUTPUT_FILE=$1
-KERNEL_FILE=$2
-RECOVERY_FILE=$3
-ROOTFS_FILE=$4
-
-BS=512
-
-#RECOVERY_OFFSET= kernel size / BS = 20M / 512 (blocks)
-RECOVERY_OFFSET=40960
-
-#ROOTFS_OFFSET = RECOVERY_OFFSET + (RECOVERY_SIZE / BS)
-# = 40960 + (10M / 512) (blocks)
-ROOTFS_OFFSET=61440
-dd bs="$BS" of="$OUTPUT_FILE" if="$KERNEL_FILE"
-dd bs="$BS" of="$OUTPUT_FILE" if="$RECOVERY_FILE" seek="$RECOVERY_OFFSET"
-dd bs="$BS" of="$OUTPUT_FILE" if="$ROOTFS_FILE" seek="$ROOTFS_OFFSET"
-dd if=/dev/zero of="$OUTPUT_FILE" bs=128k count=1 oflag=append conv=notrunc
diff --git a/target/linux/mediatek/image/mt7622.mk b/target/linux/mediatek/image/mt7622.mk
index e113939e17..3fe9700ae0 100644
--- a/target/linux/mediatek/image/mt7622.mk
+++ b/target/linux/mediatek/image/mt7622.mk
@@ -6,35 +6,58 @@ else
KERNEL_LOADADDR := 0x44000000
endif
+define Build/mmc-header
+ dd if=$(STAGING_DIR_IMAGE)/mt7622-header_$1.bin bs=512 count=1 of=$@ conv=notrunc
+endef
+
define Build/bl2
- $(CP) $(STAGING_DIR_IMAGE)/mt7622-$1-bl2.img $@
+ cat $(STAGING_DIR_IMAGE)/mt7622-$1-bl2.img >> $@
endef
define Build/bl31-uboot
- $(CP) $(STAGING_DIR_IMAGE)/mt7622_$1-u-boot.fip $@
+ cat $(STAGING_DIR_IMAGE)/mt7622_$1-u-boot.fip >> $@
endef
-define Device/bpi_bananapi-r64
- DEVICE_VENDOR := Bpi
- DEVICE_MODEL := Banana Pi R64
- DEVICE_DTS := mt7622-bananapi-bpi-r64
- SUPPORTED_DEVICES := bananapi,bpi-r64
- DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk
+define Build/mt7622-gpt
+ ptgen -g -o $@ -h 4 -s 31 -a 1 -l 1024 -g \
+ -t 0xef \
+ $(if $(findstring sdmmc,$1), \
+ -N bl2 -r -p 512k@512k \
+ ) \
+ -N fip -r -p 1M@2M \
+ -N ubootenv -r -p 1M@4M \
+ -N recovery -r -p 32M@6M \
+ $(if $(findstring sdmmc,$1), \
+ -t 0x2e -N production -p 216M@40M \
+ ) \
+ $(if $(findstring emmc,$1), \
+ -t 0x2e -N production -p 980M@40M \
+ )
endef
-TARGET_DEVICES += bpi_bananapi-r64
-define Device/bpi_bananapi-r64-rootdisk
- DEVICE_VENDOR := Bpi
- DEVICE_MODEL := Banana Pi R64 (rootdisk)
- DEVICE_DTS := mt7622-bananapi-bpi-r64-rootdisk
- DEVICE_DTS_DIR := ../dts
- SUPPORTED_DEVICES := bananapi,bpi-r64
- DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 \
- mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk
- IMAGES := sysupgrade-emmc.bin.gz
- IMAGE/sysupgrade-emmc.bin.gz := sysupgrade-emmc | gzip | append-metadata
+define Device/bananapi_bpi-r64
+ DEVICE_VENDOR := Bananapi
+ DEVICE_MODEL := BPi-R64
+ DEVICE_DTS := mt7622-bananapi-bpi-r64
+ DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk \
+ kmod-mt7615e kmod-mt7615-firmware \
+ uboot-mt7622_bananapi_bpi-r64-emmc \
+ uboot-mt7622_bananapi_bpi-r64-sdmmc \
+ e2fsprogs mkf2fs f2fsck \
+ kmod-nls-cp437 kmod-nls-iso8859-1 kmod-vfat blockd
+ ARTIFACTS := boot-sdcard.img boot-emmc.img bl2-emmc.bin bl31-emmc.bin header-emmc.bin
+ IMAGES := sysupgrade.itb
+ KERNEL_INITRAMFS_SUFFIX := -recovery.itb
+ ARTIFACT/boot-sdcard.img := mt7622-gpt sdmmc | mmc-header sdmmc | pad-to 512k | bl2 sdmmc-2ddr | pad-to 2M | bl31-uboot bananapi_bpi-r64-sdmmc | pad-to 6M
+ ARTIFACT/boot-emmc.img := mt7622-gpt emmc | mmc-header emmc | pad-to 2M | bl31-uboot bananapi_bpi-r64-emmc | pad-to 6M
+ ARTIFACT/header-emmc.bin := mt7622-gpt emmc | mmc-header emmc
+ ARTIFACT/bl31-emmc.bin := bl31-uboot bananapi_bpi-r64-emmc
+ ARTIFACT/bl2-emmc.bin := bl2 emmc-2ddr
+ KERNEL := kernel-bin | gzip
+ KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 128k
+ IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | append-metadata
endef
-TARGET_DEVICES += bpi_bananapi-r64-rootdisk
+TARGET_DEVICES += bananapi_bpi-r64
define Device/elecom_wrc-2533gent
DEVICE_VENDOR := Elecom