aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-07-24 15:30:52 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-07-26 14:00:47 +0000
commit1a9e852d7d6ea753f20d7e1f374c9f20a87d7f1e (patch)
tree7345cc2076dbc84993825392d7de58f520e76f6a
parent7fb811f6cb51d752af551eb0739daafd4ae7560b (diff)
bare-metal: Add IAR STM8 toolchain support
This commit adds a basic support of the IAR Embedded Workbench toolchain for the STM8 processors family. To use it with Qt Creator, it is enough to add there a desired Kit with a custom IAR C/C++ compiler, and then set the following in the Kit's Qbs profile settings: * Key: qbs.toolchainType * Value: iar Tested with EW for STM8 v3.11.1 on Windows using the simple projects samples which come with the default IAR installer. Change-Id: Ibc116ceb33b7df49c3241d26fa97136255ba06dd Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--share/qbs/imports/qbs/Probes/IarProbe.qbs4
-rw-r--r--share/qbs/modules/cpp/iar.js35
-rw-r--r--share/qbs/modules/cpp/iar.qbs18
-rw-r--r--src/app/qbs-setup-toolchains/iarewprobe.cpp9
4 files changed, 58 insertions, 8 deletions
diff --git a/share/qbs/imports/qbs/Probes/IarProbe.qbs b/share/qbs/imports/qbs/Probes/IarProbe.qbs
index 6e7fb7d64..c57878058 100644
--- a/share/qbs/imports/qbs/Probes/IarProbe.qbs
+++ b/share/qbs/imports/qbs/Probes/IarProbe.qbs
@@ -91,6 +91,10 @@ PathProbe {
versionMajor = parseInt(version / 100);
versionMinor = parseInt(version % 100);
versionPatch = 0;
+ } else if (architecture === "stm8") {
+ versionMajor = parseInt(version / 100);
+ versionMinor = parseInt(version % 100);
+ versionPatch = 0;
}
found = version && architecture && endianness;
diff --git a/share/qbs/modules/cpp/iar.js b/share/qbs/modules/cpp/iar.js
index 3098c88f6..60cb72343 100644
--- a/share/qbs/modules/cpp/iar.js
+++ b/share/qbs/modules/cpp/iar.js
@@ -47,6 +47,8 @@ function guessArchitecture(macros)
return "mcs51";
else if (macros["__ICCAVR__"] === "1")
return "avr";
+ else if (macros["__ICCSTM8__"] === "1")
+ return "stm8";
}
function guessEndianness(macros)
@@ -237,6 +239,8 @@ function compilerFlags(project, product, input, output, explicitlyDependsOn) {
args.push("--ec++");
} else if (input.qbs.architecture === "avr") {
args.push("--ec++");
+ } else if (input.qbs.architecture === "stm8") {
+ args.push("--ec++");
}
}
@@ -284,10 +288,20 @@ function assemblerFlags(project, product, input, output, explicitlyDependsOn) {
args.push("-r");
var warnings = input.cpp.warningLevel;
- if (warnings === "none")
- args.push("-w-");
- else
- args.push("-w+");
+ if (warnings === "none") {
+ if (input.qbs.architecture === "stm8")
+ args.push("--no_warnings");
+ else
+ args.push("-w-");
+ } else {
+ if (input.qbs.architecture !== "stm8")
+ args.push("-w+");
+ }
+
+ if (input.cpp.treatWarningsAsErrors) {
+ if (input.qbs.architecture === "stm8")
+ args.push("--warnings_are_errors");
+ }
var allIncludePaths = [];
var systemIncludePaths = input.cpp.systemIncludePaths;
@@ -300,7 +314,10 @@ function assemblerFlags(project, product, input, output, explicitlyDependsOn) {
args.push("-o", output.filePath);
- args.push("-S"); // Silent operation.
+ if (input.qbs.architecture === "stm8")
+ args.push("--silent"); // Silent operation.
+ else
+ args.push("-S"); // Silent operation.
args = args.concat(ModUtils.moduleProperty(input, "platformFlags", tag),
ModUtils.moduleProperty(input, "flags", tag),
@@ -324,6 +341,8 @@ function linkerFlags(project, product, input, outputs) {
args.push("-l", outputs.map_file[0].filePath);
else if (product.qbs.architecture === "avr")
args.push("-l", outputs.map_file[0].filePath);
+ else if (product.qbs.architecture === "stm8")
+ args.push("--map", outputs.map_file[0].filePath);
}
var allLibraryPaths = [];
@@ -355,6 +374,8 @@ function linkerFlags(project, product, input, outputs) {
args.push("-f", linkerScripts[i]);
else if (product.qbs.architecture === "avr")
args.push("-f", linkerScripts[i]);
+ else if (product.qbs.architecture === "stm8")
+ args.push("--config", linkerScripts[i]);
}
if (product.cpp.entryPoint) {
@@ -364,6 +385,8 @@ function linkerFlags(project, product, input, outputs) {
args.push("-s", product.cpp.entryPoint);
else if (product.qbs.architecture === "avr")
args.push("-s", product.cpp.entryPoint);
+ else if (product.qbs.architecture === "stm8")
+ args.push("--entry", product.cpp.entryPoint);
}
if (product.qbs.architecture === "arm")
@@ -372,6 +395,8 @@ function linkerFlags(project, product, input, outputs) {
args.push("-S"); // Silent operation.
else if (product.qbs.architecture === "avr")
args.push("-S"); // Silent operation.
+ else if (product.qbs.architecture === "stm8")
+ args.push("--silent"); // Silent operation.
args = args.concat(ModUtils.moduleProperty(product, "driverLinkerFlags"));
return args;
diff --git a/share/qbs/modules/cpp/iar.qbs b/share/qbs/modules/cpp/iar.qbs
index 6d15781a5..8b8773f7c 100644
--- a/share/qbs/modules/cpp/iar.qbs
+++ b/share/qbs/modules/cpp/iar.qbs
@@ -86,6 +86,8 @@ CppModule {
return "icc8051" + compilerExtension;
case "avr":
return "iccavr" + compilerExtension;
+ case "stm8":
+ return "iccstm8" + compilerExtension;
}
}
compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName)
@@ -98,6 +100,8 @@ CppModule {
return "a8051" + compilerExtension;
case "avr":
return "aavr" + compilerExtension;
+ case "stm8":
+ return "iasmstm8" + compilerExtension;
}
}
assemblerPath: FileInfo.joinPaths(toolchainInstallPath, assemblerName)
@@ -110,6 +114,8 @@ CppModule {
return "xlink" + compilerExtension;
case "avr":
return "xlink" + compilerExtension;
+ case "stm8":
+ return "ilinkstm8" + compilerExtension;
}
}
linkerPath: FileInfo.joinPaths(toolchainInstallPath, linkerName)
@@ -122,6 +128,8 @@ CppModule {
return "xlib" + compilerExtension;
case "avr":
return "xlib" + compilerExtension;
+ case "stm8":
+ return "iarchive" + compilerExtension;
}
}
property string archiverPath: FileInfo.joinPaths(toolchainInstallPath, archiverName)
@@ -136,6 +144,8 @@ CppModule {
return ".r51";
case "avr":
return ".r90";
+ case "stm8":
+ return ".a";
}
}
@@ -147,6 +157,8 @@ CppModule {
return qbs.debugInformation ? ".d51" : ".a51";
case "avr":
return qbs.debugInformation ? ".d90" : ".a90";
+ case "stm8":
+ return ".out";
}
}
@@ -158,6 +170,8 @@ CppModule {
return ".r51";
case "avr":
return ".r90";
+ case "stm8":
+ return ".o";
}
}
@@ -169,6 +183,8 @@ CppModule {
return "ubrof";
case "avr":
return "ubrof";
+ case "stm8":
+ return "elf";
}
}
@@ -189,7 +205,7 @@ CppModule {
}
FileTagger {
- condition: qbs.architecture === "arm";
+ condition: qbs.architecture === "arm" || qbs.architecture === "stm8";
patterns: "*.s"
fileTags: ["asm"]
}
diff --git a/src/app/qbs-setup-toolchains/iarewprobe.cpp b/src/app/qbs-setup-toolchains/iarewprobe.cpp
index 7ac786b98..4a8ed499b 100644
--- a/src/app/qbs-setup-toolchains/iarewprobe.cpp
+++ b/src/app/qbs-setup-toolchains/iarewprobe.cpp
@@ -57,7 +57,8 @@ using Internal::HostOsInfo;
static QStringList knownIarCompilerNames()
{
- return {QStringLiteral("icc8051"), QStringLiteral("iccarm"), QStringLiteral("iccavr")};
+ return {QStringLiteral("icc8051"), QStringLiteral("iccarm"),
+ QStringLiteral("iccavr"), QStringLiteral("iccstm8")};
}
static QString guessIarArchitecture(const QFileInfo &compiler)
@@ -69,6 +70,8 @@ static QString guessIarArchitecture(const QFileInfo &compiler)
return QStringLiteral("arm");
if (baseName == QLatin1String("iccavr"))
return QStringLiteral("avr");
+ if (baseName == QLatin1String("iccstm8"))
+ return QStringLiteral("stm8");
return {};
}
@@ -137,7 +140,8 @@ static Version dumpIarCompilerVersion(const QFileInfo &compiler)
if (arch == QLatin1String("arm")) {
return Version{verCode / 1000000, (verCode / 1000) % 1000, verCode % 1000};
} else if (arch == QLatin1String("avr")
- || arch == QLatin1String("mcs51")) {
+ || arch == QLatin1String("mcs51")
+ || arch == QLatin1String("stm8")) {
return Version{verCode / 100, verCode % 100};
}
@@ -181,6 +185,7 @@ static std::vector<ToolchainInstallInfo> installedIarsFromRegistry()
{QStringLiteral("EWARM"), QStringLiteral("\\arm\\bin\\iccarm.exe")},
{QStringLiteral("EWAVR"), QStringLiteral("\\avr\\bin\\iccavr.exe")},
{QStringLiteral("EW8051"), QStringLiteral("\\8051\\bin\\icc8051.exe")},
+ {QStringLiteral("EWSTM8"), QStringLiteral("\\stm8\\bin\\iccstm8.exe")},
};
QSettings registry(QLatin1String(kRegistryNode), QSettings::NativeFormat);