Uploaded image for project: 'Mynewt'
  1. Mynewt
  2. MYNEWT-527

newt - Run bsp scripts on Windows

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • v1_0_0_beta1
    • v1_0_0_rel
    • Newt
    • Security Level: Public (Viewable by anyone)
    • None
    • Windows 10, WSL, MSYS2

    Description

      Now that the `newt` tool no longer runs commands through a shell, it is not able to execute bsp scripts (`_download.sh` / `_debug.sh`) on Windows, where `CreateProcess` can't run shell scripts natively.

      A solution that works pretty well is to create parallel `_download.cmd` / `_debug.cmd` scripts with just the following:

      @rem Execute a shell with a script of the same name and .sh extension
      @sh "%~dp0%~n0.sh"
      

      And modify bsp.yml to use those instead, for example for `nrf51dk`:

      diff --git a/hw/bsp/nrf51dk/bsp.yml b/hw/bsp/nrf51dk/bsp.yml
      index 5e78d60..95b57f6 100644
      --- a/hw/bsp/nrf51dk/bsp.yml
      +++ b/hw/bsp/nrf51dk/bsp.yml
      @@ -26,8 +26,8 @@ bsp.linkerscript.BOOT_LOADER.OVERWRITE:
           - "hw/bsp/nrf51dk/boot-nrf51xxac.ld"
           - "hw/mcu/nordic/nrf51xxx/nrf51.ld"
       bsp.part2linkerscript: "hw/bsp/nrf51dk/split-nrf51dk.ld"
      -bsp.downloadscript: "hw/bsp/nrf51dk/nrf51dk_download.sh"
      -bsp.debugscript: "hw/bsp/nrf51dk/nrf51dk_debug.sh"
      +bsp.downloadscript: "hw/bsp/nrf51dk/nrf51dk_download.cmd"
      +bsp.debugscript: "hw/bsp/nrf51dk/nrf51dk_debug.cmd"
      
       bsp.flash_map:
           areas:
      diff --git a/hw/bsp/nrf51dk/nrf51dk_debug.cmd b/hw/bsp/nrf51dk/nrf51dk_debug.cmd
      new file mode 100644
      index 0000000..354743d
      --- /dev/null
      +++ b/hw/bsp/nrf51dk/nrf51dk_debug.cmd
      @@ -0,0 +1,2 @@
      +@rem Execute a shell with a script of the same name and .sh extension
      +@sh "%~dp0%~n0.sh"
      diff --git a/hw/bsp/nrf51dk/nrf51dk_download.cmd b/hw/bsp/nrf51dk/nrf51dk_download.cmd
      new file mode 100644
      index 0000000..354743d
      --- /dev/null
      +++ b/hw/bsp/nrf51dk/nrf51dk_download.cmd
      @@ -0,0 +1,2 @@
      +@rem Execute a shell with a script of the same name and .sh extension
      +@sh "%~dp0%~n0.sh"
      

      At the very least, adding these scripts to the repo will allow devs to use `newt load` and `newt debug` on Windows with minimal effort (in combination with https://github.com/apache/incubator-mynewt-newt/pull/29 and https://github.com/apache/incubator-mynewt-core/pull/150).

      How to best automate this is a question to the devs; perhaps platform overrides in `bsp.yml` to specify platform-specific scripts?

      Attachments

        Issue Links

          Activity

            People

              marko Marko Kiiskila
              simonratner Simon Ratner
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: