made pflash call async
diff --git a/bin/flash_manager.py b/bin/flash_manager.py
index 9a0f450..980341b 100644
--- a/bin/flash_manager.py
+++ b/bin/flash_manager.py
@@ -10,14 +10,14 @@
DBUS_NAME = 'org.openbmc.managers.Flash'
-OBJ_NAME = '/org/openbmc/managers/'+sys.argv[1]
+OBJ_NAME = '/org/openbmc/managers/Flash'
TFTP_PORT = 69
DOWNLOAD_DIR = '/tmp'
class FlashManagerObject(dbus.service.Object):
def __init__(self,bus,name):
self.dbus_objects = { }
-
+ self.status = { 'bios' : 'OK', 'bmc' : 'OK' }
dbus.service.Object.__init__(self,bus,name)
## load utilized objects
self.dbus_objects = {
@@ -33,6 +33,15 @@
}
}
bus = dbus.SessionBus()
+ bus.add_signal_receiver(self.UpdatedHandler,
+ dbus_interface = "org.openbmc.Flash", signal_name = "Updated", path_keyword='path')
+
+
+ def UpdatedHandler(self,path = None):
+ print "Flash update finish: "+path
+ for flash in self.dbus_objects:
+ if (path == self.dbus_objects[flash]['object_name']):
+ self.status[flash] = 'OK'
def getInterface(self,name):
o = self.dbus_objects[name]
@@ -40,20 +49,31 @@
return dbus.Interface(obj,o['interface_name'])
@dbus.service.method(DBUS_NAME,
+ in_signature='', out_signature='a{ss}')
+ def getStatus(self):
+ return self.status
+
+ @dbus.service.method(DBUS_NAME,
in_signature='sss', out_signature='')
def updateFromTftp(self,flash,url,filename):
if (self.dbus_objects.has_key(flash) == False):
- print "Error: Not a valid flash device: "+flash
+ print "ERROR FlashManager: Not a valid flash device: "+flash
return
try:
+ ## need to make download async
+ self.status[flash]="DOWNLOADING"
+ filename = str(filename)
client = tftpy.TftpClient(url, TFTP_PORT)
+ print "Downloading: "+filename+" from "+url
outfile = DOWNLOAD_DIR+"/"+filename
- client.download(filename,outfile)
+ client.download(filename,outfile)
intf = self.getInterface(flash)
+ self.status[flash]="FLASHING"
intf.update(outfile)
except Exception as e:
- print "ERROR: "+str(e)
+ print "ERROR FlashManager: "+str(e)
+ self.status="ERROR"
diff --git a/objects/flash_bios_obj.c b/objects/flash_bios_obj.c
index a4c51bd..2a5471b 100644
--- a/objects/flash_bios_obj.c
+++ b/objects/flash_bios_obj.c
@@ -14,9 +14,12 @@
gpointer user_data)
{
flash_complete_init(f,invocation);
- //tune flash
- g_print("Tuning BIOS Flash\n");
- flash_access_setup_pnor(true, false, false);
+
+ #ifdef __arm__
+ printf("Tuning BIOS Flash\n");
+ flash_access_setup_pnor(true, false, false);
+ #endif
+
return TRUE;
}
@@ -26,21 +29,25 @@
gchar* write_file,
gpointer user_data)
{
- g_print("Flashing BIOS from file\n");
- // get size from file
- struct stat stbuf;
- uint32_t address = 0, read_size = 0, write_size = 0;
+ printf("Flashing BIOS from file\n");
+ flash_complete_update(f,invocation);
+ // get size from file
+ struct stat stbuf;
+ uint32_t address = 0, read_size = 0, write_size = 0;
- if (stat(write_file, &stbuf))
- {
- g_print("Failed to get file size");
- //TODO: Error handling
- }
- write_size = stbuf.st_size;
- erase_chip();
- program_file(write_file, address, write_size);
- flash_complete_update(f,invocation);
- return TRUE;
+#ifdef __arm__
+ if (stat(write_file, &stbuf))
+ {
+ printf("ERROR: Invalid flash file: %s\n",write_file);
+ }
+ write_size = stbuf.st_size;
+ // TODO: need to change pflash to return error instead of exit
+ erase_chip();
+ program_file(write_file, address, write_size);
+#endif
+
+ flash_emit_updated(f);
+ return TRUE;
}
static void