ARMmbed / nrf51-sdk

Module to contain files provided by the nordic nRF51 SDK
Other
13 stars 17 forks source link

No binary compiled for NRF with mbed works. #27

Closed matoushybl closed 7 years ago

matoushybl commented 7 years ago

Hi, First of all I would like to apologize if this isn't the right place to seek help. I am trying to build a device using NRF51822, but I have no success even making the LED blink. I tried the binary produced by the online compiler, then I compiled it locally using Makefile and using platformio. My steps using Makefile were:

make
make merge

then I uploaded it to the chip using ST-link v2 and OpenOCD like this:

openocd -s /usr/local/Cellar/open-ocd/0.8.0/share/openocd/scripts/ -f interface/stlink-v2.cfg -f target/nrf51_stlink.tcl

telnet:

halt
flash write_image erase combined.hex 0
reset

and I also tried to replace flash write_image with program but again with no success.

The board I am using is this: http://www.aliexpress.com/item/NRF51822-2-4G-Wireless-Module-Wireless-Communication-Module-Raspberr/32339657249.html?spm=2114.01010208.3.19.TmnwwV&ws_ab_test=searchweb201556_7,searchweb201602_2_10057_10056_10037_10055_10054_301_10059_10033_10058_10032_10017_107_10060_10061_10052_414_10062_10053_413_10050_10051,searchweb201603_2&btsid=04476ee0-66bd-4321-983d-5e93db1cdd99

I tried using mbed configuration for both the DK and the mKit.

Source code:

#include "mbed.h"

DigitalOut led(P0_10);

int main() {
  while(1) {
        led = 1;
        wait(0.250);
        led = 0;
        wait(0.750);
    }
}

Could you please help me with it? I am a bit lost since this could be caused by many things including mbed itself, the toolchain (gcc), OpenOCD, the board and programmer.

Thanks

pan- commented 7 years ago

@matoushybl

You can ask such questions on the mbed forum. The board you use is not supported by mbed, it is normal that you have trouble with it. You can workaround this if you got the datasheet some knowledge around embedded programming.

matoushybl commented 7 years ago

@pan But the chip should be the same, or not?

nvlsianpu commented 7 years ago

Hi. It is the same chip as on NRF51_DK (nRF51822).

matoushybl commented 7 years ago

Yes, I thought so, but what is then the problem? Why would it work on DK but on other boards if I am using pins that are accessible from both? Of course there is a chance of faulty chip but I would like to check other options first. Any ideas about what I should try?

nvlsianpu commented 7 years ago

e.g. a mbed target use some default pins as stdio serial output, differences in oscillator circuit... Do you have programmed softdevice s110 before you download your application to the chip?

matoushybl commented 7 years ago

I tried both merging the softdevice with application hex and programming first the softdevice and then the application code. I have a question, how come the softdevice doesn't get overwritten by the application code?

nvlsianpu commented 7 years ago

It's depend from programming algorithm used. As you used command line you can check in documentation whether programming the app didn't caused chip erase. If you use merging - it's not a case.

matoushybl commented 7 years ago

Can you please point me to a proper way to program the chip? Just to eliminate the possibility that the problem is with openOCD or the process of flashing with it? Also I am using the softdevice provided with mbed s130_nrf51_2.0.0_softdevice.hex is it the correct one?

nvlsianpu commented 7 years ago

So you use mbed 5 I gues? You can build app using > mbed compile -m NRF51_DK -t GCC_ARM (https://docs.mbed.com/docs/mbed-os-handbook/en/5.1/dev_tools/cli/) or using on-line compiler and then program the board - if this wouldn't help - probably the board is really somehow not compatible.

In this case you can use nRF5 SDK from Nordic in order to run an led-blinki example on your board to verifi whether it work.

matoushybl commented 7 years ago

I was not using the OS, just the regular mbed. However I tried to build it and after flashing it didn't work. Is it still needed to flash softdevice when using the OS? Is it possible that the chip is faulty even if the programmer always completes?

matoushybl commented 7 years ago

If I run ./st-util from texane it shows

2016-08-23T17:07:47 INFO src/stlink-common.c: Loading device parameters....
2016-08-23T17:07:47 WARN src/stlink-common.c: unknown chip id! 0
pan- commented 7 years ago

@matoushybl If you merged the softdevice (make merge) with your application their is no need to flash it separately.

matoushybl commented 7 years ago

I did it with the regular mbed project but not with the OS one, should I try it?

matoushybl commented 7 years ago

I tried communicating with the module via another st-link and the result of st-util was the same, so for now I am going to close this as a chip problem, but I'll try again with a new one and if it still does not work, I'll reopen. Thanks for your effort.