Avnet Silica / Mbed OS mbed-os-sensor-node
Committer:
rspelta
Date:
Mon Oct 02 13:02:22 2017 +0200
Revision:
0:e9b834175c38
First Release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rspelta 0:e9b834175c38 1 properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
rspelta 0:e9b834175c38 2 [$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: 'latest', description: 'Revision of mbed-os to build. To access mbed-os PR use format "pull/PR number/head"']
rspelta 0:e9b834175c38 3 ]]])
rspelta 0:e9b834175c38 4
rspelta 0:e9b834175c38 5 try {
rspelta 0:e9b834175c38 6 echo "Verifying build with mbed-os version ${mbed_os_revision}"
rspelta 0:e9b834175c38 7 env.MBED_OS_REVISION = "${mbed_os_revision}"
rspelta 0:e9b834175c38 8 if (mbed_os_revision.matches('pull/\\d+/head')) {
rspelta 0:e9b834175c38 9 echo "Revision is a Pull Request"
rspelta 0:e9b834175c38 10 }
rspelta 0:e9b834175c38 11 } catch (err) {
rspelta 0:e9b834175c38 12 def mbed_os_revision = "latest"
rspelta 0:e9b834175c38 13 echo "Verifying build with mbed-os version ${mbed_os_revision}"
rspelta 0:e9b834175c38 14 env.MBED_OS_REVISION = "${mbed_os_revision}"
rspelta 0:e9b834175c38 15 }
rspelta 0:e9b834175c38 16
rspelta 0:e9b834175c38 17 // List of targets to compile
rspelta 0:e9b834175c38 18 def targets = [
rspelta 0:e9b834175c38 19 "K64F",
rspelta 0:e9b834175c38 20 "NUCLEO_F429ZI",
rspelta 0:e9b834175c38 21 "UBLOX_EVK_ODIN_W2"
rspelta 0:e9b834175c38 22 ]
rspelta 0:e9b834175c38 23
rspelta 0:e9b834175c38 24 // Map toolchains to compilers
rspelta 0:e9b834175c38 25 def toolchains = [
rspelta 0:e9b834175c38 26 ARM: "armcc",
rspelta 0:e9b834175c38 27 GCC_ARM: "arm-none-eabi-gcc",
rspelta 0:e9b834175c38 28 IAR: "iar_arm"
rspelta 0:e9b834175c38 29 ]
rspelta 0:e9b834175c38 30
rspelta 0:e9b834175c38 31 def configurations = [
rspelta 0:e9b834175c38 32 "def": ["ETH"],
rspelta 0:e9b834175c38 33 "thd": ["ATMEL", "MCR20"],
rspelta 0:e9b834175c38 34 "6lp": ["ATMEL", "MCR20"]
rspelta 0:e9b834175c38 35 ]
rspelta 0:e9b834175c38 36
rspelta 0:e9b834175c38 37 def connectiontypes = [
rspelta 0:e9b834175c38 38 "ETH",
rspelta 0:e9b834175c38 39 "ATMEL",
rspelta 0:e9b834175c38 40 "MCR20"
rspelta 0:e9b834175c38 41 ]
rspelta 0:e9b834175c38 42
rspelta 0:e9b834175c38 43 def stepsForParallel = [:]
rspelta 0:e9b834175c38 44
rspelta 0:e9b834175c38 45 // Jenkins pipeline does not support map.each, we need to use oldschool for loop
rspelta 0:e9b834175c38 46 for (int i = 0; i < targets.size(); i++) {
rspelta 0:e9b834175c38 47 for(int j = 0; j < toolchains.size(); j++) {
rspelta 0:e9b834175c38 48 for(int k = 0; k < configurations.size(); k++) {
rspelta 0:e9b834175c38 49 for(int l = 0; l < connectiontypes.size(); l++) {
rspelta 0:e9b834175c38 50
rspelta 0:e9b834175c38 51 def target = targets.get(i)
rspelta 0:e9b834175c38 52 def toolchain = toolchains.keySet().asList().get(j)
rspelta 0:e9b834175c38 53 def compilerLabel = toolchains.get(toolchain)
rspelta 0:e9b834175c38 54 def config = configurations.keySet().asList().get(k)
rspelta 0:e9b834175c38 55 def allowed_configs = configurations.get(config)
rspelta 0:e9b834175c38 56 def connectiontype = connectiontypes.get(l)
rspelta 0:e9b834175c38 57
rspelta 0:e9b834175c38 58 def stepName = "${target} ${toolchain} ${config} ${connectiontype}"
rspelta 0:e9b834175c38 59 if(allowed_configs.contains(connectiontype)) {
rspelta 0:e9b834175c38 60 stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain, config, connectiontype)
rspelta 0:e9b834175c38 61 }
rspelta 0:e9b834175c38 62 }
rspelta 0:e9b834175c38 63 }
rspelta 0:e9b834175c38 64 }
rspelta 0:e9b834175c38 65 }
rspelta 0:e9b834175c38 66
rspelta 0:e9b834175c38 67 timestamps {
rspelta 0:e9b834175c38 68 parallel stepsForParallel
rspelta 0:e9b834175c38 69 }
rspelta 0:e9b834175c38 70
rspelta 0:e9b834175c38 71 def buildStep(target, compilerLabel, toolchain, configName, connectiontype) {
rspelta 0:e9b834175c38 72 return {
rspelta 0:e9b834175c38 73 stage ("${target}_${compilerLabel}_${configName}_${connectiontype}") {
rspelta 0:e9b834175c38 74 node ("${compilerLabel}") {
rspelta 0:e9b834175c38 75 deleteDir()
rspelta 0:e9b834175c38 76 dir("mbed-os-example-client") {
rspelta 0:e9b834175c38 77 checkout scm
rspelta 0:e9b834175c38 78 def config_file = "mbed_app.json"
rspelta 0:e9b834175c38 79
rspelta 0:e9b834175c38 80 if ("${configName}" == "thd") {
rspelta 0:e9b834175c38 81 config_file = "./configs/mesh_thread.json"
rspelta 0:e9b834175c38 82 // Update Thread channel and PANID
rspelta 0:e9b834175c38 83 execute("sed -i 's/\"mbed-mesh-api.thread-config-channel\": 22/\"mbed-mesh-api.thread-config-channel\": 18/' ${config_file}")
rspelta 0:e9b834175c38 84 execute("sed -i 's/\"mbed-mesh-api.thread-config-panid\": \"0x0700\"/\"mbed-mesh-api.thread-config-panid\": \"0xBAAB\"/' ${config_file}")
rspelta 0:e9b834175c38 85
rspelta 0:e9b834175c38 86 }
rspelta 0:e9b834175c38 87
rspelta 0:e9b834175c38 88 if ("${configName}" == "6lp") {
rspelta 0:e9b834175c38 89 config_file = "./configs/mesh_6lowpan.json"
rspelta 0:e9b834175c38 90
rspelta 0:e9b834175c38 91 // Change channel for HW tests
rspelta 0:e9b834175c38 92 execute ("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel\": 12/\"mbed-mesh-api.6lowpan-nd-channel\": 17/' ${config_file}")
rspelta 0:e9b834175c38 93
rspelta 0:e9b834175c38 94 //Use PANID filter
rspelta 0:e9b834175c38 95 execute ("sed -i '/6lowpan-nd-channel\":/a \"mbed-mesh-api.6lowpan-nd-panid-filter\": \"0xABBA\",' ${config_file}")
rspelta 0:e9b834175c38 96 }
rspelta 0:e9b834175c38 97
rspelta 0:e9b834175c38 98 if ("${connectiontype}" == "MCR20") {
rspelta 0:e9b834175c38 99 // Replace default rf shield
rspelta 0:e9b834175c38 100 execute ("sed -i 's/\"value\": \"ATMEL\"/\"value\": \"MCR20\"/' ${config_file}")
rspelta 0:e9b834175c38 101 }
rspelta 0:e9b834175c38 102
rspelta 0:e9b834175c38 103 // Copy security.h to build
rspelta 0:e9b834175c38 104 mbed.getSecurityFile()
rspelta 0:e9b834175c38 105
rspelta 0:e9b834175c38 106 // Set mbed-os to revision received as parameter
rspelta 0:e9b834175c38 107 execute ("mbed deploy --protocol ssh")
rspelta 0:e9b834175c38 108 dir("mbed-os") {
rspelta 0:e9b834175c38 109 if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) {
rspelta 0:e9b834175c38 110 // Use mbed-os PR and switch to branch created
rspelta 0:e9b834175c38 111 execute("git fetch origin ${env.MBED_OS_REVISION}:_PR_")
rspelta 0:e9b834175c38 112 execute("git checkout _PR_")
rspelta 0:e9b834175c38 113 } else {
rspelta 0:e9b834175c38 114 execute ("git checkout ${env.MBED_OS_REVISION}")
rspelta 0:e9b834175c38 115 }
rspelta 0:e9b834175c38 116 }
rspelta 0:e9b834175c38 117 execute ("mbed compile --build out/${target}_${toolchain}_${configName}_${connectiontype}/ -m ${target} -t ${toolchain} -c --app-config ${config_file}")
rspelta 0:e9b834175c38 118 }
rspelta 0:e9b834175c38 119 archive '**/mbed-os-example-client.bin'
rspelta 0:e9b834175c38 120 step([$class: 'WsCleanup'])
rspelta 0:e9b834175c38 121 }
rspelta 0:e9b834175c38 122 }
rspelta 0:e9b834175c38 123 }
rspelta 0:e9b834175c38 124 }