atc1441 / D6-arduino-nRF5

D6 Fitness Tracker Arduino Core for Nordic Semiconductor nRF5 based boards
Other
21 stars 9 forks source link

BLE-DFU works for Micropython, but not for Arduino, any hints? #4

Closed gerardwr closed 4 years ago

gerardwr commented 4 years ago

Hi,

Like your videos about D6Flasher and DaFlasher, thanks for sharing!

I could use your help in flashing Arduino firmware in my Nrf52832 module (E104-BT5032A nRF52832). After I want to shift to an Nrf52832 Smartwatch.

Flashing bootloader and softdevice via OpenOcd/ST-Link works OK and:

But uploading an Arduino hex file compiled for NRF52832 using NrfConnect or D6Flasher App fails every time. NrfConnect disconnects after some seconds without uploading.

I guess the bootloader+softdevice that works for micropython is not right for Arduino.

I have been reading for days and experimenting with different bootloaders, different softdevices, but without success. The BLE upload always fails.

Would be great if you could point me in the right direction, I’m not sure where my mistake is.

Greetings.

DETAILED INFO

atc1441 commented 4 years ago

Hi sorry for answering late,

the problem you have is the SoftDevice version,

you need the version nr. 2.0.1 for this Arduino library. also the Bootloader needs to be compiled for that version.

you are using 6.1.1

gerardwr commented 4 years ago

Hi,

Thanks for your reply.

Have tried a lot of BL and SD combinations without success, so some focus is great.

I will try flashing a combination of an SD version 2.0.1 and matching bootloader.

Will report back how it goes.

atc1441 commented 4 years ago

In general you could use the portable arduino variant and flash the P8 "Stock" firmware. It containes the sd2 and a bootloader that trys to write to the display but it should work even when no display is connected. After that you can flash a simple sketch to it with the ability to go into bootloader mode. And from there you can flash anything else OTA or via the Arduino swd upload

gerardwr commented 4 years ago

That REALLY helps, thanks! I flashed the P8-stock firmware, and can now upload Arduino sketches using the NrfConnect App. See details here below.

Will try D6Flasher/DaFlasher next.

Greetings!!

DETAILED DESCRIPTION

I downloaded your portable Arduino variant from http://atcnetz.de/downloads/D6Arduino.rar , but it's for Windows and I'm on Mac, so I could not run it.

But I found:

So I used this openocd command:

pi@raspberrypi3:~/Mydata/Nrf52832/firstexperiments $ sudo openocd -f
interface/raspberrypi2-native.cfg -c "transport select swd" -f
target/nrf52.cfg -d2 -c init -c "reset init" -c halt -c "nrf5
mass_erase" -c "program dsd6-flashP8.bin verify" -c "flash write_bank 1
dsd6-uicr-flashP8.bin" -c "flash banks" -c "reset run" -c exit

After flashing, the device ATCdfu appeared in the NrfConnect App. Screenshot_20200606-215112

After connecting to the ActDfu device I could upload a compiled Arduino .ZIP sketch without any problem. Screenshot_20200606-215208

The sketch provides a (fake) BLE HeartRate service, my device is listed in NrfConnect App. Screenshot_20200606-215257

My Heartrate device is recognised by the NrfToolbox App. Screenshot_20200606-222728

So now I can use Arduino sketches using BLE, great!

atc1441 commented 4 years ago

Nice to see it works as you want :) And thank you for your very detailed description.

I am closing it now

gerardwr commented 4 years ago

Just for completeness:

Instead of using NrfConnect DFU to upload the Arduino sketch you can also combine flashing the P8-stock firmware and the Arduino .hex file using OpenOcd with this command:

pi@raspberrypi3:~/Mydata/Nrf52832/firstexperiments $ sudo openocd -f
interface/raspberrypi2-native.cfg -c "transport select swd" -f
target/nrf52.cfg -d2 -c init -c "reset init" -c halt -c "nrf5
mass_erase" -c "program dsd6-flashP8.bin verify" -c "program
HeartRateBLE.ino.hex" -c "flash write_bank 1 dsd6-uicr-flashP8.bin" -c
"flash banks" -c "reset run" -c exit