鱼C论坛

 找回密码
 立即注册
查看: 2296|回复: 7

[技术交流] 2440-(ARM9)-Bootloader设计之初始化

[复制链接]
发表于 2017-6-20 18:28:01 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 john-rgt 于 2017-6-21 14:38 编辑

        Bootloader在嵌入式Linux系统中,起到助推作用,在内核运行之前,先对各个硬件进行初始化,建立一个空间系统蓝图(映射图),说白了,就好比盖楼,在修楼之前得打好地基,才能进行下一步操作。
        本人现在也是小白菜,观点不一定对,勿喷
        在学习bootloader之前,我先对它的大概的框架进行了了解,大致架构看图;
        今天我先说一下,第一个初始化前四步。
       
1.异常向量表
何为异常
Exceptions are generated by internal and external sources to cause the processor to handle an event, such as an                                             
externally generated interrupt or an attempt to execute an Undefined instruction. The processor state just before handling the exception is normally preserved so that the original program can be resumed when the

exception routine has completed. More than one exception can arise at the same time.(这里可以练练大家的英语能力 ,试着翻译哈哈)
而异常向量表就是由7个异常向量及其函数跳转关系组成的表,具体的看ARM手册。

2.设置处理器模式为SVC模式

3.关闭看门狗
WATCHDOG:The S3C2440A watchdog timer is used to resume the controller operation whenever it is disturbed by malfunctions
such as noise and system errors. It can be used as a normal 16-bit interval timer to request interrupt service. The
watchdog timer generates the reset signal for 128 PCLK cycles.

4.关闭中断
The interrupt controller in the S3C2440A receives the request from 60 interrupt sources. These interrupt sources are
provided by internal peripherals such as DMA controller, UART, IIC, and others. In these interrupt sources, the
UARTn, AC97 and EINTn interrupts are 'OR'ed to the interrupt controller.

启动代码:
.text
.global _start
_start:
                b reset
                ldr pc,_undefined_instruction
                ldr pc,_software_interrupt
                ldr pc,_prefetch_abort
                ldr pc,_data_used
                ldr pc,_not_used
                ldr pc,_irq
                ldr pc,_fiq

_undefined_instruction: .word undefined_instruction
_software_interrupt: .word software_interrupt
_prefetch_abort: .word prefetch_abort
_data_used: .word data_used
_not_used: .word not_used
_irq: .word irq
_fiq: .word fiq
_reset: .word reset

undefined_instruction:
        nop
software_interrupt:
        nop
prefetch_abort:
        nop
data_used:
        nop
not_used:
        nop
irq:
        nop
fiq:
        nop
reset:
        bl set_svc
        bl disable_watchdog
        bl disable_interrupt
set_svc:
        mrs r0,cpsr
        bic r0,r0,#0x1f
        orr r0,r0,#0xd3
        msr cpsr,r0

#define pWTCON 0X53000000
disable_watchdog:
        ldr r0,=pWTCON
        mov r1,#0x0]
        str r1,[r0]

disable_interrupt:
        mvn r1,#0x0
        ldr r0,#0x4a000008
        str r1,[r0]

链接脚本:

OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS{
        . = 0x30000000;
        . = ALIGN(4);
        .text :
        {
        start.o(.text)
        *(.text)
        }
        . = ALIGN(4);
        .data :
        {
        *(.data)
        }
        . = ALIGN(4);
        bss_start = .;
        .bss :
        {
        *(.bss)
        }
        bss_end = .;
}



Makefile:
all : start.o
        arm-linux-ld -Tgboot.lds -o gboot.elf $^
        arm-linux-objcopy -O binary gboot.elf gboot.bin
%.o : %.S
        arm-linux-gcc -g -c $^
%.o : %.c
        arm-linux-gcc -g -c $^

2440—bootloader设计框图

2440—bootloader设计框图

评分

参与人数 1鱼币 +6 收起 理由
小甲鱼 + 6 支持楼主!

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-6-20 19:50:58 | 显示全部楼层
此帖仅作者可见
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com

使用道具 举报

 楼主| 发表于 2017-6-20 20:50:55 | 显示全部楼层
此帖仅作者可见
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com

使用道具 举报

发表于 2017-6-21 00:05:39 | 显示全部楼层
此帖仅作者可见
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com

使用道具 举报

发表于 2017-6-21 00:07:18 | 显示全部楼层
此帖仅作者可见
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com

使用道具 举报

 楼主| 发表于 2017-6-21 09:56:22 | 显示全部楼层
此帖仅作者可见
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com

使用道具 举报

 楼主| 发表于 2017-6-21 10:05:33 | 显示全部楼层
此帖仅作者可见
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com

使用道具 举报

发表于 2017-6-21 12:52:20 | 显示全部楼层
此帖仅作者可见
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-7-3 18:12

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表