diff --git a/bootinfo.c b/bootinfo.c index 34f44cc..ea7d5e3 100644 --- a/bootinfo.c +++ b/bootinfo.c @@ -336,6 +336,13 @@ void print_boot1_file_head(boot1_file_head_t *hdr, loader_type type) printf("Unknown boot0 header version\n"); } +static void usage(const char *cmd) +{ + puts("sunxi-bootinfo " VERSION "\n"); + printf("Usage: %s []\n", cmd); + printf(" With no given, will read from stdin instead\n"); +} + int main(int argc, char * argv[]) { FILE *in = stdin; @@ -352,8 +359,11 @@ int main(int argc, char * argv[]) } if (argc > 1) { in = fopen(argv[1], "rb"); - if (!in) - fail("open input: "); + if (!in) { + if (*argv[1] == '-') + usage(argv[0]); + fail("open input"); + } } int len; diff --git a/fel.c b/fel.c index 005c62a..7b61be8 100644 --- a/fel.c +++ b/fel.c @@ -28,6 +28,7 @@ #include #include +#include "common.h" #include "portable_endian.h" #include "progress.h" @@ -1565,6 +1566,7 @@ int main(int argc, char **argv) #endif if (argc <= 1) { + puts("sunxi-fel " VERSION "\n"); printf("Usage: %s [options] command arguments... [command...]\n" " -v, --verbose Verbose logging\n" " -p, --progress \"write\" transfers show a progress bar\n" diff --git a/fexc.c b/fexc.c index 9f603dd..e90bd14 100644 --- a/fexc.c +++ b/fexc.c @@ -215,6 +215,7 @@ done: */ static inline void app_usage(const char *arg0, int mode) { + fputs("sunxi-fexc " VERSION "\n\n", stderr); errf("Usage: %s [-vq]%s[ []]\n", arg0, mode ? " " : " [-I ] [-O ] "); diff --git a/nand-image-builder.c b/nand-image-builder.c index 0ca2d14..db42690 100644 --- a/nand-image-builder.c +++ b/nand-image-builder.c @@ -39,6 +39,7 @@ #include #include +#include "common.h" #include "portable_endian.h" #if defined(CONFIG_BCH_CONST_PARAMS) @@ -62,7 +63,6 @@ #define cpu_to_be32 htobe32 #define kfree free -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define BCH_PRIMITIVE_POLY 0x5803 @@ -916,7 +916,9 @@ static int create_image(const struct image_info *info) static void display_help(int status) { fprintf(status == EXIT_SUCCESS ? stdout : stderr, - "Usage: sunxi-nand-image-builder [OPTIONS] source-image output-image\n" + "sunxi-nand-image-builder %s\n" + "\n" + "Usage: sunxi-nand-image-builder [OPTIONS] source-image output-image\n" "\n" "Creates a raw NAND image that can be read by the sunxi NAND controller.\n" "\n" @@ -960,8 +962,8 @@ static void display_help(int status) " A normal image can be generated with\n" " sunxi-nand-image-builder -p 16384 -o 1280 -e 0x400000 -s -c 40/1024\n" " A boot0 image can be generated with\n" - " sunxi-nand-image-builder -p 16384 -o 1280 -e 0x400000 -s -b -u 4096 -c 64/1024\n" - ); + " sunxi-nand-image-builder -p 16384 -o 1280 -e 0x400000 -s -b -u 4096 -c 64/1024\n", + VERSION); exit(status); } diff --git a/nand-part-main.c b/nand-part-main.c index 274ce90..18d10f2 100644 --- a/nand-part-main.c +++ b/nand-part-main.c @@ -24,9 +24,11 @@ #include #include #include "nand-common.h" +#include "common.h" void usage(const char *cmd) { + puts("sunxi-nand-part " VERSION "\n"); printf("usage: %s [-f a10|a20] nand-device\n", cmd); printf(" %s nand-device 'name2 len2 [usertype2]' ['name3 len3 [usertype3]'] ...\n", cmd); printf(" %s [-f a10|a20] nand-device start1 'name1 len1 [usertype1]' ['name2 len2 [usertype2]'] ...\n", cmd); diff --git a/phoenix_info.c b/phoenix_info.c index 1db0ad3..4faded5 100644 --- a/phoenix_info.c +++ b/phoenix_info.c @@ -20,6 +20,7 @@ #include #include +#include "common.h" #include "portable_endian.h" struct phoenix_ptable { @@ -76,6 +77,7 @@ err: static void usage(char **argv) { + puts("phoenix-info " VERSION "\n"); printf("Usage: %s [options] [phoenix_image]\n" " -v verbose\n" " -q quiet\n" diff --git a/pio.c b/pio.c index 6f6fbd2..3ecf912 100644 --- a/pio.c +++ b/pio.c @@ -165,7 +165,7 @@ static const char *argv0; static void usage(int rc ) { - + fputs("sunxi-pio " VERSION "\n\n", stderr); fprintf(stderr, "usage: %s -m|-i input [-o output] pin..\n", argv0); fprintf(stderr," -m mmap - read pin state from system\n"); fprintf(stderr," -i read pin state from file\n");