Skip to content

profiles: improve SUPPORTED_DEVICES handling and profile identification#1533

Draft
map-b wants to merge 5 commits into
openwrt:mainfrom
map-b:improve-supported-devices-handling
Draft

profiles: improve SUPPORTED_DEVICES handling and profile identification#1533
map-b wants to merge 5 commits into
openwrt:mainfrom
map-b:improve-supported-devices-handling

Conversation

@map-b

@map-b map-b commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

The actual handling does not allow to several devices share a DTS compatible string to allow image compatibility between them.

  • Take the lists as lists and select the profile after checking all possible candidates.

  • Throw a new validation exception when it is not possible to identify a profile which will help to identify inconsistencies.

This also can help to make a little bit clearer the difference between "profile" and "DTS compatible string".

*There is not need to add [profile] to SUPPORTED_DEVICES list anymore.

asu/asu/util.py

Line 566 in 0328704

for name in data.get("supported_devices", []) + [profile]

Reasoning about the reverts: #1511 (comment) I would like to add that those commits would make harder to understand how we are handling the translation from Device Tree compatible strings to actual profiles names.

Before: 1

'glinet,gl-mt2500': 'glinet_gl-mt2500-airoha',                    <-- Entries are overwritten translating, wrongly to airoha variant
'glinet,mt2500-emmc': 'glinet_gl-mt2500-airoha',
'glinet,gl-mt2500-airoha': 'glinet_gl-mt2500-airoha',
'glinet_gl-mt2500': 'glinet_gl-mt2500',
'glinet_gl-mt2500-airoha': 'glinet_gl-mt2500-airoha'

After:

'glinet_gl-mt2500': ['glinet,gl-mt2500', 'glinet,mt2500-emmc', 'glinet,gl-mt2500-airoha', 'glinet_gl-mt2500'],
'glinet_gl-mt2500-airoha': ['glinet,gl-mt2500-airoha', 'glinet,mt2500-emmc', 'glinet,gl-mt2500', 'glinet_gl-mt2500-airoha'],

With this structure, select the profile where the board_name appear first in the list if the entry is shared.

Fixes: #1525
Fixes: openwrt/openwrt#20566


V2:

  • Extracted profile resolution into a standalone resolve_profile() function that handles DTS compatible → canonical profile name resolution with explicit ambiguity detection, replacing the inline valid_profile() helper.
  • Fixed a cache consistency issue: the request hash was computed from the raw board_name before profile resolution. The comma-to-underscore sanitization in get_request_hash() handled the case where board_name equals profile_name after sanitization, but not aliases resolved via the supported_devices list or the x86/armsr/... generic fallback — those produced different cache keys than the canonical profile, defeating caching.

Resolution behavior comparison (profile → list format vs flat dict):

Profiles data (profile: SUPPORTED_DEVICES list):
  engenius_esr1200:         ["engenius,esr1200", "esr1200", "esr1750", "engenius,esr1750"]
  engenius_esr1750:         ["engenius,esr1750", "esr1750", "esr1200", "engenius,esr1200"]
  ubnt_unifi-ap:            ["ubnt,unifi-ap", "unifi", "ubnt,unifi"]
  ubnt_unifi-ap-lr:         ["ubnt,unifi-ap-lr", "unifi", "ubnt,unifi", "ubnt,unifi-ap"]
Input Flat raw Flat sanitized List format
engenius_esr1200 engenius_esr1200 ✅ engenius_esr1750 ❌ engenius_esr1200 ✅
engenius,esr1200 engenius_esr1750 ❌ engenius_esr1750 ❌ engenius_esr1200 ✅
esr1200 engenius_esr1750 ❌ engenius_esr1750 ❌ error ✅
esr1750 engenius_esr1750 ❌ engenius_esr1750 ❌ error ✅
engenius,esr1750 engenius_esr1750 ✅ engenius_esr1750 ✅ engenius_esr1750 ✅
engenius_esr1750 engenius_esr1750 ✅ engenius_esr1750 ✅ engenius_esr1750 ✅
Input Flat raw Flat sanitized List format
ubnt_unifi-ap ubnt_unifi-ap ✅ ubnt_unifi-ap-lr ❌ ubnt_unifi-ap ✅
ubnt,unifi-ap ubnt_unifi-ap-lr ❌ ubnt_unifi-ap-lr ❌ ubnt_unifi-ap ✅
unifi ubnt_unifi-ap-lr ❌ ubnt_unifi-ap-lr ❌ error ✅
ubnt,unifi ubnt_unifi-ap-lr ❌ ubnt_unifi-ap-lr ❌ error ✅
ubnt_unifi-ap-lr ubnt_unifi-ap-lr ✅ ubnt_unifi-ap-lr ✅ ubnt_unifi-ap-lr ✅
ubnt,unifi-ap-lr ubnt_unifi-ap-lr ✅ ubnt_unifi-ap-lr ✅ ubnt_unifi-ap-lr ✅

Footnotes

  1. https://github.com/openwrt/asu/issues/1525#issuecomment-3497242570

@efahl

efahl commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

Hard NAK.

Is this AI slop code? You've broken event logging, broken a bug fix and removed an important test case.

As I've already explained to you several times, the root cause of this issue is incorrect metadata coming from upstream. Attempting to work around the upstream issue in the ASU server does not fix anything and leaves several other things broken (specifically both sysupgrade and the Firmware Selector).

@map-b

map-b commented Dec 5, 2025

Copy link
Copy Markdown
Contributor Author

In those two reverts, included in this PR, you were mixing totally the translation or the DT compatible strings into actually profiles, that is not sanitize that is lose track of what are the strings sended by ASU clients(if they do not try to translate before sending them) and the actual profiles which are used in ImageBuilders. It is not AI sope code, a bit unrespectfully comment was that.

If you do not want to reason, it is over, It is really sad.

Comment thread asu/routers/api.py
@map-b map-b force-pushed the improve-supported-devices-handling branch from 96024c1 to e8bf73f Compare December 5, 2025 20:11
@map-b map-b mentioned this pull request Dec 26, 2025
map-b added a commit to map-b/openwrt that referenced this pull request Feb 2, 2026
They share the same "compatible" in device tree causing some
incompatibilities (ASU profile identification), assign a unique
"compatible" and "model" to each variant.[1][2]
Commit [3] just avoided ASU profile identification limitation[4] but not
fixed the root cause.

[1]: openwrt#20632 (comment)
[2]: openwrt#20632 (comment)
[3]: openwrt@b71f466
[4]: openwrt/asu#1533
Fixes: b71f466 ("mediatek: filogic: fix supported_devices list for gl-mt2500")
Fixes: 8d30e07 ("mediatek: filogic: fix for new GL.iNet GL-MT2500/GL-MT2500A hardware revision")
Fixes: openwrt#20566
Fixes(partially): openwrt/asu#1525

Signed-off-by: Mario Andrés Pérez <mapb_@outlook.com>
map-b added a commit to map-b/openwrt that referenced this pull request Feb 5, 2026
These devices share the same "compatible" in device tree causing some
incompatibilities (sysupgrades, ASU profile identification), assign a
unique "compatible" and "model" to each variant.

Context:
Commit [1] added each variant's dts compatible to the SUPPORTED_DEVICES
field of the other variant to make easy sysupgrades between these
physically indistinguishable devices variants possible.

But there were found three issues which does not allow this:
- the sysupgrade's stricter check still used in some sysupgrade
paths(this check is being replaced(and redundant) with the newer fwtool's
SUPPORTED_DEVICES check using the info in images METADATA), this check
will fail when sysupgrading from a different board_name(compatible dts)
that the image was created for (image profile name).[2]
- ASU needs unique "dts compatible" to identify the devices profile.
- and an ASU's profile identification limitation when several devices from
a common target share SUPPORTED_DEVICES entries.[3]

There is a proposal for these issues but not yet implemented [4][3].

Until these issues are fixed we won't allow "easy" sysupgrades between
these two device variants.

Commit [5] avoided the ASU profile identification limitation but
missed the required two unique dts compatibles in order to make the two
variants fully work, although not allowing easy sysupgrade between them.

[1]: openwrt@8d30e07
[2]: sysupgrade stricter check openwrt#20566 (comment)
[3]: ASU proposal openwrt/asu#1533
[4]: allow easy sysupgrade proposal openwrt#20947
[5]: openwrt@b71f466
Fixes: b71f466 ("mediatek: filogic: fix supported_devices list for gl-mt2500")
Fixes: 8d30e07 ("mediatek: filogic: fix for new GL.iNet GL-MT2500/GL-MT2500A hardware revision")
Fixes: openwrt#20566
Fixes: openwrt/asu#1525

Signed-off-by: Mario Andrés Pérez <mapb_@outlook.com>
hauke pushed a commit to map-b/openwrt that referenced this pull request Feb 10, 2026
These devices share the same "compatible" in device tree causing some
incompatibilities (sysupgrades, ASU profile identification), assign a
unique "compatible" and "model" to each variant.

Context:
Commit [1] added each variant's dts compatible to the SUPPORTED_DEVICES
field of the other variant to make easy sysupgrades between these
physically indistinguishable devices variants possible.

But there were found three issues which does not allow this:
- the sysupgrade's stricter check still used in some sysupgrade
paths(this check is being replaced(and redundant) with the newer fwtool's
SUPPORTED_DEVICES check using the info in images METADATA), this check
will fail when sysupgrading from a different board_name(compatible dts)
that the image was created for (image profile name).[2]
- ASU needs unique "dts compatible" to identify the devices profile.
- and an ASU's profile identification limitation when several devices from
a common target share SUPPORTED_DEVICES entries.[3]

There is a proposal for these issues but not yet implemented [4][3].

Until these issues are fixed we won't allow "easy" sysupgrades between
these two device variants.

Commit [5] avoided the ASU profile identification limitation but
missed the required two unique dts compatibles in order to make the two
variants fully work, although not allowing easy sysupgrade between them.

[1]: openwrt@8d30e07
[2]: sysupgrade stricter check openwrt#20566 (comment)
[3]: ASU proposal openwrt/asu#1533
[4]: allow easy sysupgrade proposal openwrt#20947
[5]: openwrt@b71f466
Fixes: b71f466 ("mediatek: filogic: fix supported_devices list for gl-mt2500")
Fixes: 8d30e07 ("mediatek: filogic: fix for new GL.iNet GL-MT2500/GL-MT2500A hardware revision")
Fixes: openwrt#20566
Fixes: openwrt/asu#1525

Signed-off-by: Mario Andrés Pérez <mapb_@outlook.com>
Link: openwrt#21842
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
openwrt-bot pushed a commit to openwrt/openwrt that referenced this pull request Feb 10, 2026
These devices share the same "compatible" in device tree causing some
incompatibilities (sysupgrades, ASU profile identification), assign a
unique "compatible" and "model" to each variant.

Context:
Commit [1] added each variant's dts compatible to the SUPPORTED_DEVICES
field of the other variant to make easy sysupgrades between these
physically indistinguishable devices variants possible.

But there were found three issues which does not allow this:
- the sysupgrade's stricter check still used in some sysupgrade
paths(this check is being replaced(and redundant) with the newer fwtool's
SUPPORTED_DEVICES check using the info in images METADATA), this check
will fail when sysupgrading from a different board_name(compatible dts)
that the image was created for (image profile name).[2]
- ASU needs unique "dts compatible" to identify the devices profile.
- and an ASU's profile identification limitation when several devices from
a common target share SUPPORTED_DEVICES entries.[3]

There is a proposal for these issues but not yet implemented [4][3].

Until these issues are fixed we won't allow "easy" sysupgrades between
these two device variants.

Commit [5] avoided the ASU profile identification limitation but
missed the required two unique dts compatibles in order to make the two
variants fully work, although not allowing easy sysupgrade between them.

[1]: 8d30e07
[2]: sysupgrade stricter check #20566 (comment)
[3]: ASU proposal openwrt/asu#1533
[4]: allow easy sysupgrade proposal #20947
[5]: b71f466
Fixes: b71f466 ("mediatek: filogic: fix supported_devices list for gl-mt2500")
Fixes: 8d30e07 ("mediatek: filogic: fix for new GL.iNet GL-MT2500/GL-MT2500A hardware revision")
Fixes: #20566
Fixes: openwrt/asu#1525

Signed-off-by: Mario Andrés Pérez <mapb_@outlook.com>
Link: #21842
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
(cherry picked from commit 7aa1f7e)
Comment thread asu/routers/api.py Outdated
if profile in supported_devices:
return True

if len(profiles) == 1 and "generic" in profiles:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (len(profiles) == 1 or "geos" in profiles) and "generic" in profiles:

To remark that "geos" case is an exception in the "generic" targets/platforms? Adding a comment too?

@efahl I can add a separate commit for that issue since this PR is "touching" this code

slow-boat pushed a commit to slow-boat/openwrt that referenced this pull request Mar 20, 2026
These devices share the same "compatible" in device tree causing some
incompatibilities (sysupgrades, ASU profile identification), assign a
unique "compatible" and "model" to each variant.

Context:
Commit [1] added each variant's dts compatible to the SUPPORTED_DEVICES
field of the other variant to make easy sysupgrades between these
physically indistinguishable devices variants possible.

But there were found three issues which does not allow this:
- the sysupgrade's stricter check still used in some sysupgrade
paths(this check is being replaced(and redundant) with the newer fwtool's
SUPPORTED_DEVICES check using the info in images METADATA), this check
will fail when sysupgrading from a different board_name(compatible dts)
that the image was created for (image profile name).[2]
- ASU needs unique "dts compatible" to identify the devices profile.
- and an ASU's profile identification limitation when several devices from
a common target share SUPPORTED_DEVICES entries.[3]

There is a proposal for these issues but not yet implemented [4][3].

Until these issues are fixed we won't allow "easy" sysupgrades between
these two device variants.

Commit [5] avoided the ASU profile identification limitation but
missed the required two unique dts compatibles in order to make the two
variants fully work, although not allowing easy sysupgrade between them.

[1]: openwrt@8d30e07
[2]: sysupgrade stricter check openwrt#20566 (comment)
[3]: ASU proposal openwrt/asu#1533
[4]: allow easy sysupgrade proposal openwrt#20947
[5]: openwrt@2c19228
Fixes: 2c19228 ("mediatek: filogic: fix supported_devices list for gl-mt2500")
Fixes: 8d30e07 ("mediatek: filogic: fix for new GL.iNet GL-MT2500/GL-MT2500A hardware revision")
Fixes: openwrt#20566
Fixes: openwrt/asu#1525

Signed-off-by: Mario Andrés Pérez <mapb_@outlook.com>
Link: openwrt#21842
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
@map-b

map-b commented Apr 10, 2026

Copy link
Copy Markdown
Contributor Author

I have been checking for any possible side effect and I do not find any, it is the normal and well stablished use of SUPPORTED_DEVICES mechanism to allow "force-less" sysupgrades and everything works as intended except the ASU profile identification.

List of issues that are pending of this little fix, basically any "advanced" use of SUPPORTED_DEVICES:

  • NOR/NAND devices with images using either storage support.
  • Realtek target images with two RAM sizes configurations.
  • Qualcommbe device with two images for support two SFP combo modes (Eth or SFP)
  • ADSL Annex A or Annex B images
  • Mikrotic board with two images, with and without POE support.
  • Boards with different PHY but with the same hardware revision like, this PR's original example, gl-mt2500/airoha.
  • etc.

*"owut" which is the only ASU client doing a parallel translation in order to known the specific profile needed for its nice default packages analysis, for example. It must do the same translation as the ASU server. I am willing to propose the needed same little change there to mimic the ASU translation if efahl wish (TODO: this should be an api call to ASU server for doing the translation, centralizing and avoiding inconsistencies?)

@aparcar @Ansuel, I tried too much with efahl and that path only got worse and worse, sorry for appealling and pinging to you directly but this seems to be an important missing bit to fully integrate the fwtool's SUPPORTED_DEVICES with the ASU subsystem, and avoid the actual proposed workarounds(remove shared entries) which is limititing the SUPPORTED_DEVICES mechanism too much.

TLDR: The proposal is just: look at all the SUPPORTED_DEVICES lists in the target/platform (profiles.json) and select the profile which has the board_name(dts compatible) as first entry in the SUPPORTED_DEVICES list if the entry is shared by several profiles.

@map-b

map-b commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

Hard NAK.

Is this AI slop code? You've broken event logging, broken a bug fix and removed an important test case.

As I've already explained to you several times, the root cause of this issue is incorrect metadata coming from upstream. Attempting to work around the upstream issue in the ASU server does not fix anything and leaves several other things broken (specifically both sysupgrade and the Firmware Selector).

So, what should I understand from the 5 months of completely silent, no single comment? That you completely agree with efahl's unrespectfully feedback without giving a truly reasonable reason? And you just wait hopefully for me disappearing or...idk. What would you think in my shoes?

Can you point me to my own errors so I can learn from them, at least? If you both do not beat me definitively and I try to contribute in the future? The best would be you help efahl and me to find a common page... All my comments are public on GitHub and a few in the forum if you want to check. @aparcar

@aparcar

aparcar commented Apr 16, 2026

Copy link
Copy Markdown
Member

Hey @map-b thanks for your patience. There are so many things to take care of, sometimes it takes a while.

I used an AI to tackle this upstream, from my understanding this should improve the situation? I think the "supported devices" string is misleading when it secretly switches your underlying storage and thereby resets your device. This should generally be avoided... @dangowrt not sure how much time you have, but maybe you can also comment on this. We could also attach a single profile into each firmware image, by making devices "self aware", we'd avoid this entire shenanigans...

openwrt/openwrt#22952

@map-b

map-b commented Apr 16, 2026

Copy link
Copy Markdown
Contributor Author

This exactly what I am trying to avoid... 🙃.

Upstream handles this correctly (manual sysupgrading) and its one of the usefulness of the fwtool's supported_devices mechanism. It's ASU who is silently swapping the images.

Can't we generalize and consolidate the mapping/translation process in the ASU side?

There are profile and board_name which identify uniquely to images and devices respectively. The SUPPORTED_DEVICES entries represent these mappings. And the order in these lists allows identify the primary/default mapping (the first entry should have priority). *This would be the requirement in upstream side, keep the desired default as first entry in supported_devices which is the actual default behavior and it is correct in all the studied cases.

Limiting the ability to allow these cross-sysupgrades from "downstream"(ASU) does not seem correct to me. And we will be losing valuable information.

But I'm repeating myself now. *@hauke also thought in the "selecting the first entry" idea.

@Ansuel

Ansuel commented Apr 16, 2026

Copy link
Copy Markdown
Member

My 2 cent on the topic... but can't we fix this upstream? Upgrade tool shouldn't implement workaround if the project is active and things can be fixed upstream...

@map-b

map-b commented Apr 16, 2026

Copy link
Copy Markdown
Contributor Author

I'm not sure if It's a workaround, the actual profile selection in the upgrade tool is a bit, too much simple. The upstream fix is to remove the ability...?

  • Upstream provides enough (and coherent) information?
  • Based on that information, is the upgrade tool (ASU) doing well enough to select the profile, correctly?

@map-b

map-b commented Apr 20, 2026

Copy link
Copy Markdown
Contributor Author

Do we have a clear view of the problem or not? IMO there are two cases:

  1. ASU client sends the profile -> OK*. (firmware-selector and owut which needs to know the profile, to do its default_packages analysis, does the translation based on SUPPORTED_DEVICES which also has the same problem since it actually is mimicking ASU translation/mapping)
    *After "sanitization" commits asu: revert sanitize  #1554 even these "profile" cases started to fail too for the cases with shared entries in SUPPORTED_DEVICES.
  2. ASU client sends the board_name -> Not OK for the shared entries cases. (Luci ASU app)

*In both cases, ASU server is doing (during "validation request" step) a subtle translation/mapping, based on SUPPORTED_DEVICES entries from profiles.json's data, to get a proper profile name.

Bugs (in ASU side, I think):

  1. In case 1. there is not need to do the mapping/translation.
  2. We are mixing things with a "direct" translation doing the ',' -> '_' replacements.
  3. We are not accounting for the possible shared entries, not redundant since the ones which are the first in the list can be considered "special".

*The actual state, mixing profile and board_name plus replacing ',' by '_' is confusing.


If the concern is to keep ASU server simple, then simplify it and only accept profile names, not board_name.

Since the mapping/translation is only required for the on-device ASU clients, leave to them the responsibility:

  • ASU server only accepts image profile names, not board_name names.
  • ASU clients on-device (Luci ASU, owut) has to do the mapping/translation before sending the request to ASU server.
  • *Offer an independant API call on ASU server to do the translation/mapping board_name -> image profile to avoid to replicate code in ASU clients.

Regards.

@mcprat

mcprat commented Apr 30, 2026

Copy link
Copy Markdown

I fully agree with you that the fix should take place in ASU, but I think its much more simple than it seems:

The actual handling does not allow to several devices share a DTS compatible string to allow image compatibility between them.

This is completely irrelevant, two separate images should NEVER share a DTS compatible for the device. We define SUPPORTED_DEVICES to simply say that 2 images can work on 1 device, NOT that 2 identical images can work on 1 device. We don't generate identical images with different names...

There is not need to add [profile] to SUPPORTED_DEVICES list anymore.

This is the key, the profile is already in SUPPORTED_DEVICES, so either we use the profile entry or we don't care which image is used... we don't need to apply both fixes at the same time, just choose a path.

However, there is no need to "allow" a compatible image that doesn't match the profile when in reality both images are available, in other words, ASU should not decide that it is ok to change profiles during sysupgrade, that should be only up to the user in a manual sysupgrade.

so the path should be to use the profile entry only...

my example:

the two engenius devices

define Device/engenius_esr1200
  SOC := qca9557
  DEVICE_VENDOR := EnGenius
  DEVICE_MODEL := ESR1200
.......
  SUPPORTED_DEVICES += esr1200 esr1750 engenius,esr1750
endef
TARGET_DEVICES += engenius_esr1200

define Device/engenius_esr1750
  SOC := qca9558
  DEVICE_VENDOR := EnGenius
  DEVICE_MODEL := ESR1750
.......
  SUPPORTED_DEVICES += esr1750 esr1200 engenius,esr1200
endef
TARGET_DEVICES += engenius_esr1750

After these definitions are called the SUPPORTED_DEVICES lines are

engenius,esr1200 esr1200 esr1750 engenius,esr1750
and
engenius,esr1750 esr1750 esr1200 engenius,esr1200
respectively

because in image.mk we have

define Device/Init
...
  SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
...
endef

like hauke said, just select the first one (I can't find the comment where he said that idea, just that you mentioned he did)

@map-b

map-b commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

To keep the discussion simple, what this PR does is:
Given a device identifier, the board_name (usually the DTS compatible)

  • if there is only one profile which has the board_name in SUPPORTED_DEVICES select the profile as before,
  • when there are shared entries in SUPPORTED_DEVICES in several profiles, select the profile where the board_name is the first, if not throw an error.

*If the ASU client sends a true valid profile, select the profile, don't do any mapping/translation with SUPPORTED_DEVICES.

We have: Image profiles (vendor_device) and devices aka board_name aka DTS compatible (vendor,device), the way to map them, from ASU perspective, is the SUPPORTED_DEVICES entries.

The shortcuts replacing the '_' with ',' to do this mapping don't help to see the full picture. Not always the board_name is equal to the profile replacing the comma by an underscore.

Thanks @mcprat for dig in, I would make some corrections in your analysis explicitly but with this answer I hope you notice the oversights.

@mcprat

mcprat commented Apr 30, 2026

Copy link
Copy Markdown

my point is that it sounds like this change makes a 2 step process when really just 1 step is necessary.

We do not have to "map" profiles in order to treat groups of profiles one way and a single matching profile another way.
The reality is that there exists ONLY 1 profile where the board name is the FIRST element in supported_devices.

I have limited python experience and I don't want to figure out specifics right now
so I will write some garbage pseudocode for example:

foreach profile in profiles {
   if (profile.supported_devices[0] == board_name) {
      image = profile.image;
      break;
   }
}

//Keep existing logic for when the board name is legacy, and matches nothing above.
if (!image) {
  foreach profile in profiles {
      if (legacy_matching_method) {
        image = profile.image;
        break;
      }
   }
}


and thats all we need...

although, I understand in real life application it will take more lines to do the equivalent here.

@map-b

map-b commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

But, we allow mappings where it is not the first in the list (Look at rpi cases).

And the idea is to only apply the stricter requirement (be the first in the list) when there are shared entries. So we allow shared entries (compatible images) but consciously implemented).
*Oh, wait your proposal could work... But to detect the wrong cases... Anyway I hope we can move this forward, thanks again.

Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request May 4, 2026
These devices share the same "compatible" in device tree causing some
incompatibilities (sysupgrades, ASU profile identification), assign a
unique "compatible" and "model" to each variant.

Context:
Commit [1] added each variant's dts compatible to the SUPPORTED_DEVICES
field of the other variant to make easy sysupgrades between these
physically indistinguishable devices variants possible.

But there were found three issues which does not allow this:
- the sysupgrade's stricter check still used in some sysupgrade
paths(this check is being replaced(and redundant) with the newer fwtool's
SUPPORTED_DEVICES check using the info in images METADATA), this check
will fail when sysupgrading from a different board_name(compatible dts)
that the image was created for (image profile name).[2]
- ASU needs unique "dts compatible" to identify the devices profile.
- and an ASU's profile identification limitation when several devices from
a common target share SUPPORTED_DEVICES entries.[3]

There is a proposal for these issues but not yet implemented [4][3].

Until these issues are fixed we won't allow "easy" sysupgrades between
these two device variants.

Commit [5] avoided the ASU profile identification limitation but
missed the required two unique dts compatibles in order to make the two
variants fully work, although not allowing easy sysupgrade between them.

[1]: openwrt@8d30e07
[2]: sysupgrade stricter check openwrt#20566 (comment)
[3]: ASU proposal openwrt/asu#1533
[4]: allow easy sysupgrade proposal openwrt#20947
[5]: openwrt@b71f466
Fixes: b71f466 ("mediatek: filogic: fix supported_devices list for gl-mt2500")
Fixes: 8d30e07 ("mediatek: filogic: fix for new GL.iNet GL-MT2500/GL-MT2500A hardware revision")
Fixes: openwrt#20566
Fixes: openwrt/asu#1525

Signed-off-by: Mario Andrés Pérez <mapb_@outlook.com>
Link: openwrt#21842
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
@map-b map-b force-pushed the improve-supported-devices-handling branch from e8bf73f to ce45dce Compare June 18, 2026 23:21
@map-b map-b marked this pull request as draft June 18, 2026 23:24
@map-b map-b force-pushed the improve-supported-devices-handling branch from ce45dce to e3a0393 Compare June 18, 2026 23:33
map-b added 5 commits June 19, 2026 18:24
This reverts commit 1579236.

After commit 2e9edfd ("build-request: sanitize profile before use")
sanitized the incoming profile but not the lookup table, clients sending
DTS compatibles got "profile not found". This fixed the mismatch by
sanitizing both sides. Same issue: conflates board_name with profile
name.

Link: openwrt#1516
Link: openwrt#1554
Signed-off-by: Mario Andrés Pérez <mapb_@outlook.com>
This reverts commit 2e9edfd.

The ',' -> '_' replacement conflates board_name with profile name.
The fix was guided by owut's pre-translation behavior, which sends
profile names directly, not by how other clients actually work.

The trigger was a profile name using 'bananapi' while the DTS
compatible uses 'bpi'; no string replacement could bridge that.
The real fix was upstream, syncing profile names with DTS compatibles
(openwrt/openwrt@d871e95e, openwrt/openwrt#21095).

Link: openwrt#1511
Link: openwrt#1554
Signed-off-by: Mario Andrés Pérez <mapb_@outlook.com>
The actual handling does not allow to several devices share a
DTS compatible string to allow image compatibility between them.

Take the lists as lists and select the profile after checking all
possible candidates.

Throw a new validation exception when it is not possible to
identify a profile which will help to identify inconsistencies.

This also can help to make a little bit clearer the difference
between "profile" and "DTS compatible string".

There is no need to add [profile] to SUPPORTED_DEVICES list anymore.

The two preceding reverts removed the ',' -> '_' sanitization that
conflated board_name with profile name. The examples below compare
the flat dict (both raw and sanitized) against the new list format.

Profiles data (profile: SUPPORTED_DEVICES list):

  engenius_esr1200:         ["engenius,esr1200", "esr1200", "esr1750", "engenius,esr1750"]
  engenius_esr1750:         ["engenius,esr1750", "esr1750", "esr1200", "engenius,esr1200"]

  ubnt_unifi-ap:            ["ubnt,unifi-ap", "unifi", "ubnt,unifi"]
  ubnt_unifi-ap-lr:         ["ubnt,unifi-ap-lr", "unifi", "ubnt,unifi", "ubnt,unifi-ap"]

 Input                      Flat raw                       Flat sanitized
 ─────────────────────────  ─────────────────────────────  ─────────────────────────────
 engenius_esr1200           engenius_esr1200  OK           engenius_esr1750  <-
 engenius,esr1200           engenius_esr1750  <-           engenius_esr1750  <-
 esr1200                    engenius_esr1750  <-           engenius_esr1750  <-
 esr1750                    engenius_esr1750  <-           engenius_esr1750  <-
 engenius,esr1750           engenius_esr1750  OK           engenius_esr1750  OK
 engenius_esr1750           engenius_esr1750  OK           engenius_esr1750  OK

 ubnt_unifi-ap              ubnt_unifi-ap     OK           ubnt_unifi-ap-lr  <-
 ubnt,unifi-ap              ubnt_unifi-ap-lr  <-           ubnt_unifi-ap-lr  <-
 unifi                      ubnt_unifi-ap-lr  <-           ubnt_unifi-ap-lr  <-
 ubnt,unifi                 ubnt_unifi-ap-lr  <-           ubnt_unifi-ap-lr  <-
 ubnt_unifi-ap-lr           ubnt_unifi-ap-lr  OK           ubnt_unifi-ap-lr  OK
 ubnt,unifi-ap-lr           ubnt_unifi-ap-lr  OK           ubnt_unifi-ap-lr  OK

(<-) silently resolves to wrong profile

List format (resolve_profile behavior):

 Input                      Result
 ─────────────────────────  ─────────────────────
 engenius_esr1200           engenius_esr1200  OK
 engenius,esr1200           engenius_esr1200  OK
 esr1200                    error             OK
 esr1750                    error             OK
 engenius,esr1750           engenius_esr1750  OK
 engenius_esr1750           engenius_esr1750  OK

 ubnt_unifi-ap              ubnt_unifi-ap     OK
 ubnt,unifi-ap              ubnt_unifi-ap     OK
 unifi                      error             OK
 ubnt,unifi                 error             OK
 ubnt_unifi-ap-lr           ubnt_unifi-ap-lr  OK
 ubnt,unifi-ap-lr           ubnt_unifi-ap-lr  OK

Sanitization (, -> _) collapsed DTS and profile keys into the same
namespace, breaking profile name lookups that worked in the raw flat dict.
The list format preserves all entries per profile and, when ambiguous,
resolves to the profile where the input is first in its supported_devices
list, or errors explicitly if no unique match exists.

Signed-off-by: Mario Andrés Pérez <mapb_@outlook.com>
Extract DTS compatible -> profile name resolution into a dedicated
resolve_profile() function. Merges the x86 generic fallback into it,
removes the nested valid_profile() helper and the inline translation
block. Fixes dict key error with next(iter(...)).

Signed-off-by: Mario Andrés Pérez <mapb_@outlook.com>
Move get_request_hash() after validate_request() so the hash always
uses the canonical profile name, not the raw board_name input.
Remove the replace(',', '_') workaround from get_request_hash()
since the profile is always canonical at that point.

Previously, two clients sending different aliases for the same profile
(e.g. board_name vs. canonical name) would get different hash keys,
defeating the build cache.
@map-b map-b force-pushed the improve-supported-devices-handling branch from e3a0393 to 0250c97 Compare June 19, 2026 16:28
@map-b

map-b commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Time pass and new tools are available, I was going to propose make the translation a proper function but ended doing the next steps like make an API endpoint for ASU clients which do the profile identification. I have the proposal for an API endpoint for serve the profile resolution for owut and the required owut little adaptation code, I also have a proposal for the complementary required change to this PR for owut, just mimicking the new profile resolution logic. But by now, I have only updated this PR with a simplified and cleaner code.

V2 changes: (two new commits to keep PR evolution clear)

  • Reworded the reverts commits messages.
  • Refactor the proposed profile identification changes: make the profile validation (and translation) a proper function and simplify the code.
  • Add comment with examples of devices profiles affected and commented in this PR.
  • Add a long-standing bug fix with the build_request jobs hash generation which takes the profile before its validation and translation is done.

The ASU job cache issue is there since the beginning, it mostly affects ASU LuCI app since it sends the raw board_name and it gets a different build request hash that owut and firmware-selector since these sends the profile name. (e.g. each x86 request made in ASU LuCI app gets a unique hash, not the shared "generic")

We could also attach a single profile into each firmware image, by making devices "self aware", we'd avoid this entire shenanigans... #1533 (comment)

@aparcar I have thought many times about other possibilities to "attach" the used profile in the running image to uniquely identify the running image but... I cannot get anything better that DTS compatible string and the SUPPORTED_DEVICES map.

It is not clear what are the concerns here, as you can see i am all for this (and fixing any other missing bits related to ASU) but please give some real feedback so i can work on it.

*Completing the ASU integration tests is pending.

Recap: What does this PR propose?

  • Avoid a, too much, simple mapping between profile name and SUPPORTED_DEVICES entries and add logic to select the first in the list when required.
  • Unify and harmonize the profile validation (and translation) process between all ASU clients and server, no more confusing "sanitization" is done.

@efahl please, have a fresh new view on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attended Sysupgrade and owut upgrade broken: invalid sysupgrade file Attended Sysupgrade OpenWrt 24.10.3 to 24.10.4 on GL-MT2500

5 participants