Hi
I have this device I am trying to add support to
which i have failed to produce an image that boots
The device accepts firmware upgrade through OEM upgrade server only
U-Boot is Locked
So long story short i have managed to replicate OEM upgrade server
Also the Device firmware hosted encrypted, so i have managed to decrypt the OEM firmware.
and also encrypt my custom built Openwrt image
The OEM decrypted firmware contain Header + UBI + Footer
the header and footer looks very similar to what qsdk-ipq-factory-nand
generate.
but the OEM has in includes installation script. and also has file name + SHA-1 hash for the name
Long story short, i had to use the Header and the footer structure for the firmware to pass OEM checks
By only replacing OEM UBI with mine and change UBI checksum at the footer
But Openwrt UBI is very different than the OEM
Here are OEM information starting with ubireader info for OEM decrypted firmware
ubireader_display_info OEM_decrypted.img
UBI_File Warning: end_offset - start_offset length is not block aligned, could mean missing data.
UBI File
---------------------
Min I/O: 2048
LEB Size: 126976
PEB Size: 131072
Total Block Count: 175
Data Block Count: 173
Layout Block Count: 2
Internal Volume Block Count: 0
Unknown Block Count: 0
First UBI PEB Number: 1
Image: 402958865
---------------------
Image Sequence Num: 402958865
Volume Name:kernel
Volume Name:ubi_rootfs
Volume Name:rootfs_data
PEB Range: 2 - 174
Volume: kernel
---------------------
Vol ID: 0
Name: kernel
Block Count: 38
Volume Record
---------------------
alignment: 1
crc: '0xa55489c5'
data_pad: 0
errors: ''
flags: 0
name: 'kernel'
name_len: 6
padding: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
rec_index: 0
reserved_pebs: 38
upd_marker: 0
vol_type: 'dynamic'
Volume: ubi_rootfs
---------------------
Vol ID: 1
Name: ubi_rootfs
Block Count: 135
Volume Record
---------------------
alignment: 1
crc: '0xc8d0565'
data_pad: 0
errors: ''
flags: 0
name: 'ubi_rootfs'
name_len: 10
padding: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
rec_index: 1
reserved_pebs: 135
upd_marker: 0
vol_type: 'dynamic'
Volume: rootfs_data
---------------------
Vol ID: 2
Name: rootfs_data
Block Count: 0
Volume Record
---------------------
alignment: 1
crc: '0xa1d725dc'
data_pad: 0
errors: ''
flags: 'autoresize'
name: 'rootfs_data'
name_len: 11
padding: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
rec_index: 2
reserved_pebs: 1
upd_marker: 0
vol_type: 'dynamic'
from within a working device
/ # cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00010000 "0:SBL1"
mtd1: 00020000 00010000 "0:MIBIB"
mtd2: 00060000 00010000 "0:QSEE"
mtd3: 00010000 00010000 "0:CDT"
mtd4: 00010000 00010000 "0:DDRPARAMS"
mtd5: 00010000 00010000 "0:APPSBLENV"
mtd6: 00080000 00010000 "0:APPSBL"
mtd7: 00010000 00010000 "0:ART"
mtd8: 00020000 00010000 "0:BOOTCONFIG"
mtd9: 00020000 00010000 "0:BOOTCONFIG1"
mtd10: 00030000 00010000 "RESV"
mtd11: 00010000 00010000 "RESV0"
mtd12: 02900000 00020000 "rootfs"
mtd13: 02900000 00020000 "rootfs_1"
mtd14: 01200000 00020000 "RESV1"
mtd15: 00c00000 00020000 "qcacfg"
mtd16: 01000000 00020000 "qcalog"
mtd17: 0049a000 0001f000 "kernel"
mtd18: 00e88000 0001f000 "ubi_rootfs"
mtd19: 013bd000 0001f000 "rootfs_data"
mtd20: 008b8000 0001f000 "qcacfg"
mtd21: 00c98000 0001f000 "qcalog"
/ # ubinfo -a
UBI version: 1
Count of UBI devices: 3
UBI control device major/minor: 10:59
Present UBI devices: ubi0, ubi1, ubi2
ubi0
Volumes count: 3
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 328 (41648128 bytes, 39.7 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 3
Current maximum erase counter value: 4
Minimum input/output unit size: 2048 bytes
Character device major/minor: 248:0
Present volumes: 0, 1, 2
Volume ID: 0 (on ubi0)
Type: dynamic
Alignment: 1
Size: 38 LEBs (4825088 bytes, 4.6 MiB)
State: OK
Name: kernel
Character device major/minor: 248:1
-----------------------------------
Volume ID: 1 (on ubi0)
Type: dynamic
Alignment: 1
Size: 120 LEBs (15237120 bytes, 14.5 MiB)
State: OK
Name: ubi_rootfs
Character device major/minor: 248:2
-----------------------------------
Volume ID: 2 (on ubi0)
Type: dynamic
Alignment: 1
Size: 163 LEBs (20697088 bytes, 19.7 MiB)
State: OK
Name: rootfs_data
Character device major/minor: 248:3
===================================
ubi1
Volumes count: 1
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 96 (12189696 bytes, 11.6 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 20
Current maximum erase counter value: 17
Minimum input/output unit size: 2048 bytes
Character device major/minor: 247:0
Present volumes: 0
Volume ID: 0 (on ubi1)
Type: dynamic
Alignment: 1
Size: 72 LEBs (9142272 bytes, 8.7 MiB)
State: OK
Name: qcacfg
Character device major/minor: 247:1
===================================
ubi2
Volumes count: 1
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 128 (16252928 bytes, 15.5 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 20
Current maximum erase counter value: 5
Minimum input/output unit size: 2048 bytes
Character device major/minor: 240:0
Present volumes: 0
Volume ID: 0 (on ubi2)
Type: dynamic
Alignment: 1
Size: 104 LEBs (13205504 bytes, 12.6 MiB)
State: OK
Name: qcalog
Character device major/minor: 240:1
Now Again I am trying to explain every thing so stay with me
the firmware image i generated with replacing OEM UBI and only changing crc32 checksum at the footer
Accepted by device and flashed to inactive part and device reboots but fails to read UBI and verify checksum
DRAM: 256 MiB
machid : 0x8010100
NAND: spi_nand: spi_nand_flash_probe SF NAND ID 0:ef:aa:21
SF: Detected W25N01GV with page size 2 KiB, total 128 MiB
SF: Detected W25Q32 with page size 4 KiB, total 4 MiB
ipq_spi: page_size: 0x100, sector_size: 0x1000, size: 0x400000
132 MiB
Boot act=0
0x000000000000-0x000002900000 : "mtd=0"
UBI error: check_sv: bad scanning information, error 1
UBI error: ubi_init: cannot attach mtd2
UBI error: ubi_init: UBI error: cannot initialize UBI, error -22
UBI init error 22
Image checksum error!!!
and then reset and change active side to 1 and boot OEM firmware.
Now the thing is OEM UBI is 22400KiB 0x015E0000
and has 6 blocks 0x1000
each has 0xDEADC0DE
mark at the end of the UBI at these offsets
0x0158A000
0x0158B000
0x0158D000
0x01595000
0x015A6000
0x015C7000
now I have failed to generate a UBI that is identical to OEM I have tried many things
Using pad-to 22400k
pads the UBI to the size but with 0x00
trying to set volume names and sizes from image recipe failed
using qsdk-ipq-factory-nand
also failed i had to use OEM's pre generated
So how can I generate UBI that has specific volume names and sizes?
And is this is the problem ?
Help is much appreciated