Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/kinetis: allow flashing without toolchain #11545

Merged
merged 2 commits into from
May 29, 2019

Conversation

cladmi
Copy link
Contributor

@cladmi cladmi commented May 20, 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)

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

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'

In master it fails already when compiling the watchdog.

Makefile:5: recipe for target 'wdog-disable.o' failed

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'

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

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

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'                                       

Issues/PRs references

This is part of compiling and flashing boards with only docker toolchain #10870

Separate pull request for objdump #11547

@cladmi cladmi added State: waiting for other PR State: The PR requires another PR to be merged first Area: tools Area: Supplementary tools Area: toolchain Area: toolchains; everything related to compilation, libc, linking, … labels May 20, 2019
@cladmi cladmi added this to the Release 2019.07 milestone May 20, 2019
@cladmi cladmi requested a review from smlng May 22, 2019 14:44
Copy link
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested ACK, with BOARD pba-d-01-kw2x (aka PhyNode/Wave) everything still works fine!

Also fixes the issue when using docker. Nice job 👍

@smlng smlng added Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines labels May 23, 2019
@smlng
Copy link
Member

smlng commented May 23, 2019

rebase after #11547 is merged

@cladmi
Copy link
Contributor Author

cladmi commented May 27, 2019

I noticed arm-none-eabi-objdump is still used in the error case in the fcfield scripts, I updated it. The same scripts are being modified for #11562, I will handle the conflicts in this PR so wait for the split concerning it.

@cladmi cladmi force-pushed the pr/kinetis/flash_no_arm_toolchain branch from f71328c to e8fa26e Compare May 28, 2019 10:10
@cladmi
Copy link
Contributor Author

cladmi commented May 28, 2019

Rebased now that #11589 is merged.
It will still need to be rebased after merging #11547

@cladmi cladmi force-pushed the pr/kinetis/flash_no_arm_toolchain branch from e8fa26e to d765103 Compare May 28, 2019 12:05
@jcarrano jcarrano removed the State: waiting for other PR State: The PR requires another PR to be merged first label May 28, 2019
Copy link
Contributor

@jcarrano jcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the first commit now that #11547 is merged. I'm blocking to prevent accidental merge.

cladmi added 2 commits May 28, 2019 14:36
Get OBJDUMP from the environment instead of hardwriting the value.

This is a prerequisite to allow using `objdump` when building from docker
when not having the `arm` toolchain installed.
Keep the compiled '.bin' file to remove the need to compile it when
flashing. This remove the need to have the toolchain when flashing so
allow compiling and flashing with `BUILD_IN_DOCKER=1` without a local
toolchain.

Even if it ends up storing a binary, the file is only 34 bytes.
@cladmi cladmi force-pushed the pr/kinetis/flash_no_arm_toolchain branch from d765103 to e40d569 Compare May 28, 2019 12:37
@cladmi
Copy link
Contributor Author

cladmi commented May 28, 2019

Rebased to master, and I fixed a typo in the commit message preriquisite->prerequisite

@cladmi cladmi added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 28, 2019
@smlng
Copy link
Member

smlng commented May 29, 2019

tested reACK for PhyNode board

@smlng
Copy link
Member

smlng commented May 29, 2019

@jcarrano are we good here?

@jcarrano jcarrano merged commit 245f04a into RIOT-OS:master May 29, 2019
@cladmi cladmi deleted the pr/kinetis/flash_no_arm_toolchain branch May 29, 2019 12:48
@cladmi
Copy link
Contributor Author

cladmi commented May 29, 2019

Thank you for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: toolchain Area: toolchains; everything related to compilation, libc, linking, … Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants