pyocd / pyocd/pyOCD

Got flash algorithm overflowed stack when using flash loader converted from KEIL pack FLM

Open
#1,450 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

I got following errors when using flash loader converted from Keil pack FLM, the FLM working well under KEIL and Segger JLINK, but failed when using in pyocd, seems pyocd could only download one flash sector.

[=================================                 ]  68%0003571 C flash algorithm overflowed stack (4096 bytes) [__main__]
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/pyocd/__main__.py", line 161, in run
    status = cmd.invoke()
  File "/opt/homebrew/lib/python3.10/site-packages/pyocd/subcommands/load_cmd.py", line 125, in invoke
    programmer.program(filename,
  File "/opt/homebrew/lib/python3.10/site-packages/pyocd/flash/file_programmer.py", line 170, in program
    self._loader.commit()
  File "/opt/homebrew/lib/python3.10/site-packages/pyocd/flash/loader.py", line 289, in commit
    perf = builder.program(chip_erase=chipErase,
  File "/opt/homebrew/lib/python3.10/site-packages/pyocd/flash/builder.py", line 509, in program
    flash_operation = self._sector_erase_program_double_buffer(progress_cb)
  File "/opt/homebrew/lib/python3.10/site-packages/pyocd/flash/builder.py", line 949, in _sector_erase_program_double_buffer
    result = self.flash.wait_for_completion(timeout=program_timeout)
  File "/opt/homebrew/lib/python3.10/site-packages/pyocd/flash/flash.py", line 648, in wait_for_completion
    raise exceptions.FlashFailure(f"flash algorithm overflowed stack ({self.begin_stack - self.end_stack} bytes)")
pyocd.core.exceptions.FlashFailure: flash algorithm overflowed stack (4096 bytes)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the stack-trace path in pyocd/flash/flash.py, then follow the calls from pyocd/flash/builder.py through pyocd/flash/loader.py and pyocd/flash/file_programmer.py. Reproduce the reported failure with the converted Keil FLM and determine why programming more than one sector triggers the 4096-byte stack overflow; done requires a confirmed cause and a regression test or clearly documented reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.