Printer.cfg for Anycubic Kobra 2 Plus/Pro/Max

I’ve added setup instructions now. It’s basically what i did for setting everything up, but I haven’t run everything again, so if anybody can give me feedback that the instructions are understandable and working that would be great! :slight_smile:

1 Like

Here you go

#Configuration file for the Anycubic Kobra 2 neo. (Trigorilla 4.0.1 Board)


#please read every comment before changing and using this config to ensure you dont break anything.


#DISCLAIMER
#This Printer config was written and optimized by and with the help of the Klipper forum group.
#THIS IS EXPERIMENTAL and nobody will give you any warranty in case your printer blows up.
#version 1.4.0
#fixed comments and virtual SD location
#please excuse any spelling or grammatical errors in my comments as english is not my native.


#Included files
[include mcu.cfg]         #this is where the mcu settings are, as i use different ones i excluded them here
[include mainsail.cfg]
[include makro.cfg] 	#comment this if you dont have this macro file.
#[include adxl.cfg] #uncomment this if you want to connect an adxl sensor and have this config file


#printer config
[printer]
kinematics: cartesian
max_velocity: 250
max_accel: 10000 #yes it does 10k atlease at 250mm/s
max_z_velocity: 8 #dont change this
max_z_accel: 800


#this is my input shaper result, change or disable this only if you know what it does and at best have an adxl sensor
[input_shaper]
shaper_freq_x: 54.8
shaper_type_x: ei
shaper_freq_y: 34.0
shaper_type_y: mzv


#virtual SD
[virtual_sdcard]
path: ~/printer_data/gcodes #replace this with this --> path: /home/your host name/printer_data/gcodes
on_error_gcode: CANCEL_PRINT


#x stepper
[stepper_x]
step_pin: PA12
dir_pin: PA11
enable_pin: !PA15
microsteps: 16
rotation_distance: 40
endstop_pin: ^!PB11
position_endstop: -10
position_min: -14
position_max: 220
homing_speed: 100 #this sets the homing speed.


#y stepper
[stepper_y]
step_pin: PA9
dir_pin: !PA8
enable_pin: !PA15
microsteps: 16
rotation_distance: 40
endstop_pin: ^!PC13
position_endstop: -2
position_min: -3
position_max: 230
homing_speed: 100 #this sets the homing speed.

#z stepper
[stepper_z]
step_pin: PB0
dir_pin: !PB1
enable_pin: !PA15
microsteps: 16
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop
position_min: -2
position_max: 200
homing_speed: 15
second_homing_speed: 2


#extruder config
[extruder]
max_extrude_cross_section: 5.0 #change if you change nozzle diameter to something large
step_pin: PB15
dir_pin: PB14
enable_pin: !PA15
microsteps: 16
max_extrude_only_distance: 200
max_extrude_only_velocity: 80
max_extrude_only_accel: 5000
rotation_distance: 7.084
nozzle_diameter: 0.400
filament_diameter: 1.750
pressure_advance: 0.06 #if you see bulges or underextrusion on corners, tune this with the documentation (https://www.klipper3d.org/Pressure_Advance.html)
heater_pin: PB8
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC3
min_extrude_temp: 190
min_temp: 0
max_temp: 250
control: pid
pid_ki: 0.88
pid_kd: 59.12
#pressure advance
pid_kp: 14.42 #tune this with this guide (https://www.obico.io/blog/klipper-pid-tuning/)


#hotbed
[heater_bed]
heater_pin: PB9
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC1
min_temp: 0
max_temp: 120
control: pid
pid_kp: 97.1 #tune this with this guide (https://www.obico.io/blog/klipper-pid-tuning/)
pid_ki: 1.41
pid_kd: 1675.16


#inductive probe settings
[probe]
pin: PA1
x_offset : 24.0
y_offset : 13.35
#z_offset: 0
samples: 3
samples_result: average
samples_tolerance_retries: 1
sample_retract_dist: 2
speed: 15
lift_speed: 8
samples_tolerance : 0.1
samples_tolerance_retries : 3

#auto bed level settings
[bed_mesh]
speed: 200
horizontal_move_z: 3
mesh_min: 14, 11
mesh_max: 210, 215
probe_count: 7,7 #change this if you want more or less probe points
mesh_pps: 4,4 
algorithm: bicubic
bicubic_tension: 0.2

#zhome probing. Probably dont change this
[safe_z_home]
home_xy_position: 5, 10
speed: 100
z_hop: 10
z_hop_speed: 15

[controller_fan controller_fan]
pin: PB12

[heater_fan extruder_fan]
pin: PB13

[fan]
pin: PB5
cycle_time: 0.00005 #20kHz

#This pin enables the bed, hotend, extruder fan, part fan.
[output_pin enable_pin]
pin: PB6
static_value: 1

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [probe]
#*# z_offset = 1.595
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	  0.005000, 0.020000, 0.042500, 0.062500, 0.094167, 0.140833, 0.194167
#*# 	  0.045833, 0.035000, 0.038333, 0.048333, 0.054167, 0.052500, 0.091667
#*# 	  0.062500, 0.047500, 0.048333, 0.054167, 0.065833, 0.090833, 0.085833
#*# 	  0.045833, 0.018333, -0.003333, -0.008333, -0.015000, -0.047500, -0.040000
#*# 	  -0.028333, -0.052500, -0.067500, -0.077500, -0.076667, -0.103333, -0.118333
#*# 	  -0.124167, -0.168333, -0.194167, -0.213333, -0.235000, -0.287500, -0.297500
#*# 	  -0.190000, -0.240000, -0.290000, -0.321667, -0.355000, -0.418333, -0.440833
#*# x_count = 7
#*# y_count = 7
#*# mesh_x_pps = 4
#*# mesh_y_pps = 4
#*# algo = bicubic
#*# tension = 0.2
#*# min_x = 14.0
#*# max_x = 209.96
#*# min_y = 11.0
#*# max_y = 215.0

I ordered a BTT SKR mini controller board (I don’t feel like spending what it cost the printer for what hopefully will be a temporary solution :sweat_smile: ). While it arrives, I have documented all the pinouts and all the info I collected on the Kobra 2 Pro here.

The main issue I’ve noticed is that the Kobra 2 Pro uses two separate SPI interfaces to read the accelerometers, and the SKK mini only has one available SPI port. I guess I could multiplex the signal, as they can be on the same bus as long as they have their own CS port.

The other problem is adapting the cables. I could do some kind of “adapter motherboard” if I want to reuse them, or I can roll my own. Will keep you updated.

Good News, Everyone!

I’ve recently spent some time digging inside main application (app) of my Kobra 2 Pro and found a couple of interesting things.

  1. I’ve found an OTA update (en)decryption AES key in 3.0.3 app, so we can now decrypt update.bin packages with newer firmwares like 3.0.5. After decryption you will get normal zip with swu update file inside…
    AnycubicUpdateBin.zip (1.2 KB)
    Attached is LINQpad C# script (actually just a C# program) that you can use to decrypt update.bin by yourself.

  2. I’ve found a bunch of hidden G- macro codes in app, from M8000 to M8822, that is used to change any printer configuration settings, upload and download printer configs from and to USB disk and even replace default printer config files with anything you want! It also slightly looks like some of Mxxxx command from that bunch is able to execute arbitrary shell code. But all this needs further investigation, I will check and test all this and will write additional comment with results.

  3. I’v also found an (en)decryption AES keys for logs that you can export to USB disk using printer settings menu with 3.0.5 FW. Files “log_1” and “log_2”. I’ve still not wrote a snippet in C# (this will be an exercise for you! now :slight_smile: My be in next post I will attach such snippet if will not be lazy enough. Anyway, you can use this decryption key and IV for logs:
    6DE30155B7964E8CF0F3D2465997A458F8B56FF7E1E537597E9B5861062B4742
    001F35A46358F76877C3382764460775

  4. Now some of my thoughts about base that anycubic used for building FW for Kobra 2 Pro series.
    APP: Althgough it very looks like Klipper, it definitely not. At least not all that python stuff from that was Klippy made… I think they took basic ideas, concepts, algos, etc. and remade it almost from scratch.
    FW: Firmware (a Klipper counterpart for smaller MCUs, you know it) resides inside Extensa DSP coprocessor named “HiFi4” of main Allwinner SoC. You can grab this part from update swu file, it is named “dsp0”. Just an ELF wrapped compiled binary that also can be loaded in IDA and investigated. It looks like was made from original Klipper firmware, at lease reusing original code from Klipper project. May be even older one (who knows?) but with some modifications, adaptations and enchancements (uhm?) from our Chinese friends. I’ve just slightly looked inside, not thoroughly, it also needs more investigation.

Что один человек сделал, другой завсегда сломать сможет! :slight_smile:

Final thoughts.

I think it is almost impossible to goodly run original Klipper on Trigorlla (kek!) platform because of very limited RAM (only 128 megs) and not very speedy CPU to perform heavy computations on Klippy side and running some Web UI side by side. May be I am wrong, but I don’t think so. Anyway, it looks for me a relative simple and trivial task to port and run original Klipper (bare Klippy) on Linux part. But without GUI (no KlipperScreen because it needs heavy GTK). Also without OctoPrint and etc. because also very heavy software for T113. It also needs porting of firmware counterpart of Klipper to HiFi4 architecture, writing drivers, many sleepless nights, no official opensource sdk, etc… So… I think, we need to use this controller as is, may be just tweaking configs if needed and untieing it from Chinese cloud. But porting original Klipper… hm… I think no way. It is better and faster to throw out Trigorlla and retrofist it with some good aftermarket controller.

3 Likes

Yes. Hidden Mxxxx G commands is working as expected! At least that is investigated by me till now. You can try it by yourself. Copy contents of attached zip into USB disk, insert into Kobra and “print” any of included gcode files:
1_download_cfg.gcode - it will download full actual printer.cfg and unmodifiable.cfg to the root of USB disk.
2_upload_cfg.gcode - it will upload printer.cfg from your USB disk into printer and completely replace it. So it is possible now I think to modify any controller configuration settings without hassle.
There also M8817 command that will copy printer.cfg from USB disk to /app/resources/configs/printer.cfg (effectively replacing default one) and M8818 that will copy unmodifiable.cfg to the user and default ones. Please use at your own risk!
BTW, I still have not tested back uploading configs, so it is for you, bravehearts here. В бой!
gcode_configs_mgmt.zip (425 Bytes)
Note that there are ROOT and UNROOT commands that enable and disable execution of other Mxxxx commands respectively.
I will, may be, prepare a table with all other investigated usable M commands (as there are tons of it available, effectively a single set command for any printer.cfg corresponding setting property).
Will also investigate a suspicious command that I think may be related with executing shell code. Stay tuned.

3 Likes

hi all,
im new to using uart serial, im using linuxmint, i was trying to get it into the root of my kobra2 plus

i was holding ‘s’ down like the guide for the updates said but im certain im not doing it right.

i can watch the serial output when the printer boots but that is all
sorry for the noob question .

When linux will boot up completely, try pressing Enter several times or other keys. You expect to see a login prompt. At least as I remember how it works (still never tried it with my kobra). If you do not see login prompt, you need to firstly check your uart TX connection and wiring, may be there is a problem. If you will see a login prompt, but still unable to open uboot shell with “S” - then I don’t know. Needs investigation.

1 Like

im made the mistake of updating to the latest firmware and since then no uart serial context

No problem at all. Now we know encryption keys and hence how to make downgrade package to earlier firmwares back. I think it should work. I am just too lazy now to make script to build downgrade packages. May be someone will do it using infos I posted in previous answers. Or may be I will make it, but a bit later, not right now.

Thanks! Before you invest more time and work in documenting parts of the K2Pro though, I just wanted to let you know that I created a comprehensive infosite about that machine, just in case you didn’t come across it yet: Kobra2Pro Insights
However, as I didn’t check and document the pinouts yet, I’ll link to your repo in those specific sections then.

You mean like using the mobo ‘regularly’ as at other machines by just flashing klipper.bin and connecting an additional host which then runs Klipper, Moonraker, Mainsail? That would be great and (at least for me) absolutely enough… :wink:

Did I get you right that this means that one could tweak the printer.cfg with the stock setup without the need of e.g. getting root access to the machine first or do any other hacks/tweaks/mods…?

I know! You’re cited in the docs (and your references for some of the components saved me quite a lot of time! :slight_smile: ).

My repo, unlike yours, is more like a cleanup of my project scribbles than a site for public consumption. Is my expectation that any data I find will be used later by sites like yours.

My next step will probably start adapting the Kobra 2 Pro for usage with the SKR Mini E3. So expect cable layouts, marlin (I’m new to klipper and everyone says better start with what you know) configs and if tests are successful, klipper configs.

BTW, I noticed that you site states that the accelerator is an ADXL. I need to run some driver tests to confirm it, but i’m 99% sure - based on package and markings - that is a LIS2DW12. I don’t know if they use the same protocol - I know that Klipper has native support for both.

You may also want to incorporate that there is also an accelerometer present in the head, on the distribution board. Maybe that’s what’s different between the “Old” Kobra 2 heads and the “New” ones?

Oh right, I didn’t see that you referred to my site :smiley: Thanks!

It might come in handy if I could add some of your schematics directly at the site then, what do you think? Of course you’d be mentioned then as the contributor - I’m not the kind of person who is stealing the work of others for getting the ‘laurels’ for that then… :wink:
EDIT: nvm, I can just link to the files directly as well, I just thought that users wont have to ‘jump’ between different sites then… :wink:

As for the SKR at the K2 Neo (which’s mobo is different to the one being used in the K2 Pro): I’d mention and link to that from my Kobra2Neo Insights site then :slight_smile:
I’d be interested in a good mobo which could be used at the K2Pro/Plus/Max, preferrably not too expensive tho. We would have to pay attention to the connection of the inductive probe then as well as to the different Y-motor connector imho. But maybe we could talk about that in private for not cluttering up this thread - if you feel to do so, best would be via email then, you can find my address in the footer at the infosite.

Right, at least judging by the printer.cfg of the K2PPM, it’s a LIS2DW12 - I need to change that as well as I have to add the info about it being given at the head as well - I already have it on my ToDo-list :slight_smile:
Yes, that’s actually the main difference between those heads - this and the different PCB at the head which is (imho) caused by the fact that the accel sensor is being added at the K2PPM head.

1 Like

Btw: a kind user made a schematic of the pinout of the PCB of the K2PPM head and sent it to me - if it’s somewhat helpful for you, I could send it to you…

Yes, you can entirely tweak/replace printer.cfg and even unmodifiable.cfg with method I discovered. Just need to test it thoroughly.

Also you can unpack/decrypt and pack/encrypt back newer update.bin files and exported logs (there are many interesting things inside logs, i.e. URLs with newer FW updates, etc. I think developers decided to encrypt it because of that).

I’m now working on kind of ZIP bomb (like a tar bomb) trying to exloit inners of app newer encrypted update logic. It it will be successful, getting root access on any FW will be as simple as just flashing a new update manually from USB disk :wink:

Yes I know Kobra2Pro Insights, you can publish any info disclosed by me here if you want. I will create my own repo with infos and tools today, so you can link it, ok. Will publish link to github here.

About porting Klipper:

  1. Yes, It looks possible to run Klippy and even Moonraker on main CPU. May be a simple Web UI also. But I think we will be needed to run Orca, Octoprint, etc externally. It’s a bit pity at least for me. But anyway I can try. May be I am wrong and we will able to run full stack.
  2. I need to have access to HiFi4 DSP SDK to port and build FW part of Klipper, like Anycubic have done, but opensource :slight_smile: Now I have almost no info on that. Only this repo: GitHub - YuzukiHD/FreeRTOS-HIFI4-DSP: FreeRTOS for Cadence Tensilica HIFI 4 DSP on R329, D1-H, T113 With GCC Compiler to run basic code, but I need ready coded drivers and methods to control peripherals like GPIOs, SPIs, ADCs from inside HiFi4. Or even some docs to make drivers by myself. Now I just does not have this info. Without it, there is no point in even starting to try doing some porting efforts.
    I have contacted a couple of chinese shops on AliExpress that sale devboards with T113 SoC, may be they give me needed codes and examples if I will buy devboard.
2 Likes

To avoid cluttering the thread I sent you an email to your public github contact address.

1 Like

Attached a LINQPad script for decrypting logs. You can run it inside LINQPad or you can even copy a code from it to separate .cs file (or just remove “Query” XML block from linq file) and build it with f.e. bflat (issuing bflat.exe build your_file.cs) to get just usual executable. Then you can run executable inside folder with encrypted logs and it will decrypt it magically :slight_smile:

TrigorllaDecryptLog.zip (1.1 KB)

3 Likes

Great, thanks!
So I’ll wait for your GH repo with the instructions etc then and then I’ll link to it :slight_smile:

Thx, reply is sent…