-
-
Notifications
You must be signed in to change notification settings - Fork 53
Add support for BigTreeTech EBB SB 2209 USB v1.0 (rp2040). #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
WalkthroughA new board configuration for the BTT SB2209 USB V1.0 RP2040 toolboard has been introduced. This includes board definition and hardware configuration files, firmware and toolboard configuration, udev rules for device handling, and shell scripts for compiling and flashing firmware. No existing exported or public entities were modified. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant make-and-flash-mcu.sh
participant compile.sh
participant flash.sh
participant flash-path.sh
User->>make-and-flash-mcu.sh: Run as root
make-and-flash-mcu.sh->>compile.sh: Execute compile.sh
compile.sh->>compile.sh: Compile firmware and copy binary
make-and-flash-mcu.sh->>flash.sh: Execute flash.sh
flash.sh->>flash-path.sh: Call flash-path.sh with device path
sequenceDiagram
participant System
participant USB Device
participant udev
participant klipper-mcu-added.sh
USB Device->>System: Device plugged in
System->>udev: Detect device (via rules)
udev->>System: Create symlink
udev->>klipper-mcu-added.sh: Execute script
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (15)
configuration/boards/btt-sb-2209-usb-10-rp2040/make-and-flash-mcu.sh (3)
1-2: Add strict mode for safer failure handling
It’s best practice in Bash scripts to enable strict error handling to catch failures early. Consider adding at the top (immediately after the shebang) the following:#!/bin/bash +set -euo pipefail +IFS=$'\n\t'This will:
-e: exit on any command failure-u: treat unset variables as errors-o pipefail: catch failures in pipelinesIFS: avoid word-splitting pitfalls
3-6: Improve root-check and exit code
Currentlyexitwithout a code returns 0, which may mask failure in CI or wrappers. Also, error messages should go to stderr:-if [ "$EUID" -ne 0 ] - then echo "ERROR: Please run as root" - exit -fi +if [[ $EUID -ne 0 ]]; then + echo "ERROR: Please run as root" >&2 + exit 1 +fiThis ensures non-zero exit on permission issues.
8-11: Quote expansions and propagate errors
When invoking sub-scripts, wrap paths in quotes to handle whitelists or spaces, and rely onset -eto catch failures:SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -"$SCRIPT_DIR"/compile.sh -"$SCRIPT_DIR"/flash.sh + "$SCRIPT_DIR"/compile.sh + "$SCRIPT_DIR"/flash.shOptionally, if you want the wrapper to return the exit status of
flash.sh, you can useexec "$SCRIPT_DIR/flash.sh".configuration/boards/btt-sb-2209-usb-10-rp2040/98-btt-sb-2209-usb-10-rp.rules (1)
2-2: Avoid hard-coded user paths in udev rule
Using/home/pi/printer_data/...in a udev rule is brittle and non-portable. Consider installingklipper-mcu-added.shto a standard location (e.g.,/usr/local/bin/klipper-mcu-added.sh) and referencing that path here. Alternatively, document that users must adjust this path if their config directory differs.configuration/boards/btt-sb-2209-usb-10-rp2040/flash.sh (2)
1-6: Enable strict mode and fix root-check exit code
Apply the same strict flags as other scripts and ensure non-zero exit on root-check failure:#!/bin/bash +set -euo pipefail +IFS=$'\n\t' MCU=/dev/btt-sb2209-usb-10 -if [ "$EUID" -ne 0 ] - then echo "ERROR: Please run as root" - exit -fi +if [[ $EUID -ne 0 ]]; then + echo "ERROR: Please run as root" >&2 + exit 1 +fiThis also surface any missing commands (e.g.
realpath) early.
7-9: Quote paths and verify helper exists
Ensureflash-path.shis found and executable:SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -FLASH_SCRIPT=$(realpath "$SCRIPT_DIR/../../scripts/flash-path.sh") -$FLASH_SCRIPT $MCU +FLASH_SCRIPT="$(realpath "$SCRIPT_DIR"/../../scripts/flash-path.sh")" +if [[ ! -x "$FLASH_SCRIPT" ]]; then + echo "ERROR: flash-path.sh not found or not executable at $FLASH_SCRIPT" >&2 + exit 1 +fi +exec "$FLASH_SCRIPT" "$MCU"This adds robustness and proper hand-off.
configuration/boards/btt-sb-2209-usb-10-rp2040/compile.sh (3)
1-5: Add strict mode and fix root-check exit code
Apply strict flags and ensure an exit code on permission failure:#!/bin/bash +set -euo pipefail +IFS=$'\n\t' if [ "$EUID" -ne 0 ] - then echo "ERROR: Please run as root" - exit + then echo "ERROR: Please run as root" >&2 + exit 1 fi
12-16: Parameterize firmware output directory and user
Likewise, don’t hard-code/home/pi/printer_data/config/firmware_binaries—use an env var or derive from config. E.g.:-if [ ! -d "/home/pi/printer_data/config/firmware_binaries" ] +OUT_DIR="/home/pi/printer_data/config/firmware_binaries" +if [[ ! -d "$OUT_DIR" ]]; then mkdir "$OUT_DIR" - chown pi:pi /home/pi/printer_data/config/firmware_binaries + chown "$(id -u):$(id -g)" "$OUT_DIR" fiEnsures binary storage can be customized per user.
17-18: Use variables for clarity when copying UF2-cp -f /home/pi/klipper/out/klipper.uf2 /home/pi/printer_data/config/firmware_binaries/firmware-btt-sb-2209-usb-10-rp.uf2 -chown pi:pi /home/pi/printer_data/config/firmware_binaries/firmware-btt-sb-2209-usb-10-rp.uf2 +UF2_SRC="$KLIPPER_DIR/out/klipper.uf2" +UF2_DST="$OUT_DIR/firmware-btt-sb-2209-usb-10-rp.uf2" +cp -f "$UF2_SRC" "$UF2_DST" +chown "$(id -u):$(id -g)" "$UF2_DST"This reduces duplication and makes maintenance easier.
configuration/boards/btt-sb-2209-usb-10-rp2040/toolboard-config.cfg (3)
11-15: Remove duplicate/ambiguous aliases
You’ve defined bothlis2dw_cs_pin=gpio1andadxl345_cs_pin=gpio1under the same alias block. If only the LIS2DW is used, drop the ADXL345 line to avoid confusion. Also, consider using thelis2dw_cs_pinalias in the[lis2dw]section rather than rawgpiovalues.
17-19: Clarify probe vs. BLTouch pins
You’ve setbltouch_sensor_pin=gpio21and thenprobe_pin=gpio21. If your BLTouch inverts the sensor/trigger behavior, this may be intentional, but please confirm that the same GPIO isn’t conflicting. Consider adding a comment explaining reuse.
31-35: Use consistent lowercase instance names
Your[temperature_sensor Toolboard]block uses an uppercase “Toolboard,” which differs from the lowercase “toolboard” instance elsewhere. Klipper’s config is case‐sensitive; use a matching lowercase name:-[temperature_sensor Toolboard] + [temperature_sensor toolboard]configuration/boards/btt-sb-2209-usb-10-rp2040/board-definition.json (1)
39-44: Align sensor block key casing
The key"LIS2DW"is in uppercase, while other top-level keys use camelCase. To maintain consistency (and satisfy most JSON schemas), consider renaming this block to"lis2dw"or"LIS2DW_sensor".configuration/boards/btt-sb-2209-usb-10-rp2040/firmware.config (2)
57-63: Review sensor support modules
Currently you’ve enabledWANT_LIS2DW,WANT_LDC1612,WANT_HX71X, andWANT_ADS1220. The board only integrates the LIS2DW accelerometer. Unless there are external connectors for the other sensors, consider disablingLDC1612,HX71X, andADS1220to reduce firmware footprint.
67-67: Remove unused CANBUS_FREQUENCY
CONFIG_RPXXXX_CANBUSis not set, yetCONFIG_CANBUS_FREQUENCY=1000000remains. To avoid confusion, remove the CANBUS_FREQUENCY setting if CANBUS isn’t used on this board.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
configuration/boards/btt-sb-2209-usb-10-rp2040/board.pngis excluded by!**/*.pngconfiguration/boards/btt-sb-2209-usb-10-rp2040/dfubooting.pngis excluded by!**/*.pngconfiguration/boards/btt-sb-2209-usb-10-rp2040/manual.pdfis excluded by!**/*.pdf
📒 Files selected for processing (7)
configuration/boards/btt-sb-2209-usb-10-rp2040/98-btt-sb-2209-usb-10-rp.rules(1 hunks)configuration/boards/btt-sb-2209-usb-10-rp2040/board-definition.json(1 hunks)configuration/boards/btt-sb-2209-usb-10-rp2040/compile.sh(1 hunks)configuration/boards/btt-sb-2209-usb-10-rp2040/firmware.config(1 hunks)configuration/boards/btt-sb-2209-usb-10-rp2040/flash.sh(1 hunks)configuration/boards/btt-sb-2209-usb-10-rp2040/make-and-flash-mcu.sh(1 hunks)configuration/boards/btt-sb-2209-usb-10-rp2040/toolboard-config.cfg(1 hunks)
🔇 Additional comments (8)
configuration/boards/btt-sb-2209-usb-10-rp2040/board-definition.json (4)
1-2: Verify schema reference path
Ensure the"$schema": "../board-definition.schema.json"path correctly resolves to the shared schema file in the repo. If the schema is located elsewhere (e.g., atconfiguration/board-definition.schema.json), update this relative path accordingly.
6-12: Check metadata naming conventions
- Confirm that the
"id"("btt-sb-2209-usb-10-rp") and"firmwareBinaryName"("firmware-btt-sb-2209-usb-10-rp.uf2") adhere to the project’s kebab-case guidelines and do not conflict with existing IDs.- Verify that
"manufacturer"and"name"reflect the exact branding/casing preferred by BIGTREETECH.
13-22: Validate power and fan connector settings
- Ensure
"fourPinFanConnectorCount": 1matches the actual hardware (does the board provide exactly one 4-pin connector?).- Verify
"driverVoltages": [24]and the"outputPins"mapping for"part_fan_power"(GPIO14) align with the electrical design, including default"value": 0.
27-36: Verify DFU section details
- Confirm that
"flashDevice": "2e8a:0003"is the correct DFU vendor:product ID for the RP2040 bootloader.- Check that the
"instructions"accurately describe the button sequence to enter DFU mode, and that"hasBoot0Jumper": falsematches the hardware.- Ensure
dfubooting.pngis versioned in the repo and referenced in documentation.configuration/boards/btt-sb-2209-usb-10-rp2040/firmware.config (4)
13-15: Confirm CONFIG_BOARD_DIRECTORY value
CONFIG_BOARD_DIRECTORY="rp2040"selects the generic RP2040 board directory. Verify that this matches the physical directory structure and the build system’s expectation for locating the board files.
16-23: Validate USB serial and memory layout
- Check that
CONFIG_USBSERIAL=yand the chosen USB serial number (CONFIG_USB_SERIAL_NUMBER) reflect the intended endpoints.- Ensure flash (
CONFIG_FLASH_SIZE,CONFIG_FLASH_BOOT_ADDRESS,CONFIG_FLASH_APPLICATION_ADDRESS) and RAM (CONFIG_RAM_START,CONFIG_RAM_SIZE) settings match the RP2040 2 MB flash, on-chip RAM specs, and any reserved bootloader area.
26-33: Verify stage2 bootloader configuration
- Confirm that
CONFIG_RP2040_STAGE2_FILE="boot2_w25q080.S"exists in the source tree and is built correctly.- Ensure
CONFIG_RP2040_FLASH_W25Q080aligns with the actual flash chip on the board.
46-50: Cross-check USB vendor/device IDs
The firmware usesCONFIG_USB_VENDOR_ID=0x1d50andCONFIG_USB_DEVICE_ID=0x614e. Make sure these match the IDs specified in the board-definition JSON and in the udev rules.
| cp -f /home/pi/printer_data/config/RatOS/boards/btt-sb-2209-usb-10-rp2040/firmware.config /home/pi/klipper/.config | ||
| pushd /home/pi/klipper || exit | ||
| make olddefconfig | ||
| make clean | ||
| make | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Avoid absolute /home/pi paths—use script location
Hard-coding /home/pi/... prevents reuse. Instead derive the repo root from SCRIPT_DIR and reference relative paths:
-cp -f /home/pi/printer_data/config/RatOS/boards/btt-sb-2209-usb-10-rp2040/firmware.config /home/pi/klipper/.config
-pushd /home/pi/klipper || exit
+SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
+CONFIG_DIR="/home/pi/printer_data/config/RatOS/boards/btt-sb-2209-usb-10-rp2040"
+KLIPPER_DIR="/home/pi/klipper"
+cp -f "$CONFIG_DIR/firmware.config" "$KLIPPER_DIR/.config"
+pushd "$KLIPPER_DIR" || exitOptionally, expose KLIPPER_DIR and CONFIG_DIR as environment variables for flexibility.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| cp -f /home/pi/printer_data/config/RatOS/boards/btt-sb-2209-usb-10-rp2040/firmware.config /home/pi/klipper/.config | |
| pushd /home/pi/klipper || exit | |
| make olddefconfig | |
| make clean | |
| make | |
| SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) | |
| CONFIG_DIR="/home/pi/printer_data/config/RatOS/boards/btt-sb-2209-usb-10-rp2040" | |
| KLIPPER_DIR="/home/pi/klipper" | |
| cp -f "$CONFIG_DIR/firmware.config" "$KLIPPER_DIR/.config" | |
| pushd "$KLIPPER_DIR" || exit | |
| make olddefconfig | |
| make clean | |
| make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@miklschmidt I thought removing the reliance on /home/pi was planned for another major refactoring, I'm just going off status-quo "templates". Should I make this edit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
…r in Wizard "Confirm Configuration":
Error
[
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"adxl345_cs_pin"
],
"message": "Required"
}
]
Tried to follow formatting guidelines as best as possible; I'm commissioning a build using this gear but everything seems to be there so far.
Please let me know if there are any issues with the naming conventions or any other assumptions I may have made.
Summary by CodeRabbit
New Features
Chores