Add stm32flash to zephyr_flash_debug.py script


Armando Visconti
 

Hi,

I added the support for a new stm32-based board, called ArgonKey.

I would like to add the possibility to flash my board using stm32flash
tool using 'make flash', but I noticed that there is no common support
for it. There are many tools already supported, like dfu-util and
jlink.

I'm currently studying the related infrastructure based on a series of
phyton scrips like zephyr_flash_debug.py.

As I'm quite new on zephyr can someone possibly point me to some
documentation on this part?

Thx,
Armando


Marti Bolivar
 

Hi Armando,

I had written a post about this to the list, but it seems like it is no longer part of the archives since we moved to groups.io (which is unfortunate, I assumed that archives would be preserved).

I reproduce it here for your reference, hope it helps:

You can specify a flash and debug runner without touching any board files by setting BOARD_FLASH_RUNNER and/or BOARD_DEBUG_RUNNER in the CMake command line when generating a build system.

Here is an example branch, in which I have created a "dummy" runner:


Here is the commit which adds the extra runner, which just prints the command instead of acting on hardware:


Here is an example shell session where the flash and debug runners are set at CMake time and then used later using "ninja flash", "ninja debug", and "ninja debugserver". I have used the nrf52_pca10040 board, but it should work with any board.

plop: ~/src/zephyr/samples/hello_world/build (set-runner) mbolivar
$ cmake -GNinja -DBOARD=nrf52_pca10040 -DBOARD_FLASH_RUNNER=dummy -DBOARD_DEBUG_RUNNER=dummy ..
CMake Deprecation Warning at /home/mbolivar/src/zephyr/cmake/app/boilerplate.cmake:38 (cmake_policy):
  The OLD behavior for policy CMP0000 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:2 (include)


-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.3", minimum required is "3.4") 
-- Selected BOARD nrf52_pca10040
Zephyr version: 1.11.99
[snip]
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mbolivar/src/zephyr/samples/hello_world/build


plop: ~/src/zephyr/samples/hello_world/build (set-runner) mbolivar
$ ninja
[1/118] Generating always_rebuild
Building for board nrf52_pca10040
[113/118] Linking C executable zephyr/zephyr_prebuilt.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       44732 B       512 KB      8.53%
            SRAM:       11388 B        64 KB     17.38%
        IDT_LIST:         132 B         2 KB      6.45%
[118/118] Linking C executable zephyr/zephyr.elf


plop: ~/src/zephyr/samples/hello_world/build (set-runner) mbolivar
$ ninja flash
[1/89] Generating always_rebuild
Building for board nrf52_pca10040
[1/2] Flashing nrf52_pca10040
command: flash


plop: ~/src/zephyr/samples/hello_world/build (set-runner) mbolivar
$ ninja debug
[1/89] Generating always_rebuild
Building for board nrf52_pca10040
[1/2] Debugging nrf52_pca10040
command: debug


plop: ~/src/zephyr/samples/hello_world/build (set-runner) mbolivar
$ ninja debugserver
[1/89] Generating always_rebuild
Building for board nrf52_pca10040
[1/2] Debugging nrf52_pca10040
command: debugserver


Thanks,
Marti


On Wed, May 2, 2018 at 11:39 AM, Armando Visconti <armando.visconti@...> wrote:
Hi,

I added the support for a new stm32-based board, called ArgonKey.

I would like to add the possibility to flash my board using stm32flash
tool using 'make flash', but I noticed that there is no common support
for it. There are many tools already supported, like dfu-util and
jlink.

I'm currently studying the related infrastructure based on a series of
phyton scrips like zephyr_flash_debug.py.

As I'm quite new on zephyr can someone possibly point me to some
documentation on this part?

Thx,
Armando





Marti Bolivar
 

Note also that the documentation for the class you will need to implement is here:


On Wed, May 2, 2018 at 11:43 AM, Marti Bolivar <marti@...> wrote:
Hi Armando,

I had written a post about this to the list, but it seems like it is no longer part of the archives since we moved to groups.io (which is unfortunate, I assumed that archives would be preserved).

I reproduce it here for your reference, hope it helps:

You can specify a flash and debug runner without touching any board files by setting BOARD_FLASH_RUNNER and/or BOARD_DEBUG_RUNNER in the CMake command line when generating a build system.

Here is an example branch, in which I have created a "dummy" runner:


Here is the commit which adds the extra runner, which just prints the command instead of acting on hardware:


Here is an example shell session where the flash and debug runners are set at CMake time and then used later using "ninja flash", "ninja debug", and "ninja debugserver". I have used the nrf52_pca10040 board, but it should work with any board.

plop: ~/src/zephyr/samples/hello_world/build (set-runner) mbolivar
$ cmake -GNinja -DBOARD=nrf52_pca10040 -DBOARD_FLASH_RUNNER=dummy -DBOARD_DEBUG_RUNNER=dummy ..
CMake Deprecation Warning at /home/mbolivar/src/zephyr/cmake/app/boilerplate.cmake:38 (cmake_policy):
  The OLD behavior for policy CMP0000 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:2 (include)


-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.3", minimum required is "3.4") 
-- Selected BOARD nrf52_pca10040
Zephyr version: 1.11.99
[snip]
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mbolivar/src/zephyr/samples/hello_world/build


plop: ~/src/zephyr/samples/hello_world/build (set-runner) mbolivar
$ ninja
[1/118] Generating always_rebuild
Building for board nrf52_pca10040
[113/118] Linking C executable zephyr/zephyr_prebuilt.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       44732 B       512 KB      8.53%
            SRAM:       11388 B        64 KB     17.38%
        IDT_LIST:         132 B         2 KB      6.45%
[118/118] Linking C executable zephyr/zephyr.elf


plop: ~/src/zephyr/samples/hello_world/build (set-runner) mbolivar
$ ninja flash
[1/89] Generating always_rebuild
Building for board nrf52_pca10040
[1/2] Flashing nrf52_pca10040
command: flash


plop: ~/src/zephyr/samples/hello_world/build (set-runner) mbolivar
$ ninja debug
[1/89] Generating always_rebuild
Building for board nrf52_pca10040
[1/2] Debugging nrf52_pca10040
command: debug


plop: ~/src/zephyr/samples/hello_world/build (set-runner) mbolivar
$ ninja debugserver
[1/89] Generating always_rebuild
Building for board nrf52_pca10040
[1/2] Debugging nrf52_pca10040
command: debugserver


Thanks,
Marti


On Wed, May 2, 2018 at 11:39 AM, Armando Visconti <armando.visconti@...> wrote:
Hi,

I added the support for a new stm32-based board, called ArgonKey.

I would like to add the possibility to flash my board using stm32flash
tool using 'make flash', but I noticed that there is no common support
for it. There are many tools already supported, like dfu-util and
jlink.

I'm currently studying the related infrastructure based on a series of
phyton scrips like zephyr_flash_debug.py.

As I'm quite new on zephyr can someone possibly point me to some
documentation on this part?

Thx,
Armando






Armando Visconti
 

Hi Marti,

On 05/02/2018 05:43 PM, Marti Bolivar wrote:
Hi Armando,
I had written a post about this to the list, but it seems like it is no longer part of the archives since we moved to groups.io <http://groups.io> (which is unfortunate, I assumed that archives would be preserved).
I reproduce it here for your reference, hope it helps:
Thx very much,

I'll go thru it tomorrow!

Rgds,
Arm