cancel
Showing results for 
Search instead for 
Did you mean: 

booting from flash str7

prabath
Associate II
Posted on March 31, 2006 at 06:32

booting from flash str7

19 REPLIES 19
prabath
Associate II
Posted on March 05, 2006 at 19:36

Hi, I have got some test code running on str710FZ2. I have RVDK, currently I am running it on External memory. Program starts from address 0x000. It’s a simple program just print some txt through the rs

So in the project I defined the

Robase to 0x4000000

Rwbase to 0x2000000

Can some one give me the run down on how to program this in to flash. So I guess all I need to do is to put the code into flash and tell it to remap from flash?

I looked at the example code in 71x_init.s.

; define remapping

; If you need to remap memory before entring the main program

; uncomment next ligne

GBLL remapping ;p

; Then define which memory to remap to address 0x00000000

; Uncomment next line if you want to remap RAM

GBLL remap_ram

; Uncomment next line if you want to remap FLASH

; GBLL remap_flash ;p

; Uncomment next line if you want to remap the external memory

; GBLL remap_ext

ENTRY

EXPORT Reset_Handler

IMPORT T0TIMI_Addr

Reset_Handler

LDR pc, =NextInst

NextInst

NOP ; Wait for OSC stabilization

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

MSR CPSR_c, Mode_ABT:OR:F_Bit:OR:I_Bit

LDR SP, =ABT_Stack

MSR CPSR_c, Mode_UNDEF:OR:F_Bit:OR:I_Bit

LDR SP,= UNDEF_Stack

MSR CPSR_c, Mode_SVC:OR:F_Bit:OR:I_Bit

LDR SP, =RAM_Limit

; Uncomment next ligne if you need to reset all device pripherals

PERIPHERAL_INIT ; Reset all device peripherals

; Uncomment next ligne if you need to enable the EMI Bank 1

; EMI_INIT ; Initialize EIM Bank 1

;Uncomment next ligne if you need to initialize the EIC

EIC_INIT ; Initialize EIC

;******************************************************************************

;REMAPPING

;Description : Remapping memory whether RAM,FLASH or External memory

; at Address 0x0 after the application has started executing.

; Remapping is generally done to allow RAM to replace FLASH

; or EXTMEM at 0x0.

; the remapping of RAM allow copying of vector table into RAM

;******************************************************************************

IF :DEF: remapping

IF :DEF: remap_flash

MOV r0, FLASH_mask

ENDIF

IF :DEF: remap_ram

MOV r0, RAM_mask

ENDIF

IF :DEF: remap_ext

MOV r0, EXTMEM_mask

ENDIF

LDR r1, =CPM_Base_addr

LDRH r2, [r1, BOOTCR_off_addr]; Read BOOTCR Register

BIC r2, r2, 0x03 ; Reset the two LSB bits of BOOTCR

ORR r2, r2, r0 ; change the two LSB bits of BOOTCR

STRH r2, [r1, BOOTCR_off_addr]; Write BOOTCR Register

ENDIF

MSR CPSR_c, Mode_FIQ:OR:F_Bit:OR:I_Bit; Change to FIQ mode

LDR SP, =FIQ_Stack ; Initialize FIQ stack pointer

MSR CPSR_c, Mode_IRQ:OR:F_Bit:OR:I_Bit; Change to IRQ mode

LDR SP, =IRQ_Stack ; Initialize IRQ stack pointer

MSR CPSR_c, Mode_USR:OR:F_Bit:OR:I_Bit ; Change to User mode, disable IRQ and FIQ

LDR SP, =USR_Stack ; Initialize USR stack pointer

; MSR CPSR_c, Mode_SYS ; Change to System mode

; unable to change state from user mode ?

;if sys used insted of user do we stay in a privilaged mode

IMPORT __main

; --- Now branches to a C lib function that copies RO data from their

; load region to their execute region, create the RW and ZI regions

; then jumps to user C main program.

B __main ; Note : use B not BL, because an application will

; never return this way

LTORG

END

prabath
Associate II
Posted on March 06, 2006 at 18:09

What settings I use for Robase /Rwbase ?

daweiy
Associate II
Posted on March 06, 2006 at 19:06

In Zouhair's attatch scat file, Robase is 0x4000000 Rwbase is 0x2000000. You just build your project and load image to target then the RVDEBUG will inform you to flash image to flashrom or not. After flashing, just run it, be ware of your boot setting on board.

prabath
Associate II
Posted on March 06, 2006 at 22:28

thanks. I can write to flash now....

Is this settings correct?

FLASH_mask EQU 0x40000000 ; to remap FLASH at 0x0

RAM_mask EQU 0x20000000 ; to remap RAM at 0x0

EXTMEM_mask EQU 0x0003

I am confused.

aialinux
Associate II
Posted on March 06, 2006 at 23:03

How to load the program into ext flash ? I want to place RO code to ext flash, RW ZI to ext sram! And remap cpu sram to 0x00.

But i don't know how to modify the asm files.

[ This message was edited by: dom on 07-03-2006 03:35 ]

[ This message was edited by: dom on 07-03-2006 03:38 ]

daweiy
Associate II
Posted on March 06, 2006 at 23:18

Using the scat file, all readonly stuff plus 71x_vect.o and 71x_init.o be mapped to 0x40000000, is it your means Robase?

71x_vect.o locates in 0x400000000. All readwrite code and zero initiated code be mapped to 0x20000000, is it your means Rwbase?

FLASH_mask just used to config boot mode.0 for boot from flash.

FLASH_mask EQU 0x0000 ; to remap FLASH at 0x0

RAM_mask EQU 0x0002 ; to remap RAM at 0x0

EXTMEM_mask EQU 0x0003 ; to remap EXTMEM at 0x0

and

GBLL remapping

GBLL remap_flash

used to remap code after reset. So after below code,

IF :DEF: remapping

IF :DEF: remap_flash

MOV r0, #FLASH_mask

ENDIF

IF :DEF: remap_ram

MOV r0, #RAM_mask

ENDIF

IF :DEF: remap_ext

MOV r0, #EXTMEM_mask

ENDIF

LDR r1, =CPM_Base_addr

LDRH r2, [r1, #BOOTCR_off_addr]; Read BOOTCR Register

BIC r2, r2, #0x03 ; Reset the two LSB bits of BOOTCR

ORR r2, r2, r0 ; change the two LSB bits of BOOTCR

STRH r2, [r1, #BOOTCR_off_addr]; Write BOOTCR Register

ENDIF

You can see the content in 0x00000000 changed to the contents in 0x40000000(flash rom).

[ This message was edited by: dawei on 07-03-2006 03:53 ]

aialinux
Associate II
Posted on March 07, 2006 at 02:46

Oh yes!

But I want to place the code RO to ext flash 0x60000000,RW an ZI to ext sram 0x62000000,and remap cpu sram 0x20000000 to 0x00000000.

aialinux
Associate II
Posted on March 07, 2006 at 08:00

If i remap cpu sram 0x20000000 to 0x00,I must copy the vectors table to cpu sram?

How to do it Iam newbie to ARM!

I just want to port ucos to my board.But when i place the RO code to ext flash 0x60000000, RW ZI to ext sram 0x62000000,vectors to cpu sram 0x20000000 and remap to 0x0000, The example can't run. I don't know why. Anybody has port ucos succeed?

[ This message was edited by: dom on 07-03-2006 12:38 ]

aialinux
Associate II
Posted on March 07, 2006 at 16:19

Oh I see. Thank you Zouhai.