AM3352启动分析:

Stp1: 定义栈大小

Stp2: 复位CPU

Stp3: 禁能FIQ和IRQ

Stp4: 清除Bss

Stp4:调用main()函数

 

具体过程如下:

1.声明全局函数,以便在其他文件中调用:

.global    Reset            @Reset the CPU

.global _stack              @Define Stack 
    
.global _bss_start          @Define the start of the BSS(Block Started by Symbol)
    
.global _bss_end            @Define the end of the BSS
    
.global start_boot          @main()

2.定义栈大小(.set相当于C中#define )具体见笔记

.set    UND_STACK_SIZE,    0x8        @未定义

.set    ABT_STACK_SIZE,    0x8        @数据访问中止

.set    FIQ_STACK_SIZE,    0x8        @快速中断
    
.set    IRQ_STACK_SIZE,    0X800      @外部中断
    
.set    SVC_STACK_SIZE,   0x8        @管理

3.复位CPU,操作方式为为每个模式设置栈

Entry:
           LDR   r0, =_stack                             @ Read the stack address
        
    MSR   cpsr_c, #MODE_UND|I_F_BIT           @ switch to undef  mode
         
    MOV   sp,r0                                        @ write the stack pointer
         
    SUB   r0, r0, #UND_STACK_SIZE                 @ give stack space
@

@ Set up the Stack for abort mode
@        
         
    MSR   cpsr_c, #MODE_ABT|I_F_BIT           @ Change to abort mode
        
    MOV   sp, r0                                      @ write the stack pointer
         
    SUB   r0,r0, #ABT_STACK_SIZE                  @ give stack space

后面的模式都一样,不再一一列举

4.清除BSS,利用循环,每次清除一个字

Clear_Bss_Section:

     
    LDR   r0, =_bss_start                 @ Start address of BSS
         
    LDR   r1, =(_bss_end - 0x04)          @ End address of BSS
         
    MOV   r2, #0  

Loop: 
         
    STR   r2, [r0], #4                    @ Clear one word in BSS
         
    CMP   r0, r1
         
    BLE   Loop                            @ Clear till BSS end

5.至此,终于可以跳转到C代码了:

@Enter_main:
        
    LDR   r10,=start_boot
         
    MOV   lr,pc                               @ Dummy return from start_boot
         
    BX    r10                                 @ Branch to start_boot
         
    SUB   pc, pc, #0x08                @ looping

经过一天的实验,终于引导成功,实现了IO操作

待续……

转载于:https://www.cnblogs.com/liutingbl/p/4151028.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值