diff mbox series

[2/2] bcm4908: build flashable & bootable firmware images

Message ID 20210115094413.26597-2-zajec5@gmail.com
State Changes Requested
Delegated to: Rafał Miłecki
Headers show
Series [1/2] bcm63xx-cfe: enable package for bcm4908 | expand

Commit Message

Rafał Miłecki Jan. 15, 2021, 9:44 a.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

BCM4908 bootloader requires firmware with JFFS2 image containing:
1. cferam.000
2. 94908.dtb
3. vmlinux.lz
4. device custom files

cferam.000 can be obtained from the bcm63xx-cfe repository. It requires
specifying directory path that is defined using COMPATIBLE variable.

For convenience directories with device custom files are named the same
way.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 target/linux/bcm4908/image/Makefile           | 19 +++++++++++++++++++
 .../image/asus,gt-ac5300/rom/etc/image_ident  |  2 ++
 .../asus,gt-ac5300/rom/etc/image_version      |  1 +
 .../image/netgear,r8000p/etc/image_ident      |  4 ++++
 .../image/netgear,r8000p/etc/image_version    |  1 +
 5 files changed, 27 insertions(+)
 create mode 100644 target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_ident
 create mode 100644 target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_version
 create mode 100644 target/linux/bcm4908/image/netgear,r8000p/etc/image_ident
 create mode 100644 target/linux/bcm4908/image/netgear,r8000p/etc/image_version

Comments

Adrian Schmutzler Jan. 15, 2021, 3:18 p.m. UTC | #1
Hi,

some format nitpicking again and some other comments below:

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org]
> On Behalf Of Rafal Milecki
> Sent: Freitag, 15. Januar 2021 10:44
> To: openwrt-devel@lists.openwrt.org
> Cc: Rafał Miłecki <rafal@milecki.pl>
> Subject: [PATCH 2/2] bcm4908: build flashable & bootable firmware images
> 
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> BCM4908 bootloader requires firmware with JFFS2 image containing:
> 1. cferam.000
> 2. 94908.dtb
> 3. vmlinux.lz
> 4. device custom files
> 
> cferam.000 can be obtained from the bcm63xx-cfe repository. It requires
> specifying directory path that is defined using COMPATIBLE variable.
> 
> For convenience directories with device custom files are named the same
> way.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
>  target/linux/bcm4908/image/Makefile           | 19 +++++++++++++++++++
>  .../image/asus,gt-ac5300/rom/etc/image_ident  |  2 ++
>  .../asus,gt-ac5300/rom/etc/image_version      |  1 +
>  .../image/netgear,r8000p/etc/image_ident      |  4 ++++
>  .../image/netgear,r8000p/etc/image_version    |  1 +
>  5 files changed, 27 insertions(+)
>  create mode 100644 target/linux/bcm4908/image/asus,gt-
> ac5300/rom/etc/image_ident
>  create mode 100644 target/linux/bcm4908/image/asus,gt-
> ac5300/rom/etc/image_version
>  create mode 100644
> target/linux/bcm4908/image/netgear,r8000p/etc/image_ident
>  create mode 100644
> target/linux/bcm4908/image/netgear,r8000p/etc/image_version
> 
> diff --git a/target/linux/bcm4908/image/Makefile
> b/target/linux/bcm4908/image/Makefile
> index f5db38915d..eed4779d92 100644
> --- a/target/linux/bcm4908/image/Makefile
> +++ b/target/linux/bcm4908/image/Makefile
> @@ -13,6 +13,21 @@ define Build/bcm4908kernel
>  	mv $@.new $@
>  endef
> 
> +define Build/bcm4908img
> +	rm -fr $@-bootfs
> +	mkdir -p $@-bootfs
> +	cp -r $(COMPATIBLE)/* $@-bootfs/
> +	touch $@-bootfs/1-dummy
> +	cp $(DTS_DIR)/$(firstword $(DEVICE_DTS)).dtb $@-bootfs/94908.dtb
> +	cp $(KDIR)/bcm63xx-cfe/$(COMPATIBLE)/cferam.000 $@-bootfs/
> +	cp $(IMAGE_KERNEL) $@-bootfs/vmlinux.lz
> +
> +	$(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad --little-endian --squash-
> uids -v -e 128KiB -o $@-bootfs.jffs2 -d $@-bootfs -m none -n
> +	$(STAGING_DIR_HOST)/bin/bcm4908img create $@ -f $@-
> bootfs.jffs2 endef
> +
> +DEVICE_VARS += COMPATIBLE
> +
>  define Device/Default
>    KERNEL := kernel-bin | bcm4908lzma | bcm4908kernel
>    KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts) @@ -
> 29,7 +44,9 @@ define Device/asus_gt-ac5300
>    DEVICE_VENDOR := Asus
>    DEVICE_MODEL := GT-AC5300
>    DEVICE_DTS := broadcom/bcm4908/bcm4908-asus-gt-ac5300
> +  COMPATIBLE := asus,gt-ac5300

Consider using just the SUPPORTED_DEVICES variable name here instead. Even if it's not used here for updating, it's essentially where the current compatible is stored on almost all of the other targets, and it's in DEVICE_VARS by default. (One can use $(firstword $(SUPPORTED_DEVICES)) to be sure in Build/bcm4908img then)

Apart from that (and independent of whether you change the name or not), we should define a default value for this in Device/Default:

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

This will cover all current cases, and it can easily be overwritten by device-specific definitions where necessary.

>    IMAGES := bin
> +  IMAGE/bin := bcm4908img
>  endef
>  TARGET_DEVICES += asus_gt-ac5300
> 
> @@ -37,7 +54,9 @@ define Device/netgear_r8000p
>    DEVICE_VENDOR := Netgear
>    DEVICE_MODEL := R8000P
>    DEVICE_DTS := broadcom/bcm4908/bcm4906-netgear-r8000p
> +  COMPATIBLE := netgear,r8000p
>    IMAGES := bin
> +  IMAGE/bin := bcm4908img
>  endef
>  TARGET_DEVICES += netgear_r8000p
> 
> diff --git a/target/linux/bcm4908/image/asus,gt-
> ac5300/rom/etc/image_ident b/target/linux/bcm4908/image/asus,gt-
> ac5300/rom/etc/image_ident
> new file mode 100644
> index 0000000000..9e73fe74a7
> --- /dev/null
> +++ b/target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_ident

Can you point me at where these files are picked up (in code)?

I wonder whether we can replace the commas here something less strange for file names (preferably underscores so we simply use DEVICE_NAME variable).

Best

Adrian

> @@ -0,0 +1,2 @@
> +@(#) $imageversion: HND1731918 $
> +@(#) $imageversion: HND1731918 $
> diff --git a/target/linux/bcm4908/image/asus,gt-
> ac5300/rom/etc/image_version b/target/linux/bcm4908/image/asus,gt-
> ac5300/rom/etc/image_version
> new file mode 100644
> index 0000000000..fd67746f78
> --- /dev/null
> +++ b/target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_version
> @@ -0,0 +1 @@
> +HND1731918
> diff --git a/target/linux/bcm4908/image/netgear,r8000p/etc/image_ident
> b/target/linux/bcm4908/image/netgear,r8000p/etc/image_ident
> new file mode 100644
> index 0000000000..15cb69d1af
> --- /dev/null
> +++ b/target/linux/bcm4908/image/netgear,r8000p/etc/image_ident
> @@ -0,0 +1,4 @@
> +@(#) $imageversion: 5024HNDrc11R8000P2602103 $
> +@(#) $imageversion: 5024HNDrc11R8000P2602103 $
> +@(#) $changelist: Changelist:
> REL_502HND04rc11_BISON04T_REL_7_14_170_34Revision:   765096 $
> +@(#) $changelist: Changelist:
> REL_502HND04rc11_BISON04T_REL_7_14_170_34Revision:   765096 $
> diff --git a/target/linux/bcm4908/image/netgear,r8000p/etc/image_version
> b/target/linux/bcm4908/image/netgear,r8000p/etc/image_version
> new file mode 100644
> index 0000000000..f469dfed31
> --- /dev/null
> +++ b/target/linux/bcm4908/image/netgear,r8000p/etc/image_version
> @@ -0,0 +1 @@
> +5024HNDrc11R8000P2602103
> --
> 2.26.2
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Rafał Miłecki Jan. 18, 2021, 6:29 a.m. UTC | #2
On 15.01.2021 16:18, Adrian Schmutzler wrote:
>> -----Original Message-----
>> From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org]
>> On Behalf Of Rafal Milecki
>> Sent: Freitag, 15. Januar 2021 10:44
>> To: openwrt-devel@lists.openwrt.org
>> Cc: Rafał Miłecki <rafal@milecki.pl>
>> Subject: [PATCH 2/2] bcm4908: build flashable & bootable firmware images
>>
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> BCM4908 bootloader requires firmware with JFFS2 image containing:
>> 1. cferam.000
>> 2. 94908.dtb
>> 3. vmlinux.lz
>> 4. device custom files
>>
>> cferam.000 can be obtained from the bcm63xx-cfe repository. It requires
>> specifying directory path that is defined using COMPATIBLE variable.
>>
>> For convenience directories with device custom files are named the same
>> way.
>>
>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>> ---
>>   target/linux/bcm4908/image/Makefile           | 19 +++++++++++++++++++
>>   .../image/asus,gt-ac5300/rom/etc/image_ident  |  2 ++
>>   .../asus,gt-ac5300/rom/etc/image_version      |  1 +
>>   .../image/netgear,r8000p/etc/image_ident      |  4 ++++
>>   .../image/netgear,r8000p/etc/image_version    |  1 +
>>   5 files changed, 27 insertions(+)
>>   create mode 100644 target/linux/bcm4908/image/asus,gt-
>> ac5300/rom/etc/image_ident
>>   create mode 100644 target/linux/bcm4908/image/asus,gt-
>> ac5300/rom/etc/image_version
>>   create mode 100644
>> target/linux/bcm4908/image/netgear,r8000p/etc/image_ident
>>   create mode 100644
>> target/linux/bcm4908/image/netgear,r8000p/etc/image_version
>>
>> diff --git a/target/linux/bcm4908/image/Makefile
>> b/target/linux/bcm4908/image/Makefile
>> index f5db38915d..eed4779d92 100644
>> --- a/target/linux/bcm4908/image/Makefile
>> +++ b/target/linux/bcm4908/image/Makefile
>> @@ -13,6 +13,21 @@ define Build/bcm4908kernel
>>   	mv $@.new $@
>>   endef
>>
>> +define Build/bcm4908img
>> +	rm -fr $@-bootfs
>> +	mkdir -p $@-bootfs
>> +	cp -r $(COMPATIBLE)/* $@-bootfs/
>> +	touch $@-bootfs/1-dummy
>> +	cp $(DTS_DIR)/$(firstword $(DEVICE_DTS)).dtb $@-bootfs/94908.dtb
>> +	cp $(KDIR)/bcm63xx-cfe/$(COMPATIBLE)/cferam.000 $@-bootfs/
>> +	cp $(IMAGE_KERNEL) $@-bootfs/vmlinux.lz
>> +
>> +	$(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad --little-endian --squash-
>> uids -v -e 128KiB -o $@-bootfs.jffs2 -d $@-bootfs -m none -n
>> +	$(STAGING_DIR_HOST)/bin/bcm4908img create $@ -f $@-
>> bootfs.jffs2 endef
>> +
>> +DEVICE_VARS += COMPATIBLE
>> +
>>   define Device/Default
>>     KERNEL := kernel-bin | bcm4908lzma | bcm4908kernel
>>     KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts) @@ -
>> 29,7 +44,9 @@ define Device/asus_gt-ac5300
>>     DEVICE_VENDOR := Asus
>>     DEVICE_MODEL := GT-AC5300
>>     DEVICE_DTS := broadcom/bcm4908/bcm4908-asus-gt-ac5300
>> +  COMPATIBLE := asus,gt-ac5300
> 
> Consider using just the SUPPORTED_DEVICES variable name here instead. Even if it's not used here for updating, it's essentially where the current compatible is stored on almost all of the other targets, and it's in DEVICE_VARS by default. (One can use $(firstword $(SUPPORTED_DEVICES)) to be sure in Build/bcm4908img then)

Sounds good, thanks!


> Apart from that (and independent of whether you change the name or not), we should define a default value for this in Device/Default:
> 
> SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
> or
> COMPATIBLE := $(subst _,$(comma),$(1))
> 
> This will cover all current cases, and it can easily be overwritten by device-specific definitions where necessary.
> 
>>     IMAGES := bin
>> +  IMAGE/bin := bcm4908img
>>   endef
>>   TARGET_DEVICES += asus_gt-ac5300
>>
>> @@ -37,7 +54,9 @@ define Device/netgear_r8000p
>>     DEVICE_VENDOR := Netgear
>>     DEVICE_MODEL := R8000P
>>     DEVICE_DTS := broadcom/bcm4908/bcm4906-netgear-r8000p
>> +  COMPATIBLE := netgear,r8000p
>>     IMAGES := bin
>> +  IMAGE/bin := bcm4908img
>>   endef
>>   TARGET_DEVICES += netgear_r8000p
>>
>> diff --git a/target/linux/bcm4908/image/asus,gt-
>> ac5300/rom/etc/image_ident b/target/linux/bcm4908/image/asus,gt-
>> ac5300/rom/etc/image_ident
>> new file mode 100644
>> index 0000000000..9e73fe74a7
>> --- /dev/null
>> +++ b/target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_ident
> 
> Can you point me at where these files are picked up (in code)?
> 
> I wonder whether we can replace the commas here something less strange for file names (preferably underscores so we simply use DEVICE_NAME variable).

Do you mean "files" as "directories" (I know every dir is a file ;) )? If
you talk about "asus,gt-ac5300", it's used by the:
cp -r $(COMPATIBLE)/* $@-bootfs/
line in the Build/bcm4908img.

As for naming, I followed what's used by the bcm63xx-cfe repo:
https://github.com/openwrt/bcm63xx-cfe
Adrian Schmutzler Jan. 18, 2021, 11:29 a.m. UTC | #3
> Do you mean "files" as "directories" (I know every dir is a file ;) )? If you talk
> about "asus,gt-ac5300", it's used by the:
> cp -r $(COMPATIBLE)/* $@-bootfs/
> line in the Build/bcm4908img.

Ah, okay. Yes, I was referring to the directory names here. I personally consider a comma in a file name a bit disturbing/confusing and since it's not really necessary I'd simply switch to the underscore naming scheme (like done for images and tmp dirs. ($@) anyway) here.
That would mean changing the folder name to "asus_gt-ac5300" and the referenced line to

cp -r $(DEVICE_NAME)/* $@-bootfs/

Since this is pure image building code at this point, using the device definition name (DEVICE_NAME) also appears the more direct approach here compared to the compatible which is the relevant identifier on the _running_ device.

> 
> As for naming, I followed what's used by the bcm63xx-cfe repo:
> https://github.com/openwrt/bcm63xx-cfe

Since these are used/selected at build time as well, I'd personally also haven chosen the underscore naming (according to DEVICE_NAME) for these.

Note that if you do apply these two "changes", you get rid of the COMPATIBLE variable at all for the proposed patch, and this is probably the reason why a variable like this is not needed for "build steps" in the other targets (at least those I know closer by now), which simply use DEVICE_NAME for stuff like that. :-)

I'd personally prefer going that way, as using DEVICE_NAME would be more consistent and expectable for this matter.

Best

Adrian


> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Rafał Miłecki Jan. 18, 2021, 11:41 a.m. UTC | #4
On 2021-01-18 12:29, Adrian Schmutzler wrote:
>> Do you mean "files" as "directories" (I know every dir is a file ;) )? 
>> If you talk
>> about "asus,gt-ac5300", it's used by the:
>> cp -r $(COMPATIBLE)/* $@-bootfs/
>> line in the Build/bcm4908img.
> 
> Ah, okay. Yes, I was referring to the directory names here. I
> personally consider a comma in a file name a bit disturbing/confusing
> and since it's not really necessary I'd simply switch to the
> underscore naming scheme (like done for images and tmp dirs. ($@)
> anyway) here.
> That would mean changing the folder name to "asus_gt-ac5300" and the
> referenced line to
> 
> cp -r $(DEVICE_NAME)/* $@-bootfs/
> 
> Since this is pure image building code at this point, using the device
> definition name (DEVICE_NAME) also appears the more direct approach
> here compared to the compatible which is the relevant identifier on
> the _running_ device.

I agree with that reasoning and I like that idea of reusing DEVICE_NAME.


>> As for naming, I followed what's used by the bcm63xx-cfe repo:
>> https://github.com/openwrt/bcm63xx-cfe
> 
> Since these are used/selected at build time as well, I'd personally
> also haven chosen the underscore naming (according to DEVICE_NAME) for
> these.
> 
> Note that if you do apply these two "changes", you get rid of the
> COMPATIBLE variable at all for the proposed patch, and this is
> probably the reason why a variable like this is not needed for "build
> steps" in the other targets (at least those I know closer by now),
> which simply use DEVICE_NAME for stuff like that. :-)
> 
> I'd personally prefer going that way, as using DEVICE_NAME would be
> more consistent and expectable for this matter.

This is repository started by Álvaro, I just followed existing schema 
there.
I don't really think I want to start discussion on that and suggest 
another
naming schema.

One more thing to consider is that more project that just OpenWrt may 
want to
use that repository. I use it e.g. in my buildroot. Such external 
projects may
find DTS "compatible" string more common that OpenWrt-specific device 
name.
Adrian Schmutzler Jan. 18, 2021, 11:50 a.m. UTC | #5
> > Note that if you do apply these two "changes", you get rid of the
> > COMPATIBLE variable at all for the proposed patch, and this is
> > probably the reason why a variable like this is not needed for "build
> > steps" in the other targets (at least those I know closer by now),
> > which simply use DEVICE_NAME for stuff like that. :-)
> >
> > I'd personally prefer going that way, as using DEVICE_NAME would be
> > more consistent and expectable for this matter.
> 
> This is repository started by Álvaro, I just followed existing schema there.
> I don't really think I want to start discussion on that and suggest another
> naming schema.
> 
> One more thing to consider is that more project that just OpenWrt may want
> to use that repository. I use it e.g. in my buildroot. Such external projects
> may find DTS "compatible" string more common that OpenWrt-specific
> device name.

I recently invested a great effort into having DEVICE_NAME and compatible consistent on a multitude of targets (except for "," vs. "_", obviously).

So, technically it's not a big difference at the moment anyway. But let's live with the current state of the cfe repo here for now.

However, I'd propose to still get rid of the COMPATIBLE variable and construct the cfe name from DEVICE_NAME directly in the Build command:

cp $(KDIR)/bcm63xx-cfe/$(subst _,$(comma),$(DEVICE_NAME))/cferam.000 $@-bootfs/

This will remove the additional variable by simply making the current soft rule to have matching device definition name and compatible a hard one.

Best

Adrian
Rafał Miłecki Jan. 18, 2021, 12:03 p.m. UTC | #6
On 2021-01-18 12:50, Adrian Schmutzler wrote:
>> > Note that if you do apply these two "changes", you get rid of the
>> > COMPATIBLE variable at all for the proposed patch, and this is
>> > probably the reason why a variable like this is not needed for "build
>> > steps" in the other targets (at least those I know closer by now),
>> > which simply use DEVICE_NAME for stuff like that. :-)
>> >
>> > I'd personally prefer going that way, as using DEVICE_NAME would be
>> > more consistent and expectable for this matter.
>> 
>> This is repository started by Álvaro, I just followed existing schema 
>> there.
>> I don't really think I want to start discussion on that and suggest 
>> another
>> naming schema.
>> 
>> One more thing to consider is that more project that just OpenWrt may 
>> want
>> to use that repository. I use it e.g. in my buildroot. Such external 
>> projects
>> may find DTS "compatible" string more common that OpenWrt-specific
>> device name.
> 
> I recently invested a great effort into having DEVICE_NAME and
> compatible consistent on a multitude of targets (except for "," vs.
> "_", obviously).
> 
> So, technically it's not a big difference at the moment anyway. But
> let's live with the current state of the cfe repo here for now.
> 
> However, I'd propose to still get rid of the COMPATIBLE variable and
> construct the cfe name from DEVICE_NAME directly in the Build command:
> 
> cp $(KDIR)/bcm63xx-cfe/$(subst _,$(comma),$(DEVICE_NAME))/cferam.000 
> $@-bootfs/
> 
> This will remove the additional variable by simply making the current
> soft rule to have matching device definition name and compatible a
> hard one.

Are you still planning on adding generic COMPATIBLE variable filling in 
the include/*.mk ? That would be nice to have I think.
Adrian Schmutzler Jan. 19, 2021, 11:30 a.m. UTC | #7
> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org]
> On Behalf Of Rafal Milecki
> Sent: Montag, 18. Januar 2021 12:42
> To: Adrian Schmutzler <mail@adrianschmutzler.de>
> Cc: 'Rafał Miłecki' <zajec5@gmail.com>; noltari@gmail.com; openwrt-
> devel@lists.openwrt.org
> Subject: Re: [PATCH 2/2] bcm4908: build flashable & bootable firmware
> images
> 
> On 2021-01-18 12:29, Adrian Schmutzler wrote:
> >> Do you mean "files" as "directories" (I know every dir is a file ;) )?
> >> If you talk
> >> about "asus,gt-ac5300", it's used by the:
> >> cp -r $(COMPATIBLE)/* $@-bootfs/
> >> line in the Build/bcm4908img.
> >
> > Ah, okay. Yes, I was referring to the directory names here. I
> > personally consider a comma in a file name a bit disturbing/confusing
> > and since it's not really necessary I'd simply switch to the
> > underscore naming scheme (like done for images and tmp dirs. ($@)
> > anyway) here.
> > That would mean changing the folder name to "asus_gt-ac5300" and the
> > referenced line to
> >
> > cp -r $(DEVICE_NAME)/* $@-bootfs/
> >
> > Since this is pure image building code at this point, using the device
> > definition name (DEVICE_NAME) also appears the more direct approach
> > here compared to the compatible which is the relevant identifier on
> > the _running_ device.
> 
> I agree with that reasoning and I like that idea of reusing DEVICE_NAME.
> 
> 
> >> As for naming, I followed what's used by the bcm63xx-cfe repo:
> >> https://github.com/openwrt/bcm63xx-cfe
> >
> > Since these are used/selected at build time as well, I'd personally
> > also haven chosen the underscore naming (according to DEVICE_NAME) for
> > these.
> >
> > Note that if you do apply these two "changes", you get rid of the
> > COMPATIBLE variable at all for the proposed patch, and this is
> > probably the reason why a variable like this is not needed for "build
> > steps" in the other targets (at least those I know closer by now),
> > which simply use DEVICE_NAME for stuff like that. :-)
> >
> > I'd personally prefer going that way, as using DEVICE_NAME would be
> > more consistent and expectable for this matter.
> 
> This is repository started by Álvaro, I just followed existing schema there.
> I don't really think I want to start discussion on that and suggest another
> naming schema.
> 
> One more thing to consider is that more project that just OpenWrt may want
> to use that repository. I use it e.g. in my buildroot. Such external projects
> may find DTS "compatible" string more common that OpenWrt-specific
> device name.

On a second thought, I think having the DEVICE_NAME based names here would still be better.
This is the logical naming based on OpenWrt build environment, and with the requirement to have device name and compatible consistent (which holds for the affected targets/devices), external builders will just have to replace one character in their (manually set) device identifier. Now we have the chance to do it right when there is still only few devices and users of this repo around.

I will write some text and throw it against Noltari and you later today ...

Best

Adrian

> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Adrian Schmutzler Jan. 19, 2021, 11:32 a.m. UTC | #8
> > cp $(KDIR)/bcm63xx-cfe/$(subst
> _,$(comma),$(DEVICE_NAME))/cferam.000
> > $@-bootfs/
> >
> > This will remove the additional variable by simply making the current
> > soft rule to have matching device definition name and compatible a
> > hard one.
> 
> Are you still planning on adding generic COMPATIBLE variable filling in the
> include/*.mk ? That would be nice to have I think.

I'm not precisely sure what you are referring to here?

Best

Adrian
Rafał Miłecki Jan. 19, 2021, 6:09 p.m. UTC | #9
On 2021-01-19 12:32, Adrian Schmutzler wrote:
>> > cp $(KDIR)/bcm63xx-cfe/$(subst
>> _,$(comma),$(DEVICE_NAME))/cferam.000
>> > $@-bootfs/
>> >
>> > This will remove the additional variable by simply making the current
>> > soft rule to have matching device definition name and compatible a
>> > hard one.
>> 
>> Are you still planning on adding generic COMPATIBLE variable filling 
>> in the
>> include/*.mk ? That would be nice to have I think.
> 
> I'm not precisely sure what you are referring to here?

Please check below quote:

On 2021-01-15 16:18, Adrian Schmutzler wrote:
> Apart from that (and independent of whether you change the name or
> not), we should define a default value for this in Device/Default:
> 
> SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
> or
> COMPATIBLE := $(subst _,$(comma),$(1))
> 
> This will cover all current cases, and it can easily be overwritten by
> device-specific definitions where necessary.
Adrian Schmutzler Jan. 19, 2021, 6:20 p.m. UTC | #10
> -----Original Message-----
> From: Rafał Miłecki [mailto:rafal@milecki.pl]
> Sent: Dienstag, 19. Januar 2021 19:09
> To: Adrian Schmutzler <mail@adrianschmutzler.de>
> Cc: 'Rafał Miłecki' <zajec5@gmail.com>; openwrt-devel@lists.openwrt.org;
> noltari@gmail.com
> Subject: Re: [PATCH 2/2] bcm4908: build flashable & bootable firmware
> images
> 
> On 2021-01-19 12:32, Adrian Schmutzler wrote:
> >> > cp $(KDIR)/bcm63xx-cfe/$(subst
> >> _,$(comma),$(DEVICE_NAME))/cferam.000
> >> > $@-bootfs/
> >> >
> >> > This will remove the additional variable by simply making the
> >> > current soft rule to have matching device definition name and
> >> > compatible a hard one.
> >>
> >> Are you still planning on adding generic COMPATIBLE variable filling
> >> in the include/*.mk ? That would be nice to have I think.
> >
> > I'm not precisely sure what you are referring to here?
> 
> Please check below quote:
> 
> On 2021-01-15 16:18, Adrian Schmutzler wrote:
> > Apart from that (and independent of whether you change the name or
> > not), we should define a default value for this in Device/Default:
> >
> > SUPPORTED_DEVICES := $(subst _,$(comma),$(1)) or COMPATIBLE :=
> $(subst
> > _,$(comma),$(1))
> >
> > This will cover all current cases, and it can easily be overwritten by
> > device-specific definitions where necessary.

I was referring to the Device/Default block in the _target_.

However, having a global SUPPORTED_DEVICES/COMPATIBLE default is actually an interesting idea I will think about now... :-)

Best

Adrian
diff mbox series

Patch

diff --git a/target/linux/bcm4908/image/Makefile b/target/linux/bcm4908/image/Makefile
index f5db38915d..eed4779d92 100644
--- a/target/linux/bcm4908/image/Makefile
+++ b/target/linux/bcm4908/image/Makefile
@@ -13,6 +13,21 @@  define Build/bcm4908kernel
 	mv $@.new $@
 endef
 
+define Build/bcm4908img
+	rm -fr $@-bootfs
+	mkdir -p $@-bootfs
+	cp -r $(COMPATIBLE)/* $@-bootfs/
+	touch $@-bootfs/1-dummy
+	cp $(DTS_DIR)/$(firstword $(DEVICE_DTS)).dtb $@-bootfs/94908.dtb
+	cp $(KDIR)/bcm63xx-cfe/$(COMPATIBLE)/cferam.000 $@-bootfs/
+	cp $(IMAGE_KERNEL) $@-bootfs/vmlinux.lz
+
+	$(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad --little-endian --squash-uids -v -e 128KiB -o $@-bootfs.jffs2 -d $@-bootfs -m none -n
+	$(STAGING_DIR_HOST)/bin/bcm4908img create $@ -f $@-bootfs.jffs2
+endef
+
+DEVICE_VARS += COMPATIBLE
+
 define Device/Default
   KERNEL := kernel-bin | bcm4908lzma | bcm4908kernel
   KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
@@ -29,7 +44,9 @@  define Device/asus_gt-ac5300
   DEVICE_VENDOR := Asus
   DEVICE_MODEL := GT-AC5300
   DEVICE_DTS := broadcom/bcm4908/bcm4908-asus-gt-ac5300
+  COMPATIBLE := asus,gt-ac5300
   IMAGES := bin
+  IMAGE/bin := bcm4908img
 endef
 TARGET_DEVICES += asus_gt-ac5300
 
@@ -37,7 +54,9 @@  define Device/netgear_r8000p
   DEVICE_VENDOR := Netgear
   DEVICE_MODEL := R8000P
   DEVICE_DTS := broadcom/bcm4908/bcm4906-netgear-r8000p
+  COMPATIBLE := netgear,r8000p
   IMAGES := bin
+  IMAGE/bin := bcm4908img
 endef
 TARGET_DEVICES += netgear_r8000p
 
diff --git a/target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_ident b/target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_ident
new file mode 100644
index 0000000000..9e73fe74a7
--- /dev/null
+++ b/target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_ident
@@ -0,0 +1,2 @@ 
+@(#) $imageversion: HND1731918 $
+@(#) $imageversion: HND1731918 $
diff --git a/target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_version b/target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_version
new file mode 100644
index 0000000000..fd67746f78
--- /dev/null
+++ b/target/linux/bcm4908/image/asus,gt-ac5300/rom/etc/image_version
@@ -0,0 +1 @@ 
+HND1731918
diff --git a/target/linux/bcm4908/image/netgear,r8000p/etc/image_ident b/target/linux/bcm4908/image/netgear,r8000p/etc/image_ident
new file mode 100644
index 0000000000..15cb69d1af
--- /dev/null
+++ b/target/linux/bcm4908/image/netgear,r8000p/etc/image_ident
@@ -0,0 +1,4 @@ 
+@(#) $imageversion: 5024HNDrc11R8000P2602103 $
+@(#) $imageversion: 5024HNDrc11R8000P2602103 $
+@(#) $changelist: Changelist: REL_502HND04rc11_BISON04T_REL_7_14_170_34Revision:   765096 $
+@(#) $changelist: Changelist: REL_502HND04rc11_BISON04T_REL_7_14_170_34Revision:   765096 $
diff --git a/target/linux/bcm4908/image/netgear,r8000p/etc/image_version b/target/linux/bcm4908/image/netgear,r8000p/etc/image_version
new file mode 100644
index 0000000000..f469dfed31
--- /dev/null
+++ b/target/linux/bcm4908/image/netgear,r8000p/etc/image_version
@@ -0,0 +1 @@ 
+5024HNDrc11R8000P2602103