[app/aboot]: Add recovery and update support in froyo.

- Read radio.img from Cache partition and write it to FOTA partition.
- Changed partition size for Cache and added misc partition for recovery.
- Changed product name for fastboot update.

Change-Id: I831b2bb757865a0a4108cab66950691d5db9b8b2
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index fb80f38..ccc88ad 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -47,6 +47,8 @@
 #include "bootimg.h"
 #include "fastboot.h"
 
+#define EXPAND(NAME) #NAME
+#define TARGET(NAME) EXPAND(NAME)
 #define DEFAULT_CMDLINE "mem=100M console=null";
 
 #ifdef MEMBASE
@@ -628,7 +630,7 @@
 	fastboot_register("continue", cmd_continue);
 	fastboot_register("reboot", cmd_reboot);
 	fastboot_register("reboot-bootloader", cmd_reboot_bootloader);
-	fastboot_publish("product", "swordfish");
+	fastboot_publish("product", TARGET(BOARD));
 	fastboot_publish("kernel", "lk");
 
 	fastboot_init(target_get_scratch_address(), 120 * 1024 * 1024);
diff --git a/app/aboot/recovery.c b/app/aboot/recovery.c
index e9b25e5..f01e23f 100644
--- a/app/aboot/recovery.c
+++ b/app/aboot/recovery.c
@@ -245,7 +245,7 @@
 
 	if (!strcmp("update-radio",msg.command)) {
 		valid_command = 1;
-		strcpy(partition_name, "AMSS");
+		strcpy(partition_name, "FOTA");
 	}
 
 	//Todo: Add support for bootloader update too.
@@ -255,8 +255,6 @@
 		return 0; // Boot in normal mode
 	}
 
-// Disabling image update
-# if 0
 	if (read_update_header_for_bootloader(&header)) {
 		strcpy(msg.status, "invalid-update");
 		goto SEND_RECOVERY_MSG;
@@ -266,7 +264,6 @@
 		strcpy(msg.status, "failed-update");
 		goto SEND_RECOVERY_MSG;
 	}
-# endif
 	strcpy(msg.status, "OKAY");
 
 SEND_RECOVERY_MSG:
diff --git a/makefile b/makefile
index 7ea95ad..5f88084 100644
--- a/makefile
+++ b/makefile
@@ -106,6 +106,7 @@
 
 # add some automatic configuration defines
 DEFINES += \
+	BOARD=$(PROJECT) \
 	PROJECT_$(PROJECT)=1 \
 	TARGET_$(TARGET)=1 \
 	PLATFORM_$(PLATFORM)=1 \
diff --git a/target/msm7625_ffa/init.c b/target/msm7625_ffa/init.c
index e686d5b..499a988 100644
--- a/target/msm7625_ffa/init.c
+++ b/target/msm7625_ffa/init.c
@@ -62,17 +62,22 @@
 	},
 	{
 		.start = 720,
-		.length = 40 /* 5MB */,
+		.length = 240 /* 30MB */,
 		.name = "cache",
 	},
 	{
-		.start = 760,
+		.start = 960,
+		.length = 3 /* 384KB */,
+		.name = "misc",
+	},
+	{
+		.start = 963,
 		.length = 40 /* 5MB */,
 		.name = "recovery",
 	},
 	{
-		.start = 800,
-		.length = 720 /* 90MB */,
+		.start = 1003,
+		.length = 517 /* 65MB */,
 		.name = "userdata",
 	},
 };
diff --git a/target/msm7625_surf/init.c b/target/msm7625_surf/init.c
index 01a8a46..df075f8 100644
--- a/target/msm7625_surf/init.c
+++ b/target/msm7625_surf/init.c
@@ -62,17 +62,22 @@
 	},
 	{
 		.start = 720,
-		.length = 40  /* 5MB */,
+		.length = 240  /* 30MB */,
 		.name = "cache",
 	},
 	{
-		.start = 760,
+		.start = 960,
+		.length = 3 /* 384KB */,
+		.name = "misc",
+	},
+	{
+		.start = 963,
 		.length = 40 /* 5MB */,
 		.name = "recovery",
 	},
 	{
-		.start = 800,
-		.length = 720 /* 90MB */,
+		.start = 1003,
+		.length = 517 /* 65MB */,
 		.name = "userdata",
 	},
 };
diff --git a/target/msm7627_ffa/init.c b/target/msm7627_ffa/init.c
index db58e21..f54a3a9 100644
--- a/target/msm7627_ffa/init.c
+++ b/target/msm7627_ffa/init.c
@@ -71,11 +71,16 @@
 	},
 	{
 		.start = 808,
-		.length = 40  /* 5MB */,
+		.length = 240 /* 30MB */,
 		.name = "cache",
 	},
 	{
-		.start = 848,
+		.start = 1048,
+		.length = 3   /* 384KB */,
+		.name = "misc",
+	},
+	{
+		.start = 1051,
 		.length = VARIABLE_LENGTH,
 		.name = "userdata",
 	},
diff --git a/target/msm7627_surf/init.c b/target/msm7627_surf/init.c
index 9014e2d..7089e0c 100644
--- a/target/msm7627_surf/init.c
+++ b/target/msm7627_surf/init.c
@@ -71,11 +71,16 @@
 	},
 	{
 		.start = 808,
-		.length = 40  /* 5MB */,
+		.length = 240 /* 30MB */,
 		.name = "cache",
 	},
 	{
-		.start = 848,
+		.start = 1048,
+		.length = 3   /* 384KB */,
+		.name = "misc",
+	},
+	{
+		.start = 1051,
 		.length = VARIABLE_LENGTH,
 		.name = "userdata",
 	},
diff --git a/target/msm7630_surf/init.c b/target/msm7630_surf/init.c
index 4d3e468..816d8b1 100644
--- a/target/msm7630_surf/init.c
+++ b/target/msm7630_surf/init.c
@@ -89,11 +89,16 @@
 	},
 	{
 		.start = DIFF_START_ADDR,
-		.length = 5 /* In MB */,
+		.length = 30 /* In MB */,
 		.name = "cache",
 	},
 	{
 		.start = DIFF_START_ADDR,
+		.length = 1 /* In MB */,
+		.name = "misc",
+	},
+	{
+		.start = DIFF_START_ADDR,
 		.length = VARIABLE_LENGTH,
 		.name = "userdata",
 	},
diff --git a/target/qsd8250_ffa/init.c b/target/qsd8250_ffa/init.c
index 6887d6d..a4220e1 100644
--- a/target/qsd8250_ffa/init.c
+++ b/target/qsd8250_ffa/init.c
@@ -66,11 +66,16 @@
 	},
 	{
 		.start = 800,
-		.length = 40 /* 5MB */,
+		.length = 240 /* 30MB */,
 		.name = "cache",
 	},
 	{
-		.start = 840,
+		.start = 1040,
+		.length = 3 /* 384KB */,
+		.name = "misc",
+	},
+	{
+		.start = 1043,
 		.length = VARIABLE_LENGTH,
 		.name = "userdata",
 	},
diff --git a/target/qsd8250_surf/init.c b/target/qsd8250_surf/init.c
index dcddadb..07428ca 100644
--- a/target/qsd8250_surf/init.c
+++ b/target/qsd8250_surf/init.c
@@ -66,11 +66,16 @@
 	},
 	{
 		.start = 800,
-		.length = 40 /* 5MB */,
+		.length = 240 /* 30MB */,
 		.name = "cache",
 	},
 	{
-		.start = 840,
+		.start = 1040,
+		.length = 3 /* 384KB */,
+		.name = "misc",
+	},
+	{
+		.start = 1043,
 		.length = VARIABLE_LENGTH,
 		.name = "userdata",
 	},
diff --git a/target/qsd8650a_st1x/init.c b/target/qsd8650a_st1x/init.c
index bfa735d..8146eb4 100644
--- a/target/qsd8650a_st1x/init.c
+++ b/target/qsd8650a_st1x/init.c
@@ -66,11 +66,16 @@
 	},
 	{
 		.start = 800,
-		.length = 40 /* 5MB */,
+		.length = 240 /* 30MB */,
 		.name = "cache",
 	},
 	{
-		.start = 840,
+		.start = 1040,
+		.length = 3 /* 384KB */,
+		.name = "misc",
+	},
+	{
+		.start = 1043,
 		.length = VARIABLE_LENGTH,
 		.name = "userdata",
 	},