NuMaker mbed OS v6.x LoRaWAN

Committer:
cyliang
Date:
Wed Mar 22 09:57:06 2023 +0000
Revision:
1:85d22b103ba9
Parent:
0:a160d512fe55
Update OS to v6.17.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cyliang 0:a160d512fe55 1 properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
cyliang 0:a160d512fe55 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"'],
cyliang 0:a160d512fe55 3 [$class: 'BooleanParameterDefinition', name: 'regions_build_test', defaultValue: true, description: 'Test build all available regions']
cyliang 0:a160d512fe55 4 ]]])
cyliang 0:a160d512fe55 5
cyliang 0:a160d512fe55 6 library 'mbed-lib'
cyliang 0:a160d512fe55 7
cyliang 0:a160d512fe55 8 if (env.MBED_OS_REVISION == null) {
cyliang 0:a160d512fe55 9 echo 'First run in this branch, using default parameter values'
cyliang 0:a160d512fe55 10 env.MBED_OS_REVISION = ''
cyliang 0:a160d512fe55 11 }
cyliang 0:a160d512fe55 12 if (env.MBED_OS_REVISION == '') {
cyliang 0:a160d512fe55 13 echo 'Using mbed OS revision from mbed-os.lib'
cyliang 0:a160d512fe55 14 } else {
cyliang 0:a160d512fe55 15 echo "Using given mbed OS revision: ${env.MBED_OS_REVISION}"
cyliang 0:a160d512fe55 16 if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) {
cyliang 0:a160d512fe55 17 echo "Revision is a Pull Request"
cyliang 0:a160d512fe55 18 }
cyliang 0:a160d512fe55 19 }
cyliang 0:a160d512fe55 20
cyliang 0:a160d512fe55 21 // All available regions
cyliang 0:a160d512fe55 22 def regions = [
cyliang 0:a160d512fe55 23 "\"0\"", "\"1\"", "\"2\"", "\"3\"", "\"4\"", "\"5\"", "\"6\"", "\"7\"", "\"8\"",
cyliang 0:a160d512fe55 24 "\"EU868\"", "\"AS923\"", "\"AU915\"", "\"CN470\"", "\"CN779\"", "\"EU433\"",
cyliang 0:a160d512fe55 25 "\"IN865\"", "\"KR920\"", "\"US915\""
cyliang 0:a160d512fe55 26 ]
cyliang 0:a160d512fe55 27
cyliang 0:a160d512fe55 28 // Supported targets
cyliang 0:a160d512fe55 29 def targets = [
cyliang 0:a160d512fe55 30 "K64F",
cyliang 0:a160d512fe55 31 "MTS_MDOT_F411RE",
cyliang 0:a160d512fe55 32 "DISCO_L072CZ_LRWAN1"
cyliang 0:a160d512fe55 33 ]
cyliang 0:a160d512fe55 34
cyliang 0:a160d512fe55 35 // Supported toolchains
cyliang 0:a160d512fe55 36 def toolchains = [
cyliang 0:a160d512fe55 37 "ARM",
cyliang 0:a160d512fe55 38 "GCC_ARM"
cyliang 0:a160d512fe55 39 ]
cyliang 0:a160d512fe55 40
cyliang 0:a160d512fe55 41 def stepsForParallel = [:]
cyliang 0:a160d512fe55 42
cyliang 0:a160d512fe55 43 // Jenkins pipeline does not support map.each, we need to use oldschool for loop
cyliang 0:a160d512fe55 44 for (int i = 0; i < targets.size(); i++) {
cyliang 0:a160d512fe55 45 for(int j = 0; j < toolchains.size(); j++) {
cyliang 0:a160d512fe55 46 def target = targets.get(i)
cyliang 0:a160d512fe55 47 def toolchain = toolchains.get(j)
cyliang 0:a160d512fe55 48
cyliang 0:a160d512fe55 49 // Skip unwanted combination
cyliang 0:a160d512fe55 50 if (target == "DISCO_L072CZ_LRWAN1" && toolchain == "GCC_ARM") {
cyliang 0:a160d512fe55 51 continue
cyliang 0:a160d512fe55 52 }
cyliang 0:a160d512fe55 53
cyliang 0:a160d512fe55 54 def stepName = "${target} ${toolchain}"
cyliang 0:a160d512fe55 55
cyliang 0:a160d512fe55 56 stepsForParallel[stepName] = buildStep(target, toolchain)
cyliang 0:a160d512fe55 57 }
cyliang 0:a160d512fe55 58 }
cyliang 0:a160d512fe55 59
cyliang 0:a160d512fe55 60 def stepsForRegional = [:]
cyliang 0:a160d512fe55 61
cyliang 0:a160d512fe55 62 if (params.regions_build_test == true) {
cyliang 0:a160d512fe55 63 stepsForRegional["REGION BUILDER"] = build_regions(regions)
cyliang 0:a160d512fe55 64 }
cyliang 0:a160d512fe55 65
cyliang 0:a160d512fe55 66 timestamps {
cyliang 0:a160d512fe55 67 parallel stepsForParallel
cyliang 0:a160d512fe55 68 parallel stepsForRegional
cyliang 0:a160d512fe55 69 }
cyliang 0:a160d512fe55 70
cyliang 0:a160d512fe55 71 def buildStep(target, toolchain) {
cyliang 0:a160d512fe55 72 return {
cyliang 0:a160d512fe55 73 stage ("${target}_${toolchain}") {
cyliang 0:a160d512fe55 74 node ("all-in-one-build-slave") {
cyliang 0:a160d512fe55 75 deleteDir()
cyliang 0:a160d512fe55 76 dir("mbed-os-example-lorawan") {
cyliang 0:a160d512fe55 77 checkout scm
cyliang 0:a160d512fe55 78
cyliang 0:a160d512fe55 79 // A workaround for mbed-cli caching issues
cyliang 0:a160d512fe55 80 try {
cyliang 0:a160d512fe55 81 execute("mbed deploy --protocol ssh")
cyliang 0:a160d512fe55 82 } catch (err) {
cyliang 0:a160d512fe55 83 echo "mbed deploy failed - retrying after 10s"
cyliang 0:a160d512fe55 84 sleep(10)
cyliang 0:a160d512fe55 85 execute("mbed deploy --protocol ssh")
cyliang 0:a160d512fe55 86 }
cyliang 0:a160d512fe55 87
cyliang 0:a160d512fe55 88 // Set mbed-os to revision received as parameter
cyliang 0:a160d512fe55 89 if (env.MBED_OS_REVISION != '') {
cyliang 0:a160d512fe55 90 dir("mbed-os") {
cyliang 0:a160d512fe55 91 if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) {
cyliang 0:a160d512fe55 92 // Use mbed-os PR and switch to branch created
cyliang 0:a160d512fe55 93 execute("git fetch origin ${env.MBED_OS_REVISION}:_PR_")
cyliang 0:a160d512fe55 94 execute("git checkout _PR_")
cyliang 0:a160d512fe55 95 } else {
cyliang 0:a160d512fe55 96 execute("git checkout ${env.MBED_OS_REVISION}")
cyliang 0:a160d512fe55 97 }
cyliang 0:a160d512fe55 98 }
cyliang 0:a160d512fe55 99 }
cyliang 0:a160d512fe55 100
cyliang 0:a160d512fe55 101 // Adjust stack size and crystal values
cyliang 0:a160d512fe55 102 if ("${target}" == "DISCO_L072CZ_LRWAN1") {
cyliang 0:a160d512fe55 103 execute("sed -i 's/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10)/#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x13)/' \
cyliang 0:a160d512fe55 104 mbed-os/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_rcc.h")
cyliang 0:a160d512fe55 105 }
cyliang 0:a160d512fe55 106
cyliang 0:a160d512fe55 107 execute("mbed compile --build out/${target}_${toolchain}/ -m ${target} -t ${toolchain} -c")
cyliang 0:a160d512fe55 108 }
cyliang 0:a160d512fe55 109 stash name: "${target}_${toolchain}", includes: '**/mbed-os-example-lorawan.bin'
cyliang 0:a160d512fe55 110 archive '**/mbed-os-example-lorawan.bin'
cyliang 0:a160d512fe55 111 step([$class: 'WsCleanup'])
cyliang 0:a160d512fe55 112 }
cyliang 0:a160d512fe55 113 }
cyliang 0:a160d512fe55 114 }
cyliang 0:a160d512fe55 115 }
cyliang 0:a160d512fe55 116
cyliang 0:a160d512fe55 117 def build_regions(regions) {
cyliang 0:a160d512fe55 118 return {
cyliang 0:a160d512fe55 119 stage ("region_builder_K64F_GCC_ARM") {
cyliang 0:a160d512fe55 120 node ("all-in-one-build-slave") {
cyliang 0:a160d512fe55 121 deleteDir()
cyliang 0:a160d512fe55 122 dir("mbed-os-example-lorawan") {
cyliang 0:a160d512fe55 123 checkout scm
cyliang 0:a160d512fe55 124
cyliang 0:a160d512fe55 125 // A workaround for mbed-cli caching issues
cyliang 0:a160d512fe55 126 try {
cyliang 0:a160d512fe55 127 execute("mbed deploy --protocol ssh")
cyliang 0:a160d512fe55 128 } catch (err) {
cyliang 0:a160d512fe55 129 echo "mbed deploy failed - retrying after 10s"
cyliang 0:a160d512fe55 130 sleep(10)
cyliang 0:a160d512fe55 131 execute("mbed deploy --protocol ssh")
cyliang 0:a160d512fe55 132 }
cyliang 0:a160d512fe55 133
cyliang 0:a160d512fe55 134 if (env.MBED_OS_REVISION != '') {
cyliang 0:a160d512fe55 135 dir("mbed-os") {
cyliang 0:a160d512fe55 136 if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) {
cyliang 0:a160d512fe55 137 execute("git fetch origin ${env.MBED_OS_REVISION}:_PR_")
cyliang 0:a160d512fe55 138 execute("git checkout _PR_")
cyliang 0:a160d512fe55 139 } else {
cyliang 0:a160d512fe55 140 execute("git checkout ${env.MBED_OS_REVISION}")
cyliang 0:a160d512fe55 141 }
cyliang 0:a160d512fe55 142 }
cyliang 0:a160d512fe55 143 }
cyliang 0:a160d512fe55 144 //Initial sed to string format for find & replacing
cyliang 0:a160d512fe55 145 execute("sed -i 's/\"lora.phy\": 0,/\"lora.phy\": \"0\",/' mbed_app.json")
cyliang 0:a160d512fe55 146 //lora.phy 0 build tested above already
cyliang 0:a160d512fe55 147 for (int i = 1; i < regions.size(); i++) {
cyliang 0:a160d512fe55 148 def curr_region = regions.get(i)
cyliang 0:a160d512fe55 149 def prev_region = regions.get(i-1)
cyliang 0:a160d512fe55 150 execute("sed -i 's/\"lora.phy\": ${prev_region},/\"lora.phy\": ${curr_region},/' mbed_app.json")
cyliang 0:a160d512fe55 151 echo "Building region: ${curr_region}"
cyliang 0:a160d512fe55 152 execute("mbed compile -t GCC_ARM -m K64F")
cyliang 0:a160d512fe55 153 }
cyliang 0:a160d512fe55 154 }
cyliang 0:a160d512fe55 155 }
cyliang 0:a160d512fe55 156 }
cyliang 0:a160d512fe55 157 }
cyliang 0:a160d512fe55 158 }