Author Topic: Simblee - OTA programming?  (Read 7160 times)

alanu1000

  • RFduino Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Simblee - OTA programming?
« on: January 10, 2016, 12:46:23 PM »
According to its specs, Simblee is supposed to have "OTA programming with hardware OTA disable".

I take this to mean that the Arduino programming environment should be able to link to a Simblee via bluetooth and upload programs to it wirelessly.

I have not been able to figure out how to do this.

Has this feature been implemented, and if so, how does one get started with it?

Thanks

Alan

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - OTA programming?
« Reply #1 on: January 10, 2016, 04:05:36 PM »
I don't know either. I think the concept is to upload via a smart phone approach.
I'd like to be able to upload directly from the Arduino IDE via BLE OTA, but I think that would need native BLE support in the IDE on the various PCs,(Windows, Linux, Mac). Does anybody do that?, yet.



alanu1000

  • RFduino Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Simblee - OTA programming?
« Reply #2 on: January 11, 2016, 06:13:10 AM »
Thanks for your reply - it is good to know that I am not missing anything obvious.

The Arduino BT microcontroller

https://www.arduino.cc/en/Main/ArduinoBoardBT?from=Main.ArduinoBoardBluetooth

allows programming and a serial monitor connection over bluetooth, which is what I was expecting the Simblee to do, so the Arduino IDE is evidently capable of using bluetooth in this way.

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - OTA programming?
« Reply #3 on: January 11, 2016, 10:30:09 AM »
BLE (Bluetooth Low Energy) can't do the things standard Bluetooth does. And that board can't do BLE. There are chips that can do the full gamat of Bluetooth type things. But the Simblee is specialized for the Bluetooth Smart (BLE) protocols only and primarily meant for enabling sensors. They are capable of being programmed over the air. And can be made to work like a serial converter, albeit with 20 byte packet limitations.

The board you mention is not programming it's Bluetooth chip over the air. It is using the Bluetooth chip as a serial converter to program the main Arduino processor. There is a difference.

« Last Edit: September 22, 2016, 06:24:09 AM by RFD_Nelson »

wookie1

  • RFduino Jr. Member
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Simblee - OTA programming?
« Reply #4 on: January 31, 2016, 09:50:11 AM »
Tolson also posted this on the announcements for Simblee (thanks!)

https://www.simblee.com/Simblee OTA Reference V1.0.pdf

It looks pretty straightforward to do the OTA programming. I plan to try it this week. I think you just get the HEX file that Arduino creates as part of its compiling/building process and build yourself an iOS app in XCode from the example given in the Simblee library. You should be able to just cut and paste the code from your hex file into the example hex file in the library, and compile the example iOS app in XCode, load the app on your phone or whatever, and go.

« Last Edit: January 31, 2016, 10:00:53 AM by tolson »

BETZtechnik

  • RFduino Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Simblee - OTA programming?
« Reply #5 on: February 09, 2016, 11:24:49 AM »
Is there a plan to put an app in the AppStore that will allow this upload to take place ? That way end users could update the module without being an apple developer (for example).

Peter.

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - OTA programming?
« Reply #6 on: February 09, 2016, 02:03:07 PM »
We are suppose to be able to use the Nordic MCP(Master Control Panel) to upload a sketches .hex file.
The Simblee OTA method is suppose to be using the Nordic DFU OTA methods.

Has anybody had any luck figuring it out?

I start with just the basic blink sketch.

The key factors is to add the include file for OTA support...
Code: [Select]
#include <ota_bootloader.h>

A button needs to be defined to trigger the DFU OTA mode.
Code: [Select]
int dfuButton = 5; // for example
pinMode(dfuButton,INPUT);

Somewhere, either in the loop() or in a button handler interrupt, a test for pressed button puts the Simblee into DFU mode. At which time, it brodcasts the DFU Service to connect to.

Code: [Select]
if(digitalRead(dfuButton) == 1){
  ota_bootloader_start();
}

I mail myself my .hex file; which I get with my smart device email program; and store the file in the smart device storage.

When I press the dfuButton on the Simblee the MCP sees the Simblee device appear. I immediately connect to it. Then the DFU service is shown.
I hit the DFU feature on the MCP. Then I have to select file type (application), find it in the file system, answer a couple more questions and go. But, the connection is lost before I can do all that.
I think the problem is we only have 30 seconds to get all this done. I thought the 30 seconds was going to be just the time to make the initial connection. But it seems to be the total time
to make the connection, find the file, try to type in what you need to in the MCP. Phew!
Anybody got any ideas!?

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - OTA programming?
« Reply #7 on: February 09, 2016, 05:08:14 PM »
More info. Instead of using Nordics MCP(Master Conrol Panel) for DFU use Nordic ToolBox instead. The MCP takes too long to finally get to the actual download and the Simblee will time out. The ToolBox is available on both iOS and Android. And it allows you to pre-select the file you want to download.

But now my hang up is the new DFU bootloaders require what they call an INIT file. It has a .DAT suffix. Would be nice to know how to build these required .dat files. Anybody got ideas! Back to the drawing board.

I haven't tried the Master Control Panel that is available for PCs. Is there a ToolBox DFU for PCs. Seems like that could then be tied into the Arduino IDE somehow. Then we would be playing with power!


spkilla

  • RFduino Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Simblee - OTA programming?
« Reply #8 on: August 23, 2016, 11:29:42 PM »
hey, thanks tolson for the information regarding the nordic dfu mode tool. Since it isn't very clear on how to create the ota file using said application, i would love to extend the information. As stated above you need to upload a init file to allow an ota to go through. lucky for us nordic has a pdf explaining the structure of the init file which has been attached to this post.

The way I managed to get that structure down was by downloading nordics master control panel from the downloads section here and using the nrf tool which is explained nicely here. I hope all this information is helpful to anyone that needs it. Enjoy!  8)
« Last Edit: August 24, 2016, 04:55:01 PM by spkilla »

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - OTA programming?
« Reply #9 on: August 24, 2016, 02:30:33 PM »
hey, thanks tolson for the information regarding the nordic dfu mode tool. Since it isn't very clear on how to create the ota file using said application, i would love to extend the information. As stated above you need to upload a init file to allow an ota to go through. lucky for us nordic has a pdf explaining the structure of the init file which can be seen here[EDIT: BROKEN LINK]

The way I managed to get that structure down was by downloading nordics master control panel from the downloads section here and using the nrf tool which is explained nicely here. I hope all this information is helpful to anyone that needs it. Enjoy!  8)

Your first link is broken. While the other two links explains some things, but those don't work as explained with the current version of Android DFU tools.
The nrfutil command has changed several times and now the command options are different again.
There is no "genpkg". It is now called "pkg generate". It now requires a encryption key. etc etc etc.
What we need is an exact location of the versions of specific commands that would let us actually create the app.zip file that the current Android DFU app will successfully up load to a Simblee specifically. No use of Nordic dongles or jtag devices. Some things not known specifically is which SDK and SoftDevice S110 version is in the Simblee. These things seem to have to match up.

And the commands need to work with Linux and OSX besides just Windows.
« Last Edit: August 24, 2016, 02:42:39 PM by tolson »

spkilla

  • RFduino Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Simblee - OTA programming?
« Reply #10 on: August 24, 2016, 05:21:20 PM »
hey, thanks tolson for the information regarding the nordic dfu mode tool. Since it isn't very clear on how to create the ota file using said application, i would love to extend the information. As stated above you need to upload a init file to allow an ota to go through. lucky for us nordic has a pdf explaining the structure of the init file which can be seen here[EDIT: BROKEN LINK]

The way I managed to get that structure down was by downloading nordics master control panel from the downloads section here and using the nrf tool which is explained nicely here. I hope all this information is helpful to anyone that needs it. Enjoy!  8)

Your first link is broken. While the other two links explains some things, but those don't work as explained with the current version of Android DFU tools.
The nrfutil command has changed several times and now the command options are different again.
There is no "genpkg". It is now called "pkg generate". It now requires a encryption key. etc etc etc.
What we need is an exact location of the versions of specific commands that would let us actually create the app.zip file that the current Android DFU app will successfully up load to a Simblee specifically. No use of Nordic dongles or jtag devices. Some things not known specifically is which SDK and SoftDevice S110 version is in the Simblee. These things seem to have to match up.

And the commands need to work with Linux and OSX besides just Windows.

Sorry about that, I attached the pdf to the previous post since the link didn't work directly. The pdf explains some of the things mentioned above. I was actually able to provide an ota through nordics nrf toolbox android app by having the update file ignore the ota version and by using nordic master control panel version 3.10.0.14. As for the softdevice version it has to be one of these three 0x64 0x45 0x5a as those were the versions that allowed me to ota. I only have access to a windows environment at the moment so I'll only be able to provide the command i used which was
Quote
nrfutil dfu genpkg --application myapp.hex --application-version 0xffffffff --dev-type 0xffff --dev-revision 0xffff --sd-req 0x64,0x45,0x5a myapp.zip
Hopefully this is enough information to help a someone make a proper tutorial.

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - OTA programming?
« Reply #11 on: August 24, 2016, 05:27:10 PM »
OK, long story or short story. On my OpenSuSE 13.2 box I have both python3 and python2. When I do a pip install something it defaults to the version 3 version. nrfutil requires python 2. Ugh! OK so have to sudo pip uninstall nrfutil. Make sure it is all gone and then sudo pip2 install nrfutil. But by default it downloads and installs the nrfutil version 1.4.19 which has too many advanced features, requirements, and big change in command flags that don't work with Simblee. So sudo pip2 uninstall nrfutil.

The last version that works with Simblee is nrfutil 0.5.2. One way to install that is to download the package from...
https://github.com/NordicSemiconductor/pc-nrfutil/tree/0_5_2
Within that package do a ...
sudo python setup.py install
verify it installed with
>nrfutil version
nrfutil version 0.5.2

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - OTA programming?
« Reply #12 on: August 24, 2016, 05:41:03 PM »
Here is an example sketch for use with the RFduino RGB Shield attached to a Simblee Shield. The green light will be flashing. A press on the GPIO5 button will drop the Simblee into DFU OTA mode. The Simblee will advertise "DfuTarg" for a short while (30 seconds?) which should be seen by the  nRF_Control_Panel, nRF_Connect, or nRF_Toolbox / DFU apps.

Blink_ota.ino
Code: [Select]
// Blink_ota.ino
// Modified by Thomas Olson 2016

#include <SimbleeBLE.h>
#include <ota_bootloader.h>


int blink_LED = 3; // 3 for green, 4 for blue

int connected_LED = 2; // lights when smart device connects.
int OTA_button = 5; //

void setup() {
  // initialize the digital pin as an output.
  pinMode(blink_LED, OUTPUT);
  pinMode(OTA_button, INPUT);
  pinMode(connected_LED, OUTPUT);
  //SimbleeBLE.begin();   // Uncomment this if you want OTA service available on connection. In which case no need for button_OTA.
}

void loop() {
  digitalWrite(blink_LED, HIGH);
  delay(1000);
  digitalWrite(blink_LED, LOW);
  delay(100);

  if(digitalRead(OTA_button) == 1){

    ota_bootloader_start();
  }

}


void SimbleeBLE_onConnect()
{
  digitalWrite(connected_LED, HIGH);
}
void SimbleeBLE_onDisconnect()
{
  digitalWrite(connected_LED, LOW);
}

Compile and upload this sketch to the Simblee. Find the working directory where Arduino IDE stashes project files. Find the .hex file and copy that to a safe place. In my case it was called Blink_ota.ino.hex. Copy this file somewhere safe. I renamed it bgota.hex.

So now we need something that we can upload via DFU that is different than what is running so we know it works. I simply changed the blink_LED to 4 which is the blue LED. Recompile, but don't upload to Simblee. We just want to create a HEX file.  Again find where the Arduino IDE saved the work space. This time copy the Blink_ota.ino.hex file to somewhere save and rename it bbota.hex.

Now we need to convert the .hex file to the required .zip file.

In my case I made a simple unix shell script called mkdfuzip.

mkdfuzip
Code: [Select]
#!/bin/sh

if [ -n "$1" ]
then
        nrfutil dfu genpkg $1.zip --application $1.hex --application-version 0xffff --dev-revision 0xffff --dev-type 0xffff --sd-req 0xfffe

else
        echo Usage: $0 APP_NAME_REQRUIRED
fi


So now I can do..
>mkdfuzip bgota
>mkdfuzip bbota
Which creates bgota.zip and bbota.zip

Then I mail these files to myself. Then on my Android email I save the two zip files to storage.
Then bring up nRF Toolbox. And then select the DFU Tool.
Then SELECT FILE. Select file type.. Distribution packet (ZIP).
Find and choose which ever bgota.zip or bbota.zip which fills in info in the APP.
Then press the button_OTA on the Simblee.
Then SELECT DEVICE and SCAN and wait for DfuTarg show up.
Then click on it. Then click on UPLOAD.

Volia.  Blue blinking light.
« Last Edit: August 24, 2016, 06:46:48 PM by tolson »

spkilla

  • RFduino Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Simblee - OTA programming?
« Reply #13 on: August 24, 2016, 05:46:18 PM »
One more thing to note. The nrf toolbox app doesnt require the simblee to be in dfu mode. It'll automatically put it into dfu then upload.

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Simblee - OTA programming?
« Reply #14 on: August 24, 2016, 05:52:21 PM »
One more thing to note. The nrf toolbox app doesnt require the simblee to be in dfu mode. It'll automatically put it into dfu then upload.

I haven't found that to work.
SELECT DEVICE
SCAN
nada!!!

What is the trick???