updater: Add script for converting bin file to C array
This commit is contained in:
		@@ -56,7 +56,7 @@ $(OBJ):
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	@echo [CLEAN]
 | 
			
		||||
	rm -f $(OBJ) $(MAPFILE).map $(CFILES:%.c=$(OBJDIR)/%.c.d) $(RAM_CODE_TARGET).bin $(RAM_CODE_TARGET).elf $(RAM_CODE_TARGET).bin.c
 | 
			
		||||
	$(QUIET)rm -f $(OBJ) $(MAPFILE).map $(CFILES:%.c=$(OBJDIR)/%.c.d) $(RAM_CODE_TARGET).bin $(RAM_CODE_TARGET).elf $(RAM_CODE_TARGET).bin.c
 | 
			
		||||
 | 
			
		||||
-include $(CFILES:%.c=$(OBJDIR)/%.c.d)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,8 @@
 | 
			
		||||
#!env python
 | 
			
		||||
 | 
			
		||||
# Convert a file to a c array
 | 
			
		||||
# bin2carray <output file> <input file>
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
@@ -11,7 +14,17 @@ dest_file = sys.argv[1]
 | 
			
		||||
 | 
			
		||||
print("%s --> %s" % (source_file, dest_file))
 | 
			
		||||
 | 
			
		||||
with open(dest_file, "w") as f:
 | 
			
		||||
	f.write("AAA")
 | 
			
		||||
with open(source_file, "rb") as src:
 | 
			
		||||
	data = src.read()
 | 
			
		||||
 | 
			
		||||
with open(dest_file, "w") as dest:
 | 
			
		||||
	dest.write("static const char binary_blob[%d] = {\n" % (len(data)))
 | 
			
		||||
	for current,idx in zip(data, range(len(data))):
 | 
			
		||||
		if ((idx+1) % 4 == 0):
 | 
			
		||||
			dest.write(hex(current)+",\n")
 | 
			
		||||
		else:
 | 
			
		||||
			dest.write(hex(current)+",")
 | 
			
		||||
 | 
			
		||||
	dest.write("};\n")
 | 
			
		||||
 | 
			
		||||
sys.exit(0)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user