diff options
| author | Alejandro Soto <alejandro@34project.org> | 2024-05-22 14:59:49 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2024-05-24 05:58:43 -0600 |
| commit | cc3eed896e039d3c7088454ed49e483b82fe9917 (patch) | |
| tree | 6fb0a1acc630b94da0a6bb16ce58d7036ebacbcd | |
| parent | f544591a74d0f27d5e55261ce50eec562549aad9 (diff) | |
scripts/makehex: initial commit
Diffstat (limited to '')
| -rw-r--r-- | mk/makehex.mk | 11 | ||||
| -rw-r--r-- | mk/tools.mk | 1 | ||||
| -rw-r--r-- | scripts/makehex.py | 22 |
3 files changed, 34 insertions, 0 deletions
diff --git a/mk/makehex.mk b/mk/makehex.mk new file mode 100644 index 0000000..9aa9ebb --- /dev/null +++ b/mk/makehex.mk @@ -0,0 +1,11 @@ +makehex_src = $(call require_core_objs,$(1),makehex_src) +makehex_obj = $(call require_core_objs,$(1),makehex_obj) + +define hooks/makehex + define obj_rules + $$(call makehex_obj,$(1)): $$(call makehex_src,$(1)) scripts/makehex.py $$(obj_deps) + $$(call run,MAKEHEX,$$@) $$(PYTHON3) scripts/makehex.py <$$< >$$@ + endef + + $$(eval $$(call add_obj_rules,$(1))) +endef diff --git a/mk/tools.mk b/mk/tools.mk index d5ea853..5decb78 100644 --- a/mk/tools.mk +++ b/mk/tools.mk @@ -3,6 +3,7 @@ define find_tools_lazy $(call find_command_lazy,genhtml,GENHTML) $(call find_command_lazy,peakrdl,PEAKRDL) $(call find_command_lazy,pkg-config,PKG_CONFIG) + $(call find_command_lazy,python3,PYTHON3) $(call find_command_lazy,qsys-generate,QSYS_GENERATE) $(call find_command_lazy,quartus,QUARTUS) $(call find_command_lazy,verilator,VERILATOR) diff --git a/scripts/makehex.py b/scripts/makehex.py new file mode 100644 index 0000000..3304fb3 --- /dev/null +++ b/scripts/makehex.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# +# This is free and unencumbered software released into the public domain. +# +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. + +import sys + +bindata = sys.stdin.buffer.read() +assert len(bindata) % 4 == 0 +nwords = len(bindata) // 4 + +for i in range(nwords): + if i < len(bindata) // 4: + w = bindata[4*i : 4*i+4] + print("%02x%02x%02x%02x" % (w[3], w[2], w[1], w[0])) + else: + print("0") + |
