![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
example using mbed loramac with GPS in application layer
This repository can work on NAmote72.
This main.cpp generates Cayenne LPP GPS payload.
See mbed documentation for provisioning instructions.
Jenkinsfile@0:2e040cc7f7b8, 2019-01-03 (annotated)
- Committer:
- Wayne Roberts
- Date:
- Thu Jan 03 16:18:09 2019 -0800
- Revision:
- 0:2e040cc7f7b8
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Wayne Roberts |
0:2e040cc7f7b8 | 1 | properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [ |
Wayne Roberts |
0:2e040cc7f7b8 | 2 | [$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: '', description: 'Revision of mbed-os to build. To access mbed-os PR use format "pull/PR number/head"'], |
Wayne Roberts |
0:2e040cc7f7b8 | 3 | [$class: 'BooleanParameterDefinition', name: 'regions_build_test', defaultValue: true, description: 'Test build all available regions'] |
Wayne Roberts |
0:2e040cc7f7b8 | 4 | ]]]) |
Wayne Roberts |
0:2e040cc7f7b8 | 5 | |
Wayne Roberts |
0:2e040cc7f7b8 | 6 | library 'mbed-lib' |
Wayne Roberts |
0:2e040cc7f7b8 | 7 | |
Wayne Roberts |
0:2e040cc7f7b8 | 8 | if (env.MBED_OS_REVISION == null) { |
Wayne Roberts |
0:2e040cc7f7b8 | 9 | echo 'First run in this branch, using default parameter values' |
Wayne Roberts |
0:2e040cc7f7b8 | 10 | env.MBED_OS_REVISION = '' |
Wayne Roberts |
0:2e040cc7f7b8 | 11 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 12 | if (env.MBED_OS_REVISION == '') { |
Wayne Roberts |
0:2e040cc7f7b8 | 13 | echo 'Using mbed OS revision from mbed-os.lib' |
Wayne Roberts |
0:2e040cc7f7b8 | 14 | } else { |
Wayne Roberts |
0:2e040cc7f7b8 | 15 | echo "Using given mbed OS revision: ${env.MBED_OS_REVISION}" |
Wayne Roberts |
0:2e040cc7f7b8 | 16 | if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) { |
Wayne Roberts |
0:2e040cc7f7b8 | 17 | echo "Revision is a Pull Request" |
Wayne Roberts |
0:2e040cc7f7b8 | 18 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 19 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 20 | |
Wayne Roberts |
0:2e040cc7f7b8 | 21 | // All available regions |
Wayne Roberts |
0:2e040cc7f7b8 | 22 | def regions = [ |
Wayne Roberts |
0:2e040cc7f7b8 | 23 | "\"0\"", "\"1\"", "\"2\"", "\"3\"", "\"4\"", "\"5\"", "\"6\"", "\"7\"", "\"8\"", |
Wayne Roberts |
0:2e040cc7f7b8 | 24 | "\"EU868\"", "\"AS923\"", "\"AU915\"", "\"CN470\"", "\"CN779\"", "\"EU433\"", |
Wayne Roberts |
0:2e040cc7f7b8 | 25 | "\"IN865\"", "\"KR920\"", "\"US915\"" |
Wayne Roberts |
0:2e040cc7f7b8 | 26 | ] |
Wayne Roberts |
0:2e040cc7f7b8 | 27 | |
Wayne Roberts |
0:2e040cc7f7b8 | 28 | // Supported targets |
Wayne Roberts |
0:2e040cc7f7b8 | 29 | def targets = [ |
Wayne Roberts |
0:2e040cc7f7b8 | 30 | "K64F", |
Wayne Roberts |
0:2e040cc7f7b8 | 31 | "MTB_MTS_XDOT", |
Wayne Roberts |
0:2e040cc7f7b8 | 32 | "MTB_MURATA_ABZ", |
Wayne Roberts |
0:2e040cc7f7b8 | 33 | "MTS_MDOT_F411RE", |
Wayne Roberts |
0:2e040cc7f7b8 | 34 | "DISCO_L072CZ_LRWAN1", |
Wayne Roberts |
0:2e040cc7f7b8 | 35 | "MTB_ADV_WISE_1510", |
Wayne Roberts |
0:2e040cc7f7b8 | 36 | "MTB_RAK811" |
Wayne Roberts |
0:2e040cc7f7b8 | 37 | ] |
Wayne Roberts |
0:2e040cc7f7b8 | 38 | |
Wayne Roberts |
0:2e040cc7f7b8 | 39 | // Map toolchains to compilers |
Wayne Roberts |
0:2e040cc7f7b8 | 40 | def toolchains = [ |
Wayne Roberts |
0:2e040cc7f7b8 | 41 | ARM: "armcc", |
Wayne Roberts |
0:2e040cc7f7b8 | 42 | GCC_ARM: "arm-none-eabi-gcc", |
Wayne Roberts |
0:2e040cc7f7b8 | 43 | IAR: "iar_arm", |
Wayne Roberts |
0:2e040cc7f7b8 | 44 | ARMC6: "arm6" |
Wayne Roberts |
0:2e040cc7f7b8 | 45 | ] |
Wayne Roberts |
0:2e040cc7f7b8 | 46 | |
Wayne Roberts |
0:2e040cc7f7b8 | 47 | def stepsForParallel = [:] |
Wayne Roberts |
0:2e040cc7f7b8 | 48 | |
Wayne Roberts |
0:2e040cc7f7b8 | 49 | // Jenkins pipeline does not support map.each, we need to use oldschool for loop |
Wayne Roberts |
0:2e040cc7f7b8 | 50 | for (int i = 0; i < targets.size(); i++) { |
Wayne Roberts |
0:2e040cc7f7b8 | 51 | for(int j = 0; j < toolchains.size(); j++) { |
Wayne Roberts |
0:2e040cc7f7b8 | 52 | def target = targets.get(i) |
Wayne Roberts |
0:2e040cc7f7b8 | 53 | def toolchain = toolchains.keySet().asList().get(j) |
Wayne Roberts |
0:2e040cc7f7b8 | 54 | def compilerLabel = toolchains.get(toolchain) |
Wayne Roberts |
0:2e040cc7f7b8 | 55 | |
Wayne Roberts |
0:2e040cc7f7b8 | 56 | // Skip unwanted combination |
Wayne Roberts |
0:2e040cc7f7b8 | 57 | if (target == "MTB_MURATA_ABZ" && toolchain == "GCC_ARM") { |
Wayne Roberts |
0:2e040cc7f7b8 | 58 | continue |
Wayne Roberts |
0:2e040cc7f7b8 | 59 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 60 | if (target == "DISCO_L072CZ_LRWAN1" && toolchain == "GCC_ARM") { |
Wayne Roberts |
0:2e040cc7f7b8 | 61 | continue |
Wayne Roberts |
0:2e040cc7f7b8 | 62 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 63 | if (target == "MTB_RAK811" && toolchain == "GCC_ARM") { |
Wayne Roberts |
0:2e040cc7f7b8 | 64 | continue |
Wayne Roberts |
0:2e040cc7f7b8 | 65 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 66 | |
Wayne Roberts |
0:2e040cc7f7b8 | 67 | def stepName = "${target} ${toolchain}" |
Wayne Roberts |
0:2e040cc7f7b8 | 68 | |
Wayne Roberts |
0:2e040cc7f7b8 | 69 | stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain) |
Wayne Roberts |
0:2e040cc7f7b8 | 70 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 71 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 72 | |
Wayne Roberts |
0:2e040cc7f7b8 | 73 | def stepsForRegional = [:] |
Wayne Roberts |
0:2e040cc7f7b8 | 74 | |
Wayne Roberts |
0:2e040cc7f7b8 | 75 | if (params.regions_build_test == true) { |
Wayne Roberts |
0:2e040cc7f7b8 | 76 | stepsForRegional["REGION BUILDER"] = build_regions(regions) |
Wayne Roberts |
0:2e040cc7f7b8 | 77 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 78 | |
Wayne Roberts |
0:2e040cc7f7b8 | 79 | timestamps { |
Wayne Roberts |
0:2e040cc7f7b8 | 80 | parallel stepsForParallel |
Wayne Roberts |
0:2e040cc7f7b8 | 81 | parallel stepsForRegional |
Wayne Roberts |
0:2e040cc7f7b8 | 82 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 83 | |
Wayne Roberts |
0:2e040cc7f7b8 | 84 | def buildStep(target, compilerLabel, toolchain) { |
Wayne Roberts |
0:2e040cc7f7b8 | 85 | return { |
Wayne Roberts |
0:2e040cc7f7b8 | 86 | stage ("${target}_${compilerLabel}") { |
Wayne Roberts |
0:2e040cc7f7b8 | 87 | node ("${compilerLabel}") { |
Wayne Roberts |
0:2e040cc7f7b8 | 88 | deleteDir() |
Wayne Roberts |
0:2e040cc7f7b8 | 89 | dir("mbed-os-example-lorawan") { |
Wayne Roberts |
0:2e040cc7f7b8 | 90 | checkout scm |
Wayne Roberts |
0:2e040cc7f7b8 | 91 | execute("mbed deploy --protocol ssh") |
Wayne Roberts |
0:2e040cc7f7b8 | 92 | |
Wayne Roberts |
0:2e040cc7f7b8 | 93 | // Set mbed-os to revision received as parameter |
Wayne Roberts |
0:2e040cc7f7b8 | 94 | if (env.MBED_OS_REVISION != '') { |
Wayne Roberts |
0:2e040cc7f7b8 | 95 | dir("mbed-os") { |
Wayne Roberts |
0:2e040cc7f7b8 | 96 | if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) { |
Wayne Roberts |
0:2e040cc7f7b8 | 97 | // Use mbed-os PR and switch to branch created |
Wayne Roberts |
0:2e040cc7f7b8 | 98 | execute("git fetch origin ${env.MBED_OS_REVISION}:_PR_") |
Wayne Roberts |
0:2e040cc7f7b8 | 99 | execute("git checkout _PR_") |
Wayne Roberts |
0:2e040cc7f7b8 | 100 | } else { |
Wayne Roberts |
0:2e040cc7f7b8 | 101 | execute("git checkout ${env.MBED_OS_REVISION}") |
Wayne Roberts |
0:2e040cc7f7b8 | 102 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 103 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 104 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 105 | |
Wayne Roberts |
0:2e040cc7f7b8 | 106 | // Adjust stack size and crystal values |
Wayne Roberts |
0:2e040cc7f7b8 | 107 | if ("${target}" == "DISCO_L072CZ_LRWAN1") { |
Wayne Roberts |
0:2e040cc7f7b8 | 108 | execute("sed -i 's/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10)/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x13)/' \ |
Wayne Roberts |
0:2e040cc7f7b8 | 109 | mbed-os/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rcc.h") |
Wayne Roberts |
0:2e040cc7f7b8 | 110 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 111 | |
Wayne Roberts |
0:2e040cc7f7b8 | 112 | if ("${target}" == "MTB_MURATA_ABZ") { |
Wayne Roberts |
0:2e040cc7f7b8 | 113 | execute("sed -i 's/define symbol __size_heap__ = 0x800;/define symbol __size_heap__ = 0x1000;/' \ |
Wayne Roberts |
0:2e040cc7f7b8 | 114 | mbed-os/targets/TARGET_STM/TARGET_STM32L0/TARGET_STM32L0x2xZ/device/TOOLCHAIN_IAR/stm32l082xZ.icf") |
Wayne Roberts |
0:2e040cc7f7b8 | 115 | execute("sed -i 's/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10)/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x16)/' \ |
Wayne Roberts |
0:2e040cc7f7b8 | 116 | mbed-os/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rcc.h") |
Wayne Roberts |
0:2e040cc7f7b8 | 117 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 118 | |
Wayne Roberts |
0:2e040cc7f7b8 | 119 | if ("${target}" == "MTB_MTS_XDOT") { |
Wayne Roberts |
0:2e040cc7f7b8 | 120 | execute("sed -i 's/define symbol __size_heap__ = 0x800;/define symbol __size_heap__ = 0x1800;/' \ |
Wayne Roberts |
0:2e040cc7f7b8 | 121 | mbed-os/targets/TARGET_STM/TARGET_STM32L1/TARGET_MTB_MTS_XDOT/device/TOOLCHAIN_IAR/stm32l152xc.icf") |
Wayne Roberts |
0:2e040cc7f7b8 | 122 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 123 | |
Wayne Roberts |
0:2e040cc7f7b8 | 124 | if ("${target}" == "MTB_RAK811") { |
Wayne Roberts |
0:2e040cc7f7b8 | 125 | execute("sed -i 's/#define RCC_HSICALIBRATION_DEFAULT (0x10U)/#define RCC_HSICALIBRATION_DEFAULT (0x11U)/' \ |
Wayne Roberts |
0:2e040cc7f7b8 | 126 | mbed-os/targets/TARGET_STM/TARGET_STM32L1/device/stm32l1xx_hal_rcc.h") |
Wayne Roberts |
0:2e040cc7f7b8 | 127 | execute("sed -i 's/define symbol __size_heap__ = 0x800;/define symbol __size_heap__ = 0x1800;/' \ |
Wayne Roberts |
0:2e040cc7f7b8 | 128 | mbed-os/targets/TARGET_STM/TARGET_STM32L1/TARGET_MTB_RAK811/device/TOOLCHAIN_IAR/stm32l152xba.icf") |
Wayne Roberts |
0:2e040cc7f7b8 | 129 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 130 | |
Wayne Roberts |
0:2e040cc7f7b8 | 131 | execute("mbed compile --build out/${target}_${toolchain}/ -m ${target} -t ${toolchain} -c") |
Wayne Roberts |
0:2e040cc7f7b8 | 132 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 133 | stash name: "${target}_${toolchain}", includes: '**/mbed-os-example-lorawan.bin' |
Wayne Roberts |
0:2e040cc7f7b8 | 134 | archive '**/mbed-os-example-lorawan.bin' |
Wayne Roberts |
0:2e040cc7f7b8 | 135 | step([$class: 'WsCleanup']) |
Wayne Roberts |
0:2e040cc7f7b8 | 136 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 137 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 138 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 139 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 140 | |
Wayne Roberts |
0:2e040cc7f7b8 | 141 | def build_regions(regions) { |
Wayne Roberts |
0:2e040cc7f7b8 | 142 | return { |
Wayne Roberts |
0:2e040cc7f7b8 | 143 | stage ("region_builder_K64F_GCC_ARM") { |
Wayne Roberts |
0:2e040cc7f7b8 | 144 | node ("arm-none-eabi-gcc") { |
Wayne Roberts |
0:2e040cc7f7b8 | 145 | deleteDir() |
Wayne Roberts |
0:2e040cc7f7b8 | 146 | dir("mbed-os-example-lorawan") { |
Wayne Roberts |
0:2e040cc7f7b8 | 147 | checkout scm |
Wayne Roberts |
0:2e040cc7f7b8 | 148 | execute("mbed deploy --protocol ssh") |
Wayne Roberts |
0:2e040cc7f7b8 | 149 | |
Wayne Roberts |
0:2e040cc7f7b8 | 150 | if (env.MBED_OS_REVISION != '') { |
Wayne Roberts |
0:2e040cc7f7b8 | 151 | dir("mbed-os") { |
Wayne Roberts |
0:2e040cc7f7b8 | 152 | if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) { |
Wayne Roberts |
0:2e040cc7f7b8 | 153 | execute("git fetch origin ${env.MBED_OS_REVISION}:_PR_") |
Wayne Roberts |
0:2e040cc7f7b8 | 154 | execute("git checkout _PR_") |
Wayne Roberts |
0:2e040cc7f7b8 | 155 | } else { |
Wayne Roberts |
0:2e040cc7f7b8 | 156 | execute("git checkout ${env.MBED_OS_REVISION}") |
Wayne Roberts |
0:2e040cc7f7b8 | 157 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 158 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 159 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 160 | //Initial sed to string format for find & replacing |
Wayne Roberts |
0:2e040cc7f7b8 | 161 | execute("sed -i 's/\"lora.phy\": 0,/\"lora.phy\": \"0\",/' mbed_app.json") |
Wayne Roberts |
0:2e040cc7f7b8 | 162 | //lora.phy 0 build tested above already |
Wayne Roberts |
0:2e040cc7f7b8 | 163 | for (int i = 1; i < regions.size(); i++) { |
Wayne Roberts |
0:2e040cc7f7b8 | 164 | def curr_region = regions.get(i) |
Wayne Roberts |
0:2e040cc7f7b8 | 165 | def prev_region = regions.get(i-1) |
Wayne Roberts |
0:2e040cc7f7b8 | 166 | execute("sed -i 's/\"lora.phy\": ${prev_region},/\"lora.phy\": ${curr_region},/' mbed_app.json") |
Wayne Roberts |
0:2e040cc7f7b8 | 167 | echo "Building region: ${curr_region}" |
Wayne Roberts |
0:2e040cc7f7b8 | 168 | execute("mbed compile -t GCC_ARM -m K64F") |
Wayne Roberts |
0:2e040cc7f7b8 | 169 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 170 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 171 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 172 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 173 | } |
Wayne Roberts |
0:2e040cc7f7b8 | 174 | } |