cancel
Showing results for 
Search instead for 
Did you mean: 

ST92F150 changing flash sectors

scott239955
Associate II
Posted on October 15, 2004 at 07:48

ST92F150 changing flash sectors

7 REPLIES 7
scott239955
Associate II
Posted on May 17, 2011 at 11:36

I use an ST92F150 with 128K flash and have been using Flash sector 2 (FLASH2) for my code (.text). I am running out of space and wanted to use sector 3 (FLASH3), but when I change the linker file the firmware does not run. Everything compiles ok and the emulator does not complain, but nothing seems to run on the application board. The change I was making is

.text : { *(.text) } > FLASH3

Is there something else I should do to get this to work? I will also eventually need to change the .rodata from FLASH0 because it is getting full and I need to add a bootloader. I attached the linker file and the emulator map file. I used the default memory map for the emulator (I think) and then added some user space for the external RAM. Also, if anyone sees anything wrong with these files, I would appreciate comments about that.

I added the memory map ouput file (reduced to one page by remove specific information) from my_project.map - I thought the information my help find a solution.

[ This message was edited by: Smiles on 14-08-2004 21:54 ]

I found some additional information - The code jumps to main ok and does initalization, but gets lost and somehow halts the program shortly after interrupts are enabled ei(); Should I do something with the interrupt vectors? They work ok when FLASH2 sector is used for code.

[ This message was edited by: Smiles on 17-09-2004 23:54 ]

eticasas
Associate II
Posted on May 17, 2011 at 11:36

hello smiles

My be you have an undefined or wrong ISR (Interrupt Segment Register).

Before enabling interrupt you must set ISR to point to the segment containing the interrupt VECTOR table and interrupt service routines.

Because you have interrupt VECTOR table and .init in the same sector (FLASH3)

(and your code jumps to main in FLASH3 ok) you can simply make ISR=CSR adding the instructions in crtBegin.spp before call main function

spp #MMU_PG

ld ISR,CSR ;make ISR to point to FLASH3 (current CSR)

spp #0

_call M_(main)

good luck.

scott239955
Associate II
Posted on May 17, 2011 at 11:36

I found some additional information - The code jumps to main ok and does initialization, but gets lost and somehow halts the program shortly after interrupts are enabled ei(); Should I do something with the interrupt vectors? They work ok when FLASH2 sector is used for code. I am now currently out of FLASH in sector FLASH2 and really need to get it in FLASH3.

siegmund
Associate II
Posted on May 17, 2011 at 11:36

hello smiles,

since here is really bad support from st-engineers, i will try to help you.

when you relocated your code to flash3, you have to relocate your interrupt-vector-table to flash3, too. normallly it is located at flash0.

even top-level-IR, DIV-BY-ZERO and all the others, too.

then it should work.

good luck.
scott239955
Associate II
Posted on May 17, 2011 at 11:36

Thank you for helping. I first tried setting the ISR register just before the call to main() as mentioned:

spp MMU_PG

ld ISR,CSR ;make ISR to point to FLASH3 (current CSR)

spp 0

When this did not work, I looked at R248, the ISR, and it was still zero so I used this line instead to set it to 1:

ld ISR,SEG(0x010000) ;make ISR to point to FLASH3

However, I still could not run the application. I'm wondering if the other initalization startup code needs to be in the 1st section and so it does not work when putting everything (.init and .text) in the 2nd sector (FLASH3). The vector table just contains the offset address, but the other .init stuff may need to be in the beginning of flash memory. Or maybe I'm wrong? To do this I think I need to

(1) Take the vector table out of the same section as the other .init stuff and put it in FLASH3, leaving the other .init stuff in FLASH0.

or

(2) Put the ISR code in FLASH0 along with the .init stuff and ISR table, but leave the other code in FLASH3.

I have been trying to do this but do not sure how and am having problems. Does what I said seem correct? Thanks again for your help.

eticasas
Associate II
Posted on May 17, 2011 at 11:36

hello smiles

Looking at your .ld file the running design use FLASH0 and FLASH1 both in segment 0 (first 64 Kbyte) and probably you are

using compact memory model.

Move both FLASH0 and FLASH1 in FLASH3 using the same memory models is easy and add 8Kbyte

to your code space.

1) I suggest you to merge interrupt vector table in crtbegin.spp (there is a place for this)

2) Change in your .ld file FLASH0 and FLASH1 -> FLASH3 (.init from crtbegin must be the first)

3) You need a small code to load in FLASH0 only to jump to __Reset in FLASH3

/******************************/

#include ''config.spp''

PROGRAMMING_MODEL

.section .initF0, ''ax''

.word ResetF0

.word 0xFFFF

.word 0xFFFF

.word 0xFFFF ; No change this

.word 0xFFFF

ResetF0:

jps seg(__Reset), sof(__Reset)

/******************************/

4)

Add

.initF0 : { *(.initF0) } > FLASH0

to .ld file :

5)

Make ISR to point to FLASH3 adding the instructions in crtBegin.spp before call main function

spp #MMU_PG

ld ISR,CSR ; This must work if .init is in FLSH3

spp #0

_call M_(main)

6)

Probably Linker will produce a warning because you are using compact memory model and code is in 2 segment (.initF0) this is normally

That's all.

********

Moving only FLASH2 to FLASH3 my require to change memory model if you need to call something from FLASH0 to FLASH3 and viceversa.

Good Luck

scott239955
Associate II
Posted on May 17, 2011 at 11:36

Hi Saverio,

Thank you again. Because I have 128K external RAM I am using the medium memory model with unmapped data objects. I gave up trying to move the vector table to the second flash sector (FLASH3) and ended up separating my interrupt vector service code (not table) into another section and put it in the 1st flash sector (FLASH0) along with the interrupt vector table and startup code. I put the rest of my code in FLASH3. I did this before I got your suggestion. Eventually, I need to get a bootloader working so I may need to revisit this issue. I ended up with:

FLASH0 : ORIGIN = 0x000000, LENGTH = 8K, MMU = IDPR2

FLASH1 : ORIGIN = 0x002000, LENGTH = 8K

FLASH2 : ORIGIN = 0x004000, LENGTH = 48K, MMU = IDPR1

FLASH3 : ORIGIN = 0x010000, LENGTH = 64K

EEPROM : ORIGIN = 0x220000, LENGTH = 1K

FPROT : ORIGIN = 0x231FFC, LENGTH = 4

RAM : ORIGIN = 0x200000, LENGTH = 6K, MMU = IDPR3

EXT_RAM0 : ORIGIN = 0x300000, LENGTH = 16K

EXT_RAM1 : ORIGIN = 0x304000, LENGTH = 16K

EXT_RAM2 : ORIGIN = 0x308000, LENGTH = 16K

EXT_RAM3 : ORIGIN = 0x30C000, LENGTH = 16K /* 64K of EXT RAM */

EXT_RAM4 : ORIGIN = 0x310000, LENGTH = 16K

EXT_RAM5 : ORIGIN = 0x314000, LENGTH = 16K

EXT_RAM6 : ORIGIN = 0x318000, LENGTH = 16K

EXT_RAM7 : ORIGIN = 0x31C000, LENGTH = 16K /* 128K of EXT RAM */

REGFILE (t) : ORIGIN = 0x00, LENGTH = 208

.init : { *(.init) } > FLASH0

.interrupt_code : { *(.isr_code) } > FLASH0

.text : { *(.text) } > FLASH3

.fini : { *(.fini) } > FLASH0

.secinfo : { CREATE_SECINFO_TABLE } > FLASH0

.rodata : { *(.rodata) } > FLASH2

Thanks