0

ST-LINK nrf51822 and QT Creator [closed]

bishop gravatar image

asked 2015-01-07 21:13:26 +0200

updated 2015-01-07 21:38:11 +0200

Hello! I'm trying to build a program for nrf51822 via QT Creator. I'm using QBS for build. I have a makefile from SDK examples for nrf51822. Someone can help me, how to setup qbs-project to build (and debug) nrf51822 program? Thanks.

edit retag flag offensive reopen delete report spam

Closed as "the question is answered, right answer was accepted" by bishop at 2015-01-20 19:45:09 +0200

1 answer

Sort by » oldest newest most voted
3
mmulder gravatar image

answered 2015-01-13 09:35:10 +0200

updated 2015-01-13 13:42:38 +0200

Hi,

I use QT creator under Linux and Mac for nRF51822 software development. Below an example qbs file using the heartrate example. I you have other questions just ask.

import qbs
import qbs.FileInfo

Product {
Depends { name:"cpp" }

type: ["application", "hex", "bin", "size"]
name: "example"

property string sdk: "../nrf51-sdk/"
property string vendor: "Nordic"
property string softDevice: "s110"
property string device: "nrf51822"
property string deviceVariant: "xxac" // xxaa=256kB Flash,16kB RAM | xxab=128kB Flash,16kB RAM | xxac=256kB Flash,32kB RAM

cpp.defines: [
    "NRF51",
    "BLE_STACK_SUPPORT_REQD",
    "S110",
    "SOFTDEVICE_PRESENT",
    "BOARD_PCA10028"
]
cpp.warningLevel: "default" //"all" // or "none", "default"
cpp.treatWarningsAsErrors: true
cpp.executableSuffix: ".out"
cpp.positionIndependentCode: false

Properties {
    condition: qbs.buildVariant === "debug"
    cpp.commonCompilerFlags: [
        "-mcpu=cortex-m0", "-mthumb", "-mabi=aapcs", "-mfloat-abi=soft",
        "-std=gnu99", "-flto", "-fno-builtin",
        "-fdata-sections","-ffunction-sections","-fno-strict-aliasing",
        "-Wall",
    ]
    cpp.debugInformation: true
    cpp.optimization: "none" // "none" or "fast"
}

Properties {
    condition: qbs.buildVariant === "release"
    cpp.commonCompilerFlags: [
        "-mcpu=cortex-m0", "-mthumb", "-mabi=aapcs", "-mfloat-abi=soft",
        "-std=gnu99", "-flto", "-fno-builtin",
        "-fdata-sections","-ffunction-sections","-fno-strict-aliasing",
        "-Wall",
    ]
    cpp.debugInformation: false
    cpp.optimization: "small"
}

cpp.linkerFlags:[
    "-Xlinker", "-Map="+buildDirectory+"/"+name+".map",
    "-mthumb", "-mabi=aapcs",
    "-L"+path+"/"+sdk+"components/toolchain/gcc/",
    "-T"+path+"/"+sdk+"components/toolchain/gcc/gcc_nrf51_"+softDevice+"_"+deviceVariant+".ld",
    "-mcpu=cortex-m0",
    "-Wl,--gc-sections","--specs=nano.specs","-lc","-lnosys",
]
cpp.includePaths: [
    "../inc",
    sdk+"examples/bsp",
    sdk+"components/ble/common",
    sdk+"components/ble/ble_services/ble_bas",
    sdk+"components/ble/ble_services/ble_hrs",
    sdk+"components/ble/ble_services/ble_dis",
    sdk+"components/ble/device_manager",
    sdk+"components/drivers_nrf/hal",
    sdk+"components/drivers_nrf/uart",
    sdk+"components/drivers_nrf/pstorage",
    sdk+"components/drivers_nrf/pstorage/config",
    sdk+"components/libraries/fifo",
    sdk+"components/libraries/sensorsim",
    sdk+"components/libraries/scheduler",
    sdk+"components/libraries/timer",
    sdk+"components/libraries/button",
    sdk+"components/libraries/trace",
    sdk+"components/libraries/gpiote",
    sdk+"components/libraries/util",
    sdk+"components/softdevice/"+softDevice+"/headers/",
    sdk+"components/softdevice/common/softdevice_handler",
    sdk+"components/toolchain/gcc",
    sdk+"components/toolchain",
]
files: [
    "../src/*.c",
    sdk+"examples/bsp/bsp.c",
    sdk+"components/libraries/button/app_button.c",
    sdk+"components/libraries/sensorsim/ble_sensorsim.c",
    sdk+"components/libraries/util/app_error.c",
    sdk+"components/libraries/timer/app_timer.c",
    sdk+"components/libraries/gpiote/app_gpiote.c",
    sdk+"components/libraries/scheduler/app_scheduler.c",
    sdk+"components/libraries/util/nrf_assert.c",
    sdk+"components/libraries/trace/app_trace.c",
    sdk+"components/libraries/uart/retarget.c",
    sdk+"components/libraries/fifo/app_fifo.c",
    sdk+"components/drivers_nrf/hal/nrf_delay.c",
    sdk+"components/drivers_nrf/pstorage/pstorage.c",
    sdk+"components/drivers_nrf/uart/app_uart_fifo.c",
    sdk+"components/softdevice/common/softdevice_handler/softdevice_handler.c",
    sdk+"components/toolchain/system_nrf51.c",
    sdk+"components/ble/ble_services/ble_hrs/ble_hrs.c",
    sdk+"components/ble/ble_services/ble_dis/ble_dis.c",
    sdk+"components/ble/ble_services/ble_bas/ble_bas.c",
    sdk+"components/ble/common/ble_conn_params.c",
    sdk+"components/ble/common/ble_advdata.c",
    sdk+"components/ble/common/ble_srv_common.c",
    sdk+"components/ble/device_manager/device_manager_peripheral.c",
    sdk+"components/toolchain/gcc/gcc_startup_nrf51.s",
]

Rule {
    id: hex
    inputs: "application"
    Artifact {
        fileTags: ["hex"]
        filePath: FileInfo.baseName(input.filePath) + ".hex"
    }
    prepare: {
        var args = ["-O", "ihex", input.filePath, output.filePath];
        var cmd = new Command("arm-none-eabi-objcopy", args);
        cmd.description = "converting to hex: "+FileInfo.fileName(input.filePath);
        cmd.highlight = "linker";
        return cmd;

    }
}

Rule {
    id: bin
    inputs: "application"
    Artifact {
        fileTags: ["bin"]
        filePath: FileInfo.baseName(input.filePath) + ".bin"
    }
    prepare: {
        var args = ["-O", "binary", input.filePath, output.filePath];
        var cmd = new Command("arm-none-eabi-objcopy", args);
        cmd.description = "converting to bin: "+FileInfo.fileName(input.filePath);
        cmd.highlight = "linker";
        return cmd;

    }
}

Rule {
        id: size
        inputs: ["application"]
        Artifact {
            fileTags: ["size"]
            filePath: "-"
        }
        prepare: {
            var args = [input.filePath];
            var cmd = new Command("arm-none-eabi-size", args);
            cmd.description = "File size: " + FileInfo.fileName(input.filePath);
            cmd.highlight = "linker";
            return cmd;
        }
    }
}
edit flag offensive delete publish link more

Comments

Thank you! This is good example! I' already resolved my problem, but your answer helped me to upgrade my project! Thank you one more time!

bishop ( 2015-01-14 11:25:01 +0200 )editconvert to answer

Any example for Ant/S210?

Miguel Ángel ( 2015-05-19 08:51:53 +0200 )editconvert to answer

This is great information, it really helped me out a lot. I created a template project based on this:

https://devzone.nordicsemi.com/blogs/...

Jacob Portukalian ( 2015-08-02 05:57:29 +0200 )editconvert to answer

Question Tools

1 follower

Stats

Asked: 2015-01-07 21:13:26 +0200

Seen: 1,733 times

Last updated: Jan 13 '15