OpenWrt Forum Archive

Topic: How to create a .bin image?

The content of this topic has been archived on 21 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

My goal is to use the sysupgrade script to flash a Compex wp543 board. I believe that sysupgrade needs a .bin file to do the upgrade.
When I build the OpenWrt code base for this target, the build seems to be good and several files are generated in the bin directory. E.g. 
openwrt-ar71xx-generic-wpj35-squashfs-factory.img
openwrt-ar71xx-generic-root.squashfs
openwrt-ar71xx-generic-root.squashfs-64k
openwrt-ar71xx-generic-rootfs.tar.gz
openwrt-ar71xx-generic-vmlinux-lzma.elf
openwrt-ar71xx-generic-uImage-lzma.bin
openwrt-ar71xx-generic-uImage-gzip.bin
openwrt-ar71xx-generic-vmlinux.gz
openwrt-ar71xx-generic-vmlinux.lzma
openwrt-ar71xx-generic-vmlinux.bin
openwrt-ar71xx-generic-vmlinux.elf

I'm expecting to see a bin file such as openwrt-ar71xx-wp543-squashfs.bin in the bin directory, but there is no such file?

Anyone know where I should be looking to understand how this gets generated?
Or, what I should do to generate the .bin file?

hmmmmm  let me think....

what about dd if=/dev/urandom of=image.bin count=4000000

?

*confused*

Most likely answer is that you selected too many packages. The wiki should really mention this. Comes up quite often and I've experienced and asked the same question when I tried to build my first image.

The .bin file required to use sysupgrade should've been generated during the build process. I.e. I'm building my own image and do not want to use dd to copy it off an existing unit.

I've tried reducing packages during the build, but it made no difference.

After further investigation it seems like:
-Compex uses their own boot loader called "myloader"
-During the build process they use a tool called mkmylofw to generate the .bin files (specific for their bootloader I assume)
-With this product (wp543) it seems like they're generating an .img file instead of a .bin file
-I then tried using the .img file to do an sysupgrade, but got the following message:
   "Sysupgrade is not yet supported on wp543."

Like I understand you use OpenWRT SDK downloaded from Compex, then you selected wrong board, because it created img file for wpj35.
Compex img by default haven't upgrade support. Use tftp to upload new img file to device.

tftp -i 192.168.168.1 put openwrt-ar71xx-generic-wp543-squashfs-factory.img

Myloader activate tftp for 5 seconds after power ON.

Thank you, I've noticed that I had the wrong board selected at one point and rectified that.

I understand the tftp option, which is available for 5 seconds when booting, but this is not helping me. I need the ability to do a remote upgrade (i.e. I do not have physical access to the unit). Also the unit may be on a different type of network, which would not allow traffic for a 192.168.168.x address and submask.

I have wpe72 it is have same myloader, so it would work on your board. edit target/linux/ar71xx/image/Makefile

define Image/Build/MyLoader
    $(call PatchKernelLzma,$(2),$(3))
    -$(STAGING_DIR_HOST)/bin/mkmylofw -B $(2) -s $(4) \
        -p0x030000:0xe0000:al:0x80060000:kernel:$(KDIR_TMP)/vmlinux-$(2).bin.lzma \
        -p0x110000:0:::rootfs:$(KDIR)/root.$(1) \
        $(call imgname,$(1),$(2))-$(5)-factory.img
    --sh $(TOPDIR)/scripts/combined-image.sh \
        "$(KDIR_TMP)/vmlinux-$(2).bin.lzma" \
        "$(KDIR)/root.$(1)" \
        $(call sysupname,$(1),$(2))
endef

this create a sysupgrade file to your board. But be careful, this not control size of your board.
Now your need teach your board accept new image, then edit file /lib/upgrade/platform.sh
replace "pb42" to "wp543"(in platform_check_image() and platform_do_upgrade()) , now replace string in platform_do_upgrade_combined()

mtd -r $append -F$kernelpart:$kern_length:$CI_LDADR,rootfs write - $partitions

to

mtd -r $append write - $partitions

If you need to add same values to new image by default, add same changes to target/linux/ar71xx/base-files/lib/upgrade/platform.sh
I hope it was helpful for you.

Thanks neryba. I've made all the changes and created a new image, but when I try to use sysupgrade like:

sysupgrade -v openwrt-ar71xx-generic-wp543-squashfs-8M-factory.img

then I get the following messages:
"Invalid image. Use *-sysupgrade.bin files on this board
Image check 'platform_check_image' failed."

I've also tried by renaming the .img to a .bin, because I'm assuming they're the same?

rebo wrote:

Thanks neryba. I've made all the changes and created a new image, but when I try to use sysupgrade like:

sysupgrade -v openwrt-ar71xx-generic-wp543-squashfs-8M-factory.img

then I get the following messages:
"Invalid image. Use *-sysupgrade.bin files on this board
Image check 'platform_check_image' failed."

I've also tried by renaming the .img to a .bin, because I'm assuming they're the same?

pleas remove build_dir and build image again, if all is correct you will see two images in bin/ar71xx/ directory

openwrt-ar71xx-generic-wp543-squashfs-8M-factory.img
openwrt-ar71xx-generic-wp543-squashfs-sysupgrade.bin

The discussion might have continued from here.