[riot-notifications] [RIOT-OS/RIOT] cpu/kinetis: allow flashing without toolchain (#11545)

Gaƫtan Harter notifications at github.com
Mon May 20 12:52:50 CEST 2019


### Contribution description

This pull request allows to flash the kinetis boards without relying on a local target specific toolchain. A native one is still required for objdump.

This allows only having the toolchain in docker.

### Testing procedure

Flashing any `kinetis` board that uses `wdog-disable.bin` to test the whole pull request. Like `pba-d-01-kw2x` or `mulle` flashing a kinetis board using `USE_OLD_OPENOCD=1`. 

With this pull request it can flash without any `arm` toolchain (only `objdump` necessary)

<details><summary><code>PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" DOCKER="sudo docker" BUILD_IN_DOCKER=1 RIOT_CI_BUILD=1  BOARD=pba-d-01-kw2x make -C examples/default/ flash</code></summary><p>

```
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" DOCKER="sudo docker" BUILD_IN_DOCKER=1 RIOT_CI_BUILD=1  BOARD=pba-d-01-kw2x make -C examples/default/ flash
make: Entering directory '/home/harter/work/git/worktree/riot_master/examples/default'
Launching build container using image "riot/riotbuild:latest".
sudo docker run --rm -t -u "$(id -u)" \
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/worktree/riot_master:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'    -v /home/harter/work/git/RIOT/.git:/home/harter/work/git/RIOT/.git \
    -e 'BOARD=pba-d-01-kw2x' -e 'RIOT_CI_BUILD=1' \
    -w '/data/riotbuild/riotbase/examples/default/' \
    'riot/riotbuild:latest' make
Building application "default" for "pba-d-01-kw2x" with MCU "kinetis".

   text    data     bss     dec     hex filename
  64116     604    6960   71680   11800 /data/riotbuild/riotbase/examples/default/bin/pba-d-01-kw2x/default.elf
/home/harter/work/git/worktree/riot_master/dist/tools/openocd/openocd.sh flash /home/harter/work/git/worktree/riot_master/examples/default/bin/pba-d-01-kw2x/default.elf
### Flashing Target ###
/home/harter/work/git/worktree/riot_master/examples/default/bin/pba-d-01-kw2x/default.elf is fine.
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : add flash_bank kinetis kx.flash
adapter speed: 1000 kHz
none separate
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : kx.cpu: hardware has 6 breakpoints, 4 watchpoints
    TargetName         Type       Endian TapName            State
--  ------------------ ---------- ------ ------------------ ------------
 0* kx.cpu             cortex_m   little kx.cpu             running
Info : MDM: Chip is unsecured. Continuing.
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000774 msp: 0x1fffc200
auto erase enabled
Info : Probing flash info for bank 0
Warn : Flash Configuration Field written.
Warn : Reset or power off the device to make settings effective.
wrote 65536 bytes from file /home/harter/work/git/worktree/riot_master/examples/default/bin/pba-d-01-kw2x/default.elf in 3.691923s (17.335 KiB/s)
34 bytes written at address 0x20000000
downloaded 34 bytes in 0.004008s (8.284 KiB/s)
target halted due to breakpoint, current mode: Thread
xPSR: 0x01000000 pc: 0x20000020 msp: 0x1fffc200
verified 64720 bytes in 0.845870s (74.720 KiB/s)
Info : MDM: Chip is unsecured. Continuing.
shutdown command invoked
Done flashing
make: Leaving directory '/home/harter/work/git/worktree/riot_master/examples/default'
```

</p></details>

In master it fails already when compiling the watchdog.

<details><summary><code>Makefile:5: recipe for target 'wdog-disable.o' failed</code></summary><p>

```
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" DOCKER="sudo docker" BUILD_IN_DOCKER=1 RIOT_CI_BUILD=1  BOARD=pba-d-01-kw2x make -C examples/default/ flash
make: Entering directory '/home/harter/work/git/worktree/riot_master/examples/default'
Launching build container using image "riot/riotbuild:latest".
sudo docker run --rm -t -u "$(id -u)" \
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/worktree/riot_master:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'    -v /home/harter/work/git/RIOT/.git:/home/harter/work/git/RIOT/.git \
    -e 'BOARD=pba-d-01-kw2x' -e 'RIOT_CI_BUILD=1' \
    -w '/data/riotbuild/riotbase/examples/default/' \
    'riot/riotbuild:latest' make
Building application "default" for "pba-d-01-kw2x" with MCU "kinetis".

   text    data     bss     dec     hex filename
  64116     604    6960   71680   11800 /data/riotbuild/riotbase/examples/default/bin/pba-d-01-kw2x/default.elf
arm-none-eabi-as -mthumb -o wdog-disable.o wdog-disable.s
make[1]: arm-none-eabi-as: Command not found
Makefile:5: recipe for target 'wdog-disable.o' failed
make[1]: *** [wdog-disable.o] Error 127
/home/harter/work/git/worktree/riot_master/cpu/kinetis/Makefile.include:52: recipe for target '/home/harter/work/git/worktree/riot_master/cpu/kinetis/dist/wdog-disable.bin' failed
make: *** [/home/harter/work/git/worktree/riot_master/cpu/kinetis/dist/wdog-disable.bin] Error 2
make: Leaving directory '/home/harter/work/git/worktree/riot_master/examples/default'
```

</p></details>

With the first commit only, it fails on `check-fcield`.

<details><summary><code>cpu/kinetis/dist/check-fcfield-elf.sh: arm-none-eabi-objdump: not found<br/>Abort flash procedure!<br/>pre-flash checks failed, status=1</code></summary><p>

```
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" DOCKER="sudo docker" BUILD_IN_DOCKER=1 RIOT_CI_BUILD=1  BOARD=pba-d-01-kw2x make -C examples/default/ flash                                                                                                       
make: Entering directory '/home/harter/work/git/worktree/riot_master/examples/default'                                                                                                                                                                                                    
Launching build container using image "riot/riotbuild:latest".                                                                                                                                                                                                                            
sudo docker run --rm -t -u "$(id -u)" \                                                                                                                                                                                                                                                   
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/worktree/riot_master:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/d
ata/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'    -v /home/harter/work/git/RIOT/.git:/home/harter/work/git/RIOT/.git \                                                 
    -e 'BOARD=pba-d-01-kw2x' -e 'RIOT_CI_BUILD=1' \                                                                                                                                                                                                                                       
    -w '/data/riotbuild/riotbase/examples/default/' \                                                                                                                                                                                                                                     
    'riot/riotbuild:latest' make                                                                                                                                                                                                                                                          
[sudo] password for harter:                                                                                                                                                                                                                                                               
Building application "default" for "pba-d-01-kw2x" with MCU "kinetis".                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                          
   text    data     bss     dec     hex filename                                                                                                                                                                                                                                          
  64116     604    6960   71680   11800 /data/riotbuild/riotbase/examples/default/bin/pba-d-01-kw2x/default.elf                                                                                                                                                                           
/home/harter/work/git/worktree/riot_master/dist/tools/openocd/openocd.sh flash /home/harter/work/git/worktree/riot_master/examples/default/bin/pba-d-01-kw2x/default.elf                                                                                                                  
### Flashing Target ###                                                                                                                                                                                                                                                                   
/home/harter/work/git/worktree/riot_master/cpu/kinetis/dist/check-fcfield-elf.sh: 12: /home/harter/work/git/worktree/riot_master/cpu/kinetis/dist/check-fcfield-elf.sh: arm-none-eabi-objdump: not found                                                                                  
Danger of bricking the device during flash!                                                                                                                                                                                                                                               
Flash configuration field of /home/harter/work/git/worktree/riot_master/examples/default/bin/pba-d-01-kw2x/default.elf:                                                                                                                                                                   
/home/harter/work/git/worktree/riot_master/cpu/kinetis/dist/check-fcfield-elf.sh: 19: /home/harter/work/git/worktree/riot_master/cpu/kinetis/dist/check-fcfield-elf.sh: arm-none-eabi-objdump: not found                                                                                  
Abort flash procedure!                                                                                                                                                                                                                                                                    
pre-flash checks failed, status=1                                                                                                                                                                                                                                                         
/home/harter/work/git/worktree/riot_master/examples/default/../../Makefile.include:538: recipe for target 'flash' failed                                                                                                                                                                  
make: *** [flash] Error 1                                                                                                                                                                                                                                                                 
make: Leaving directory '/home/harter/work/git/worktree/riot_master/examples/default'                                       
```

</p></summary>


### Issues/PRs references

This is part of compiling and flashing boards with only docker toolchain https://github.com/RIOT-OS/RIOT/pull/10870
TODO Separate PR for `objdump`
You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/11545

-- Commit Summary --

  * cpu/kinetis/check-fcfield: use OBJDUMP
  * makefiles/toolchain: fallback to 'objdump'
  * kinetis: save 'wdog-disable.bin' binary in the repository

-- File Changes --

    M boards/common/frdm/Makefile.include (3)
    M boards/mulle/Makefile.include (2)
    M boards/pba-d-01-kw2x/Makefile.include (2)
    M cpu/kinetis/Makefile.include (4)
    M cpu/kinetis/dist/README.md (7)
    M cpu/kinetis/dist/check-fcfield-elf.sh (4)
    M cpu/kinetis/dist/check-fcfield-hex.sh (4)
    A cpu/kinetis/dist/wdog-disable.bin (0)
    M makefiles/toolchain/gnu.inc.mk (2)
    M makefiles/toolchain/llvm.inc.mk (2)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/11545.patch
https://github.com/RIOT-OS/RIOT/pull/11545.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11545
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190520/b7e07511/attachment-0001.html>


More information about the notifications mailing list