2.10.2 Application Example
The Demo Meter application includes an example showing how to use the ICM to easily increase and improve the security and reliability regarding the metrology library binary loading process and the IRAM1 (where the metrology library runs) content integrity. The example can be easily modified to consider additional memory regions.
The example is enabled or disabled by means of the preprocessor directive “#define ICM_MONITORING”, located in the “config_demo_app.h” file. To change the default behavior (ICM monitoring enabled), simply comment the directive, compile the project, then download it to the evaluation board (refer to 3 Debug and Modify the Demo Meter Application for additional information).
- First, the ICM is configured to compute the Hash of the region of the Flash memory containing the metrology library binary. The Hash is saved in “met_lib_bin_sha”.
- Then, the ICM is re-configured to continuously monitor the region of the IRAM1, where the metrology binary was copied from the Flash. This procedure is computing the Hash of the proper IRAM1 region, which is saved in “iram1_sha”, and then re-computing continuously the Hash and comparing it with the one saved in “met_lib_bin_sha”. If a mismatch happens, an interrupt is triggered.
- By doing this, the application is able to detect:
- That the data in IRAM1 corresponds to the binary stored in Flash, meaning that the copy from Flash to IRAM1 was completed successfully and that no other data was written in IRAM1.
- That the IRAM1 content does not change.