Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormadmonkey <madfkingmonkey@gmail.com>2017-09-29 16:17:55 +0300
committermadmonkey <madfkingmonkey@gmail.com>2017-09-29 16:17:55 +0300
commita1f00b1ca4d571968ad008f47e3eb5ceb79e5f63 (patch)
tree4588e8707602b785b7bf67c375080740453a1673
parentd2fc93215a7878708e9892476ad65e727cfe590e (diff)
write nand
-rw-r--r--hakchi-gui/src/mainwindow.cpp6
-rw-r--r--hakchi-gui/src/mainwindow.h1
-rw-r--r--hakchi-gui/src/mainwindow.ui6
-rw-r--r--hakchi-gui/src/worker.cpp65
-rw-r--r--hakchi-gui/src/worker.h2
5 files changed, 80 insertions, 0 deletions
diff --git a/hakchi-gui/src/mainwindow.cpp b/hakchi-gui/src/mainwindow.cpp
index 25bba76..9c498bf 100644
--- a/hakchi-gui/src/mainwindow.cpp
+++ b/hakchi-gui/src/mainwindow.cpp
@@ -151,3 +151,9 @@ void MainWindow::on_actionDump_nand_triggered()
{
emit doWork(Worker::dumpNandFull);
}
+
+void MainWindow::on_actionWrite_nand_triggered()
+{
+// do not use
+// emit doWork(Worker::writeNandFull);
+}
diff --git a/hakchi-gui/src/mainwindow.h b/hakchi-gui/src/mainwindow.h
index 7c9b8c9..45a98c9 100644
--- a/hakchi-gui/src/mainwindow.h
+++ b/hakchi-gui/src/mainwindow.h
@@ -32,6 +32,7 @@ private slots:
void on_actionMemboot_triggered();
void on_actionShutdown_triggered();
void on_actionDump_nand_triggered();
+ void on_actionWrite_nand_triggered();
private:
Ui::MainWindow*ui;
diff --git a/hakchi-gui/src/mainwindow.ui b/hakchi-gui/src/mainwindow.ui
index a85fcac..f2d26ef 100644
--- a/hakchi-gui/src/mainwindow.ui
+++ b/hakchi-gui/src/mainwindow.ui
@@ -217,6 +217,7 @@
<addaction name="actionDump_uboot"/>
<addaction name="actionDump_kernel_img"/>
<addaction name="actionDump_nand"/>
+ <addaction name="actionWrite_nand"/>
<addaction name="actionUnpack_kernel_img"/>
<addaction name="actionRebuild_kernel_img"/>
<addaction name="actionFlash_kernel"/>
@@ -265,6 +266,11 @@
<string>dump nand</string>
</property>
</action>
+ <action name="actionWrite_nand">
+ <property name="text">
+ <string>write nand</string>
+ </property>
+ </action>
<action name="actionFlash_uboot">
<property name="text">
<string>flash uboot</string>
diff --git a/hakchi-gui/src/worker.cpp b/hakchi-gui/src/worker.cpp
index aa25b84..a57ca64 100644
--- a/hakchi-gui/src/worker.cpp
+++ b/hakchi-gui/src/worker.cpp
@@ -143,6 +143,9 @@ void Worker::doWork(int work)
case dumpNandFull:
do_dumpNandFull();
break;
+ case writeNandFull:
+ do_writeNandFull();
+ break;
case unpackKernel:
do_unpackKernel();
break;
@@ -356,6 +359,68 @@ void Worker::do_dumpNandFull()
printf("%s - OK\n",Q_FUNC_INFO);
}
+void Worker::do_writeNandFull()
+{
+ if((!init())||(!fel->haveUboot()))
+ {
+ return;
+ }
+ const size_t block=0x2000000;
+ const size_t count=0x10;
+ calcProgress(0-(block*count));
+ const QString nandFile("dump/nand.bin");
+ QDir(".").mkdir("dump");
+ size_t fs=loadFile(nandFile.toLocal8Bit(),0);
+ size_t offset=0;
+ md5context context;
+ md5init(&context);
+ QByteArray buf(block,Qt::Uninitialized);
+ if((fs>0)&&((fs%block)==0)&&(fs<=(block*count)))
+ {
+ FILE*hf=fopen(nandFile.toLocal8Bit(),"rb");
+ if(hf)
+ {
+ while(fread(buf.data(),1,block,hf)==block)
+ {
+ if(fel->writeFlash(offset,block,buf.data())!=block)
+ {
+ printf("nand: write error\n");
+ return;
+ }
+ md5update(&context,buf.data(),block);
+// calcProgress(block);
+ offset+=block;
+ }
+ fclose(hf);
+ }
+// printf("%zuM done, continuing\n",fs/0x100000);
+ }
+ else
+ {
+// QDir(".").remove(nandFile);
+ }
+ /*
+ uint8_t md5[16];
+ char md5str[40];
+ while(offset<(block*count))
+ {
+ if(fel->readFlash(offset,block,buf.data())!=block)
+ {
+ printf("nand: read error\n");
+ return;
+ }
+ appendFile(nandFile.toLocal8Bit(),buf.data(),block);
+ offset+=block;
+ md5update(&context,buf.data(),block);
+ md5calc(buf.data(),block,md5);
+ printf("%s\n",md5print(md5,md5str));
+ }
+ md5final(&context,md5);
+ printf("%s\n",md5print(md5,md5str));
+ */
+ printf("%s - OK\n",Q_FUNC_INFO);
+}
+
void Worker::do_unpackKernel()
{
if(::system(QString("extractimg \"%1\"").arg(kernelFile).toLocal8Bit())==0)
diff --git a/hakchi-gui/src/worker.h b/hakchi-gui/src/worker.h
index 57fb476..3135b89 100644
--- a/hakchi-gui/src/worker.h
+++ b/hakchi-gui/src/worker.h
@@ -14,6 +14,7 @@ public:
dumpUboot,
dumpKernel,
dumpNandFull,
+ writeNandFull,
unpackKernel,
packKernel,
flashKernel,
@@ -39,6 +40,7 @@ private:
void do_dumpUboot();
void do_dumpKernel();
void do_dumpNandFull();
+ void do_writeNandFull();
void do_unpackKernel();
void do_packKernel();
void do_flashKernel();