Boot Architecture on MSM™
- ARM9™/AMSS boot
- On-chip PBL
- qcsbl.mbn
- oemsbl.mbn
- amss.mbn
- –
- Configures initial hardware config
(TLMM GPIO Configuration)
- –
- Configures modem's
multiprocessor subsystem
(SMEM, SMD, RPC)
- –
- Modem automatically connects to 3G network
- Application processor/Linux boot
- Android Bootloader
- –
- In /bootable/bootloader/legacy
- Linux OS image
- –
- Mounts system and user file system
- –
- Starts up Android components via system/core/rootdir, starts up initial Dalvik process
Boot Architecture on MSM (cont.)
- When power is applied to MSM, mARM executes the Primary Boot Loader (PBL) from on-chip ROM
- PBL loads Qualcomm Secondary Boot Loader (QCSBL) into memory and transitions to secondary boot stage
- System fully boots after QCSBL execution and enters operational software download mode
- Modem image is loaded on mARM
- Applications boot image, i.e., Android bootloader, is loaded into memory for aARM execution, which continues loading Android OS
Boot Architecture on QSD
- ARM9™/AMSS boot
- On-chip PBL
- dbl.mbn/fsbl.mbn
- osbl.mbn
- amss.mbn
- –
- Configures initial hardware config
(TLMM GPIO Configuration)
- –
- Configures modem's
multiprocessor subsystem
(SMEM, SMD, RPC)
- –
- Modem automatically connects
to 3G network
- Application processor/Linux boot
- Android Bootloader
- –
- In bootable/bootloader/legacy
- Linux OS image
- –
- Mounts system and user file system
- –
- Starts up Android components via system/core/rootdir, starts up initial Dalvik process

Android Bootloader Configuration~
Android Bootloader
- For MSM7xxx and QSD, modem processor plays master role and handles memory configuration and clock/voltage setting for entire system
- Android bootloader entry point (in /android/bootable/bootloader/legacy/usbloader/main.c)
- Initialize ARM11 clock speed from TCXO to 600 MHz
- Create partition table and initialize basic peripherals, such as UART, keypad, panel, USB, and flash controller
- Parse or generate ATAGs
- Load kernel and hand over to kernel init code
- Handle image download, if needed
Bootloader File Structure
- Bootloader located in:
- /android/bootable/bootloader/legacy/usbloader
- Bootloader libraries come from three categories:
- Generic
- Architecture
- Board
Bootloader File Structure –Generic Category
- Generic category contains code useful to any bootloader
- Common bootloader libraries and base architectures
- bootable/bootloader/legacy/include/boot/*.*
- bootable/bootloader/legacy/libboot/*.*
- bootable/bootloader/legacy/libc/*.*
- bootable/bootloader/legacy/arch_armv6/*.*
- Generated library and object located at:
- out/target/product/msm7627_surf/obj/STATIC_LIBRARIES/libboot_intermediates/libboot.a
- out/target/product/msm7627_surf/obj/STATIC_LIBRARIES/libboot_c_intermediates/libboot_c.a
- out/target/product/msm7627_surf/obj/STATIC_LIBRARIES/libboot_arch_armv6_intermediates/libboot_arch_armv6.a
Bootloader File Structure –Architecture Category
- Architecture category contains code useful to specific CPU, system-on-chip, etc.
- Libraries and base architectures –Headers
- bootable/bootloader/legacy/include/msm7k/*.*
- bootable/bootloader/legacy/ arch_msm7k /*.*
- Generated library and object file located at:
- out/target/product/msm7627_surf/obj/STATIC_LIBRARIES/libboot_arch_msm7k_intermediates/libboot_arch_msm7k.a
Bootloader File Structure –Board Category
- Board category contains code useful to a single, specific device
- Libraries and base architectures –Configuration
- vendor/qcom/msm7627_surf/*.*
- vendor/qcom/msm7627_surf/boot/*.*
- Generated library and object file located at:
- out/target/product/msm7627_surf/obj/STATIC_LIBRARIES/libboot_board_surf_intermediates/libboot_board_surf.a
Bootloader File Structure –Board Configuration
- The BoardConfig.mk defines important build variables:
- TARGET_BOOTLOADER_LIBS := \libboot_board_surf \libboot_arch_msm7k\libboot_arch_armv6
- TARGET_BOOTLOADER_LINK_SCRIPT := \vendor/qcom/$(TARGET_PRODUCT)/boot/boot.ld
- BOARD_KERNEL_CMDLINE := mem=203M console=ttyMSM2,115200n8 androidboot.hardware=qcom
Bootloader Configuration
- The following primary files require modification for SURF boards:
- vendor/qcom/msm7627_surf/boot/board.c –Defines flash partitions and atags, provides board-specific initialization
- vendor/qcom/msm7627_surf/boot/panel.c –Panel driver for outputting console messages
- vendor/qcom/msm7627_surf/boot/keypad.c –Keypad driver for hot-key controlling
- arch_msm7k/android/nand.c –Flash driver for NAND devices
- arch_msm7k/hsusb.c –USB driver for fast boot
- arch_msm7k/clock.c –Clock driver for setting frequency of ARM11 and AHB
- arch_msm7k/uart.c –Serial port driver
- arch_msm7k/gpio.c –GPIO driver for bootloader
Note:For QSD, similar modifications would be made under the appropriate QSD architecture subdirectory.
Flash Layout –board.c
- Flash partition table (unit –block); the partition in PTABLE must refer to allocation in /AMSS/products/7600/tools/headergen/partition.c
ptentry PTABLE[] = {
{
.start = 300,
.length = 40,
.name = "boot",
},
{
.start = 356,
.length = 512,
.name = "system"
},
{
.start = 868,
.length = 155 + 1024,
.name = "userdata",
},
{
.name = "",
},
};
Partition table
|
Range
|
Android partitions
|
0:APPSBL
|
230 –233
(1 MB)
|
Android
Bootloader
|
0:APPS +
0:FTL +
0:EFS2APPS
|
300 –339
(5 MB)
|
boot (kernel)
|
356 –867
(64 MB)
|
system
| |
868 –2046
(147 MB)
|
user data
|
Command Line –board.c
- Use Linux kernel command line (default kernel command line) or specify command line in BoardConfig.mk
const char *board_cmdline(void)
{
return "mem=201M console=ttyMSM2,115200n8";
}
- Board machine type
unsigned board_machtype(void)
{
return 1439;
}
- To register machine type, see [R1]
Keypad Configuration –keypad.c
- android/bootable/bootloader/legacy/arch_msm7k/keypad.c
- Configure GPIO for keypad
static unsigned int halibut_row_gpios[] = { 31, 32, 33, 34, 35, 41 };
static unsigned int halibut_col_gpios[] = { 36, 37, 38, 39, 40 };
- Configure special key to stop booting Linux
- –
- The following example shows two different stop boot key mappings used by two different targets –SURF and FFA
static unsigned int halibut_key_map[] = {
[11] = BOOT_KEY_CONTINUE_BOOT, /* FA on SURF, B on FFA */
[23] = BOOT_KEY_STOP_BOOT, /* FB on SURF */
[27] = BOOT_KEY_STOP_BOOT, /* 2 on FFA */
};
- On SURF, pressing the [FB] key will stop booting Linux and the system will enter Fastboot mode; the FFA's special key is [2]
Keypad Configuration –keypad.c (cont.)
- Register keypad information
static gpio_keypad_info halibut_keypad = {
.output_gpios = halibut_row_gpios,
.input_gpios = halibut_col_gpios,
.noutputs = ARRAY_SIZE(halibut_row_gpios),
.ninputs = ARRAY_SIZE(halibut_col_gpios),
.key_map = halibut_key_map,
.settle_time = 5000,
.polarity = 0,
.drive_inactive_outputs = 1
};
Panel Configuration –panel.c
- The following interfaces are implemented for the Toshiba VGA panel on SURF:
- panel_init( ) –Panel ID detection
- panel_poweron( ) –Power-on panel
- panel_backlight( ) –Control backlight of panel
- The MDDI console is implemented to output messages
- bootable/bootloader/legacy/arch_msm7k/mddi_console.c
- console_init()
- console_putc()
- console_clear()
Bootloader Framebuffer
- console_putc() calls drawglyph() to draw the character on LCD
- drawglyph(pixels + cy * 12 * fb_width + cx * 6, FGCOLOR,fb_width, font5x12 + (c -32) * 2);
- The font5x12[] is character pattern file
unsigned font5x12[] = {0x00000000, 0x00000000,0x08421080, 0x000200840x00052940, 0x00000000,0x15f52800, 0x0000295f,0x1c52f880, 0x00023e94,0x08855640, 0x0004d542,.......}
Bootloader Framebuffer (cont.)
- Default resolution in bootloader is 800 (fb_width) x 480(fb_height)
- Color format –565RGB
- bit[0:4] –Blue
- bit[5:10] –Green
- bit[11:15] –Red
- Example to splash RGB color on LCD
void splash_image(){
unsigned short *dst = mddi_framebuffer();
unsigned short color,rgb[3] = {0xf800, 0x07E0, 0x001f};
unsigned j,k;
for (j = 0; j < fb_height; j++) {
if ( !(j % (fb_height/3) ) )
color = rgb[ j/(fb_height/3) ];
for (k = 0; k < fb_width; k++ )
*dst++ = color;
}
console_flush();
}
UART Configuration –uart.c
- bootable/bootloader/legacy/arch_msm7k/uart.c
- uart_init() –Configure UART base address and init UART configuration, uart_init (n) , n = 0 (UART1), 1 (UART2), 2 (UART3)
- In uart_init()uwr(UART_CSR_115200, UART_CSR); // to change baud rate
- uart_getc() –Get input character from console
- uart_putc() –Send output character to console
- uart_put() –Send output string to console
USB Driver
- bootable/bootloader/legacy/arch_msm7k/hsusb.c
- Supports fastboot protocol to download image
- Supports Fastboot mode
- Protocol defined over USB
- Used for flashing Android bootloader, system image, and file system
- Mode normally triggered by special key sequence upon startup
- Fastboot application
- –
- Source files –system/core/fastboot
- –
- Fastboot available on Linux, Mac OSX, and Windows versions; for information regarding how to build the fastboot application, refer to [Q3]
- –
- Flashes new Android code much faster than JTAG
Bootloader MSM7x27 Clock Configuration –clock.c
- bootable/bootloader/legacy/arch_msm7k/clock.c
- ARM11 core clock source is determined by A11S_CLK_CNTL (0xC0100100) CLK_SRC1_SEL[12:14] or CLK_SRC0_SEL[4:6] and A11S_CLK_SEL (0xC0100104) CLK_SEL_SRC1N0[0]
- MSM7x27 pll speed of Dual mode frequency plan

Bootloader MSM7x27 Clock Configuration –clock.c (cont.)
- arm11_clock_init() increases the ARM11 core speed from 19.2 MHz to 600 MHz
- C = > A11S_CLK_CNTL, S => A11S_CLK_SEL
C,(CLK_SRC_TCXO << 12) | (DIV_1 << 8) | \
(CLK_SRC_TCXO << 4) | (DIV_1)),
S, ((DIV_4 << 1) | (CLK_SRC0)),
|
ARM11 : 19.2 MHz / 1 = 19.2 MHz
|
C, (CLK_SRC_TCXO << 12) | (DIV_1 << 8) | \
(CLK_SRC_PLL2 << 4) | (DIV_5)),
S, ((DIV_4 << 1) | (CLK_SRC1)),
|
ARM11 : 1200 MHz / 5 = 240 MHz
|
C, (CLK_SRC_PLL2 << 12) | (DIV_3 << 8) | \
(CLK_SRC_PLL2 << 4) | (DIV_5)),
S, ((DIV_4 << 1) | (CLK_SRC0)),
|
ARM11 : 1200 MHz / 3 = 400 MHz
|
C, (CLK_SRC_PLL2 << 12) | (DIV_3 << 8) | \
(CLK_SRC_PLL2 << 4) | (DIV_2)),
S, ((DIV_3 << 1) | (CLK_SRC1)),
|
ARM11 : 1200 MHz / 2 = 600 MHz
|
Bootloader QSD Clock Configuration –clock.c
- bootable/bootloader/legacy/arch_qsd8k/clock.c
- Scorpion core clock source is determined by SPSS_CLK_SEL (0xAC100104) register [2:1]; reset clock source is AXI Bus Clock
- arm11_clock_init() sets the Scorpion core clock source to 01: Unbuffered Snapdragon core processor PLL
val = readl(A11S_CLK_SEL);
val &= ~(0x3 << 1); // reset the clock source
val |= (1 << 1);//set clock source to SPLL
writel(val, A11S_CLK_SEL);
- The formula for SPLL is CLOCK = TCXO * L * 2, and the value of L can be configured in PLL_FSM_CTL_EXT(0xA8800010)[8:3]
val = readl(SCPLL_CTLE);
val &= ~(0x3F << 3);
val |= (0x14 << 3); //Use 0x1A instead of 0x14 for 998 MHz
writel(val, SCPLL_CTLE); //19.2 MHz*20*2=768 MHz, 19.2 MHz*26*2=998 MHz
Android Images
- Output folder is android/out/target/product/msm7627_surf
- usbloader –Android bootloader; for compliance with MIBIB architecture, a header is needed
- –
- MSM7K –appsboot.mbn (usbloader) and appsboothd.mbn
- –
- QSD8K –appsboot.mbn (40 bytes header + usbloader)
- boot.img –Image containing (boot header + Linux kernel + ramdisk/rootfs)
- system.img –Image containing Android user space applications and libraries, including libc.
Android Images –Bootimage Header
struct boot_img_hdr {
unsigned char magic[BOOT_MAGIC_SIZE];
unsigned kernel_size; /* size in bytes */
unsigned kernel_addr; /* physical load addr 0x10008000 */
unsigned ramdisk_size; /* size in bytes */
unsigned ramdisk_addr; /* physical load addr 0x11000000 */
unsigned tags_addr; /* physical addr for kernel tags
0x10000100 */
unsigned page_size; /* flash page size we assume */
unsigned unused[2]; /* future expansion: should be 0 */
unsigned char cmdline[BOOT_ARGS_SIZE];
unsigned id[8]; /* timestamp / checksum / sha1 / etc */
}
Android Kernel Configuration~
Kernel Boot Sequence
- Kernel initializing procedure
- zImage decompression
- –
- /kernel/arch/arm/boot/compressed/head.S
- ARM architecture specific kernel code
- –
- /kernel/arch/arm/kernel/head.S
- –
- /kernel/arch/arm/kernel/head-common.S
- Processor-independent kernel code
- –
- /kernel/init/main.c
- –
- start_kernel()
Memory Map Requirements of Linux Kernel on MSM
- Kernel physical memory start address recommended on 2 MB alignment
- In file /kernel/arch/arm/kernel/head.S
#if (PHYS_OFFSET & 0x001fffff)
#error "PHYS_OFFSET must be at an even 2MiB boundary!"





