8. Build the Demo

The application project comes with two pre-configured launchers: one to launch the application on the simulator and the other one to compile the application for the i.MX RT595 EVK Rev. C1.

8.1. Build on Simulator

  1. Right-click on com.microej.demo.watch.vglite project.
  2. Click on Run as > MicroEJ Application.
  3. Select Demo (Sim).
  4. Click on OK.

Before launching the application, some generators are running (image and font generators). Then application on the simulator starts.

=============== [ Initialization Stage ] ===============
=============== [ Converting fonts ] ===============
=============== [ Converting images ] ===============
=============== [ Launching on Simulator ] ===============
../_images/player.png

Another window appears: it is a mock which allows you to change some data like heart rate value. This mock is connected on corresponded application services. When the service is interrogated, the mock returns an adequate answer.

../_images/wearable_mock.png

Note

The mock is embedded in the platform. However, it is possible to compile again a new mock. Please consult chapter Wearable Mock.

8.2. Build on Device

8.2.1. BSP Connection

The platform has been designed to copy its files (platform header files, platform C archive, and compiled application C archive) into a compatible BSP. The application launcher for the embedded device must be first configured to target the BSP for the i.MX RT595 EVK Rev. C1 (this BSP is available in the package) before launching the application compilation.

Note

Retrieve more information about BSP connection here.

Follow the next steps to configure the launcher for the embedded device:

  1. Go to the unzipped package folder: [root]/bsp/mimxrt595_freertos-bsp.
  2. This folder is the BSP project root folder; copy the full path of this folder.
  3. Open MicroEJ SDK.
  4. Open menu Run > Run Configurations....
  5. From the list on the left, select launcher Demo (Emb).
  6. Open the Configuration tab.
  7. Go to the item Device > Deploy.
  8. Scroll to see the last text field (3rd-party BSP project) and paste the BSP project root folder’s full path.
  9. Click on Apply.
  10. Click on Close.

Note

The embedded launcher is now configured to target the BSP project. No need to configure it again.

The following error occurs when the launcher for embedded is executed without BSP configuration:

=============== [ Initialization Stage ] ===============

FAIL
Please specify the BSP project location (application option 'deploy.bsp.root.dir'), or disable option 'deploy.bsp.microejapp'.

8.2.2. Evaluation License

The platform requires a MicroEJ Evaluation License to compile the application for the embedded device. To install a license, launch the application compilation: follow same steps as the simulator (select Demo (Emb) instead of Demo (Sim)):

  1. Right-click on com.microej.demo.watch.vglite project.
  2. Click on Run as > MicroEJ Application.
  3. Select Demo (Emb).
  4. Click on OK.

The execution starts and stops abruptly; the following trace is displayed:

=============== [ Initialization Stage ] ===============
Platform connected to BSP location '[...]\mimxrt595_freertos-bsp' using application option 'deploy.bsp.root.dir'.
[INFO ] Launching in Evaluation mode. Your UID is 0123456789ABCDEF.

[ERROR] Invalid license check (No license found).

FAIL
Java returned: -1

This trace mentions the Machine UID (0123456789ABCDEF). The MicroEJ licenses server requires this code to generate a license for your computer.

  1. Copy the Machine UID.
  2. Go to https://license.microej.com.
  3. Click on Create a new account link.
  4. Create your account with a valid email address. You will receive a confirmation email a few minutes after. Click on the confirmation link in the email and login with your new account.
  5. Click on Activate a License.
  6. Set Product P/N: to 9PEVNLDBU6IJ.
  7. Set UID: to the UID you copied before.
  8. Click on Activate.
  9. The license is being activated. You should receive your activation by email in less than 5 minutes. If not, please contact support@microej.com.
  10. Once received by email, save the attached zip file that contains your activation key.
  11. Create the direcory C:\Users\%USERNAME%\.microej\licenses (launch Windows Command Prompt and type command mkdir C:\Users\%USERNAME%\.microej\licenses).
  12. Copy the license zip file in this directory.

MicroEJ Evaluation License is now installed in your environment. You can relaunch the compilation for the device (see next chapter).

8.2.3. Compile Application

This chapter considers the two mandatory steps BSP Connection and Evaluation License have been performed.

  1. Right-click on com.microej.demo.watch.vglite project.
  2. Click on Run as > MicroEJ Application.
  3. Select Demo (Emb).
  4. Click on OK.

Before compiling the application, some generators are running (image and font generators). Then the application is compiled (SOAR, partial link) and deployed in the BSP project (deployment).

=============== [ Initialization Stage ] ===============
Platform connected to BSP location '[...]\mimxrt595_freertos-bsp' using application option 'deploy.bsp.root.dir'.
[INFO ] Launching in Evaluation mode. Your UID is 0123456789ABCDEF.
=============== [ Converting fonts ] ===============
=============== [ Converting images ] ===============
=============== [ Launching SOAR ] ===============
=============== [ Launching Link ] ===============
=============== [ Deployment ] ===============
MicroEJ files for the 3rd-party BSP project are generated to '[...]\com.microej.demo.watch.vglite\com.microej.Main\platform'.
The MicroEJ application (microejapp.o) has been deployed to: '[...]\mimxrt595_freertos-bsp\projects\microej\platform\lib'.
The MicroEJ platform library (microejruntime.a) has been deployed to: '[...]\mimxrt595_freertos-bsp\projects\microej\platform\lib'.
The MicroEJ platform header files (*.h) have been deployed to: '[...]\mimxrt595_freertos-bsp\projects\microej\platform\inc'.
=============== [ Completed Successfully ] ===============

SUCCESS

As described, the platform files (header files and platform C archive) and compiled application C archive are available in the application temporary folder ([...]\com.microej.demo.watch.vglite\com.microej.Main\platform) and copied too in BSP project.

8.2.4. Compile BSP

The BSP project available in the package is already configured to compile its C files against the platform header files and to link against platform and application archives.

  1. Unplug the board.
  2. Ensure JP18 and JP19 are closed.
  3. Change DIP switches (SW7) to OFF,OFF,ON (ISP0,ISP1,ISP2).
  4. Plug a USB cable on J40.
../_images/cmsis.jpg
  • Open IAR project [root]/bsp/mimxrt595_freertos-bsp/projects/microej/iar/microej_freertos.eww.
  • Click on Project > Make.
  • After the link step, click on Project > Download > Download Active Application to download the application on the device.
  • After the download step, press the Reset button to start the application.
../_images/board-flower.jpg

Note

The BSP project is configured to deploy the application using CMSIS-DAP. See BSP project options to select JLink or another probe.

8.2.5. Compile Additional Watchface

The application (also called kernel) is designed to load additional watchfaces (also called features). A feature has to be compiled against the kernel.

  1. Open com.microej.demo.watch.watchface.simple project.
  2. Right click on the Java file com.microej.demo.watch.watchface.simple.SimpleWatchfaceEntryPoint.
  3. Click on Run as > Run Configurations...; a new window appears.
  4. Click on top-left button New launch configuration:
../_images/compile_feature_1.png
  1. A new launcher called SimpleWatchfaceEntryPoint is created and automatically filled:
../_images/compile_feature_2.png
  1. Open the Execution tab.
  2. Select Execute on Device and Build Dynamic Feature as Settings.
../_images/compile_feature_3.png
  1. Open the Configuration tab and open the menu Feature > Dynamic Download.
  2. Browse to select the kernel output file (ELF file: microej_freertos.out) generated by IAR.
../_images/compile_feature_4.png
  1. Click on Run.

The simple watchface is compiled against the kernel.

=============== [ Initialization Stage ] ===============
=============== [ Converting fonts ] ===============
=============== [ Converting images ] ===============
=============== [ Launching SOAR ] ===============
=============== [ Completed Successfully ] ===============

SUCCESS

A feature file (.fo) is generated in simple watchface project:

../_images/compile_feature_5.png

8.2.6. Deploy Additional Watchface

Each new watchface (feature) must be deployed individually by programming the feature loader buffer (located in RAM at address 0x20480000) with the feature file (.fo).

The feature loader buffer can be written by any means. The only restriction is that the feature file first four bytes must only be written after the rest of the file (the kernel considers a new feature is available as soon as it detects the first four bytes).

The kernel displays the following message on debug console once it is ready to receive a new feature:

Waiting for a feature to be available

At this time, the kernel is waiting for a new feature on the Debug Console Serial Port.

To deploy the new feature with the Serial Port connection, just have to send the feature file, as it is, in binary format to the serial COM port used for the Debug Console. Most hyper terminals don’t have the send file in the binary format feature. Most of them, while sending a file, decode the feature file byte as Unicode characters, and this corrupts the data transfer.

Use HTerm software http://der-hammer.info/pages/terminal.html that implements that feature correctly.

  1. Connect Hterm to the board’s Debug Console Serial Port by selecting the correct COM port (115200 bauds, 8N1).
  2. Click on Send file and select the feature file (.fo).
  3. Start the deployment by clicking on Start.
../_images/Hterm_send_file.png

As soon as the transfer starts, a message with the number of bytes transferred appears in the console log. The end of the transfer is automatically detected when no more bytes are transmitted. Then the kernel detects the new feature and, if it is valid, installs it. Finally, the kernel switches to it.

Transferred bytes: 1024
Transferred bytes: 2048
[...]
Transferred bytes: 449536
Transferred bytes: 449990
Transfer is over
Application available. Loading application.
Waiting for an application to be available
[WF Registry] Adding SimpleWatchface
[WF Registry] Stopping FlowerWatchface
[WF Registry] Starting SimpleWatchface

Note

The new watchface is deployed in RAM. A board reset removes the watchface.

8.2.7. Deployment Issues

  • Large feature file

    The feature file (.fo) cannot be higher than the feature loader buffer (see Limitations). In that case, the reception is automatically interrupted, and the kernel tries to install the feature.

    The following exception is thrown when the kernel is not able to install the feature:

    Exception in thread "Thread1" ej.kf.IncompatibleFeatureException
    
  • Low power

    In some situations (i.e., in the watchface carousel or a low-power watchface is running), the system can be asleep in DeepSleep mode (see Power Management). In that case, the bytes transmitted to the COM serial port are skipped.

    Workarounds:

    • Switch to a watchface or a permanently active application.
    • Send some characters to the serial COM port to wake up the system. The following message is displayed when the system is ready to receive a new feature during the next ten seconds:
    Awake from deep sleep for 10 seconds
    
  • Incompatible Feature

    A feature has to be compiled for a dedicated kernel. As soon as the kernel is built, the feature must be built and deployed again.

    The following exception is thrown when the kernel is trying to install a feature that is not compatible with it:

    Exception in thread "Thread1" ej.kf.IncompatibleFeatureException
    

8.3. Wearable Mock

8.3.1. Description

The wearable mock is used for the simulation of the application. It allows you to change heart rate and power level to simulate hardware sensors.

../_images/wearable_mock.png

The user can dynamically change the heart rate in two modes: by zone and by value. When the by value mode is selected, the slider sets the heart rate value. On the other hand, when by zone mode is selected, the heart rate will be automatically updated by picking a random value between Low and High bounds.

The power level value can be changed by moving the slider. When the Charge mode is selected, the power level will increase by two percent every five seconds, whereas the value will decrease by one percent every second if the Discharge mode is selected. The slider is automatically updated to follow charge or discharge.

8.3.2. Setup

The mock source files are available in the packaging. This project allows building the mock (for instance, changing behavior, a widget, etc.). To install it in your workspace, follow these steps:

  • Go to the unzipped package folder: [root]/application/.
  • Copy the full path of the file mock-src.zip available in this folder.
  • Open MicroEJ SDK.
  • Open menu File > Import....
  • Go to the item General > Existing Projects into Workspace.
  • Click on Next >.
  • Select radio button Select archive file.
  • Paste the mock-src.zip full path and press Enter (or browse to select it from the file system).
  • Ensure project com.microej.demo.watch.mock is checked.
  • Click on Finish.

8.3.3. Build and Use

The next steps explain how to build the mock and how to add in the MicroEJ platform for i.MX RT595 EVK Rev. C1:

  • Select the project (click on it): com.microej.demo.watch.mock
  • Click on the blue button (like platform build). The new mock is built and pushed into your repository.
  • Build again the platform (see Platform Build).
  • Launch the application on the new platform. The new mock is now used.

Note

The mock is embedded in the MicroEJ platform because the platform configuration project expresses the dependency <dependency transitive="false" org="com.microej.demo.watch.imxrt595" name="mock" rev="..." />.

8.3.4. Use without Building

Another solution to use easily your mock available in your workspace is to enable an option in your MicroEJ preferences.:

  • Open menu Window > Preferences > MicroEJ > Settings
  • Check the option Resolve Foundation Library in workspace.
  • Click on Apply and Close.
  • Launch the application on the platform. The new mock is now used.

This tip prevents building the mock and the platform. Source files are directly used.