pyocd / FlashAlgo

Framework for building Arm Cortex-M "FLM" style flash programming algorithms.
Apache License 2.0
159 stars 151 forks source link

flash_algo.py problem #58

Open pashka32 opened 3 years ago

pashka32 commented 3 years ago

Hello. I am trying to run a flash_algo.py file. I need to create an algo file for stm32h7. However, I am getting the error. What could be the reason for this?

(venv) root@Note:/mnt/d/pyTest# python3 flash_algo.py STM32H7xx.FLM c_blob.tmpl out.c
Traceback (most recent call last):
  File "flash_algo.py", line 349, in <module>
    main()
  File "flash_algo.py", line 45, in main
    algo.process_template(args.template, args.output)
  File "flash_algo.py", line 158, in process_template
    target_text = template.render(data_dict)
  File "/mnt/d/pyTest/venv/lib/python3.8/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/mnt/d/pyTest/venv/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 41, in top-level template code
jinja2.exceptions.UndefinedError: 'header_size' is undefined
flit commented 3 years ago

This is caused by running flash_algo.py directly instead of running generate_blobs.py. (Sorry it's not very obvious!)

You can see here that generate_blobs.py defines the dictionary used for the Jinja template, including header_size: https://github.com/pyocd/FlashAlgo/blob/1244f427929884425ed09dab17e7a120749dada8/scripts/generate_blobs.py#L64-L70