Build QBS中的后期构建步骤
我正在尝试将nRF51822(Arm Cortex微控制器)构建过程从Build QBS中的后期构建步骤,build,qbs,nrf51,Build,Qbs,Nrf51,我正在尝试将nRF51822(Arm Cortex微控制器)构建过程从Make转换为QBS。我已经让编译过程正常工作了(有很多硬编码的路径,但我稍后会修复)。但是,最后一步是使用objcopy将链接器生成的.out文件转换为.hex文件。除了制作另一个类似这样的应用程序(效果不太好),我无法确定如何运行我的规则: 是否可以在cpp应用程序中设置一个post link步骤,而不是像这样设置两个应用程序s?我是否最好使用自己的规则定义一个全新的应用程序,以进行编译和链接 还有一个额外的问题,是否可以
Make
转换为QBS
。我已经让编译过程正常工作了(有很多硬编码的路径,但我稍后会修复)。但是,最后一步是使用objcopy
将链接器生成的.out
文件转换为.hex
文件。除了制作另一个类似这样的应用程序
(效果不太好),我无法确定如何运行我的规则:
是否可以在cpp应用程序中设置一个post link步骤,而不是像这样设置两个应用程序
s?我是否最好使用自己的规则定义一个全新的应用程序
,以进行编译和链接
还有一个额外的问题,是否可以在QBS文件中指定“运行”可执行文件,以便当我在QtCreator中单击运行时,它实际运行nrfjprog.exe并将代码闪烁到芯片上?(您可以在IDE中执行此操作,但我更希望能够在QBS文件中执行。)算出了,最终目标由应用程序中的类型:
行决定,所以只需将其更改为:
import qbs
import qbs.FileInfo
Project {
CppApplication {
// The filetag to generate.
type: "hex"
name: "nrf51_template"
files: ["main.cpp",
"SaneSPI.cpp",
"SaneSPI.h",
"Timer.cpp",
"Timer.h",
"Delay.cpp",
"Delay.h",
"GPIO.cpp",
"GPIO.h"]
Group {
name: "Startup files"
files: ["nrf51822/Source/Templates/system_" + deviceSeries + ".c",
"nrf51822/Source/Templates/gcc/gcc_startup_" + deviceSeries + ".s"]
}
// The chip variant can be:
//
// "xxaa": The 256 kB version
// "xxbb": The 128 kB version
//
// RFduino is xxaa.
property string deviceVariant: "xxaa"
// Must be "nrf51"
property string deviceSeries: "nrf51"
// The softdevice (radio firmware) to use. Can be:
//
// "": For no radio.
// "s110": For BLE slave/peripheral
// "s120": For BLE host/central
// "s130": For BLE central and peripheral
property string softDevice: "s110"
// Must be cortex-m0
property string cpu: "cortex-m0"
cpp.includePaths: ["nrf51822/Include",
"nrf51822/Include/gcc",
"nrf51822/Include/" + softDevice]
cpp.compilerName: ["arm-none-eabi-g++.exe"]
cpp.compilerPath: ["C:/Program Files/GNU Tools ARM Embedded/4.8 2014q1/bin/arm-none-eabi-g++.exe"]
cpp.linkerName: ["arm-none-eabi-g++.exe"]
cpp.linkerPath: ["C:/Program Files/GNU Tools ARM Embedded/4.8 2014q1/bin/arm-none-eabi-g++.exe"]
cpp.cxxFlags: ["-mcpu=" + cpu, "-mthumb", "-mabi=aapcs", "--std=c++11", "-mfloat-abi=soft"]
cpp.linkerFlags: ["-L\"C:/Program Files/GNU Tools ARM Embedded/4.8 2014q1/arm-none-eabi/lib/armv6-m\"",
"-L\"C:/Program Files/GNU Tools ARM Embedded/4.8 2014q1/lib/gcc/arm-none-eabi/4.8.3/armv6-m\"",
"-Xlinker",
"-Map=C:/Users/thutt/nRF51_Template/output_filename.map",
"-mcpu=" + cpu,
"-mthumb",
"-mabi=aapcs",
"-L", "C:/Users/thutt/nRF51_Template/nrf51822/Source/templates/gcc/",
"-Tgcc_" + deviceSeries + "_" + softDevice + "_" + deviceVariant + ".ld"]
cpp.defines: ["BOARD_PCA10001", "NRF51"]
// Suppresses -m32 compiler option.
cpp.architecture: "arm"
// Suppress windows definitions and compiler options.
cpp.minimumWindowsVersion: undefined
cpp.executableSuffix: ".out"
Rule {
id: hex
inputs: ["application"]
Artifact {
fileTags: ["hex"]
fileName: ".obj/" + product.name + "/" + input.baseDir + "/" + input.fileName + ".hex"
}
prepare: {
// var compilerPath = ModUtils.moduleProperty(product, "compilerPath");
var objCopyPath = "C:/Program Files/GNU Tools ARM Embedded/4.8 2014q1/bin/arm-none-eabi-objcopy.exe";
var args = ["-O", "ihex", input.filePath, output.filePath];
var cmd = new Command(objCopyPath, args);
cmd.description = "converting to hex: " + FileInfo.fileName(input.filePath);
cmd.highlight = "linker";
return cmd;
}
}
// To flash:
// nrfjprog --reset --program $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
}
}
好主意,我也打算在一些MCU项目中尝试QBS!如果你想聊这件事,就在推特上打电话给我;)
import qbs
import qbs.FileInfo
Project {
CppApplication {
// The filetag to generate.
type: "hex"
name: "nrf51_template"
files: ["main.cpp",
"SaneSPI.cpp",
"SaneSPI.h",
"Timer.cpp",
"Timer.h",
"Delay.cpp",
"Delay.h",
"GPIO.cpp",
"GPIO.h"]
Group {
name: "Startup files"
files: ["nrf51822/Source/Templates/system_" + deviceSeries + ".c",
"nrf51822/Source/Templates/gcc/gcc_startup_" + deviceSeries + ".s"]
}
// The chip variant can be:
//
// "xxaa": The 256 kB version
// "xxbb": The 128 kB version
//
// RFduino is xxaa.
property string deviceVariant: "xxaa"
// Must be "nrf51"
property string deviceSeries: "nrf51"
// The softdevice (radio firmware) to use. Can be:
//
// "": For no radio.
// "s110": For BLE slave/peripheral
// "s120": For BLE host/central
// "s130": For BLE central and peripheral
property string softDevice: "s110"
// Must be cortex-m0
property string cpu: "cortex-m0"
cpp.includePaths: ["nrf51822/Include",
"nrf51822/Include/gcc",
"nrf51822/Include/" + softDevice]
cpp.compilerName: ["arm-none-eabi-g++.exe"]
cpp.compilerPath: ["C:/Program Files/GNU Tools ARM Embedded/4.8 2014q1/bin/arm-none-eabi-g++.exe"]
cpp.linkerName: ["arm-none-eabi-g++.exe"]
cpp.linkerPath: ["C:/Program Files/GNU Tools ARM Embedded/4.8 2014q1/bin/arm-none-eabi-g++.exe"]
cpp.cxxFlags: ["-mcpu=" + cpu, "-mthumb", "-mabi=aapcs", "--std=c++11", "-mfloat-abi=soft"]
cpp.linkerFlags: ["-L\"C:/Program Files/GNU Tools ARM Embedded/4.8 2014q1/arm-none-eabi/lib/armv6-m\"",
"-L\"C:/Program Files/GNU Tools ARM Embedded/4.8 2014q1/lib/gcc/arm-none-eabi/4.8.3/armv6-m\"",
"-Xlinker",
"-Map=C:/Users/thutt/nRF51_Template/output_filename.map",
"-mcpu=" + cpu,
"-mthumb",
"-mabi=aapcs",
"-L", "C:/Users/thutt/nRF51_Template/nrf51822/Source/templates/gcc/",
"-Tgcc_" + deviceSeries + "_" + softDevice + "_" + deviceVariant + ".ld"]
cpp.defines: ["BOARD_PCA10001", "NRF51"]
// Suppresses -m32 compiler option.
cpp.architecture: "arm"
// Suppress windows definitions and compiler options.
cpp.minimumWindowsVersion: undefined
cpp.executableSuffix: ".out"
Rule {
id: hex
inputs: ["application"]
Artifact {
fileTags: ["hex"]
fileName: ".obj/" + product.name + "/" + input.baseDir + "/" + input.fileName + ".hex"
}
prepare: {
// var compilerPath = ModUtils.moduleProperty(product, "compilerPath");
var objCopyPath = "C:/Program Files/GNU Tools ARM Embedded/4.8 2014q1/bin/arm-none-eabi-objcopy.exe";
var args = ["-O", "ihex", input.filePath, output.filePath];
var cmd = new Command(objCopyPath, args);
cmd.description = "converting to hex: " + FileInfo.fileName(input.filePath);
cmd.highlight = "linker";
return cmd;
}
}
// To flash:
// nrfjprog --reset --program $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
}
}