mediatek: fix IPv4-only corner case and commit in 99-net-ps
[oweals/openwrt.git] / scripts / mkits-qsdk-ipq-image.sh
1 #!/usr/bin/env bash
2 #
3 # Licensed under the terms of the GNU GPL License version 2 or later.
4 # Author: Piotr Dymacz <pepe2k@gmail.com>, based on mkits.sh.
5 #
6 # Qualcomm SDK (QSDK) sysupgrade compatible images for IPQ40xx, IPQ806x
7 # and IPQ807x use FIT format together with 'dumpimage' tool from U-Boot
8 # for verifying and extracting them. Based on 'images' sections names,
9 # corresponding mtd partitions are flashed.
10 # This is a simple script for generating FIT images tree source files,
11 # compatible with the QSDK sysupgrade format. Resulting images can be
12 # used for initial (factory -> OpenWrt) installation and would work
13 # both in CLI and GUI. The script is also universal in a way it allows
14 # to include as many sections as needed.
15 #
16
17 usage() {
18         echo "Usage: `basename $0` output img0_name img0_file [[img1_name img1_file] ...]"
19         exit 1
20 }
21
22 # We need at least 3 arguments
23 [ "$#" -lt 3 ] && usage
24
25 # Target output file
26 OUTPUT="$1"; shift
27
28 # Create a default, fully populated DTS file
29 echo "\
30 /dts-v1/;
31
32 / {
33         description = \"OpenWrt factory image\";
34         #address-cells = <1>;
35
36         images {" > ${OUTPUT}
37
38 while [ -n "$1" -a -n "$2" ]; do
39         [ -f "$2" ] || usage
40
41         name="$1"; shift
42         file="$1"; shift
43
44         echo \
45 "               ${name} {
46                         description = \"${name}\";
47                         data = /incbin/(\"${file}\");
48                         type = \"Firmware\";
49                         arch = \"ARM\";
50                         compression = \"none\";
51                         hash@1 {
52                                 algo = \"crc32\";
53                         };
54                 };" >> ${OUTPUT}
55 done
56
57 echo \
58 "       };
59 };" >> ${OUTPUT}