We are trying to implement DFU for a nrf52840. Step one is creating a binary that Notehub can retrieve the version information from.
Following the esp32 example, I added a version.c file:
#include "main.h"
#include <string.h>
// Edit options, Common
// Build
// Set 'Always Rebuild' to yes
// C Helpers to convert a number to a string
#define STRINGIFY(x) STRINGIFY_(x)
#define STRINGIFY_(x) #x
// Definitions used by firmware update
#define PRODUCT_ORG_NAME ""
#define PRODUCT_DISPLAY_NAME "Notecard Example"
#define PRODUCT_FIRMWARE_ID "notecard-example-v1"
#define PRODUCT_DESC ""
#define PRODUCT_MAJOR 1
#define PRODUCT_MINOR 0
#define PRODUCT_PATCH 0
#define PRODUCT_BUILD 0
#define PRODUCT_BUILT __DATE__ " " __TIME__
#define PRODUCT_BUILDER ""
#define PRODUCT_VERSION STRINGIFY(PRODUCT_MAJOR) "." STRINGIFY(PRODUCT_MINOR) "." STRINGIFY(PRODUCT_PATCH)
// This is a product configuration JSON structure that enables the Notehub to recognize this
// firmware when it's uploaded, to help keep track of versions and so we only ever download
// firmware builds that are appropriate for this device.
#define QUOTE(x) "\"" x "\""
#define FIRMWARE_VERSION_HEADER "firmware::info:"
#define FIRMWARE_VERSION FIRMWARE_VERSION_HEADER \
"{" QUOTE("org") ":" QUOTE(PRODUCT_ORG_NAME) \
"," QUOTE("product") ":" QUOTE(PRODUCT_DISPLAY_NAME) \
"," QUOTE("description") ":" QUOTE(PRODUCT_DESC) \
"," QUOTE("firmware") ":" QUOTE(PRODUCT_FIRMWARE_ID) \
"," QUOTE("version") ":" QUOTE(PRODUCT_VERSION) \
"," QUOTE("built") ":" QUOTE(PRODUCT_BUILT) \
"," QUOTE("ver_major") ":" STRINGIFY(PRODUCT_MAJOR) \
"," QUOTE("ver_minor") ":" STRINGIFY(PRODUCT_MINOR) \
"," QUOTE("ver_patch") ":" STRINGIFY(PRODUCT_PATCH) \
"," QUOTE("ver_build") ":" STRINGIFY(PRODUCT_BUILD) \
"," QUOTE("builder") ":" QUOTE(PRODUCT_BUILDER) \
"}"
const char *productVersion() {
return ("Ver " PRODUCT_VERSION " " PRODUCT_BUILT);
}
// Return the firmware's version, which is both stored within the image and which is verified by DFU
const char *firmwareVersion() {
return &FIRMWARE_VERSION[strlen(FIRMWARE_VERSION_HEADER)];
}
I confirmed that the binary file contains the json formatted string with the âfirmware::infoâ header. Itâs near the end of the file, with all the other string constants.
But when I upload it to Notehub, the version is not recognized. The version, metadata, organization, description, product, built, and builder fields are empty.
Is Notehub looking for the âfirmware::infoâ string in a particular location?
Is there a way to remove a file from Notehub once Iâve uploaded it?
Thanks