Skip to content

Instantly share code, notes, and snippets.

@SteveGotthardt
Last active July 10, 2024 22:48
Show Gist options
  • Save SteveGotthardt/3e19d47212fbf8262f708e792257731f to your computer and use it in GitHub Desktop.
Save SteveGotthardt/3e19d47212fbf8262f708e792257731f to your computer and use it in GitHub Desktop.
Working on getting Klipper up and running on Trigorilla_Pro_A_V1.0.4

Klipper for AnyCubic Kobra Trigorilla_Pro_A_V1.0.4

Status: move r65 to r66 for TMC control

Attaching to target via P4 with SAM-ICE

physical connection: Atmel SAM-ICE 20 pin jumpered to P4

  • P4: Pin 1 -> ICE Pin 1 = VTref
  • P4: Pin 2 -> ICE Pin 20 = GND
  • P4: Pin 3 -> ICE Pin 7 = TMS (used by SWD)
  • P4: Pin 4 -> ICE Pin 9 = TCK
  • P4: Pin 5 -> ICE Pin 15 = RESET

running J-link commander

  • Device: Cortex-M4
  • Target Interface: SWD
  • Interface Speed: 2000 KHz

finding stuff with J-Mem

  • VTOR is at 0xE000ED08
  • which shows vector table start now at 0x8000 (was 0x0 at boot)
  • which shows stack pointer at 0x20008D10 and reset at 0x82A1 - this is for program that shipped with my board

What is the clock running at:

PLL config @ 0x40054100 CMU_PLLCFGR = 0x1110_3100 (reset is 0x1110_1300)

So it looks like 8MHz XTAL * 50 / 2 is 200MHz system clock

  • MPLLM[0:4] = 0, divide by 1
  • PLLSRC = 0, XTAL selected (8MHz)
  • MPLLN[8:0] = 0x031, mult x 50
  • MPLLR[3:0] = 1, divide by 2
  • MPLLQ[3:0] = 1, divide by 2
  • MPLLP[3:0] = 1, divide by 2

XTAL selection: 0x40054032 CMU_XTALCR = 0, oscillates

XTAL configure: 0x40054410 CMU_XTALCFGR = 0, high-drive, not ultra, oscillates

Clock division of 200MHz system clock

  • CMU_SCFGR @ 0x40054020 32 bits after boot: 0x00242210
  • PCLK0: divide by 1
  • PCLK1: divide by 2
  • PCLK2: divide by 4
  • PCLK3: divide by 4
  • PCLK4: divide by 16
  • EXCKS: divide by 4
  • HCLKS: divide by 1

TMC UART address mapping

  • Z: [10] MS1_AD0 is resistor to GND, MS2_AD1 tied to VCC
    • so Z can be addressed with [10] or [11] without trace-cutting
  • Y: [01] MS1_AD0 is tied to VCC, MS2_AD1 is resistor to GND
    • so Y can be addressed with [01] or [11] without trace-cutting
  • X: [00] MS1_AD0 and MS_AD1 tied together through resistor to GND
    • so X can be [00] (R65 placed) or [11] (R66 placed)

Fix addressing (no trace cutting, just move resistors):

  • remap X address to [11] by moving R65 to R66 (VCC) - TESTED - works!

Extruder driver on my board is MS35775, a 2208 clone

Pin Mapping

  • PA0: BED heater
  • PA1: E0 heater
  • PA2: UART TX to 22ohm to CH340G pin 3 RXD
  • PA3: UART RX to 22ohm to CH340G pin 2 TXD
  • PA4: X stepper dir
  • PA5: X stepper step
  • PA6: X tmc2209 endstop = ^diag (StallGuard)
  • PA7: Y stepper !dir
  • PA8: Z tmc2209 endstop = ^diag (StallGuard)
  • PA9: X/Y tmc2209 TX
  • PA10: SD, Detect
  • PA11:
  • PA12:
  • PA13: E0 fan
  • PA14: MCU fan
  • PA15: X/Y/Z tmc2209 RX
  • PB0: E1/ZL stepper !dir ZL not installed
  • PB1: E1/ZL stepper step
  • PB2: E1/ZL endstop = ^diag (StallGuard)
  • PB3: Motor control TX
  • PB4: Motor control RX
  • PB5: Beeper
  • PB6: Autolevel RX
  • PB7: Autolevel TX
  • PB8: Probe
  • PB9: fan
  • PB10: P3 (LCD), Pin 3 TXD
  • PB11:
  • PB12: (SPI SSN)
  • PB13: (SPI SCK)
  • PB14: (SPI MISO)
  • PB15: (SPI MOSI)
  • PC0: BED sensor -> connector T1
  • PC1: E0 sensor
  • PC2: Power loss
  • PC3: X/Y/Z/E stepper enable (!)
  • PC4: Y stepper step
  • PC5: Y tmc2209 endstop = ^diag (StallGuard)
  • PC6: Z stepper dir
  • PC7: Z stepper step
  • PC8: SDIO, D0
  • PC9: SDIO, D1
  • PC10: SDIO, D2
  • PC11: SDIO, D3
  • PC12: SDIO, CK
  • PC13: Filament runout
  • PC14: E0 stepper step
  • PC15: E0 stepper dir
  • PD2: SDIO, CMD
  • PH1: (LCD reset)
  • PH2: LCD P3, Pin 2 RXD

Board Connectors

LCD - P3

  • Pin 1: GND
  • Pin 2: MCU pin 1: PH2 RXD
  • Pin 3: MCU pin 29: PB10 TXD
  • Pin 4: MCU pin 7: NRST (NC)
  • Pin 5: 5V

FAN2 (P19) controlled by PA14

T1 (P5)

  • Pin 1: PC0 -
  • Pin 2: GND

SPI (P20)

Reference

pinoutHC32F460 IMG_20221029_122426 IMG_20221214_075019

vector-table m4_map hc32-clockregs https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2202_TMC2208_TMC2224_datasheet_rev1.13.pdf https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2209_Datasheet_V103.pdf

@SteveGotthardt
Copy link
Author

SteveGotthardt commented Apr 3, 2024

@aiden0rchad
That should work. And,of course, a common ground between the boards.

Will the piZ2W have a hard time communicating over WiFi when enclosed? Maybe use a plastic cover?

@aiden0rchad
Copy link

@SteveGotthardt It shouldn't have issues with WiFi, if there is it should be very negligible. The plastic ABS MCU enclosure should affect the signals at all. Maybe if I have the PiZ2W right next to the 2020 aluminum, then maybe it might. But there's ways around it. You can add a U.FL connector to the PiZ2W which you can attach a Flex WiFi antenna or convert it to SMA to attach a standard SMA WiFi antenna.

@exdablju
Copy link

@SteveGotthardt My cable from motherboard to extruder broke. I was trying to repair it, but I lost extruder connector... Do you maybe have pinout for this cable? From motherboard to extruder?

@SteveGotthardt
Copy link
Author

@exdablju - I do not have a pinout for that cable - I only have the mainboard (no printer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment