📄 customizing_u-boot_for_your_own_board.html
字号:
SOBJS = $(LIB): .depend $(OBJS) $(AR) crv $@ $(OBJS) </pre><ul><li class="level1"><div class="li"> Modify config.mk to suit your memory layout. This file contains the start address of uboot. Typically the image will be built to reside at the upper part of memory.</div></li></ul><pre class="code text"># TEXT_BASE should be defined as the MAX_SDRAM Address - 256k bytes# 256k is defined as CFG_MONITOR_LEN in ./include/configs/<board>.h# TEXT_BASE was 0X07FC0000 for the stampTEXT_BASE = 0x03FC0000PLATFORM_CPPFLAGS += -I$(TOPDIR) </pre></div><h4><a name="additional_considerations" id="additional_considerations">Additional Considerations</a></h4><div class="level4"><p> You may need to adjust some other files to suit your board hardware. </p><ul><li class="level1"><div class="li"> Flash Access</div><ul><li class="level2"><div class="li"> Flash access is modified in a common file <strong>common/flash.c</strong></div></li><li class="level2"><div class="li"> This uses the <strong>flash_info_t *info</strong> structure</div></li></ul></li></ul><ul><li class="level1"><div class="li"> Memory Access and CPLD’s </div><ul><li class="level2"><div class="li"> These are set up in a file in the <strong>cpu/bf533</strong> directory.</div></li><li class="level2"><div class="li"> The file <strong>cpu/bf533/cpu.c</strong> defines Data and instruction CPLD’s</div></li></ul></li></ul><pre class="code text">#define SDRAM_EBIU (PAGE_SIZE_4MB | CPLB_WT | CPLB_L1_AOW | CPLB_USER_RD | CPLB_USER_WR | CPLB_SUPV_WR | CPLB_VALID | ANOMALY_05000158)#define SDRAM_IKERNEL (PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_LOCK) #define L1_DMEMORY (PAGE_SIZE_4KB | CPLB_L1_CHBL | CPLB_L1_AOW | CPLB_WT | CPLB_SUPV_WR | CPLB_USER_WR | CPLB_VALID | ANOMALY_05000158) #define L1_IMEMORY (PAGE_SIZE_1MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_LOCK) #define SDRAM_IGENERIC (PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID) icplb_table[16][2]={{0xFFA00000, L1_IMEMORY},{0x00000000, SDRAM_IKERNEL}, /*SDRAM_Page1*/{0x00400000, SDRAM_IKERNEL}, /*SDRAM_Page1*/#ifdef CONFIG_STAMP{0x07C00000, SDRAM_IKERNEL}, /*SDRAM_Page14*/#else{0x03C00000, SDRAM_IKERNEL}, /*SDRAM_Page14*/#endif {0x00800000, SDRAM_IGENERIC}, /*SDRAM_Page2*/{0x00C00000, SDRAM_IGENERIC}, /*SDRAM_Page2*/{0x01000000, SDRAM_IGENERIC}, /*SDRAM_Page4*/{0x01400000, SDRAM_IGENERIC}, /*SDRAM_Page5*/{0x01800000, SDRAM_IGENERIC}, /*SDRAM_Page6*/{0x01C00000, SDRAM_IGENERIC}, /*SDRAM_Page7*/{0x02000000, SDRAM_IGENERIC}, /*SDRAM_Page8*/{0x02400000, SDRAM_IGENERIC}, /*SDRAM_Page9*/{0x02800000, SDRAM_IGENERIC}, /*SDRAM_Page10*/{0x02C00000, SDRAM_IGENERIC}, /*SDRAM_Page11*/{0x03000000, SDRAM_IGENERIC}, /*SDRAM_Page12*/{0x03400000, SDRAM_IGENERIC}, /*SDRAM_Page13*/ </pre></div><!-- SECTION [3473-7726] --><h2><a name="u_boot_startup_sequence" id="u_boot_startup_sequence">U Boot Startup Sequence</a></h2><div class="level2"><p>The following sequence of files defines the startup sequence for U-boot</p><p> The start up sequence for the BF533 is as follows</p><pre class="code text">cpu/bf533/start.S : inits pll / sdram and relocates from flash to Ram enabled icache and dcache, sets up stack jumps to _start1 cpu/bf533/start1.S : completes init after relocate to ram calls board_init_f; lib_blackfin/board.c: runs **board_init_f** **board_init_r** to initialize the whole system and finally calls **main_loop** to run the boot command line parser </pre><pre class="code"> Specific Init functions and the files associated with them</pre><pre class="code text">init_IRQ() cpu/bf533/ints.c flash_init() drivers/cfi_flash.cenv_init() common/env_flash.cinit_baudrate() lib_blackfin/board.cserial_init() cpu/bf533/serial.cconsole_init_f() common/console.c display_banner() lib_blackfin/board.ccheckboard() board/stamp/stamp.ctimer_init() cpu/bf533/interrupts.c </pre></div><h4><a name="checking_the_startup_sequence" id="checking_the_startup_sequence">Checking the Startup Sequence</a></h4><div class="level4"><p> You can check this sequence using <strong>bfin-uclinux-objdump</strong> to disassemble object files</p><pre class="code text">__Check a particular file__ $ bfin-uclinux-objdump -D cpu/bf533/start.o | more Disassembly of section .text: 00000000 <_start>: 0: 20 e1 61 00 R0=0x61 (X); 4: ff e3 fe ff CALL 0 <_start>; 8: 90 61 R0=0x32(x); a: 10 3e SYSCFG=R0; c: 24 00 SSYNC; e: 01 60 R1=0x0(x); 10: 02 60 R2=0x0(x); 12: 03 60 R3=0x0(x); 14: 04 60 R4=0x0(x); 16: 05 60 R5=0x0(x); 18: 06 60 R6=0x0(x); 1a: 07 60 R7=0x0(x); __Check the u-boot elf image__ $ bfin-uclinux-objdump -D u-boot | more Disassembly of section .text: 03fc0000 <_start>: 3fc0000: 20 e1 61 00 R0=0x61 (X); 3fc0004: 00 e3 b2 06 CALL 3fc0d68 <putch>; 3fc0008: 90 61 R0=0x32(x); 3fc000a: 10 3e SYSCFG=R0; 3fc000c: 24 00 SSYNC; 3fc000e: 01 60 R1=0x0(x); 3fc0010: 02 60 R2=0x0(x); 3fc0012: 03 60 R3=0x0(x); 3fc0014: 04 60 R4=0x0(x); 3fc0016: 05 60 R5=0x0(x); </pre></div><!-- SECTION [7727-10154] --><h2><a name="adding_u-boot_commands" id="adding_u-boot_commands">Adding U-boot commands</a></h2><div class="level2"><p> You can create your own uboot commands.</p><p>The directory <strong>common</strong> contains the sources for many commands</p><p> Add the name of the new command file cmd_xxx.o file to the list of COBJS in <strong>common/Makefile</strong> to include additional objects in the u-boot image.</p><p> A command is added to the system at link time by adding some special code to a regular “C” file. You can specify a max number of arguments and if the command can be repeated or remembered by the system.</p><p>A remembered command will be repeated if a blank command is issued after the first instance of the command.</p><pre class="code c"><span class="co2">#include <common.h></span><span class="co2">#include <asm/blackfin.h></span><span class="co2">#include <command.h></span> U_BOOT_CMD<span class="br0">(</span> mycmd, <span class="co1">// name </span> <span class="nu0">2</span>, <span class="co1">// max args</span> <span class="nu0">1</span>, <span class="co1">// rep </span> do_mycmd, <span class="co1">// command function</span> <span class="st0">"mycmd - my test command <span class="es0">\n</span>"</span>, <span class="co1">// command usage</span> <span class="st0">" A test command example <span class="es0">\n</span>"</span> <span class="co1">// command help</span><span class="br0">)</span>;</pre><p>A typical command function is shown below. You will need to add code to interpret the command arguments.</p><pre class="code c"><span class="kw4">int</span> do_mycmd<span class="br0">(</span>cmd_tbl_t *cmdtp, <span class="kw4">int</span> flag, <span class="kw4">int</span> argc, <span class="kw4">char</span> *argv<span class="br0">[</span><span class="br0">]</span><span class="br0">)</span><span class="br0">{</span> <span class="co1">// flag used to hold system information ( not normally used )</span> <span class="co1">// argc = count of additional args</span> <span class="co1">// argv = list of commands</span> <span class="co1">//... add command code as required...</span> <span class="kw1">return</span> <span class="nu0">0</span>; <span class="co1">// if the command is OK</span><span class="br0">}</span></pre></div><!-- SECTION [10155-] --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -