[En-Nut-Discussion] branches/devnut_m3n: _vtable needs 512 Byte alignment

Ulrich Prinz uprinz2 at netscape.net
Wed Jul 20 23:59:55 CEST 2011



On 17.07.2011 15:49, Uwe Bonnes wrote:
> Hello,
> 
> _vtable in the linker script needs 512 Byte alignement
> 
> (from pm0056.pdf:) 4.4.4           Vector table offset register
> (SCB_VTOR) Bits 31:30 Reserved, must be kept cleared Bits 29:11
> TBLOFF[29:9]: Vector table base offset field. It contains bits [29:9]
> of the offset of the table base from memory address 0x00000000. When 
> setting TBLOFF, you must align the offset to the number of exception
> entries in the vector table. The minimum alignment is 128 words.
> Table alignment requirements mean that bits[8:0] of the table offset
> are always zero.
> 
> 
With my implementation two things are done:
The FLASH vtable is only used by its first two words to start the CPU.
The rest is code already.

The RAM vtable is initialized by the start up code and it is placed
right at the beginning of the SRAM0. So there is no alignment problem to
512byte pages.

> For the original linker script one doesn't notice, as _vtable is the
> first item in SRAM0. However if you want to run from SRAM, like with
> the linker script modified like below, _vtable may get placed
> inappropriate.
> 
> To not waste RAM space however, probably best is to place the
> _vtable definition first. The alignement directive should be changed
> however.

Ok, in a RAM configuration...

Add a compiler directive like DEBUG_RAM.
In the c Code add some #ifdef DEBUG_RAM to assign the interrupt table to
.isr_vector instead of .vtable
Exclude the original vtable assignment and the copy-over of stack
pointer and reset vector.

Now it could work already. As the linker script vtable is dynamically
reserved by the site the c-Code defines for the arra at that position,
it should work out of the box.

Ulrich



More information about the En-Nut-Discussion mailing list