How to Extract a Resource Into a Dedicated Memory Section

This tutorial is valid for architectures 7.x.

By default, all application resources are grouped in a single .rodata.resources section.

This tutorial describes how to extract a specific application resource into a custom memory section.

This tutorial is based on Example-NLS 5.0.0. The translations of the example will be extracted in a dedicated memory section.
The resource will be moved from internal flash memory to external QSPI flash memory.

1) Identify the symbol of the resource to relocate

The symbol of the resource to relocate can be found in the ApplicationResources section of the SOAR.map:

2) Extract the resource into a dedicated section

A custom link file needs to be added to the VEE Port to perform this extraction.

  • Create the following folder hierarchy in the -configuration project of the VEE Port:
    • -configuration/dropins/MICROJVM/link
  • Create a extractResource.lscf file inside the link/ folder.
  • Add the following content:
<lscFragment>
 	<defSection name=".rodata.myresource" start="0" end="0x7fffffff" align="16"/>
 	
	<memoryLayout ranges=".rodata.myresource" image="true">
		<sectionRef name="*" symbol="_java_rodata_resource_java_Pcom_microej_example_nls_generated_HelloWorldMessages.nls"/>
	</memoryLayout>
		
</lscFragment>
  • Note:
    • The name of the link file can be customized as long as the .lscf extension is kept.
    • .rodata.myresource is the custom section where symbols will be relocated.
    • Symbols to relocate in this section are listed inside memoryLayout.
    • More information about the MicroEJ Linker file format can be found at MicroEJ Linker — MicroEJ Documentation
  • The VEE Port and the application need to be rebuilt to apply changes.

3) Position the section in the third party linker file

Edit your third party linker file to position this section in the right memory.

For example:

place in QSPI_region        { section .rodata.myresource };

4) Check the resource relocation

The .map file generated by the C toolchain allows to check the correct relocation of the resource.

Before:

_java_rodata_resource_java_Pcom_microej_example_nls_generated_HelloWorldMessages.nls
                         0x800'7940    0xac  Data  Gb  microejapp.o [2]

After:

.rodata.myresource      ro code  0x9001'29e0      0xac  microejapp.o [2]

...

_java_rodata_resource_java_Pcom_microej_example_nls_generated_HelloWorldMessages.nls
                        0x9001'29e0    0xac  Data  Gb  microejapp.o [2]

Alex for MicroEJ

2 Likes