summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShohei Sakamoto <sakamotos@casio.co.jp>2015-11-19 12:50:00 +0900
committerShohei Sakamoto <sakamotos@casio.co.jp>2015-11-20 17:17:53 +0900
commitcea433c3ce71a0a9277fa59037f25ad10e49900f (patch)
tree70ea22c9bd57895722fb72ac6675cef2aa2fb9df
parent7fc5f15b78397b51e5b7d9b7e1825e918caad0f5 (diff)
downloadkoi-uboot-cea433c3ce71a0a9277fa59037f25ad10e49900f.tar.gz
Adjust alignment of info partition
Align to Write-Protect-Group boundary. Change-Id: Icaa7fe01d8fb0a7657492689c1451ed586c8a114 Signed-off-by: Shohei Sakamoto <sakamotos@casio.co.jp>
-rw-r--r--board/samsung/koi/koi.c121
-rw-r--r--disk/part_efi.c2
-rw-r--r--include/configs/koi.h26
3 files changed, 85 insertions, 64 deletions
diff --git a/board/samsung/koi/koi.c b/board/samsung/koi/koi.c
index eff972fe3..bba8a3108 100644
--- a/board/samsung/koi/koi.c
+++ b/board/samsung/koi/koi.c
@@ -38,19 +38,19 @@
#define DEBOUNCE_DELAY 10000
#define OM_1stSDMMC_2ndUSB 0x2
-/* these are in number of blocks */
-#define RECOVERY_PART_START CONFIG_GPT_RECOVERY_START / 512
-/* all these sizes are in MiB */
-#define RECOVERY_PART_SIZE CONFIG_GPT_RECOVERY_SIZE * 1024 * 2
-#define SYSTEM_PART_SIZE CONFIG_GPT_SYSTEM_SIZE * 1024 * 2
-#define USERDATA_PART_SIZE CONFIG_GPT_USERDATA_SIZE * 1024 * 2
-#define CACHE_PART_SIZE CONFIG_GPT_CACHE_SIZE * 1024 * 2
-#define BOOT_PART_SIZE CONFIG_GPT_BOOT_SIZE * 1024 * 2
-/* this size is in KiB */
-#define BOOTLOADER_PART_SIZE CONFIG_GPT_BOOTLOADER_SIZE * 2
-
#define MAX_GPT_PART 8
+static unsigned long part_blknum[MAX_GPT_PART] = {
+ CONFIG_GPT_RECOVERY_BLKNUM,
+ CONFIG_GPT_SYSTEM_BLKNUM,
+ CONFIG_GPT_USERDATA_BLKNUM,
+ CONFIG_GPT_CACHE_BLKNUM,
+ CONFIG_GPT_MISC_BLKNUM,
+ CONFIG_GPT_BOOT_BLKNUM,
+ CONFIG_GPT_INFO_BLKNUM,
+ CONFIG_GPT_BOOTLOADER_BLKNUM
+};
+
#define DEV_NUM 0
DECLARE_GLOBAL_DATA_PTR;
@@ -466,7 +466,7 @@ static void set_dieid(char *buf)
setenv("dieid#", &dieid);
}
-static void get_bootarg_from_info_partition(char *buf)
+static int get_bootarg_from_info_partition(char *buf)
{
unsigned long start, count;
unsigned char pid;
@@ -478,7 +478,7 @@ static void get_bootarg_from_info_partition(char *buf)
get_boot_part_info(dev_num, 7, &start, &count, &pid);
if (pid != 0x83 && pid != 0xee)
- return;
+ return -1;
/*
serial,0123456789abcdef
@@ -504,6 +504,8 @@ static void get_bootarg_from_info_partition(char *buf)
strncat(buf, p, 16);
/* also set the die-id based on serial no */
set_dieid(p);
+ } else {
+ return -1;
}
if (strncmp("btmac", (char *)0x48000018, 5) == 0) {
p = (char *)0x4800001e;
@@ -527,11 +529,27 @@ static void get_bootarg_from_info_partition(char *buf)
strcat(buf, " snd_soc_ak4678.IDVol=");
strcat(buf, startstr);
}
+ return 0;
+}
+
+static int copy_info_partition(void)
+{
+ char arg[50];
+
+ strcpy(arg, "mmc read 0 0x48000000 0x72AD10 0x1");
+ run_command(arg, 0);
+ if (strncmp("serial", (char *)0x48000000, 6) == 0) {
+ strcpy(arg, "mmc write 0 0x48000000 0x72C000 0x1");
+ run_command(arg, 0);
+ return 0;
+ }
+ return -1;
}
+
static unsigned int mkbootimg_hdr[CFG_FASTBOOT_MKBOOTIMAGE_PAGE_SIZE/4];
-static void get_bootarg_from_boot_partition(char *buf)
+static void get_bootarg_from_img_hdr(char *buf)
{
struct fastboot_boot_img_hdr *fb_hdr = (struct fastboot_boot_img_hdr *)mkbootimg_hdr;
@@ -784,49 +802,50 @@ int board_late_init(void)
printf("boot mode is SDMMC, skip GPT partitioning\n");
#endif
} else {
- if(find_gpt_part_name("recovery") != 0 || find_gpt_part_name("boot") != 0
- || find_gpt_part_name("info") != 0
- || find_gpt_part_name("bootloader") != 0)
- {
- run_command("env default -f",0);
- run_command("run make_gpt_part",0);
- printf("Creating gpt partitions!!\n");
- } else {
- rw_img_hdr(mode==CONFIG_FACTORY_RESET_MODE ? 1:0, "read");
- get_bootarg_from_info_partition(tmp_buf);
- get_bootarg_from_boot_partition(tmp_buf);
- setenv("bootargs", tmp_buf);
- }
-
- if (find_gpt_part_name("recovery") == 0 || find_gpt_part_name("info") == 0) {
- /* Total 7 partitions right now */
- unsigned long start[MAX_GPT_PART];
- unsigned long count[MAX_GPT_PART];
- unsigned char pid[MAX_GPT_PART];
- int i;
-
- for (i = 0; i < MAX_GPT_PART; i++) {
- get_boot_part_info(DEV_NUM, i+1, &start[i], &count[i], &pid[i]);
- if (pid[i] != 0xee)
- printf("Part%d: NOT GPT PARTITION ERROR !!\n", i);
+ int create_gpt = 0;
+ if (find_gpt_part_name("recovery") != 0
+ || find_gpt_part_name("boot") != 0
+ || find_gpt_part_name("info") != 0
+ || find_gpt_part_name("bootloader") != 0) {
+ create_gpt = 1;
+ } else {
+ unsigned long start, count;
+ unsigned char pid;
+ int i;
+
+ /* check if partitions are aligned with the partition
+ * information obtained from the partition table.
+ */
+ for (i = 0; i < MAX_GPT_PART; i++) {
+ get_boot_part_info(DEV_NUM, i+1, &start, &count, &pid);
+ if (i == 0 && start != CONFIG_GPT_RECOVERY_START_BLK) {
+ create_gpt = 1;
+ break;
+ } else if (pid != 0xee) {
+ printf("Part%d: NOT GPT PARTITION ERROR !!\n", i);
+ create_gpt = 1;
+ break;
+ } else if (count != part_blknum[i]) {
+ printf("Part%d: Block Number differ!!\n", i);
+ create_gpt = 1;
+ break;
+ }
+ }
}
-
- /* check if partitions are aligned with the partition
- * information obtained from the partition table.
- */
- if ((start[0] != RECOVERY_PART_START) || /* part1 - recovery */
- (count[0] != RECOVERY_PART_SIZE) ||
- (count[1] != SYSTEM_PART_SIZE) || /* part2 - system */
- (count[2] != USERDATA_PART_SIZE) || /* part3 - userdata */
- (count[3] != CACHE_PART_SIZE) || /* part4 - cache */
- (count[5] != BOOT_PART_SIZE)|| /* part6 - boot */
- (count[7] != BOOTLOADER_PART_SIZE)) { /* part8 - bootloader */
+ if (create_gpt) {
run_command("env default -f",0);
run_command("run make_gpt_part",0);
- printf("Re-Creating gpt partitions!!\n");
+ printf("Creating gpt partitions!!\n");
}
}
+
+ if (get_bootarg_from_info_partition(tmp_buf)) {
+ if (copy_info_partition() == 0) // copy from old location
+ get_bootarg_from_info_partition(tmp_buf); // retry
}
+ rw_img_hdr(mode==CONFIG_FACTORY_RESET_MODE ? 1:0, "read");
+ get_bootarg_from_img_hdr(tmp_buf);
+ setenv("bootargs", tmp_buf);
#endif
if (mode == CONFIG_FACTORY_RESET_MODE) {
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 81ce5cc26..cd8685ebe 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -142,7 +142,7 @@ int find_efi_part_name(block_dev_desc_t * dev_desc, const char *name)
if (!dev_desc) {
printf("%s: Invalid Argument(s)\n", __func__);
- return;
+ return -1;
}
/* This function validates AND fills in the GPT header and PTE */
if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
diff --git a/include/configs/koi.h b/include/configs/koi.h
index 6216f161c..0516b95cf 100644
--- a/include/configs/koi.h
+++ b/include/configs/koi.h
@@ -241,15 +241,17 @@
* until then, update the start and size, if required,
* at both places
*/
-#define CONFIG_GPT_RECOVERY_START 0x11A0000
-#define CONFIG_GPT_RECOVERY_SIZE 50 /* MB */
-#define CONFIG_GPT_SYSTEM_SIZE 512 /* MB */
-#define CONFIG_GPT_USERDATA_SIZE 2700 /* MB */
-#define CONFIG_GPT_CACHE_SIZE 360 /* MB */
-#define CONFIG_GPT_MISC_SIZE 8 /* KB */
-#define CONFIG_GPT_BOOT_SIZE 30 /* MB */
-#define CONFIG_GPT_INFO_SIZE 8 /* KB */
-#define CONFIG_GPT_BOOTLOADER_SIZE 512 /* KB */
+#define CONFIG_GPT_RECOVERY_START_BLK 36096
+#define CONFIG_GPT_RECOVERY_BLKNUM 102400
+#define CONFIG_GPT_SYSTEM_BLKNUM 1048576
+#define CONFIG_GPT_USERDATA_BLKNUM 5529600
+#define CONFIG_GPT_CACHE_BLKNUM 737280
+#define CONFIG_GPT_MISC_BLKNUM 16
+#define CONFIG_GPT_BOOT_BLKNUM 66288
+#define CONFIG_GPT_INFO_BLKNUM 16384
+#define CONFIG_GPT_BOOTLOADER_BLKNUM 16384
+
+#define OLD_GPT_INFO_START_BLK 7515408 /* info offset of before KOI00A */
#define CONFIG_GPT_ENV \
"uuid_disk=12345678-1234-1234-1234-123456789012;"\
@@ -258,9 +260,9 @@
"name=userdata,size=2700MiB,uuid=0FC63DAF-8483-4772-8E79-3D69D8477DE4;"\
"name=cache,size=360MiB,uuid=0FC63DAF-8483-4772-8E79-3D69D8477DE4;" \
"name=misc,size=8KiB,uuid=0FC63DAF-8483-4772-8E79-3D69D8477DE4;" \
- "name=boot,size=30MiB,uuid=0FC63DAF-8483-4772-8E79-3D69D8477DE4;" \
- "name=info,size=8KiB,uuid=0FC63DAF-8483-4772-8E79-3D69D8477DE4;" \
- "name=bootloader,size=512KiB,uuid=0FC63DAF-8483-4772-8E79-3D69D8477DE4\0"
+ "name=boot,size=33144KiB,uuid=0FC63DAF-8483-4772-8E79-3D69D8477DE4;" \
+ "name=info,size=8MiB,uuid=0FC63DAF-8483-4772-8E79-3D69D8477DE4;" \
+ "name=bootloader,size=8MiB,uuid=0FC63DAF-8483-4772-8E79-3D69D8477DE4\0"
#ifdef CONFIG_CPU_EXYNOS3250
/* CFG_FASTBOOT_TRANSFER_BUFFER + CFG_FASTBOOT_TRANSFER_BUFFER_SIZE */