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.

Tuesday, January 19, 2010

Uboot for PXA (1)

UBOOT is a loader based on PPC boot loader.

The file structure is simply shown as below:

u-boot-arm
|_board
|_common
|_cpu
|_disk
|_doc
|_drivers
|_examples
|_fs
|_include
|_lib_arm
|_lib_avr32
|_lib_blackfin
|_lib_generic
|_lib_i386
|_lib_m68k
|_lib_microblaze
|_lib_mips
|_lib_nios
|_lib_nios2
|_lib_ppc
|_lib_sh
|_lib_sparc
|_libfdt
|_nand_spl
|_net
|_nenand_ipl
|_post
|_tools
...
...
...

board: All supporting target boards ard defined in this directory. For example \u-boot-arm\board\pxa\aspenite
A board_init function is defined in aspenite_168.c

cpu: All supoorting CPU type are defined in this directory. For example \u-boot-arm\cpu\pxa
All CPU env init including interrupts are defined. start.s is the first pieces of codes running
in the system. Its main task is to copy the whole uboot from flash into ram & start execution.

common: This is the directory stored all the uboot commands. We normally look at cmb_boot.c & cmd_bootm.c
It has the function to verify the kernel & doing decompression.)

drivers: This directory provides all the interface drivers.

fs: This directory provides all the supporting file system.

lib_arm: This directory providing all the common libraries for arm platform.

include: All headers are placed in this directory. For example u-boot-arm\include\asm-arm\arch-pxa & u-boot-arm\include\asm-arm\arch-pxa168