Thursday, January 21, 2010

Uboot for PXA (2)

Compilation for UBOOT
=====================
Pre-request: User should install the corresponding cross tool chain in advance.

It is a very simple procedures, user has to choose the target platform first.

user:/home/user/u-boot-arm/make ARCH=arm CROSS_COMPILE=arm-marvel-linux-gnueabi- aspenite_config

Then user should able to build the uboot as below.

user:/home/user/u-boot-arm/make ARCH=arm CROSS_COMPILE=arm-marvel-linux-gnueabi-

(PS:The output binary is placed in the same directory.)

CPU directory
=============

uboot is starting from \u-boot-arm\cpu\pxa\start.s & it defined the standard arm reset vector table
as below.

.globl _start
_start: b reset
ldr pc, _undefined_instruction
ldr pc, _software_interrupt
ldr pc, _prefetch_abort
ldr pc, _data_abort
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_abort: .word data_abort
_not_used: .word not_used
_irq: .word irq
_fiq: .word fiq

.balignl 16,0xdeadbeef

Below codes are impoerant & defined control by u-boot-arm\board\pxa\aspenite\u-boot.lds

_TEXT_BASE:
.word TEXT_BASE

.globl _armboot_start
_armboot_start:
.word _start

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

.globl _bss_end
_bss_end:
.word _end

Then it is the actual reset codes.

reset:
mrs r0,cpsr /* set the CPU to SVC32 mode */
bic r0,r0,#0x1f /* (superviser mode, M=10011) */
orr r0,r0,#0x13
msr cpsr,r0

Then it will call cpu_init_crit & performing very low level init stuffs. Normally, user no need to touch
these pieces of codes. It init clock, timer, interrupts & then determmine copy itself from flash into RAM (relocation) for execution.

The stack is setup as below.

_TEXT_BASE:
.word TEXT_BASE

.globl _armboot_start
_armboot_start:
.word _start

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

.globl _bss_end
_bss_end:
.word _end

Finally, it will jump to the C codes (Congrtulation ^_^)

ldr pc, _start_armboot

The start_armboot function is defined in lib_arm/board.c

cpu.c

It is defined those I-D caches function & doing IRQ setup if necessary.

interrupt.c

The pxa u-boot doesn't setup any interrupts.

serial.c

It is the serial port init, pxa_setbrg_dev().

Board directory
===============

Board directory mainly includes all the board specify stuffs.

u-boot.lds //linker script
aspenite_pxa168.c // development board init.

board_init() in the aspenite_pxa168.c is important, it enables clock, init gpio, regulator ...etc.

lib_arm directory
=================

start.s will finally call start_armboot and it is defined in /lib_arm/board.c

It is mainly call the mem_malloc_init function and all the peripherials init functions.

Conclusion
==========

The uboot is very powerful & it has many features to be explored.

No comments: