
On Sat, Dec 25, 2021 at 7:10 PM Pali Rohár pali@kernel.org wrote:
csum32 is checksum of data, not including header. If generated image does not pass kwboot verification then it is invalid.
Agreed, but this is how it gets computed later in the caller function:
/* Build and add image data checksum */ checksum = cpu_to_le32(image_checksum32((uint8_t *)ptr + headersz, datasz));
Since headersz is now different (headersz += opt_hdr_v1_size(ohdr); in this patch), presumably different (and maybe wrong?) data is now getting checksummed.
Has it worked with some previous version? If yes, can you bisect git commit which broke it?
Just reverting this one specific commit is enough to fix the issue. After revert:
$ tools/mkimage -n ./board/qnap/qsw-98dx3236/kwbimage.cfg -T kwbimage -a 0x00800000 -e 0x00800000 -d u-boot.bin u-boot.kwb Image Type: MVEBU Boot from nand Image Image version:1 BIN Hdr Size: 76224 Bytes = 74.44 KiB = 0.07 MiB Data Size: 735764 Bytes = 718.52 KiB = 0.70 MiB Load Address: 00800000 Entry Point: 00800000
$ sudo tools/kwboot -a -b u-boot.kwb -t -B 115200 /dev/ttyUSB0 kwboot version 2022.01-rc4-00076-g34df634003-dirty Patching image boot signature to UART Sending boot message. Please reboot the target...- Waiting 2s and flushing tty Sending boot image header (76288 bytes)... <snip> Done
General initialization - Version: 1.0.0 Serdes initialization - Version: 1.0.2 DDR3 Training Sequence - Ver TIP-1.55.0 DDR3 Training Sequence - Switching XBAR Window to FastPath Window DDR3 Training Sequence - Ended Successfully
Sending boot image data (735768 bytes)... <snip> Done Finishing transfer [Type Ctrl-\ + c to quit]
U-Boot 2022.01-rc4-00076-g34df634003-dirty (Jan 01 1980 - 00:00:00 +0000)
SoC: 98DX3236-A1 at 800 MHz Model: QNAP QSW-M408S Board: qsw-98dx3236 DRAM: 512 MiB (800 MHz, 16-bit, ECC not enabled) NAND: 512 MiB
Best,