Skip to content

Instantly share code, notes, and snippets.

@SteveGotthardt
Last active May 16, 2024 06:34
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

@exdablju
Copy link

exdablju commented Dec 6, 2022

Hello! Is there a possibility to switch from Klipper with modified (resoldered) R65-R66 to standard printer firmware? I am about to setup Klipper on my Kobra, but this is my only printer so i want an ability to configure Klipper during day and if not satisfied yet - use my printer as before without need to resolder back. I can compile firmware for Kobra, but I struggle to find what to change in it to work after resoldering (without Klipper). If you have any clues please let me know. Thanks.

@lygris
Copy link

lygris commented Dec 7, 2022

@exdablju Yes you will have to recompile the marlin firmware with the address changed for X. I'm not sure how to actually do that but I know you can do it per some guy on reddit.

I have my kobra working in klipper right now and i'm dialing in the settings. I only got my kobra about 2 weeks ago so it's taking me a few days of calibrating but if you've been printing awhile you can probably get it dialed in pretty quickly.

Oh and if you suck at soldering SMD resistors like I do, you can replace the 0 ohm resistor with a small bit of wire.

@lygris
Copy link

lygris commented Dec 12, 2022

@SteveGotthardt Is there any pins on the board I can use to wire up a bltouch on this?

@SteveGotthardt
Copy link
Author

@lygris
PB6 and PB7 ? I would start there since that is what they are using for leveling

@lygris
Copy link

lygris commented Dec 12, 2022

@SteveGotthardt Any clue where the physical pins are for those 2? i'm not too good at this board level stuff.

@SteveGotthardt
Copy link
Author

@lygris
the SPI connector is not used, right? So these should be open
so choose from:
PB12: (SPI SSN)
PB13: (SPI SCK)
PB14: (SPI MISO)
PB15: (SPI MOSI)

@lygris
Copy link

lygris commented Dec 14, 2022

@SteveGotthardt I have it wired up using SSN/PB12 but the probe status isn't reporting correctly. Tried both PB12 and ^PB12, on PB12 it always reports open and on ^pb12 it always reports triggered. tried to use PH2 from the lcd and it would only report open. Tested with 2 sensors different sensors in case 1 is bad. Wondering if it's because PWM isn't supported on any of those? Are PB0-2 working pins or are they dead? Looks like there isn't a chip soldered in there to make them work.

EDIT: sorry i meant i used the pullup on PB8 not PB12.

@SteveGotthardt
Copy link
Author

@lygris
I have new firmware in release section that makes GPIO work for beeper - maybe that will help?

@lygris
Copy link

lygris commented Jan 6, 2023

@SteveGotthardt I flashed your updated bin last night but didn't have time to go much further. I would need to wire up the bl touch wire to the inside of the lcd at that point in place of the beeper correct?

@SteveGotthardt
Copy link
Author

@lygris
not the beeper - it is hardwired/mounted on the mainboard. The new FW should insure proper GPIO operation for other pins too. - maybe retry PB12?

@lygris
Copy link

lygris commented Jan 6, 2023

@SteveGotthardt tried it with PB15 for sensor pin and pb12 for control, same behavior as before, it can't sense the probe status. Not sure the updated firmware actually applied? Is there anything other than throwing it on an sdcard with the klipper.bin name i need to do to update/flash to the newer version?

@SteveGotthardt
Copy link
Author

The beeper will beep a few times if firmware was successful. I think the name needs to be changed to firmware.bin and only file on SD card

@lygris
Copy link

lygris commented Jan 6, 2023

@SteveGotthardt ahh firmware.bin worked, still no luck on getting the bltouch working. I even tried desoldering the beeper and using that. I give up, going to order an skr mini E3 v3

@Digedi77
Copy link

@SteveGotthardt hello Steve maybe you can help me I flashed my Anycubic Kobra plus with your clipper firmware, the Cobra also beeps three times. but now it always stops right at the beginning when it wants to start the z-axis. do you have an idea why?

@SteveGotthardt
Copy link
Author

@Digedi77
Sorry, I don't own the printer, just the mainboard - here is a link from someone with Kobra (but theirs is a max) https://klipper.discourse.group/t/anycubice-kobra-max-config-file/5379/6
maybe you can get some info in there that may help?

@Digedi77
Copy link

@SteveGotthardt
---> Hi Stev, yes I have already written to him (thanks) but I don't think he knows why either.... he recommended your KLIPPER firmware flash version.... so it can't be that or... .. (Thanks in advance)

@suprs0nic
Copy link

suprs0nic commented Mar 14, 2023

@SteveGotthardt Just want to say thank you for youre work! I used the fitst release firmware until it was merged and my kobra works great thanks to you!
BR Thomas

@Adriandcy
Copy link

Adriandcy commented Apr 28, 2023

https://www.youtube.com/watch?v=9oZcltdv82g&list=WL&index=1&t=1s

este usuario lo ha conseguido, he soldado y copiado el printer.cfg y todo va de lujo

@janosch2377
Copy link

The precompiled firmware runs very well. Thanks a lot!

@themaximax
Copy link

themaximax commented Feb 11, 2024

This is my first 3D printer and I'm just starting to get the hang of it.
Can you please tell me if I just re-solder the extruder driver chip to a tmc2209, do I need to change anything other than
#define E0_DRIVER_TYPE TMC2209?
If I use the Marlin firmware.

@aiden0rchad
Copy link

Thank you for your work! Works great with my printer, I do want to ask if I can connect using the PI GPIO pins/UART rather than USB, are there header pins in the Trigorilla_Pro_A_V1.0.4 or maybe even points i can solder to directly connect to. Id like to hide my Raspberry Pi Zero 2W inside the the MCU enclosure.

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

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