[OpenWrt-Devel] [PATCH] [brcm47xx] Belkin F7DXXXX (BCM47XX based) support for Linux 3.18
Rafał Miłecki
zajec5 at gmail.com
Tue Jul 14 07:43:40 EDT 2015
On 23 June 2015 at 16:16, Joseph East <eastyjr at gmail.com> wrote:
> From d38c8c72b99908d3d9a39bd858d1c76e9864faac Mon Sep 17 00:00:00 2001
> From: Joseph East <eastyjr at gmail.com>
> Date: Wed, 10 Jun 2015 19:19:26 +0930
> Subject: [PATCH] Belkin F7DXXXX (BCM47XX based) Support for Linux 3.18
>
> Patchset based on previous work by Cody Schafer and Luc Forcier to allow TRX images with Belkin IDs to be compiled as part of the BRCM47XX platform for Linux 3.18.
>
> The patchset has been tested with a Belkin F7D4401 (PlayMax N600), other devices part of the previous patch are untested but have been included, however the Belkin QA TRX signature has been removed.
>
> The otrx tool has been modified to accept a -m argument which allows comparison against a user defined TRX signature, this works in tandem with the changes in platform.sh to verify the different Belkin TRXs for supported models.
> @@ -47,6 +48,8 @@ struct trx_header {
>
> char *trx_path;
> size_t trx_offset = 0;
> +uint8_t use_trx_override = 0;
> +uint32_t trx_override = 0;
> char *partition[TRX_MAX_PARTS] = {};
>
> static inline size_t otrx_min(size_t x, size_t y) {
> @@ -143,15 +146,30 @@ uint32_t otrx_crc32(uint8_t *buf, size_t len) {
> static void otrx_check_parse_options(int argc, char **argv) {
> int c;
>
> - while ((c = getopt(argc, argv, "o:")) != -1) {
> + while ((c = getopt(argc, argv, "m:o:")) != -1) {
> switch (c) {
> case 'o':
> trx_offset = atoi(optarg);
> break;
> + case 'm':
> + trx_override = strtol(optarg, NULL, 16);
> + use_trx_override = 1;
> + break;
> }
> }
> }
>
> +static bool is_trx_magic(uint32_t magic) {
> + if(use_trx_override)
> + {
> + return magic == trx_override;
> + }
> + else
> + {
> + return magic == TRX_MAGIC;
> + }
> +}
Please follow a coding style that is already used in the file (I mean
braces location).
> @@ -119,11 +139,33 @@ platform_check_image() {
> fi
> ;;
> "trx")
> + local flash_generic=$(platform_expected_image | cut -d ' ' -f 3)
> + [ -n "$flash_generic" -a "nogeneric" == "$flash_generic" ] && {
This pre-test with -n seems to be unneeded.
> diff --git a/target/linux/brcm47xx/image/Makefile b/target/linux/brcm47xx/image/Makefile
> index 6768820..45ed330 100644
> --- a/target/linux/brcm47xx/image/Makefile
> +++ b/target/linux/brcm47xx/image/Makefile
> @@ -34,6 +34,17 @@ endif
> $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
> endef
>
> +# Function for multiple Belkin Trx
> +# 1: trx input
> +# 2: bin output
> +# 3: 4 magic bytes
> +define Image/Build/Belkin_
> + echo -ne $(3) > $(2).head
> + dd if=$(1) of=/dev/stdout bs=4 skip=1 > $(2).tail
> + cat $(2).head $(2).tail > $(2)
> + rm -f $(2).head $(2).tail
> +endef
> +
> define Image/Build/wgt634u
> dd if=$(KDIR)/loader.elf of=$(BIN_DIR)/$(IMG_PREFIX)-wgt634u-$(2).bin bs=131072 conv=sync
> cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx >> $(BIN_DIR)/$(IMG_PREFIX)-wgt634u-$(2).bin
> @@ -71,6 +82,10 @@ define Image/Build/Edi
> $(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(3).bin
> endef
>
> +define Image/Build/Belkin
> + $(call Image/Build/Belkin_,$(BIN_DIR)/$(IMG_PREFIX)-$(1).trx,$(BIN_DIR)/openwrt-$(2)-$(patsubst jffs2-%,jffs2,$(1)).bin,$(3))
> +endef
> +
> define Image/Build/Huawei
> dd if=/dev/zero of=$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(3)-gz.bin bs=92 count=1
> echo -ne 'HDR0\x08\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(3)-gz.bin
> @@ -362,6 +377,10 @@ define Image/Build
> -f $(KDIR)/vmlinux.gz \
> $(call trxalign/$(1),$(1))
> $(call Image/Build/$(SUBTARGET)/$(1),$(1))
> + $(call Image/Build/Belkin,$(1),f7d3301,'\x22\x03\x10\x20')
> + $(call Image/Build/Belkin,$(1),f7d3302,'\x28\x09\x09\x20')
> + $(call Image/Build/Belkin,$(1),f7d4302,'\x06\x10\x10\x20')
> + $(call Image/Build/Belkin,$(1),f7d4401,'\x17\x85\x01\x00')
> # $(call Image/Build/Chk,$(1),wgr614_v9,U12H094T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
> # $(call Image/Build/Chk,$(1),wndr3400_vcna,U12H155T01_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
> # $(call Image/Build/Chk,$(1),wnr3500U,U12H136T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
Please use the new image building system.
> diff --git a/target/linux/brcm47xx/patches-3.18/032-11-MIPS-BCM47XX-Include-Belkin-F7D4XXX-F7D3XXX-TRX-for-mtd.patch b/target/linux/brcm47xx/patches-3.18/032-11-MIPS-BCM47XX-Include-Belkin-F7D4XXX-F7D3XXX-TRX-for-mtd.patch
> new file mode 100644
> index 0000000..8e2c1df
> --- /dev/null
> +++ b/target/linux/brcm47xx/patches-3.18/032-11-MIPS-BCM47XX-Include-Belkin-F7D4XXX-F7D3XXX-TRX-for-mtd.patch
> @@ -0,0 +1,43 @@
> +--- a/drivers/mtd/bcm47xxpart.c
> ++++ b/drivers/mtd/bcm47xxpart.c
> +@@ -45,6 +45,10 @@
> + #define TRX_MAGIC 0x30524448
> + #define SHSQ_MAGIC 0x71736873 /* shsq (weird ZTE H218N endianness) */
> + #define UBI_EC_MAGIC 0x23494255 /* UBI# */
> ++#define BELKIN_F7D3301_MAGIC 0x20100322 /* Belkin TRX */
> ++#define BELKIN_F7D3302_MAGIC 0x20090928
> ++#define BELKIN_F7D4302_MAGIC 0x20101006
> ++#define BELKIN_F7D4401_MAGIC 0x00018517
> +
> + struct trx_header {
> + uint32_t magic;
> +@@ -55,6 +59,20 @@ struct trx_header {
> + uint32_t offset[3];
> + } __packed;
> +
> ++static bool is_trx_magic(uint32_t magic)
> ++{
> ++ switch (magic) {
> ++ case TRX_MAGIC:
> ++ case BELKIN_F7D3301_MAGIC:
> ++ case BELKIN_F7D3302_MAGIC:
> ++ case BELKIN_F7D4302_MAGIC:
> ++ case BELKIN_F7D4401_MAGIC:
> ++ return true;
> ++ default:
> ++ return false;
> ++ }
> ++}
> ++
> + static void bcm47xxpart_add_part(struct mtd_partition *part, const char *name,
> + u64 offset, uint32_t mask_flags)
> + {
> +@@ -189,7 +207,7 @@ static int bcm47xxpart_parse(struct mtd_
> + }
> +
> + /* TRX */
> +- if (buf[0x000 / 4] == TRX_MAGIC) {
> ++ if (is_trx_magic(buf[0x000 / 4])) {
> + if (BCM47XXPART_MAX_PARTS - curr_part < 4) {
> + pr_warn("Not enough partitions left to register trx, scanning stopped!\n");
> + break;
> --
> 2.1.4
I still would love to see it upstreamed. No, it's not a requirement in
general, but I have bad experience with out of tree patches like this.
For months we have:
[PATCH] mtd: bcm47xxpart: support for Xiaomi specific board_data partition
[PATCH] mtd: bcm47xxpart: detect T_Meter partition
that I can't get tested.
Your patch is based on the OpenWrt's older bcm47xxpart.c and I've
already submitted endianess cleanup for the upstram driver. Having
your in OpenWrt will force someone to rebase it at some point, etc.
In general it could be easier for you & us to split this patch into
smaller ones. There are parts that could be pushed as they are I
believe.
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list