How to prepare sysupgrade.bin for my device?

Hi all,

We are using openwrt to build up firmware for our device.
Now, we have kernel image(Image), rootfs(rootfs.squashfs) and bld(bld.bin) at build dir.
After checking the image/Makefile under target/linux/xxxx folder, still no idea how to prepare my own sysupgrade.bin for my device.
Does anyone can give me some tips to try? Please advise. Thanks a lot.

There isn't universal rule for abstract board. It depends of your board bootloader firstly.
The most common case is uboot bootloader. In this case scenario looks like:
0. Add board configuration data (compiled dts-file or another data) into vmlinux kernel. It's kernel

  1. Pack kernel with lzma command (if your version of uboot support it). It's kernel.lzma
  2. Make header for packed kernel to inform uboot how to load your kernerl with mkimage command. It's kernel.bin
  3. Simply join packed kernel with uboot header and rootfs.squash with cat command. It's sysupgrade.bin.
    All these steps you can find in ./include/image* and in ./target/linux/${your_arch}/${your_sub_arch}/image/Makefile
1 Like

Hi 123serge123,

Thanks. Since our bld is not uboot, sound like I need to create the rules to pack sysupgrade.bin. Do you have any doc I can follow up? Thanks.

Start from doc on your bootloader.

  1. Which firmware image header format does it support? Does exist special tool to prepare kernel image header? Does kernel support parser for this header (if not, you have to use fixed flash partitioning for kernel and roots parts)?
  2. Does bootloader support packed image?
  3. Where (flash offset) does it search firmware image header?
  4. Does bootloader require flash area for its own information/environment?
  5. Does your firmware require flash area for its own data/environment (usually some info for network and wifi drivers: calibration data, mac addresses etc)?

If you answer these questions you can plan your total flash partitioning (layout) and sysupgrade (firmware) part of this layout,

1 Like

HI 123serge123,

Thanks.

  1. Yes, kernel support parser for the header.
  2. No, bld did not support packed image.
  3. Basically, we have bld, Image and rootfs. I can calculate the offset via each size.
  4. Yes, there is a dtb partition.
  5. Yes, there is a add partition which is ubifs format.
    Do you know which target under target/linux/ I can refer? Thanks.

Paractically all modern target can use nand/ubi:
apm821xx
ar71xx
at91
ath79
bcm53xx
imx6
ipq40xx
ipq806x
kirkwood
lantiq
layerscape
mvebu
omap
oxnas
pistachio
ramips
rb532

1 Like

Thanks. I will take a look first.

Hi 123serge123,

After checking how ramips create image, I can create full image with appending each bins into one image file. Like |bst|bld|fac|kernel|rootfs|add|.

Still, I have another question. Since we would like to upgrade kernel and rootfs partitions only via web, so
How do I prepare a sysupgrade image with kernel/rootfs only?
How to ask sysupgrade script to upgrade kernel/rootfs partition?
Please help. Thanks.

You can define your own upgrade scripts or use default functions.
See /lib/upgrade/{platform.sh, nand.sh, ubnt.sh} as examples.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.