2012年5月28日月曜日

Bootloader AP

An open-source GPL licensed boot-loader for ARM architecture Qualcomm System-on-Chip based devices such as those made by HTC. Intended to be a Free Open-Source alternative to the closed-source boot-loader (hboot) used by manufacturers. The ROM image is binary-compatible with hboot images.

Source Code

Warning: If you cloned the repository before 05:41 UTC 29th October, please delete your local repository and clone again. I had to replace the original repository so the history and refs would not match and your future pulls or fetches would fail.

Source is available from the git repository using:

git clone git://tjworld.net/bootloader-ap.git  

and can be browsed using gitweb.

Status

5th November: noticed that the hboot code for libc functions such as memcpy look very much like the Bionic (Google libc alternative used by Android) code for memcpy which is in fact an empty wrapper for the Bionic bcopy function. It seems plausible that Qualcomm and/or HTC would re-use Bionic (rather than write their own implementation). If confirmed bootloader-ap can import the Bionic libc library functions it needs, rather than my having to write them.

3rd November

Added complete libc skeleton definition based on completed analysis of usage by hboot. Will write the implementations later. Added zlib compression library 1.2.3 (as used in hboot).

30th October

Realised that the hboot initialisation code (the first ~1700 bytes) is op-code identical to that contained in the Vision Linux kernel source-file arch/arm/mach-msm/arch-init-7x30.S. Not only has this revealed at a stroke what this code is doing (from the comments in the source-code file) but it also shines light on the legal status of the hboot binary, since the source-code file is licensed using the BSD 3-clause open source license. This helps clarify the status of this project and means the source-file can be incorporated directly.

29th October 2010

Created the project and defined the directory structure based on the original Android legacy bootloader project. Used the Linux kernel build system as inspiration. First task was to ensure a ROM image that is binary-compatible with hboot images can be created by the tools. Created the skeleton initialisation stubs in assembler and modified the section and align directives to get the correct header layout and modified the linker and objcopy commands to create the ROM image in the project's base directory.

Building

Prerequisites

To build the ARM code on an Intel/AMD IA32 PC a cross-compiler is required. See my instructions for installing the cross-compiler.

Build

From the project's base directory ensure there is a .config file symbolically linked:

ls -Al .config  lrwxrwxrwx 1 tj tj 30 2010-10-28 23:06 .config -> arch/configs/msm7x30_defconfig  

If not, create the sym-link to the correct configuration file (At this time there's only one!):

ln -s arch/configs/msm7x30_defconfig .config  

To create the ROM image:

make    make -C arch  make[1]: Entering directory `/home/all/Projects/Android/ARM/bootloader-ap/arch'  arm-none-linux-gnueabi-gcc  -I/home/all/Projects/Android/ARM/bootloader-ap/include  -c -o arm-head.o arm-head.S  arm-none-linux-gnueabi-gcc  -I/home/all/Projects/Android/ARM/bootloader-ap/include  -c -o msm7x30-init.o msm7x30-init.S  arm-none-linux-gnueabi-ld -N -Ttext 0x8D000000 -e _start -o arch.o arm-head.o msm7x30-init.o  make[1]: Leaving directory `/home/all/Projects/Android/ARM/bootloader-ap/arch'  arm-none-linux-gnueabi-objcopy -S -O binary arch/arch.o bootloader-ap  ROM Image is  bootloader-ap  

If the make is successful there will be a new file in the project's base directory called bootloader-ap. It can be examined with hexdump. This example shows the original skeleton that proved the binary layout is identical to an hboot image:

hexdump -C bootloader-ap     00000000  12 00 00 ea 30 2e 30 31  2e 30 30 30 31 00 00 00  |....0.01.0001...|  00000010  37 32 33 30 20 53 50 4c  00 00 00 00 00 00 a0 e1  |7230 SPL........|  00000020  53 48 49 50 00 00 00 00  00 00 a0 e1 00 00 a0 e1  |SHIP............|  00000030  48 42 4f 4f 54 2d 37 32  33 30 00 00 00 00 a0 e1  |HBOOT-7230......|  00000040  62 75 69 6c 64 2d 74 65  73 74 00 00 00 00 a0 e1  |build-test......|  00000050  10 0f 11 ee 0b 0a c0 e3  05 00 c0 e3 02 00 80 e3  |................|  00000060  10 0f 01 ee 01 00 00 eb  00 00 a0 e1 00 00 a0 e1  |................|  00000070  00 40 a0 e3 08 10 9f e5  0c 20 a0 e3 00 30 91 e5  |.@....... ...0..|  00000080  1e ff 2f e1 6c 00 60 ab                           |../.l.`.|  00000088  

To clean up (remove) the generated files:

make clean    make -C arch clean;  make[1]: Entering directory `/home/all/Projects/Android/ARM/bootloader-ap/arch'  rm -f *.o  make[1]: Leaving directory `/home/all/Projects/Android/ARM/bootloader-ap/arch'  rm -f *.o bootloader-ap

0 件のコメント:

コメントを投稿