Running code in RAM from FLASH (PowerPC 8270)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Running code in RAM from FLASH (PowerPC 8270)

4,410件の閲覧回数
peperson
Contributor I
I'm running the code from FLASH currently, but want to speed things up by copying the code to RAM at boot up and executing there. What do I have to change in the CodeWarrior project settings and/or linker file to have the boot code in FLASH copy the executable to RAM and jump there?

My current .lcf file is:

MEMORY
{
SDRAM: org = 0x00000000, len = 0x02000000 // 32 Meg
IMMR: org = 0x04700000, len = 0x00020000 // 128 K
LBUS_SDRAM: org = 0xD0000000, len = 0x00800000 // 8 Meg
FLASH: org = 0xFF000000, len = 0x01000000 // 16 Meg

rom: org = 0xFFF00100, len = 0x000FFF00 /* Flash */
ram: org = 0x00100000, len = 0x00100000 /* SDRAM */
kernel_data: org = 0x00200000, len = 0x00A00000 /* SDRAM */
pflash: org = 0x00C00000, len = 0x00400000 /* 4 MB */

}

SECTIONS
{

GROUP : {

.code (TEXT) :
{

* (.vector0100)
. = ALIGN(0x100);
* (.vector0200)
. = ALIGN(0x100);
* (.dsExcpt)
. = ALIGN(0x100);
* (.isExcpt)
. = ALIGN(0x100);
* (.vector0500)
. = ALIGN(0x100);
* (.vector0600)
. = ALIGN(0x100);
* (.vector0700)
. = ALIGN(0x100);
* (.vector0800)
. = ALIGN(0x100);
* (.vector0900)
. = ALIGN(0x100);
* (.vector0A00)
. = ALIGN(0x100);
. = . +0x100;
* (.vector0C00)
. = ALIGN(0x100);
. = . +0x300;
* (itlb_miss)
. = ALIGN(0x100);
* (dtlb_miss_load)
. = ALIGN(0x100);
* (dtlb_miss_store)
. = ALIGN(0x100);
* (.vector1300)
. = ALIGN(0x100);
* (.vector1400)
. = ALIGN(0x100);
. = . +0x1B00;
* (DISPATCH)
* (IPSUM)
* (.text)
* (.eini)
* (.fini)
* (.init)
* (tlb_data_violation)
* (tlb_inst_violation)
}
.ctors (CONST) : {}
.dtors (CONST) : {}
.rodata (CONST) : {
*(.rdata)
*(.rodata)
}
extab : {}
extabindex : {}

} > rom

GROUP : {
.data : {}
.sdata : {}
.sbss : {}
.sdata2 : {}
.sbss2 : {}
.bss : {}

} > ram

flashp (TEXT) : {tc_flash.o} > pflash
}

__DEFAULT_PROCESSOR_NUMBER = 1;
__KERNEL_DATA_VERIFY_ENABLE = 0;

__SDRAM_BASE = ADDR(SDRAM);
__SDRAM_SIZE = SIZEOF(SDRAM);

__IMMR_BASE = ADDR(IMMR);
__IMMR_SIZE = SIZEOF(IMMR);

__LBUS_SDRAM_BASE = ADDR(LBUS_SDRAM);
__LBUS_SDRAM_SIZE = SIZEOF(LBUS_SDRAM);

__FLASH_BASE = ADDR(FLASH);
__FLASH_SIZE = SIZEOF(FLASH);

_stack_addr = ADDR(ram) + SIZEOF(ram);
__SP_INIT = ADDR(ram) + SIZEOF(ram);
_stack_end = _stack_addr - 0x1000;

__KERNEL_DATA_START = ADDR(kernel_data);
__KERNEL_DATA_END = ADDR(kernel_data) + SIZEOF(kernel_data) - 1;

/* EOF */
ラベル(1)
タグ(1)
0 件の賞賛
1 返信

1,059件の閲覧回数
Teo
NXP Employee
NXP Employee
You can do this similar with how RW data are handled in your .lcf.
i.e. place the sections that are going to be relocated in RAM in a separate group and put them in "ram" memory segment. e.g.

GROUP : {
.text (TEXT) : {}
.rodata (CONST) : {
*(.rdata)
*(.rodata)
}
} > ram

Note that relocation is handled by runtime start-up code. So be sure not to put the runtime start-up code to be relocated also. Usually this code is placed in ".init" section.

You can verify where the code will be relocated by the .MAP file generated by linker. Look for "Memory map" section. You should see a table similar with the following:

Starting Size File ROM RAM Buffer
address Offset Address Address
.reset fff00000 00001fd8 00000340 fff00000 fff00000
.init fff01fd8 00000618 00002318 fff01fd8 fff01fd8
.text 00100000 00004604 00002930 fff025f0 fff025f0
.rodata 00104608 00000a58 00006f38 fff06bf8 fff06bf8
.....

"ROM address" column - where it will be flashed
"Starting address" column - where it will be relocated.

Warning: a code will safely run only from "starting address" addresses, so do not expect the relocated functions to execute properly from flash.

Additional thing to know, the software/auto breakpoints can be put in the relocated code only after relocation has been done. To overcome this limitation, I would recommend to put a hardware breakpoint at "main" and only after that activate the rest of software breakpoints.

Regards,
Teodor Madan
0 件の賞賛