diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100644 index 000000000000..401a6f8b35e8 --- /dev/null +++ b/CHANGELOG.txt @@ -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. \ No newline at end of file diff --git a/Deployment_Log.txt b/Deployment_Log.txt new file mode 100644 index 000000000000..c76ea41523b8 --- /dev/null +++ b/Deployment_Log.txt @@ -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) \ No newline at end of file diff --git a/README.txt b/README.txt new file mode 100644 index 000000000000..57a68ec9373a --- /dev/null +++ b/README.txt @@ -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. + +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. \ No newline at end of file diff --git a/Test_Results.txt b/Test_Results.txt new file mode 100644 index 000000000000..ed54c12ab35a --- /dev/null +++ b/Test_Results.txt @@ -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. \ No newline at end of file diff --git a/config/manta_m4p_v2_enderv3.cfg b/config/manta_m4p_v2_enderv3.cfg new file mode 100644 index 000000000000..9f2a686fc7fb --- /dev/null +++ b/config/manta_m4p_v2_enderv3.cfg @@ -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 +rotation_distance: 40 +microsteps: 16 +endstop_pin: ^X_STOP +position_endstop: 0 +position_min: 0 +position_max: 235 + +[tmc2209 stepper_x] +uart_pin: MOTOR0_UART +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 +rotation_distance: 40 +microsteps: 16 +endstop_pin: ^Y_STOP +position_endstop: 0 +position_min: 0 +position_max: 235 + +[tmc2209 stepper_y] +uart_pin: MOTOR1_UART +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 +rotation_distance: 8 +microsteps: 16 +endstop_pin: ^Z_STOP +position_endstop: 0 +position_min: 0 +position_max: 250 + +[tmc2209 stepper_z] +uart_pin: MOTOR2_UART +run_current: 0.90 +hold_current: 0.60 +stealthchop_threshold: 0 + +[extruder] +step_pin: MOTOR3_STEP +dir_pin: MOTOR3_DIR +enable_pin: !MOTOR3_EN +rotation_distance: 22.8 +microsteps: 16 +nozzle_diameter: 0.4 +filament_diameter: 1.75 +heater_pin: HOTEND_HEATER +sensor_type: EPCOS 100K B57560G104F +sensor_pin: HOTEND_THERMISTOR +min_temp: 0 +max_temp: 300 + +[tmc2209 extruder] +uart_pin: MOTOR3_UART +run_current: 0.80 +hold_current: 0.50 +stealthchop_threshold: 0 + +[heater_bed] +heater_pin: BED_HEATER +sensor_type: Generic 3950 +sensor_pin: BED_THERMISTOR +min_temp: 0 +max_temp: 120 + +[fan] +pin: PART_COOLING + +[heater_fan hotend_fan] +pin: HOTEND_FAN +heater: extruder +heater_temp: 50.0 + +[bltouch] +sensor_pin: PROBE_SIGNAL +control_pin: PROBE_SERVO +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 \ No newline at end of file diff --git a/scripts/flash_stm32_usb_dfu.ps1 b/scripts/flash_stm32_usb_dfu.ps1 new file mode 100644 index 000000000000..feebd5d74cd7 --- /dev/null +++ b/scripts/flash_stm32_usb_dfu.ps1 @@ -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) +- 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 \ No newline at end of file