Now we are really getting started here ! How to program Torrus ?
Torrus is based on an nRF52832, and is usually programmed in C using an interface chip called CMSIS-DAP. That programming chip can be found in nRF52 dev kit for ~50$, but I think we could also program it for 0-2$ !
We currently have two problems to solve :
1. Use Arduino to program Torrus, not a complex IDE
2. Program Torrus without requiring an external programmer, or just an FTDI chip.
Arduino and nRF52
Thanks to Sandeepmistry we have a port that allow us to use Nordic nRF5 chips with Arduino ! It's been used by others who based their core software on this library :
- RedBearLab nRF51822 Github (DFU Over The Air bootloader, seems to be buttonless !)
- Bluefruit nRF52 Github
- Sparkfun nRF52832 Breakout board Github
So guess what ? We are going to do the same !
But we might need to provide extra features to make it easy to program. That's what I will be working on for the next weeks. I have started to fork the library on Github, and work on Torrus board support. I have also included the serial programming tool from Sparfun (more below...).
Programming Torrus
Here is the big deal ! We want to get rid of the CMSIS-DAP programmer, because if it is great for debugging, it is big and expensive.
To avoid using the programmer, Nordic offers another way called DFU (Device Firmware Update). DFU can be done via two ways :
- Serial Update.
In this case we need to reset the device, press a button to get in DFU mode and send the new firmware over serial (from Arduino for example), perfect for developing. - OTA (Over The Air) Update, in a word via Bluetooth. The device can be set in DFU mode from a Bluetooth Service. This is great so everyone can update Torrus from its phone.
Before going further I like to give you a quick explanation of the Application layout (all the data that goes in the nRF52, Torrus brain) :
The softdevice is provided by Nordic, it runs all the important functions. We can't modify it, just call functions. It is the first piece of software to be executed on boot, just before the bootloader.
The application is ... well the application ! All we need to develop ! To create bluetooth services, communicate with other sensors... This is what we will work on most of the time
The bootloader checks if we are trying to update the software, otherwise it launch the application.
Here is what we have to do now :
Create the bootloader so it can update from Bluetooth or Serial
Modify Torrus circuit to add a Serial programmer (certainly the CP2104A) that will be able to automatically reset the board.
Make the new bootloader work with Arduino.
Then we will be able to program Torrus from its USB port.
Documentation
Below you will find most of the interesting documentation on the subject (pretty much all we need to solve those problems).
Sparfkun nRF52832 breakout board guide (Serial bootloader) :
Nordic DFU official documentation (Buttonless DFU OTA only supported in prod since SDK v14)
Android DFU library Git from Nordic
Nordic DFU bootloaders examples
Bluefruit nRF52 feather documentation (bootloader buttonless with CP2104 FTDI, factory reset)
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.