2
我試圖將nRF51822(Arm Cortex微控制器)構建過程從Make
轉換爲QBS
。我有編譯過程工作正常(大量硬編碼路徑,但我會稍後修復)。但是,最後一步是使用objcopy
將鏈接器生成的.out
文件轉換爲.hex
文件。我不知道如何讓我的規則來運行其它不是通過使另一Application
這樣的(這並不能很好地工作):QBS後構建步驟
import qbs
import qbs.FileInfo
Project {
CppApplication {
type: "application" // To suppress bundle generation on Mac
name: "nrf51_template"
files: ["main.cpp",
"nrf51822/Source/nrf_delay/nrf_delay.c"]
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"]
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"
// To flash:
// nrfjprog --reset --program $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
}
Application {
name: "nrf51_template_hex"
Group {
files: "C:/Users/thutt/nRF51_Template-build/qtc_Desktop2-debug/nrf51_template.out"
fileTags: ["out"]
}
Depends {
name: "nrf51_template"
}
Rule {
id: hex
inputs: ["out"]
Artifact {
fileTags: ["application"]
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;
}
}
}
}
是否有可能在的A-Link後工序CppApplication
而不是兩個Application
是這樣的嗎?我最好用我自己的Rule
定義一個全新的Application
進行編譯和鏈接?
還有一個問題,是否可以在QBS文件中指定「運行」可執行文件,以便當我單擊QtCreator中的運行時,它實際上運行nrfjprog.exe並將代碼閃爍到芯片上? (您可以在IDE中執行此操作,但我希望能夠在QBS文件中執行此操作。)
好主意,我想爲某些MCU項目嘗試QBS!如果你想聊聊這個,請在Twitter上打我;) – errordeveloper