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

openocd: return error if flashing went wrong #2897

Merged
merged 1 commit into from
Jul 27, 2016

Conversation

kaspar030
Copy link
Contributor

without this change, flashing with openocd always seems to succeed, even if it didn't.

@kaspar030 kaspar030 added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: build system Area: Build system labels Apr 30, 2015
@OlegHahm
Copy link
Member

OlegHahm commented May 2, 2015

IIRC the shutdown command will cause OpenOCD to always return an error value in newer versions.
See #2471 and #2472.

@kaspar030
Copy link
Contributor Author

I'm using "Open On-Chip Debugger 0.9.0-dev-00401-gf3b1405 (2015-04-15-12:26)", that's a fairly recent git compile.

Without this patch:

[kaspar@localhost pthread]$ BOARD=iot-lab_M3 make flash
Building application "pthread" for "iot-lab_M3" with MCU "stm32f1".
"make" -C /home/kaspar/src/riot.5/boards/iot-lab_M3
"make" -C /home/kaspar/src/riot.5/core
"make" -C /home/kaspar/src/riot.5/cpu/stm32f1
"make" -C /home/kaspar/src/riot.5/cpu/cortex-m3_common
"make" -C /home/kaspar/src/riot.5/cpu/stm32f1/periph
"make" -C /home/kaspar/src/riot.5/drivers
"make" -C /home/kaspar/src/riot.5/sys
"make" -C /home/kaspar/src/riot.5/sys/posix
"make" -C /home/kaspar/src/riot.5/sys/posix/pthread
"make" -C /home/kaspar/src/riot.5/sys/timex
"make" -C /home/kaspar/src/riot.5/sys/vtimer
   text    data     bss     dec     hex filename
  14688     112    4460   19260    4b3c /home/kaspar/src/riot.5/tests/pthread/bin/iot-lab_M3/pthread.elf
/home/kaspar/src/riot.5/dist/tools/openocd/openocd.sh flash
### Flashing Target ###
Open On-Chip Debugger 0.9.0-dev-00401-gf3b1405 (2015-04-15-12:26)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select '.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description '*' and serial '*'
Done flashing
[kaspar@localhost pthread]$

Flashing always returns error 0.

With this patch:

[kaspar@localhost pthread]$ BOARD=iot-lab_M3 make flash
Building application "pthread" for "iot-lab_M3" with MCU "stm32f1".
"make" -C /home/kaspar/src/riot.5/boards/iot-lab_M3
"make" -C /home/kaspar/src/riot.5/core
"make" -C /home/kaspar/src/riot.5/cpu/stm32f1
"make" -C /home/kaspar/src/riot.5/cpu/cortex-m3_common
"make" -C /home/kaspar/src/riot.5/cpu/stm32f1/periph
"make" -C /home/kaspar/src/riot.5/drivers
"make" -C /home/kaspar/src/riot.5/sys
"make" -C /home/kaspar/src/riot.5/sys/posix
"make" -C /home/kaspar/src/riot.5/sys/posix/pthread
"make" -C /home/kaspar/src/riot.5/sys/timex
"make" -C /home/kaspar/src/riot.5/sys/vtimer
   text    data     bss     dec     hex filename
  14688     112    4460   19260    4b3c /home/kaspar/src/riot.5/tests/pthread/bin/iot-lab_M3/pthread.elf
/home/kaspar/src/riot.5/dist/tools/openocd/openocd.sh flash
### Flashing Target ###
Open On-Chip Debugger 0.9.0-dev-00401-gf3b1405 (2015-04-15-12:26)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select '.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description '*' and serial '*'
/home/kaspar/src/riot.5/tests/pthread/../../Makefile.include:233: recipe for target 'flash' failed
make: *** [flash] Error 1
[kaspar@localhost pthread]$ BOARD=iot-lab_M3 make flash
Building application "pthread" for "iot-lab_M3" with MCU "stm32f1".
"make" -C /home/kaspar/src/riot.5/boards/iot-lab_M3
"make" -C /home/kaspar/src/riot.5/core
"make" -C /home/kaspar/src/riot.5/cpu/stm32f1
"make" -C /home/kaspar/src/riot.5/cpu/cortex-m3_common
"make" -C /home/kaspar/src/riot.5/cpu/stm32f1/periph
"make" -C /home/kaspar/src/riot.5/drivers
"make" -C /home/kaspar/src/riot.5/sys
"make" -C /home/kaspar/src/riot.5/sys/posix
"make" -C /home/kaspar/src/riot.5/sys/posix/pthread
"make" -C /home/kaspar/src/riot.5/sys/timex
"make" -C /home/kaspar/src/riot.5/sys/vtimer
   text    data     bss     dec     hex filename
  14688     112    4460   19260    4b3c /home/kaspar/src/riot.5/tests/pthread/bin/iot-lab_M3/pthread.elf
/home/kaspar/src/riot.5/dist/tools/openocd/openocd.sh flash
### Flashing Target ###
Open On-Chip Debugger 0.9.0-dev-00401-gf3b1405 (2015-04-15-12:26)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select '.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Info : clock speed 1000 kHz
Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
Info : JTAG tap: stm32f1x.bs tap/device found: 0x06414041 (mfg: 0x020, part: 0x6414, ver: 0x0)
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32f1x.cpu       cortex_m   little stm32f1x.cpu       running
Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
Info : JTAG tap: stm32f1x.bs tap/device found: 0x06414041 (mfg: 0x020, part: 0x6414, ver: 0x0)
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080002a4 msp: 0x200036b4
Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
Info : JTAG tap: stm32f1x.bs tap/device found: 0x06414041 (mfg: 0x020, part: 0x6414, ver: 0x0)
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080002a4 msp: 0x200036b4
** Programming Started **
auto erase enabled
Info : device id = 0x10016414
Info : flash size = 512kbytes
wrote 16384 bytes from file /home/kaspar/src/riot.5/tests/pthread/bin/iot-lab_M3/pthread.hex in 0.732912s (21.831 KiB/s)
** Programming Finished **
** Verify Started **
verified 14800 bytes in 0.242978s (59.483 KiB/s)
** Verified OK **
Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
Info : JTAG tap: stm32f1x.bs tap/device found: 0x06414041 (mfg: 0x020, part: 0x6414, ver: 0x0)
shutdown command invoked
Done flashing
[kaspar@localhost pthread]$

@kaspar030
Copy link
Contributor Author

Seems they fixed openocd's behaviour in March:

commit 19f219f731f29503c8e4d432935d3ea558cc1659
Author: Paul Fertser 
Date:   Fri Mar 13 16:32:53 2015 +0300
    Tcl exception codes cleanup, shutdown command amendments
    
    This patch might influence openocd Tcl commands behaviour in subtle
    ways, please give it a nice testing.
    
    The idea is that if an OpenOCD Tcl command returns an error, an
    exception is raised, and then the return code is propogated all the
    way up (or to the "catch" if present). This allows to detect
    "shutdown" which is not actually an error but has to raise an
    exception to stop execution of the commands that follow it in the
    script.
    
    openocd_thread special-cases shutdown because it should then terminate
    OpenOCD with a success error code, unless shutdown was called with an
    optional "error" argument which means terminate with a non-zero exit
    code.
    
    Change-Id: I7b6fa8a2e24c947dc45d8def0008b4b007c478b3
    Signed-off-by: Paul Fertser 
    Reviewed-on: http://openocd.zylin.com/2600
    Tested-by: jenkins
    Reviewed-by: Juha Niskanen 
    Reviewed-by: Jens Bauer 
    Reviewed-by: Oleksij Rempel 

@kaspar030 kaspar030 added the Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer label May 8, 2015
@OlegHahm
Copy link
Member

OlegHahm commented May 8, 2015

I think the problem remains. #2471 would fix this misbehavior as well, but I think we can (unfortunately) not assume that most RIOT developers will have a bleeding edge distribution like Arch, but more conservative stuff like Ubuntu LTS.

@LudwigKnuepfer
Copy link
Member

We can still encourage them to build their own recent version or live with a failing flash target.

@kaspar030
Copy link
Contributor Author

or check for a recent openocd version...

@OlegHahm
Copy link
Member

OlegHahm commented May 8, 2015

Or use a reasonable distribution. However, this will lead to some confusion on the "support channels".

@LudwigKnuepfer
Copy link
Member

@OlegHahm You mean to say that confused people will show up in the support channels?

@LudwigKnuepfer
Copy link
Member

Checking for the version sounds good to me.

@OlegHahm OlegHahm modified the milestone: Release 2015.06 May 28, 2015
@kaspar030 kaspar030 modified the milestones: Release NEXT MAJOR, Release 2015.09 Sep 2, 2015
@miri64
Copy link
Member

miri64 commented Nov 27, 2015

Needs rebase

@kaspar030 kaspar030 force-pushed the fix_openocd_flash_return_code branch from a61aad2 to 246b2b0 Compare December 7, 2015 10:56
@kaspar030
Copy link
Contributor Author

  • rebased. I'm un-tagging for release, though, as the same argument (will cause confusion on ubuntu LTS) is still valid.

@kaspar030 kaspar030 removed this from the Release 2015.12 milestone Dec 7, 2015
@kYc0o
Copy link
Contributor

kYc0o commented Jan 25, 2016

is this PR ready for the next release? just let me know if it needs to be ACK

@OlegHahm
Copy link
Member

Let's wait for next Ubuntu LTS this April.

@miri64 miri64 modified the milestone: Release 2016.07 Mar 29, 2016
@miri64
Copy link
Member

miri64 commented Jun 3, 2016

New version of Ubuntu was released.

@OlegHahm
Copy link
Member

OlegHahm commented Jun 3, 2016

Including a new version of OpenOCD?

@miri64
Copy link
Member

miri64 commented Jun 3, 2016

Depends on what you call "new":

$ apt-cache show openocd
Package: openocd
Priority: extra
Section: universe/embedded
Installed-Size: 5324
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Uwe Hermann <uwe@debian.org>
Architecture: amd64
Version: 0.9.0-1build1
Depends: libc6 (>= 2.15), libhidapi-hidraw0 (>= 0.8.0~rc1+git20140201.3a66d4e+dfsg), libjim0.76 (>= 0.73), libusb-0.1-4 (>= 2:0.1.12), libusb-1.0-0 (>= 2:1.0.9~)
Filename: pool/universe/o/openocd/openocd_0.9.0-1build1_amd64.deb
Size: 1915448
MD5sum: 8559d5af6b9750f4b568af40bdcf46e7
SHA1: 75d0a64dbd4798b7126c02680524e352443e6d72
SHA256: 2cc01156b6acaa2e92052765ae48d6e8148db7c9fc0705abeebdd7b82351108f
Description-en: Open on-chip JTAG debug solution for ARM and MIPS systems
 OpenOCD is an on-chip debugging, in-system programming and boundary-scan
 testing tool for ARM and MIPS systems.
 .
 The debugger uses an IEEE 1149-1 compliant JTAG TAP bus master to access
 on-chip debug functionality available on ARM based microcontrollers or
 system-on-chip solutions. For MIPS systems the EJTAG interface is supported.
 .
 User interaction is realized through a telnet command line interface,
 a gdb (the GNU debugger) remote protocol server, and a simplified RPC
 connection that can be used to interface with OpenOCD's Jim Tcl engine.
 .
 OpenOCD supports many different types of JTAG interfaces/programmers.
Description-md5: 3846dda8ec5ba34e07da3b1d9ee73c0a
Homepage: http://openocd.sourceforge.net/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu

@kaspar030
Copy link
Contributor Author

Back then I tested with v0.9-devel, so an older version than what Ubuntu ships now. Should we get this in?

@OlegHahm
Copy link
Member

Has anybody tried with the new Ubuntu version?

@OlegHahm
Copy link
Member

This PR would basically break on newer openocd version if I remember this correctly.

@kaspar030 kaspar030 force-pushed the fix_openocd_flash_return_code branch from 246b2b0 to a539b99 Compare July 13, 2016 15:29
@kaspar030
Copy link
Contributor Author

  • rebased, fixed another occurence

I'm using

[kaspar@booze src]$ openocd --version
Open On-Chip Debugger 0.9.0 (2016-04-27-23:18)

and this PR works as expected.

@OlegHahm
Copy link
Member

Difficult to verify without access to OpenOCD documentation, but seems to work. ACK

@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jul 13, 2016
@kYc0o kYc0o added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jul 16, 2016
@kYc0o
Copy link
Contributor

kYc0o commented Jul 16, 2016

Can you squash what you marked to be squashed? Murdock is complaining :(

@kYc0o
Copy link
Contributor

kYc0o commented Jul 22, 2016

@kaspar030 just squash, code looks good and it's already ACKed, let's merge it asap :D

@kYc0o
Copy link
Contributor

kYc0o commented Jul 27, 2016

Please squash this, it's easy :D

@kaspar030 kaspar030 force-pushed the fix_openocd_flash_return_code branch from a539b99 to 8601285 Compare July 27, 2016 15:42
@kaspar030
Copy link
Contributor Author

  • squashed, rebased

@kYc0o
Copy link
Contributor

kYc0o commented Jul 27, 2016

Danke schön! :D

@kYc0o
Copy link
Contributor

kYc0o commented Jul 27, 2016

Already ACKed, so GO!

@kYc0o kYc0o merged commit 6dfec48 into RIOT-OS:master Jul 27, 2016
@kaspar030 kaspar030 deleted the fix_openocd_flash_return_code branch February 7, 2017 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants