MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.17k stars 19.21k forks source link

[FR] Add support for TriGorilla Pro A V1.0.4 for Anycubic Kobra, Anycubic Kobra Max #24757

Open tensiondriven opened 2 years ago

tensiondriven commented 2 years ago

Is your feature request related to a problem? Please describe.

Need to add support for Trigorilla Pro 1.0.4a

Are you looking for hardware support?

Yes, the Anycubic Kobra and Anycubic Kobra Max use the TriGorilla Pro A V1.0.4 board, but Anycubic has not published the pinouts for this board.

Describe the feature you want

Add support for TriGorilla Pro A V1.0.4 board to support anycubic Kobra, Kobra Max.

Additional context

https://www.chitusystems.com/ may be the manufacturer of the Trigorilla boards (not confirmed)

Discussions on Reddit:

Picture of the Mainboard (Anycubic Kobra) TriGorilla Pro A V1.0.4 https://imgur.com/a/N4fyafO Main Chip on the board appears to be a HC32F460 Cortex-M4

xC0000005 commented 1 year ago

Chitu is the manufacturer (see the trigorilla_pro_disk environment, where the firmware is encrypted.) You should be able to start from the pro and work out the pins.

tensiondriven commented 1 year ago

I'll give it a shot. Can you provide an overview of the process for working the pin-outs? I'm technical (software developer), but not terribly experienced with reverse engineering hardware. I've heard of other people suggesting that this can be done, but need an outline/overview of where to start. Any links, resources etc would be useful!

xC0000005 commented 1 year ago

First step - Backup your firmware & bootloader. Pull the boot jumper and start that sucker up and download it using ST's flasher. Now you can always go back. Put that boot jumper back on.

Second step- Get SOMETHING to build for that board. If there's no config, I'd suggest using the AnyCubic Predator config. It's for a delta but it'll let you build something. Copy over the config files from the config repo (they're under examples, delta, anycubic, predator IIRC) You'll want to add a motherboard id to boards.h (don't worry about the ID, but locate it near the other trigorilla one. Youll want to add a case for that motherboard to mb.h You'll add a pins file for your rev (copy the existing trigorilla and hope!) Set your board in configuration.h t your new trigorilla variant. run pio run -e trigorilla_pro_disk, copy the update.zw file it created to the SD, put it in and turn it on. It should beep a bunch and hopefully boot up.

If it doesn't, start turning off features (TFT display comes to mind). By default it'll probably want you to listen to usb at 115200, 8, N, 1 and see if it boots up. Sometimes Marlin will tell you what goes wrong. SD_SUPPORT is another thing to turn off if it won't boot.

Most people will use a multimeter with continuity testing and the pinout of the chip to determine endstops, heaters, and stepper pins, filament runout and so on.

If trigorilla_pro_disk won't update for you, mail me (git hub handle at gmail ) the backup you made and I'll find out the offset for the bootloader.

I leave heaters unplugged until verified and I test: endstops, Thermistors, heaters, steppers, runout/level/etc

in that order.

tensiondriven commented 1 year ago

Brilliant, thank you. That all made sense to me. Hopefully I won't fry the thing in the process. A couple of Q's:

What is ST's Flasher? Presumably this is the flashing utility for the STM board, but wanted to check. Hoping it runs on linux or mac, though i guess worst case I can get windows running on something.

What is pio? Is this a binary that comes with the flasher?

When you say

If trigorilla_pro_disk won't update for you Are you saying that if I'm unable to boot the board with using the trigorilla firmware binary from the Marlin repo then you can lend a hand? Just trying to grok "won't update".

This is most excellent, thank you for effort - i appreciate it.

xC0000005 commented 1 year ago

What processor is that on the board? A GD STM clone or actual ST? Regardless, you want to find the pinout for chip and look for boot0 and trace it, see if it goes to a pad. If it does, pulling it high (any 3.3v source) and then powering on will invoke the serial bootloader.

https://www.youtube.com/watch?v=vL-JXBVUNRg shows how to back up chitu boards (which this is). I don't know if ST's tools will read GD devices. If you succeed in saving it off, drop a copy of it to me in email and I'll see if it has any different encryption than the other chitu boards. (If there's a firmware update already available for it, point me to it).

xC0000005 commented 1 year ago

Hey, sweet - there's no encryption on the firmware now. That's a great sign.

xC0000005 commented 1 year ago

So, their firmware is Marlin. Did they release the source somewhere?

xC0000005 commented 1 year ago

This is not a chitu board (it's made by them but doesn't use their encryption at all). I'd see if there's any other boards based on that hardware and start from those. Still use the multimeter to map the pins, but it's not exactly a chitu/trigorilla derivative like you'd expect. So the real question is "What board do you start from as a basis?" and that depends on the MCU. Sorry for the bad information on what environment to use.

tensiondriven commented 1 year ago

No problem, still super thankful for the guidance.

I also mis-spoke; the MCU on the board is the HC32F460 (which apparently only recently received support for Klipper)

Yes, the firmware is a modified Marlin. No, they didn't release the source (and yes, they're in violation of GPL. There are a few people on the internet who are upset about that.)

Out of curiosity, how did you determine that there's no encryption on the firmware?

Knowing that the board is based on HC32F460, does that help you advise me on what base firmware / board to start from as a basis?

thisiskeithb commented 1 year ago

HC32F460 is not supported in mainline Marlin yet, so they really need to post or provide their source code to see what was done to support this MCU.

ST’s licensing does not allow running some of their code on non-ST MCUs, so we’d need to verify some things before adding support (see: GD32 support).

xC0000005 commented 1 year ago

How did I know there's no encryption? I opened in in binary ninja and read the vector table, guessed a few values and got a relatively decent disassembly. Like thisiskeithb, I'd love to see what they did. Looks to me like it would be a different HAL (and the timers are...limited).

xC0000005 commented 1 year ago

https://github.com/wellrun/hc32f460/tree/master/hc32f460_sdk/%E7%BC%96%E7%A8%8B%E5%B7%A5%E5%85%B7 has the programmer, so you could (maybe) backup the firmware and bootloader, if you can translate it.

Michel-lev commented 1 year ago

20220912_193324 20220912_193312 20220912_193242 Bonjour Si ça peut aider j'ai trouvé quelques pin pour kobra max voir photo

tensiondriven commented 1 year ago

Bonjour Si ça peut aider j'ai trouvé quelques pin pour kobra max voir photo Translated: Hello If it can help I found some pins for kobra max see photo

Fantastic! This is a huge step forward.. I'm afraid I don't know what all of the names for the findings mean so I may need some help making this actionable

xC0000005 commented 1 year ago

If you own a cheap dev board for this, it should be possible to cobble together enough Arduino functions on top of the MDK/Pack files from the website I linked to. This thing will be a lot like the M200 series of printers, motion controller on a limited MCU and probably a smart LDC (I'd guess).

tensiondriven commented 1 year ago

@xC0000005 There's enough here that I would need to learn to pull this off that I expect I won't have time/energy to do it for some time. I'll try posting a link to this thread on the Anycubic Reddit and maybe someone will be interested in coordinating with me on moving it forward.

Thanks x100 for everything so far!

ServerOnTheMove commented 1 year ago

Seems that Anycubic published their development(?) branch of the Max firmware. Maybe this will help?

https://github.com/ANYCUBIC-3D/Kobra_Max

MaxWinterstein commented 1 year ago

Seems that Anycubic published their development(?) branch of the Max firmware. Maybe this will help?

https://github.com/ANYCUBIC-3D/Kobra_Max

And also for Kobra: https://github.com/ANYCUBIC-3D/Kobra

ellensp commented 1 year ago

Yes the source is out, unfortunately you cannot use platformio, it is designed for Keil uVision

marlomgirardi commented 1 year ago

I believe the Ender 2 Pro has the same MCU as this board https://github.com/MarlinFirmware/Marlin/issues/24338 as it might not work with the current STM32 implementation

maikramer commented 1 year ago

For the people with no hope, well, I'm almost there. I built a firmware from marlin upstream. It can be built with platformio, like normal marlin. I made it changing almost nothing from the marlin source, only adding code in a separate repo for the Arduino related code. Well, for someone wanting to take a look. Filament sensor is not stable yet, with a feel things.

The repo is https://github.com/maikramer/MarlinKobraMax

I work on it everyday, and I'm keeping marlin updated.

ntrrgc commented 1 year ago

Yes, the firmware is a modified Marlin. No, they didn't release the source (and yes, they're in violation of GPL. There are a few people on the internet who are upset about that.)

About a month later, the firmware source code was finally made available in their GitHub:

https://github.com/ANYCUBIC-3D/Kobra https://github.com/ANYCUBIC-3D/Kobra_Max

There is this reddit post that explains how to build it in Windows using Keil https://www.reddit.com/r/anycubic/comments/y2waxu/tutorial_how_to_build_anycubic_marlin_source_code/ I couldn't find info myself about how to get it working in something more open, like PlatformIO, but seeing recent Klipper work on that specific MCU chip makes me hopeful: https://github.com/Klipper3d/klipper/pull/5208

The source code has personally been useful when troubleshooting problems with the printer, like it shipping with a different thermistor that they configured in the firmware :sweat: I swapped the thermistor for the one in that source code and was able to finally get PID not being a wild oscillating mess after auto-tuning!

I found it weird that in Configuration.h you can see #define CUSTOM_MACHINE_NAME "Anycubic Viper" (instead of Anycubic Kobra), but I could confirm that indeed that's how my Kobra with stock firmware identifies over serial:

FIRMWARE_NAME:Marlin bugfix-2.0.x (Dec 22 2021 14:30:26) SOURCE_CODE_URL:github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:Anycubic Viper EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff

Tannoo commented 1 year ago

I have recently got possession of the Kobra Max. Well, this has been interesting. I have been able to compile all of the official published codes, but they do not run on the printer. I am still digging to get something working via PlatformIO before I throw out this useless control board.

Tannoo commented 1 year ago

For the people with no hope, well, I'm almost there. I built a firmware from marlin upstream. It can be built with platformio, like normal marlin. I made it changing almost nothing from the marlin source, only adding code in a separate repo for the Arduino related code. Well, for someone wanting to take a look. Filament sensor is not stable yet, with a feel things.

The repo is https://github.com/maikramer/MarlinKobraMax

I work on it everyday, and I'm keeping marlin updated.

I am having issues with getting platformIO to get with the ball game.

Platform Manager: Installing git+https://github.com/maikramer/platform-hc32f46x.git UserSideException: Please install Git client from https://git-scm.com/downloads

I have all forms of GIT installed and cloned that repo. What does it want from me?

Tannoo commented 1 year ago

For the people with no hope, well, I'm almost there. I built a firmware from marlin upstream. It can be built with platformio, like normal marlin. I made it changing almost nothing from the marlin source, only adding code in a separate repo for the Arduino related code. Well, for someone wanting to take a look. Filament sensor is not stable yet, with a feel things. The repo is https://github.com/maikramer/MarlinKobraMax I work on it everyday, and I'm keeping marlin updated.

I am having issues with getting platformIO to get with the ball game.

Platform Manager: Installing git+https://github.com/maikramer/platform-hc32f46x.git UserSideException: Please install Git client from https://git-scm.com/downloads

I have all forms of GIT installed and cloned that repo. What does it want from me?

Nevermind.... I had to restart VSCode.

Tannoo commented 1 year ago

Still cannot get it to compile. There is a reference to a "loop()" in main.cpp of the platformIO toolchain that is says doesn't exist.

Tannoo commented 1 year ago

In '.....platformio\packages\framework-arduino-hc32f46x\cores\arduino\main\main.cpp':

    extern void timer01B_init(); // used for beep duration timer
    extern void timer02B_init(); // soft serial
    extern void timer41_init();  // 1k Hz, used for temperature tick
    extern void timer42_init();  // step motor

    extern void setup();
    core_hook_post_setup();

    // call loop() forever
    while (1) {
        core_hook_loop();
        extern void loop();
    }
    return 0;
}

I added "extern void " to the 'loop()', 'setup()', 'timer01B_init()', 'timer02B_init()', 'timer41_init()', and 'timer42_init()'.

Now, it compiles.

Let's see if it runs.

Tannoo commented 1 year ago

No go. The printer beeped several times before the screen booted up. The system just hangs after that. Restarting it does no good. Put stock firmware back on and it is running again.