pyocd / pyOCD

Open source Python library for programming and debugging Arm Cortex-M microcontrollers
https://pyocd.io
Apache License 2.0
1.13k stars 484 forks source link

Wrong r12 offset in FreeRTOS stack frame #1043

Closed newbrain closed 3 years ago

newbrain commented 3 years ago

Offset of r12 in FreeRTOS stack frame dictionary at line 102 in pyocd/rtos/freertos.py is not correct: https://github.com/pyocd/pyOCD/blob/f146817ad2233d247e70fbba6adfe03b2c3fd8cc/pyocd/rtos/freertos.py#L101-L103

The correct value should be 52, (42 is, oddly, not the correct answer here).

flit commented 3 years ago

Oops, thanks for the report.

(42 is, oddly, not the correct answer here)

🤣

Fyi, I have an update to the FreeRTOS plugin that supports FreeRTOS 10.x. It needs more testing, and I haven't yet checked whether it breaks compatibility with FreeRTOS 8.x/9.x. The branch is https://github.com/flit/pyOCD/tree/feature/freertos_10.

newbrain commented 3 years ago

Fyi, I have an update to the FreeRTOS plugin that supports FreeRTOS 10.x.

Interesting, thanks.

I'm working on a ThreadX (AzureRTOS) plugin, that's why I've noticed the typo. It seems to work but I need to set up a compliant development environment and to test it according to the Contributing.md document, till now I've just added the new code on my installation(s). If all goes well, I'll make a pull request in 1-2 weeks.

flit commented 3 years ago

I'm working on a ThreadX (AzureRTOS) plugin

Sweet! If you need any help, just ask. You can either email me or use the new GitHub Discussions.

You might actually want to take a look at my feature/freertos_10 branch. There is a utility called build_register_offset_table() in pyocd/rtos/common.py. And there is a more compact way of generating offsets in the FreeRTOS code. With all the stack frame forms possible in v8-M it was getting pretty crazy using simple lists of offsets. Eventually I'd like to make most of the thread context class common.