[Android Q&A, Help & Troubleshooting] barretoperez:
Well... it's indeed quite hard to find. There aren't many public instructions online, but I figured out how to repack payload.bin by reading the code in two repositories: https://github.com/google/ota-generator and https://github.com/chenxiaolong/avbroot-inc-ota.

This payload.bin thing is an OTA update firmware package, containing compressed image files like system.img, boot.img, vendor.img, and metadata. It's generated during the Android source code compilation process using delta_generator, which is part of Google's official otatools. You can download otatools from here: https://ci.android.com/builds/branches/aosp-master/grid. Just pick any green square under "aosp_cf_x86_64_phone," and click to download. All the executable files for otatools are mostly in the 'bin' directory, including delta_generator, and it must be run in a 64-bit Linux environment.

As for using delta_generator, it's quite complex because it requires information about the names of various OTA partitions (like abl, modem, system, vendor, etc.), the corresponding image file paths, dynamic partition group information (which needs a separate text file; without it, the resulting payload won't work for flashing), post-installation command lines (also specified in a separate text file), and timestamp information.

I can show you the command I used with delta_generator, and you can use it as a reference. But don't copy it verbatim, as each device's partition setup is different:

./delta_generator -out_file=payload.bin -partition_names=abl:aop:bluetooth:boot:cmnlib:cmnlib64:devcfg:dsp:dtbo:featenabler:hyp:imagefv:keymaster:logo:mdm_oem_stanvbk:modem:multiimgoem:my_bigball:my_carrier:my_company:my_engineering:my_heytap:my_manifest:my_preload:my_product:my_region:my_stock:odm:product:qupfw:recovery:spunvm:storsec:system:system_ext:tz:uefisecapp:vbmeta:vbmeta_system:vendor:xbl:xbl_config:xbl_config_lp5:xbl_lp5 -new_partitions=./payload/abl.img:./payload/aop.img:./payload/bluetooth.img:./payload/boot.img:./payload/cmnlib.img:./payload/cmnlib64.img:./payload/devcfg.img:./payload/dsp.img:./payload/dtbo.img:./payload/featenabler.img:./payload/hyp.img:./payload/imagefv.img:./payload/keymaster.img:./payload/logo.img:./payload/mdm_oem_stanvbk.img:./payload/modem.img:./payload/multiimgoem.img:./payload/my_bigball.img:./payload/my_carrier.img:./payload/my_company.img:./payload/my_engineering.img:./payload/my_heytap.img:./payload/my_manifest.img:./payload/my_preload.img:./payload/my_product.img:./payload/my_region.img:./payload/my_stock.img:./payload/odm.img:./payload/product.img:./payload/qupfw.img:./payload/recovery.img:./payload/spunvm.img:./payload/storsec.img:./payload/system.img:./payload/system_ext.img:./payload/tz.img:./payload/uefisecapp.img:./payload/vbmeta.img:./payload/vbmeta_system.img:./payload/vendor.img:./payload/xbl.img:./payload/xbl_config.img:./payload/xbl_config_lp5.img:./payload/xbl_lp5.img -dynamic_partition_info_file=./dyn_part_info.txt -max_timestamp=1673519040 -new_postinstall_config_file=./postinstall_config.txt

The dyn_part_info.txt file is the dynamic partition group information file. In my case, the content I wrote is as follows:

super_partition_groups=qti_dynamic_partitions
super_qti_dynamic_partitions_group_size=5639712768
super_qti_dynamic_partitions_partition_list=vendor system product odm my_engineering system_ext my_product my_stock my_heytap my_company my_carrier my_region my_preload my_bigball my_manifest

Then, postinstall_config.txt contains the post-installation command information (for my case, it's for the vendor partition):

RUN_POSTINSTALL_vendor=true
POSTINSTALL_PATH_vendor=bin/checkpoint_gc

After running the above command, the generated payload.bin file needs to be signed before it can be flashed through recovery. You can generate a signing certificate using OpenSSL, and choose the RSA algorithm. As for how to sign it, you can refer to the 'sign_payload()' function in the main.rs file in this project https://github.com/chenxiaolong/avbroot-inc-ota. Then write your own Rust program to implement it.

Good luck!

And, if you find all of this a bit too cumbersome, you might want to consider the ota-generator I mentioned earlier. It's an official Google tool for creating OTA packages with a user-friendly graphical interface. However, their codebase is a bit outdated, and they've used a Vue frontend web interface, which causes compatibility issues. At least on my node.js, it didn't run successfully, and I'm not a frontend developer, so I can't fix the errors. As a result, I had to give up on their graphical tool and resort to this more rudimentary method, but it's effective at least.