microbit: Updates to enable semantic versioning of the micro:bit runtime DAL

More specifically, the build system now uses the semantic versioning meta-data
held in module.json to define a major.minor.patch version. Additionally, is the branch
being compiled is *not* the master branch, the version is appended with <branchname><githash>.

Specific updates:

- Updates to CMake files to expose this to the micro:bit runtime code.
- Addition of uBit.systemVersion() to expose this to application code.
- Displaying of version string over serial if MICROBIT_DBG is enabled.
- Distribution of version string over BLE via the firmware revision characteristic.
This commit is contained in:
Joe Finney 2015-10-08 14:37:35 +01:00
parent 2230e39340
commit 85a26dc8e1
6 changed files with 53 additions and 5 deletions

View file

@ -225,6 +225,14 @@ class MicroBit
*/
unsigned long systemTime();
/**
* Determine the version of the micro:bit runtime currently in use.
*
* @return A textual description of the currentlt executing micro:bit runtime.
* TODO: handle overflow case.
*/
char *systemVersion();
/**
* Triggers a microbit panic where an infinite loop will occur swapping between the panicFace and statusCode if provided.
*

View file

@ -243,6 +243,16 @@
#define MICROBIT_HEAP_DBG 0
#endif
// Versioning options.
// We use semantic versioning (http://semver.org/) to identify differnet versions of the micro:bit runtime.
// Where possible we use yotta (an ARM mbed build tool) to help us track versions.
// if this isn't available, it can be defined manually as a configuration option.
//
#ifndef MICROBIT_DAL_VERSION
#define MICROBIT_DAL_VERSION "unknown"
#endif
//
// Helper macro used by the micro:bit runtime to determine if a boolean configuration option is set.
//

View file

@ -1,10 +1,10 @@
{
"name": "microbit-dal",
"version": "0.0.1",
"version": "1.2.1",
"license": "Apache2",
"description": "The runtime library for the BBC micro:bit, developed by Lancaster University",
"keywords": ["mbed-classic", "microbit", "runtime", "library", "lancaster", "University"],
"author": "James Devine <j.devine@lancaster.ac.uk (mailto:j.devine@lancaster.ac.uk) >",
"author": "Joe Finney <j.finney@lancaster.ac.uk (mailto:j.finney@lancaster.ac.uk) >",
"homepage": "https://developer.mbed.org/teams/Lancaster-University/code/microbit/",
"dependencies":{
"mbed-classic": "~0.0.4",

View file

@ -32,10 +32,24 @@ set(YOTTA_AUTO_MICROBIT-DAL_CPP_FILES
"MemberFunctionCallback.cpp"
)
execute_process(WORKING_DIRECTORY "../../yotta_modules/${PROJECT_NAME}" COMMAND "git" "log" "--pretty=format:%h" "-n" "1" OUTPUT_VARIABLE git_hash)
execute_process(WORKING_DIRECTORY "../../yotta_modules/${PROJECT_NAME}" COMMAND "git" "rev-parse" "--abbrev-ref" "HEAD" OUTPUT_VARIABLE git_branch OUTPUT_STRIP_TRAILING_WHITESPACE)
if (${git_branch} STREQUAL "master")
set(MICROBIT_DAL_VERSION_STRING "${YOTTA_MICROBIT_DAL_VERSION_STRING}")
else()
set(MICROBIT_DAL_VERSION_STRING "${YOTTA_MICROBIT_DAL_VERSION_STRING}-${git_branch}-g${git_hash}")
endif()
set(MICROBIT_DAL_VERSION_FLAGS "-DMICROBIT_DAL_VERSION=\\\"${MICROBIT_DAL_VERSION_STRING}\\\"")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MICROBIT_DAL_VERSION_FLAGS}")
if (YOTTA_CFG_MICROBIT_CONFIGFILE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${YOTTA_FORCE_INCLUDE_FLAG} \"${YOTTA_CFG_MICROBIT_CONFIGFILE}\"")
endif ()
if(CMAKE_COMPILER_IS_GNUCC)
file(REMOVE "CortexContextSwitch.s")
configure_file("CortexContextSwitch.s.gcc" "CortexContextSwitch.s" COPYONLY)

View file

@ -4,10 +4,10 @@ char MICROBIT_BLE_DEVICE_NAME[] = "BBC MicroBit [xxxxx]";
#if CONFIG_ENABLED(MICROBIT_BLE_ENABLED) && CONFIG_ENABLED(MICROBIT_BLE_DEVICE_INFORMATION_SERVICE)
const char MICROBIT_BLE_MANUFACTURER[] = "The Cast of W1A";
const char MICROBIT_BLE_MODEL[] = "Microbit SB2";
const char MICROBIT_BLE_MODEL[] = "micro:bit";
const char MICROBIT_BLE_SERIAL[] = "SN1";
const char MICROBIT_BLE_HARDWARE_VERSION[] = "0.2";
const char MICROBIT_BLE_FIRMWARE_VERSION[] = "1.1";
const char MICROBIT_BLE_FIRMWARE_VERSION[] = MICROBIT_DAL_VERSION;
const char MICROBIT_BLE_SOFTWARE_VERSION[] = "1.0";
#endif
@ -340,7 +340,7 @@ void MicroBit::removeIdleComponent(MicroBitComponent *component)
{
int i = 0;
while(idleThreadComponents[i] != component && i < MICROBIT_IDLE_COMPONENTS)
while(idleThreadComponents[i] != component && i < MICROBIT_IDLE_COMPONENTS)
i++;
if(i == MICROBIT_IDLE_COMPONENTS)
@ -360,6 +360,18 @@ unsigned long MicroBit::systemTime()
return ticks;
}
/**
* Determine the version of the micro:bit runtime currently in use.
*
* @return A textual description of the currentlt executing micro:bit runtime.
* TODO: handle overflow case.
*/
char *MicroBit::systemVersion()
{
return MICROBIT_DAL_VERSION;
}
/**
* Triggers a microbit panic where an infinite loop will occur swapping between the panicFace and statusCode if provided.
*

View file

@ -16,12 +16,16 @@ int main()
#if CONFIG_ENABLED(MICROBIT_DBG)
pc.baud(115200);
// For diagnostics. Gives time to open the console window. :-)
for (int i=3; i>0; i--)
{
pc.printf("=== SUPERMAIN: Starting in %d ===\n", i);
wait(1.0);
}
pc.printf("micro:bit runtime DAL version %s\n", MICROBIT_DAL_VERSION);
#endif
// Bring up our nested heap allocator.