Re: custom script for debug/flash


Marti Bolivar
 

Hi Raj,

On Tue, Nov 14, 2017 at 1:32 AM, Gundi, Rajavardhan <rajavardhan.gundi@...> wrote:

Hi Marti,

 

I see that you have modified the “debug”, “debugserver” and “flash” scripts to make it OS agnostic. I am working on an xtensa board and I have a dedicated script for this board which is different from the regular xtensa.py that you have created. I have the below questions in order to port my script to the new method.


Sure thing, happy to help. 

1)    How is xtensa.py being invoked? In other words if my new script is called myxtensa.py, what I should do to ensure this gets called?

Currently, by creating a subclass of ZephyrBinaryRunner that provides a create_for_shell_script() method which claims compatibility with 'xt-gdb.sh'. (See link to documentation below and the source code for zephyr_flash_debug.py ).

The use of this method is a temporary transition so that the rest of the build system wouldn't have to change much to invoke the Python scripts as opposed to the old shell scripts.  The Makefile / Makefile.inc changes in this patch hopefully make it more clear what happened:


Now that the build system has switched to CMake, it's less clear what's going on. My next goal is to change the interface to zephyr_flash_debug.py so it doesn't rely on environment variables and just takes command line arguments instead. This will allow removing the create_for_shell_script() method.

One important gotcha is that your module currently must be imported so the ZephyrBinaryRunner subclass is found. See scripts/support/runner/__init__.py for an example.

2)    Is there documentation on how to write the script? I looked at what’s there in the comments, but is that enough? If yes, I’ll go over them again.

Well, I hope so, but if there's anything Zephyr-specific that's missing I hope you'll let me know, and I'll try to improve it.

Here is the main documentation for ZephyrBinaryRunner, which is the most important class:


I'll try to make time to add some of this information to Zephyr's Sphinx documentation as well.

3)    My script is heavily making use of Linux shell scripting. It makes use of kill, sleep, Ctrl+C etc. Any pointers on how to achieve these now?


Luckily, Python has good cross-platform support for dealing with operating system facilities like sleeping and signals. Since Zephyr is moving to Python 3 over shell scripts, some research on your part will be needed. I suggest taking a look at the Python documentation and searching around on things like StackOverflow, and looking at the existing implementations for examples.

Thanks,
Marti
 

Regards,

Raj


Join devel@lists.zephyrproject.org to automatically receive all group messages.