Skip to content

Instantly share code, notes, and snippets.

@SteveGotthardt
Last active November 3, 2024 09:45
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

@aiden0rchad
Copy link

@SteveGotthardt I think the best way for this is just solder usb data wires to the board underneath?

@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)

@igorsvetlana
Copy link

igorsvetlana commented Oct 30, 2024

Hello good sir, I managed to desolder the solder pads to both R66 and R65 so I scraped the surface on the motherboard and solder like this instead (marked in blue)
Untitled
and when I try to measure continuity between the solder pad and the PCB copper line (marked in green) there is continuity, but Klipper spits out
"Unable to read tmc uart 'stepper_x' register IFCNT"

So I wonder if there is another point on the board I can measure continuity from or re solder a wire...

EDIT:
Also measured from the "left" solder pad to the pin on the driver/chip itself, third one down (where my red line is) and there is continuity between them.

EDIT2: I also have continuity between pin 64 (VCC) on the HC32F460 to pin 3. Is my error completely firmware related? 🤔

EDIT3: For anyone with same (hopefully not) is just solder R65 instead and used https://github.com/printers-for-people/catboat

@iq440
Copy link

iq440 commented Nov 3, 2024

EDIT3: For anyone with same (hopefully not) is just solder R66 instead and used https://github.com/printers-for-people/catboat

Bro, I've encountered the same problem. I can't do anything about it... no config helps. When the X axis starts moving, it sometimes goes to the home position, but most often it just gives the same error...

Your last link doesn't work, can you help me find a solution to this problem?

@igorsvetlana
Copy link

igorsvetlana commented Nov 3, 2024

EDIT3: For anyone with same (hopefully not) is just solder R66 instead and used https://github.com/printers-for-people/catboat

Bro, I've encountered the same problem. I can't do anything about it... no config helps. When the X axis starts moving, it sometimes goes to the home position, but most often it just gives the same error...

Your last link doesn't work, can you help me find a solution to this problem?

Seems like i broke the hyperlink,
https://github.com/printers-for-people/catboat
Just make sure to resolder the resistor/wire to R65.
How to:
https://github.com/printers-for-people/catboat/wiki/KIAUH-Install

Edit: i mixed up R65 and R66 in previous comments, Ive changed them so anyone else dont get confused. Its R65 that has to be soldered when using Catboat project.

@iq440
Copy link

iq440 commented Nov 3, 2024

EDIT3: For anyone with same (hopefully not) is just solder R65 instead and used https://github.com/printers-for-people/catboat

Found it, thanks)

Have you found out what the reason is?
What exactly is the problem?

I mean, it's definitely the control board, but which element is causing such problems?

@igorsvetlana
Copy link

I mean, it's definitely the control board, but which element is causing such problems?

I've have no clue, i dont have that much knowledge in these electronics..

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