bbdjlinuxfans 发表于 2006-11-21 13:02:47

求教: 编译u-boot 启动基于S3C2410的开发板

有人试过编译U-BOOT 1.1.4以上的版本启动S3C2410/SMDK2410兼容的开发板吗? 我最近试着编译了U-BOOT-1.1.4, U-BOOT-1.1.5, U-BOOT-1.1.6和U-BOOT-2006-06-30-2020, 使用的开发板是成都博睿的MC2410A. MC2410A据说是基于S3C2410的, 只是成都博睿在S3C2410的基础上做了一点改动, 基本配置是ARM920T, 64MB SDRAM加64MB NAND FLASH, 没有NOR FLASH. MC2410A可以用VIVI BOOTLOADER启动. 但是我把编译好的u-boot.bin通过JTAG接口烧到NAND FLASH上以后, 关电源再加电却没有任何屏幕显示 (我是通过串口连接CONSOLE的). 我试过修改 u-boot/board/smdk2410/ 目录下的u-boot.lds, 把SECTIONS{…}里的第一行 “. = 0x…” 改成0x33f80000, 0x33f00000或0x00000000, 都没有用. 我也试过用 vivi/arch/s3c2410/ 目录下的head.S 完全替换 u-boot/cpu/arm920t/ 下的start.S, 看看起始于”_start:”的这段汇编代码在u-boot.bin能否被硬件识别, 但还是什么反应都没有 (我在这段汇编代码里插入了汇编打印语句向串口输出调试信息, 在VIVI中编译后是能够正常打印的). 我没有修改任何Makefile或config.mk, 不知道是否和Makefile的设置有关. 哪位大侠能帮我看看顺便指点一下, 我先谢谢了.

以下是我用来替换u-boot/cpu/arm920t/start.S 的vivi/arch/s3c2410/head.S. 在VIVI下编译是可以正常启动的, 放在U-BOOT里就没反应了.

/*
* vivi/arch/s3c2410/head.S:
*   Initialise hardware
*
* Copyright (C) 2001 MIZI Research, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
*
*
* Author: Janghoon Lyu <[email protected]>
* Date: $Date: 2003/02/26 10:38:11 $
*
* $Revision: 1.18 $
*
*
* History:
*
* 2002-05-14: Janghoon Lyu <[email protected]>
*   - Initial code
*
*/

#include "linkage-vivi.h"

@ Start of executable code

ENTRY(_start)
ENTRY(ResetEntryPoint)

@
@ Exception vector table (physical address = 0x00000000)
@

@ 0x00: Reset
        b        Reset

@ 0x04: Undefined instruction exception
UndefEntryPoint:
        b        HandleUndef

@ 0x08: Software interrupt exception
SWIEntryPoint:
        b        HandleSWI

@ 0x0c: Prefetch Abort (Instruction Fetch Memory Abort)
PrefetchAbortEnteryPoint:
        b        HandlePrefetchAbort

@ 0x10: Data Access Memory Abort
DataAbortEntryPoint:
        b        HandleDataAbort

@ 0x14: Not used
NotUsedEntryPoint:
        b        HandleNotUsed

@ 0x18: IRQ(Interrupt Request) exception
IRQEntryPoint:
        b        HandleIRQ

@ 0x1c: FIQ(Fast Interrupt Request) exception
FIQEntryPoint:
        b        HandleFIQ

@
@ VIVI magics
@

@ 0x20: magic number so we can verify that we only put
        .long   0
@ 0x24:
        .long   0
@ 0x28: where this vivi was linked, so we can put it in memory in the right place
        .long   _start
@ 0x2C: this contains the platform, cpu and machine id
        .long   0x010600C1
@ 0x30: vivi capabilities
        .long   0
@ 0x34:
        b        SleepRamProc

        .balignl 16,0xdeadbeef

_TEXT_BASE:
        .word        0x33f00000

.globl _armboot_start
_armboot_start:
        .word _start

/*
* These are defined in the board-specific linker script.
*/
.globl _bss_start
_bss_start:
        .word 0

.globl _bss_end
_bss_end:
        .word 0


@
@ Start VIVI head
@
Reset:
        /*
       * set the cpu to SVC32 mode
       */
        mrs        r0,cpsr
        bic        r0,r0,#0x1f
        orr        r0,r0,#0xd3
        msr        cpsr,r0
       
        @ disable watch dog timer
        mov        r0, #0x53000000
        mov        r1, #0x0
        str        r1,

        @ disable all interrupts
        mov        r0, #0x4A000000
        mov        r1, #0xffffffff
        str        r1,
        ldr        r1, =0x3ff
        str        r1,        

        @ initialise system clocks
        mov        r1, #CLK_CTL_BASE
        mvn        r2, #0xff000000
        str        r2,
       
        @ 1:2:4
        mov        r0, #0x4C000000
        mov        r1, #0x3
        str        r1,

        mrc        p15, 0, r1, c1, c0, 0                @ read ctrl register
        orr        r1, r1, #0xc0000000                @ Asynchronous
        mcr        p15, 0, r1, c1, c0, 0                @ write ctrl register

        @ now, CPU clock is 200 Mhz
        mov        r1, #CLK_CTL_BASE
        ldr        r2, mpll_200mhz
        str        r2,

        bl        memsetup

        @ All LED on
        mov        r1, #GPIO_CTL_BASE
        add        r1, r1, #oGPIO_F
        ldr        r2,=0x55aa
        str        r2,
        mov        r2, #0xff
        str        r2,
        mov        r2, #0x00
        str        r2,

        @ set GPIO for UART
        mov        r1, #GPIO_CTL_BASE
        add        r1, r1, #oGPIO_H
        ldr        r2, gpio_con_uart       
        str        r2,
        ldr        r2, gpio_up_uart
        str        r2,        
        bl        InitUART

#ifdef CONFIG_DEBUG_LL
        @ Print current Program Counter
        ldr        r1, SerBase
        mov        r0, #'\r'
        bl        PrintChar
        mov        r0, #'\n'
        bl        PrintChar
        mov        r0, #'@'
        bl        PrintChar
        ldr        r0, STR_OK
        ldr        r1, SerBase
        bl        PrintWord
        mov        r0, pc
        bl        PrintHexWord
#endif

        bl        copy_myself

        @ jump to ram
        ldr        r1, =on_the_ram
        add        pc, r1, #0
        nop
        nop
1:        b        1b                @ infinite loop

on_the_ram:

#ifdef CONFIG_DEBUG_LL
        ldr        r1, SerBase
        ldr        r0, STR_STACK
        bl        PrintWord
        ldr        r0, DW_STACK_START
        bl        PrintHexWord
#endif

        @ get read to call C functions
        ldr        sp, DW_STACK_START        @ setup stack pointer
        mov        fp, #0                        @ no previous frame, so fp=0
        mov        a2, #0                        @ set argv to NULL

        bl        main                        @ call main

        mov        pc, #0x00000000                @ otherwise, reboot

@
@ End VIVI head
@

/*
* subroutines
*/

@
@ Wake-up codes
@
WakeupStart:
        @ Clear sleep reset bit
        ldr        r0, PMST_ADDR
        mov        r1, #0x10
        str        r1,

        @ Release the SDRAM signal protections
        ldr        r0, PMCTL1_ADDR
        ldr        r1,
        bic        r1, r1, #((1 << 19) | (1 << 18) | (1 << 17))
        str        r1,

        @ Go...
        ldr        r0, PMSR0_ADDR        @ read a return address
        ldr        r1,
        mov        pc, r1
        nop
        nop
1:        b        1b                @ infinite loop

SleepRamProc:
        @ SDRAM is in the self-refresh mode */
        ldr        r0, REFR_ADDR
        ldr        r1,
        orr        r1, r1, #(1 << 22)
        str        r1,

        @ wait until SDRAM into self-refresh
        mov        r1, #16
1:        subs        r1, r1, #1       
        bne        1b

        @ Set the SDRAM singal protections
        ldr        r0, PMCTL1_ADDR
        ldr        r1,
        orr        r1, r1, #((1 << 19) | (1 << 18) | (1 << 17))
        str        r1,

        /* Sleep... Now */
        ldr        r0, PMCTL0_ADDR
        ldr        r1,
        orr        r1, r1, #(1 << 3)
        str        r1,        
1:        b        1b

ENTRY(memsetup)
        @ initialise the static memory

        @ set memory control registers
        mov        r1, #0x48000000
        adrl        r0, mem_cfg_val
        add        r2, r0, #52
1:        ldr        r3, , #4
        str        r3, , #4
        cmp        r2, r0
        bne        1b

        mov        pc, lr


@
@ copy_myself: copy vivi to ram
@
copy_myself:
        mov        r10, lr

        @ reset NAND
        mov        r1, #NAND_CTL_BASE
        ldr        r2, =0xf830                @ initial value
        str        r2,
        ldr        r2,
        bic        r2, r2, #0x800                @ enable chip
        str        r2,
        mov        r2, #0xff                @ RESET command
        strb        r2,
        mov        r3, #0                        @ wait
1:        add        r3, r3, #0x1
        cmp        r3, #0xa
        blt        1b
2:        ldr        r2,         @ wait ready
        tst        r2, #0x1
        beq        2b
        ldr        r2,
        orr        r2, r2, #0x800                @ disable chip
        str        r2,

        @ get read to call C functions (for nand_read())
        ldr        sp, DW_STACK_START        @ setup stack pointer
        mov        fp, #0                        @ no previous frame, so fp=0

        @ copy vivi to RAM
        ldr        r0, =0x33f00000
        mov   r1, #0x0
        mov        r2, #0x20000
        bl        nand_read_ll

        tst        r0, #0x0
        beq        ok_nand_read
#ifdef CONFIG_DEBUG_LL
bad_nand_read:
        ldr        r0, STR_FAIL
        ldr        r1, SerBase
        bl        PrintWord
1:        b        1b                @ infinite loop
#endif
       
ok_nand_read:
#ifdef CONFIG_DEBUG_LL
        ldr        r0, STR_OK
        ldr        r1, SerBase
        bl        PrintWord
#endif

        @ verify
        mov        r0, #0
        ldr        r1, =0x33f00000
        mov        r2, #0x400        @ 4 bytes * 1024 = 4K-bytes
go_next:
        ldr        r3, , #4
        ldr        r4, , #4
        teq        r3, r4
        bne        notmatch
        subs        r2, r2, #4
        beq        done_nand_read       
        bne        go_next
notmatch:
#ifdef CONFIG_DEBUG_LL
        sub        r0, r0, #4
        ldr        r1, SerBase
        bl        PrintHexWord
        ldr        r0, STR_FAIL
        ldr        r1, SerBase
        bl        PrintWord
#endif
1:        b        1b
done_nand_read:

#ifdef CONFIG_DEBUG_LL
        ldr        r0, STR_OK
        ldr        r1, SerBase
        bl        PrintWord
#endif

        mov        pc, r10

@ clear memory
@ r0: start address
@ r1: length
mem_clear:
        mov        r2, #0
        mov        r3, r2
        mov        r4, r2
        mov        r5, r2
        mov        r6, r2
        mov        r7, r2
        mov        r8, r2
        mov        r9, r2

clear_loop:
        stmia        r0!, {r2-r9}
        subs        r1, r1, #(8 * 4)
        bne        clear_loop

        mov        pc, lr



@ Initialize UART
@
@ r0 = number of UART port
InitUART:
        ldr        r1, SerBase
        mov        r2, #0x0
        str        r2,
        str        r2,
        mov        r2, #0x3
        str        r2,
        ldr        r2, =0x245
        str        r2,
#define UART_BRD ((50000000 / (115200 * 16)) - 1)
        mov        r2, #UART_BRD
        str        r2,

        mov        r3, #100
        mov        r2, #0x0
1:        sub        r3, r3, #0x1
        tst        r2, r3
        bne        1b

        mov        pc, lr


@
@ Exception handling functions
@
HandleUndef:
#ifdef CONFIG_DEBUG_LL
        mov        r12, r14
        ldr        r0, STR_UNDEF
        ldr        r1, SerBase
        bl        PrintWord
        bl        PrintFaultAddr
#endif
1:        b        1b                @ infinite loop

HandleSWI:
#ifdef CONFIG_DEBUG_LL
        mov        r12, r14
        ldr        r0, STR_SWI
        ldr        r1, SerBase
        bl        PrintWord
        bl        PrintFaultAddr
#endif
1:        b        1b                @ infinite loop

HandlePrefetchAbort:
#ifdef CONFIG_DEBUG_LL
        mov        r12, r14
        ldr        r0, STR_PREFETCH_ABORT
        ldr        r1, SerBase
        bl        PrintWord
        bl        PrintFaultAddr
#endif
1:        b        1b                @ infinite loop

HandleDataAbort:
#ifdef CONFIG_DEBUG_LL
        mov        r12, r14
        ldr        r0, STR_DATA_ABORT
        ldr        r1, SerBase
        bl        PrintWord
        bl        PrintFaultAddr
#endif
1:        b        1b                @ infinite loop

HandleIRQ:
#ifdef CONFIG_DEBUG_LL
        mov        r12, r14
        ldr        r0, STR_IRQ
        ldr        r1, SerBase
        bl        PrintWord
        bl        PrintFaultAddr
#endif
1:        b        1b                @ infinite loop

HandleFIQ:
#ifdef CONFIG_DEBUG_LL
        mov        r12, r14
        ldr        r0, STR_FIQ
        ldr        r1, SerBase
        bl        PrintWord
        bl        PrintFaultAddr
#endif
1:        b        1b                @ infinite loop

HandleNotUsed:
#ifdef CONFIG_DEBUG_LL
        mov        r12, r14
        ldr        r0, STR_NOT_USED
        ldr        r1, SerBase
        bl        PrintWord
        bl        PrintFaultAddr
#endif
1:        b        1b                @ infinite loop


@
@ Low Level Debug
@
#ifdef CONFIG_DEBUG_LL

@
@ PrintFaultAddr: Print falut address
@
@ r12: contains address of instruction + 4
@
PrintFaultAddr:
        mov        r0, r12                        @ Print address of instruction + 4
        ldr        r1, SerBase
        bl        PrintHexWord
        mrc        p15, 0, r0, c6, c0, 0        @ Read fault virtual address
        ldr        r1, SerBase
        bl        PrintHexWord
        mov        pc, lr

@ PrintHexNibble : prints the least-significant nibble in R0 as a
@ hex digit
@   r0 contains nibble to write as Hex
@   r1 contains base of serial port
@   writes ro with XXX, modifies r0,r1,r2
@   TODO : write ro with XXX reg to error handling
@   Falls through to PrintChar
PrintHexNibble:
        adr        r2, HEX_TO_ASCII_TABLE
        and        r0, r0, #0xF
        ldr        r0,         @ convert to ascii
        b        PrintChar

@ PrintChar : prints the character in R0
@   r0 contains the character
@   r1 contains base of serial port
@   writes ro with XXX, modifies r0,r1,r2
@   TODO : write ro with XXX reg to error handling
PrintChar:
TXBusy:
        ldr        r2,
        and        r2, r2, #UTRSTAT_TX_EMPTY
        tst        r2, #UTRSTAT_TX_EMPTY
        beq        TXBusy       
        str        r0,
        mov        pc, lr

@ PrintWord : prints the 4 characters in R0
@   r0 contains the binary word
@   r1 contains the base of the serial port
@   writes ro with XXX, modifies r0,r1,r2
@   TODO : write ro with XXX reg to error handling
PrintWord:
        mov        r3, r0
        mov        r4, lr
        bl        PrintChar

        mov        r0, r3, LSR #8                /* shift word right 8 bits */
        bl        PrintChar

        mov        r0, r3, LSR #16                /* shift word right 16 bits */
        bl        PrintChar
       
        mov        r0, r3, LSR #24                /* shift word right 24 bits */
        bl        PrintChar

        mov        r0, #'\r'
        bl        PrintChar

        mov        r0, #'\n'
        bl        PrintChar

        mov        pc, r4

@ PrintHexWord : prints the 4 bytes in R0 as 8 hex ascii characters
@   followed by a newline
@   r0 contains the binary word
@   r1 contains the base of the serial port
@   writes ro with XXX, modifies r0,r1,r2
@   TODO : write ro with XXX reg to error handling
PrintHexWord:
        mov        r4, lr
        mov        r3, r0
        mov        r0, r3, LSR #28
        bl        PrintHexNibble
        mov        r0, r3, LSR #24
        bl        PrintHexNibble
        mov        r0, r3, LSR #20
        bl        PrintHexNibble
        mov        r0, r3, LSR #16
        bl        PrintHexNibble
        mov        r0, r3, LSR #12
        bl        PrintHexNibble
        mov        r0, r3, LSR #8
        bl        PrintHexNibble
        mov        r0, r3, LSR #4
        bl        PrintHexNibble
        mov        r0, r3
        bl        PrintHexNibble

        mov        r0, #'\r'
        bl        PrintChar

        mov        r0, #'\n'
        bl        PrintChar

        mov        pc, r4
#endif
       
@
@ Data Area
@
@ Memory configuration values
.align 4
mem_cfg_val:
        .long        0x22111110        @vBWSCON
        .long        0x00000700        @vBANKCON0
        .long        0x00000700        @vBANKCON1
        .long        0x00000700        @vBANKCON2
        .long        0x00000700        @vBANKCON3
        .long        0x00000700        @vBANKCON4
        .long        0x00000700        @vBANKCON5
        .long        0x00018005        @vBANKCON6
        .long        0x00018005        @vBANKCON7
        .long        0x008E0459        @vREFRESH
        .long        0xb1        @vBANKSIZE
        .long        0x30        @vMRSRB6
        .long        0x30        @vMRSRB7

@ Processor clock values
.align 4
mpll_200mhz:
        .long        0x33f00338
@ inital values for GPIO
gpio_con_uart:
        .long        0x0016faaa
gpio_up_uart:
        .long        0x000007ff

        .align        2
DW_STACK_START:
        .word        0x33E64000+0x00008000-4

#ifdef CONFIG_DEBUG_LL
        .align        2
HEX_TO_ASCII_TABLE:
        .ascii        "0123456789ABCDEF"
STR_STACK:
        .ascii        "STKP"
STR_UNDEF:
        .ascii        "UNDF"
STR_SWI:
        .ascii        "SWI "
STR_PREFETCH_ABORT:
        .ascii        "PABT"
STR_DATA_ABORT:
        .ascii        "DABT"
STR_IRQ:
        .ascii        "IRQ "
STR_FIQ:
        .ascii        "FIQ"
STR_NOT_USED:
        .ascii        "NUSD"
        .align 2
STR_OK:
        .ascii        "OK"
STR_FAIL:
        .ascii        "FAIL"
STR_CR:
        .ascii"\r\n"
#endif

.align 4
SerBase:
        .long UART0_CTL_BASE

.align 4
PMCTL0_ADDR:
        .long 0x4c00000c
PMCTL1_ADDR:
        .long 0x56000080
PMST_ADDR:
        .long 0x560000B4
PMSR0_ADDR:
        .long 0x560000B8
REFR_ADDR:
        .long 0x48000024

:?::?::?:

qnhgpsj 发表于 2006-11-21 13:51:15

别改start.S,看看你用串口对不对?你的板子用的哪个串口做调试串口?在/include/configs/下相应的头文件里是不是选择了该串口输出调试信息?比如说,你板子上用串口2做调试口,但是你的头文件里却定义了串口1来输出调试信息,那U-BOOT就把调试信息发送到串口1去了!不要改start.S 和 u-boot.lds文件。
页: [1]
查看完整版本: 求教: 编译u-boot 启动基于S3C2410的开发板