Skip to content

Commit

Permalink
First version (alpha)
Browse files Browse the repository at this point in the history
V0.5

Early version featuring :
Reading and displaying board partition table, local and remote
Flashing individual partition to target
Saving configuration

Next Features to implement :

Download remote partition
Erase remote partition
Manage SD cards
Handling building stages before flashing
Improve UI

Note : This version is focused on the Jetson Board, support for RPi and
other boards to come soon!
  • Loading branch information
Nolaan committed Oct 22, 2014
1 parent 07168e4 commit 9ea1b01
Show file tree
Hide file tree
Showing 10 changed files with 1,113 additions and 77 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/sans_titre.pro.user
/tags
342 changes: 342 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Companion

Companion is mainly a GUI to flash your development board.

Companion is a program utility main focused on Embedded System Development.

The aim of the project is to ease the development cycle of embedded systems.
By wrapping the commandline tools used to flash the board and obtain its
status into a GUI.

Currently only the Nvidia Jetson TK1 board (pm375) is supported.
Soon it will also be compatible with the Raspberry Pi.

This is an early version that may contain some bugs, provided without warranty.

Feel free to provide me with encountered issues via github.

It's licensed under the GPL License. See LICENSE file.
84 changes: 42 additions & 42 deletions sans_titre.pro → companion.pro
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
#-------------------------------------------------
#-------------------------------------------------
#
# Project created by QtCreator 2014-10-13T20:01:16
# Project created by QtCreator 2014-10-22T01:02:30
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = sans_titre
TARGET = companion
TEMPLATE = app

INCLUDEPATH += /usr/include/kde4
INCLUDEPATH += gui, core, util

SOURCES += main.cpp\
mainwindow.cpp \
gui/partwidget.cpp \
core/partitionnode.cpp \
gui/partwidgetbase.cpp \
gui/parttablewidget.cpp \
core/copysource.cpp \
core/copysourcedevice.cpp \
core/copysourcefile.cpp \
core/copytarget.cpp \
core/copytargetdevice.cpp \
core/copytargetfile.cpp \
core/devboard.cpp \
core/device.cpp \
core/libparted.cpp \
core/operationrunner.cpp \
core/operationstack.cpp \
core/partition.cpp \
core/partitionnode.cpp \
core/partitionrole.cpp \
core/partitiontable.cpp \
fs/ext2.cpp \
Expand All @@ -43,12 +50,9 @@ SOURCES += main.cpp\
fs/unformatted.cpp \
fs/unknown.cpp \
fs/xfs.cpp \
util/capacity.cpp \
util/externalcommand.cpp \
util/globallog.cpp \
util/helpers.cpp \
util/report.cpp \
core/operationstack.cpp \
gui/parttablewidget.cpp \
gui/partwidget.cpp \
gui/partwidgetbase.cpp \
jobs/backupfilesystemjob.cpp \
jobs/checkfilesystemjob.cpp \
jobs/copyfilesystemjob.cpp \
Expand Down Expand Up @@ -76,23 +80,26 @@ SOURCES += main.cpp\
ops/restoreoperation.cpp \
ops/setfilesystemlabeloperation.cpp \
ops/setpartflagsoperation.cpp \
core/copysourcedevice.cpp \
core/copytarget.cpp \
core/copytargetdevice.cpp \
core/copysource.cpp \
core/copysourcefile.cpp \
core/copytargetfile.cpp \
core/libparted.cpp \
core/operationrunner.cpp \
core/devboard.cpp
util/capacity.cpp \
util/externalcommand.cpp \
util/globallog.cpp \
util/helpers.cpp \
util/report.cpp

HEADERS += mainwindow.h \
gui/partwidget.h \
core/partitionnode.h \
gui/partwidgetbase.h \
gui/parttablewidget.h \
core/copysource.h \
core/copysourcedevice.h \
core/copysourcefile.h \
core/copytarget.h \
core/copytargetdevice.h \
core/copytargetfile.h \
core/devboard.h \
core/device.h \
core/libparted.h \
core/operationrunner.h \
core/operationstack.h \
core/partition.h \
core/partitionnode.h \
core/partitionrole.h \
core/partitiontable.h \
fs/ext2.h \
Expand All @@ -114,13 +121,9 @@ HEADERS += mainwindow.h \
fs/unformatted.h \
fs/unknown.h \
fs/xfs.h \
util/capacity.h \
util/externalcommand.h \
util/globallog.h \
util/helpers.h \
util/libpartitionmanagerexport.h \
util/report.h \
core/operationstack.h \
gui/parttablewidget.h \
gui/partwidget.h \
gui/partwidgetbase.h \
jobs/backupfilesystemjob.h \
jobs/checkfilesystemjob.h \
jobs/copyfilesystemjob.h \
Expand Down Expand Up @@ -148,15 +151,12 @@ HEADERS += mainwindow.h \
ops/restoreoperation.h \
ops/setfilesystemlabeloperation.h \
ops/setpartflagsoperation.h \
core/copysourcedevice.h \
core/copytarget.h \
core/copytargetdevice.h \
core/copysource.h \
core/copysourcefile.h \
core/copytargetfile.h \
core/libparted.h \
core/operationrunner.h \
core/devboard.h
util/capacity.h \
util/externalcommand.h \
util/globallog.h \
util/helpers.h \
util/libpartitionmanagerexport.h \
util/report.h

FORMS += mainwindow.ui

Expand Down
267 changes: 267 additions & 0 deletions companion.pro.user

Large diffs are not rendered by default.

181 changes: 169 additions & 12 deletions core/devboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <kurlrequester.h>
#include <QFile>
#include <qtextstream.h>
#include <QMessageBox>


DevBoard::DevBoard(MainWindow* parent,const QString& name, const QString& arch,const QString& cpu_name, const QString& cpu_arch)
Expand All @@ -27,7 +28,7 @@ DevBoard::DevBoard(MainWindow* parent,const QString& name, const QString& arch,c
m_timer->setInterval(3000);
connect(m_timer, SIGNAL(timeout()), this, SLOT(this->isConnected()));
m_timer->start();
parseFlashConfig(parent);
}

DevBoard::~DevBoard()
Expand Down Expand Up @@ -90,12 +91,13 @@ void DevBoard::getParttable(MainWindow* parent)

int start;
int last;
int bytepersector=4096;
//int bytepersector=4096;
QRegExp rx("\\d+");
QRegExp nm("^\\w+=(\\w+)");

QList<int>sectorsVals;
QList<QString>partNames;

// Fetch the partition table text file from the board
if(this->m_ConnectionStatus && isConfPathValid(parent))
{
Expand Down Expand Up @@ -185,16 +187,17 @@ void DevBoard::getParttable(MainWindow* parent)
ptable->append(p);
}

// Create partition and insert them in ptable
int i=0;

this->setPartitionTable(ptable);
}

void DevBoard::on_conf_refresh(MainWindow* parent)
{
if(this->isConfPathValid(parent))
{
this->parseFlashConfig(parent);
parent->refreshMandatoryFiles(m_MandatoryFiles,0);
}


}

Expand Down Expand Up @@ -229,18 +232,172 @@ void DevBoard::saveConfTab(MainWindow* parent)

void DevBoard::parseFlashConfig(MainWindow* parent)
{
int start;
int last;
//int bytepersector=4096;
QRegExp rx("\\d+");
QRegExp nm("^\\w+=(\\w+)");
QList<int>sectorsVals;
QList<QString>partNames;

PartitionTable* ptable = new PartitionTable();
PartitionRole::Roles(r);
r = PartitionRole::Primary;

QString flashcfg;
QString name;

flashcfg = parent->getUrlToolPath() + "/bootloader/flash.cfg";
if(QFile(flashcfg).exists())
{

QSettings sets(flashcfg,QSettings::IniFormat);
QFile layout(flashcfg);
QString line;
if(layout.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream ts(&layout);
line = ts.readLine();
start = 0; //reset sectors to begin
last = 0; //reset sectors to begin
while(!ts.atEnd())
{
// For Jetson in flash.cfg file partion are
// declared with a [partition] heading
if(line.contains("partition"))
{
while(!line.isEmpty())
{
if(line.contains(QRegExp("^name")))
{
nm.indexIn(line);
partNames.append(nm.cap(1));

}
if(line.contains("size"))
{
rx.indexIn(line);

last = start + rx.cap().toInt()/4096; // We want the number of sectors!
sectorsVals.append(start);
sectorsVals.append(last);
start = last;

}
if(line.contains(QRegExp(".img")) && !line.contains("#"))
{
QRegExp nm2("^\\w+=(\\w+.img)");
nm2.indexIn(line);
m_MandatoryFiles.insert(partNames.last(),parent->getUrlToolPath() + "/bootloader/" + nm2.cap(1));
}
line = ts.readLine();
}
}
line = ts.readLine();
}

// Create the partition table, populate it with partition
// and apply the partition table to the right partition widget


while(!sectorsVals.empty())
{
start = sectorsVals.takeFirst();
last = sectorsVals.takeFirst();
name = partNames.takeFirst();
this->m_DeviceNode = name;
Partition* p = new Partition(ptable, *this, PartitionRole(r), FileSystemFactory::create(FileSystem::Ext4, 0, 4096), start, last, -1);
this->m_DeviceNode = "emmc";

ptable->append(p);
}

// Adding ptable to the second partition widget

parent->setFuturePartTable(ptable);

}
}
}



void DevBoard::flashPart(QString partName, MainWindow* parent)
{
QProcess process;
QString bootloader, toolPath, options, cmdline, fsImage, go;
int confirmed = 0;
confirmed = QMessageBox::warning(parent, tr("Companion"),
tr("Are you sure?\n"
"Confirm to flash!"),
QMessageBox::Yes
| QMessageBox::Cancel);
if( m_ConnectionStatus && (confirmed==QMessageBox::Yes) )
{
// Build the command line
// ./nvflash --bl fastboot.bin --download LNX rootfs.img --go

toolPath = parent->getUrlToolPath();
toolPath.append("/bootloader/nvflash ");

options = " --download ";
options.append(partName+" ");

fsImage = m_MandatoryFiles.value(partName) + " ";

bootloader = " --bl " + parent->getUrlToolPath();
bootloader.append("/bootloader/fastboot.bin ");

go = " --go";

cmdline = toolPath + options + fsImage + bootloader + go;

// Send command
process.start(cmdline);
process.waitForFinished(-1); // will wait forever until finished

QString stdout = process.readAllStandardOutput();
QString stderr = process.readAllStandardError();
cmdline.clear();
}

// QFile layout(flashcfg);
// QString line;
// if(layout.open(QIODevice::ReadOnly | QIODevice::Text))
// {
// QSettings
// }
}

void DevBoard::flashAll(MainWindow* parent)
{
QProcess process;
QString bootloader, toolPath, options, cmdline, fsImage, go;
int confirmed = 0;
confirmed = QMessageBox::warning(parent, tr("Companion"),
tr("Are you sure?\n"
"Confirm to flash!"),
QMessageBox::Yes
| QMessageBox::Cancel);

if( m_ConnectionStatus && (confirmed==QMessageBox::Yes) )
{
process.setWorkingDirectory(parent->getUrlToolPath());
// Build the command line
// ./flash.sh -L bootloader/u-boot.bin -r jetson-tk1 mmcblk0p1

toolPath.append("./flash.sh ");

bootloader = "-L bootloader/u-boot.bin ";

options = "-r ";
options.append("jetson-tk1 ");
options.append("mmcblk0p1 ");

cmdline = toolPath + bootloader + options ;

// Send command
process.start(cmdline);



process.waitForFinished(-1); // will wait forever until finished

QString stdout = process.readAllStandardOutput();
QString stderr = process.readAllStandardError();
cmdline.clear();
}
}
Loading

0 comments on commit 9ea1b01

Please sign in to comment.