2008-11-06 10:17 PM
STR912Fxxx -Boot Bank switching using J-Link (IAR IDE)
2011-05-17 12:54 AM
STR912Fxxx -Boot Bank switching using J-Link (IAR System)
Step 1:- Down load SEGGER J-Link ARM v3.84 and install in your PC. Link: Open J-Link STR9 commander: 1) Using: Setb 1 - command you can configure CS1 (bank1 as a Boot bank). 2) Using: Show conf - command you can verify the current boot bank setting. Step 2:- Understand the memory map of STR912. Before boot bank remapping:- 1) Default memory Boot Bank 0 (512kB) from 0x0 to 0x7FFFF 2) Bank 1 (32kB) above the 512k. After boot bank 1 remap:- 1) Default memory Bank 0 (512kB) from 0x80000 to 0xFFFFF 2) Boot bank 1 (32kB) from 0x0 to 0x7FFF. Note in between 0x7FFF to 0x80000 memory reserved. Step 3:- In Boot loader what we should do in code. 1) init.s - file you replace the following code section. /*******************Added By Murugan.P on 19/06/2008***************************/ ;Boot bank 1(32kb 0x0 to 0x7FFF) as a boot bank. ;Non boot bank 0 (0x80000 to 0xFFFFF) as a Non boot bank. /******************************************************************************/ LDR R6, =0x54000000 ;boot bank size LDR R7, =0x0 STR R7, [R6] LDR R6, =0x54000004 ; non boot bank size LDR R7, =0x6 ; 512K STR R7, [R6] LDR R6, =0x5400000C ; boot bank address = Bank 1 LDR R7, =0x0 ; 0x0 STR R7, [R6] LDR R6, =0x54000010 ; non boot bank address = Bank 0 LDR R7, =0x20000 ; 0x10000 = 4x 0x4000 STR R7, [R6] LDR R6, =0x54000018 ; enable Non Boot bank LDR R7, =0x18 STR R7, [R6] 2) Enable following this line in fmi.h file /* ========================================================================== */ /* When bank 1 is remapped at address 0x0, decomment the following line */ /* ========================================================================== */ #define Remap_Bank_1 /*Enabled by Murugan.p*/ Step 4:- In User application what we need to modify:- Compile the user application code in default memory 512 kb location (default memory 512k boot bank (0x0 to 0x7FFFF) location). Before compilation we need to comment the PLL configuration and boot bank and non boot bank base address configuration section in the user application code init.s file. Generate the Hex.file. Step 5:- After the bank switch while writing the user application Hex.file into Non Boot Bank-0 512k location you should add 0x80000 and write in appropriate location. For example: Our default vector address resides in the location form 0x00000000 to 0x00000178 am I right? While writing the non boot bank 0 512kb location Write Address=0x80000 | 0x00000000; indeed of 0x0 data you should write 0x80000 location. ;;;;;;;;;;;;; Write Address=0x80000 | 0x00000178; indeed of 0x0 data you should write 0x80178 location. ;;;;;;;;;;;;; so on…oK Step 6:- While executing our application just call the bellow mentioned ram location function. void __ramfunc APP_Execut (void) { pFunction JumpTo; // before change mapping, disable all VIC ints VIC0->INTECR = 0xff; VIC1->INTECR = 0xff; // Change mapping: // bank1 (32K) starting addr 0 -> 0x40.0000 // bank0 (512K) starting addr 0x40.0000 -> 0 // Bank1 is still the boot bank, this does not change. FMI->BBADR = BOOT_BANK_ADD; //0x400000 >> 2; FMI->NBBADR = NONBOOT_BANK_ADD; //0x0 ; // Jump to the user application and execute it JumpTo = (pFunction)0x00; JumpTo(); } With this configuration application user code will work without any problem. If its works if the problem solved say thanks to God……..Ok Step 7:- If any problem or your user application is not running you do one thing just after executing the APP_Execut (); function just stop the Execution without killing the program you should save the memory from 0x0 to 0x7FFF using memory save option. Now you can compare your user application hex file with above memory saved hex file it should be same ok2011-05-17 12:54 AM
Hi!
Can I use this example as DFU bootloader, I mean, in user mode, calling that function on point 6 switch the banking and reset. On boot I will start executing from boot 1, right? and how to switch back to the normal behaviour? Thanks