Nordic nRF51822 Semihosting, BKPT at start problem

Sysprogs forums Forums VisualGDB Nordic nRF51822 Semihosting, BKPT at start problem

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8926
    Mikael.K
    Participant

    Hi.

    I have been trying to figure out why I the example program for the nRF51822 UART work while the debugger is connected and the semihost dialogue pops up and I click Yes.

    And why it will not work if I disconnect the debugger (SWD and Jlink lite) after reset or powerloss.

    So I started digging for answers, and What i found is that there is a breakpoint in the startcode, It do not matter if I select release or debug, or if Semihost is disabled in the “Embedded Frameworks” options.

    And there is no —specs=<span class=”skimlinks-unlinked”>rdimon.specs in the LDFLAGS, and I can not find it anywhere else. </span>

     

    When I only use Jlink.exe trough command prompt to check where the MCU is after powerloos/reset
    It shows that is stopped at a BKPT in the beginning.

     

    I use VisualGDB 5.1 build 712
    And everything is done trough VisualGDB interface, no external lib or fix.

     

    I have the same problem as this guy, but the solution only gave me an error.
    https://devzone.nordicsemi.com/question/75701/disable-output-to-arm-semihosting-console/

    I found this
    Why I am not a fan of ARM’s Semihosting feature

     

    Disassembly (Release)
    int
    _isatty (int fd)
    {
    0x0001ba00 push {r4, r5, lr}
    0x0001ba02 sub sp, #12
    #ifdef ARM_RDI_MONITOR
    int fh = remap_handle (fd);
    0x0001ba04 bl 0x1b4fc <remap_handle>
    0x0001ba08 movs r4, #9
    0x0001ba0a str r0, [sp, #4]
    0x0001ba0c add r5, sp, #4
    0x0001ba0e adds r0, r4, #0
    0x0001ba10 adds r1, r5, #0
    0x0001ba12 bkpt 0x00ab                           <— Stops here
    0x0001ba14 adds r4, r0, #0
    if (result == -1)
    0x0001ba16 movs r0, r4
    0x0001ba18 adds r3, r4, #1
    0x0001ba1a beq.n 0x1ba20 <_isatty+32>
    return wrap (do_AngelSWI (AngelSWI_Reason_IsTTY, &fh));

    I have tried to find any info about the ARM_RDI_MONITOR define but without any luck.

     

    debug.mak

    BINARYDIR := Debug

    #Additional flags
    PREPROCESSOR_MACROS := DEBUG=1
    INCLUDE_DIRS :=
    LIBRARY_DIRS :=
    LIBRARY_NAMES :=
    ADDITIONAL_LINKER_INPUTS :=
    MACOS_FRAMEWORKS :=
    LINUX_PACKAGES :=

    CFLAGS := -ggdb -ffunction-sections -O0
    CXXFLAGS := -ggdb -ffunction-sections -fno-exceptions -fno-rtti -O0
    ASFLAGS :=
    LDFLAGS := -Wl,-gc-sections
    COMMONFLAGS :=
    LINKER_SCRIPT := C:\Users\mikael.kallberg.EXEGER\AppData\Local\VisualGDB\EmbeddedBSPs\arm-eabi\com.sysprogs.arm.nordic.nrf5x/nRF5x/LinkerScripts/nRF51822_XXAC_S130.lds

    START_GROUP := -Wl,–start-group
    END_GROUP := -Wl,–end-group

    #Additional options detected from testing the toolchain
    USE_DEL_TO_CLEAN := 1
    CP_NOT_AVAILABLE := 1

    ADDITIONAL_MAKE_FILES := nrf5x.mak
    GENERATE_BIN_FILE := 1
    GENERATE_IHEX_FILE := 1
    GENERATE_MAP_FILE := 0

    • This topic was modified 7 years, 8 months ago by Mikael.K.
    #8929
    support
    Keymaster

    Hi,

    The fast semihosting framework is designed to be used under debugger, but if your program does not call printf() or similar functions, it should not trigger. If you want to build a release executable that will discard the printf() output instead of trying to communicate to the debugger, please follow the steps below:

    1. In VisualGDB Project Properties -> Embedded Frameworks please uncheck the “Redirect printf() to fast semihosting” flag
    2. On the Makefile settings page for the Debug configuration add ‘FAST_SEMIHOSTING_STDIO_DRIVER’ to the list of preprocessor macros to enable this feature for Debug configuration only
    3. In your code provide the default implementations for _isatty() and _write() that will just return the correct values and not send anything.

    This should eliminate any references to the semihosting functionality in the release build and make it run with no debugger attached.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.