forked from pycom/pycom-micropython-sigfox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
157 lines (142 loc) · 5.26 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
def buildVersion
def boards_to_build_1 = ["LOPY_868", "WIPY"]
def boards_to_build_2 = ["LOPY_915", "SIPY"]
def boards_to_test = ["LOPY_868", "WIPY"]
node {
stage('Checkout') { // get source
checkout scm
sh 'rm -rf esp-idf'
sh 'git clone --depth=1 --recursive -b master https://github.com/pycom/pycom-esp-idf.git esp-idf'
}
// build the primary boards that we test
stage('Build1') {
// build the cross compiler first
sh '''cd mpy-cross;
make all'''
def parallelSteps = [:]
for (x in boards_to_build_1) {
def name = x
def name_short = "LOPY"
def lora_band = ""
if (name == "LOPY_868") {
lora_band = " LORA_BAND=USE_BAND_868"
} else if (name == "LOPY_915") {
lora_band = " LORA_BAND=USE_BAND_915"
} else {
name_short = name
}
parallelSteps[name] = boardBuild(name, name_short, lora_band)
}
parallel parallelSteps
stash includes: '**/*.bin', name: 'binary'
stash includes: 'tests/**', name: 'tests'
stash includes: 'esp-idf/components/esptool_py/**', name: 'esp-idfTools'
stash includes: 'tools/**', name: 'tools'
stash includes: 'esp32/tools/**', name: 'esp32Tools'
}
// build the secondary boards just used for the release
stage('Build2') {
def parallelSteps = [:]
for (x in boards_to_build_2) {
def name = x
def name_short = "LOPY"
def lora_band = ""
if (name == "LOPY_868") {
lora_band = " LORA_BAND=USE_BAND_868"
} else if (name == "LOPY_915") {
lora_band = " LORA_BAND=USE_BAND_915"
} else {
name_short = name
}
parallelSteps[name] = boardBuild(name, name_short, lora_band)
}
parallel parallelSteps
stash includes: '**/*.bin', name: 'binary'
stash includes: 'tests/**', name: 'tests'
stash includes: 'esp-idf/components/esptool_py/**', name: 'esp-idfTools'
stash includes: 'tools/**', name: 'tools'
stash includes: 'esp32/tools/**', name: 'esp32Tools'
}
}
stage ('Flash') {
def parallelFlash = [:]
for (x in boards_to_test) {
def name = x
parallelFlash[name] = flashBuild(name)
}
parallel parallelFlash
}
stage ('Test'){
def parallelTests = [:]
for (x in boards_to_test) {
def name = x
def board_name = name
if (name == "LOPY_868" || name == "LOPY_915") {
board_name = "LOPY"
}
parallelTests[board_name] = testBuild(board_name)
}
parallel parallelTests
}
def testBuild(name) {
return {
node(name) {
sleep(5) //Delay to skip all bootlog
dir('tests') {
timeout(30) {
sh '''./run-tests --target=esp32-''' + name +''' --device /dev/ttyUSB0'''
}
}
sh 'python esp32/tools/resetBoard.py reset'
sh 'python esp32/tools/resetBoard.py releasePins'
}
}
}
def flashBuild(name) {
def node_name = name
if (name != "WIPY") {
node_name = "LOPY"
}
return {
node(node_name) {
sh 'rm -rf *'
unstash 'binary'
unstash 'esp-idfTools'
unstash 'esp32Tools'
unstash 'tests'
unstash 'tools'
sh 'python esp32/tools/resetBoard.py bootloader'
sh 'esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 erase_flash'
sh 'python esp32/tools/resetBoard.py bootloader'
sh 'esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 esp32/build/'+ name +'/release/bootloader/bootloader.bin 0x8000 esp32/build/'+ name +'/release/lib/partitions.bin 0x10000 esp32/build/'+ name +'/release/appimg.bin'
sh 'python esp32/tools/resetBoard.py reset'
sh 'python esp32/tools/resetBoard.py releasePins'
}
}
}
def boardBuild(name, name_short, lora_band) {
def app_bin = name.toLowerCase() + '.bin'
return {
sh '''export PATH=$PATH:/opt/xtensa-esp32-elf/bin;
export IDF_PATH=${WORKSPACE}/esp-idf;
cd esp32;
make TARGET=boot -j2 BOARD=''' + name_short + lora_band
sh '''export PATH=$PATH:/opt/xtensa-esp32-elf/bin;
export IDF_PATH=${WORKSPACE}/esp-idf;
cd esp32;
make TARGET=app -j2 BOARD=''' + name_short + lora_band
sh '''cd esp32/build/'''+ name +'''/release;
rm -rf firmware_package;
mkdir -p firmware_package;
cd firmware_package;
cp ../bootloader/bootloader.bin .;
cp ../lib/partitions.bin .;
cp ../../../../boards/''' + name_short + '''/''' + name + '''/script .;
cp ../''' + app_bin + ''' .;
tar -cvzf ''' + name + '''.tar.gz bootloader.bin partitions.bin script ''' + app_bin
}
}
def version() {
def matcher = readFile('esp32/build/LOPY/release/genhdr/mpversion.h') =~ 'MICROPY_GIT_TAG (.+)'
matcher ? matcher[0][1] : null
}