9. 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 MIMXRT595-EVK.
9.1. Build on Simulator
- Right-click on
com.microej.demo.watch.vglite
project. - Click on
Run as
>MicroEJ Application
. - Select
Demo (Sim)
. - 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 ] ===============
Two others windows appear:
- a wearable 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.
- a mock which allows you to declare a Wifi Access Point for the NTP time update. Changing this configuration requires a restart of the simulator.
Note
The wearable mock is embedded in the platform. However, it is possible to compile again a new mock. Please consult chapter Wearable Mock.
9.2. Build on Device
9.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 MIMXRT595-EVK (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:
- Go to the unzipped package folder:
[root]/bsp/mimxrt595_freertos-bsp
. - This folder is the BSP project root folder; copy the full path of this folder.
- Open MicroEJ SDK.
- Open menu
Run
>Run Configurations...
. - From the list on the left, select launcher
Demo (Emb)
. - Open the
Configuration
tab. - Go to the item
Device
>Deploy
. - Scroll to see the last text field (3rd-party BSP project) and paste the BSP project root folder’s full path.
- Click on
Apply
. - 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'.
9.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)
):
- Right-click on
com.microej.demo.watch.vglite
project. - Click on
Run as
>MicroEJ Application
. - Select
Demo (Emb)
. - 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.
- Copy the Machine UID.
- Go to https://license.microej.com.
- Click on
Create a new account link
. - 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.
- Click on
Activate a License
. - Set
Product P/N
: to9PEVNLDBU6IJ
. - Set
UID
: to the UID you copied before. - Click on
Activate
. - The license is being activated. You should receive your activation by email in less than 5 minutes. If not, please contact support@microej.com.
- Once received by email, save the attached zip file that contains your activation key.
- Create the direcory
C:\Users\%USERNAME%\.microej\licenses
(launch Windows Command Prompt and type commandmkdir C:\Users\%USERNAME%\.microej\licenses
). - 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).
9.2.3. Compile Application
This chapter considers the two mandatory steps BSP Connection and Evaluation License have been performed.
- Right-click on
com.microej.demo.watch.vglite
project. - Click on
Run as
>MicroEJ Application
. - Select
Demo (Emb)
. - 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.
9.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.
- Unplug the board.
- Ensure JP18 and JP19 are closed.
- Change DIP switches (SW7) to OFF,OFF,ON (ISP0,ISP1,ISP2).
- Plug a USB cable on J40.
- 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.
Note
The BSP project is configured to deploy the application using CMSIS-DAP. See BSP project options to select JLink or another probe.
9.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.
- Open
com.microej.demo.watch.watchface.simple
project. - Right click on the Java file
com.microej.demo.watch.watchface.simple.SimpleWatchfaceEntryPoint
. - Click on
Run as
>Run Configurations...
; a new window appears. - Click on top-left button
New launch configuration
:
- A new launcher called
SimpleWatchfaceEntryPoint
is created and automatically filled:
- Open the
Execution
tab. - Select
Execute on Device
andBuild Dynamic Feature
asSettings
.
- Open the
Configuration
tab and open the menuFeature > Dynamic Download
. - Browse to select the kernel output file (ELF file:
microej_freertos.out
) generated by IAR.
- 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:
9.2.6. Deploy Additional Watchface
Each new watchface (feature) must be deployed individually by programming the feature loader buffer (located in RAM at address 0x20380000
) 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.
- Connect Hterm to the board’s Debug Console Serial Port by selecting the correct COM port (115200 bauds, 8N1).
- Click on
Send file
and select the feature file (.fo
). - Start the deployment by clicking on
Start
.
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.
9.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
Warning
Feature deployment is not available in the POWER_SAVING performance profile. Refer to Performance Profiles.
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
9.3. Wearable Mock
9.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.
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.
9.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 pressEnter
(or browse to select it from the file system). - Ensure project
com.microej.demo.watch.mock
is checked. - Click on
Finish
.
9.3.3. Build and Use
The next steps explain how to build the mock and how to add in the MicroEJ platform for MIMXRT595-EVK:
- 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="..." />
.
9.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.
9.4. WiFi Configuration Mock
The WiFi configuration mock allows the declaration of different WiFi Access Points that the application can connect.
Each Access Point has the following features:
- a SSID.
- a security access mode (Open, WPA1, WPA2 …).
- a passwork paraphrase if needed.
- a RSSID.
- a channel number.
- a WPS configuration.
- a BSSID.
The declared Access Points are saved and restored when the simulator is restarted.
- This mock comes with the NET foundation library and can not be modified.
- This mock will only pop up once the application starts to use the network library. If the NetTimeService is not used by the application, this mock will not appear.
- The simulator WiFi Configuration mock can not be used over a VPN network.