Ath79: support for BHR-4GRV (like WZR-HP-G450H)

Hello.

I have Buffalo BHR-4GRV router. This model is a wired router with the same design as WZR-HP-G450H, and we can use WZR-HP-G450H's firmware for installation in ar71xx target.

I tried to install the OpenWrt firmware for WZR-HP-G450H in ath79 target to BHR-4GRV, but mtd partitions are not defined in dts and boot failed. So I added that definition in dts, however, detected only one of the two flash devices installed on BHR-4GRV.

Are there any ideas...?

initramfs bootlog (ath79)

[    0.590708] m25p80 spi0.0: w25q128 (16384 Kbytes)
[    0.595558] 5 fixed-partitions partitions found on MTD device spi0.0
[    0.601940] Creating 5 MTD partitions on "spi0.0":
[    0.606781] 0x000000000000-0x000000040000 : "u-boot"
[    0.612893] 0x000000040000-0x000000050000 : "u-boot-env"
[    0.619365] 0x000000050000-0x000000060000 : "ART"
[    0.625214] 0x000000060000-0x000001fe0000 : "firmware"
[    0.630390] mtd: partition "firmware" extends beyond the end of device "spi0.0" -- size truncated to 0xfa0000
[    0.663863] 2 uimage-fw partitions found on MTD device firmware
[    0.669842] 0x000000060000-0x0000001c7fdb : "kernel"
[    0.675895] 0x0000001c7fdb-0x000001000000 : "rootfs"
[    0.681902] mtd: device 5 (rootfs) set to be root filesystem
[    0.687713] 1 squashfs-split partitions found on MTD device rootfs
[    0.693955] 0x0000003c0000-0x000001000000 : "rootfs_data"
[    0.700409] 0x000001fe0000-0x000002000000 : "user_property"
[    0.706087] mtd: partition "user_property" is out of reach -- disabled

bootlog (ar71xx)

[    0.650545] m25p80 spi0.0: found w25q128, expected m25p80
[    0.666347] m25p80 spi0.0: w25q128 (16384 Kbytes)
[    0.673479] m25p80 spi0.1: found w25q128, expected m25p80
[    0.688527] m25p80 spi0.1: w25q128 (16384 Kbytes)
...
[    0.704419] Concatenating MTD devices:
[    0.708198] (0): "spi0.0"
[    0.710829] (1): "spi0.1"
[    0.713516] into device "flash"
...
[    0.738242] Creating 5 MTD partitions on "flash":
[    0.743055] 0x000000000000-0x000000040000 : "u-boot"
[    0.750087] 0x000000040000-0x000000050000 : "u-boot-env"
[    0.757704] 0x000000050000-0x000000060000 : "ART"
[    0.764761] 0x000000060000-0x000001fe0000 : "firmware"
[    0.854499] 2 uimage-fw partitions found on MTD device firmware
[    0.860484] 0x000000060000-0x0000001c7fdb : "kernel"
[    0.867374] 0x0000001c7fdb-0x000001fe0000 : "rootfs"
[    0.874529] mtd: device 7 (rootfs) set to be root filesystem
[    0.880288] 1 squashfs-split partitions found on MTD device rootfs
[    0.886581] 0x0000003c0000-0x000001fe0000 : "rootfs_data"
[    0.894177] 0x000001fe0000-0x000002000000 : "user_property"

What have you added?
A second node in the spi node for your second nor flash?
Please provide a code snippet or something like that.

Thanks for your reply.

I added missing &spi{ } node:

&spi {
	status = "okay";
	num-cs = <1>;

	flash@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <25000000>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "u-boot";
				reg = <0x0000000 0x0040000>;
				read-only;
			};

			partition@40000 {
				label = "u-boot-env";
				reg = <0x0040000 0x0010000>;
				//read-only;
			};

			ART: partition@50000 {
				label = "ART";
				reg = <0x0050000 0x0010000>;
				read-only;
			};

			partition@60000 {
				label = "firmware";
				reg = <0x0060000 0x1f80000>;
			};

			partition@1fe0000 {
				label = "user_property";
				reg = <0x1fe0000 0x0020000>;
				read-only;
			};
		};
	};
};

From the ar71xx bootlog i see two nor flash devices, is that true for your BHR-4GRV?

If i take a look into mach-wzr-hp-g450h.c , there is only one spi nor flash defined.

Probably your second nor flash is detected by some magic initialization code on ar71xx target... Never seen this kernel print before:

[    0.704419] Concatenating MTD devices:
[    0.708198] (0): "spi0.0"
[    0.710829] (1): "spi0.1"
[    0.713516] into device "flash"

Seems drivers/mtd/mtdconcat.c is the magic key...
This is used from within arch/mips/ath79/dev-m25p80.c.
This code does not exist in the ath79 target!

Only for clarification, you used the ar71xx images of whr-hp-g450g for your bhr-4grv, right?

Yes.

Also yes.

A simple research let me think that this mtdconcat driver isn´t supported with a dts based device definition.

The function mtd_concat_create() has to be called after registration of mtd devices and this is currently only possible with code (mach-files + init code)...

You have to live with non concated mtd devices on ath79 until anyone (or you) implement somthing that could be defined in dts to use the driver drivers/mtd/mtdconcat.c on dts based tagets.
But 16MB (one nor flash of your router) are not that bad for a router device. :slight_smile:

What you can do, you could register both mtd devices and use the second one for other purposes...

I see...
I do not have much knowledge about that field, so it seems necessary to wait to be implemented...

Although it is the best to use it in full, there are certainly enough sizes even in half. OK, I will consider your proposal, thank you! :wink:

If you want to use the two nor flash devices on your router here is a example:

Read the comment above cs-gpios = <0>, <&gpio 2 GPIO_ACTIVE_HIGH>;.
This describes how you use the single cs gpio for two devices...
The first one gets activated if the cs gpio (gpio 2) is low and the second device get active if the same gpio is high.
This should be also true for your device.

Don´t think this has a high priority because there are not that much devices that use the mtdconcat driver...

Actually I looked at that thread and I was interested in cs-gpios property, but I did not know how to identify gpio pin that might be connected, and I gave it up.

Don´t think this has a high priority because there are not that much devices that use the mtdconcat driver...

Indeed... Hmm...

If i´m right it should be exactly like in the example with cs-gpios = <0>, <&gpio 2 GPIO_ACTIVE_HIGH>;, but for your device you have two flash nodes with compatible = "jedec,spi-nor";.

If you take a look in the datasheet on page 11 you see that gpio 2 is the spi hw cs pin and this one is used for both spi devices on the exapmle. Device one gets selected if gpio two = low and device two get selected with the same gpio = high.

And the the first gpio is <0> because this says here we use the hw cs gpio (gpio 2 = low).

Oh, I see! OK, I'll try it.

For a better understanding here is the dts binding doc for spi:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/Documentation/devicetree/bindings/spi/spi-bus.txt

Thank you!

I added cs-gpios = <0>, <&gpio 2 GPIO_ACTIVE_HIGH>; and second flash definition, but failed to recognize it...

dts:

&spi {
	status = "okay";
	num-cs = <2>;
	cs-gpios = <0>, <&gpio 2 GPIO_ACTIVE_HIGH>;

	flash@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <25000000>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "u-boot";
				reg = <0x0000000 0x0040000>;
				read-only;
			};

			partition@40000 {
				label = "u-boot-env";
				reg = <0x0040000 0x0010000>;
				//read-only;
			};

			ART: partition@50000 {
				label = "ART";
				reg = <0x0050000 0x0010000>;
				read-only;
			};

			partition@60000 {
				label = "firmware";
				reg = <0x0060000 0x1f80000>;
			};

			partition@1fe0000 {
				label = "user_property";
				reg = <0x1fe0000 0x0020000>;
				read-only;
			};
		};
	};

	flash@1 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "jedec,spi-nor";
		reg = <1>;
		spi-max-frequency = <25000000>;

	};
};

log:

[    0.590748] m25p80 spi0.0: w25q128 (16384 Kbytes)
[    0.595596] 5 fixed-partitions partitions found on MTD device spi0.0
[    0.601986] Creating 5 MTD partitions on "spi0.0":
[    0.606827] 0x000000000000-0x000000040000 : "u-boot"
[    0.612952] 0x000000040000-0x000000050000 : "u-boot-env"
[    0.619428] 0x000000050000-0x000000060000 : "ART"
[    0.625267] 0x000000060000-0x000001fe0000 : "firmware"
[    0.630446] mtd: partition "firmware" extends beyond the end of device "spi0.0" -- size truncated to 0xfa0000
[    0.663909] 2 uimage-fw partitions found on MTD device firmware
[    0.669887] 0x000000060000-0x0000001c7fdb : "kernel"
[    0.675984] 0x0000001c7fdb-0x000001000000 : "rootfs"
[    0.681943] mtd: device 5 (rootfs) set to be root filesystem
[    0.687759] 1 squashfs-split partitions found on MTD device rootfs
[    0.694002] 0x0000003c0000-0x000001000000 : "rootfs_data"
[    0.700439] 0x000001fe0000-0x000002000000 : "user_property"
[    0.706117] mtd: partition "user_property" is out of reach -- disabled
[    0.716972] m25p80 spi0.1: unrecognized JEDEC id bytes: 00, 00, 00
[    0.723233] m25p80: probe of spi0.1 failed with error -2

In ar71xx target, as usual it will be recognized normally.

In dts must be:

	num-cs = <2>;
	cs-gpios = <0>, <0>;

The mach-wzr-hp-g450h.c profile use:

...
ath79_register_m25p80_multi(&wzrhpg450h_flash_data);
..

Where multi means two HW Chip Selects and two NOR-flash devices.
(dev-m25p80.c#L94)

1 Like

Thank you for your reply.

It works, and second flash is recognized!

I see. Thank you!

Support for BHR-4GRV (ath79) was marged, thanks for all!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.