diff mbox series

[RFC] aquantia-firmware: package MediaTek's Aquantia AQR113C firmware

Message ID 20240205132308.24015-1-zajec5@gmail.com
State RFC
Delegated to: Rafał Miłecki
Headers show
Series [RFC] aquantia-firmware: package MediaTek's Aquantia AQR113C firmware | expand

Commit Message

Rafał Miłecki Feb. 5, 2024, 1:23 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

Aquantia AQR113C is PHY that needs loading a firmware. Some devices may
have it stored on flash and some need filesystem to provide it.

MediaTek holds its own AQR113C firmware file for its boards. Package it.

The problem is obtaining that firmware:
1. Cloning whole repo seems like an overkill for copying a single file
2. Public git server doesn't support git protocol (and so git archive)
3. Gitiles UI doesn't allow downloading raw files (nor binaries as text)

The only option seems to be downloading tar archive of "firmware"
directory. The problem is such archives generated by Gitiles differ on
every download so a checksum can't be specified.

Due to all above a custom download is implemented in "Build/Prepare".
Then firmware gets simply extracted and packaged.

Cc: Robert Marko <robimarko@gmail.com>
Cc: Christian Marangi <ansuelsmth@gmail.com>
Cc: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 package/firmware/aquantia-firmware/Makefile | 36 +++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 package/firmware/aquantia-firmware/Makefile

Comments

Robert Marko Feb. 5, 2024, 2:15 p.m. UTC | #1
On Mon, 5 Feb 2024 at 14:23, Rafał Miłecki <zajec5@gmail.com> wrote:
>
> From: Rafał Miłecki <rafal@milecki.pl>
>
> Aquantia AQR113C is PHY that needs loading a firmware. Some devices may
> have it stored on flash and some need filesystem to provide it.
>
> MediaTek holds its own AQR113C firmware file for its boards. Package it.

Hi Rafal, not going into details of this patch, but what is the
license situation with
redistributing the AQR firmware?

Regards,
Robert
>
> The problem is obtaining that firmware:
> 1. Cloning whole repo seems like an overkill for copying a single file
> 2. Public git server doesn't support git protocol (and so git archive)
> 3. Gitiles UI doesn't allow downloading raw files (nor binaries as text)
>
> The only option seems to be downloading tar archive of "firmware"
> directory. The problem is such archives generated by Gitiles differ on
> every download so a checksum can't be specified.
>
> Due to all above a custom download is implemented in "Build/Prepare".
> Then firmware gets simply extracted and packaged.
>
> Cc: Robert Marko <robimarko@gmail.com>
> Cc: Christian Marangi <ansuelsmth@gmail.com>
> Cc: Daniel Golle <daniel@makrotopia.org>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
>  package/firmware/aquantia-firmware/Makefile | 36 +++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>  create mode 100644 package/firmware/aquantia-firmware/Makefile
>
> diff --git a/package/firmware/aquantia-firmware/Makefile b/package/firmware/aquantia-firmware/Makefile
> new file mode 100644
> index 0000000000..9cf67f41bb
> --- /dev/null
> +++ b/package/firmware/aquantia-firmware/Makefile
> @@ -0,0 +1,36 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +include $(TOPDIR)/rules.mk
> +
> +PKG_NAME:=aquantia-firmware
> +PKG_RELEASE:=1
> +
> +include $(INCLUDE_DIR)/package.mk
> +
> +define Package/aquantia-mediatek-aqr113c-firmware
> +  SECTION:=firmware
> +  CATEGORY:=Firmware
> +  TITLE:=MediaTek's firmware for Aquantia AQR113C
> +endef
> +
> +define Build/Prepare
> +       mkdir -p $(PKG_BUILD_DIR)
> +
> +       # Download for "aquantia-mediatek-aqr113c-firmware" package
> +       wget \
> +               -O $(DL_DIR)/mtk-openwrt-feeds-refs_heads_master-21.02-files-target-linux-mediatek-mt7988-base-files-lib-firmware.tar.gz \
> +               "https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+archive/refs/heads/master/21.02/files/target/linux/mediatek/mt7988/base-files/lib/firmware.tar.gz"
> +       tar xf $(DL_DIR)/mtk-openwrt-feeds-refs_heads_master-21.02-files-target-linux-mediatek-mt7988-base-files-lib-firmware.tar.gz -C $(PKG_BUILD_DIR)
> +       # TODO: Verify extracted firmware checksum
> +endef
> +
> +define Build/Compile
> +
> +endef
> +
> +define Package/aquantia-mediatek-aqr113c-firmware/install
> +       $(INSTALL_DIR) $(1)/lib/firmware
> +       $(INSTALL_DATA) $(PKG_BUILD_DIR)/Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld $(1)/lib/firmware/
> +endef
> +
> +$(eval $(call BuildPackage,aquantia-mediatek-aqr113c-firmware))
> --
> 2.35.3
>
Daniel Golle Feb. 5, 2024, 2:21 p.m. UTC | #2
On Mon, Feb 05, 2024 at 02:23:08PM +0100, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> Aquantia AQR113C is PHY that needs loading a firmware. Some devices may
> have it stored on flash and some need filesystem to provide it.

Are you aware of any MediaTek boards which do come with AQR113C but
don't bring their own dedicated firmware flash/EEPROM IC connected
directly to first PHY?
UniFi 6 LR v1/v2 (Aquantia AQR112C) and MT7988RFB (Aquantia AQR113C)
both come with a dedidated flash/EEPROM IC for the PHY firmware.
However, that firmware (esp. on the UniFi 6 LR) may of course be
outdated by now and we may want to load newer firmware from within
Linux anyway.

> 
> MediaTek holds its own AQR113C firmware file for its boards. Package it.
> 
> The problem is obtaining that firmware:
> 1. Cloning whole repo seems like an overkill for copying a single file
> 2. Public git server doesn't support git protocol (and so git archive)
> 3. Gitiles UI doesn't allow downloading raw files (nor binaries as text)
> 
> The only option seems to be downloading tar archive of "firmware"
> directory. The problem is such archives generated by Gitiles differ on
> every download so a checksum can't be specified.
> 
> Due to all above a custom download is implemented in "Build/Prepare".
> Then firmware gets simply extracted and packaged.
> 
> Cc: Robert Marko <robimarko@gmail.com>
> Cc: Christian Marangi <ansuelsmth@gmail.com>
> Cc: Daniel Golle <daniel@makrotopia.org>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
>  package/firmware/aquantia-firmware/Makefile | 36 +++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>  create mode 100644 package/firmware/aquantia-firmware/Makefile
> 
> diff --git a/package/firmware/aquantia-firmware/Makefile b/package/firmware/aquantia-firmware/Makefile
> new file mode 100644
> index 0000000000..9cf67f41bb
> --- /dev/null
> +++ b/package/firmware/aquantia-firmware/Makefile
> @@ -0,0 +1,36 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +include $(TOPDIR)/rules.mk
> +
> +PKG_NAME:=aquantia-firmware
> +PKG_RELEASE:=1

PKG_VERSION ?

PKG_LICENSE ?

> +
> +include $(INCLUDE_DIR)/package.mk
> +
> +define Package/aquantia-mediatek-aqr113c-firmware
> +  SECTION:=firmware
> +  CATEGORY:=Firmware
> +  TITLE:=MediaTek's firmware for Aquantia AQR113C
> +endef
> +
> +define Build/Prepare
> +	mkdir -p $(PKG_BUILD_DIR)
> +
> +	# Download for "aquantia-mediatek-aqr113c-firmware" package
> +	wget \
> +		-O $(DL_DIR)/mtk-openwrt-feeds-refs_heads_master-21.02-files-target-linux-mediatek-mt7988-base-files-lib-firmware.tar.gz \
> +		"https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+archive/refs/heads/master/21.02/files/target/linux/mediatek/mt7988/base-files/lib/firmware.tar.gz"
> +	tar xf $(DL_DIR)/mtk-openwrt-feeds-refs_heads_master-21.02-files-target-linux-mediatek-mt7988-base-files-lib-firmware.tar.gz -C $(PKG_BUILD_DIR)
> +	# TODO: Verify extracted firmware checksum
> +endef
> +
> +define Build/Compile
> +
> +endef
> +
> +define Package/aquantia-mediatek-aqr113c-firmware/install
> +	$(INSTALL_DIR) $(1)/lib/firmware
> +	$(INSTALL_DATA) $(PKG_BUILD_DIR)/Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld $(1)/lib/firmware/
> +endef
> +
> +$(eval $(call BuildPackage,aquantia-mediatek-aqr113c-firmware))
> -- 
> 2.35.3
>
Rafał Miłecki Feb. 5, 2024, 7:10 p.m. UTC | #3
On 5.02.2024 15:15, Robert Marko wrote:
> On Mon, 5 Feb 2024 at 14:23, Rafał Miłecki <zajec5@gmail.com> wrote:
>>
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> Aquantia AQR113C is PHY that needs loading a firmware. Some devices may
>> have it stored on flash and some need filesystem to provide it.
>>
>> MediaTek holds its own AQR113C firmware file for its boards. Package it.
> 
> Hi Rafal, not going into details of this patch, but what is the
> license situation with
> redistributing the AQR firmware?

Good question. I don't know.

Cc linux-mediatek@
Can we get some licensing help, please?



Initial firmware file
Rhe-05.06-Candidate7-AQR_Mediatek_23B_StartOff_ID45623_VER36657.cld was
added in the commit:

commit 24ba51c5be18613127b2d8407b0223174624b130
Author: developer <developer@mediatek.com>
Date:   Tue Nov 15 11:22:46 2022 +0800

     [][kernel][mt7988][eth][Change AQR113C firmware download method to MDIO gangload]

     [Description]
     Change AQR113C firmware download method to MDIO gangload.

     If without this patch, AQR113C cannot boot from MDIO gangload.

     [Release-log]
     N/A


     Change-Id: Iddc29f5e1c73c772bcea9313938b6daccc10025a
     Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6781059

with not licensing details.



Later there was a firmware update update handled by adding file:
Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld in the commit:

commit 405b1e31f924b97d379719fb39f0d28c0fac43a9
Author: developer <developer@mediatek.com>
Date:   Tue Mar 28 17:00:41 2023 +0800

     [][kernel][mt7988][eth][Fix AQR113C 5GBASE-T compliance test mode4 tone1 fail issue]

     [Description]
     Fix AQR113C 5GBASE-T compliance test mode4 tone1 fail issue by
     updating firmware version to
     Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld.

     If without this patch, AQR113C might not pass the 5GBASE-T mode4 tone1
     items for the compliance test.

     [Release-log]
     N/A


     Change-Id: I3b2c6e6cf1a6ba8183daa7e30110ff2c839c5989
     Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7305781

but again with not licensing info.



I also can't find any readme file specifying licensing of those files.
Rafał Miłecki Feb. 5, 2024, 7:21 p.m. UTC | #4
On 5.02.2024 15:21, Daniel Golle wrote:
> On Mon, Feb 05, 2024 at 02:23:08PM +0100, Rafał Miłecki wrote:
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> Aquantia AQR113C is PHY that needs loading a firmware. Some devices may
>> have it stored on flash and some need filesystem to provide it.
> 
> Are you aware of any MediaTek boards which do come with AQR113C but
> don't bring their own dedicated firmware flash/EEPROM IC connected
> directly to first PHY?
> UniFi 6 LR v1/v2 (Aquantia AQR112C) and MT7988RFB (Aquantia AQR113C)
> both come with a dedidated flash/EEPROM IC for the PHY firmware.
> However, that firmware (esp. on the UniFi 6 LR) may of course be
> outdated by now and we may want to load newer firmware from within
> Linux anyway.

I'm not sure if I can verify using Linux if there is EEPROM attached to
any of two PHYs on my board. I don't believe Linux's PHY driver exposes
possibly-attached EEPROM as any Linux device.

I think however that with EEPROM present I wouldn't need Linux driver
to load PHY firmware. In my board case I need to do that which makes me
believe there is no EEPROM chip with firmware present.
Christian Marangi Feb. 5, 2024, 7:51 p.m. UTC | #5
On Mon, Feb 05, 2024 at 08:21:43PM +0100, Rafał Miłecki wrote:
> On 5.02.2024 15:21, Daniel Golle wrote:
> > On Mon, Feb 05, 2024 at 02:23:08PM +0100, Rafał Miłecki wrote:
> > > From: Rafał Miłecki <rafal@milecki.pl>
> > > 
> > > Aquantia AQR113C is PHY that needs loading a firmware. Some devices may
> > > have it stored on flash and some need filesystem to provide it.
> > 
> > Are you aware of any MediaTek boards which do come with AQR113C but
> > don't bring their own dedicated firmware flash/EEPROM IC connected
> > directly to first PHY?
> > UniFi 6 LR v1/v2 (Aquantia AQR112C) and MT7988RFB (Aquantia AQR113C)
> > both come with a dedidated flash/EEPROM IC for the PHY firmware.
> > However, that firmware (esp. on the UniFi 6 LR) may of course be
> > outdated by now and we may want to load newer firmware from within
> > Linux anyway.
> 
> I'm not sure if I can verify using Linux if there is EEPROM attached to
> any of two PHYs on my board. I don't believe Linux's PHY driver exposes
> possibly-attached EEPROM as any Linux device.
> 
> I think however that with EEPROM present I wouldn't need Linux driver
> to load PHY firmware. In my board case I need to do that which makes me
> believe there is no EEPROM chip with firmware present.
>

Just to be clear, the EEPROM (actually it's a spi) is attached directly
to the PHY internally, you don't have a way to expose it in linux...

Also in that configuration, the FW is loaded automatically and with the
current driver, fw loading is skipped as a correct FW version is read
from the PHY. (FW loading from attached EEPROM is setup by hw strapping)

There is no need to verify if an EEPROM is attached, the check we do
is either a FW is present and loaded or a FW is not loaded and the PHY
FW version reg answer with 0.0.0 (or 0xff if held in reset state)
Arınç ÜNAL Feb. 6, 2024, 7:12 p.m. UTC | #6
On 5.02.2024 22:10, Rafał Miłecki wrote:
> On 5.02.2024 15:15, Robert Marko wrote:
>> On Mon, 5 Feb 2024 at 14:23, Rafał Miłecki <zajec5@gmail.com> wrote:
>>>
>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>
>>> Aquantia AQR113C is PHY that needs loading a firmware. Some devices may
>>> have it stored on flash and some need filesystem to provide it.
>>>
>>> MediaTek holds its own AQR113C firmware file for its boards. Package it.
>>
>> Hi Rafal, not going into details of this patch, but what is the
>> license situation with
>> redistributing the AQR firmware?
> 
> Good question. I don't know.
> 
> Cc linux-mediatek@
> Can we get some licensing help, please?
> 
> 
> 
> Initial firmware file
> Rhe-05.06-Candidate7-AQR_Mediatek_23B_StartOff_ID45623_VER36657.cld was
> added in the commit:
> 
> commit 24ba51c5be18613127b2d8407b0223174624b130
> Author: developer <developer@mediatek.com>
> Date:   Tue Nov 15 11:22:46 2022 +0800
> 
>      [][kernel][mt7988][eth][Change AQR113C firmware download method to MDIO gangload]
> 
>      [Description]
>      Change AQR113C firmware download method to MDIO gangload.
> 
>      If without this patch, AQR113C cannot boot from MDIO gangload.
> 
>      [Release-log]
>      N/A
> 
> 
>      Change-Id: Iddc29f5e1c73c772bcea9313938b6daccc10025a
>      Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6781059
> 
> with not licensing details.
> 
> 
> 
> Later there was a firmware update update handled by adding file:
> Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld in the commit:
> 
> commit 405b1e31f924b97d379719fb39f0d28c0fac43a9
> Author: developer <developer@mediatek.com>
> Date:   Tue Mar 28 17:00:41 2023 +0800
> 
>      [][kernel][mt7988][eth][Fix AQR113C 5GBASE-T compliance test mode4 tone1 fail issue]
> 
>      [Description]
>      Fix AQR113C 5GBASE-T compliance test mode4 tone1 fail issue by
>      updating firmware version to
>      Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld.
> 
>      If without this patch, AQR113C might not pass the 5GBASE-T mode4 tone1
>      items for the compliance test.
> 
>      [Release-log]
>      N/A
> 
> 
>      Change-Id: I3b2c6e6cf1a6ba8183daa7e30110ff2c839c5989
>      Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7305781
> 
> but again with not licensing info.
> 
> 
> 
> I also can't find any readme file specifying licensing of those files.

Maybe these should be submitted to the linux-firmware repository (by
MediaTek or with MediaTek's approval) and the license specified on the
WHENCE file.

https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/

Arınç
diff mbox series

Patch

diff --git a/package/firmware/aquantia-firmware/Makefile b/package/firmware/aquantia-firmware/Makefile
new file mode 100644
index 0000000000..9cf67f41bb
--- /dev/null
+++ b/package/firmware/aquantia-firmware/Makefile
@@ -0,0 +1,36 @@ 
+# SPDX-License-Identifier: GPL-2.0-only
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=aquantia-firmware
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/aquantia-mediatek-aqr113c-firmware
+  SECTION:=firmware
+  CATEGORY:=Firmware
+  TITLE:=MediaTek's firmware for Aquantia AQR113C
+endef
+
+define Build/Prepare
+	mkdir -p $(PKG_BUILD_DIR)
+
+	# Download for "aquantia-mediatek-aqr113c-firmware" package
+	wget \
+		-O $(DL_DIR)/mtk-openwrt-feeds-refs_heads_master-21.02-files-target-linux-mediatek-mt7988-base-files-lib-firmware.tar.gz \
+		"https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+archive/refs/heads/master/21.02/files/target/linux/mediatek/mt7988/base-files/lib/firmware.tar.gz"
+	tar xf $(DL_DIR)/mtk-openwrt-feeds-refs_heads_master-21.02-files-target-linux-mediatek-mt7988-base-files-lib-firmware.tar.gz -C $(PKG_BUILD_DIR)
+	# TODO: Verify extracted firmware checksum
+endef
+
+define Build/Compile
+
+endef
+
+define Package/aquantia-mediatek-aqr113c-firmware/install
+	$(INSTALL_DIR) $(1)/lib/firmware
+	$(INSTALL_DATA) $(PKG_BUILD_DIR)/Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld $(1)/lib/firmware/
+endef
+
+$(eval $(call BuildPackage,aquantia-mediatek-aqr113c-firmware))