Commit Graph

83 Commits

Author SHA1 Message Date
Daniel Golle 089c2bb217 mediatek: mt7623: yet another legacy image variable restored
Restore BOOTFS_BLOCKS variable until U7623 gets brushed, so things
hopefully build now.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-07-21 16:48:35 +01:00
Daniel Golle 5096f0513b mediatek: mt7623: allow build without ext4 rootfs
The image generation code for the U7623 board expects ext4 filesystem
to be selected in menuconfig and CONFIG_TARGET_ROOTFS_PARTSIZE to be
defined. Now that ext4 isn't enabled any more, the variable was missing
and broke the build.
Set the default (104) instead of using the config variable to fix that.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-07-21 15:34:21 +01:00
Daniel Golle c5b3c13b60 mediatek: mt7623: add back needed build steps for U7623 board
When reworking the BPi-R2 the mtk-mmc-img build step was removed
despite it was still needed to build the image for the UniElec U7623
board. Add it back for now until U7623 gets its facelift.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-07-21 10:26:44 +01:00
Daniel Golle ddec752890 mediatek: drop kmod-mmc
Support for MMC is built-into the kernel anyway, no need to select the
(empty/stub) kmod package.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-07-20 17:01:02 +01:00
Daniel Golle 86a61e716e mediatek: rework Bananapi BPi-R2
* introduce recovery (=initramfs) vs. production dual boot scheme
 * make use of uImage.FIT (instead of FAT partition)
 * generate images using build steps (instead of external scripts)
 * simplify sysupgrade and config restore (thanks to uImage.FIT)
 * make sure mmc devices are ordered persistently (set DT aliases)

This commit breaks sysupgrade from existing installations, you will
have to re-install using the sdcard.img.gz image.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-07-20 04:16:48 +01:00
Daniel Golle 01a9d22086
mediatek: bpi-r64: add eMMC bootloader artifacts
In order to allow easily updating the bootloader on eMMC also provide
artifacts for that. Support for updating bootloader via TFTP will be
added to the loader CLI menu in a follow-up commit.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-05-01 22:55:14 +01:00
Daniel Golle 210916c9e6
mediatek: bpi-r64: fix sdcard.img.gz in ImageBuilder
Generating the sdcard.img.gz file requires the initramfs/recovery
image to be present. Use the newly introduced 'append-image-stage'
build command to fix the ImageBuilder for the BPi-R64.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-04-23 23:16:54 +01:00
Oskari Lemmela 3c23a7c03d
mediatek: mt7622: add spi-nand support for bananapi bpi-r64
Some of bpi-r64 boards have serial NAND attached to SPI bus.
Add SD card image support for installing openwrt to it.
Default to nand upgrade if root device is not mmc block device.

Separate preloader and uboot images for snand are generated.

Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
2021-04-11 20:19:44 +01:00
Oskari Lemmela d05051774e mediatek: bpi-r64: use separate partition for emmc bootloader
eMMC booloader is stored to separate partition.
FIP size is increased to 2MB.

Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
2021-04-11 14:55:35 +01:00
Daniel Golle e887049fbb
mediatek: add alternative bootchain variant for UniFi 6 LR
Builds images for the Ubiquiti Network UniFi 6 LR device running the
U-Boot build added by the previous commits.
Everything but MTD partitions is moved to dtsi.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-04-09 16:04:57 +01:00
Daniel Golle 6f5cd3bdcf
mediatek: generate complete sdcard image for BPi-R64
Populate the recovery and production partitions of the generated sdcard
image for the Bananapi BPi-R64.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-03-24 15:27:54 +00:00
David Bauer 42d943f40a mediatek: fix broken UniFi 6 LR image
Ubiquiti's own bootloader expects the configuration mode to be present
with a "@" instead of a "-" for the sperator character. Otherwise
booting of the image fails.

Signed-off-by: David Bauer <mail@david-bauer.net>
2021-03-18 00:56:33 +01:00
Daniel Golle b40f707f71 mediatek: bpi-r64: use dt-overlay to select SATA or PCIE1
The Bananapi BPi-R64 got a SATA interface which cannot be used at the
same time as the second mPCIe slot. The decission is made by hogging
GPIO 90.
Embed two addtional DT overlay blobs into the image to allow bootloader
selection of either SATA or PCIE1 feature.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-03-17 19:12:19 +00:00
Daniel Golle c17b1dca60
mediatek: mt7622: drop duplicate DEVICE_PACKAGES
kmod-mt7615e kmod-mt7615-firmware and uboot-envtools are already part
of the target's default package set. No need to add them again for
buffalo_wsr-2533dhp2.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-03-15 16:40:31 +00:00
INAGAKI Hiroshi 74f15628dd mediatek: add support for Buffalo WSR-2533DHP2
This adds support for the Buffalo WSR-2533DHP2.

The device uses the Broadcom TRX image format with a special magic. To
be able to boot the images or load them they have to be wrapped with
different headers depending how it is loaded.

There are multiple ways to install OpenWrt on this device.
Boot ramdisk from U-Boot
----------------------------
This will load the image and not write it into the flash.

1. Stop boot menu with "space" key
2. Select "System Load Linux to SDRAM via TFTP."
3. Load this image:
   openwrt-mediatek-mt7622-buffalo_wsr-2533dhp2-initramfs-kernel.bin
4. The system boots the image

Write to flash from U-Boot
-----------------------------
This will load the image over tftp and directly write it into the flash.

1. Stop boot menu with "space" key
2. Select "System Load Linux Kernel then write to Flash via TFTP."
3. Load this image:
   openwrt-mediatek-mt7622-buffalo_wsr-2533dhp2-squashfs-factory-uboot.bin
4. The system writes this image into the flash and boots into it.

Write to flash from Web UI
-----------------------------
This will load the image over over the Web UI and write it into the flash

1. Open the Web UI
2. Go to "管理" -> "ファームウェア更新"
3. Select "ローカルファイル指定" and click "更新実行"
4. Load this image:
   openwrt-mediatek-mt7622-buffalo_wsr-2533dhp2-squashfs-factory.bin
5. The system writes this image into the flash and boots into it.

Specifications
-------------------
* SoC:       MT7622 (4x4 2.4 GHz Wifi)
* Wifi:      MT7615 (4x4 5 GHz Wifi)
* Flash:     Winbond W29N01HZ 128MB SLC NAND
* RAM        256MB
* Ethernet:  Realtek RTL8367S (5 x 1GBit/s, SoC via 2.5GBit/s)

Co-Developed-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2021-03-15 17:02:17 +01:00
Daniel Golle 34adb6db1d
mediatek: mt7622: clean up image build
* clean up whitespace to make GPT partitioning more readable
 * don't select packages already part of the target default selection
 * don't select U-Boot variants (breaks ImageBuilder)
 * don't select AHCI on boards without SATA
 * don't select kmod-usb2 and kmod-ohci, USB 1.x and USB 2.0 devices
   work fine with the in-SoC XHCI host having just kmod-usb3 installed.
 * select kmod-btmtkuart for devices with Bluetooth support
 * sort DEVICE_PACKAGES

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-03-14 22:00:10 +00:00
Daniel Golle 1a7ef2c3cf
mediatek: image: don't use 'M' unit as dd may not support that
dd on Mac OS X apparently fails when using 'M' unit for bs.
dd: bs: illegal numeric value
Use 'k' unit instead for 'pad-to' to fix that.

Reported-by: Georgi Valkov <gvalkov@abv.bg>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-03-13 15:36:57 +00:00
Daniel Golle 1d412235a5 mediatek: mt7622: check firmware metadata
All mt7622 devices except for the UBI-variant of the mt7622-rfb1 carry
metadata appended to the sysupgrade image.
Add it for the mt7622-rfb1-ubi as well and check it on sysupgrade to
avoid accidentally flashing firmware for the wrong device (or variant
or future DEVICE_COMPAT_VERSION).

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-03-04 02:57:19 +00:00
Oskari Lemmela 60d2623cc5 mediatek: mt7622: change image generation
- set only one EFI system partition
- use shorter path for DEVICE_DTS file

Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
2021-03-03 01:00:23 +00:00
Oskari Lemmela 0234881f31 mediatek: mt7622: use ptgen generated MBR header
mt7622 uses MBR partition for booting from SD card.
Add hybrid MBR entry with boot flag after PMBR entry.

Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
2021-03-03 01:00:23 +00:00
Daniel Golle bb98ddc47b mediatek: mt7622: make sure image generation can run in parallel
The previous approach of referencing artifacts in follow-up artifacts
can't work with parallel builds in the current way image.mk is built.
Refactor things so this is not needed.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-03-02 01:41:31 +00:00
Daniel Golle ded54ae196 mediatek: mt7622: bpi-r64: simplify eMMC install procedure
Write everything needed for eMMC install into the gaps between
partitions on SD card. In that way, installation to eMMC only needs
the SD card, no additional files need to be loaded via TFTP any more.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-03-01 19:33:46 +00:00
Daniel Golle aaa0203ad4 mediatek: mt7622: rename mt7622-ubi to mt7622-rfb1-ubi
This profile is meant to be used on MT7622 rfb1 AP, indicate that in
the name to make things less confusing.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-03-01 11:57:02 +00:00
Daniel Golle dfa0a38d1f 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>
2021-02-28 04:15:44 +00:00
Daniel Golle 0235186182 mediatek: add alternative UBI NAND layout for Linksys E8450
The vendor flash layout of the Linksys E8450 is problematic as it uses
the SPI-NAND chip without any wear-leveling while at the same time
wasting a lot of space for padding.
Use an all-UBI layout instead, storing the kernel+dtb+squashfs in
uImage.FIT standard format in UBI volume 'fit', the read-write
overlay in UBI volume 'rootfs_data' as well as reduntant U-Boot
environments 'ubootenv' and 'ubootenv2', and a 'recovery'
kernel+dtb+initramfs uImage.FIT for dual-boot.

** WARNING **
THIS PROCEDURE CAN EASILY BRICK YOUR DEVICE PERMANENTLY IF NOT CARRIED
OUT VERY CAREFULLY AND EXACTLY AS DESCRIBED!

Step 0

 * Configure your PC to have the static IPv4 address 192.168.1.254/24
 * Provide bin/targets/mediatek/mt7622 via TFTP

Now continue EITHER with step 1A or 1B, depending on your preference
(and on having serial console wired up or not).

Step 1A (Using the vendor web interface (or non-UBI OpenWrt install))

In order to update to the new bootloader and UBI-based firmware,
use the web browser of your choice to open the routers web-interface
accessible on http://192.168.1.1

 * Navigate to
   'Configuration' -> 'Administration' -> 'Firmware Upgrade'

 * Upload the file
    openwrt-mediatek-mt7622-linksys_e8450-ubi-initramfs-recovery.itb
   and proceed with the upgrade.

 * Once OpenWrt comes up, use SCP to upload the new bootloader files to
   /tmp on the router:
    *-mt7622-linksys_e8450-ubi-preloader.bin
    *-mt7622-linksys_e8450-ubi-bl31-uboot.fip

 * Connect via SSH as you will now need to replace the bootloader in
   the Flash.

    ssh root@192.168.1.1
    (the usual warnings)

 * First of all, backup all the flash now:

    for mtd in /dev/mtdblock*; do
     dd if=$mtd of=/tmp/$(basename $mtd);
    done

 * Then use SCP to copy /tmp/mtdblock* from the router and keep them
   safe. You will need them should you ever want to return to the
   factory firmware!

 * Now flow the uploaded files:
    mtd -e /dev/mtd0 write /tmp/*linksys_e8450-ubi-preloader.bin /dev/mtd0
    mtd -e /dev/mtd1 write /tmp/*linksys_e8450-ubi-bl31-uboot.fip /dev/mtd1

   If and only if both writes look like the completed successfully
   reboot the router. Now continue with step 2.

Step 1B (Using the vendor bootloader serial console)

 * Use the serial to backup all /dev/mtd* devices before using the
   stock firmware (you got root shell when connected to serial).

 * Then reboot and select 'U-Boot Console' in the boot menu.

 * Copy the following lines, one by one:

tftpboot 0x40080000 openwrt-mediatek-mt7622-linksys_e8450-ubi-preloader.bin
tftpboot 0x40100000 openwrt-mediatek-mt7622-linksys_e8450-ubi-bl31-uboot.fip
nand erase 0x0 0x180000
nand write 0x40080000 0x0 0x180000
reset

Now continue with step 2

Step 2

Once the new bootchain comes up, the loader will initialize UBI and the
ubootenv volumes. It will then of course fail to find any bootable
volume and hence resort to load kernel via TFTP from server
192.168.1.254 while giving itself the address 192.168.1.1

The requested file is called
openwrt-mediatek-mt7622-linksys_e8450-ubi-initramfs-recovery.itb
and your TFTP server should provide exactly that :)
It will be written to UBI as recovery image and booted.
You can then continue and flash the production OS image, either
by using sysupgrade in the booted initramfs recovery OS, or by using
the bootloader menu and TFTP.

That's it. Go ahead and mess around with a bootchain built almost
completely from source (only DRAM calibration blobs are fitted in bl2,
and the irreplacable on-chip ROM loader remains, of course).
And enjoy U-Boot built with many great features out-of-the-box.

You can access the bootloader environment from within OpenWrt using the
'fw_printenv' and 'fw_setenv' commands. Don't be afraid, once you got
the new bootchain installed the device should be fairly unbrickable
(holding reset button before and during power-on resets things and
allows reflashing recovery image via TFTP)

Special thanks to @dvn0 (Devan Carpenter) for providing amazingly fast
infra for test-builds, allowing for `make clean ; make -j$(nproc)` in
less than two minutes :)

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-02-28 01:23:48 +00:00
John Crispin aa94e34c1d mediatek: add Linksys E8450 support
The Linksys E8450, also known as Belkin RT3200, is a dual-band
IEEE 802.11bgn/ac/ax router based on MediaTek MT7622BV and
MediaTek MT7915AN chips.

FCC: K7S-03571 and K7S-03572

Hardware highlights:
 - CPU: MediaTek MT7622BV (2x ARM Cortex-A53 @ 1350 MHz max.)
 - RAM: 512MB DDR3
 - Flash: 128MB SPI-NAND (2k+64)
 - Ethernet: MT7531BE switch with 5 1000Base-T ports
             CPU port connected with 2500Base-X
 - WiFi 2.4 GHz: 802.11bgn 4T4R built-in antennas
                 MT7622VB built-in
 - WiFi   5 GHz: 802.11ac/ax 4T4R built-in antennas
                 MT7915AN chip on-board via PCIe
                 MT7975AN front-end
 - Buttons: Reset and WPS
 - LEDS: 3 user controllable LEDs, 4 wired to switch
 - USB: USB2.0, single port
 - no Bluetooth (supported by SoC, not wired on board)
 - Serial: JST PH 2.0MM 6 Pin connector inside device
            ----_____________----
           [  GND RX - TX  -  -  ]
            ---------------------
 - JTAG:   unpopulated ARM JTAG 20-pin connector (works)

This commit adds support for the device in a way that is compatible
with the vendor firmware's bootloader and dual-boot flash layout, the
resulting image can directly be flashed using the vendor firmware.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-02-28 01:20:53 +00:00
Felix Fietkau c46ccb69d1 mediatek: mt7622: add Linux 5.10 support
Switch mt7622 subtarget to Linux 5.10, it has been tested by many of us
on several devices for a couple of weeks already.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-02-28 00:45:56 +00:00
Daniel Golle 198385b69d mediatek: switch to use seperate ramdisk for initramfs images
MediaTek targets always use U-Boot's modern uImage.FIT format which
allows bundling several blobs into a single file including hashes,
descriptions and more. In fact, we are already using that to bundle
the Flattened Device Tree blob with the kernel on this and many
other targets.
In the same fashion, we can now make use of the newly introduced
support for building seperate ramdisk to uImage.FIT with a dedicated
initrd blob checked and loaded by U-Boot instead of embedding the
cpio archive into the kernel itself.
This allows for having larger ramdisks, choosing ramdisk compression
independently of kernel compression (while only kernel is decompressed
by the bootloader) and for more easily replacing or modifying the
filesystem contained in an initramfs image.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-02-25 16:39:55 +00:00
Oskari Lemmela 7befce2bb1 mediatek: mt7622: fix bpi-r64 emmc f2fs overlay
f2fs tools are needed for generating f2fs overlay.
vfat modules are used for recovery mounting.

Fixes: f72a2b004c ("mediatek: add bpi-r64 emmc support")
Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
2021-02-24 19:31:19 +00:00
Daniel Golle c7293bcfcc
mediatek: move mt7623a-unielec-u7623*.dts* out of patch
Instead of adding those device tree sources using a patch, simply move
them to the newly created dts folder.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-02-19 10:00:46 +00:00
Daniel Golle e3b8849088
mediatek: more clean solution for out-of-tree DTS
Use approach suggested by Adrian Schmutzler instead of introducing
another device variable.
Also revert the unnecessary white-space changes accidentally introduced
by the previous commit.

Fixed: c067b1e79b ("mediatek: move out-of-tree DTS files to dedicated dts folder")
Suggested-by: Adrian Schmutzler <mail@adrianschmutzler.de>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-02-19 01:25:49 +00:00
Daniel Golle c067b1e79b
mediatek: move out-of-tree DTS files to dedicated dts folder
Use dedicated dts folder like on ramips to store device tree source
files for boards not already supported in vanilla Linux.
Doing so instead of having them in files-* has several advantages:
 * we don't need to duplicate them for several kernel versions
 * changes to a device tree don't trigger a complete kernel rebuild
 * the files are more obvious to find

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-02-19 00:05:53 +00:00
David Bauer 634c13c186 mediatek: add support for Ubiquiti UniFi 6 LR
Hardware
--------

MediaTek MT7622
512MB DDR3 RAM
64M SPI-NOR Flash (Winbond W25Q512JV)
MediaTek MT7622 802.11bgn 4T4R WMAC
MediaTek MT7915 802.11ax 4T4R
Marvell AQR1112 100/1000/2500 NBase-T PHY
Holtek HT32F52241 LED controller
Reset Switch

UART
----

CPU UART0 at the pinout next to the Holtek MCU.

Pinout (first pin next to SoC / MCU)

0 3V3
1 RX
2 TX
3 GND

Settings are 115200 8N1.

Opening the case
----------------

Opening the case is not a nice task, as itis glued together. Insert a
flat knife between the front and back casing below the ethernet port.
Open up a gap this way and insert a flat scredriver, remove the knife.

Work your way around the casing by applying force to seperate the front
and back casing. This losens the glue and opens the plastic clips. Be
gentle, as these clips are very cheap and break quickly.

Installation
------------

1. Connect to the booted device at 192.168.1.20 using username/password
   "ubnt".

2. Transfer the OpenWrt sysupgrade image to the device using SCP.

3. Check the mtd partition number for bs / kernel0 / kernel1

   $ cat /proc/mtd

4. Set the bootselect flag to boot from kernel0

   $ dd if=/dev/zero bs=1 count=1 of=/dev/mtdblock6

5. Write the OpenWrt sysupgrade image to both kernel0 as well as kernel1

   $ dd if=openwrt.bin of=/dev/mtdblock8
   $ dd if=openwrt.bin of=/dev/mtdblock9

6. Reboot the device. It should boot into OpenWrt.

Signed-off-by: David Bauer <mail@david-bauer.net>
2021-02-18 01:15:45 +01:00
Adrian Schmutzler 7157c77c6d target: use SPDX license identifiers on scripts
Use SPDX license tags to allow machines to check licenses.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-02-10 15:47:23 +01:00
Adrian Schmutzler 598b29585e target: use SPDX license identifiers on Makefiles
Use SPDX license tags to allow machines to check licenses.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-02-10 15:47:18 +01:00
Adrian Schmutzler f52081bcf9 treewide: provide global default for SUPPORTED_DEVICES
The majority of our targets provide a default value for the variable
SUPPORTED_DEVICES, which is used in images to check against the
compatible on a running device:

  SUPPORTED_DEVICES := $(subst _,$(comma),$(1))

At the moment, this is implemented in the Device/Default block of
the individual targets or even subtargets. However, since we
standardized device names and compatible in the recent past, almost
all targets are following the same scheme now:

  device/image name:  vendor_model
  compatible:         vendor,model

The equal redundant definitions are a symptom of this process.

Consequently, this patch moves the definition to image.mk making it
a global default. For the few targets not using the scheme above,
SUPPORTED_DEVICES will be defined to a different value in
Device/Default anyway, overwriting the default. In other words:
This change is supposed to be cosmetic.

This can be used as a global measure to get the current compatible
with: $(firstword $(SUPPORTED_DEVICES))
(Though this is not precisely an achievement of this commit.)

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-01-23 12:45:21 +01:00
Chuanhong Guo 006cd489f0 mediatek: mt7622: select bluetooth module instead of firmware
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
2020-09-22 21:13:54 +08:00
David Woodhouse 7190fb2da4 mediatek: mt7623: use bash for generating bootable images
It turns out that 'echo -e' isn't portable; it doesn't work in the dash
builtin echo and Ubuntu users are complaining.

I can't even get octal (specified by POSIX) to work consistently because
those  variants of 'echo' which *do* support -e don't seem to interpret
octalwithout it.

I could switch to /bin/echo but using -e with that isn't actually
portable *either* even though it works today.

For now just stick with bash, and use its builtin. We may end up using
something else entirely; perhaps perl.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2020-09-19 13:39:29 +01:00
David Woodhouse b36422b914 mediatek: mt7623: add full system image for UniElec U7623
This adds a full eMMC image including U-Boot, which means that the
kernel can inherit the true RAM size detected by the preloader.

As implemented in previous commits, sysupgrade to this image from
the legacy layout (and via that, from the vendor-installed image)
is supported.

Rename the legacy image for the 512MiB board, for clarity.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2020-07-26 17:08:31 +08:00
David Woodhouse 1113dcab05 mediatek: mt7623: rename gen_banana_pi_img.sh → gen_mtk_mmc_img.sh
As I buy more hardware and continue to work on consolidation, This will
apply to a lot of MediaTek platforms; rename it accordingly.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2020-07-26 17:08:21 +08:00
David Woodhouse f5cebbe2e4 mediatek: mt7623: make gen_banana_pi_img.sh more generic
This actually covers fairly much all the MediaTek platforms; they
only have different images because they don't include the preloader
and U-Boot, and rely on preinstalled stuff from the vendor.

So this script can slowly take over the world as we complete the
support for various other platforms, starting with UniElec U7623…

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2020-07-26 17:08:21 +08:00
David Woodhouse 5787684cb4 mediatek: mt7623: add scatter file for unbricking with SP Flash Tool
Many MediaTek SoCs can be unbricked by using the SP Flash Tool from
http://spflashtool.com/ along with a "scatter list" file, which is
just a text file listing which image gets loaded where.

We use a trivial partition layout for the tool, with the whole eMMC
image as a single "partition", which means users just need to unzip
the sysupgrade image. Doing the real partition layout would be overly
complex and would require the individual partitions to be shipped
as artifacts — or users to extract them out of the sysupgrade image
just for the tool to put them adjacent to each other on the eMMC
anyway.

The tool does require a copy of the preloader in order to operate,
even when it isn't flashing the preloader to the eMMC boot region.
So drop that into the bin directory as an artifact too.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2020-07-26 17:07:52 +08:00
Chuanhong Guo 65fc47cac5 mediatek: mt7623: build lzma fit for bpi-r2
bpi-r2 images are shipped with mainline u-boot which can extract lzma
with no problem.
remove custom kernel recipe to build lzma fit image instead of
uncompressed fit with zboot.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
2020-07-26 17:04:49 +08:00
David Woodhouse 6eb63019af mediatek: mt7623: fix sysupgrade from vendor OpenWrt on UniElec U7623
This board ships with an ancient 14.07-based OpenWrt using block2mtd, and
the MBR partition table contains nonsense.

It is possible to sysupgrade to an upstream OpenWrt image, but the
legacy layout of the OpenWrt images start at 0xA00 in the eMMC, with
a raw uImage. The legacy OpenWrt image doesn't "own" the beginning
of the device, including the MBR and U-Boot.

This means that when a user upgrades to upstream OpenWrt, it doesn't
boot because it can't find the right partitions. So hard-code them on
the kernel's command line using CONFIG_CMDLINE_PARTITION (for block).

Additionally, the vendor firmware doesn't cope with images larger than
about 36MiB, because it only overwrites the contents of its "firmware"
MTD partition. The current layout of the legacy image wastes a lot of
space, allowing over 32MiB for the kernel and another 10MiB for the FAT
recovery file system which is only created as 3MiB. So pull those in
to allow 4¾ MiB for the kernel, 3MiB for recovery, and then we have over
20MiB for the root file system.

This doesn't affect the new images which ship with a full eMMC image
including a different MBR layout and a partition for U-Boot, because
our modern U-Boot can actually pass the command line to the kernel, and
the built-in one doesn't get used anyway.

Tested by upgrading from vendor OpenWrt to the current legacy image,
from legacy to itself, to the previous legacy layout, and then to
finally the full-system image.

This commit probably wants backporting to 19.07, which also doesn't
install over the vendor OpenWrt and doesn't even have a full-system
installation option.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2020-07-26 16:42:35 +08:00
Adrian Schmutzler 739d282c2f mediatek: remove condition in Device/Default
The current condition with part of the variables set dependent on
the subtarget in Device/Default isn't really nice to read and also
defeats the purpose of having a default node.

This removes the special settings for mt7623 and moves them to the
individual devices, which is not much of a problem as there are
actually just two of them and they partly use different settings
anyway.

While at it, slightly adjust the order of variables and wrap some
long lines.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-07-25 23:19:19 +02:00
John Crispin 5a5031e70b mediatek: generate UBI images for the rev board
Signed-off-by: John Crispin <john@phrozen.org>
2020-07-16 09:16:34 +02:00
David Woodhouse f632747704 mediatek: fix bashism in gen_banana_pi_img.sh
There was a bashism in the script. This fixes the script so that it
doesn't actually require bash, and can be run with any POSIX shell as
its shebang suggests.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2020-07-09 11:11:31 +02:00
David Woodhouse af9932c9b7 mediatek: Implement sysupgrade support for Banana Pi R2
Based on work by Alexey Loukianov <lx2@lexa2.ru> and others.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2020-07-08 23:22:30 +02:00
David Woodhouse 7adc29f59e mediatek: add SD card image creation for Banana Pi R2
Based on work by Alexey Loukianov <lx2@lexa2.ru> and others.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2020-07-08 23:22:30 +02:00
David Woodhouse 91e43a1d7a mediatek: enable SATA for mt7623
The MT7623 SoC has the same SATA block as the MT7622, so enable it in
MT7623 builds too and add it to the DEVICE_PACKAGES for those boards.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2020-07-08 23:22:30 +02:00