Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2025-10-28
- Added `.config` for STM32G0B1 (USB PA11/PA12, 8MHz, 8KiB bootloader).
- Created `klipper/config/manta_m4p_v2_enderv3.cfg` example printer config.
- Authored `klipper/README.txt` deployment guide.
13 changes: 13 additions & 0 deletions Deployment_Log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Firmware Deployment Log

2025-10-28
- Target: STM32G0B1 (Manta M4P v2.0)
- Build config: `.config` (USB PA11/PA12, 8MHz crystal, 8KiB offset)
- Build artifact: out/klipper.bin
- Build version: v0.13.0-374-g99c0bfca4
- Build date: 2025-10-28
- Firmware SHA256: cafc2c9fb62c8b4454f9279a6b46337f2bcff801fc9014fec929d98da269ea3d
- Checksum file: out/klipper.bin.sha256
- Flash tool: STM32CubeProgrammer
- Flash address: 0x08002000
- Verification: Pending (post-flash version and checksum)
75 changes: 75 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Klipper Firmware — Deployment Guide (Manta M4P v2.0 / Ender 3 V3)

Overview
- Board: BTT Manta M4P v2.0
- MCU: `STM32G0B1`
- Bootloader offset: `8 KiB` (`0x08002000`)
- Clock reference: `8 MHz crystal`
- Communication: `USB on PA11/PA12`

Pinout Summary (alias-based)
- X: `MOTOR0_STEP`, `MOTOR0_DIR`, `MOTOR0_EN`, endstop `X_STOP`
- Y: `MOTOR1_STEP`, `MOTOR1_DIR`, `MOTOR1_EN`, endstop `Y_STOP`
- Z: `MOTOR2_STEP`, `MOTOR2_DIR`, `MOTOR2_EN`, endstop `Z_STOP`
- E: `MOTOR3_STEP`, `MOTOR3_DIR`, `MOTOR3_EN`
- Thermistors: `HOTEND_THERMISTOR`, `BED_THERMISTOR`
- Heaters: `HOTEND_HEATER`, `BED_HEATER`
- Fans: `PART_COOLING`, `HOTEND_FAN`
- Probe: `PROBE_SIGNAL`, `PROBE_SERVO`

Configuration Reference
- Firmware settings are captured in `klipper/.config`:
- Architecture: STM32
- Processor: STM32G0B1
- Clock Reference: 8MHz crystal
- Communication: USB (PA11/PA12)
- Bootloader offset: 0x08002000
- Printer config: `klipper/config/manta_m4p_v2_enderv3.cfg`
- Update `[mcu] serial:` with your device path from `/dev/serial/by-id/`.
- Calibrate `rotation_distance`, `run_current`, and sensor types for your hardware.

Build (WSL/Ubuntu)
1) Install dependencies:
- `sudo apt-get update && sudo apt-get install -y make gcc-arm-none-eabi python3 libncurses-dev`
2) Build:
- `cd /mnt/c/Users/poopo/Documents/trae_projects/manta/klipper`
- Ensure `.config` exists (provided).
- `make olddefconfig && make`
3) Output:
- Firmware: `out/klipper.bin`

Windows Flashing (STM32CubeProgrammer)
1) Enter DFU:
- Disconnect USB, hold `BOOT`, tap `RESET`, release `BOOT`, reconnect USB.
2) Program:
- Start address: `0x08002000`.
- File: `out/klipper.bin`.
- Click Download; then press `RESET`.
- Optional CLI: use `klipper/scripts/flash_stm32_usb_dfu.ps1` (requires STM32CubeProgrammer CLI). It connects via `port=USB`, writes at `0x08002000`, verifies, then issues reboot.
3) Alternative:
- If offset fails, rebuild Klipper with "No bootloader" and flash at `0x08000000`.

Host Integration (Pi/PC)
- Verify serial: `ls /dev/serial/by-id/` and copy the full path into `[mcu]`.
- Restart Klipper service and connect.

Testing Protocol
- Axis: Test X/Y/Z jogs and homing; verify directions and endstops.
- Temperature: Verify hotend/bed readings; PID tune as needed.
- Probe: Deploy/retract and Z-trigger; perform `G28`/`BED_MESH_CALIBRATE`.
- Safety: Test `EMERGENCY_STOP` and max-temp protections.
- Communication: Send G-code, check logs for errors.

Troubleshooting
- USB not detected: try different cable/port, ensure power, re-enter DFU.
- Driver issues: install STM32CubeProgrammer or use Zadig WinUSB for DFU.
- Wrong offset: confirm `.config` bootloader and start address alignment.
- Serial mismatch: always use `/dev/serial/by-id/...` not `/dev/tty*`.
- Verification: `out/klipper.bin.sha256` contains the SHA256 of the built firmware (generated via `certutil`). Use it to validate the binary before flashing and for post-flash integrity checks.
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 68 has inconsistent indentation - it starts with | followed by a space and dash, while other lines use just a dash. This should be - Verification: to match the formatting of lines 64-67.

Suggested change
- Verification: `out/klipper.bin.sha256` contains the SHA256 of the built firmware (generated via `certutil`). Use it to validate the binary before flashing and for post-flash integrity checks.
- Verification: `out/klipper.bin.sha256` contains the SHA256 of the built firmware (generated via `certutil`). Use it to validate the binary before flashing and for post-flash integrity checks.

Copilot uses AI. Check for mistakes.

Version Control
- Do not overwrite critical files; track changes in `CHANGELOG.txt`.
- Record builds in `Deployment_Log.txt`; log test outcomes in `Test_Results.txt`.

Reproducibility Notes
- With `.config` + `manta_m4p_v2_enderv3.cfg` + this README, another technician can rebuild and deploy identical firmware.
12 changes: 12 additions & 0 deletions Test_Results.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Test Plan — Manta M4P v2.0 / Ender 3 V3

2025-10-28 — Initial plan created
- Axis movement: Pending hardware connection
- Homing: Pending
- Temperature control: Pending
- Probe and safe_z_home: Pending
- Emergency stop: Pending
- Host communication: Pending

Notes:
- Populate with pass/fail and observations after hardware tests.
125 changes: 125 additions & 0 deletions config/manta_m4p_v2_enderv3.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# BTT Manta M4P v2.0 — Ender 3 V3 example Klipper config
# Assumptions: STM32G0B1 MCU, USB comms, 8KiB bootloader offset (0x08002000)

[mcu]
# Replace with your device ID from `/dev/serial/by-id/` on the host
serial: /dev/serial/by-id/usb-Klipper_stm32g0b1_REPLACE_ME

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 15
max_z_accel: 100
square_corner_velocity: 5.0

[stepper_x]
step_pin: MOTOR0_STEP
dir_pin: MOTOR0_DIR
enable_pin: !MOTOR0_EN
Comment on lines +17 to +19
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration uses alias names (e.g., MOTOR0_STEP, MOTOR0_DIR, MOTOR0_EN) that are never defined. These aliases need to be defined in a [board_pins] section mapping them to actual STM32G0B1 pins, or the actual pin names should be used directly. Based on the existing generic-bigtreetech-manta-m4p.cfg, MOTOR0_STEP should be PC6, MOTOR0_DIR should be PA14, and MOTOR0_EN should be PC7.

Copilot uses AI. Check for mistakes.
rotation_distance: 40
microsteps: 16
endstop_pin: ^X_STOP
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias X_STOP is undefined. Based on the existing board configuration, this should be PC0.

Suggested change
endstop_pin: ^X_STOP
endstop_pin: ^PC0

Copilot uses AI. Check for mistakes.
position_endstop: 0
position_min: 0
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The position_min: 0 setting may prevent homing adjustments. Consider setting this to a small negative value (e.g., -5) to allow for Z-offset calibration with the BLTouch probe, which is configured with offsets at lines 105-107.

Copilot uses AI. Check for mistakes.
position_max: 235

[tmc2209 stepper_x]
uart_pin: MOTOR0_UART
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias MOTOR0_UART is undefined. Based on the existing generic-bigtreetech-manta-m4p.cfg, the UART pin for the X motor (motor 0) should be PB12.

Suggested change
uart_pin: MOTOR0_UART
uart_pin: PB12

Copilot uses AI. Check for mistakes.
run_current: 0.80
hold_current: 0.50
stealthchop_threshold: 0

[stepper_y]
step_pin: MOTOR1_STEP
dir_pin: MOTOR1_DIR
enable_pin: !MOTOR1_EN
Comment on lines +34 to +36
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aliases MOTOR1_STEP, MOTOR1_DIR, and MOTOR1_EN are undefined. Based on the existing board configuration, these should be PB10, PB2, and PB11 respectively.

Copilot uses AI. Check for mistakes.
rotation_distance: 40
microsteps: 16
endstop_pin: ^Y_STOP
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias Y_STOP is undefined. Based on the existing board configuration, this should be PC1.

Suggested change
endstop_pin: ^Y_STOP
endstop_pin: ^PC1

Copilot uses AI. Check for mistakes.
position_endstop: 0
position_min: 0
position_max: 235

[tmc2209 stepper_y]
uart_pin: MOTOR1_UART
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias MOTOR1_UART is undefined. Based on the existing board configuration, this should be PC10.

Suggested change
uart_pin: MOTOR1_UART
uart_pin: PC10

Copilot uses AI. Check for mistakes.
run_current: 0.90
hold_current: 0.60
stealthchop_threshold: 0

[stepper_z]
step_pin: MOTOR2_STEP
dir_pin: MOTOR2_DIR
enable_pin: !MOTOR2_EN
Comment on lines +51 to +53
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aliases MOTOR2_STEP, MOTOR2_DIR, and MOTOR2_EN are undefined. Based on the existing board configuration, these should be PB0, PC5, and PB1 respectively.

Copilot uses AI. Check for mistakes.
rotation_distance: 8
microsteps: 16
endstop_pin: ^Z_STOP
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias Z_STOP is undefined. Based on the existing board configuration, this should be PC2.

Suggested change
endstop_pin: ^Z_STOP
endstop_pin: ^PC2

Copilot uses AI. Check for mistakes.
position_endstop: 0
position_min: 0
position_max: 250

[tmc2209 stepper_z]
uart_pin: MOTOR2_UART
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias MOTOR2_UART is undefined. Based on the existing board configuration, this should be PC9.

Suggested change
uart_pin: MOTOR2_UART
uart_pin: PC9

Copilot uses AI. Check for mistakes.
run_current: 0.90
hold_current: 0.60
stealthchop_threshold: 0

[extruder]
step_pin: MOTOR3_STEP
dir_pin: MOTOR3_DIR
enable_pin: !MOTOR3_EN
Comment on lines +68 to +70
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aliases MOTOR3_STEP, MOTOR3_DIR, and MOTOR3_EN are undefined. Based on the existing board configuration, these should be PB3, PB4, and PD5 respectively.

Copilot uses AI. Check for mistakes.
rotation_distance: 22.8
microsteps: 16
nozzle_diameter: 0.4
filament_diameter: 1.75
heater_pin: HOTEND_HEATER
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias HOTEND_HEATER is undefined. Based on the existing board configuration, this should be PC8.

Suggested change
heater_pin: HOTEND_HEATER
heater_pin: PC8

Copilot uses AI. Check for mistakes.
sensor_type: EPCOS 100K B57560G104F
sensor_pin: HOTEND_THERMISTOR
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias HOTEND_THERMISTOR is undefined. Based on the existing board configuration, this should be PA0.

Suggested change
sensor_pin: HOTEND_THERMISTOR
sensor_pin: PA0

Copilot uses AI. Check for mistakes.
min_temp: 0
max_temp: 300

[tmc2209 extruder]
uart_pin: MOTOR3_UART
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias MOTOR3_UART is undefined. Based on the existing board configuration, this should be PA13.

Suggested change
uart_pin: MOTOR3_UART
uart_pin: PA13

Copilot uses AI. Check for mistakes.
run_current: 0.80
hold_current: 0.50
stealthchop_threshold: 0

[heater_bed]
heater_pin: BED_HEATER
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias BED_HEATER is undefined. Based on the existing board configuration, this should be PD8.

Suggested change
heater_pin: BED_HEATER
heater_pin: PD8

Copilot uses AI. Check for mistakes.
sensor_type: Generic 3950
sensor_pin: BED_THERMISTOR
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias BED_THERMISTOR is undefined. Based on the existing board configuration, this should be PC4.

Suggested change
sensor_pin: BED_THERMISTOR
sensor_pin: PC4

Copilot uses AI. Check for mistakes.
min_temp: 0
max_temp: 120

[fan]
pin: PART_COOLING
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias PART_COOLING is undefined. Based on the existing board configuration, this should be PD2.

Suggested change
pin: PART_COOLING
pin: PD2

Copilot uses AI. Check for mistakes.

[heater_fan hotend_fan]
pin: HOTEND_FAN
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias HOTEND_FAN is undefined. Based on the existing board configuration, this should be PD3.

Suggested change
pin: HOTEND_FAN
pin: PD3

Copilot uses AI. Check for mistakes.
heater: extruder
heater_temp: 50.0

[bltouch]
sensor_pin: PROBE_SIGNAL
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias PROBE_SIGNAL is undefined. Based on the existing board configuration, this should be PC14.

Suggested change
sensor_pin: PROBE_SIGNAL
sensor_pin: PC14

Copilot uses AI. Check for mistakes.
control_pin: PROBE_SERVO
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alias PROBE_SERVO is undefined. Based on the existing board configuration, this should be PA1.

Copilot uses AI. Check for mistakes.
x_offset: -44
y_offset: -7
z_offset: 0

[safe_z_home]
home_xy_position: 117.5,117.5
speed: 80
z_hop: 10
z_hop_speed: 10

[input_shaper]
shaper_type_x: mzv
shaper_freq_x: 40
shaper_type_y: mzv
shaper_freq_y: 40

[bed_screws]
screw1: 30,30
screw2: 205,30
screw3: 205,205
screw4: 30,205
48 changes: 48 additions & 0 deletions scripts/flash_stm32_usb_dfu.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<#
Purpose: Flash Klipper firmware to STM32 (Manta M4P v2.0) via USB DFU using STM32CubeProgrammer CLI.

Prereqs:
- Install STM32CubeProgrammer (includes STM32_Programmer_CLI.exe)
- Board in DFU mode (BOOT0+RST per WINDOWS_FLASHING.md)
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference to WINDOWS_FLASHING.md that doesn't exist in the repository. This should either reference an existing documentation file (e.g., README.txt which contains the DFU instructions on line 42-47) or the non-existent file should be created.

Suggested change
- Board in DFU mode (BOOT0+RST per WINDOWS_FLASHING.md)
- Board in DFU mode (BOOT0+RST per README.txt lines 42-47)

Copilot uses AI. Check for mistakes.
- Firmware at ..\out\klipper.bin built with start address 0x08002000

Usage (PowerShell):
.\flash_stm32_usb_dfu.ps1

Note:
- Adjust `$CLI`, `$PORT`, and `$ADDRESS` if needed.
#>

Param(
[string]$BinPath = "$PSScriptRoot\..\out\klipper.bin",
[string]$CLI = "C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe",
[string]$Port = "USB",
[string]$Address = "0x08002000"
)

Write-Host "Flashing firmware via STM32CubeProgrammer CLI" -ForegroundColor Cyan
Write-Host "Bin: $BinPath" -ForegroundColor Cyan
Write-Host "CLI: $CLI" -ForegroundColor Cyan
Write-Host "Port: $Port, Address: $Address" -ForegroundColor Cyan

if (!(Test-Path $BinPath)) {
Write-Error "Firmware not found: $BinPath"
exit 1
}
if (!(Test-Path $CLI)) {
Write-Error "STM32_Programmer_CLI.exe not found. Please install STM32CubeProgrammer and update path."
exit 1
}

# Connect to device in DFU mode and write binary at the specified address with verify
& $CLI -c port=$Port -w $BinPath $Address -v
if ($LASTEXITCODE -ne 0) {
Write-Error "Flashing failed (exit code $LASTEXITCODE)."
exit $LASTEXITCODE
}

Write-Host "Flash completed and verified successfully." -ForegroundColor Green

# Optional: reboot device if supported
& $CLI -c port=$Port -rst
Write-Host "Reboot command issued." -ForegroundColor Green
Loading