Klipper ESP32 support

Hi nefelim4ag and koconnor,
thanks for your kind replies.

@nefelim4ag

ESP32s run no RTOS, but
As the name indicates, FreeRTOS FreeRTOS Overview - ESP32 - — ESP-IDF Programming Guide v5.5.2 documentation, https://www.freertos.org is licenced under MIT open source license and might be a solution for us.

@koconnor
Of course, take your time.

Sorry I’m no developer. I just can write simple phyton scripts :cry:, mechanics and electronics are ok.

The background for my request is…
I just bought a “cheap” laser engraver/cutter and read a lot about those machines before and after buying. Almost all laser engraver/cutter mainboards use an ESP32. I even found a 3D printer board with ESP32 and 4 drivers https://www.fysetc.com/en-de/products/fysetc-e4-board-with-built-in-wi-fi-and-bluetooth-4-pcs-tmc2209-240mhz-16m-flash-3d-printer-control-board-based-for-3d-printer?srsltid=AfmBOookmGjTLuN0Bh1wjF6iRKy-pK410GYAEeFzL5FN8EqIQVno2tLe
I hope Klipper supports sometime in the future laser engraver/cutters or CNC machines. Laser engraver/cutters are way less complex compared to an e.g. CNC milling machine. Just two axes plus the laser. These “cheap” machines with diode lasers run with grbl (g-code) GitHub - grbl/grbl: An open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on a straight Arduino.
Free software for the laser engraver/cutter is the cool GitHub - arkypita/LaserGRBL: Laser optimized GUI for GRBL.
Klipper is in my eyes an industrial standard and pushes new 3D products. You could trade mark Klipper (unaware if you already did).

It is the intermediate layer. So, we can’t really control anything or guarantee anything (Linux MCU is the example).
The last attempt, that I’m aware of, is:

IIRC, he did some stuff to disable half of the RTOS, to simply guarantee stepper timings.

I guess you can ping him on discord, he will be glad.

So, again, anyone can try, but there will be caveats over RTOS, and I’m not sure it is the right solution overall.
(Or you have to rewrite half of the firmware so it will play nicely with RTOS).

This is the only repo that I’m able to find with something bare metal: GitHub - cpq/mdk: A bare metal SDK for the ESP32 & ESP32C3
So, it is technically possible to do so.

-Timofey

1 Like

Thanks Timofey,
well, as stated before “I’m no programmer”. I understand what you wrote, but I’m not able to help.
Maybe some of those people can help Features request MCU support for ESP32 · Issue #199 · Klipper3d/klipper · GitHub.
megablue, jeffeb3, hg42, mmone, FolkertRA, jakep82, jubjub64, MCTaylor17, IXMAN89, beikeland, chmondkind, marcboivin, mpalpha, cinehorse, Darkstar77, Rmdhn1, rocknstorm, indyjonesnl, shodanx2, andremalenfant, creatormir, Giuseppe499, victorhalla, ulope, chrisalbertson, MR-VENOM, DragarX, nikhil-robinson, creatormir

Don’t know, if these people get a message.

Put in an “@” sign before their names, ie: @jeffeb3 , @beikeland , @victorhalla , @ulope 7 @nikhi_robinson and they should get a notification saying that they’re being mentioned - these are the only ones I found with active IDs here.

2 Likes

I have been summoned!

Honestly though, I won’t be much help. ESP32 as a target MCU would be epic. The arduino/platformIO version does indeed run on FreeRTOS. In my opinion, it is very close to vxworks, which is pretty awful to deal with if you’re not familiar. I’m not sure if it has to be removed or if that is just because that developer felt more comfortable without it.

There are some very good alternative for esp32 firmware. FluidNC being the main one. Most esp boards have very little IO, but the IO they have is fast and flexible. But even to run a CNC machine, boards like the Jackpot CNC controller need an ISP GPIO expansion, which will make it even more complex. I haven’t ever thought the esp32 was a good fit for 3D printing. It is great for CNC though.

It’s really a chicken and egg problem. If klipper worked on it (and had a good way to add gpio expansion), board manufacturers would almost certainly choose to build boards for 3D printing. But the boards need to exist and someone with the experience and motivation needs to make it.

1 Like

Hey, I got it working on the ESP32! Klippy runs on my PC and can control motors using ESP32 boards, I’ve tested it on ESP32, ESP32S3, and ESP32H2. Making the Klippy dict is still a bit of a hack because the ESP-IDF build system is weird. You have to build it twice for the compile_times text to show up. If anyone has a fix, feel free to open a PR.

Here is the repo : GitHub - nikhil-robinson/klipper_esp32: Klipper_ESP32 is an implementation of the Klipper protocol for Espressif's ESP32 microcontroller set.

3 Likes

Welcome nikhil-robinson,

god bless you, please, Mr. Robinson (I know you heard that one before)! Awsome, thank you.
I’ll try it with the laser engraver/cutter in the near future. It uses MKS-DLC32/MKS-ESP32-PRO-main/hardware/LS ESP32 PRO V2.1_002/LS ESP32 PRO V2.1_002 SCH.pdf at main · makerbase-mks/MKS-DLC32 · GitHub. Even if I brick it wouldn’t matter. Those boards are not expensive. You can get the boards for around 20 bucks @ ali.

Is that worth a new Klipper PR?

edit:
First project with the laser will be a single layer PCB using acid. When successfully completed a two layer PCB.
Then buying an IR laser and trying it without acid.
I expect to reach a resolution of 19.685 mils.

hcet14

Hey there! I’ve also been playing with this for a while (out of spite, I have a board and I want it working xD). I initially started tinkering with @nikhil-robinson’s fork and got a bit carried away while trying to get FreeRTOS out of the way.

Things are looking good in that regard, with latencies being predictable (at least in the tests I’ve done).

@nikhil-robinson after fighting cmake for a while I got to a solution that I think is decent enough for the CTR stuff, using ESP-IDF components. There’s a “klipper” component that is built first (but not linked), and then a “main” component that generates and includes the CTR, that is built and linked against everything else. If you want to take a look here it is, feel free to reuse anything you deem useful.

I haven’t fully integrated it with klipper’s Makefiles yet, but that’s on the list too :stuck_out_tongue:

I just got back from some vacation time and I’ve been planning to start building an actual printer around it so there’s that, if anyone wants to take a stab at it, feel free to give it a shot! :slight_smile:

3 Likes