鱼C论坛

 找回密码
 立即注册
查看: 2548|回复: 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.

启动代码:
  1. .text
  2. .global _start
  3. _start:
  4.                 b reset
  5.                 ldr pc,_undefined_instruction
  6.                 ldr pc,_software_interrupt
  7.                 ldr pc,_prefetch_abort
  8.                 ldr pc,_data_used
  9.                 ldr pc,_not_used
  10.                 ldr pc,_irq
  11.                 ldr pc,_fiq

  12. _undefined_instruction: .word undefined_instruction
  13. _software_interrupt: .word software_interrupt
  14. _prefetch_abort: .word prefetch_abort
  15. _data_used: .word data_used
  16. _not_used: .word not_used
  17. _irq: .word irq
  18. _fiq: .word fiq
  19. _reset: .word reset

  20. undefined_instruction:
  21.         nop
  22. software_interrupt:
  23.         nop
  24. prefetch_abort:
  25.         nop
  26. data_used:
  27.         nop
  28. not_used:
  29.         nop
  30. irq:
  31.         nop
  32. fiq:
  33.         nop
  34. reset:
  35.         bl set_svc
  36.         bl disable_watchdog
  37.         bl disable_interrupt
  38. set_svc:
  39.         mrs r0,cpsr
  40.         bic r0,r0,#0x1f
  41.         orr r0,r0,#0xd3
  42.         msr cpsr,r0

  43. #define pWTCON 0X53000000
  44. disable_watchdog:
  45.         ldr r0,=pWTCON
  46.         mov r1,#0x0]
  47.         str r1,[r0]

  48. disable_interrupt:
  49.         mvn r1,#0x0
  50.         ldr r0,#0x4a000008
  51.         str r1,[r0]
复制代码


链接脚本:


  1. OUTPUT_ARCH(arm)
  2. ENTRY(_start)
  3. SECTIONS{
  4.         . = 0x30000000;
  5.         . = ALIGN(4);
  6.         .text :
  7.         {
  8.         start.o(.text)
  9.         *(.text)
  10.         }
  11.         . = ALIGN(4);
  12.         .data :
  13.         {
  14.         *(.data)
  15.         }
  16.         . = ALIGN(4);
  17.         bss_start = .;
  18.         .bss :
  19.         {
  20.         *(.bss)
  21.         }
  22.         bss_end = .;
  23. }
复制代码




Makefile:
  1. all : start.o
  2.         arm-linux-ld -Tgboot.lds -o gboot.elf $^
  3.         arm-linux-objcopy -O binary gboot.elf gboot.bin
  4. %.o : %.S
  5.         arm-linux-gcc -g -c $^
  6. %.o : %.c
  7.         arm-linux-gcc -g -c $^
复制代码

2440—bootloader设计框图

2440—bootloader设计框图

评分

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

查看全部评分

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2017-6-20 19:50:58 | 显示全部楼层
此帖仅作者可见
小甲鱼最新课程 -> https://ilovefishc.com

使用道具 举报

 楼主| 发表于 2017-6-20 20:50:55 | 显示全部楼层
此帖仅作者可见
小甲鱼最新课程 -> https://ilovefishc.com

使用道具 举报

发表于 2017-6-21 00:05:39 | 显示全部楼层
此帖仅作者可见
小甲鱼最新课程 -> https://ilovefishc.com

使用道具 举报

发表于 2017-6-21 00:07:18 | 显示全部楼层
此帖仅作者可见
小甲鱼最新课程 -> https://ilovefishc.com

使用道具 举报

 楼主| 发表于 2017-6-21 09:56:22 | 显示全部楼层
此帖仅作者可见
小甲鱼最新课程 -> https://ilovefishc.com

使用道具 举报

 楼主| 发表于 2017-6-21 10:05:33 | 显示全部楼层
此帖仅作者可见
小甲鱼最新课程 -> https://ilovefishc.com

使用道具 举报

发表于 2017-6-21 12:52:20 | 显示全部楼层
此帖仅作者可见
小甲鱼最新课程 -> https://ilovefishc.com

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-8 07:30

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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