Skip to content

Mbed DAL: Generation and Automation

Beate Jost edited this page Mar 24, 2023 · 8 revisions

This text describes the process of generating the Device Abstraction Layer (DAL) for Calliope Mini boards for the Open Roberta Lab.

Workflow

This is the complete workflow for integrating new upstream releases.

Currently, changes for ora-cc-rsc are found in branch feature/mbed-dal-automation. Until this pull request is merged with master, please checkout this branch and continue the steps mentioned for ora-cc-rsc.

There are two GitHub repositories,

This has to be done once. Now we start to work with repository microbit-dal.

  • fetch from upstream to your local workspace: git fetch upstream
  • select the tag <tag-name> we want to integrate into our repositories.
  • carry out the following steps to create the branch bluetooth-enabled:
       git checkout <tag-name>
       git branch -D bluetooth-enabled
       git checkout -b bluetooth-enabled
       <cherry-pick all of our commits from cherry-pick-branch, as of Feb 2023: 964cc99 5fcda9f a261ea6 56faa04 1240746 e74d99c 3719c64 835e4cc
       <cherry-pick the topmost commit from cherry-pick-bluetooth-enabled, as of Feb 2023: d702ae64bd>

    Note the marker in the commit history for cherry-pick-branch that indicates the commits to be cherry picked.

  • carry out the following steps to create the branch bluetooth-disabled:
       git checkout <tag-name>
       git branch -D bluetooth-disabled
       git checkout -b bluetooth-disabled
       <cherry-pick all of our commits from cherry-pick-branch, as of Feb 2023 see above>
       <cherry-pick the topmost commit from cherry-pick-bluetooth-disabled branch, as of Feb 2023: 3c19d98b43>
  • create and push two new tags to microbit-dal, using appropriate X, Y and Z values:
    • on the bluetooth-enabled branch vX.Y.Z-bluetooth-enabled.
    • on the bluetooth-disabled branch vX.Y.Z-bluetooth-disabled.

Now we start to work with repository microbit.

  • fetch from upstream to your local workspace: git fetch upstream
  • select the _same _tag <tag-name> as for microbit-dal.
  • carry out the following steps
       git checkout <tag-name>
       git branch -D develop
       git checkout -b develop
       <cherry-pick all of our commits from cherry-pick-branch, as of Feb 2023: 2485e9a 55f6185>
       git push origin

    Note the marker in the commit history for cherry-pick-branch that indicates the commits to be cherry picked. It may be possible to set-upstream and to force. Be very careful!

Go to GitHub and execute the GitHub action release.yml on the microbit repository to generate the release. The release name should typically contain the same version numbering as the microbit-dal repository to maintain uniformity between the two repositories.

Next, update pom.xml in ora-cc-rsc to reflect the correct release name in microbit repository. Finally, run mvn clean install in ora-cc-rsc to fetch and generate the directory libs2017 for RobotMbed. This fetches the release from microbit repository and contains all resources the integrate the resources from the Calliope tag into the OpenRoberta lab.

Notes

  • there are two folders in RobotMbed, libs2016 and libs2017. libs2016 is for compatibility with older devices, whereas libs2017 is for newer devices. We update libs2017 only.

  • the lib files (.a) for libraries in the RobotMbed\libs2017 folder are created by the script compileLibrary.sh from ora-cc-rsc. Currently, we're using the following additional libraries: FourDigitDisplay, Grove_LED_BAR and Sht31.

  • the script is to be run as follows: ./compileLibrary.sh <compiler> <library_name> <library_location> <compiler_resources>

  • in Feb 2023 we have used the tag v2.2.0-rc6-calliope.rc3-iss0.3.

  • changes (found in the cherry-pick branch) made by us are primarily in the following files:

    • MicroBitCompat.h and MicroBitCompat.cpp
    • CalliopeRGB.h and CalliopeRGB.cpp
    • MicroBitAccelerometer.h and MicroBitAccelerometer.cpp
    • MicroBitCompass.h and MicroBitCompass.cpp
    • MicroBitDisplay.h and MicroBitDisplay.cpp
    • ManagedString.h and ManagedString.cpp
    • MicroBitImage.h and MicroBitImage.cpp
  • in the microbit repository, there is a dependency on microbit-dal that needs to be updated in module.json. This is done in our GitHub action.

  • in the past, we have created a sequence of commits to change the two repositories. Not all old commits are put into the new cherry-pick branch. Below is a list of our old commits, along with reasoning why they were (not) cherry picked:

  • microbit-dal

    Commit hash Commit description Cherry picked (Y/N) Files updated Remarks
    cdbbbddb OpenRoberta/robertalab#335 added animate images function to the dal Y MicroBitDisplay (.h and .cpp) -
    241a87f9 create ManagedString from decimal number Y MicroBitCompat (.h and .cpp), ManagedString (.h and .cpp) -
    0900013f display decimal only when have number larger then 0 after decimal point Y MicroBitCompat.cpp, ManagedString.cpp -
    74b7ae58 OpenRoberta/robertalab#375 bug fix for animateImages Y MicroBitDisplay (.h and .cpp) -
    87845cea Merge remote-tracking branch 'upstream/master' N - Merge commit; we already have the upstream commits
    9041448e Merge remote-tracking branch 'upstream/master' N - Merge commit; we already have the upstream commits
    7d7977a3 create managed string from unsigned long Y MicroBitCompat (.h and .cpp), ManagedString (.h and .cpp) -
    6f1202d5 bump version N - Version update to module.json
    615d46c1 Merge remote-tracking branch 'upstream/master' N - Merge commit; we already have the upstream commits
    13b63732 add function for finding element occurrence in array Y MicroBitCompat (.h and .cpp), MicroBitDisplay (.h and .cpp) -
    8a64765c #433 bump version for adding find element in array N - Version update to module.json
    fb5e9dc9 OpenRoberta/robertalab#410 add support for strength of acceleration Y MicroBitAccelerometer (.h and .cpp) Removed MicroBitAccelerometer-bmx (.h and .cpp) from commit, since it is not used anymore
    94c792c2 OpenRoberta/#410 add shifting image functionality Y MicroBitImage (.h and .cpp) -
    450eaaa5 OpenRoberta/#410 add invert operation on image Y MicroBitImage (.h and .cpp) -
    4f3645d7 bump version for supporting shift and invert of a function N - Version update to module.json
    36d57eaa OpenRoberta/robertalab#462 add color type to microbit-dal Y CalliopeRGB (.h and .cpp), MicroBitColor (.h and .cpp) -
    0c88f7e6 bump version for added MicroBitColor type N - Version update to module.json
    908a7c18 Merge remote-tracking branch 'upstream/master' N - Merge commit; we already have the upstream commits
    fb977862 bump version for fixing compass N - Version update to module.json
    48c40e6b OpenRoberta/robertalab#510 implement != operator for ManagedStrings Y ManagedString (.h and .cpp) -
    85484d64 bump version for supporting Managed String comparation N - Version update to module.json
    8e0946f1 switched starting polarity of pulses for motor, so different values could be used for duty percentage Y CalliopeSoundMotor.cpp -
    378b591c overriding slow speeds to kill the going to 100 on other motor bug Y CalliopeSoundMotor.cpp -
    4f77e2be #542 bump version of micrbit-dal N - Version update to module.json
    6313b616 #542 forgot semicolon Y CalliopeSoundMotor.cpp -
    3a4ed829 #536 #535 normalised microphone values 0-100 and added read pulse Y MicroBitPin (.h and .cpp) -
    70f6e092 #536 535 bump microbit version (or6) N - Version update to module.json
    320219ae fixed timepulse OpenRoberta/robertalab#536 runtime->pulsetime Y MicroBitPin.cpp -
    9ff266bd bump microbit-dal version N - Version update to module.json
    40b08c65 OpenRoberta/robertalab#571 math on list implementation Y MicroBitCompat.h Exclude module.json from the commit
    803bce63 OpenRoberta/roberatlab#803 add isPrime and isWhole functions Y MicroBitCompat (.h and .cpp) Exclude module.json from the commit
    2d2b4dd1 OpenRoberta/robertalab#335 added animate images function to the dal N - Same as commit cdbbbddb
    a9fba22f create ManagedString from decimal number N - Same as commit 241a87f9
    8ec94169 display decimal only when have number larger then 0 after decimal point N - Same as commit 0900013f
    0a3215d4 OpenRoberta/robertalab#375 bug fix for animateImages N - Same as commit 74b7ae58
    2cb019e4 create managed string from unsigned long N - Same as commit 7d7977a3
    b1868cd0 bump version N - Same as commit 6f1202d5
    7f747e0e add function for finding element occurrence in array N - Same as commit 13b63732
    9703dc3f #433 bump version for adding find element in array N - Same as commit 8a64765c
    3cbe2fce OpenRoberta/robertalab#410 add support for strength of acceleration N - Same as commit fb5e9dc9
    8b8ff8f3 OpenRoberta/#410 add shifting image functionality N - Same as commit 94c792c2
    00488be2 OpenRoberta/#410 add invert operation on image N - Same as commit 450eaaa5
    dda6e254 bump version for supporting shift and invert of a function N - Same as commit 4f3645d7
    e3858315 OpenRoberta/robertalab#462 add color type to microbit-dal N - Same as commit 36d57eaa
    bc2d46de bump version for added MicroBitColor type N - Same as commit 0c88f7e6
    ae77a277 bump version for fixing compass N - Same as commit fb977862
    a5a913a6 OpenRoberta/robertalab#510 implement != operator for ManagedStrings N - Same as commit 48c40e6b
    e9d250ce bump version for supporting Managed String comparation N - Same as commit 85484d64
    e0b0a0d6 switched starting polarity of pulses for motor, so different values could be used for duty percentage N - Same as commit 8e0946f1
    9f25ad5f overriding slow speeds to kill the going to 100 on other motor bug N - Same as commit 378b591c
    d6bf00a1 #542 bump version of micrbit-dal N - Same as commit 4f77e2be
    eb68f81d #542 forgot semicolon N - Same as commit 6313b616
    48628b9d #536 #535 normalised microphone values 0-100 and added read pulse N - Same as commit 3a4ed829
    3557e0ba #536 535 bump microbit version (or6) N - Same as commit 70f6e092
    dd7359c3 fixed timepulse OpenRoberta/robertalab#536 runtime->pulsetime N - Same as commit 320219ae
    e74789a5 bump microbit-dal version N - Same as commit 9ff266bd
    c76c895a OpenRoberta/robertalab#571 math on list implementation N - Same as commit 40b08c65
    e2dd07b5 OpenRoberta/roberatlab#803 add isPrime and isWhole functions N - Same as commit 803bce63
    9395adc7 rebasing with fork N - Merge commit; we already have the upstream commits
    e561adc1 bump version N - Version update to module.json
    5c977506 update to v2.1.1 N - Merge commit; we already have the upstream commits
    34dadb22 fix bugs from merging with upstream N - Did not merge manually, so no bug to fix
    786f2444 add missing setColour function implementation Y CalliopeRGB.cpp -
    e986dbca bump the version to 2.1.2 N - Version update to module.json
  • microbit

    Commit hash Commit description Cherry picked (Y/N) Files updated Remarks
    2457e287 bump to latest 2017 version N - Version update to module.json
    c7b5ddfd bump version N - Version update to module.json
    e5470fd3 Merge remote-tracking branch 'upstream/master' N - Merge commit; we already have the upstream commits
    4cfc182b #433 bump version for adding find element in array N - Version update to module.json
    09bf0ebe bump version for supporting shift and invert of a function N - Version update to module.json
    17d73ca3 OpenRoberta/robertalab#462 add color type to microbit-dal Y MicroBit.h -
    f40b5657 bump version for added MicroBitColor type N - Version update to module.json
    7f23702d sync fork N - Merge commit; we already have the upstream commits
    c72e4239 bump version for fixed compass sensor N - Version update to module.json
    857bcdb4 bump version for supporting Managed String comparation N - Version update to module.json
    e7ae444e #542 bump version of micrbit-dal N - Version update to module.json
    f23c3b75 #536 535 bump microbit version N - Version update to module.json
    a58e8979 bump microbit version N - Version update to module.json
    bc4a31d9 bump version N - Version update to module.json
    88f9f2a5 bump version N - Version update to module.json
    7dd5f3a1 OpenRoberta/roberatlab#803 add isPrime and isWhole functions N - Version update to module.json
    f9a60f55 bump to latest 2017 version N - Same as commit 2457e287
    aa51278f bump version N - Same as commit c7b5ddfd
    512db4bc #433 bump version for adding find element in array N - Same as commit 4cfc182b
    e87d734e bump version for supporting shift and invert of a function N - Same as commit 09bf0ebe
    0f028f3c OpenRoberta/robertalab#462 add color type to microbit-dal N - Same as commit 17d73ca3
    45076518 bump version for added MicroBitColor type N - Same as commit f40b5657
    b5aaa8bf bump version for fixed compass sensor N - Same as commit c72e4239
    82085757 bump version for supporting Managed String comparation N - Same as commit 857bcdb4
    b7a04c7e #542 bump version of micrbit-dal N - Same as commit e7ae444e
    b1743c4c #536 535 bump microbit version N - Same as commit f23c3b75
    d6b88b7f bump microbit version N - Same as commit a58e8979
    0accddb9 bump version N - Same as commit bc4a31d9
    dc0500dd bump version N - Same as commit 88f9f2a5
    eb18c2a0 OpenRoberta/roberatlab#803 add isPrime and isWhole functions N - Same as commit 7dd5f3a1
    f2476ef4 updated microbit-dal version N - Merge commit; we already have the upstream commits
    d3d6432c update to version 2.1.1 N - Merge commit; we already have the upstream commits
    b1868cd0 bump the version to 2.1.2 N - Version update to module.json
  • yotta is needed to build the source code, as outlined here.

    • microbit-dal:
yotta target calliope-mini-classic-gcc@https://github.com/calliope-mini/target-calliope-mini-classic-gcc
yotta --config=./config.json build
  • microbit:
yotta target calliope-mini-classic-gcc@https://github.com/calliope-mini/target-calliope-mini-classic-gcc
yotta build
  • the target embedded device can be found in yotta registry. For calliope-mini, yotta registry usage is deprecated (see https://support.microbit.org/support/solutions/articles/19000123284-arm-yotta-registry-deprecation). We have to use a new target embedded device, found at calliope-mini-classic-gcc@https://github.com/calliope-mini/target-calliope-mini-classic-gcc

  • Execute the following commands from cloned microbit-dal directory:

  • the directory structure after successful running of the two commands is:

    image

  • the resources built by yotta are found in the yotta_modules folder, to be copied to the RobotMbed/libs2017 folder, found in ora-cc-rsc.

  • The static libraries (.a files in Ubuntu), found in the following directories, need to be copied to RobotMbed/libs2017 folder, found in ora-cc-rsc:

    image

  • The generated static libraries for Bluetooth enabled devices need to be renamed as follows:

    • microbit-dal.a => microbit-dal-b.a
    • mbed-classic.a => mbed-classic-b.a

Testing

Now we need to check whether device specific functions still work in the new release.

Testing Radio

Following tests have been performed successfully:

To test the two radio programs, upload the programs to two Calliope Minis, one for transmission and one for reception. The program is as follows:

  • Both programs start with showing string "Hallo!".
  • Next, the display shows a beating heart, wherein images of a heart are shown. This is repeated 3 times to simulate a heartbeat.
  • After clearing the display, the LED shows red, orange, yellow, green and blue with an interval of 500 ms. These colours are defined in a variable called colours.
  • Next, the LED is switched off.
  • The display now shows a music symbol (beam note), and three notes (c', g and b') are played. The first two are quarter notes, and the last one is a half note.
  • The display is again cleared.
  • Next, the displays show an arrow, indicating the user needs to press a button. The program waits until this button has been pressed.
    • For radio_tx, this arrow points to the left, meaning button A needs to be pressed to continue. Upon pressing, a message "Hallo Roberta!" is transmitted.
    • For radio_rx, this arrow points to the right, meaning button B needs to be pressed to continue. Upon pressing, a string message should be received.
  • After transmitting and receiving, the display shows a check mark. This indicates the programs are over.

The programs run successfully, when the receiving Calliope Mini receives the string "Hallo Roberta!", thereby indicating that both transmission and reception work.

Testing Bluetooth connectivity

To test the program transfer, run a local instance of the server, then update Open Roberta Lab's default webpage (lab.open-roberta.org) address in your device's settings to that of the local server's IP.

  • on iOS devices, the following settings need to be updated:

    image Under section OPEN ROBERTA LAB, replace the url as follows: https://lab.open-roberta.org#loadSystem&&calliope2017 => http://:<port|default-1999>#loadSystem&&calliope2017

  • On Android devices, the following settings need to be updated:

    Click on the custom link icon (top right, wrench icon), replace the url with the following: http://:<port|default-1999>#loadSystem&&calliope2017

    Calliope Mini Android app does not seem to allow IP addresses as urls in custom links:

  • write and upload a test program.

  • Cross compiler tests found here should run. Note, that the generated .hex files are smaller in size compared to the ones generated with the old static libraries for all except math_lists cross compiler test:

    Filename File size (with old static libs, in kB) File size (with new static libs, in kB)
    action_sound 395 393
    actor_dualmotor_without_pin 401 398
    actor_fourdigitdisplay_without_pin 419 417
    actor_ledbar_without_pin 395 392
    actors_pins 398 396
    actors_singlemotor_and_motionkit_without_pins 400 398
    callibot 401 399
    control_logic 398 396
    math_lists 472 477
    messages 402 399
    motors 401 398
    radio_rx 409 406
    radio_tx 409 406
    sensor_pins 403 400
    sensors_all_without_pins_and_callibot_and_ultrasonic 443 441
    sensors_config_pin_pull 394 392
    sensor_ultrasonic_and_colourtcs3472 409 407
    text_colour_images_functions 413 411
Clone this wiki locally