Skip to content

ota: Add precheck for diff apply#12

Merged
xiaoxiang781216 merged 4 commits intoopen-vela:devfrom
JianyuWang0623:add_precheck
Jul 22, 2025
Merged

ota: Add precheck for diff apply#12
xiaoxiang781216 merged 4 commits intoopen-vela:devfrom
JianyuWang0623:add_precheck

Conversation

@JianyuWang0623
Copy link
Member

@JianyuWang0623 JianyuWang0623 commented Jul 22, 2025

Pick from Gerrit

Summary

  1. ota: remove this redundant judgment
  2. ota: need reboot and retry if patch failed
  3. ota: Fix error that progress exceeds 100
  4. ota: Add precheck for diff apply

Time spent

Binary Precheck (sec) Apply (sec)
vela_ap.bin 0.6540 53.5653
vela_audio.bin 0.1931 14.5435
vela_cp.bin 0.4005 31.8204
vela_quickapp.bin 0.2488 1.9555
vela_tee.bin 0.0944 5.9005
vela_vendor.bin 1.0311 9.8397

Impact

  • tools/gen_ota_zip.py

Testing

  1. Self test passed
all:

clean:
        rm -rvf ./ddelta_generate ./ddelta_apply
        rm -rvf ./after.crc32 ./before.crc32
        rm -rvf ./old/vela_ap*.hexdump
        rm -rvf ./new/vela_ap*.hexdump
        rm -rvf ./ap.patch
        rm -rvf ./*.tmp.log
        rm -rvf ./ap.patch.*
        rm -rvf ap.patch.*.zip

.crc32.before:
        crc32 old/vela_ap.bin* new/vela_ap.bin* ap.patch* > before.crc32
.crc32.after:
        crc32 old/vela_ap.bin* new/vela_ap.bin* ap.patch* > after.crc32

build_ddelta:
        make -C ../../../../external/ddelta/ddelta -f Makefile > $@.tmp.log 2>&1
        mv ../../../../external/ddelta/ddelta/ddelta_generate .
        mv ../../../../external/ddelta/ddelta/ddelta_apply .

dd_files:
        cp old/202506100438/images/ap/vela_ap.bin ./old
        cp new/202506150438/images/ap/vela_ap.bin ./new
        
        dd if=./old/vela_ap.bin of=./old/vela_ap.bin0 bs=524288 count=1
        dd if=./old/vela_ap.bin of=./old/vela_ap.bin1 bs=524288 count=1 skip=1
        dd if=./new/vela_ap.bin of=./new/vela_ap.bin0 bs=524288 count=1
        dd if=./new/vela_ap.bin of=./new/vela_ap.bin1 bs=524288 count=1 skip=1
        
        dd if=/dev/zero of=old/vela_ap.bin_zero bs=10485760 count=1
        
        hexdump -v -e '"%07.7_ax  " 16/1 "%02x " "\n"' ./old/vela_ap.bin > ./old/vela_ap.before.hexdump
        hexdump -v -e '"%07.7_ax  " 16/1 "%02x " "\n"' ./new/vela_ap.bin > ./new/vela_ap.before.hexdump


#
#
#

generate: ap.patch.blk5MB
apply: apply.normal

ap.patch.blk1KB: build_ddelta
        make dd_files > dd.tmp.log 2>&1
        rm -vf $@.zip
        ./ddelta_generate old/vela_ap.bin new/vela_ap.bin $@ 1024 > $@.tmp.log 2>&1
        zip $@.zip $@                                                                                                                                                                   
        ln -sf $@ ap.patch

ap.patch.blk512KB: build_ddelta
        make dd_files > dd.tmp.log 2>&1
        rm -vf $@.zip
        ./ddelta_generate old/vela_ap.bin new/vela_ap.bin $@ 524288 > $@.tmp.log 2>&1
        zip $@.zip $@
        ln -sf $@ ap.patch

ap.patch.blk5MB: build_ddelta
        make dd_files > dd.tmp.log 2>&1
        rm -vf $@.zip
        ./ddelta_generate old/vela_ap.bin new/vela_ap.bin $@ 5242880 > $@.tmp.log 2>&1
        zip $@.zip $@
        ln -sf $@ ap.patch

ap.patch.blknone: build_ddelta
        make dd_files > dd.tmp.log 2>&1
        rm -vf $@.zip
        ./ddelta_generate old/vela_ap.bin new/vela_ap.bin $@ > $@.tmp.log 2>&1
        zip $@.zip $@
        ln -sf $@ ap.patch

apply.normal: build_ddelta .crc32.before
        ./ddelta_apply ./old/vela_ap.bin ./ ./ap.patch > $@.tmp.log 2>&1
        hexdump -v -e '"%07.7_ax  " 16/1 "%02x " "\n"' ./old/vela_ap.bin > ./old/vela_ap.after.hexdump
        make .crc32.after

apply.test: build_ddelta .crc32.before
        ./ddelta_apply ./old/vela_ap.bin ./ ./ap.patch test > $@.tmp.log 2>&1
        hexdump -v -e '"%07.7_ax  " 16/1 "%02x " "\n"' ./old/vela_ap.bin > ./old/vela_ap.after.hexdump
        make .crc32.after

#
#
#

corrupt_block:
        # corrupt block?
        # Cannot apply patch: -4(2)
        make generate
        dd if=/dev/zero of=old/vela_ap.bin bs=16 seek=2 count=2 conv=notrunc
        make apply
  1. CI

gneworld and others added 4 commits July 22, 2025 15:53
The partition files that need to be differentiated end with .patch, and new partitions to be added are specified using --newpartition.

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
Should not exit and remove ota.zip(rcS.ota) after ddelta_apply failed.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 merged commit 16de41c into open-vela:dev Jul 22, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants