nRF51822 evaluation kit board Mac OS X problems

  • I am reposting this from the other thread since that one is marked SOLVED.

    I've had a lot of problems along these lines, and also a lot of great solutions.

    I basically went through 3 phases with my nRF51822 Evaluation Kit board (PCA10001).

    In phase 1, everything worked well, both with and without softdevice. I could use JLinkExe to download programs and I could use JLinkGDBServer with gdb to debug. This was with version 4.62, previous versions didn't work so well.

    In phase 2, I could use JLinkExe to download programs using the si 1 and selemu commands first (without them it didn't work). However, the GDB server didn't work. The output was:

    Code
    Connecting to J-Link...
    Connecting to J-Link failed. GDBServer will be closed...
    Restoring target state and closing J-Link connection...
    Connecting to J-Link...
    Connecting to J-Link failed. GDBServer will be closed...
    Restoring target state and closing J-Link connection...
    Shutting down...

    In phase 3, JLinkExe doesn't work even with si 1 and selemu. This is the output:

    So it can connect to the debugger, but not contact the device.

    Throughout these phases, I've always been able to use the "Recover" command in the latest version of nRFgo Studio.

    My questions are:

    1. Does anyone know a sequence of commands that does the same thing as Recover in nRFgo Studio?

    2. Do you have any suggestions for how to get JLinkGDBServer up and running? I was thinking that I could put some commands in a script to be launched with JLinkGDBServer, but I'm not sure what the non-interactive version of selemu is.

  • I'm having really good luck with this board now with one exception. I'm using V4.62a of the JLink software on MacOS 10.8.2.

    I'll summarize below my procedure, in the hope that it will help others. This was gathered from these really helpful posts about: splitting the soft device binary, modifying this procedure for version 3 of soft device, and launching JLinkGdbServer in SWD mode,

    Requires nRF51822 dongle from their $99 development kit, the download of the s100 "soft device" firmware using the download product key in the kit, and the JLink software. I'm using GCC 4.8.x to compile with a custom makefile and linker script derived from Paul Stoffregen's teensy 3 code.

    Here's basically what I did (don't include stuff after # marks):


    brew install libusb

    #extract the two parts of the soft device (the main code section and the user control register section)
    arm-none-eabi-objcopy -Iihex -Obinary --only-section .sec3 s110_nrf51822_4.0.0-2.beta_softdevice.hex s110_nrf51822_4.0.0-2.beta_softdevice_uicr.bin
    arm-none-eabi-objcopy -Iihex -Obinary --remove-section .sec3 s110_nrf51822_4.0.0-2.beta_softdevice.hex s110_nrf51822_4.0.0-2.beta_softdevice_mainpart.bin

    export DYLD_LIBRARY_PATH=.
    ./JLinkExe

    device nrf51822
    speed 1000
    r # reset the device
    w4 4001e504 2 # NVIC CONFIG EEN (erase enabled)
    w4 4001e50c 1 # NVIC ERASEALL (erase all flash including UICR)
    r
    w4 4001e504 1 # NVIC CONFIG WEN (enable writing)
    # load the soft device binary.
    loadbin s110_nrf51822_4.0.0-2.beta_softdevice_uicr.bin 0x10001000
    loadbin s110_nrf51822_4.0.0-2.beta_softdevice_mainpart.bin 0
    r
    q

    ./JLinkGDBServer -if SWD -device nRF51822 -speed 4000 & # runs in background

    gdb program.elf # this is your executable
    target remote localhost:2331
    set remote memory-write-packet-size 1024
    set remote memory-write-packet-size fixed
    load program.elf
    monitor reset #reset the chip
    c # continue -- runs the program
    ^C
    bt
    # etc.


    The main problem I'm having now is not being able to send/receive UART data from the nRF51822. I've posted about that here.

    Hope this helps,

    -c

  • I've consolidated all this into a Makefile that:

    • compiles c code using GCC;
    • links as appropriate for the "softdevice" setup;
    • erases the dongle and reprograms the "softdevice"; and
    • runs GDB and stops on a breakpoint.


    This seems pretty reproducible for me.
    The program itself doesn't do very much yet.

    http://hg.cmason.com/nrf

    See README there for details.
    Hope this helps,
    -c

  • Quote


    CDC functionality:
    It is a limitation in the Mac OS X (!!) USB CDC kernel driver. It requests exclusive access to the device, so libusb (used by the J-Link DLL/lib) is no longer able to get access to the J-Link, so debugging is not possible.
    This is why the USB CDC drivers of Mac need to be temporarily disabled. This is not a bug in the J-Link software.

    Not sure what exactly is the problem here right now.
    In general 2 things should be done do make sure that a connection to the nRF51 can be established:
    1) ALWAYS select the device, so J-Link knows which device it connects to. The nRF51 needs some special handling.
    2) Always make sure that SWD is selected as interface.

    For J-Link Commander we recommend to start it as follows:
    JLinkExe -if SWD -device nRF51822

    For GDBServer it should look identical:
    JLinkGDBServer -if SWD -device nRF51822

    By the way: Selecting the device is enough to make flash programming work. Commands like "monitor flash download 1" are deprecated and not necessary anymore.

    Did you try this?
    Do you still see any connection issues?

    If yes:
    What we are looking for is a very simple reproduction scenario which for example says:
    "Download this bin file into the target and J-Link will no longer connect to the CPU properly. Same works fine under Windows"


    Best regards
    Alex

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hi all,

    It turned out that it was an unfortunate combination of some specifics of the Apple Mac OS X driver and some "misbehavior" of the J-Link library.
    It has been fixed for V4.88 and later of the J-Link software, so now it is possible to use the CDC part in parallel with the J-Link part.

    Download-Link: http://www.segger.com/jlink-software.html


    - Alex

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!