1) Download mtd-utils from the link.
ftp://ftp.infradead.org/pub/mtd-utils/
(PS: Reference link http://elinux.org/CompilingMTDUtils)
2) Preparation for x86 build.
i) zlib
ii) lzo
iii) uuid
(PS: For ubuntu 10.04, user can install the packages from "Synaptic Package Manager" or "apt-get".)
3) Build with the following command.
WITHOUT_XATTR=1 make
sudo su
DESTDIR=/usr/local make install
To compile external mtd-utils-1.3.x, build e2fsprogs, lzo, zlib in ltib first. No need to modify the Makefile.
Then run the following:
Setting the following flags.
ZLIBCPPFLAGS="-I/home/usr/include" ZLIBLDFLAGS="-L/home/usr/lib" CROSS=arm-none-linux-gnueabi- WITHOUT_XATTR=1 make
Monday, June 14, 2010
Sunday, February 21, 2010
Adding new U-Boot commands
U-Boot providing interactive commands to end user but it may be necessary to add extra commands. There is a standard command interface
and it is defined in include/command.h. Every command defined a cmd_tbl_t structure.
#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
struct cmd_tbl_s {
char *name; /* Command Name */
int maxargs; /* maximum number of arguments */
int repeatable; /* autorepeat allowed? */
/* Implementation function */
int (*cmd)(struct cmd_tbl_s *, int, int, char *[]);
char *usage; /* Usage message (short) */
#ifdef CONFIG_SYS_LONGHELP
char *help; /* Help message (long) */
#endif
#ifdef CONFIG_AUTO_COMPLETE
/* do auto completion on the arguments */
int (*complete)(int argc, char *argv[], char last_char, int maxv, char *cmdv[]);
#endif
};
The command structure defined the name of the command, max number of the arguments, autorepeat, implementation function, usage and help.
The command console is defined in common/command.c. The find_cmd() is used to match the correspnding command function.
Below is an example to show how to read the cpu id.
#define read_cpuid(reg) \
({ \
unsigned int __val; \
asm("mrc p15, 0, %0, c0, c0, " __stringify(reg) \
: "=r" (__val) \
: \
: "cc"); \
__val; \
})
int do_cpuid(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
printf("cpu id: %x\n", read_cpuid(0));
printf("cache type: %x\n", read_cpuid(1));
printf("chip id: %x\n", *(volatile unsigned int *)0xd4282c00);
return 0;
}
U_BOOT_CMD(
cpuid, 6, 1, do_cpuid,
"cpuid - read cpu id\n",
" - read cpu id\n"
);
and it is defined in include/command.h. Every command defined a cmd_tbl_t structure.
#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
struct cmd_tbl_s {
char *name; /* Command Name */
int maxargs; /* maximum number of arguments */
int repeatable; /* autorepeat allowed? */
/* Implementation function */
int (*cmd)(struct cmd_tbl_s *, int, int, char *[]);
char *usage; /* Usage message (short) */
#ifdef CONFIG_SYS_LONGHELP
char *help; /* Help message (long) */
#endif
#ifdef CONFIG_AUTO_COMPLETE
/* do auto completion on the arguments */
int (*complete)(int argc, char *argv[], char last_char, int maxv, char *cmdv[]);
#endif
};
The command structure defined the name of the command, max number of the arguments, autorepeat, implementation function, usage and help.
The command console is defined in common/command.c. The find_cmd() is used to match the correspnding command function.
Below is an example to show how to read the cpu id.
#define read_cpuid(reg) \
({ \
unsigned int __val; \
asm("mrc p15, 0, %0, c0, c0, " __stringify(reg) \
: "=r" (__val) \
: \
: "cc"); \
__val; \
})
int do_cpuid(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
printf("cpu id: %x\n", read_cpuid(0));
printf("cache type: %x\n", read_cpuid(1));
printf("chip id: %x\n", *(volatile unsigned int *)0xd4282c00);
return 0;
}
U_BOOT_CMD(
cpuid, 6, 1, do_cpuid,
"cpuid - read cpu id\n",
" - read cpu id\n"
);
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.
=====================
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
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
Thursday, June 18, 2009
A report for 2009 Java Certification Day
The event mainly introduce the updates of the Java technology. There are some interesting stuffs I would like to share with you ^_^
JavaFX:
The JavaFX technologies is great & it is a real cross platform environment. Developers can focus on the applications and no need to concern on the porting issues. JavaFX applications developed on PC could be moved to Mobile phone, MID or even TV very easily. More information could be found in http://www.javafx.com/
http://kenai.com/
It is a service where you can host your open source projects and code, as well as find and collaborate with developers of like mind. The presenter just demostrat a few steps to clone & creatre a facebook application & it is real interesting. As you don't need to understand PHP or some other coding language — such as Ruby on Rails, JavaScript, or Python — especially one that has a client library for our API.
http://www.java.com/en/store/index.jsp
In future, Java developers can sell the applications just similar to the iPhone developer. ^_^ It is another platform to support freelance developer.
http://zembly.com/
It is a super great service. It inspire the developer to collaborate with other developers of like mind. It is an excellent collaboration of the software development flow. NetBean 6.7 IDE will support this service. ^_^
LeJOS:
LeJOS (Lego Java OS) is an open source project. It allow you to program LEGO MINDSTORMS NXT in Java. For information could be found in http://lejos.sourceforge.net/index.php
What next?
SUN & Oracle is going to be merge & some new big things are coming. Let see what happen ^_^
JavaFX:
The JavaFX technologies is great & it is a real cross platform environment. Developers can focus on the applications and no need to concern on the porting issues. JavaFX applications developed on PC could be moved to Mobile phone, MID or even TV very easily. More information could be found in http://www.javafx.com/
http://kenai.com/
It is a service where you can host your open source projects and code, as well as find and collaborate with developers of like mind. The presenter just demostrat a few steps to clone & creatre a facebook application & it is real interesting. As you don't need to understand PHP or some other coding language — such as Ruby on Rails, JavaScript, or Python — especially one that has a client library for our API.
http://www.java.com/en/store/index.jsp
In future, Java developers can sell the applications just similar to the iPhone developer. ^_^ It is another platform to support freelance developer.
http://zembly.com/
It is a super great service. It inspire the developer to collaborate with other developers of like mind. It is an excellent collaboration of the software development flow. NetBean 6.7 IDE will support this service. ^_^
LeJOS:
LeJOS (Lego Java OS) is an open source project. It allow you to program LEGO MINDSTORMS NXT in Java. For information could be found in http://lejos.sourceforge.net/index.php
What next?
SUN & Oracle is going to be merge & some new big things are coming. Let see what happen ^_^
Tuesday, June 2, 2009
First trial to compile Android (Part 2)
1) To install the cross compiler for your target device.
e.g. arm-2008q1-126-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
It can be downloaded from codesourcery.com
2) Download the Linux kernel linux-2.6.25-android-1.0_r1.tar
$ tar -xf linux-2.6.25-android-1.0_r1.tar
3) Downlaod the Linux version Android SDK android-sdk-linux_x86-1.5_r2
4) To assemble the root file system.
i) To download the busybox under linux environment. http://benno.id.au/blog/2007/11/14/android-busybox
ii) To run the emulator from the SDK & acquire the root file system.
$./tools/emulator &
iii) The Android should be launched & user should go to the Settings & enable the folloing options.
Wait for debugger.
Show running processes.
Show screen updates
iv) Under the console, user should install the busybox as following.
$./adb push ./busybox /data
$./adb shell
$/data/busybox tar -czf system.tar.gz /system
$/data/busybox tar -czf data.tar.gz /data
$/data/busybox tar -czf etc.tar.gz /etc
$/data/busybox tar -czf sbin.tar.gz /sbin
$exit
$./adb pull /system.tar.gz ./
$./adb pull /data.tar.gz ./
$./adb pull /etc.tar.gz ./
$./adb pull /sbin.tar.gz ./
$./adb pull /init ./
5) To create the rootdisk
$ mkdir ram_disk
$ cd ram_disk
$ mkdir cache dev proc root sys tmp var
$tar -xf ./system.tar.gz
$tar -xf ./data.tar.gz
$tar -xf ./etc.tar.gz
$tar -xf ./sbin.tar.gz
$cp ./init ./
The root disk is ready now ^_^
7) The android kenel may not support the target board, user has to change the build configuration & add the platform depend codes accordingly.
e.g. /arch/arm/mach-s3c6410
8) Debug & cross compile the kernel & the rootdisk accordingly.
9) Good luck & have fun ^_^
e.g. arm-2008q1-126-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
It can be downloaded from codesourcery.com
2) Download the Linux kernel linux-2.6.25-android-1.0_r1.tar
$ tar -xf linux-2.6.25-android-1.0_r1.tar
3) Downlaod the Linux version Android SDK android-sdk-linux_x86-1.5_r2
4) To assemble the root file system.
i) To download the busybox under linux environment. http://benno.id.au/blog/2007/11/14/android-busybox
ii) To run the emulator from the SDK & acquire the root file system.
$./tools/emulator &
iii) The Android should be launched & user should go to the Settings & enable the folloing options.
Wait for debugger.
Show running processes.
Show screen updates
iv) Under the console, user should install the busybox as following.
$./adb push ./busybox /data
$./adb shell
$/data/busybox tar -czf system.tar.gz /system
$/data/busybox tar -czf data.tar.gz /data
$/data/busybox tar -czf etc.tar.gz /etc
$/data/busybox tar -czf sbin.tar.gz /sbin
$exit
$./adb pull /system.tar.gz ./
$./adb pull /data.tar.gz ./
$./adb pull /etc.tar.gz ./
$./adb pull /sbin.tar.gz ./
$./adb pull /init ./
5) To create the rootdisk
$ mkdir ram_disk
$ cd ram_disk
$ mkdir cache dev proc root sys tmp var
$tar -xf ./system.tar.gz
$tar -xf ./data.tar.gz
$tar -xf ./etc.tar.gz
$tar -xf ./sbin.tar.gz
$cp ./init ./
The root disk is ready now ^_^
7) The android kenel may not support the target board, user has to change the build configuration & add the platform depend codes accordingly.
e.g. /arch/arm/mach-s3c6410
8) Debug & cross compile the kernel & the rootdisk accordingly.
9) Good luck & have fun ^_^
Sunday, May 31, 2009
First trial to compile Android (Part 1)
1) To install the ubuntu-9.04-desktop-i386 system.
2) To install some building packages & utilities.
$ sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl
$ sudo apt-get install valgrind
$ sudo apt-get install sun-java6-jdk
4) To add some system variables.
export LANG=c
export PATH=~/bin:$PATH:.
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.07
export ANDROID_JAVA_HOME=$JAVA_HOME
3) It must install the Git & Repo, please read the link in detail. http://source.android.com/download/using-repo
$ sudo apt-get install git-core gnupg
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
$ mkdir myAndroid
$ cd myAndroid
$ repo init -u git://android.git.kernel.org/platform/manifest.git
4) User can download the Android codes now.
$ repo sync
5) To compile the Android.
$make
6) Checking the result in myAndroid/out.
Have fun ^_^
2) To install some building packages & utilities.
$ sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl
$ sudo apt-get install valgrind
$ sudo apt-get install sun-java6-jdk
4) To add some system variables.
export LANG=c
export PATH=~/bin:$PATH:.
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.07
export ANDROID_JAVA_HOME=$JAVA_HOME
3) It must install the Git & Repo, please read the link in detail. http://source.android.com/download/using-repo
$ sudo apt-get install git-core gnupg
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
$ mkdir myAndroid
$ cd myAndroid
$ repo init -u git://android.git.kernel.org/platform/manifest.git
4) User can download the Android codes now.
$ repo sync
5) To compile the Android.
$make
6) Checking the result in myAndroid/out.
Have fun ^_^
Subscribe to:
Posts (Atom)