fix flash locking issue
diff --git a/objects/control_host_obj.c b/objects/control_host_obj.c
index 672ef85..0e33586 100644
--- a/objects/control_host_obj.c
+++ b/objects/control_host_obj.c
@@ -208,7 +208,7 @@
NULL); /* user_data */
control_host_set_debug_mode(control_host,0);
- control_host_set_flash_side(control_host,"primary");
+ control_host_set_flash_side(control_host,"golden");
/* Export the object (@manager takes its own reference to @object) */
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
diff --git a/objects/flash_bios_obj.c b/objects/flash_bios_obj.c
index b16aca0..2d8303f 100644
--- a/objects/flash_bios_obj.c
+++ b/objects/flash_bios_obj.c
@@ -58,9 +58,6 @@
{
printf("ERROR FlashControl: Unable to init\n");
}
- //TODO: have to tune flash twice
- sleep(1);
- update(f,obj_path);
}
return TRUE;
}
diff --git a/objects/flasher_obj.c b/objects/flasher_obj.c
index 93faa69..b172d3a 100644
--- a/objects/flasher_obj.c
+++ b/objects/flasher_obj.c
@@ -52,7 +52,8 @@
static int32_t ffs_index = -1;
static uint8_t FLASH_OK = 0;
-static uint8_t FLASH_ERROR = 1;
+static uint8_t FLASH_ERROR = 0x01;
+static uint8_t FLASH_SETUP_ERROR = 0x02;
static struct blocklevel_device *bl;
static int erase_chip(void)
@@ -209,7 +210,7 @@
close_devs();
}
-static void flash_access_setup_bmc(bool use_lpc, bool need_write)
+static int flash_access_setup_bmc(bool use_lpc, bool need_write)
{
int rc;
printf("Setting up BMC flash\n");
@@ -220,18 +221,19 @@
rc = ast_sf_open(AST_SF_TYPE_BMC, &fl_ctrl);
if (rc) {
fprintf(stderr, "Failed to open controller\n");
- exit(1);
+ return FLASH_SETUP_ERROR;
}
/* Open flash chip */
rc = flash_init(fl_ctrl, &fl_chip);
if (rc) {
fprintf(stderr, "Failed to open flash chip\n");
- exit(1);
+ return FLASH_SETUP_ERROR;
}
/* Setup cleanup function */
atexit(flash_access_cleanup_bmc);
+ return FLASH_OK;
}
static void flash_access_cleanup_pnor(void)
@@ -254,7 +256,7 @@
close_devs();
}
-static void flash_access_setup_pnor(bool use_lpc, bool use_sfc, bool need_write)
+static int flash_access_setup_pnor(bool use_lpc, bool use_sfc, bool need_write)
{
int rc;
printf("Setting up BIOS flash\n");
@@ -268,7 +270,7 @@
rc = sfc_open(&fl_ctrl);
if (rc) {
fprintf(stderr, "Failed to open controller\n");
- exit(1);
+ return FLASH_SETUP_ERROR;
}
using_sfc = true;
} else {
@@ -277,7 +279,7 @@
rc = ast_sf_open(AST_SF_TYPE_PNOR, &fl_ctrl);
if (rc) {
fprintf(stderr, "Failed to open controller\n");
- exit(1);
+ return FLASH_SETUP_ERROR;
}
#ifdef __powerpc__
}
@@ -287,7 +289,7 @@
rc = flash_init(fl_ctrl, &fl_chip);
if (rc) {
fprintf(stderr, "Failed to open flash chip\n");
- exit(1);
+ return FLASH_SETUP_ERROR;
}
/* Unlock flash (PNOR only) */
@@ -296,6 +298,7 @@
/* Setup cleanup function */
atexit(flash_access_cleanup_pnor);
+ return FLASH_OK;
}
uint8_t flash(FlashControl* flash_control,bool bmc_flash, uint32_t address, char* write_file, char* obj_path)
@@ -313,22 +316,28 @@
if (bmc_flash) {
if (!has_ast) {
fprintf(stderr, "No BMC on this platform\n");
- return FLASH_ERROR;
+ return FLASH_SETUP_ERROR;
}
- flash_access_setup_bmc(use_lpc, erase || program);
+ rc = flash_access_setup_bmc(use_lpc, erase || program);
+ if (rc) {
+ return FLASH_SETUP_ERROR;
+ }
} else {
if (!has_ast && !has_sfc) {
fprintf(stderr, "No BMC nor SFC on this platform\n");
- return FLASH_ERROR;
+ return FLASH_SETUP_ERROR;
}
- flash_access_setup_pnor(use_lpc, has_sfc, erase || program);
+ rc = flash_access_setup_pnor(use_lpc, has_sfc, erase || program);
+ if (rc) {
+ return FLASH_SETUP_ERROR;
+ }
}
rc = flash_get_info(fl_chip, &fl_name,
&fl_total_size, &fl_erase_granule);
if (rc) {
fprintf(stderr, "Error %d getting flash info\n", rc);
- return FLASH_ERROR;
+ return FLASH_SETUP_ERROR;
}
#endif
if (strcmp(write_file,"")!=0)
@@ -356,6 +365,10 @@
else
{
printf("Flash tuned\n");
+ //tune twice
+ if (!bmc_flash) {
+ flash_access_setup_pnor(use_lpc, has_sfc, erase || program);
+ }
}
return FLASH_OK;
}
@@ -407,7 +420,7 @@
}
int rc = flash(flash_control,bmc_flash,address,cmd->argv[2],cmd->argv[3]);
- if (rc == FLASH_ERROR) {
+ if (rc) {
flash_message(connection,cmd->argv[3],"error","Flash Error");
} else {
flash_message(connection,cmd->argv[3],"done","");