Memory Configuration#
The following are a few important key points related to SiWG917 memory configuration.
It is recommended to set the MEMORY_CONFIG bit in the ext_custom_feature_bit_map in the sl_wifi_device_configuration_t.
If DMA is used, 1 KB of memory goes to UDMA.
Linker File#
The linker file is a text file made up of a series of linker directives which tells the linker where the available memory is and how it should be used. Therefore, they reflect exactly the memory resources and memory map of the target microcontroller.
From the sections present in the linker file, it is important to know from where the configuration of the memory happens.
MEMORY#
The linker's default configuration permits allocation of all the available memory, including the flash and embedded SRAM. The ‘MEMORY’ command describes the location and size of memory blocks in the target. The linker file can have a MEMORY command, and there can be many memory regions defined within the MEMORY command.
The syntax of the MEMORY command is as follows,
MEMORY
{
name (attr) : ORIGIN = origin, LENGTH = len
...
}
name: defines the name of the regions that are referred by the GNU linker.
attr: defines the attributes of a particular memory region. The valid attribute should be made up of the options as mentioned in the following table (e.g., rwx):
Letter
Section Attribute
'R'
Read-only sections
'W'
Read/write sections
'X'
Sections containing executable code
'A'
Allocated sections
'I'
Initialized sections
'L'
Initialized sections
ORIGIN: specifies the start address of the memory region in the physical memory.
LENGTH: specifies the size of the memory region in bytes.
Example: This is one of the Memory section configurations of SiWG917, where ‘rom’ here refers to flash and ‘ram’ refers to SRAM.
LENGTH: section in RAM where we configure the memory configurations of SRAM. ORIGIN: section in ROM/RAM from where application flash address/SRAM address starts.
MEMORY
{
rom (rx) : ORIGIN = 0x8202000, LENGTH = 0x6e000
ram (rwx) : ORIGIN = 0x400, LENGTH = 0x30000
psram (rwx) : ORIGIN = 0xa000000, LENGTH = 0x800000
}
ENTRY (Reset_Handler)#
The ‘ENTRY’ command is used for defining the first executable instruction. The syntax of ENTRY command is as follows,
ENTRY (symbol)
The argument of the command is a symbol name. For example, the default GNU linker script of SiWG917’s (linkerfile_SoC.ld) defines the first executable instruction of the target as ‘Reset_Handler’. The symbol ‘Reset_Handler’ must be defined in the code.
What is Reset_Handler?
Reset is invoked on power up or a soft reboot. The exception model treats reset as a special form of exception. When reset is asserted, the operation of the processor stops potentially at any point in an instruction.
When reset is de-asserted, execution restarts from the address provided by the reset entry in the vector table, which is “Reset_Handler” in our example.
SECTIONS#
The ‘SECTIONS’ command maps the input sections to output sections, and the order of the output sections in memory. The linker file can only have one SECTIONS command but can have many statements within the SECTIONS command. The most frequently used statement in the SECTIONS command is the section definition, which specifies the properties of an output section (location, alignment, contents, fill pattern, and target memory region).
The syntax of a SECTIONS command is as follows.
SECTIONS
{
...
secname start BLOCK(align) (NOLOAD) : AT ( ldadr )
{ contents } > region :phdr =fill
...
}
The ‘secname’ and ‘contents’ are required for a section definition, others are optional.
secname | The name of the output |
---|---|
| Specifies the address that the output section will be loaded at. |
| Advances the location counter before the section begins so that the section starts at the specified alignment. |
| Marks a section to not be loaded at runtime. |
| Specifies the load address of the section to |
| Assigns this section to a defined region of memory. |
Below is the sample linker file of SiWG917 where all the above-explained sections are used. The definitions of above-mentioned sections in the sample linker file are explained below.
MEMORY
{
rom (rx) : ORIGIN = 0x8202000, LENGTH = 0x6e000
ram (rwx) : ORIGIN = 0x400, LENGTH = 0x30000
psram (rwx) : ORIGIN = 0xa000000, LENGTH = 0x800000
}
ENTRY(Reset_Handler)
SECTIONS
{
.text :
{
KEEP(*(.isr_vector))
KEEP(*(.reset_handler))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
KEEP(*(.eh_fram e*))
} > rom
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > rom
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > rom
Section | Definition |
---|---|
.text | The name of the section. |
special linker variable dot '.'` | Always contains the current output location counter. It can be used to get the end address of the vectors by referencing the dot '.' variable after |
'.ctors' | Section reserved for a list of constructors (initialization routines), including functions to initialize data when the program starts. |
'.dtors' | Section reserved for a list of destructors (termination routines) that should be called when the program terminates. For more information, refer to: https://gcc.gnu.org/onlinedocs/gccint/Initialization.html |
'> rom' | Assigns the |