Hi!
Friedrich Lobenstock wrote on 19/01/08 03:11 MET:
>
> Basically my cheat lets msp430-jtag thinks it is programming real code not
> just the interrupt vectors at address 0xffe0.
Further investigation show that msp430-jtag scans the elf sections and only
progamms those with certain flags:
# grep -n -A5 "get sections relevant for the application" \
/usr/lib/python2.5/site-packages/mspgcc/elf.py
290: """get sections relevant for the application"""
291- res = []
292- for section in self.sections:
293- if section.sh_flags & ELFSection.SHF_ALLOC and
section.sh_type != ELFSection.SHT_NOBITS:
294- res.append(section)
295- return res
>From that above output we conclude that we need to take a look at the elf
section flags. Let's see which flags we currently got in our elf file
(output edited to fit into 75 chars per line):
# readelf -S testprogram
There are 6 section headers, starting at offset 0xbc:
Section Headers:
[Nr] Name ~ Flg Lk Inf Al
[ 0] ~ 0 0 0
[ 1] .text ~ AX 0 0 1
[ 2] .vectors ~ 0 0 1
[ 3] .shstrtab ~ 0 0 1
[ 4] .symtab ~ 5 10 4
[ 5] .strtab ~ 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
We see that only the .text section got the "Alloc" flag set.
Let us now put the puzzle together and change our program in the following
way when declaring the .vectors section:
; Interrupt Vector Table
.section .vectors, "a"
Note the added "Alloc" flag.
Now lets use msp430-jtag to first do a mass-erase and then program our file
again:
# msp430-jtag -D --lpt=/dev/ttyUSB0 --backend ti --spy-bi-wire -e
# msp430-jtag -D --lpt=/dev/ttyUSB0 --backend ti \
--spy-bi-wire -p testprogram
[...]
ELF section .text at 0xfc00 28 bytes
ELF section .vectors at 0xffe0 32 bytes
TODO list:
actionProgram
backend library version: 20107000
MSP430_Identify: Device type: 'MSP430F20x3'
Program...
60 bytes programmed.
Reset and release device...
Note the output of "ELF section ..." which shows that both the .text and
the .vectors section are programmed. The later is curricle for the start of
our program after a device reset.
--
MfG / Regards
Friedrich Lobenstock