Hey al, I am trying to understand a custom openwrt lede build from an iot hardware vendor. For some reason there is a libmbedtls version that ends up in their /overlay/upper/usr/lib/
directory when I run their stock squashfs-sysupgrade.bin firmware, but if I build my own version using their scripts, I get very different files in the overlay (including a much newer mbedtls that doesn't work). So I am trying to trace back where their version comes from. So the bottom line is, how do the openwrt build script determine (using the make files/make menuconfig/etc) which files go into the rootfs image, and which into the sysupgrade image?
Cheers,
Dolf.
1 Like
The overlay is only initialized on first boot, until then it should not exist, see dd-based hard reset:
https://openwrt.org/docs/guide-user/troubleshooting/failsafe_and_factory_reset#hard_factory_reset
So where do the squashfs-sysupgrade and rootfs images get stored then in flash? I see these partitions:
dev: size erasesize name
mtd0: 00040000 00010000 "u-boot"
mtd1: 00fa0000 00010000 "firmware"
mtd2: 00160000 00010000 "kernel"
mtd3: 00e40000 00010000 "rootfs"
mtd4: 00890000 00010000 "rootfs_data"
mtd5: 00010000 00010000 "config"
mtd6: 00010000 00010000 "art"
mtd4
is mounted as /overlay and mtd3 as /rom. What I had assumed is that rootfs image is stored in mtd3 and squashfs-sysupgrade in mtd4. Is that not the case?
In the vanilla OpenWrt firmware, the overlay aka rootfs_data should be initially empty.
The sysupgrade image is loaded into tmpfs, which is RAM, before being written to flash.
See also: Inspecting an image (firmware) without installing - #5 by sumo
OK, so after it loads the sysupgrade image to tmpfs, where in flash does it write the data? rootfs_data
(mtd4) right?
But my question initially was about building custom openwrt images. When I build the image (using make
) I get a *-rootfs-squashfs.bin
and a *-squashfs-sysupgrade.bin
image. How does the image building system determine which files should end up on the rootfs and which files in the sysupgrade images?
rootfs is IN sysupgrade images
which not suprisingly gets written here;
I see the following files:
openwrt-ar71xx-generic-kernel.bin
openwrt-ar71xx-generic-rootfs-squashfs.bin
openwrt-ar71xx-generic-squashfs-sysupgrade.bin
What is the difference between
openwrt-ar71xx-generic-rootfs-squashfs.bin
and openwrt-ar71xx-generic-squashfs-sysupgrade.bin
send them into binwalk
and have a look... (but from the looks of it the top two are the components that go into the bottom one)
2 Likes
...you need their buildsystem or binwalk to check out their build logic
1 Like
They are just using the openwrt make files with some additional files getting copied around. But I don't think they make their own makefiles except for a few packages. So I was assuming the sysupgrade and similar images are normal for openwrt. That is not the case? Openwrt normally doesn't create those files if you build an image?
I thought this was normal standard openwrt behaviour to create those files and they would end up like this in flash:
mtd2: 00160000 00010000 "kernel" <---- openwrt-ar71xx-generic-kernel.bin
mtd3: 00e40000 00010000 "rootfs" <----- openwrt-ar71xx-generic-rootfs-squashfs.bin
mtd4: 00890000 00010000 "rootfs_data" <------- openwrt-ar71xx-generic-squashfs-sysupgrade.bin
I was expecting the 1st file to contain the kernel, the second file have the read-only firmware that gets written to rom in the rootfs
partition, and the third file (sysupgrade
) to contain changes (i.e. system upgrades) that get writtany changes end up in the sysupgrade file which gets written to rootfs_data. That is not the case? Vanilla openwrt doesn't create squashfs-sysupgrade.bin
and rootfs-squashfs.bin
files?
rootfs_data = overlay...
if there is stuff there, then that is an artifact of upgrade / init logic and nothing really to do with images(layout)... suggest reading up on this on the wiki...
1 Like
Yes I know rootfs=overlay. What is getting me confused is the three image files. I understand that overlay should initially be empty with stock firmware only in ROM. But after that, what I thought a sysupgrade
image was, was a file with additional new(er versions of) files that have changed compared to the stock version in rootfs
, and therefore get written to rootfs_data
so through the overlay system, you can upgrade an existing router with a newer version of the firmware. So now rootfs
contains the stock firmware and rootfs_data
contains the overlay with newer versions of the files from the system upgrade. But that is appartently not what happens? So every sysupgrade image should be a full new copy of the whole openwrt build? And it rewrites the full rootfs
partition?
as stated... rootfs_data for most intents and purposes should be relatively empty (just re-initialized every upgrade)
sysupgrade.bin (kernel>kernel rootfs>rootfs rootfs_data<clear)
1 Like
Ok, so a vanilla openwrt does not build rootfs-squashfs.bin
and squashfs-sysupgrade.bin
files?
Specific image types depend on the target.
You can personally confirm it here:
https://downloads.openwrt.org/
1 Like