How to extract kernel1 from sysupgrade file?

Hello!
I wonder how to extract kernel1 from sysupgrade file ?
I need it for uboot booting to restore firmware due to i bricked my router and other restore options doesn't working.

Which device? If NAND-based, it is likely a tar archive. If not, a utility like binwalk is useful.

1 Like

xiaomi mi wifi mini. it has spi flash
i tried binwalk but crc error occurred at boot time.

root:~ $ binwalk ~/Downloads/miwifi_r1cm_all_75496_2.8.91_ENG.bin 

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
676           0x2A4           uImage header, header size: 64 bytes, header CRC: 0xF20048C9, created: 2016-01-28 10:25:13, image size: 1499556 bytes, Data Address: 0x80000000, Entry Point: 0x80000000, data CRC: 0x769ED9C8, OS: Linux, CPU: MIPS, image type: OS Kernel Image, compression type: lzma, image name: "MIPS OpenWrt Linux-2.6.36"
740           0x2E4           LZMA compressed data, properties: 0x6D, dictionary size: 8388608 bytes, uncompressed size: 4469872 bytes
1508004       0x1702A4        Squashfs filesystem, little endian, version 4.0, compression:xz, size: 11200678 bytes, 2087 inodes, blocksize: 262144 bytes, created: 2016-01-28 10:25:11
12988904      0xC631E8        U-Boot version string, "U-Boot 1.1.3 (Jan 28 2016 - 18:16:37)"
12989656      0xC634D8        CRC32 polynomial table, little endian
13020796      0xC6AE7C        uImage header, header size: 64 bytes, header CRC: 0x4C2C7A43, created: 2016-01-28 10:15:52, image size: 2089093 bytes, Data Address: 0x80000000, Entry Point: 0x80000000, data CRC: 0x8925F0F5, OS: Linux, CPU: MIPS, image type: OS Kernel Image, compression type: lzma, image name: "MIPS Linux"
13020860      0xC6AEBC        LZMA compressed data, properties: 0x5D, dictionary size: 8388608 bytes, uncompressed size: 3819088 bytes

root:~ $ 
root:~ $ dd if=Downloads/miwifi_r1cm_all_75496_2.8.91_ENG.bin of=kernel1 bs=1 skip=676 count=1499556
1499556+0 records in
1499556+0 records out
1499556 bytes transferred in 5.513198 secs (271994 bytes/sec)
root:~ $ file kernel1
kernel1: u-boot legacy uImage, MIPS OpenWrt Linux-2.6.36, Linux/MIPS, OS Kernel Image (lzma), 1499556 bytes, Thu Jan 28 10:25:13 2016, Load Address: 0x80000000, Entry Point: 0x80000000, Header CRC: 0xF20048C9, Data CRC: 0x769ED9C8
root:~ $ du -sh kernel1
2.1M    kernel1
root:~ $ 

here is firmware http://bigota.miwifi.com/xiaoqiang/rom/r1cm/miwifi_r1cm_all_75496_2.8.91_ENG.bin

You use dd to extract - it appears you're using the correct software.

but it give me crc error while booting.

binwalk typically has an “extract” option

1 Like

but i don't know where to find uImage ?

U-boot showing "CRC Error-- using default environment" is harmless and it doesn't have anything to do with the firmware that is flashed.

It seems that the USB recovery to factory should be pretty bombproof unless you've replaced the bootloader. If you have replaced the bootloader with one that is not locked, just write the OpenWrt squashfs-sysupgrade directly to flash into the OS1 partition.

1 Like