From a94e8ba63e8141cbb85d5e3d203a211e7d919ec9 Mon Sep 17 00:00:00 2001 From: Jesse Taube Date: Fri, 21 Jan 2022 19:16:47 -0500 Subject: [PATCH] licence rename and list --- flash.h => flash-defs.h | 3 +-- flash_confs.c | 8 +++++++- flash_confs.h | 7 ++++++- main.c => imx-flashconf.c | 35 ++++++++++++++++++++++++++++------- mk.sh | 3 ++- 5 files changed, 44 insertions(+), 12 deletions(-) rename flash.h => flash-defs.h (99%) rename main.c => imx-flashconf.c (68%) diff --git a/flash.h b/flash-defs.h similarity index 99% rename from flash.h rename to flash-defs.h index a2b19d4..f7bc678 100644 --- a/flash.h +++ b/flash-defs.h @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: BSD-3-Clause /* * Copyright 2018-2020 NXP * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause */ #ifndef __FLEXSPI_NOR_CONFIG__ diff --git a/flash_confs.c b/flash_confs.c index d43af8e..1d483a1 100644 --- a/flash_confs.c +++ b/flash_confs.c @@ -1,4 +1,10 @@ -#include "flash.h" +// SPDX-License-Identifier: BSD-3-Clause +/* + * Copyright 2018-2020 NXP + * All rights reserved. + */ + +#include "flash-defs.h" #include "flash_confs.h" static const flash_configs configs[] = { { .config = { diff --git a/flash_confs.h b/flash_confs.h index 7baa18c..0b88e46 100644 --- a/flash_confs.h +++ b/flash_confs.h @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: (GPL-2.0 or MIT) +/* + * Copyright (C) 2020 Jesse Taube + */ + #ifndef __FLASH_CONFIGS__ #define __FLASH_CONFIGS__ typedef struct _flash_configs { @@ -5,4 +10,4 @@ char name[32]; } flash_configs; const flash_configs * get_flash_confs(); -#endif /* __FLASH_CONFIGS__*/ \ No newline at end of file +#endif /* __FLASH_CONFIGS__ */ \ No newline at end of file diff --git a/main.c b/imx-flashconf.c similarity index 68% rename from main.c rename to imx-flashconf.c index 0e12c40..5ff02da 100644 --- a/main.c +++ b/imx-flashconf.c @@ -1,3 +1,8 @@ +// SPDX-License-Identifier: (GPL-2.0 or MIT) +/* + * Copyright (C) 2020 Jesse Taube + */ + #include #include #include @@ -5,12 +10,13 @@ #include #include #include -#include "flash.h" +#include "flash-defs.h" #include "flash_confs.h" -size_t get_name_match(const flash_configs* , const char * name); -void help(int code); -void prepend(FILE * fno, size_t offset); +size_t get_name_match(const flash_configs * , const char *); +void help(int); +void prepend(FILE *, size_t); +void list(const flash_configs *); int main(int argc, char *argv[]){ char name[32]; @@ -22,7 +28,7 @@ int main(int argc, char *argv[]){ FILE * fnum; const flash_configs * configs = get_flash_confs(); const flexspi_nor_config_t * config; - while ((opt = getopt(argc, argv, "p:n:o:b:")) != -1) + while ((opt = getopt(argc, argv, "p:n:o:b:lh")) != -1) { errno = 0; switch (opt) @@ -50,6 +56,9 @@ int main(int argc, char *argv[]){ case 'h': help(0); break; + case 'l': + list(configs); + break; default: help(-3); break; @@ -87,8 +96,13 @@ int main(int argc, char *argv[]){ puts("Done!"); return 0; } +void list(const flash_configs * configs){ + for(size_t i = 0; *configs[i].name;i++) + printf("%lu: %s\n",i,configs[i].name); + exit(0); +} -size_t get_name_match(const flash_configs* configs, const char * name){ +size_t get_name_match(const flash_configs * configs, const char * name){ size_t i = 0; while(*configs[i].name){ if(strncmp(configs[i].name,name,32) == 0) @@ -137,6 +151,13 @@ void prepend(FILE * fno, size_t offset){ } void help(int code){ - puts("help"); + puts("+--------------------------------------------------------------+"); + puts("| -h - This message. |"); + puts("| -o - Output file name. |"); + puts("| -n - Name of flash config to use, defined in flash_confs.c . |"); + puts("| -p - Padding offset, other than default (0x1000). |"); + puts("| -b - Create binary image, and offset to put u-boot.img at. |"); + puts("| -l - List names of flash defined in flash_confs.c . |"); + puts("+--------------------------------------------------------------+"); exit(code); } \ No newline at end of file diff --git a/mk.sh b/mk.sh index b7f71bc..64b7790 100755 --- a/mk.sh +++ b/mk.sh @@ -1 +1,2 @@ -gcc *.c -o test \ No newline at end of file +#!/usr/bin/bash +gcc -Wall imx-flashconf.c flash_confs.c -o imx-flashconf \ No newline at end of file -- 2.42.0