Critical Issue
This issue affects code intended to execute in place in flash
by using alt_load()
to copy writable sections to RAM.
If an ELF section (for example .bss
) is to be copied from
flash to RAM using alt_load()
, the software build tools
verify that the section fits in RAM but not that it fits in the
flash memory that it will be programmed in. The tools generate a
programming file without any indication of a code size error.
This issue is more likely to affect you if your target memory
is the MAX 10 onchip flash, which is relatively small. This issue
only affects you if you are using alt_load()
.
You can manually determine whether your code fits by looking at the beginning of the .objdump file, created when you build your application. This file contains information that you can use to determine whether each section fits in your flash memory, as demonstrated in the following example.
The .objdump file is created in the application’s
top-level directory of the application. You can generate it from
the command line by typing make app
in the application
directory.
Near the top of the .objdump file is a list of sections similar to the following:
Sections: | ||||||
Idx | Name | Size | VMA | LMA | File off | Algn |
0 | .entry | 00000020 | 00028000 | 00028000 | 00001000 | 2**5 |
| | CONTENTS, ALLOC, LOAD, READONLY, CODE | ||||
1 | .exceptions | 00000220 | 00028020 | 00028020 | 00001020 | 2**2 |
| | CONTENTS, ALLOC, LOAD, READONLY, CODE | ||||
2 | .text | 00006504 | 00028240 | 00028240 | 00001240 | 2**2 |
| | CONTENTS, ALLOC, LOAD, READONLY, CODE | ||||
3 | .rodata | 0000005c | 00040000 | 0002e744 | 00008000 | 2**2 |
| | CONTENTS, ALLOC, LOAD, READONLY, DATA | ||||
4 | .rwdata | 00001b78 | 0004005c | 0002e7a0 | 0000805c | 2**2 |
| | CONTENTS, ALLOC, LOAD, DATA, SMALL_DATA | ||||
5 | .bss | 00000154 | 00041bd4 | 00030318 | 00009bd4 | 2**2 |
| | ALLOC, SMALL_DATA |
Each section has values for size, VMA, and LMA. VMA is the runtime address, and LMA is the load address. If a section is not copied, VMA = LMA. If a section is copied, it is copied from LMA to VMA.
In this case, which uses alt_load()
, .entry
and .text
are
not copied (VMA = LMA). .rodata
, .rwdata
,
and .bss
are copied from a flash address (LMA) to a RAM
address (VMA).
The flash in this example has a range of 0x28000 to 0x30000.
The .rwdata
section is programmed to flash starting
at VMA = 0x2e7a0, and extends to VMA Size = 0x2e7a0 0x1b78 =
0x30518. Therefore it does not fit in flash.