====== oowow-dump2xz ====== - https://docs.khadas.com/_export/code/scripts/oowow-dump2xz?codeblock=0 - https://github.com/khadas-oowow/oowow-tools/blob/main/oowow-dump2xz ===== Online usage examples ===== - write android image via burn tool - connect SBC with PC by USB cable - reboot device to oowow - boot next shell commands from PC ''export BOOT=1'' - copy boot-loader from special eMMC area - this is actual for VIM4 Ardroid 14, this feature works start **from oowow version 241000 up** '' mkdir Android-14-vim4 && cd Android-14-vim4 \\ export OSVER=14 \\ export VER=v240822-beta \\ export BOOT=1 \\ #export REMOTE=192.168.31.x \\ #export REMOTE=edge2-12345.local \\ curl http://docs.khadas.com/_export/code/scripts/oowow-dump2xz?codeblock=0 | sh -s - \\ ls -l1 *.img.xz '' ```sh oowow-dump2xz #!/bin/sh ## hyphop ## #= oowow-dump2xz #: USAGE mkdir FOO && cd FOO && [OSVER=] [VER=] [LABEL=] [OUT=] [BOOT=] owow-dump2xz lowcase(){ echo "$@" | tr '[:upper:]' '[:lower:]' ; } upcase(){ echo "$@" | tr '[:lower:]' '[:upper:]' ; } CMD(){ echo "# $@" >&2 ; "$@" ;} DIE(){ echo "! $@" >&2 ; exit 1;} REMOTE=${REMOTE:-172.22.1.1} XZE=https://raw.githubusercontent.com/hyphop/khadas-rescue-tools/master/scripts/xze XZE=http://docs.khadas.com/_export/code/scripts/xze?codeblock=0 for D in *-dump.img.zst; do O=${D%.*} [ -s "$D" ] || continue CMD zstd -d "$D" || CMD rm "$O" done for D in *-dump.img; do [ -s "$D" ] && break D= done [ "$D" ] || { # DUMP begin echo DUMP data ... ping -q -c1 $REMOTE || DIE "cant reach $REMOTE host" BOARD=$(ssh root@$REMOTE /opt/board_name 2>/dev/null ) echo "BOARD: $BOARD" [ "BOARD" ] || DIE "BOARD undetected" boot=boot0 [ "$BOOT" ] && { echo copy boot area ssh root@$REMOTE cat /dev/mmcblk?boot0 > $boot ls -l1 $boot } T=$BOARD.sfdisk ssh root@$REMOTE sfdisk --dump \$\(/opt/mmc_disk\)>$T # | tee $T echo -- USER_DATA=userdata grep $USER_DATA $T || ssh root@$REMOTE /opt/aml_partitions >>$T # | tee $T grep $USER_DATA $T | while read a b c d e f g h j k l m ; do [ "$d" ] || DIE "partition $USER_DATA not found" echo "${d%,*} or $l" echo ${l:-${d%,*}} > $T.userdata done read USER_START < $T.userdata BS=512 BYTES=${BYTES:-$((USER_START*BS))} board=${board-$(lowcase $BOARD)} DUMP=$BOARD-emmc-dump.img echo "Dump image from $BOARD > $DUMP $BYTES bytes ...wait..." CMD curl -L "$REMOTE"/api/disk/rdz/mmc.zst:$((BYTES)) -o$DUMP.zst CMD zstd -d $DUMP.zst D=$DUMP } # DUMP end BOARD=${D%%-*} board=${board-$(lowcase $BOARD)} LABEL=${LABEL:-Android} label=${label:-$(lowcase $LABEL)} OSVER=${OSVER:-14} VER=${VER:-v240820} OUT=${OUT:-$board-$label-$OSVER-$VER.raw.img} echo "CONVERT $D to $OUT ..." [ -e "$OUT" ] && DIE "image $OUT already exist" CMD truncate -s+50M "$D" CMD mv "$D" "$OUT" bootloader(){ [ "$BOOT" ] || return 0 boot=${boot:-boot0} echo "BOOT LOADER '$boot' inject to image...">&2 BOOT_OFFSET=$(du -b "$OUT") BOOT_SIZE=$(du -b "$boot") echo "copy boot area $boot to $OUT by $BOOT_OFFSET + $BOOT_SIZE">&2 gzip -c $boot >> "$OUT" echo bootloader=$BOOT_OFFSET } xze=$(which xze) xze=${xze:-./xze} [ -s "$xze" ] || curl "$XZE" -o"$xze" CMD sh $xze "$OUT" \ --meta \ label="$LABEL" \ builder="Khadas" \ date="$(TZ=GMT+0 date)" \ match=BOARD=$BOARD \ $(bootloader) \ duration=90 \ desc="$BOARD $LABEL $OSVER $VER" ``` ```shell logs mkdir Android-14-vim4 && cd Android-14-vim4 export OSVER=14 export VER=v240822-beta curl http://docs.khadas.com/_export/code/scripts/oowow-dump2xz?codeblock=0 | sh -s - % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1837 0 1837 0 0 2209 0 --:--:-- --:--:-- --:--:-- 2210 DUMP data ... PING 172.22.1.1 (172.22.1.1) 56(84) bytes of data. --- 172.22.1.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.343/0.343/0.343/0.000 ms BOARD: VIM4 Warning: Permanently added '172.22.1.1' (ED25519) to the list of known hosts. The backup GPT table is corrupt, but the primary appears OK, so that will be used. -- 8124416, - size= 52946936, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=1FE84740-97C9-8C42-98E2-C47015AECEC7, name="userdata", attrs="GUID:50,60" Dump image from VIM4 > VIM4-emmc-dump.img 4159700992 bytes ...wait... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 8485 0 8485 0 0 8496 0 --:--:-- --:--:-- --:--:-- 8493 # curl -L 172.22.1.1/api/disk/rdz/mmc.zst:4159700992 -oVIM4-emmc-dump.img.zst % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1032M 0 1032M 0 0 9.8M 0 --:--:-- 0:01:44 --:--:-- 4000 # zstd -d VIM4-emmc-dump.img.zst VIM4-emmc-dump.img.zst: 4159700992 bytes CONVERT VIM4-emmc-dump.img to vim4-android-14-v240822-beta.img ... # truncate -s+50M VIM4-emmc-dump.img # mv VIM4-emmc-dump.img vim4-android-14-v240822-beta.img # sh ./xze vim4-android-14-v240822-beta.img --meta label=Android builder=Khadas date=Thu Aug 22 02:58:40 AM GMT 2024 match=BOARD=VIM4 duration=90 desc=VIM4 Android 14 v240822-beta [i] xze compress vim4-android-14-v240822-beta.img (4212129792 bytes) > vim4-android-14-v240822-beta.img.xz # /usr/bin/xz -T8 --block-size 90M -k -c -F xz --verbose vim4-android-14-v240822-beta.img (1/1) 100 % 883.8 MiB / 4,017.0 MiB = 0.220 46 MiB/s 1:27 [i] padded to 926724096 from 926722204 + 1892 [i] XZ info Strms Blocks Compressed Uncompressed Ratio Check Filename 1 45 883.8 MiB 4,017.0 MiB 0.220 CRC64 vim4-android-14-v240822-beta.img.xz [i] add meta block ##META_FILE## FILE: vim4-android-14-v240822-beta.img.xz UNPACKED_SIZE: 4212129792 PACKED_SIZE: 926724096 FILE_SIZE: 926728192 ##META-FILE## ##KRESCUE_META## type:xz label: Android builder: Khadas date: Thu Aug 22 02:58:40 AM GMT 2024 match: BOARD=VIM4 duration: 90 desc: VIM4 Android 14 v240822-beta image: vim4-android-14-v240822-beta.img ##KRESCUE-META## ##KRESCUE##END [i] padded to 4096 from 308 + 3788 ``` ==== HowTo Check meta ==== ```shell khadas@localhost:/images/vim4$ xze vim4n-android-14-v240820.raw.img.xz Strms Blocks Compressed Uncompressed Ratio Check Filename 2 46 839.1 MiB 4,019.3 MiB 0.209 CRC64 vim4n-android-14-v240820.raw.img.xz [i] blocks: 46 // 839.1*MiB // 4,019.3*MiB ##META_FILE## FILE: vim4n-android-14-v240820.raw.img.xz UNPACKED_SIZE: 4214509060 PACKED_SIZE: 879849472 FILE_SIZE: 879853568 ##META-FILE## ##KRESCUE_META## type:xz label: Android builder: Khadas date: Wed Sep 18 05:43:57 AM GMT 2024 match: BOARD=VIM4 bootloader: 4212129792 vim4n-android-14-v240820.raw.img: vim4n-android-14-v240820.raw.img duration: 90 desc: VIM4 Android 14 v240820 image: vim4n-android-14-v240820.raw.img ##KRESCUE-META## ##KRESCUE##END ``` **bootloader: 4212129792** - showing us this image has additional special bootloader ==== VIM4 Android 11 ==== ''OSVER'' and ''VER'' must be setup properly and related with installed eMMC system ```sh VIM4 Android 11 export OSVER=11-64bit export VER=v240620 curl http://docs.khadas.com/_export/code/scripts/oowow-dump2xz?codeblock=0 | sh -s - ``` ==== VIM4 Android 14 ==== ''OSVER'' and ''VER'' must be setup properly and related with installed eMMC system ```sh VIM4 Android 14 export OSVER=14 export VER=v240820 export BOOT=1 curl http://docs.khadas.com/_export/code/scripts/oowow-dump2xz?codeblock=0 | sh -s - ``` ==== Edge2 Anrdoid 14 ==== ```sh export OSVER=14 export VER=v240820 curl http://docs.khadas.com/_export/code/scripts/oowow-dump2xz?codeblock=0 | sh -s - ``` ==== VIM1S Anrdoid 14 ==== ```sh export OSVER=14 export VER=v240820 curl http://docs.khadas.com/_export/code/scripts/oowow-dump2xz?codeblock=0 | sh -s - ```