$ objcopy -O binary -j .text prog.elf prog.bin$ objcopy -O ihex -j .text prog.elf prog.hex
cpp.linkerScripts: [ "stack.ld", "sections.ld" ]
flags = flags.concat(["-T",path+"/"+ld_script])
cpp.linkerScripts: [ "STM32F4XX.ld" ]
Javascriptimport qbs Product { name: "AIP_firmware" type: ["application"]//,"hex","bin"] Depends { name:"cpp" } cpp.executableSuffix: ".elf" files: [ "src/*.c", "src/*.h" ] cpp.includePaths: [ "src/" ] cpp.commonCompilerFlags: [ "-mmcu=msp430f5529", "-fdata-sections","-ffunction-sections", "-Wl,-gc-sections", "-Os", "-nostartfiles","-nostdlib","-nodefaultlibs", "-std=gnu99","-Wall", "-D VERSION="+version ]; cpp.linkerFlags:[ "-mmcu=msp430f5529", "-fdata-sections","-ffunction-sections", "-Wl,-gc-sections", "-Os", "-nostartfiles","-nostdlib","-nodefaultlibs", "-std=gnu99","-Wall", "-D VERSION="+version ]; Rule { inputs: ["c"] Artifact { fileTags: ['obj'] filePath: '.obj/' + qbs.getHash(input.baseDir) + '/' + input.fileName + '.o' } prepare: { var args = []; args = args.concat(product.compilerOptions) args.push('-J'); args.push('-c'); args.push(input.filePath); args.push('-o'); args.push(output.filePath); var cmd = new Command(product.compilerPath, args); cmd.description = 'compiling ' + input.fileName; return cmd; } } Rule { multiplex: true inputs: ['obj'] Artifact { fileTags: ['elf'] filePath: product.name + '.elf' } prepare: { var args = []; args = args.concat(product.compilerOptions) for (i in inputs["obj"]) args.push(inputs["obj"][i].filePath); args.push('-o'); args.push(output.filePath); var cmd = new Command(product.compilerPath, args); cmd.description = 'linking ' + product.name + product.compilerOptions; return cmd; } } Rule { inputs: "elf" Artifact { fileTags: ["bin"] filePath: product.name + ".bin" } prepare: { var args = ["-O", "binary", input.filePath, output.filePath]; var cmd = new Command(product.objcopyPath, args); cmd.description = "converting to bin"; return cmd; } } Rule { inputs: "elf" Artifact { fileTags: ["hex"] filePath: product.name + ".hex" } prepare: { var args = ["-O", "ihex", input.filePath, output.filePath]; var cmd = new Command(product.objcopyPath, args); cmd.description = "converting to hex"; return cmd; } }}
The following properties are not set. Set them in your profile or product: cpp.architecture: you might want to re-run 'qbs-setup-toolchains'
Javascriptimport qbs Product { name: "AIP_firmware" type: ["elf","hex","bin"] property string version: "0.0" property string compilerPath: "/usr/bin/msp430-gcc" property string objcopyPath: "/usr/bin/msp430-objcopy" property var compilerOptions: [ "-mmcu=msp430f5529", "-fdata-sections","-ffunction-sections", "-Wl,-gc-sections", "-Os", "-nostartfiles","-nostdlib","-nodefaultlibs", "-std=gnu99","-Wall", "-D VERSION="+version ]; Group { name: "sources" files: 'src/*.c' fileTags: ['c'] } Group { name: "headers" files: 'src/*.h' fileTags: ['h'] } Rule { inputs: ["c"] Artifact { fileTags: ['obj'] filePath: '.obj/' + qbs.getHash(input.baseDir) + '/' + input.fileName + '.o' } prepare: { var args = []; args = args.concat(product.compilerOptions) args.push('-c'); args.push(input.filePath); args.push('-o'); args.push(output.filePath); var cmd = new Command(product.compilerPath, args); cmd.description = 'compiling ' + input.fileName; return cmd; } } Rule { multiplex: true inputs: ['obj'] Artifact { fileTags: ['elf'] filePath: product.name + '.elf' } prepare: { var args = []; args = args.concat(product.compilerOptions) for (i in inputs["obj"]) args.push(inputs["obj"][i].filePath); args.push('-o'); args.push(output.filePath); var cmd = new Command(product.compilerPath, args); cmd.description = 'linking ' + product.name + product.compilerOptions; return cmd; } } Rule { inputs: "elf" Artifact { fileTags: ["bin"] filePath: product.name + ".bin" } prepare: { var args = ["-O", "binary", input.filePath, output.filePath]; var cmd = new Command(product.objcopyPath, args); cmd.description = "converting to bin"; return cmd; } } Rule { inputs: "elf" Artifact { fileTags: ["hex"] filePath: product.name + ".hex" } prepare: { var args = ["-O", "ihex", input.filePath, output.filePath]; var cmd = new Command(product.objcopyPath, args); cmd.description = "converting to hex"; return cmd; } }}
/usr/local/bin/mspdebug tilib "prog path_to_my_file.bin reset"