Vault 7: Projects
This publication series is about specific projects related to the Vault 7 main publication.
} >reset
The code in this section generates a "goto __reset" instruction located in the "reset" memory section. This will cause the
CPU to jump to the boot loader startup code after any device reset. This is common code that is present in any default linker
script for PIC24F.
2) The second section is the IVT. In the IVT we need to jump to the user's remapped IVT table.
__APP_IVT_BASE = 0x1400;
.ivt __IVT_BASE :
{
LONG(ABSOLUTE(__APP_IVT_BASE) + 0x004); /* __ReservedTrap0*/
LONG(ABSOLUTE(__APP_IVT_BASE) + 0x008); /* __OscillatorFail*/
LONG(ABSOLUTE(__APP_IVT_BASE) + 0x00C); /* __AddressError*/
LONG(ABSOLUTE(__APP_IVT_BASE) + 0x010); /* __StackError*/
LONG(ABSOLUTE(__APP_IVT_BASE) + 0x014); /* __MathError*/
...
LONG(ABSOLUTE(__DEFAULT_VECTOR)); /* __Interrupt116 not implemented */
LONG(ABSOLUTE(__DEFAULT_VECTOR)); /* __Interrupt117 not implemented */
} >ivt
This linker code will place the _APP_IVT_BASE constant + an offset address at each of the IVT vector entries. This will
cause the CPU to jump to the specified vector in the user's remapped IVT table.
Note that each entry is 4 bytes away from the previous entry. Is is because the resulting remapped IVT will need to use
"goto" instructions at each entry in order to reach the desired handler. The "goto" instruction takes two instruction words at 2
bytes of memory address each.
3) Section (3), the AIVT, is either not used or is used by the boot loader and shouldn't be used by the application. If the boot
loader requires interrupts, then it uses the AIVT and switches to AIVT interrupts before starting and switches back to the IVT
before jumping to the customer code. No linker modifications are required here. For boot loaders that don't require interrupts,
some have the AIVT section removed since they are not remapped to the user space and not used by the boot loader.
4) Section (4), the boot loader code - the only modification required in the linker script for the boot loader code is the
changes to the memory region definitions discussed previously in the Memory Region Definitions section.
5) Section (5) is the user remapped reset. This is the address where the boot loader jumps upon completion. This address
needs to be at a fixed location in code that both the boot loader and the application know about. At this address there needs
to be a jump to the user application code. In the application linker script:
.application_ivt __APP_IVT_BASE :
{
SHORT(ABSOLUTE(__reset)); SHORT(0x04); SHORT((ABSOLUTE(__reset) >> 16) & 0x7F);
SHORT(0);
SHORT(DEFINED(__ReservedTrap0) ? ABSOLUTE(__ReservedTrap0) :
ABSOLUTE(__DefaultInterrupt)); SHORT(0x04); SHORT(DEFINED(__ReservedTrap0) ?
(ABSOLUTE(__ReservedTrap0) >> 16) & 0x7F : (ABSOLUTE(__DefaultInterrupt) >> 16) & 0x7F);
SHORT(0);
SHORT(DEFINED(__OscillatorFail) ? ABSOLUTE(__OscillatorFail) :
ABSOLUTE(__DefaultInterrupt)); SHORT(0x04); SHORT(DEFINED(__OscillatorFail) ?
(ABSOLUTE(__OscillatorFail) >> 16) & 0x7F : (ABSOLUTE(__DefaultInterrupt) >> 16) & 0x7F);
SHORT(0);
SHORT(DEFINED(__AddressError) ? ABSOLUTE(__AddressError) :
ABSOLUTE(__DefaultInterrupt)); SHORT(0x04); SHORT(DEFINED(__AddressError) ?
(ABSOLUTE(__AddressError) >> 16) & 0x7F : (ABSOLUTE(__DefaultInterrupt) >> 16) & 0x7F);
SHORT(0);
This section of code has been added to the default linker script. This creates a section in code located at __APP_IVT_BASE
address. In this case the __APP_IVT_BASE address is also defined in the application linker file:
__APP_IVT_BASE = 0x1400;
This address must match exactly between the boot loader code, boot loader linker file, and the application linker file. If any of
these do not match then the linkage between the interrupt remapping or reset remapping will not work and the application
will fail to run properly.
The first entry in this table is the user remapped reset. This code generates a "goto __reset" at address __APP_IVT_BASE.
This allows the boot loader to jump to this fixed address to then jump to the start of the user code (located at the __reset
label).
1.6 Demos MLA - USB Library Help Device - Boot Loader - HID
264
Protego_Release_01_05-Related-OEM-Documentation-MLA_v2013_12_20-help_mla_usb.pdf