summaryrefslogtreecommitdiffstats
path: root/src/local.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/local.c')
-rw-r--r--src/local.c70
1 files changed, 67 insertions, 3 deletions
diff --git a/src/local.c b/src/local.c
index 8498eab..c6ffc0a 100644
--- a/src/local.c
+++ b/src/local.c
@@ -25,6 +25,7 @@
#endif
#include "local.h"
+#include "global.h"
#include "device.h"
#include "image.h"
@@ -115,11 +116,74 @@ int local_flash_image(struct image * image) {
}
+static int local_nanddump(const char * file, int mtd, int offset) {
+
+ char * command;
+ size_t size;
+ int ret;
+
+ size = snprintf(NULL, 0, "nanddump -s %d -f %s /dev/mtd%dro", offset, file, mtd);
+
+ command = malloc(size);
+ if ( ! command )
+ return 1;
+
+ snprintf(command, size, "nanddump -s %d -f %s /dev/mtd%dro", offset, file, mtd);
+
+ ret = system(command);
+
+ free(command);
+
+ return ret;
+
+}
+
+struct nanddump_args {
+ int valid;
+ int mtd;
+ int offset;
+};
+
+static struct nanddump_args nanddump_n900[] = {
+ [IMAGE_XLOADER] = { 1, 0, 0x00000000 },
+ [IMAGE_SECONDARY] = { 1, 0, 0x00004200 },
+ [IMAGE_KERNEL] = { 1, 3, 0x00000800 },
+ [IMAGE_INITFS] = { 1, 4, 0x00000800 },
+ [IMAGE_ROOTFS] = { 1, 5, 0x00000000 },
+};
+
+/* FIXME: Is this table correct? */
+static struct nanddump_args nanddump[] = {
+ [IMAGE_XLOADER] = { 1, 0, 0x00000200 },
+ [IMAGE_SECONDARY] = { 1, 0, 0x00004000 },
+ [IMAGE_KERNEL] = { 1, 2, 0x00000800 },
+ [IMAGE_INITFS] = { 1, 3, 0x00000800 },
+ [IMAGE_ROOTFS] = { 1, 4, 0x00000000 },
+};
+
int local_dump_image(enum image_type image, const char * file) {
- /* kernel on n900:
- system("nanddump -s 0x000800 -f /var/tmp/zImage /dev/mtd3");
- */
+ if ( device == DEVICE_RX_51 ) {
+
+ if ( image < sizeof(nanddump_n900)/sizeof(nanddump_n900[0]) || ! nanddump_n900[image].valid ) {
+ ERROR("Unsuported image type: %s", image_type_to_string(image));
+ return -1;
+ }
+
+ return local_nanddump(file, nanddump_n900[image].mtd, nanddump_n900[image].offset);
+
+ } else {
+
+ if ( image < sizeof(nanddump)/sizeof(nanddump[0]) || ! nanddump[image].valid ) {
+ ERROR("Unsuported image type: %s", image_type_to_string(image));
+ return -1;
+ }
+
+ return local_nanddump(file, nanddump[image].mtd, nanddump[image].offset);
+
+ }
+
+ return -1;
}