Git Product home page Git Product logo

arduino-nrf5's Introduction

๐Ÿ‘‹๐Ÿฝ Hi there, I'm Sandeep ๐Ÿ‘จ๐Ÿฝโ€๐Ÿ’ป

๐Ÿ‘จ๐Ÿฝโ€๐Ÿ”ฌ Personal Projects

Current

  • Arduino Libraries: ๐Ÿ“ก LoRa | โš™๏ธ nRF5 | ๐Ÿฅซ CAN | ๐Ÿš˜ OBD2 |

Past

๐Ÿ‘จ๐Ÿฝโ€๐Ÿ”ง Past work for @arduino

arduino-nrf5's People

Contributors

austin1611 avatar beetix avatar bojh avatar carlosperate avatar d00616 avatar dlabun avatar dsanders11 avatar endlessdelirium avatar fabianhugo avatar honnet avatar jacobrosenthal avatar jhmaloney avatar mdahlstrom avatar micooke avatar morganrallen avatar nihaopaul avatar nobodyguy avatar ntavish avatar orrmany avatar outlandnish avatar owenbrotherwood avatar oyooyo avatar per1234 avatar probonopd avatar rogerclarkmelbourne avatar sandeepmistry avatar scepticint avatar suschman avatar tlonch avatar urish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-nrf5's Issues

Warnings for library classes: Wire and SPI

Compiling an sketch does create following warnings:

WARNING: library SPI claims to run on [nRF5] architecture(s) and may be incompatible with your current board which runs on [nRF] architecture(s).
WARNING: library Wire claims to run on [nRF5] architecture(s) and may be incompatible with your current board which runs on [nRF] architecture(s).

There must be a mismatch in between a architcture naming nRF and the nRF5.

Generic nRF51822 doesnt work with S130 or S110 softdevices

I'm using the http://www.waveshare.com/product/modules/wireless/bluetooth/nrf51822-eval-kit.htm and have made a new variant, but this problem applies equally to the Generic nRF51822 variant

If I compile the blink all sketch, to flash all pins, and compile without a soft device, it works fine.

However, if I install the S130 softdevice s130_nrf51_2.0.1_softdevice.hex and select S130 from the menu, the sketch fails to toggle any pins :-(

I've tried an old version of the S130 soft device s130_softdevice_v9.0.hex (https://developer.nordicsemi.com/nRF5_SDK/nRF51_SDK_v9.x.x/doc/9.0.0/) but this doesnt work either.

I also tried s110_nrf51_8.0.0_softdevice.hex but that didn't work

Note. The Jlink interface from the IDE isnt working, so I retrieved the files downloaded by the "nRF5 flash softdevice" command and flashed manually using jFlash. But the files are being flashed to the correct location i.e 0x0000 and seem to be the correct size.

Bluetooth Mesh

Will this core development roadmap include the Bluetooth Mesh at some point? Currently, there is Nordic Open Mesh for N51/N52. Will this be more immediate one?

Servo Library Doesn't Work?

Hi Everyone,

Before I start, I just want to thank Sandeep and everyone who contribute to this library, it is incredible work :)

I am trying to get servo to work on the nrf52 board. I notice on the bottom of this github page it says we are using the core based on the Arduino SAMD Core. However, when I run the Servo Sweep Example. It Gives me the following message.

WARNING: library Servo claims to run on [avr architecture(s) and may be incompatible with your current board which runs on sam architecture(s).
In file included from /var/folders/13/7vdzws8x02d0r7rmwljm676c0000gn/T/arduino_modified_sketch_940886/Sweep.ino:10:0:
/Applications/Arduino.app/Contents/Java/libraries/Servo/src/Servo.h:69:2: error: #error "This library only supports boards with an AVR, SAM or SAMD processor."
 #error "This library only supports boards with an AVR, SAM or SAMD processor."
  ^
exit status 1
Error compiling for board nRF52 DK.

I dig further into the Servo.h and find out there is this condition in the code

// Architecture specific include
#if defined(ARDUINO_ARCH_AVR)
#include "avr/ServoTimers.h"
#elif defined(ARDUINO_ARCH_SAM)
#include "sam/ServoTimers.h"
#elif defined(ARDUINO_ARCH_SAMD)
#include "samd/ServoTimers.h"
#else
#error "This library only supports boards with an AVR, SAM or SAMD processor."
#endif

I am wondering since this library is built on the SAMD architecture, maybe it should pass the SAMD conditioning and select include "samd/ServoTimers.h"? Or the SAMD we are using here is different than what they are looking for in the code.

Thank you so much, please let me know if there is anything unclear about my question :) Will be happy to clarify.

Thanks again,

Alex

flashing micro:bit

I tried to flash the softdevice onto the micro:bit, but get 128 errors when flashing softdevice or Blink sketch:
Segger firmware is installed on microbit, Zadig replaced the JLink driver for WinUSB,
COM-Port is greyed out in the arduino IDE;
There was no message "Accept or Decline" when flashing the softdevice.
How can the microbit be flashed from within the Arduino IDE? Anyone who succeeded?

error report:
cortex_m reset_config sysresetreq
adapter speed: 1000 kHz
nrf51.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0
** Programming Started **
auto erase enabled
wrote 93184 bytes from file C:\Users\Martin\AppData\Local\Arduino15\packages\sandeepmistry\hardware\nRF5\0.2.0/cores/nRF5/SDK/components/softdevice/s110/hex/s110_nrf51_8.0.0_softdevice.hex in 27.661337s (3.290 KiB/s)
** Programming Finished **
** Verify Started **
jaylink: SWD I/O operation failed: 06.
Error: jaylink_swd_io() failed: JAYLINK_ERR_DEV.
jaylink: Failed to send data to device: LIBUSB_ERROR_TIMEOUT.
jaylink: Failed to send data to device: LIBUSB_ERROR_TIMEOUT.
jaylink: Sending data to device timed out.
jaylink: transport_write() failed: -4.
Error: jaylink_swd_io() failed: JAYLINK_ERR_TIMEOUT.
Error: checksum mismatch - attempting binary compare
jaylink: Last read operation left 1661 bytes.
jaylink: Failed to send data to device: LIBUSB_ERROR_PIPE.
jaylink: transport_write() failed: -1.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
jaylink: Last read operation left 1730 bytes.
jaylink: Failed to send data to device: LIBUSB_ERROR_IO.
jaylink: transport_write() failed: -1.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
diff 0 address 0x00000000. Was 0x60 instead of 0xc0
diff 1 address 0x00000001. Was 0xb8 instead of 0x07

Flushing programs does not really happen with new sandeepmistry/nRF5 0.1.0 board installation

Under "Nordic Semiconductor nRF5 Boards": nrf52 DK (Version 0.1.0)
It is possible to compile and do flushing/upload the current program - but running is everytime the previous old last flushed image!
I have done a complete de- and re-installation - still the same behaviour. Something is wrong in that new inspiring environment.
It's a pitty - the old nRF/nRF board setting I have deinstalled already!

Blinky?

Just got this setup according to the ReadMe. Based on the following output seems to be building and downloading ok. For a simple Blink.ino example, what PIN should I use? 13 doesnt seem to work, not sure how these nrf52 pins are mapped.

GNU ARM Eclipse 64-bits Open On-Chip Debugger 0.10.0-dev-00287-g85cec24 (2016-01-10-12:03)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
swd
cortex_m reset_config sysresetreq
adapter speed: 1000 kHz
nrf51.cpu: target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000574 msp: 0x20008000
** Programming Started **
auto erase enabled
wrote 4096 bytes from file /var/folders/75/wvhmv78s3zz48zf4fssk4__40000gn/T/buildd5ae82e677127ac286f51de66781d807.tmp/Blink.ino.bin in 0.232602s (17.197 KiB/s)
** Programming Finished **
** Verify Started **
verified 3388 bytes in 0.085533s (38.682 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked

BMD-300/BMD-301 Support

I don't have my eval board yet but I've been working on adding support for this module. The board looks pretty similar to the Nordic board but I don't know that it would work with the NRF52DK board since I think Rigado has their own bootloader though I believe it still uses the J-Link chip.

I'd like to support the Rigado bootloader, RigDFU. It has two update options, serial and BLE (Mac/Linux Only). So essentially there are three ways to update this module.

Initially I wanted to include an upload menu under a BMD-300 board where you could select openocd, RigDFU Serial, or RigDFU BLE but I couldn't figure out how to get that to play nice with the platform.txt. So for now I've just been trying to get the serial working.

So far in boards.txt I have:

BMD-300/301.name=BMD-300/301 RigDFU

BMD-300/301.upload.tool=sandeepmistry:rigdfu
BMD-300/301.upload.protocol=
BMD-300/301.upload.maximum_size=524288

BMD-300/301.build.mcu=cortex-m4
BMD-300/301.build.f_cpu=16000000
BMD-300/301.build.board=BMD-300
BMD-300/301.build.core=nRF5
BMD-300/301.build.variant=BMD-300_RigDFU
BMD-300/301.build.variant_system_lib=
BMD-300/301.build.extra_flags=-DNRF52
BMD-300/301.build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16
BMD-300/301.build.ldscript=nrf52_xxaa.ld

BMD-300/301.menu.softdevice.none=None
BMD-300/301.menu.softdevice.none.softdevice=none

BMD-300/301.menu.softdevice.s132=S132
BMD-300/301.menu.softdevice.s132.softdevice=s132
BMD-300/301.menu.softdevice.s132.softdeviceversion=2.0.1
BMD-300/301.menu.softdevice.s132.upload.maximum_size=409600
BMD-300/301.menu.softdevice.s132.build.extra_flags=-DNRF52 -DS132 -DNRF51_S132
BMD-300/301.menu.softdevice.s132.build.ldscript=armgcc_s132_nrf52832_xxaa.ld

BMD-300/301.menu.lfclk.lfxo=Crystal Oscillator
BMD-300/301.menu.lfclk.lfxo.build.lfclk_flags=-DUSE_LFXO
BMD-300/301.menu.lfclk.lfrc=RC Oscillator
BMD-300/301.menu.lfclk.lfrc.build.lfclk_flags=-DUSE_LFRC
BMD-300/301.menu.lfclk.lfsynt=Synthesized
BMD-300/301.menu.lfclk.lfsynt.build.lfclk_flags=-DUSE_LFSYNT

And in platform.txt I added:

tools.rigdfu.path={runtime.platform.path}/tools/rigdfu
tools.rigdfu.cmd=py
tools.rigdfu.cmd.windows=py.exe

tools.rigdfu.genimage.pattern="{cmd}" -2 {path}/image-tools/genimage/genimage.py {build.path}/{build.project_name}.hex -o {build.path}/{build.project_name}.RigDFU.bin

tools.rigdfu.upload.params.verbose=-d2
tools.rigdfu.upload.params.quiet=-d0
tools.rigdfu.upload.pattern="{cmd}" -3 {path}/update-tools/serial/dfu.py {build.path}/{build.project_name}.RigDFU.bin -s {serial.port}

I also added a variant folder. The problem with this is we need to run the .hex through their genimage.py script first before uploading. I couldn't figure out how to get that to work. Maybe add it into the compiler patterns?

I got the scripts from their github which you need to request access to. You need python 2 and 3 so I used the Python Launcher. BLE.py operates in a similar fashion for BLE updates. Encryption options are also available through the DFU.py and BLE.py which would be nice to incorporate.

How to use latest core

Can you please give some details on how to work on the latest core from git?

I tried cloning this repo to
/Users/adityatannu/Documents/hardware/nRF5
and
/Users/adityatannu/Documents/Arduino/hardware/nRF5

But I do not seem to be getting the latest changes in the IDE.

I'm not really sure how this works but for ESP8266/Arduino core, it is mapped to
/Applications/Arduino.app/Contents/Java/hardware/esp8266com/esp8266, I tried doing something similar but didn't work. The release I installed from Boards Manager seems to be the active one.

I'd really appreciate some guidance here!

printf support

At the moment i play around with printf. This doesn't work until i have modified Print.cpp like https://forum.arduino.cc/index.php?topic=197601.msg1488213#msg1488213

I think this is not a perfect solution because file is ignored. I have no idea about a correct implementation.

diff --git a/cores/nRF5/Print.cpp b/cores/nRF5/Print.cpp
index 05a1f18..71f7551 100644
--- a/cores/nRF5/Print.cpp
+++ b/cores/nRF5/Print.cpp
@@ -37,6 +37,16 @@ size_t Print::write(const uint8_t *buffer, size_t size)
   return n;
 }
 
+// for printf compatibility
+extern "C" {
+__attribute__((weak))
+int _write(int file, char *buffer, int size)
+{
+  Serial.write(buffer, size);
+       return 0;
+}
+}
+
 size_t Print::print(const __FlashStringHelper *ifsh)
 {
   return print(reinterpret_cast<const char *>(ifsh));

Running on Raspberry Pi (OpenOCD issue)

Hi,

I'm trying to run this on a raspberry pi, so I had to manually install the arm gcc (even though we are already on ARM I read that it might still be required for correct compilation for cortext M) and OpenOCD.

Now for OpenOCD I had to download the source code (https://github.com/sandeepmistry/openocd-code-nrf5/) and install from master branch:

./bootstrap
./configure --disable-werror
make
sudo make install

(mostly from https://github.com/sandeepmistry/openocd-code-nrf5/blob/nrf5/.travis.yml)

So I am currently getting the following error when trying to upload to a micro:bit:

Arduino: 1.6.13 (Linux), Board: "BBC micro:bit, None"

Sketch uses 2,988 bytes (1%) of program storage space. Maximum is 262,144 bytes.
Open On-Chip Debugger 0.10.0-dev-00255-g57a19d4 (2016-12-02-00:58)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
Error: The specified debug interface was not found (cmsis-dap)
The following debug interfaces are available:
1: ftdi
2: usb_blaster
3: jlink
4: vsllink
the selected serial port 3: jlink
 does not exist or your board is not connected
5: ulink
6: hla
7: osbdm
8: opendous
9: sysfsgpio
10: aice

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I have selected the micro:bit board, and the CMSIS-DAP programmer.

This was the configuration summary when trying to instal OpenOCD:

OpenOCD configuration summary
--------------------------------------------------
MPSSE mode of FTDI based devices        yes (auto)
Segger J-Link JTAG Programmer           yes (auto)
ST-Link JTAG Programmer                 yes (auto)
TI ICDI JTAG Programmer                 yes (auto)
Keil ULINK JTAG Programmer              yes (auto)
Altera USB-Blaster II Compatible        yes (auto)
Versaloon-Link JTAG Programmer          yes (auto)
OSBDM (JTAG only) Programmer            yes (auto)
eStick/opendous JTAG Programmer         yes (auto)
Andes JTAG Programmer                   yes (auto)
USBProg JTAG Programmer                 no
Raisonance RLink JTAG Programmer        no
Olimex ARM-JTAG-EW Programmer           no
CMSIS-DAP Compliant Debugger            no

Do I need to install anything else? Any help would be greatly appreciated.

Unable to flash softdevice (Incorrect file version)

When trying to flash the S132 soft device I am getting an error saying it cannot open the HEX file. From looking at the error log OpenOCD is looking for 2.0.0 of the soft device when 2.0.1 is actually in the soft device folder. I was able to rename the 2.0.1 HEX over to 2.0.0 and it flashed successfully.

Missing SDK BLE libraries etc

What is the best method to use Nordic's BLE libraries?

i.e I tried to compile the ble_peripheral\ble_app_beacon example from SDK V11, but none of the headers are in your repo.

Is this a licensing issue?

Will this become the official core for the Arduino Primo ?

I've just realised that the Arduino Primo will use the nRF52 as the main processor, and as Sandeep works for Arduino, I wondered if this repo will be the Core that the Primo uses, or whether Nordic are developing a separate core for the Repo.
In which case it seems pointless continuing with this one, as an official core written by Nordic developers would probably be better ??

Wire nRF52 DK implementation bug

I expect I have found the nRF52 DK Wire issue: SCL & SDA are swapped!
SCL is on the the SDA hardware pin - as I have confirmed with a Salea Logic !
In variants.cpp the Arduino pin translation should be:

  // SDA, SCL
  26,   //SDA
  27,   //SCL

... but I'm currently not able to test and confirm it, because I have a (local?) flushing issue with the new board management version under (sandeepmistry/nRF5): New created *.ino.hex images are not flushed really/correctly!

Binary Integers not recongized

If you try to declare an integer in the binary format it will fail to compile... Verbose is attached, cheesy example sketch below.

`int Test = B001;

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}`
zero.txt
nrf.txt

Unable to get code on the board

Hi guys I have nrf52 DK board and I would like to use Arduino ide to program it.

But when I try to flash new bootloader or adding softdevice or adding bootloader is leading alywas to errors.

My board have PCA10040 any and its date is prior to 2016.9

Can someone give me more detailed information how to get started from the scratch with that board and the code available at this repo ?

Missing file error after fresh install

I followed the install procedure with a new arduino installal and the additional board package.

Arduino: 1.6.12 (Windows 10), Board:"Generic nRF51822, 16 kB RAM, 256 kB flash (xxaa), None, Crystal Oscillator"

In file included from C:\Users\BramenRianne\AppData\Local\Arduino15\packages\sandeepmistry\hardware\nRF5\0.2.0\cores\nRF5/Arduino.h:5:0,

                 from sketch\sketch_nov13a.ino.cpp:1:

c:\users\bramenrianne\appdata\local\arduino15\packages\sandeepmistry\tools\gcc-arm-none-eabi\5_2-2015q4\lib\gcc\arm-none-eabi\5.2.1\include\stdint.h:9:26: fatal error: stdint.h: No such file or directory

compilation terminated.

exit status 1
Fout bij het compileren van board Generic nRF51822

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Using Wire

variants.h seems to have these pin definitions for SDA, SCL. What pins should be used on the nRF52 DK, (26) and (27)?

#define WIRE_INTERFACES_COUNT 1

#define PIN_WIRE_SDA         (20u)
#define PIN_WIRE_SCL         (21u)

Wire.cpp has this way to instantiate a Wire interface but doesn't seem to be called anywhere, so I'm not sure what values _uc_pinSCL and _uc_pinSDA take in the TwoWire::begin call

TwoWire::TwoWire(NRF_TWIM_Type * p_twim, NRF_TWIS_Type * p_twis, IRQn_Type IRQn, uint8_t pinSDA, uint8_t pinSCL)

Power consumption seems high

Power consumption of an blank app is 4ma (on BLENano and others)... this seems high. Any tips/tweaks for lower power consumption? For comparison, pre-compiled samples from the NRF SDK use lest than 1/2 of that even when advertising via ble etc.

NRF_RTCx

Has anyone been able to use the RTC, i noticed the delay.c using it but havnt been able to use it.

static unsigned irq_counter = 0;
boolean LD = false;

void RTC0_IRQHandler(void) {
  irq_counter++;
  if (irq_counter % 8 == 0) {
    LD = !LD;
    digitalWrite(9, false);
  }
  NRF_RTC0->EVENTS_TICK = 0UL;
}

void stopRTC() {
  NRF_RTC0->TASKS_STOP = 0UL;
}
void setRTC() {
  //stop to set options
  stopRTC();

  NVIC_SetPriority(RTC0_IRQn, 15);
  NVIC_ClearPendingIRQ(RTC0_IRQn);
  NVIC_EnableIRQ(RTC0_IRQn);

  NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
  NRF_CLOCK->TASKS_LFCLKSTART = 1UL;

  NRF_RTC0->PRESCALER = (1<<12) -1;
  NRF_RTC0->EVTENSET = offsetof(NRF_RTC_Type, EVENTS_TICK);
  NRF_RTC0->INTENSET = offsetof(NRF_RTC_Type, EVENTS_TICK);
  NRF_RTC0->TASKS_START = 1UL;
}

void setup() {
  pinMode(9,OUTPUT);
  digitalWrite(9, LD);
  setRTC();
}

void loop() {
  __WFI();
}

Implement pin output modes

When a pin is switched to OUTPUT the GPIO_PIN_CNF_DRIVE_S0S1 profile is enabled. What is your opinion to implement mode switching via OUTPUT_S0S1, OUTPUT_H0S1, OUTPUT_H0H1, OUTPUT_D0S1.... OUTPUT_H0D1?

Rationale behind this core?

Hello,

This is a question about the main differences between this core (sandeepmistry) and the one by RedBearLab. Setting apart some obvious differences: this core supports also the nRF52 chipset, may I ask what are the main philosophical reasons (rationale) behing this core?

I kindly suggest you may also add this rationale to the the main README.md of the repository. It will be of great help for newcomers trying to understand the different approaches to developing BLE chipsets.

I am a seasoned C++ developer with some experience in the low-level programming of the nrF51 series. It is great to see the effort you are putting together in this core. Thank you!

This core:
https://github.com/sandeepmistry/arduino-nRF5

RedBearLab core:
https://github.com/RedBearLab/nRF51822-Arduino

BLE example

Arduino-nRF5 works very well for me. Using it with a nrf52 development kit. Succeeded also in changing the path structure within the platform.txt to map the sdk structure. But when trying to start BLE examples I ran into a lot of troubles as it is difficult to find out which SDK 11 files are really necessary to run within the Arduino environment.

Therefore I wanted to ask whether someone already succeeded to implement a BLE example with Arduino-nRF5 for the nRF52832 MCU?

Tom

Question: What is the impact supporting bootloader with DFU?

At the moment it is possible to select a softdevice and flash it to the BLE enabled device. Now it would be nice to support DFU-Service also - but what is the price? On Nordic side we can read that a BLE application must be extended for supporting. But in my inial assesment we are not yet prepared on BLE side (BLEPeripheral library). The following changes are required to add BLE DFU Service support to an application:

The application must use the Device Manager. If the application does not use the Device Manager yet, you must update the application. See BLE Device Manager for more information.
You must add DFU related files to the BLE application project. See Including DFU files in application.
You must implement a function that executes application-specific operations to ensure a graceful shutdown of the application. See Implementing graceful shutdown.
The application must correctly set up the BLE services. See Setting up the BLE services.
The application must propagate SoftDevice BLE events to the BLE DFU Service. See Propagating BLE stack events.

So in my rough idea:

  1. We need the dfu enabled bootloader. May be flushed via Arduino menu like the softdevice way. In the SDK there are prepared bootloader hex files with dfu - like the softdevice hex files in nRF5_SDK_11.0.0/examples/dfu/bootloader
  2. We have to set and implement a new BLEPeripheral callback for the gracefull shutdown.
  3. We have to propagte the BLE events to the deployed bootloader build-in DFU service
    and I do not know at the moment what's all done in the nordic Device Manger at all.

In a first (more or less stupid ;-) shot I tried to use mergehex.exe to combine SD+application with that bootloader hexfile - may be to get a hint. For merging only SD & App. this is valid, but mergehex does say: ERROR: The hex files cannot be merged since there are conflicts. ... not detailed but seems explicable, because upper preconditions are not given with my standard BLEPeripheral services exteneded application - and I do not have checked the valid addressing ranges.

Does anybody have experience or a deeper knowledge on this area, how to start progress in this direction?

Crash on ISR

This code is hanging after first timer/rtc event on NRF51 and NRF52. I think this code is correct.

//#define TIMER
#define RTC

#include "nrf.h"

uint16_t counter = 0;

void setup() {
  Serial.begin(38400);

  NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
  NRF_CLOCK->TASKS_HFCLKSTART = 1;

  while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {}

  NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer;
  NRF_TIMER2->PRESCALER = 2;

  #ifdef TIMER
    NVIC_SetPriority(TIMER2_IRQn, 15);
    NVIC_ClearPendingIRQ(TIMER2_IRQn);
    NVIC_EnableIRQ(TIMER2_IRQn);
  #endif
  NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_16Bit;
  NRF_TIMER2->CC[0] = 4000;
  NRF_TIMER2->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos;
  NRF_TIMER2->TASKS_START = 1;

  #ifdef RTC
    NVIC_SetPriority(RTC0_IRQn, 15);
    NVIC_ClearPendingIRQ(RTC0_IRQn);
    NVIC_EnableIRQ(RTC0_IRQn);
  #endif
  NRF_RTC0->PRESCALER = 32;
  NRF_RTC0->EVTENSET = RTC_EVTENSET_COMPARE0_Msk;
  NRF_RTC0->INTENSET = RTC_INTENSET_COMPARE0_Msk;
  NRF_RTC0->CC[0] = 2000;
  NRF_RTC0->TASKS_START = 1;

}

void loop() {
  Serial.print("Counter: ");
  Serial.println(counter);
  delay(300);
}

void TIMER_2_ISR(void)
{
  counter++;
  NRF_TIMER2->EVENTS_COMPARE[0] = 0;
#if __CORTEX_M == 0x04
    volatile uint32_t dummy = NRF_TIMER2->EVENTS_COMPARE[0];
    (void)dummy;
#endif
}

void RTC0_IRQHandler(void)
{
  counter++;
  NRF_RTC0->EVENTS_COMPARE[0] = 0;

#if __CORTEX_M == 0x04
    volatile uint32_t dummy = NRF_RTC0->EVENTS_COMPARE[0];
    (void)dummy;
#endif
}

Question: How to flush RBL nRF51822 and BLENano?

The arduino-nRF5 project can flush the nRF52-DK with it's buildin JLink debugger. Do I have to connect a external JLink to the RBL nRF51822 board by soldering a header to SWD-B? Or is the idea to support a serial programmer later on - especilly for BLENano?

Support for internal hardware via external/internal libraries

The nRF5 Platform provides a lot of internal Hardware like:

  • Watchdog Timer
  • PPI
  • RADIO
  • Temperature Sensor
  • NFC
  • I2S
  • Hardware Random Number Generator
    ....

I think the best way is to provide bundled libraries supporting the internal hardware instead of forking an external library like #55 (comment) or #54 (comment)

For other platforms a lot of libraries are included:

  • Arduino for AVR comes with "EEPROM", "SPI", "HID", "SoftwareSerial", "Wire".
  • Arduino for SAMD is bundled with "HID", "SAMD_AnalogCorrection", "SPI", "USBHost" and "Wire".
  • Arduino for ESP8266 comes with 24 libraries supporting Hard- and Software features.

I think there is no problem to bundle more libraries than Arduino for AVR. This makes it easier for many people use the internal Hardware of nRF5 MCU.

Example: In the future arduino-nRF5 is included into "Board Manager" per default like a lot of other boards. The installation is easy. Nobody sees what is written in README. The most people have no knowledge about complete functionality provided by nRF5 hardware.

To use an external library you must know that the MCU provides a functionality, you have to know that there are external libraries providing Nordic specific functionality and last but not least you have to choose a correct version. Libraries like SleepyDog are marked as compatible but they aren't.

In my opinion, when hardware functionality is implemented in external libraries this results in projects using more hardware, like a external temerature sensor instead of the internal one, or insecure cryptogaphy by seeding a pseudo random number generator with input of an analog pin instead of using random numbers generated with included hardware RNG...

If you wanna provide the hardware functionality across external libraries, i think the best way is to create a github organization which collects all additional libraries. This helps people with advanced knowledge to find out what is implemented. I think in most cases a fork of libraries like SlepyDog or TrueRandom must be maintained by people working with arduino-nrf5.

Support for analogWrite with 3rd parameter: frequency

Motivated by a real application need (use case) and the particle (extended) Wiring-API, an additional analogWrite(pin, pwm, freq) Wiring method would be very useful. One unique method with a default parameter:
void analogWrite(uint32_t ulPin, uint32_t ulValue, uint32_t ulFreq=500);
would also be valid.

nRF51 and nRF52 Development Boards

Hi Sandeep,

I have designed a couple of development boards using the nRF51 and nRF52; they have been for sale on Tindie. Can I use your Arduino core to program them through the redBear programmer? Do I need to go through J-link on an nRF52 DK board? If I send you one of these boards would you help me learn how to program it using your core?

I am working with another fellow now to build an Arduino core for the STM32L4 family. This is the development board we are using for that:

https://www.tindie.com/products/onehorse/dragonfly-stm32l4-breakout-board/

Please let me know if you have some interest in collaborating to make the nRF52 usable with the Arduino IDE.

Kris

Error while flashing SoftDevice.

Hi,
I am trying to flash my Bluzdk by following the steps given by you. But as I proceed to the last step i.e.

Select Tools -> nRF5 Flash SoftDevice
Read license agreement
Click "Accept" to accept license and continue, or "Decline" to decline and abort
If accepted, SoftDevice binary will be flashed to the board

I get the following error:

java.io.IOException: Cannot run program "/home/amitt/.arduino15/packages/sandeepmistry/tools/openocd/0.10.0-dev.nrf5/bin/openocd": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:485)
at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:11)
at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:129)
at cc.arduino.packages.uploaders.SerialUploader.burnBootloader(SerialUploader.java:410)
at com.github.sandeepmistry.arduino.nRF5.nRF5FlashSoftDevice.lambda$run$0(nRF5FlashSoftDevice.java:143)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.(UNIXProcess.java:248)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 7 more
Error while flashing SoftDevice.

Please help, how do I proceed now ?

Why does this core need GCC 5.2 ?

Edit.

I think I may have asked this question, and I think the answer is utoa is needed from 5.2, but just to note, that

From what I've read on the Nordic blog they don't recommend using gcc newer than 4.9.3

See https://devzone.nordicsemi.com/tutorials/7/development-with-gcc-and-eclipse/

`*Note - 12-3-2016 *

Was made aware of a potential bug that may have been introduced in the latest 5.2 release by @lucas in the comments. Problem is described in this thread. Will look into this, but for now you may want to use the 4.9.3 release to be safe. `

Also see

https://devzone.nordicsemi.com/question/70735/nrf52-pca10040-debugging-fails-eclipse/

which recommends 4.9

Version control conflict while flashing soft device

While flashing the soft-device as per the repo here with the jar file, there happens to be a version conflict between the generated hex file and downloaded one in the path: $../Arduino15/packages/sandeepmistry/hardware/nRF5/0.1.0/cores/nRF5/SDK/components/softdevice/s132/hex/s132_nrf52_2.0.0_softdevice.hex . (beteen .._nrf52_2.0.0 & .._nrf52_2.0.1).

Linker error: using pulseIn() realized as puls_asm.S

Using the pulseIn() method in a sketch (e.g.)

#define PULSE_PIN 3
void setup() {
  Serial.begin(115200);
  pinMode(PULSE_PIN, INPUT_PULLUP);
  uint32_t pulse = pulseIn(PULSE_PIN, HIGH, 6000);
  Serial.print  ("pulse len[us]: ");
  Serial.println(pulse);  
}
void loop() {}

does create an linker error:
see output log:

c:/users/.../appdata/local/arduino15/packages/sandeepmistry/tools/gcc-arm-none-eabi/5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld.exe: 
error: C:\Users\...\AppData\Local\Temp\build564232db8aa323b9aba1a2502c4097a0.tmp/test_pulseIn.ino.elf 
uses VFP register arguments, 
C:\Users\...\AppData\Local\Temp\build564232db8aa323b9aba1a2502c4097a0.tmp/core\core.a(pulse_asm.S.o) 
does not

c:/users/.../appdata/local/arduino15/packages/sandeepmistry/tools/gcc-arm-none-eabi/5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld.exe: 
failed to merge target specific data of file C:\Users\...\AppData\Local\Temp\build564232db8aa323b9aba1a2502c4097a0.tmp/core\core.a(pulse_asm.S.o)

In the assumption that the DUE configuration (platform.txt) has a proper setting, I have tried to find a difference but I'm not succesful up to now.

Current repo when installed per instructions does not install all variants

The current README.md lists 4 supported boards.
The current boards.txt contains entries for 6 boards:
. nRF52DK.name=nRF52 DK
. BluzDK.name=Bluz DK
. BLENano.name=RedBearLab BLE Nano
. RedBearLab_nRF51822.name=RedBearLab nRF51822
. Generic_nRF51822.name=Generic nRF51822
. Waveshare_BLE400.name=Waveshare BLE400

The current package_nRF5_boards_index.json only lists the first 2 boards
The current arduino-nRF5-0.1.0.tar.gz only includes variants files for the first 2 boards

When the instructions in the README.md are followed, only nRF52 DK and Bluz DK are shown in the boards manager.

Linker warnings on all boards except nRF52 DK

ld.exe: warning: changing start of section .heap by 4 bytes
ld.exe: warning: changing start of section .stack_dummy by 4 bytes
ld.exe: warning: changing start of section .heap by 4 bytes
ld.exe: warning: changing start of section .stack_dummy by 4 bytes
ld.exe: warning: changing start of section .heap by 4 bytes
ld.exe: warning: changing start of section .stack_dummy by 4 bytes

I presume this isn't important, never the less, ideally something should be changed in the linker file to fix this.

Cant get it to work with an nRF51822 board by Waveshare

Unfortunately I can't get this core to work with my nRF51822 board. (http://www.waveshare.com/nrf51822-eval-kit.htm) http://www.waveshare.com/w/upload/1/1b/BLE400-Schematic.pdf

The board uses an nRF51822 QFAC
It has LED's on pins 18 to 22

I install the JSON package
Cloned the git repo as per the readme

JLink programming doesnt directly work for me so I've been using the hex file generated by the IDE in the tmp folder, uploading via JFlash or the JLink CLI exe

Sketch should just link P0.20

void setup() {
  // put your setup code here, to run once:
  pinMode(20,OUTPUT);
}

void loop() {
    // put your main code here, to run repeatedly:
  digitalWrite(20,HIGH);
  delay(500);
  digitalWrite(20,LOW);
  delay(500);  
}

I tried with and without the S130 softdevice. Neither worked :-(

So I'm kinda stumped at the moment about what to try next.

Inspiring: New kinds on the block: IMM-NRF52832

Just want tell the community: I have get it working, flashing the new IMM-NRF5832 module from Tindie/i-SYST: Softdevice and BLE-application using the nRF52-DK Jlink.
Trick: For to forwarding Serial output flush a dummy (w/o Serial!!) application to the nRF-DK, connect the RX/TX ports and SWD pins to the Debug-out connector.
img_5662

External libraries do not compile

Not sure what's going on with this one, but select external libraries will not compile.... For example if you try to use the Adafruit GFX library it will come back with a "No such file or directory" error. I know this library works perfectly fine if I select any other Arduino board. Same issue occurs with libraries I wrote personally.

Sending bytes to Serial stops working

Sending bytes, e,g, via the Arduino Serial Monitor does halt the loop. May be the receive buffer is not yet initialized correctly. The standard Arduino Communication - SerialEvent example can be used for reproducing this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.