Personal tools

Log in

Changes

From IGEP - ISEE Wiki

Jump to: navigation, search

The IGEP X-loader

10,696 bytes removed, 12:28, 3 March 2011
no edit summary
= BOOT<br> =
The IGEP X-Loader must reside in the microSD card or in the OneNand.<br>
== Low Level Initialization MMC Boot ==
The OMAP Processor loads the XLoader directly from the mmc or the OneNand and copy the binary into the internal processor RAM (0x40200000) and jump to this place, this internal memory it's limited to 64K divided as: Interrupts, code, data and stack. Initialization code can be found using this link: [http://git.igep.es/?p=pub/scm/igep-x-loader.git;a=blob;f=cpu/omap3/start.S;hPrepare the microsd card ==4cbf4379b8502ebfe0409b35e4aafba712234c34;hb=HEAD start.S]&nbsp; <pre>&nbsp; 96 reset: 97 /*
98 * set You can follow this howto about how [[ http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat|prepare the cpu to SVC32 modemicrosd card]].
99 */
100 mrs r0,cpsr
101 bic r0,r0,#0x1f  102 orr r0,r0,#0xd3  103 msr cpsr,r0  104   105 /* Copy vectors to mask ROM indirect addr */   106 adr r0, _start /* r0 &lt;- current position of code */  107 add r0, r0, #4 /* skip reset vector */  108 mov r2, #64 /* r2 &lt;- size to copy */  109 add r2, r0, r2 /* r2 &lt;- source end address */  110 mov r1, #SRAM_OFFSET0 /* build vect addr */  111 mov r3, #SRAM_OFFSET1  112 add r1, r1, r3  113 mov r3, #SRAM_OFFSET2  114 add r1, r1, r3  115 next:  116 ldmia r0!, {r3-r10} /* copy from source address [r0] */  117 stmia r1!, {r3-r10} /* copy to target address [r1] */  118 cmp r0, r2 /* until source end address [r2] */  119 bne next /* loop until equal */  120   121 bl cpy_clk_code /* put dpll adjust code behind vectors */  122   123 /* the mask ROM code should have PLL and others stable */  124 bl cpu_init_crit  &nbsp;125   126 relocate: /* relocate U-Boot to RAM */  127 adr r0, _start /* r0 &lt;- current position of code */  128 ldr r1, _TEXT_BASE /* test if we run from flash or RAM */  129 cmp r0, r1 /* no need to relocate if XIP */  130 beq stack_setup /* skip txt cpy if XIP(SRAM, SDRAM) */   131   132 ldr r2, _armboot_start  133 ldr r3, _bss_start  134 sub r2, r3, r2 /* r2 &lt;- size of armboot */  135 add r2, r0, r2 /* r2 &lt;- source end address */  136   137 copy_loop:  138 ldmia r0!, {r3-r10} /* copy from source address [r0] */  139 stmia r1!, {r3-r10} /* copy to target address [r1] */  140 cmp r0, r2 /* until source end addreee [r2] */  141 ble copy_loop  142   143 /* Set up the stack */  144 stack_setup:  145 ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */  146 sub sp, r0, #128 /* leave 32 words for abort-stack */  147 and sp, sp, #~7 /* 8 byte alinged for (ldr/str)d */  148   149 /* Clear BSS (if any). Is below tx (watch load addr - need space) */  150 clear_bss:  151 ldr r0, _bss_start /* find start of bss segment */  152 ldr r1, _bss_end /* stop here */  153 mov r2, #0x00000000 /* clear value */  154 clbss_l:  155 str r2, [r0] /* clear BSS location */  156 cmp r0, r1 /* are we at the end yet */  157 add r0, r0, #4 /* increment clear index pointer */  158 bne clbss_l /* keep clearing till at end */  159   160 ldr pc, _start_armboot /* jump to C code */  161   162 _start_armboot: .word start_armboot </pre> It's important take a lool to the call assembly function cpu_init_crit (you can see the code below) this is resposable to call the board initialization defined in [http://git.igep.es/?p=pub/scm/igep-x-loader.git;a=blob;f=board/igep0020/platform.S platform.S] file. Check the call to lowlevel_init:<br> <pre> 175 cpu_init_crit: 176 /*  177 * Invalidate L1 I/D  178 */  179 mov r0, #0 /* set up for MCR */  180 mcr p15, 0, r0, c8, c7, 0 /* invalidate TLBs */  181 mcr p15, 0, r0, c7, c5, 1 /* invalidate icache */  182   183 /* Invalide L2 cache (gp device call point)   184 * - warning, this may have issues on EMU/HS devices  185 * this call can corrupt r0-r5  186 */  187 mov r12, #0x1 @ set up to invalide L2   188 smi: .word 0xE1600070 @ Call SMI monitor  189   190 /*  191 * disable MMU stuff and caches  192 */  193 mrc p15, 0, r0, c1, c0, 0  194 bic r0, r0, #0x00002000 @ clear bits 13 (--V-)  195 bic r0, r0, #0x00000007 @ clear bits 2:0 (-CAM)  196 orr r0, r0, #0x00000002 @ set bit 1 (--A-) Align  197 #ifndef CONFIG_ICACHE_OFF  198 orr r0, r0, #0x00001800 @ set bit 11,12 (---I Z---) BTB,I-Cache  199 #endif  200 mcr p15, 0, r0, c1, c0, 0  201   202 /*  203 * Jump to board specific initialization... The Mask ROM will have already initialized  204 * basic memory. Go here to bump up clock rate and handle wake up conditions.  205 */  206 adr r0, _start /* r0 &lt;- current position of code */  207 ldr r1, _TEXT_BASE /* test if we run from flash or RAM */  208 cmp r0, r1 /* pass on info about skipping some init portions */  209 moveq r0,#0x1 /* flag to skip prcm and sdrc setup */  210 movne r0,#0x0  211   212 mov ip, lr /* persevere link reg across call */  213 bl lowlevel_init /* go setup pll,mux,memory */  214 mov lr, ip /* restore link */  215 mov pc, lr /* back to my caller */ </pre> Lowlevel_init it's responsable to set the stack settings and call the lowlevel board initialization called s_init "C" code defined in [http://git.igep.es/?p=pub/scm/igep-x-loader.git;a=blob;f=board/igep0020/igep0020.c here]<br> <pre> 171 .globl lowlevel_init 172 lowlevel_init:  173 ldr sp, SRAM_STACK  174 str ip, [sp] /* stash old link register */  175 mov ip, lr /* save link reg across call */  176 bl s_init /* go setup pll,mux,memory */  177 ldr ip, [sp] /* restore save ip */  178 mov lr, ip /* restore link reg */  179   180 /* back to arch calling code */  181 mov pc, lr   </pre> At the end and after the s_init call the code jump to initial C function called [http://git.igep.es/?p=pub/scm/igep-x-loader.git;a=blob;f=lib/board.c start_armboot] defined in the file lib/board.c.<br> <pre> 65 init_fnc_t *init_sequence[] = { 66 cpu_init, /* basic cpu dependent setup */ 67 board_init, /* basic board dependent setup */ 68 #ifdef CFG_NS16550_SERIAL 69 serial_init, /* serial communications setup */ 70 #endif 71 print_info, 72 nand_init, /* board specific nand init */ 73 #ifdef CONFIG_MMC 74 init_func_i2c, 75 #endif 76 NULL, 77 }; 78 79 void start_armboot (void) 80 { 81 init_fnc_t **init_fnc_ptr; 82 int i, size; 83 uchar *buf; 84 int *first_instruction; 85 block_dev_desc_t *dev_desc = NULL; 86 #ifdef CONFIG_ONENAND 87 unsigned int onenand_features; 88 #endif 89 /* Execute init_sequence */ 90 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { 91 if ((*init_fnc_ptr)() != 0) { 92 hang (); 93 } 94 } 95 96 /* Execute board specific misc init */ 97 misc_init_r(); 98 99 /* Initialize OneNand */ 100 onenand_init(); 101 102 /* Initialize MMC */ 103 mmc_init(1); 104 105 /* Load the Linux kernel */ 106 /* boot_linux() should never return */ 107 boot_linux(); 108 109 hang(); 110 }</pre> == C Execution Flow<br> == === s_init<br> === Function: [http://git.igep.es/?p=pub/scm/igep-x-loader.git;a=blob;f=board/igep0020/igep0020.c s_init]<br>  This function it's responsable to do the basic board (processor) initialization. It's called before the "C" generic initialization code.<br> <pre> 874 /********************************************************** 875 * Routine: s_init  876 * Description: Does early system init of muxing and clocks.  877 * - Called at time when only stack is available.  878 **********************************************************/  879 void s_init(void)  880 {  881 watchdog_init();  882 try_unlock_memory();  883 set_muxconf_regs();  884 delay(100);  885 prcm_init();  886 per_clocks_enable();  887 gpmc_init ();  888 config_multichip_package();  889 }   </pre> This function set the PLL clocks, MUX settings, GPMC configuration and memory configuration.  === cpu_init<br> === Function: [http://git.igep.es/?p=pub/scm/igep-x-loader.git;a=blob;f=cpu/omap3/cpu.c cpu_init]<br>  This function it's the responsable to do the CPU generic initialization and it's the first function called. <br>  === board_init<br> === Function: [http://git.igep.es/?p=pub/scm/igep-x-loader.git;a=blob;f=board/igep0020/igep0020.c board_init]<br>  This function it's defined per board and it's the responsable to initialize the board.  Initialization GPMC for access to LAN9221 Ethernet controller and initialization of malloc &amp; free algorithms (from here all code can use malloc &amp; free calls). <pre> 895 int board_init(void) 896 { 897 // Setup gpmc &lt;-&gt; Ethernet 898 setup_net_chip(is_cpu_family()); 899 // Setup Malloc memory 900 mem_malloc_init(XLOADER_MALLOC_IPTR, XLOADER_MALLOC_SIZE); 901 902 return 0; 903 }</pre> === serial_init<br> === Function:&nbsp;[http://git.igep.es/?p=pub/scm/igep-x-loader.git;a=blob;f=drivers/serial.c serial_init] This function initializes the serial driver.   === <br> <br> 4 Settings &amp; Configuration: ===
====== ================ ======