WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 27bab25

Browse files
committed
Add Red Vision changes
1 parent 157b706 commit 27bab25

File tree

9 files changed

+108
-0
lines changed

9 files changed

+108
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,6 @@
7474
[submodule "lib/alif-security-toolkit"]
7575
path = lib/alif-security-toolkit
7676
url = https://github.com/micropython/alif-security-toolkit.git
77+
[submodule "lib/red_vision"]
78+
path = lib/red_vision
79+
url = https://github.com/sparkfun/red_vision.git

lib/red_vision

Submodule red_vision added at 2823b91

ports/rp2/boards/SPARKFUN_IOTREDBOARD_RP2350/mpconfigboard.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// Board and hardware specific configuration
2+
#ifndef MICROPY_HW_BOARD_NAME
23
#define MICROPY_HW_BOARD_NAME "SparkFun IoT RedBoard RP2350"
4+
#endif
5+
6+
#ifndef MICROPY_HW_FLASH_STORAGE_BYTES
37
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1536 * 1024)
8+
#endif
9+
410

511
// Enable networking.
612
#define MICROPY_PY_NETWORK 1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
list(APPEND MICROPY_DEF_BOARD
2+
# Board name
3+
"MICROPY_HW_BOARD_NAME=\"SparkFun IoT RedBoard RP2350 (Red Vision)\""
4+
# 8MB (8 * 1024 * 1024)
5+
"MICROPY_HW_FLASH_STORAGE_BYTES=8388608"
6+
# Pin definitions
7+
)

ports/rp2/boards/SPARKFUN_IOTREDBOARD_RP2350/pins.csv

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,15 @@ A2,GPIO42
6868
A3,GPIO43
6969
A4,GPIO44
7070
A5,GPIO45
71+
72+
# Red Vision pins
73+
CAMERA_D0,GPIO28
74+
CAMERA_VSYNC,GPIO42
75+
CAMERA_HSYNC,GPIO41
76+
CAMERA_PCLK,GPIO40
77+
CAMERA_XCLK,GPIO44
78+
DISPLAY_CLK,GPIO22
79+
DISPLAY_TX,GPIO23
80+
DISPLAY_DC,GPIO20
81+
DISPLAY_CS,GPIO21
82+
SD_CS,GPIO9

ports/rp2/boards/SPARKFUN_XRP_CONTROLLER/mpconfigboard.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// Board and hardware specific configuration
2+
#ifndef MICROPY_HW_BOARD_NAME
23
#define MICROPY_HW_BOARD_NAME "SparkFun XRP Controller"
4+
#endif
5+
6+
#ifndef MICROPY_HW_FLASH_STORAGE_BYTES
37
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1536 * 1024)
8+
#endif
49

510
// Enable networking.
611
#define MICROPY_PY_NETWORK 1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
list(APPEND MICROPY_DEF_BOARD
2+
# Board name
3+
"MICROPY_HW_BOARD_NAME=\"SparkFun XRP Controller (Red Vision)\""
4+
# 8MB (8 * 1024 * 1024)
5+
"MICROPY_HW_FLASH_STORAGE_BYTES=8388608"
6+
)

ports/rp2/boards/SPARKFUN_XRP_CONTROLLER/pins.csv

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,15 @@ NEOPIXEL,GPIO37
8282
WL_GPIO0,EXT_GPIO0
8383
WL_GPIO1,EXT_GPIO1
8484
WL_GPIO2,EXT_GPIO2
85+
86+
# Red Vision pins
87+
CAMERA_D0,GPIO12
88+
CAMERA_VSYNC,GPIO13
89+
CAMERA_HSYNC,GPIO14
90+
CAMERA_PCLK,GPIO15
91+
CAMERA_XCLK,GPIO3
92+
DISPLAY_CLK,GPIO18
93+
DISPLAY_TX,GPIO19
94+
DISPLAY_DC,GPIO16
95+
DISPLAY_CS,GPIO17
96+
SD_CS,GPIO7

sparkfun_build.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ function add_frozen_data_to_boot_for_port {
8484
cat ports/${TARGET_PORT_NAME}/modules/_boot.py
8585
}
8686

87+
# Deletes all SparkFun build directories for the given port
88+
# Options:
89+
# $1: Port name
90+
function delete_build_directories_for_port {
91+
local TARGET_PORT_NAME=$1
92+
echo "TARGET_PORT_NAME: ${TARGET_PORT_NAME}"
93+
94+
local SPARKFUN_BOARD_PREFIX="ports/${TARGET_PORT_NAME}/build-*"
95+
96+
for build_dir in $SPARKFUN_BOARD_PREFIX; do
97+
echo "Deleting build directory: ${build_dir}"
98+
rm -rf ${build_dir}
99+
done
100+
}
101+
87102
# Builds all SparkFun boards for the given port
88103
# Options:
89104
# -n: Port name
@@ -281,6 +296,36 @@ function add_qwiic_manifest {
281296
done
282297
}
283298

299+
# Builds Red Vision firmware for RP2 boards
300+
function build_micropython_red_vision_rp2 {
301+
# Set Pico SDK path to $GITHUB_WORKSPACE/micropython/lib/pico-sdk if $GITHUB_WORKSPACE is set, otherwise use the current directory
302+
# https://stackoverflow.com/a/246128/4783963
303+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
304+
if [ -n "$GITHUB_WORKSPACE" ]; then
305+
export PICO_SDK_PATH="$GITHUB_WORKSPACE/lib/pico-sdk"
306+
else
307+
export PICO_SDK_PATH="$SCRIPT_DIR/lib/pico-sdk"
308+
fi
309+
310+
# Clone the Red Vision submodule
311+
# git submodule update --init --recursive lib/red_vision
312+
313+
# Build OpenCV
314+
make -C lib/red_vision/micropython-opencv PLATFORM=rp2350 --no-print-directory ${MAKEOPTS}
315+
316+
# Archive the examples directory
317+
python3 -m freezefs lib/red_vision/red_vision_examples lib/red_vision/extract_red_vision_examples.py --on-import=extract --compress --overwrite always
318+
319+
# Set CMake arguments for Pico SDK to use MicroPython-OpenCV malloc wrappers
320+
# and enable C++ exceptions
321+
export CMAKE_ARGS="-DSKIP_PICO_MALLOC=1 -DPICO_CXX_ENABLE_EXCEPTIONS=1"
322+
323+
build_all_sparkfun_boards_rp2 -f "$SCRIPT_DIR/lib/red_vision/manifest.py" -v "RED_VISION" -m "$SCRIPT_DIR/lib/red_vision/micropython-opencv/micropython_opencv.cmake"
324+
325+
# Unset CMake arguments to avoid affecting other builds
326+
unset CMAKE_ARGS
327+
}
328+
284329
# Assumes that MAKEOPTS environment variable is set
285330
# This is designed to be the user-facing function that will build all SparkFun boards
286331
# Options:
@@ -374,5 +419,16 @@ function build_sparkfun {
374419

375420
# Copy all mimxrt teensy binary files to the output directory
376421
copy_all_for_prefix ${OUTPUT_DIRECTORY} "ports/mimxrt" "build-TEENSY" "firmware" "elf" "${OUTPUT_FILE_PREFIX}TEENSY_" true
422+
423+
Remove all builds to prepare for Red Vision build
424+
delete_build_directories_for_port esp32
425+
delete_build_directories_for_port rp2
426+
delete_build_directories_for_port mimxrt
427+
428+
# Build Red Vision
429+
build_micropython_red_vision_rp2
430+
431+
# Copy all rp2 binary files to the output directory
432+
copy_all_for_prefix ${OUTPUT_DIRECTORY} "ports/rp2" "build-SPARKFUN_" "firmware" "uf2" "RED_VISION_${OUTPUT_FILE_PREFIX}"
377433
}
378434

0 commit comments

Comments
 (0)