forked from qt-creator/qt-creator
BareMetal: Add support for Nordic Semiconductor devices in UVSC provider
This patch adds support for Nordic nRFx ARM devices family. Tested with J-Link debugger using the PCA10040 development board which contains nRF52832 chip. Change-Id: Iabcdd1c9678b631b58c56bf067f400324ec1915f Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -99,26 +99,31 @@ static QString buildAdapterOptions(const JLinkUvscAdapterOptions &opts)
|
||||
return s;
|
||||
}
|
||||
|
||||
static QString buildDllRegistryKey(const DriverSelection &driver)
|
||||
{
|
||||
const QFileInfo fi(driver.dll);
|
||||
return fi.baseName();
|
||||
}
|
||||
|
||||
static QString buildDllRegistryName(const DeviceSelection &device,
|
||||
const JLinkUvscAdapterOptions &opts)
|
||||
{
|
||||
if (device.algorithmIndex < 0 || device.algorithmIndex >= int(device.algorithms.size()))
|
||||
return {};
|
||||
|
||||
const DeviceSelection::Algorithm algorithm = device.algorithms.at(device.algorithmIndex);
|
||||
const QFileInfo path(algorithm.path);
|
||||
const QString start = algorithm.start.startsWith("0x") ? algorithm.start.mid(2)
|
||||
: algorithm.start;
|
||||
const QString size = algorithm.size.startsWith("0x") ? algorithm.size.mid(2)
|
||||
: algorithm.size;
|
||||
const QString flashStart = UvscServerProvider::adjustFlashAlgorithmProperty(algorithm.flashStart);
|
||||
const QString flashSize = UvscServerProvider::adjustFlashAlgorithmProperty(algorithm.flashSize);
|
||||
const QString adaptOpts = buildAdapterOptions(opts);
|
||||
return QStringLiteral(" %6 -FN1 -FF0%1 -FS0%2 -FL0%3 -FP0($$Device:%4$%5)")
|
||||
.arg(path.fileName(), start, size, device.name, path.filePath(), adaptOpts);
|
||||
|
||||
QString content = QStringLiteral(" %6 -FN1 -FF0%1 -FS0%2 -FL0%3 -FP0($$Device:%4$%5)")
|
||||
.arg(path.fileName(), flashStart, flashSize, device.name, path.filePath(), adaptOpts);
|
||||
|
||||
if (!algorithm.ramStart.isEmpty()) {
|
||||
const QString ramStart = UvscServerProvider::adjustFlashAlgorithmProperty(algorithm.ramStart);
|
||||
content += QStringLiteral(" -FD%1").arg(ramStart);
|
||||
}
|
||||
if (!algorithm.ramSize.isEmpty()) {
|
||||
const QString ramSize = UvscServerProvider::adjustFlashAlgorithmProperty(algorithm.ramSize);
|
||||
content += QStringLiteral(" -FC%1").arg(ramSize);
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
// JLinkUvProjectOptions
|
||||
@@ -138,7 +143,7 @@ public:
|
||||
const auto dllRegistry = m_targetOption->appendPropertyGroup("TargetDriverDllRegistry");
|
||||
const auto setRegEntry = dllRegistry->appendPropertyGroup("SetRegEntry");
|
||||
setRegEntry->appendProperty("Number", 0);
|
||||
const QString key = buildDllRegistryKey(driver);
|
||||
const QString key = UvscServerProvider::buildDllRegistryKey(driver);
|
||||
setRegEntry->appendProperty("Key", key);
|
||||
const QString name = buildDllRegistryName(device, provider->m_adapterOpts);
|
||||
setRegEntry->appendProperty("Name", name);
|
||||
|
@@ -68,12 +68,6 @@ static QString buildAdapterOptions(const StLinkUvscAdapterOptions &opts)
|
||||
return s;
|
||||
}
|
||||
|
||||
static QString buildDllRegistryKey(const DriverSelection &driver)
|
||||
{
|
||||
const QFileInfo fi(driver.dll);
|
||||
return fi.baseName();
|
||||
}
|
||||
|
||||
static QString buildDllRegistryName(const DeviceSelection &device,
|
||||
const StLinkUvscAdapterOptions &opts)
|
||||
{
|
||||
@@ -81,13 +75,11 @@ static QString buildDllRegistryName(const DeviceSelection &device,
|
||||
return {};
|
||||
const DeviceSelection::Algorithm algorithm = device.algorithms.at(device.algorithmIndex);
|
||||
const QFileInfo path(algorithm.path);
|
||||
const QString start = algorithm.start.startsWith("0x") ? algorithm.start.mid(2)
|
||||
: algorithm.start;
|
||||
const QString size = algorithm.size.startsWith("0x") ? algorithm.size.mid(2)
|
||||
: algorithm.size;
|
||||
const QString flashStart = UvscServerProvider::adjustFlashAlgorithmProperty(algorithm.flashStart);
|
||||
const QString flashSize = UvscServerProvider::adjustFlashAlgorithmProperty(algorithm.flashSize);
|
||||
const QString adaptOpts = buildAdapterOptions(opts);
|
||||
return QStringLiteral(" %6 -FN1 -FF0%1 -FS0%2 -FL0%3 -FP0($$Device:%4$%5)")
|
||||
.arg(path.fileName(), start, size, device.name, path.filePath(), adaptOpts);
|
||||
.arg(path.fileName(), flashStart, flashSize, device.name, path.filePath(), adaptOpts);
|
||||
}
|
||||
|
||||
// StLinkUvProjectOptions
|
||||
@@ -107,7 +99,7 @@ public:
|
||||
const auto dllRegistry = m_targetOption->appendPropertyGroup("TargetDriverDllRegistry");
|
||||
const auto setRegEntry = dllRegistry->appendPropertyGroup("SetRegEntry");
|
||||
setRegEntry->appendProperty("Number", 0);
|
||||
const QString key = buildDllRegistryKey(driver);
|
||||
const QString key = UvscServerProvider::buildDllRegistryKey(driver);
|
||||
setRegEntry->appendProperty("Key", key);
|
||||
const QString name = buildDllRegistryName(device, provider->m_adapterOpts);
|
||||
setRegEntry->appendProperty("Name", name);
|
||||
|
@@ -66,6 +66,17 @@ constexpr int defaultPortNumber = 5101;
|
||||
|
||||
// UvscServerProvider
|
||||
|
||||
QString UvscServerProvider::buildDllRegistryKey(const DriverSelection &driver)
|
||||
{
|
||||
const QFileInfo fi(driver.dll);
|
||||
return fi.baseName();
|
||||
}
|
||||
|
||||
QString UvscServerProvider::adjustFlashAlgorithmProperty(const QString &property)
|
||||
{
|
||||
return property.startsWith("0x") ? property.mid(2) : property;
|
||||
}
|
||||
|
||||
UvscServerProvider::UvscServerProvider(const QString &id)
|
||||
: IDebugServerProvider(id)
|
||||
{
|
||||
|
@@ -78,6 +78,9 @@ public:
|
||||
bool isValid() const override;
|
||||
QString channelString() const final;
|
||||
|
||||
static QString buildDllRegistryKey(const Uv::DriverSelection &driver);
|
||||
static QString adjustFlashAlgorithmProperty(const QString &property);
|
||||
|
||||
protected:
|
||||
explicit UvscServerProvider(const QString &id);
|
||||
explicit UvscServerProvider(const UvscServerProvider &other);
|
||||
|
@@ -83,6 +83,24 @@ static QStringList findKeilPackFiles(const QString &path)
|
||||
return files;
|
||||
}
|
||||
|
||||
static QStringList findNordicSemiconductorPackFiles(const QString &path)
|
||||
{
|
||||
QStringList files;
|
||||
QDirIterator it(path, {"*_DeviceFamilyPack"}, QDir::Dirs);
|
||||
while (it.hasNext()) {
|
||||
const QDir dfpDir(it.next());
|
||||
const QFileInfoList entries = dfpDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot,
|
||||
QDir::Name);
|
||||
if (entries.isEmpty())
|
||||
continue;
|
||||
QDirIterator fit(entries.last().absoluteFilePath(), {"*.pdsc"},
|
||||
QDir::Files | QDir::NoSymLinks);
|
||||
while (fit.hasNext())
|
||||
files.push_back(fit.next());
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
static void fillElementProperty(QXmlStreamReader &in, QString &prop)
|
||||
{
|
||||
prop = in.readElementText().trimmed();
|
||||
@@ -115,8 +133,10 @@ static void fillAlgorithms(QXmlStreamReader &in, DeviceSelection::Algorithms &al
|
||||
in.skipCurrentElement();
|
||||
DeviceSelection::Algorithm algorithm;
|
||||
algorithm.path = attrs.value("name").toString();
|
||||
algorithm.start = attrs.value("start").toString();
|
||||
algorithm.size = attrs.value("size").toString();
|
||||
algorithm.flashStart = attrs.value("start").toString();
|
||||
algorithm.flashSize = attrs.value("size").toString();
|
||||
algorithm.ramStart = attrs.value("RAMstart").toString();
|
||||
algorithm.ramSize = attrs.value("RAMsize").toString();
|
||||
algorithms.push_back(algorithm);
|
||||
}
|
||||
|
||||
@@ -206,11 +226,13 @@ void DeviceSelectionModel::fillAllPacks(const FilePath &toolsIniFile)
|
||||
return;
|
||||
|
||||
QStringList allPackFiles;
|
||||
QDirIterator it(packsPath, {"Keil"}, QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
QDirIterator it(packsPath, {"Keil", "NordicSemiconductor"}, QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
while (it.hasNext()) {
|
||||
const QString path = it.next();
|
||||
if (path.endsWith("/Keil"))
|
||||
allPackFiles << findKeilPackFiles(path);
|
||||
else if (path.endsWith("/NordicSemiconductor"))
|
||||
allPackFiles << findNordicSemiconductorPackFiles(path);
|
||||
}
|
||||
|
||||
if (allPackFiles.isEmpty())
|
||||
@@ -277,6 +299,8 @@ void DeviceSelectionModel::parseFamily(QXmlStreamReader &in, DeviceSelectionItem
|
||||
const QStringRef elementName = in.name();
|
||||
if (elementName == "processor") {
|
||||
fillCpu(in, child->cpu);
|
||||
} else if (elementName == "algorithm") {
|
||||
fillAlgorithms(in, child->algorithms);
|
||||
} else if (elementName == "memory") {
|
||||
fillMemories(in, child->memories);
|
||||
} else if (elementName == "description") {
|
||||
@@ -325,6 +349,8 @@ void DeviceSelectionModel::parseDevice(QXmlStreamReader &in, DeviceSelectionItem
|
||||
fillCpu(in, child->cpu);
|
||||
} else if (elementName == "debug") {
|
||||
fillSvd(in, child->svd);
|
||||
} else if (elementName == "description") {
|
||||
fillElementProperty(in, child->desc);
|
||||
} else if (elementName == "memory") {
|
||||
fillMemories(in, child->memories);
|
||||
} else if (elementName == "algorithm") {
|
||||
|
@@ -27,7 +27,8 @@
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDataWidgetMapper>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
using namespace Utils;
|
||||
@@ -65,8 +66,10 @@ constexpr char deviceMemorySizeKeyC[] = "BareMetal.UvscServerProvider.DeviceMemo
|
||||
// Device ALGORITHM data keys.
|
||||
constexpr char deviceAlgorithmKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithm";
|
||||
constexpr char deviceAlgorithmPathKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmPath";
|
||||
constexpr char deviceAlgorithmStartKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmStart";
|
||||
constexpr char deviceAlgorithmSizeKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmSize";
|
||||
constexpr char deviceAlgorithmFlashStartKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmStart";
|
||||
constexpr char deviceAlgorithmFlashSizeKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmSize";
|
||||
constexpr char deviceAlgorithmRamStartKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmRamStart";
|
||||
constexpr char deviceAlgorithmRamSizeKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmRamSize";
|
||||
constexpr char deviceAlgorithmIndexKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmIndex";
|
||||
|
||||
// DeviceSelection
|
||||
@@ -110,8 +113,10 @@ QVariantMap DeviceSelection::toMap() const
|
||||
for (const DeviceSelection::Algorithm &algorithm : qAsConst(algorithms)) {
|
||||
QVariantMap m;
|
||||
m.insert(deviceAlgorithmPathKeyC, algorithm.path);
|
||||
m.insert(deviceAlgorithmStartKeyC, algorithm.start);
|
||||
m.insert(deviceAlgorithmSizeKeyC, algorithm.size);
|
||||
m.insert(deviceAlgorithmFlashStartKeyC, algorithm.flashStart);
|
||||
m.insert(deviceAlgorithmFlashSizeKeyC, algorithm.flashSize);
|
||||
m.insert(deviceAlgorithmRamStartKeyC, algorithm.ramStart);
|
||||
m.insert(deviceAlgorithmRamSizeKeyC, algorithm.ramSize);
|
||||
algorithmList.push_back(m);
|
||||
}
|
||||
map.insert(deviceAlgorithmKeyC, algorithmList);
|
||||
@@ -159,8 +164,10 @@ void DeviceSelection::fromMap(const QVariantMap &map)
|
||||
const auto m = entry.toMap();
|
||||
DeviceSelection::Algorithm algorithm;
|
||||
algorithm.path = m.value(deviceAlgorithmPathKeyC).toString();
|
||||
algorithm.start = m.value(deviceAlgorithmStartKeyC).toString();
|
||||
algorithm.size = m.value(deviceAlgorithmSizeKeyC).toString();
|
||||
algorithm.flashStart = m.value(deviceAlgorithmFlashStartKeyC).toString();
|
||||
algorithm.flashSize = m.value(deviceAlgorithmFlashSizeKeyC).toString();
|
||||
algorithm.ramStart = m.value(deviceAlgorithmRamStartKeyC).toString();
|
||||
algorithm.ramSize = m.value(deviceAlgorithmRamSizeKeyC).toString();
|
||||
algorithms.push_back(algorithm);
|
||||
}
|
||||
}
|
||||
@@ -186,7 +193,9 @@ bool DeviceSelection::Memory::operator==(const Memory &other) const
|
||||
|
||||
bool DeviceSelection::Algorithm::operator==(const Algorithm &other) const
|
||||
{
|
||||
return path == other.path && start == other.start && size == other.size;
|
||||
return path == other.path
|
||||
&& flashStart == other.flashStart && flashSize == other.flashSize
|
||||
&& ramStart == other.ramStart && ramSize == other.ramSize;
|
||||
}
|
||||
|
||||
bool DeviceSelection::operator==(const DeviceSelection &other) const
|
||||
@@ -297,7 +306,7 @@ void DeviceSelectionMemoryView::refresh()
|
||||
class DeviceSelectionAlgorithmItem final : public TreeItem
|
||||
{
|
||||
public:
|
||||
enum Column { PathColumn, StartColumn, SizeColumn };
|
||||
enum Column { PathColumn, FlashStartColumn, FlashSizeColumn, RamStartColumn, RamSizeColumn };
|
||||
explicit DeviceSelectionAlgorithmItem(int index, DeviceSelection &selection)
|
||||
: m_index(index), m_selection(selection)
|
||||
{}
|
||||
@@ -308,8 +317,10 @@ public:
|
||||
const auto &algorithm = m_selection.algorithms.at(m_index);
|
||||
switch (column) {
|
||||
case PathColumn: return algorithm.path;
|
||||
case StartColumn: return algorithm.start;
|
||||
case SizeColumn: return algorithm.size;
|
||||
case FlashStartColumn: return algorithm.flashStart;
|
||||
case FlashSizeColumn: return algorithm.flashSize;
|
||||
case RamStartColumn: return algorithm.ramStart;
|
||||
case RamSizeColumn: return algorithm.ramSize;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
@@ -320,11 +331,17 @@ public:
|
||||
if (role == Qt::EditRole) {
|
||||
auto &algorithm = m_selection.algorithms.at(m_index);
|
||||
switch (column) {
|
||||
case StartColumn:
|
||||
algorithm.start = data.toString();
|
||||
case FlashStartColumn:
|
||||
algorithm.flashStart = data.toString();
|
||||
return true;
|
||||
case SizeColumn:
|
||||
algorithm.size = data.toString();
|
||||
case FlashSizeColumn:
|
||||
algorithm.flashSize = data.toString();
|
||||
return true;
|
||||
case RamStartColumn:
|
||||
algorithm.ramStart = data.toString();
|
||||
return true;
|
||||
case RamSizeColumn:
|
||||
algorithm.ramSize = data.toString();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -334,8 +351,10 @@ public:
|
||||
Qt::ItemFlags flags(int column) const final
|
||||
{
|
||||
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
if (column == StartColumn || column == SizeColumn)
|
||||
if (column == FlashStartColumn || column == FlashSizeColumn
|
||||
|| column == RamStartColumn || column == RamSizeColumn) {
|
||||
flags |= Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -350,7 +369,7 @@ DeviceSelectionAlgorithmModel::DeviceSelectionAlgorithmModel(DeviceSelection &se
|
||||
QObject *parent)
|
||||
: TreeModel<TreeItem, DeviceSelectionAlgorithmItem>(parent), m_selection(selection)
|
||||
{
|
||||
setHeader({tr("Name"), tr("Start"), tr("Size")});
|
||||
setHeader({tr("Name"), tr("FLASH Start"), tr("FLASH Size"), tr("RAM Start"), tr("RAM Size")});
|
||||
refresh();
|
||||
}
|
||||
|
||||
@@ -373,25 +392,40 @@ DeviceSelectionAlgorithmView::DeviceSelectionAlgorithmView(DeviceSelection &sele
|
||||
: QWidget(parent)
|
||||
{
|
||||
const auto model = new DeviceSelectionAlgorithmModel(selection, this);
|
||||
const auto layout = new QHBoxLayout;
|
||||
const auto layout = new QGridLayout;
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_comboBox = new QComboBox;
|
||||
m_comboBox->setToolTip(tr("Algorithm path."));
|
||||
m_comboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
m_comboBox->setModel(model);
|
||||
layout->addWidget(m_comboBox);
|
||||
const auto startEdit = new QLineEdit;
|
||||
startEdit->setToolTip(tr("Start address."));
|
||||
layout->addWidget(startEdit);
|
||||
const auto sizeEdit = new QLineEdit;
|
||||
sizeEdit->setToolTip(tr("Size."));
|
||||
layout->addWidget(sizeEdit);
|
||||
layout->addWidget(m_comboBox, 0, 0, 1, 0);
|
||||
// Add FLASH area settings.
|
||||
const auto flashLabel = new QLabel(tr("FLASH:"));
|
||||
layout->addWidget(flashLabel, 1, 0);
|
||||
const auto flashStartEdit = new QLineEdit;
|
||||
flashStartEdit->setToolTip(tr("Start address."));
|
||||
layout->addWidget(flashStartEdit, 1, 1);
|
||||
const auto flashSizeEdit = new QLineEdit;
|
||||
flashSizeEdit->setToolTip(tr("Size."));
|
||||
layout->addWidget(flashSizeEdit, 1, 2);
|
||||
// Add RAM area settings.
|
||||
const auto ramLabel = new QLabel(tr("RAM:"));
|
||||
layout->addWidget(ramLabel, 2, 0);
|
||||
const auto ramStartEdit = new QLineEdit;
|
||||
ramStartEdit->setToolTip(tr("Start address."));
|
||||
layout->addWidget(ramStartEdit, 2, 1);
|
||||
const auto ramSizeEdit = new QLineEdit;
|
||||
ramSizeEdit->setToolTip(tr("Size."));
|
||||
layout->addWidget(ramSizeEdit, 2, 2);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
const auto mapper = new QDataWidgetMapper(this);
|
||||
mapper->setModel(model);
|
||||
mapper->addMapping(startEdit, DeviceSelectionAlgorithmItem::StartColumn);
|
||||
mapper->addMapping(sizeEdit, DeviceSelectionAlgorithmItem::SizeColumn);
|
||||
mapper->addMapping(flashStartEdit, DeviceSelectionAlgorithmItem::FlashStartColumn);
|
||||
mapper->addMapping(flashSizeEdit, DeviceSelectionAlgorithmItem::FlashSizeColumn);
|
||||
mapper->addMapping(ramStartEdit, DeviceSelectionAlgorithmItem::RamStartColumn);
|
||||
mapper->addMapping(ramSizeEdit, DeviceSelectionAlgorithmItem::RamSizeColumn);
|
||||
|
||||
connect(m_comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, [mapper, this](int index) {
|
||||
@@ -403,8 +437,10 @@ DeviceSelectionAlgorithmView::DeviceSelectionAlgorithmView(DeviceSelection &sele
|
||||
emit algorithmChanged(-1);
|
||||
});
|
||||
|
||||
connect(startEdit, &QLineEdit::editingFinished, mapper, &QDataWidgetMapper::submit);
|
||||
connect(sizeEdit, &QLineEdit::editingFinished, mapper, &QDataWidgetMapper::submit);
|
||||
connect(flashStartEdit, &QLineEdit::editingFinished, mapper, &QDataWidgetMapper::submit);
|
||||
connect(flashSizeEdit, &QLineEdit::editingFinished, mapper, &QDataWidgetMapper::submit);
|
||||
connect(ramStartEdit, &QLineEdit::editingFinished, mapper, &QDataWidgetMapper::submit);
|
||||
connect(ramSizeEdit, &QLineEdit::editingFinished, mapper, &QDataWidgetMapper::submit);
|
||||
}
|
||||
|
||||
void DeviceSelectionAlgorithmView::setAlgorithm(int index)
|
||||
|
@@ -73,8 +73,10 @@ public:
|
||||
|
||||
struct Algorithm {
|
||||
QString path;
|
||||
QString size;
|
||||
QString start;
|
||||
QString flashSize;
|
||||
QString flashStart;
|
||||
QString ramSize;
|
||||
QString ramStart;
|
||||
|
||||
bool operator==(const Algorithm &other) const;
|
||||
};
|
||||
|
@@ -84,7 +84,7 @@ DeviceSelectorDetailsPanel::DeviceSelectorDetailsPanel(DeviceSelection &selectio
|
||||
m_memoryView = new DeviceSelectionMemoryView(m_selection);
|
||||
layout->addRow(tr("Memory:"), m_memoryView);
|
||||
m_algorithmView = new DeviceSelectionAlgorithmView(m_selection);
|
||||
layout->addRow(tr("Flash algorithm"), m_algorithmView);
|
||||
layout->addRow(tr("Flash algorithm:"), m_algorithmView);
|
||||
m_peripheralDescriptionFileChooser = new Utils::PathChooser(this);
|
||||
m_peripheralDescriptionFileChooser->setExpectedKind(Utils::PathChooser::File);
|
||||
m_peripheralDescriptionFileChooser->setPromptDialogFilter(
|
||||
|
Reference in New Issue
Block a user