mdm9x15:Re-organise the partitions
Move the boot partition as first partition to
avoid potential issue with nand atags passed to
the Kernel
CRs-Fixed: 331657
Change-Id: I57280bc5f72caa60af51b6757441124321f2be2a
diff --git a/include/lib/ptable.h b/include/lib/ptable.h
index 07fbf80..e1d970f 100644
--- a/include/lib/ptable.h
+++ b/include/lib/ptable.h
@@ -2,7 +2,7 @@
* Copyright (c) 2008, Google Inc.
* All rights reserved.
*
- * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -64,6 +64,7 @@
unsigned length, unsigned flags, char type, char perm);
struct ptentry *ptable_find(struct ptable *ptable, const char *name);
struct ptentry *ptable_get(struct ptable *ptable, int n);
+int ptable_get_index(struct ptable *ptable, const char *name);
int ptable_size(struct ptable *ptable);
void ptable_dump(struct ptable *ptable);
diff --git a/lib/ptable/ptable.c b/lib/ptable/ptable.c
index 895ed50..33afd9f 100644
--- a/lib/ptable/ptable.c
+++ b/lib/ptable/ptable.c
@@ -2,7 +2,7 @@
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
- *Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
+ *Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -97,3 +97,12 @@
{
return ptable->count;
}
+
+int ptable_get_index(struct ptable *ptable, const char *name)
+{
+ for(int i=0; i < ptable->count; i++) {
+ if (!strcmp(ptable->parts[i].name, name))
+ return i;
+ }
+ return -1;
+}
diff --git a/target/mdm9615/init.c b/target/mdm9615/init.c
old mode 100755
new mode 100644
index fd2f4f7..653986b
--- a/target/mdm9615/init.c
+++ b/target/mdm9615/init.c
@@ -87,6 +87,7 @@
extern void reboot(unsigned reboot_reason);
void update_ptable_apps_partitions(void);
void update_ptable_modem_partitions(void);
+void update_ptable_reorder(void);
extern int fake_key_get_state(void);
void target_init(void)
@@ -117,7 +118,11 @@
update_ptable_modem_partitions();
ptable_dump(&flash_ptable);
- flash_set_ptable(&flash_ptable);
+
+ /* Reorder the partition table */
+ update_ptable_reorder();
+
+ flash_set_ptable( &flash_ptable);
}
@@ -351,3 +356,18 @@
((struct flash_info *)flash_get_info())->num_blocks -
ptentry_ptr[ptn_index].start;
}
+
+void update_ptable_reorder(void)
+{
+ int boot_index;
+ struct ptentry boot_ptn;
+
+ boot_index = ptable_get_index(&flash_ptable, "boot");
+ if(boot_index == -1) {
+ dprintf (CRITICAL, "ERROR: Boot Partition not found. \n");
+ return;
+ }
+ boot_ptn = flash_ptable.parts[boot_index] ;
+ flash_ptable.parts[boot_index] = flash_ptable.parts[0];
+ flash_ptable.parts[0] = boot_ptn;
+}