Skip to content

airoha: an7581: add uboot chainloader - #22151

Merged
openwrt-bot merged 5 commits into
openwrt:mainfrom
hurrian:airoha-chainloader
Mar 5, 2026
Merged

openwrt-bot merged 5 commits into
openwrt:mainfrom
hurrian:airoha-chainloader

Conversation

@hurrian

@hurrian hurrian commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Due to issues surrounding the implementation of the vendor BMT/BBT on Airoha, upstream ATF + uboot has switched to UBI flash partitions.

However, some devices shipped on this platform are bootloader locked, and thus it is impossible to replace ATF + uboot.

During testing for the Gemtek W1700K (#17869), sysupgrades from Linux (which is unaware of the underlying BMT/BBT) would occasionally write data into blocks which were remapped by the vendor uboot when it was read on the following reboot, causing a soft brick.

An acceptable workaround [1],[2] was discussed where an intermediate uboot would be written by the vendor uboot (which is aware of Airoha BMT/BBT). This chainloader would then ignore the regions of flash used by the vendor uboot, and store all relevant data inside of UBI.

UBI would then be used to handle bad block management. As the vendor ATF + uboot do not read or interact with the UBI region, we would avoid unwanted remaps from BMT/BBT.

This commit introduces support for building such a chainloader, by packaging u-boot and DTS into a FIT image; to be flashed like a kernel.

Configuration for the Gemtek W1700K is provided as an example of how the chainloader is used.

[1] #17869 (comment)
[2] #17869 (comment)

Signed-off-by: Kenneth Kasilag [email protected]

@github-actions github-actions Bot added core packages pull request/issue for core (in-tree) packages target/airoha pull request/issue for airoha target labels Feb 23, 2026
Comment thread target/linux/airoha/image/an7581.mk Resolved
@Ansuel

Ansuel commented Feb 23, 2026

Copy link
Copy Markdown
Member

I was also working on this... Does it work or it's just POC?

@andrewjlamarche

andrewjlamarche commented Feb 23, 2026 •

Copy link
Copy Markdown
Contributor

I'm going to test as soon as I get my SBE1V1K set up to replace my main W1700K.

@hurrian
hurrian force-pushed the airoha-chainloader branch 5 times, most recently from 58293ac to aa3a1cc Compare February 26, 2026 23:00
@github-actions github-actions Bot added the build/scripts/tools pull request/issues for build, scripts and tools related changes label Feb 27, 2026
@Ansuel

Ansuel commented Mar 3, 2026

Copy link
Copy Markdown
Member

So any news for this? ...

@hurrian
hurrian force-pushed the airoha-chainloader branch from 0fd8262 to 9f6a4d7 Compare March 3, 2026 11:59
@hurrian

hurrian commented Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

So any news for this? ...

On further testing on the W1700K, the vendor bootloader disables STANDALONE image booting from flash - I had to repack the uboot image as a Linux kernel image, add a fake Linux image header and attempt to undo some of the boot setup done for booting a Linux kernel.

Unfortunately this device doesn't have CPU JTAG so I can't debug where it's hanging in the shim sequence...

@kirdesde

kirdesde commented Mar 3, 2026 •

Copy link
Copy Markdown

So any news for this? ...

On further testing on the W1700K, the vendor bootloader disables STANDALONE image booting from flash - I had to repack the uboot image as a Linux kernel image, add a fake Linux image header and attempt to undo some of the boot setup done for booting a Linux kernel.

Unfortunately this device doesn't have CPU JTAG so I can't debug where it's hanging in the shim sequence...

I was having the same problem booting an u-boot image built by the python script. (stuck at loading kernel)

but using the an7581-uboot-fit recipe from hurrian@d6402ea#diff-0425cf93ddfbcbf40599dfea716c3fb0aede54889a0bfd454c060d1290f26112 works for me.

The stock u-boot boots the chainloader u-boot.

w1700k-ubi.log

I'll post my changes soon on github.

Update: https://github.com/kirdesde/openwrt/tree/w1700k_ubi

I've used the instructions provide by @hurrian : https://gist.github.com/hurrian/2f72c006becaedb564714a63fca9caf5

See my comment below in the gist.

@kirdesde

kirdesde commented Mar 3, 2026

Copy link
Copy Markdown

BTW

During the switch to ubi I erased the entire stock bootloader by accident :-(

I've used the instructions from @Rondom https://forum.openwrt.org/t/quantum-fiber-w1700k-support/222776/565?u=kirdes to recover.

Boot the device with the reset button pressed and press 'x'.

Send the FIP via XModem, ATF is booting in RAM and after another press 'x" send the entire bootloader via XModem.

I've used the one that came with the latest stock firmware https://gcs-firmware-details-prod-002.storage.googleapis.com/W1700K/WXK001-05.00.30.82.bin (path: /opt/econet/tcboot.bin)
Device is then loading ATF and stock u-boot running again in RAM.

Last step is to tftp the same tcboot.bin, stock u-boot is then writing the bootloader automatically to the flash.

@Ansuel

Ansuel commented Mar 3, 2026

Copy link
Copy Markdown
Member

@kirdesde thanks for confirming that the same signed bootloader can be used to recover... that is nice.

Anyway my test were done with simply loading the uboot with tftp and then use the go command... Didn't manage to make the bootm command work. Nice to have... Can we finalize this so we can finally progress and have the device merged?

Also if bootm works we can also compress it with lzma that decrease the size from 700kb to 200kb and it means even smaller uboot partition.

@kirdesde

kirdesde commented Mar 3, 2026

Copy link
Copy Markdown

@kirdesde thanks for confirming that the same signed bootloader can be used to recover... that is nice.

Anyway my test were done with simply loading the uboot with tftp and then use the go command... Didn't manage to make the bootm command work. Nice to have... Can we finalize this so we can finally progress and have the device merged?

Also if bootm works we can also compress it with lzma that decrease the size from 700kb to 200kb and it means even smaller uboot partition.

u-boot is already lzma compressed, kirdesde@1def477

I hope @andrewjlamarche and @hurrian can confirm this is working. Next step would be to merge that into the w1700k PR i think.

Thanks @hurrian for providing all the groundwork ;-)

@hurrian

hurrian commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @kirdesde! Adjusting the load address fixed the boot hang when loading from flash.

Here's a boot log of the chain load working; I'll update my PR in a bit.

@hurrian
hurrian force-pushed the airoha-chainloader branch 2 times, most recently from 884b1ce to fdbd57f Compare March 4, 2026 01:23
@hurrian

hurrian commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

ping @Ansuel this should be ready for review; in this latest revision I got rid of the python script and the static .its file and used the existing toolchain mkits script in the build recipe.

Once done, the other half of this would be migrating #17869 to UBI and building an installer script; since manually typing in ubiformat commands is quite error prone...

@Ansuel

Ansuel commented Mar 4, 2026

Copy link
Copy Markdown
Member

@hurrian maybe we can rework the FIP_COMPRESS part a bit and change it to LZMA_COMPRESS. I would like to compress the .bin in uboot makefile instead of in the target.

Comment thread target/linux/airoha/image/an7581.mk Resolved
@hurrian
hurrian force-pushed the airoha-chainloader branch from fdbd57f to cb2adb5 Compare March 4, 2026 02:52
@github-actions github-actions Bot added the kernel pull request/issue with Linux kernel related changes label Mar 4, 2026
hurrian pushed a commit to hurrian/openwrt-w1700k that referenced this pull request Mar 6, 2026
Add ubi nvmem driver, required to load nvmem entries from ubi volumes

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
hurrian pushed a commit to hurrian/openwrt-w1700k that referenced this pull request Mar 6, 2026
Add a label to the spi node to allow device trees to reference it
(i.e. to mark status = "okay").

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
hurrian pushed a commit to hurrian/openwrt-w1700k that referenced this pull request Mar 6, 2026
Enable fitblk driver, required to parse the fit image and set-up the rootfs volume

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
hurrian pushed a commit to hurrian/openwrt-w1700k that referenced this pull request Mar 6, 2026
Add ubi nvmem driver, required to load nvmem entries from ubi volumes

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
carlosz1986 pushed a commit to carlosz1986/openwrt that referenced this pull request Mar 7, 2026
It is more accurate to describe the contents of the FIP as
compressed, instead of the FIP itself becoming compressed.

Update variable naming accordingly.

Signed-off-by: Kenneth Kasilag <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
carlosz1986 pushed a commit to carlosz1986/openwrt that referenced this pull request Mar 7, 2026
Due to issues surrounding the implementation of the vendor BMT/BBT
on Airoha, upstream ATF + uboot has switched to UBI flash partitions.

However, some devices shipped on this platform are bootloader locked,
and thus it is impossible to replace ATF + uboot.

During testing for the Gemtek W1700K (openwrt#17869), sysupgrades from Linux
(which is unaware of the underlying BMT/BBT) would occasionally write
data into blocks which were remapped by the vendor uboot when it was
read on the following reboot, causing a soft brick.

An acceptable workaround [1],[2] was discussed where an intermediate
uboot would be written by the vendor uboot (which is aware of Airoha
BMT/BBT). This chainloader would then ignore the regions of flash
used by the vendor uboot, and store all relevant data inside of UBI.

UBI would then be used to handle bad block management. As the vendor
ATF + uboot do not read or interact with the UBI region, we would avoid
unwanted remaps from BMT/BBT.

This commit introduces support for building such a chainloader, by
packaging u-boot and DTS into a FIT image; to be flashed like a kernel.

Configuration for the Gemtek W1700K is provided as an example of how the
chainloader is used.

[1] openwrt#17869 (comment)
[2] openwrt#17869 (comment)

Signed-off-by: Kenneth Kasilag <[email protected]>
[ move FIP_COMPRESS to Build/Compile, wrap some long lines ]
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
carlosz1986 pushed a commit to carlosz1986/openwrt that referenced this pull request Mar 7, 2026
Add a label to the spi node to allow device trees to reference it
(i.e. to mark status = "okay").

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
carlosz1986 pushed a commit to carlosz1986/openwrt that referenced this pull request Mar 7, 2026
Enable fitblk driver, required to parse the fit image and set-up the rootfs volume

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
carlosz1986 pushed a commit to carlosz1986/openwrt that referenced this pull request Mar 7, 2026
Add ubi nvmem driver, required to load nvmem entries from ubi volumes

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
lukasz1992 pushed a commit to lukasz1992/openwrt that referenced this pull request Mar 10, 2026
It is more accurate to describe the contents of the FIP as
compressed, instead of the FIP itself becoming compressed.

Update variable naming accordingly.

Signed-off-by: Kenneth Kasilag <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
lukasz1992 pushed a commit to lukasz1992/openwrt that referenced this pull request Mar 10, 2026
Due to issues surrounding the implementation of the vendor BMT/BBT
on Airoha, upstream ATF + uboot has switched to UBI flash partitions.

However, some devices shipped on this platform are bootloader locked,
and thus it is impossible to replace ATF + uboot.

During testing for the Gemtek W1700K (openwrt#17869), sysupgrades from Linux
(which is unaware of the underlying BMT/BBT) would occasionally write
data into blocks which were remapped by the vendor uboot when it was
read on the following reboot, causing a soft brick.

An acceptable workaround [1],[2] was discussed where an intermediate
uboot would be written by the vendor uboot (which is aware of Airoha
BMT/BBT). This chainloader would then ignore the regions of flash
used by the vendor uboot, and store all relevant data inside of UBI.

UBI would then be used to handle bad block management. As the vendor
ATF + uboot do not read or interact with the UBI region, we would avoid
unwanted remaps from BMT/BBT.

This commit introduces support for building such a chainloader, by
packaging u-boot and DTS into a FIT image; to be flashed like a kernel.

Configuration for the Gemtek W1700K is provided as an example of how the
chainloader is used.

[1] openwrt#17869 (comment)
[2] openwrt#17869 (comment)

Signed-off-by: Kenneth Kasilag <[email protected]>
[ move FIP_COMPRESS to Build/Compile, wrap some long lines ]
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
lukasz1992 pushed a commit to lukasz1992/openwrt that referenced this pull request Mar 10, 2026
Add a label to the spi node to allow device trees to reference it
(i.e. to mark status = "okay").

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
lukasz1992 pushed a commit to lukasz1992/openwrt that referenced this pull request Mar 10, 2026
Enable fitblk driver, required to parse the fit image and set-up the rootfs volume

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
lukasz1992 pushed a commit to lukasz1992/openwrt that referenced this pull request Mar 10, 2026
Add ubi nvmem driver, required to load nvmem entries from ubi volumes

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
maurerle pushed a commit to maurerle/openwrt that referenced this pull request Mar 17, 2026
It is more accurate to describe the contents of the FIP as
compressed, instead of the FIP itself becoming compressed.

Update variable naming accordingly.

Signed-off-by: Kenneth Kasilag <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
maurerle pushed a commit to maurerle/openwrt that referenced this pull request Mar 17, 2026
Due to issues surrounding the implementation of the vendor BMT/BBT
on Airoha, upstream ATF + uboot has switched to UBI flash partitions.

However, some devices shipped on this platform are bootloader locked,
and thus it is impossible to replace ATF + uboot.

During testing for the Gemtek W1700K (openwrt#17869), sysupgrades from Linux
(which is unaware of the underlying BMT/BBT) would occasionally write
data into blocks which were remapped by the vendor uboot when it was
read on the following reboot, causing a soft brick.

An acceptable workaround [1],[2] was discussed where an intermediate
uboot would be written by the vendor uboot (which is aware of Airoha
BMT/BBT). This chainloader would then ignore the regions of flash
used by the vendor uboot, and store all relevant data inside of UBI.

UBI would then be used to handle bad block management. As the vendor
ATF + uboot do not read or interact with the UBI region, we would avoid
unwanted remaps from BMT/BBT.

This commit introduces support for building such a chainloader, by
packaging u-boot and DTS into a FIT image; to be flashed like a kernel.

Configuration for the Gemtek W1700K is provided as an example of how the
chainloader is used.

[1] openwrt#17869 (comment)
[2] openwrt#17869 (comment)

Signed-off-by: Kenneth Kasilag <[email protected]>
[ move FIP_COMPRESS to Build/Compile, wrap some long lines ]
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
maurerle pushed a commit to maurerle/openwrt that referenced this pull request Mar 17, 2026
Add a label to the spi node to allow device trees to reference it
(i.e. to mark status = "okay").

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
maurerle pushed a commit to maurerle/openwrt that referenced this pull request Mar 17, 2026
Enable fitblk driver, required to parse the fit image and set-up the rootfs volume

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
maurerle pushed a commit to maurerle/openwrt that referenced this pull request Mar 17, 2026
Add ubi nvmem driver, required to load nvmem entries from ubi volumes

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
namiltd pushed a commit to namiltd/openwrt that referenced this pull request Mar 17, 2026
It is more accurate to describe the contents of the FIP as
compressed, instead of the FIP itself becoming compressed.

Update variable naming accordingly.

Signed-off-by: Kenneth Kasilag <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
namiltd pushed a commit to namiltd/openwrt that referenced this pull request Mar 17, 2026
Due to issues surrounding the implementation of the vendor BMT/BBT
on Airoha, upstream ATF + uboot has switched to UBI flash partitions.

However, some devices shipped on this platform are bootloader locked,
and thus it is impossible to replace ATF + uboot.

During testing for the Gemtek W1700K (openwrt#17869), sysupgrades from Linux
(which is unaware of the underlying BMT/BBT) would occasionally write
data into blocks which were remapped by the vendor uboot when it was
read on the following reboot, causing a soft brick.

An acceptable workaround [1],[2] was discussed where an intermediate
uboot would be written by the vendor uboot (which is aware of Airoha
BMT/BBT). This chainloader would then ignore the regions of flash
used by the vendor uboot, and store all relevant data inside of UBI.

UBI would then be used to handle bad block management. As the vendor
ATF + uboot do not read or interact with the UBI region, we would avoid
unwanted remaps from BMT/BBT.

This commit introduces support for building such a chainloader, by
packaging u-boot and DTS into a FIT image; to be flashed like a kernel.

Configuration for the Gemtek W1700K is provided as an example of how the
chainloader is used.

[1] openwrt#17869 (comment)
[2] openwrt#17869 (comment)

Signed-off-by: Kenneth Kasilag <[email protected]>
[ move FIP_COMPRESS to Build/Compile, wrap some long lines ]
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
namiltd pushed a commit to namiltd/openwrt that referenced this pull request Mar 17, 2026
Add a label to the spi node to allow device trees to reference it
(i.e. to mark status = "okay").

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
namiltd pushed a commit to namiltd/openwrt that referenced this pull request Mar 17, 2026
Enable fitblk driver, required to parse the fit image and set-up the rootfs volume

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
namiltd pushed a commit to namiltd/openwrt that referenced this pull request Mar 17, 2026
Add ubi nvmem driver, required to load nvmem entries from ubi volumes

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
namiltd pushed a commit to namiltd/openwrt that referenced this pull request Mar 17, 2026
It is more accurate to describe the contents of the FIP as
compressed, instead of the FIP itself becoming compressed.

Update variable naming accordingly.

Signed-off-by: Kenneth Kasilag <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
namiltd pushed a commit to namiltd/openwrt that referenced this pull request Mar 17, 2026
Due to issues surrounding the implementation of the vendor BMT/BBT
on Airoha, upstream ATF + uboot has switched to UBI flash partitions.

However, some devices shipped on this platform are bootloader locked,
and thus it is impossible to replace ATF + uboot.

During testing for the Gemtek W1700K (openwrt#17869), sysupgrades from Linux
(which is unaware of the underlying BMT/BBT) would occasionally write
data into blocks which were remapped by the vendor uboot when it was
read on the following reboot, causing a soft brick.

An acceptable workaround [1],[2] was discussed where an intermediate
uboot would be written by the vendor uboot (which is aware of Airoha
BMT/BBT). This chainloader would then ignore the regions of flash
used by the vendor uboot, and store all relevant data inside of UBI.

UBI would then be used to handle bad block management. As the vendor
ATF + uboot do not read or interact with the UBI region, we would avoid
unwanted remaps from BMT/BBT.

This commit introduces support for building such a chainloader, by
packaging u-boot and DTS into a FIT image; to be flashed like a kernel.

Configuration for the Gemtek W1700K is provided as an example of how the
chainloader is used.

[1] openwrt#17869 (comment)
[2] openwrt#17869 (comment)

Signed-off-by: Kenneth Kasilag <[email protected]>
[ move FIP_COMPRESS to Build/Compile, wrap some long lines ]
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
namiltd pushed a commit to namiltd/openwrt that referenced this pull request Mar 17, 2026
Add a label to the spi node to allow device trees to reference it
(i.e. to mark status = "okay").

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
namiltd pushed a commit to namiltd/openwrt that referenced this pull request Mar 17, 2026
Enable fitblk driver, required to parse the fit image and set-up the rootfs volume

Signed-off-by: Dirk Buchwalder <[email protected]>
Link: openwrt#22151
Signed-off-by: Christian Marangi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build/scripts/tools pull request/issues for build, scripts and tools related changes core packages pull request/issue for core (in-tree) packages kernel pull request/issue with Linux kernel related changes target/airoha pull request/issue for airoha target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants