Commit graph

6 commits

Author SHA1 Message Date
Ruslan Mstoi a8e0655833 scripts: file2hex.py: PEP 8 style fix
Fix pycodestyle PEP 8 issue:

E127 continuation line over-indented for visual indent

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2020-06-12 11:09:58 +02:00
Ruslan Mstoi 1bae76770b scripts: file2hex.py: add argument help text
Convert the description comment at the top of the file to a
documentation string. That string then maybe viewed with the --help
argument. Also, rework a bit the documentation string.

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2020-06-12 11:09:58 +02:00
Marc Herbert 3061c92aaf file2hex.py: new --gzip-mtime option that defaults to zero + test
This makes the output of file2hex.py deterministic by default while also
letting the user set the mtime in the gzip header manually if desired.

Use the option without any argument to restore the previous behavior
that sets the current (and obviously changing) "now" timestamp.

To test:  ./sanitycheck --tag gen_inc_file

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-04-17 08:27:40 -04:00
Marc Herbert 195195a4fc file2hex.py: switch from gzip.compress() to GzipFile()
Zero functional change, this is pure refactoring and preparation for
using the mtime= parameter which the gzip.compress() shortcut does not
make available.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-03-29 08:12:53 -04:00
Anas Nashif 7256553955 scripts: python: cleanup script and fix PEP8 issues
Ran scripts through flake8 and fixed issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-03 19:03:41 -05:00
Jukka Rissanen 0ff4c25958 build: Add rules in Makefile.gen to generate a hex file
This commit is useful if there is a need to generate a file
that can be included into the application at build time.
The file can also be compressed automatically when embedding it.

Files to be generated are listed in
     generate_inc_file
     generate_inc_gz_file
variables.

How to use this commit in your application:

1. Add this to your application Makefile

   SRC = $(ZEPHYR_BASE)/<your-app-dir>/src
   include $(ZEPHYR_BASE)/scripts/Makefile.gen

2. Add needed binary/other embedded files into src/Makefile
   to "generate_inc_file" or "generate_inc_gz_file" variables:

   # List of files that are used to generate a file that can be
   # included into .c file.
   generate_inc_file += \
           echo-apps-cert.der \
           echo-apps-key.der \
           file.bin

   generate_inc_gz_file += \
           index.html

   include $(ZEPHYR_BASE)/scripts/Makefile.gen

3. In the application, do something with the embedded file

   static const unsigned char inc_file[] = {
   #include "file.bin.inc"
   };

   static const unsigned char gz_inc_file[] = {
   #include "index.html.gz.inc"
   };

The generated files in ${SRC}/*.inc are automatically removed
when you do "make pristine"

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-18 14:56:16 -04:00