@@ -19,9 +19,10 @@ function download_qwiic_release {
19
19
# Builds all SparkFun boards for the given port
20
20
# Options:
21
21
# $1: Port name
22
+ # $2: [Optional] Prefix for the SparkFun board directories for port(default: "-SPARKFUN_")
22
23
function build_for_port {
23
24
local TARGET_PORT_NAME=$1
24
- local SPARKFUN_PREFIX=" SPARKFUN_"
25
+ local SPARKFUN_PREFIX=${2 :- SPARKFUN_}
25
26
local SPARKFUN_BOARD_PREFIX=" ports/${TARGET_PORT_NAME} /boards/${SPARKFUN_PREFIX} *"
26
27
27
28
for board in $SPARKFUN_BOARD_PREFIX ; do
@@ -56,6 +57,17 @@ function build_all_sparkfun_boards_esp32 {
56
57
build_for_port " esp32"
57
58
}
58
59
60
+ # Builds all Teensy mimxrt boards
61
+ # Options:
62
+ # $1: Whether to build the cross compiler
63
+ function build_all_sparkfun_boards_mimxrt {
64
+ if $1 ; then
65
+ make ${MAKEOPTS} -C mpy-cross
66
+ fi
67
+
68
+ build_for_port " mimxrt" " TEENSY"
69
+ }
70
+
59
71
# Copies all files with the given prefix from the SparkFun build directories to the output directory
60
72
# Options:
61
73
# $1: Output directory
@@ -64,19 +76,33 @@ function build_all_sparkfun_boards_esp32 {
64
76
# $4: File basename
65
77
# $5: Extension
66
78
# $6: Prefix to put on output files
79
+ # $7: [Optional] Convert file to hex (default: false)
67
80
function copy_all_for_prefix {
68
81
local OUT_DIRECTORY=$1
69
82
local PORT_DIRECTORY=$2 # The directory where the ports are located (e.g. ports/rp2)
70
83
local BUILD_PREFIX=$3 # The prefix of the SparkFun build directories (e.g. build-SPARKFUN_)
71
84
local FILE_BASENAME=$4 # the target base name of the file to copy from each SparkFun build directory (e.g. firmware)
72
85
local EXTENSION=$5 # The extension of the file to copy (e.g. uf2)
73
86
local OUTPUT_PREFIX=$6 # The prefix to put on the output files (e.g. MICROPYTHON_ or MINIMAL_MICROPYTHON_)
87
+ local CONVERT_TO_HEX=${7:- false} # Whether to convert the file to hex (default: false)
88
+
74
89
75
90
mkdir -p ${OUT_DIRECTORY}
76
91
77
92
for file in $( find ${PORT_DIRECTORY} -wholename " *${BUILD_PREFIX} */*${FILE_BASENAME} .${EXTENSION} " ) ; do
78
93
echo " Moving $file to ${OUT_DIRECTORY} "
79
- mv $file ${OUT_DIRECTORY} /${OUTPUT_PREFIX} $( echo $file | sed -n " s/.*${BUILD_PREFIX} \([^/]*\)\/${FILE_BASENAME} .${EXTENSION} /\1/p" ) .${EXTENSION}
94
+ # First, add the check to see if we need to convert the file to hex
95
+ if $CONVERT_TO_HEX ; then
96
+ echo " Converting $file to hex"
97
+ # Convert the file to hex using hex using the command objcopy -O ihex <file> <output_file>
98
+ # We need to get the output file name from the input file name
99
+ OUTPUT_FILE=${OUT_DIRECTORY} /${OUTPUT_PREFIX} $( echo $file | sed -n " s/.*${BUILD_PREFIX} \([^/]*\)\/${FILE_BASENAME} .${EXTENSION} /\1/p" ) .hex
100
+ # Use objcopy to convert the file to hex and move it to the output directory (maybe unnecessary if the .hex file is already available from the build)
101
+ objcopy -O ihex $file $OUTPUT_FILE
102
+ else
103
+ # Just move the file without converting it
104
+ mv $file ${OUT_DIRECTORY} /${OUTPUT_PREFIX} $( echo $file | sed -n " s/.*${BUILD_PREFIX} \([^/]*\)\/${FILE_BASENAME} .${EXTENSION} /\1/p" ) .${EXTENSION}
105
+ fi
80
106
done
81
107
}
82
108
@@ -117,19 +143,32 @@ function copy_all_for_prefix_esp32 {
117
143
# $1: Qwiic directory
118
144
# $2: BOARD directory
119
145
# $3: Board prefix
146
+ # $4: The file to add the frozen manifest line to (e.g. mpconfigboard.cmake or mpconfigboard.mk.) Default: mpconfigboard.cmake
120
147
function add_qwiic_manifest {
121
148
local QWIIC_DIRECTORY=$1 # The directory where the Qwiic drivers are located to be frozen
122
149
local BOARD_DIRECTORY=$2 # The directory where the boards are located (e.g. ports/rp2/boards)
123
150
local BOARD_PREFIX=$3 # The prefix of the SparkFun board directories (e.g. SPARKFUN_)
151
+ local MPCONFIG_FILE=" ${4:- mpconfigboard.cmake} " # The file to add the frozen manifest line to (e.g. mpconfigboard.cmake or mpconfigboard.mk. )
124
152
125
153
for board in $( find ${BOARD_DIRECTORY} -type d -name " ${BOARD_PREFIX} *" ) ; do
154
+ echo " Adding Qwiic drivers to manifest.py for $board "
126
155
if [ ! -f ${board} /manifest.py ]; then
127
156
echo " Creating manifest.py for $board "
128
157
echo " include(\"\$ (PORT_DIR)/boards/manifest.py\" )" > ${board} /manifest.py
129
158
130
159
# also add the necessary frozen manifest line to mpconfigboard.cmake: set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
131
- echo " Adding frozen manifest line to mpconfigboard.cmake for $board "
132
- printf " \nset(MICROPY_FROZEN_MANIFEST \"\$ {MICROPY_BOARD_DIR}/manifest.py\" )" >> ${board} /mpconfigboard.cmake
160
+ # We will use the optional MPCONFIG_FILE argument to determine if we should add this line
161
+
162
+ if [ -n " $MPCONFIG_FILE " ]; then
163
+ if [[ $MPCONFIG_FILE == * .mk ]]; then
164
+ # For TEENSY which use mpconfigboard.mk instead of mpconfigboard.cmake
165
+ echo " Adding frozen manifest line to mpconfigboard.mk for $board "
166
+ printf " \nFROZEN_MANIFEST ?= \$ (BOARD_DIR)/manifest.py" >> ${board} /mpconfigboard.mk
167
+ elif [[ $MPCONFIG_FILE == * .cmake ]]; then
168
+ echo " Adding frozen manifest line to mpconfigboard.cmake for $board "
169
+ printf " \nset(MICROPY_FROZEN_MANIFEST \"\$ {MICROPY_BOARD_DIR}/manifest.py\" )" >> ${board} /mpconfigboard.cmake
170
+ fi
171
+ fi
133
172
fi
134
173
135
174
echo " Adding freeze line to manifest.py for $board "
@@ -174,12 +213,18 @@ function build_sparkfun {
174
213
# Perform minimal build for RP2
175
214
build_all_sparkfun_boards_rp2 false
176
215
216
+ # Perform minimal build for mimxrt
217
+ build_all_sparkfun_boards_mimxrt false
218
+
177
219
# Copy all esp32 binary files to the output directory
178
220
copy_all_for_prefix_esp32 ${OUTPUT_DIRECTORY} " ports/esp32" " build-SPARKFUN_" " MINIMAL_${OUTPUT_FILE_PREFIX} "
179
221
180
222
# Copy all rp2 binary files to the output directory
181
223
copy_all_for_prefix ${OUTPUT_DIRECTORY} " ports/rp2" " build-SPARKFUN_" " firmware" " uf2" " MINIMAL_${OUTPUT_FILE_PREFIX} "
182
224
225
+ # Copy all mimxrt teensy binary files to the output directory
226
+ copy_all_for_prefix ${OUTPUT_DIRECTORY} " ports/mimxrt" " build-TEENSY" " firmware" " elf" " MINIMAL_${OUTPUT_FILE_PREFIX} TEENSY_" true
227
+
183
228
echo " Downloading Qwiic library and adding to manifest.py for SparkFun boards"
184
229
# Perform Qwiic download
185
230
download_qwiic_release ${QWIIC_DIRECTORY}
@@ -190,18 +235,29 @@ function build_sparkfun {
190
235
191
236
# Add the downloaded Qwiic drivers to the manifest.py for each rp2 board
192
237
add_qwiic_manifest " ../../../../${QWIIC_DIRECTORY} " " ports/rp2/boards" " SPARKFUN_"
238
+
239
+ # Add the downloaded Qwiic drivers to the manifest.py for each mimxrt teensy board (this might not work because they might lose their 40 vs. 41 when added)
240
+ add_qwiic_manifest " ../../../../${QWIIC_DIRECTORY} " " ports/mimxrt/boards" " TEENSY40" " mpconfigboard.mk"
241
+ add_qwiic_manifest " ../../../../${QWIIC_DIRECTORY} " " ports/mimxrt/boards" " TEENSY41" " " # We don't need to add the frozen manifest line to mpconfigboard.mk for TEENSY41, it is already there
193
242
194
- echo " Performing full SparkFun build for ESP32 and RP2 "
243
+ echo " Performing full SparkFun build for ESP32, RP2, and mimxrt "
195
244
196
245
# Perform Qwiic Build for ESP32
197
246
build_all_sparkfun_boards_esp32 false
198
247
199
248
# Perform Qwiic Build for RP2
200
249
build_all_sparkfun_boards_rp2 false
201
250
251
+ # Perform Qwiic build for mimxrt
252
+ build_all_sparkfun_boards_mimxrt false
253
+
202
254
# Copy all esp32 binary files to the output directory
203
255
copy_all_for_prefix_esp32 ${OUTPUT_DIRECTORY} " ports/esp32" " build-SPARKFUN_" ${OUTPUT_FILE_PREFIX}
204
256
205
257
# Copy all rp2 binary files to the output directory
206
258
copy_all_for_prefix ${OUTPUT_DIRECTORY} " ports/rp2" " build-SPARKFUN_" " firmware" " uf2" ${OUTPUT_FILE_PREFIX}
259
+
260
+ # Copy all mimxrt teensy binary files to the output directory
261
+ copy_all_for_prefix ${OUTPUT_DIRECTORY} " ports/mimxrt" " build-TEENSY" " firmware" " elf" " ${OUTPUT_FILE_PREFIX} TEENSY_" true
207
262
}
263
+
0 commit comments