# Custom Legato Image Generation

**URL:** https://forum.legato.io/t/custom-legato-image-generation/7014
**Category:** Legato Application Framework
**Created:** [June 12, 2026, 6:20pm UTC](https://forum.legato.io/t/custom-legato-image-generation/7014 "2026-06-12T18:20:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![upsampled](https://avatars.discourse-cdn.com/v4/letter/u/bc8723/32.png) [@upsampled](https://forum.legato.io/u/upsampled)
#### Post date: [June 12, 2026, 6:20pm UTC](https://forum.legato.io/t/custom-legato-image-generation/7014/1 "2026-06-12T18:20:23Z")

</div>

My goal is to create a custom image for a factory WP7702 where every layer is built from known sources. So far I have been successful rebuilding the modem firmware image and the Yocto kernel/rootfs image. The remaining piece I am struggling with is the Legato layer.

Specifically, I need to build a replacement for `legato-squashfs.ubi.cwe` that includes my primary application by default.

My application is defined by a single `.adef` file. My assumption was that I could create a custom `.sdef` that includes the default Legato system definition and then adds my application:

```auto
// custom.sdef
#include "$LEGATO_ROOT/default.sdef"

apps:
{
    $PA_CONFIG_ADEF
}

```

I then build the system using the Yocto SDK environment and `mksys`:

```auto
mksys -t wp77xx \
      -i $LEGATO_ROOT/interfaces/modemServices \
      -C "-O2 -Wno-unused-but-set-variable -Wno-unused-result" \
      custom.sdef

```

This produces a `.update` file that is approximately 9.1 MB. For comparison, the stock `legato-squashfs.ubi.cwe` appears to be about 7.1 MB.

I then convert the `.update` file into a CWE using `systocwe`, and finally merge the modem firmware CWE, the Yocto kernel/rootfs CWE, and the generated Legato CWE into a single image using `swicwe`.

The resulting image installs, but Sahara reports that the Legato image is too large.

My questions are:

1. Is this the correct process for generating a replacement `legato-squashfs.ubi.cwe`?

2. Is the additional ~2 MB likely causing the image to exceed the available Legato partition size?

3. What is the recommended way to reduce the size of the generated Legato image?

4. Is there an existing Sierra/Legato system definition that is used to generate the stock `legato-squashfs.ubi.cwe`, and if so, is it available for reference?

Any guidance would be appreciated.

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)
#### Post date: [June 13, 2026, 2:04am UTC](https://forum.legato.io/t/custom-legato-image-generation/7014/2 "2026-06-13T02:04:58Z")

</div>

Q1 and Q2: if you build a simple hello world application with same procedure, can it be run? If yes, then your procedure is correct. FYI, I used this method to build the legato.cwe together with my application:

> [@Flash size wp7607](https://forum.legato.io/t/flash-size-wp7607/3805/35):
>
> you can go to legato-19.02.0/modules/WiFi/wifi.sdef, under “apps:” section, add e.g. $LEGATO\_ROOT/apps/sample/helloWorld/helloWorld.adef [image] Now the new app will be included in legato.cwe. Please also note that the max size for legato partition is 8MB.

Q3: you can use “more /proc/mtd” to check the current legato partition size. To enlarge the partition size, you need to contact distributor to get a tool or enable the AT!PARTITION command:

> **[Repartition wp7702](https://forum.sierrawireless.com/t/repartition-wp7702/22662)**
>
> There is an older forum topic on this. But has anyone found a way to repartition the WP7702 to increase the size of the rootfs as of 2021? The AT!PARTITION is not supposed to work on WP77xx as per the AT command reference r8, but does show the...

Q4: you can have a look here:

> [@R16-WP7608-Partition-Size-Change](https://forum.legato.io/t/r16-wp7608-partition-size-change/5645/10):
>
> This is hard to compare as the code in legato framework is totally different. But seems there is significant decrease on the size and I think you can add your app and see if it can work on the module in the field.

---

<div class="post-metadata">

### Author: ![upsampled](https://avatars.discourse-cdn.com/v4/letter/u/bc8723/32.png) [@upsampled](https://forum.legato.io/u/upsampled)
#### Post date: [June 17, 2026, 1:30pm UTC](https://forum.legato.io/t/custom-legato-image-generation/7014/3 "2026-06-17T13:30:52Z")

</div>

> [@upsampled](#):
>
> ```auto
> mksys -t wp77xx \
> -i $LEGATO_ROOT/interfaces/modemServices \
> -C "-O2 -Wno-unused-but-set-variable -Wno-unused-result" \
> custom.sdef
> 
> ```

The core issue was the command above did not include the `-d` option. This meant the debug symbols were compiled into the binaries, increasing the side of the image and ultimately being too large for the partition.

```auto
mksys -t wp77xx 
-d /tmp/dbg_sym
-i $LEGATO_ROOT/interfaces/modemServices 
-C "-O2 -Wno-unused-but-set-variable -Wno-unused-result" 
custom.sdef

```
