Skip to content
Snippets Groups Projects
Commit 54bd3c37 authored by Tristan Gingold's avatar Tristan Gingold
Browse files

tomem: pad software, adjust envm config

parent 140833dc
Branches
No related merge requests found
nvm_set_data_storage_client \
-client_name {code} \
-number_of_words 168 \
-number_of_words 256 \
-word_size 8 \
-use_for_simulation {0} \
-content_type {MEMORY_FILE} \
......
......@@ -21,7 +21,7 @@ main.o: main.c
${OBJCOPY} -O binary $< $@
%.mem: %.bin
./tomem.py $< > $@
./tomem.py $< 1024 > $@
$(OUTPUT).elf: $(LDS) $(OBJS)
${XCC} $(CFLAGS) -o $@ -nostartfiles $(OBJS) -T $(LDS) -Wl,-Map=$(OUTPUT).map
......
......@@ -4,15 +4,23 @@ import sys
def main():
if len(sys.argv) < 2:
sys.exit("Usage: {} FILE".format(sys.argv[0]))
sys.exit("Usage: {} FILE [LEN]".format(sys.argv[0]))
filename = sys.argv[1]
b = open(filename, 'rb').read()
if len(b) % 4 != 0:
sys.exit("length of {} is not a multiple of 4".format(filename))
if len(sys.argv) > 1:
flen = int(sys.argv[2])
if len(b) > flen:
sys.exit("{} is longer than {}".format(filename, flen))
else:
flen = len(b)
for i in range(len(b)):
v, = struct.unpack('<B', b[i])
print('{:08b}'.format(v))
for i in range(len(b), flen):
print('{:08b}'.format(0))
if __name__ == '__main__':
main()
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment