aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVikram Pandita <vikram.pandita@ti.com>2011-02-26 15:27:30 -0800
committerVikram Pandita <vikram.pandita@ti.com>2011-02-27 14:51:23 -0800
commit472b65add898f278456fcd762b718bbcc7abf08f (patch)
treee103571cbd3eb2ae63b094929410ed89f5ce43ef
parent8a4cf6c9129c9d6aef9f9ec13090c2521051d892 (diff)
downloadu-boot-pandroid-472b65add898f278456fcd762b718bbcc7abf08f.tar.gz
omap4: blaze: fix GPT partition creation
Syncup blaze omap4 GPT partition creation logic with panda. The new partition table looks like: (hole) 128KB "xloader" 128KB "bootloader" 256KB (hole) 512K "boot" 8MB "system" 512MB "cache" 256MB "userdata" 512MB The GPT partion need not be flashed now. It can be done via fastboot. %fastboot oem format Note: Saveenv has been disabled for now since there is no environment partition Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
-rw-r--r--board/omap4430sdp/mmc.c389
-rw-r--r--board/omap4430sdp/omap4430sdp.c2
-rw-r--r--include/configs/omap4430sdp.h41
3 files changed, 306 insertions, 126 deletions
diff --git a/board/omap4430sdp/mmc.c b/board/omap4430sdp/mmc.c
index d187886d..e4ea72b2 100644
--- a/board/omap4430sdp/mmc.c
+++ b/board/omap4430sdp/mmc.c
@@ -1,111 +1,310 @@
/*
- * (C) Copyright 2004-2009 Texas Instruments, <www.ti.com>
- * Kishore Kadiyala <kishore.kadiyala@ti.com>
+ * Copyright (c) 2010, The Android Open Source Project.
*
- * See file CREDITS for list of people who contributed to this
- * project.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Neither the name of The Android Open Source Project nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
*/
-#include <common.h>
-#include <asm/io.h>
-#include <asm/arch/cpu.h>
-#include <asm/arch/mem.h>
-#if (CONFIG_FASTBOOT)
+#include <common.h>
+#include <mmc.h>
#include <fastboot.h>
-#endif
-void board_mmc_init(void)
-{
-#if (CONFIG_FASTBOOT)
-
- /* Partitons on EMMC preasent on OMAP4SDP required for Fastboot*/
- fastboot_ptentry ptn[10] = {
- {
- .name = "ptable",
- .start = 0x00, /*Sector Start */
- .length = 128*1024, /*128KB */
- .flags = 0,
- },
- {
- .name = "xloader",
- .start = 0x100, /*Sector Start */
- .length = 128*1024, /*128KB */
- .flags = 0,
- },
- {
- .name = "bootloader",
- .start = 0x200, /*Sector Start */
- .length = 256*1024, /*256KB */
- .flags = 0,
- },
- {
- .name = "environment",
- .start = 0x400, /* Sector Start */
- .length = 128*1024, /*128KB */
- .flags = FASTBOOT_PTENTRY_FLAGS_WRITE_ENV,
- },
- {
- .name = "boot",
- .start = 0x500, /* Sector Start */
- .length = 14*1024*1024, /*14MB */
- .flags = 0,
- },
- {
- .name = "recovery",
- .start = 0x7500, /*Sector Start */
- .length = 14*1024*1024, /*14MB */
- .flags = 0,
- },
- {
- .name = "system",
- .start = 0x11800, /* Sector Start */
- .length = 384*1024*1024, /*384MB */
- .flags = 0,
- },
- {
- .name = "userdata",
- .start = 0xD2000, /* Sector Start */
- .length = 512*1024*1024, /*512MB */
- .flags = 0,
- },
- {
- .name = "cache",
- .start = 0x1D5000, /* Sector Start */
- .length = 128*1024*1024, /*128MB */
- .flags = 0,
- },
- {
- .name = "media",
- .start = 0x217800, /* Sector Start */
- .length = 1024*1024*1024, /*1GB */
- .flags = 0,
- },
- /* Rest of the RAW Partitions can start from Sector start 0x27B622 */
+#define EFI_VERSION 0x00010000
+#define EFI_ENTRIES 128
+#define EFI_NAMELEN 36
+
+static const u8 partition_type[16] = {
+ 0xa2, 0xa0, 0xd0, 0xeb, 0xe5, 0xb9, 0x33, 0x44,
+ 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7,
+};
+
+static const u8 random_uuid[16] = {
+ 0xff, 0x1f, 0xf2, 0xf9, 0xd4, 0xa8, 0x0e, 0x5f,
+ 0x97, 0x46, 0x59, 0x48, 0x69, 0xae, 0xc3, 0x4e,
+};
+
+struct efi_entry {
+ u8 type_uuid[16];
+ u8 uniq_uuid[16];
+ u64 first_lba;
+ u64 last_lba;
+ u64 attr;
+ u16 name[EFI_NAMELEN];
+};
+
+struct efi_header {
+ u8 magic[8];
+
+ u32 version;
+ u32 header_sz;
+
+ u32 crc32;
+ u32 reserved;
+
+ u64 header_lba;
+ u64 backup_lba;
+ u64 first_lba;
+ u64 last_lba;
+
+ u8 volume_uuid[16];
+
+ u64 entries_lba;
+
+ u32 entries_count;
+ u32 entries_size;
+ u32 entries_crc32;
+} __attribute__((packed));
+
+struct ptable {
+ u8 mbr[512];
+ union {
+ struct efi_header header;
+ u8 block[512];
};
- int i;
- for (i = 0; i < 10; i++)
- fastboot_flash_add_ptn(&ptn[i]);
-#endif
+ struct efi_entry entry[EFI_ENTRIES];
+};
+
+static void init_mbr(u8 *mbr, u32 blocks)
+{
+ mbr[0x1be] = 0x00; // nonbootable
+ mbr[0x1bf] = 0xFF; // bogus CHS
+ mbr[0x1c0] = 0xFF;
+ mbr[0x1c1] = 0xFF;
+
+ mbr[0x1c2] = 0xEE; // GPT partition
+ mbr[0x1c3] = 0xFF; // bogus CHS
+ mbr[0x1c4] = 0xFF;
+ mbr[0x1c5] = 0xFF;
+
+ mbr[0x1c6] = 0x01; // start
+ mbr[0x1c7] = 0x00;
+ mbr[0x1c8] = 0x00;
+ mbr[0x1c9] = 0x00;
+
+ memcpy(mbr + 0x1ca, &blocks, sizeof(u32));
+
+ mbr[0x1fe] = 0x55;
+ mbr[0x1ff] = 0xaa;
+}
+
+static void start_ptbl(struct ptable *ptbl, unsigned blocks)
+{
+ struct efi_header *hdr = &ptbl->header;
+
+ memset(ptbl, 0, sizeof(*ptbl));
+
+ init_mbr(ptbl->mbr, blocks - 1);
+
+ memcpy(hdr->magic, "EFI PART", 8);
+ hdr->version = EFI_VERSION;
+ hdr->header_sz = sizeof(struct efi_header);
+ hdr->header_lba = 1;
+ hdr->backup_lba = blocks - 1;
+ hdr->first_lba = 34;
+ hdr->last_lba = blocks - 1;
+ memcpy(hdr->volume_uuid, random_uuid, 16);
+ hdr->entries_lba = 2;
+ hdr->entries_count = EFI_ENTRIES;
+ hdr->entries_size = sizeof(struct efi_entry);
+}
+
+static void end_ptbl(struct ptable *ptbl)
+{
+ struct efi_header *hdr = &ptbl->header;
+ u32 n;
+
+ n = crc32(0, 0, 0);
+ n = crc32(n, (void*) ptbl->entry, sizeof(ptbl->entry));
+ hdr->entries_crc32 = n;
+
+ n = crc32(0, 0, 0);
+ n = crc32(0, (void*) &ptbl->header, sizeof(ptbl->header));
+ hdr->crc32 = n;
+}
+
+int add_ptn(struct ptable *ptbl, u64 first, u64 last, const char *name)
+{
+ struct efi_header *hdr = &ptbl->header;
+ struct efi_entry *entry = ptbl->entry;
+ unsigned n;
+
+ if (first < 34) {
+ printf("partition '%s' overlaps partition table\n", name);
+ return -1;
+ }
+
+ if (last > hdr->last_lba) {
+ printf("partition '%s' does not fit\n", name);
+ return -1;
+ }
+ for (n = 0; n < EFI_ENTRIES; n++, entry++) {
+ if (entry->last_lba)
+ continue;
+ memcpy(entry->type_uuid, partition_type, 16);
+ memcpy(entry->uniq_uuid, random_uuid, 16);
+ entry->uniq_uuid[0] = n;
+ entry->first_lba = first;
+ entry->last_lba = last;
+ for (n = 0; (n < EFI_NAMELEN) && *name; n++)
+ entry->name[n] = *name++;
+ return 0;
+ }
+ printf("out of partition table entries\n");
+ return -1;
+}
+
+void import_efi_partition(struct efi_entry *entry)
+{
+ struct fastboot_ptentry e;
+ int n;
+ if (memcmp(entry->type_uuid, partition_type, sizeof(partition_type)))
+ return;
+ for (n = 0; n < (sizeof(e.name)-1); n++)
+ e.name[n] = entry->name[n];
+ e.name[n] = 0;
+ e.start = entry->first_lba;
+ e.length = (entry->last_lba - entry->first_lba + 1) * 512;
+ e.flags = 0;
+
+ if (!strcmp(e.name,"environment"))
+ e.flags |= FASTBOOT_PTENTRY_FLAGS_WRITE_ENV;
+ fastboot_flash_add_ptn(&e);
+
+ if (e.length > 0x100000)
+ printf("%8d %7dM %s\n", e.start, e.length/0x100000, e.name);
+ else
+ printf("%8d %7dK %s\n", e.start, e.length/0x400, e.name);
+}
+
+static int load_ptbl(void)
+{
+ static unsigned char data[512];
+ static struct efi_entry entry[4];
+ int n,m,r;
+ r = mmc_read(1, 1, data, 512);
+ if (r != 1) {
+ printf("error reading partition table\n");
+ return -1;
+ }
+ if (memcmp(data, "EFI PART", 8)) {
+ printf("efi partition table not found\n");
+ return -1;
+ }
+ for (n = 0; n < (128/4); n++) {
+ r = mmc_read(1, 1 + n, (void*) entry, 512);
+ if (r != 1) {
+ printf("partition read failed\n");
+ return 1;
+ }
+ for (m = 0; m < 4; m ++)
+ import_efi_partition(entry + m);
+ }
+ return 0;
+}
+
+struct partition {
+ const char *name;
+ unsigned size_kb;
+};
+
+static struct partition partitions[] = {
+ { "-", 128 },
+ { "xloader", 128 },
+ { "bootloader", 256 },
+ { "-", 512 },
+ { "boot", 8*1024 },
+ { "system", 512*1024 },
+ { "cache", 256*1024 },
+ { "userdata", 512*1024},
+ { "media", 0 },
+ { 0, 0 },
+};
+
+static struct ptable the_ptable;
+
+static int do_format(void)
+{
+ struct ptable *ptbl = &the_ptable;
+ unsigned sector_sz, blocks;
+ unsigned next;
+ int n;
+
+ if (mmc_init(1)) {
+ printf("mmc init failed?\n");
+ return -1;
+ }
+
+ mmc_info(1, &sector_sz, &blocks);
+ printf("blocks %d\n", blocks);
+
+ start_ptbl(ptbl, blocks);
+ n = 0;
+ next = 0;
+ for (n = 0, next = 0; partitions[n].name; n++) {
+ unsigned sz = partitions[n].size_kb * 2;
+ if (!strcmp(partitions[n].name,"-")) {
+ next += sz;
+ continue;
+ }
+ if (sz == 0)
+ sz = blocks - next;
+ if (add_ptn(ptbl, next, next + sz - 1, partitions[n].name))
+ return -1;
+ next += sz;
+ }
+ end_ptbl(ptbl);
+
+ fastboot_flash_reset_ptn();
+ if (mmc_write(1, (void*) ptbl, 0, sizeof(struct ptable)) != 1)
+ return -1;
+
+ printf("\nnew partition table:\n");
+ load_ptbl();
+
+ return 0;
}
int fastboot_oem(const char *cmd)
{
if (!strcmp(cmd,"format"))
- printf("\nBlze: format oem : not implemented yet\n");
+ return do_format();
return -1;
}
+
+void board_mmc_init(void)
+{
+ /* nothing to do this early */
+}
+
+int board_late_init(void)
+{
+ if (mmc_init(1)) {
+ printf("mmc init failed?\n");
+ return 1;
+ }
+ printf("\nefi partition table:\n");
+ return load_ptbl();
+}
+
+
diff --git a/board/omap4430sdp/omap4430sdp.c b/board/omap4430sdp/omap4430sdp.c
index 2a90657e..b00ef956 100644
--- a/board/omap4430sdp/omap4430sdp.c
+++ b/board/omap4430sdp/omap4430sdp.c
@@ -473,6 +473,7 @@ int board_init(void)
gpmc_init();
+#if 0 /* No eMMC env partition for now */
/* Intializing env functional pointers with eMMC */
boot_env_get_char_spec = mmc_env_get_char_spec;
boot_env_init = mmc_env_init;
@@ -480,6 +481,7 @@ int board_init(void)
boot_env_relocate_spec = mmc_env_relocate_spec;
env_ptr = (env_t *) (CFG_FLASH_BASE + CFG_ENV_OFFSET);
env_name_spec = mmc_env_name_spec;
+#endif
/* board id for Linux */
gd->bd->bi_arch_number = MACH_TYPE_OMAP_4430SDP;
diff --git a/include/configs/omap4430sdp.h b/include/configs/omap4430sdp.h
index d091b7a6..0cd3dd57 100644
--- a/include/configs/omap4430sdp.h
+++ b/include/configs/omap4430sdp.h
@@ -37,6 +37,8 @@
#define CONFIG_4430SDP 1 /* working with SDP */
#define CONFIG_FASTBOOT 1 /* Using fastboot interface */
+#define BOARD_LATE_INIT 1
+
/* SDP revisions */
#define SDP_4430_VIRTIO 0x1
#define SDP_4430_V1 0x2
@@ -147,8 +149,12 @@
root=/dev/nfs rw nfsroot=128.247.77.158:/home/a0384864/wtbu/rootfs \
ip=dhcp"
#else
-#define CONFIG_BOOTARGS "root=/dev/ram0 rw mem=512M console=ttyS2,115200n8 \
-initrd=0x81600000,64M ramdisk_size=65536"
+
+#define CONFIG_BOOTARGS "console=ttyO2,115200n8 mem=456M@0x80000000 mem=512M@0xA0000000" \
+ " init=/init vram=10M omapfb.vram=0:4M androidboot.console=ttyO2"
+
+#define CONFIG_BOOTCOMMAND "booti mmc1"
+
#endif
#define CONFIG_NETMASK 255.255.254.0
@@ -230,39 +236,13 @@ initrd=0x81600000,64M ramdisk_size=65536"
#define PHYS_FLASH_SIZE_SDPV2 SZ_128M
#define PHYS_FLASH_SIZE SZ_32M
-/* REVISIT if once NAND/NOR/ONENAND support is added on OMAP4SDP */
-#ifdef OMAP4_NAND_NOR_ONENAND
-#define CFG_FLASH_BASE boot_flash_base
-#define PHYS_FLASH_SECT_SIZE boot_flash_sec
-/* Dummy declaration of flash banks to get compilation right */
-#define CFG_FLASH_BANKS_LIST {0, 0}
-
-#define CFG_MONITOR_BASE CFG_FLASH_BASE /* Monitor at start of flash */
-#define CFG_ONENAND_BASE ONENAND_MAP
-#define CFG_ENV_IS_IN_NAND 1
-#define CFG_ENV_IS_IN_ONENAND 1
-#define CFG_ENV_IS_IN_FLASH 1
-#define ONENAND_ENV_OFFSET 0xc0000 /* environment starts here */
-#define SMNAND_ENV_OFFSET 0xc0000 /* environment starts here */
-
-#define CFG_ENV_SECT_SIZE boot_flash_sec
-#define CFG_ENV_OFFSET boot_flash_off
-#define CFG_ENV_ADDR boot_flash_env_addr
-#endif
+#define CFG_FLASH_BASE 0x0
#define CFG_MONITOR_BASE CFG_FLASH_BASE /* Monitor at start of flash */
#define CFG_ONENAND_BASE ONENAND_MAP
-/* eMMC Variables */
-#define CFG_ENV_IS_IN_EMMC 1
-#define CFG_FLASH_BASE 0x0
-#define CFG_ENV_SECT_SIZE SZ_128K
-#define CFG_ENV_OFFSET 0x400
-#define CFG_ENV_ADDR 0x400
-
-#define ENV_IS_VARIABLE 1
-
+#define CFG_ENV_IS_NOWHERE 1
/* Fastboot variables */
#define CFG_FASTBOOT_TRANSFER_BUFFER (PHYS_SDRAM_1 + SZ_16M)
#define CFG_FASTBOOT_TRANSFER_BUFFER_SIZE (SZ_512M - SZ_16M)
@@ -288,7 +268,6 @@ initrd=0x81600000,64M ramdisk_size=65536"
#define CFG_JFFS2_FIRST_BANK CFG_MAX_FLASH_BANKS /* use flash_info[2] */
#define CFG_JFFS2_NUM_BANKS 1
-#define ENV_IS_VARIABLE 1
#endif
#ifndef __ASSEMBLY__