WIP: Marlin on Jackpot

Fluidterm is mostly just like a COM port interface like putty or teraterm, and it talks to Marlin just fine. The one advantage over say putty is I can use CTRL-R to toggle the DTR/CTS or whatever to hard reset the controller.

I haven’t given up on the serial mux, I’ve just gotten a bit distracted. I still think it’s possible without a huge effort.

1 Like

Oh, so that was just Marlin…dang.

Okay, so I think I’ve got it working this time.

I set X2 to a low current and it had the expected effect: the X2 motor moves more easily by hand while all of the rest of the motors are normal. Then I set it back to normal and set Y2 to be low current, and Y2 became easier to turn by hand. I also configured (in configuration_adv.h) the “A” axis (6th stepper driver) to be 32-step microstepping and in the M122 report it shows 32 while all the others show 16. So the commands are being routed to the appropriate stepper drivers.

The basic idea of the update is what I outlined before. The TMCStepper library already has a “pre-read” and “pre-write” routine that is the perfect spot to insert switching of the serial MUX to route the serial signal to the proper stepper driver. But within the TMCStepper library it only knows about native Arduino pins and it has no concept of the I2S streaming through the HCT595 shift registers.

So I added a callback function, and the pre-read and pre-write functions invoke the callback function (if any). Then on the Marlin side I have a function that writes the pins (which map to the I2S streamed pins) to set up the mux.

The only bad part is that setting the I2S pins doesn’t take effect immediately. There is a queue for the DMA and it takes a moment for the pin values to propagate through the queue and appear on the output. By my calculations it’s 32 milliseconds to flush the FIFO so I have a delay of 40. A delay of 5ms was not enough and wires were getting crossed, setting values on the wrong stepper drivers.

I need to start a conversation with the maintainers of the TMCStepper library to see if they are amenable to adding the callback functionality, and then, perhaps in parallel see if the Marlin folks have any input/objections to adding a new board and the tweaks it requires.

But I think I can have an unofficial release put together before then and people can try it out.

4 Likes

Dude, that is nuts. You are trying to make it sound Easy…but I know it wasn’t because I barely understand any of that.

1 Like

Holy crap, this is awesome!
I wonder… if we made an add-on for the expansion port that added thermistor and a couple of MOSFET IO, could we make the jackpot into a controller for the Repeat printer… ??? !!!

That is crazy. I love it.

It looks like the pins on the expansion header (GPIO12, GPIO13, GPIO14, and GPIO15) are analog capable, but only when wifi is not started. It would probably be straightforward to add an expansion board with ADCs where you would fetch the values over i2c, but I’m not sure what that would entail on the firmware side. I’m not seeing any obvious feature where someone has implemented i2c temperature readings.

But it’s just software.

1 Like

That would be nuts honestly. I still can’t believe you are this close to getting marlin working on it at all. I never even considered it for even a second.

2 Likes

You know. I never know what to expect in here. This place is so unique!!! Congrats Jamie!

3 Likes

Ok, for anyone brave, I think this will work:

Download this:
https://github.com/vector76/Marlin/archive/refs/heads/jackpot_updates.zip

Build with VSCode and you should get a binary firmware.bin within the folder .pio\build\esp32\

I use a modified version of the FluidNC upload batch file to upload the firmware using esptool.exe that came with FluidNC:

@echo off
set EsptoolPath=esptool.exe
set BaseArgs=--chip esp32 --baud 921600
set SetupArgs=--before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect
set Firmware=0x10000 firmware.bin
echo %EsptoolPath% %BaseArgs% %SetupArgs% %Firmware%
%EsptoolPath% %BaseArgs% %SetupArgs% %Firmware%

Also you can use fluidterm to connect to the controller and the nice thing about that is you can use CTRL-R to reset the controller and view the startup messages.

And then you will need version 2.1 (not 2.1.1) of the ESP3D-WEBUI:
https://github.com/luc-github/ESP3D-WEBUI/releases/tag/v2.1

Unpack that and get index.html.gz and upload that to the controller.

Somehow the system remembers my SSID and password even though I triple-checked that it’s not defined in Marlin anywhere. I am confused how it got there, but it is evidently in flash somewhere not in the filesystem (index.html.gz) and not in the firmware (firmware.bin) and not on the SD card. There is a tab on the web UI to set the SSID and password or configure AP mode, but I wouldn’t know how to set that up if it weren’t already working.

I think I might try a few things to see if I can get a completely fresh start and see if I can figure out how to set the SSID and password from there.

1 Like

Ok, if you have a totally blank system, the upload script (batch file) I gave above is not enough because it doesn’t set up a file system or (I think) boot loader. Maybe other things too, I’m not sure.

Install FluidNC. Then install Marlin over top of it. It’s a workaround for the parts that I don’t understand, but for now it’s good enough to get started.

After you’ve installed Marlin over top of FluidNC, you will find it starts in AP mode with SSID=“MARLIN_ESP” and default password is “12345678”.

From there you can upload index.html.gz, and after that you can configure your own station mode or AP mode with your own SSID and password.

2 Likes

That is different. So marlin still treats this as two systems? The firmware, and the wifi firmware. Sort of like the skr with an esp01. I actually like the sound of that better. I guess that makes sense marlin doesn’t have an interface really and this doesn’t have an LCD, so it has to get controlled somehow.

I need to poke around, I feel like this can open up the door to a few odd mods.

1 Like

I’ll head down this path today. I picked up a 2nd Jackpot and some extra USB-C ESP32s a while back specifically to play around on a test bench. I need to put the 4.7K pullup mod on the ESP32s, and I’m going to put together a test setup using that extra jackpot. I’m also going to build a little ESP32 test fixture of some kind.

This is interesting to me as well. Does marlin run in core1 and the UI core0? I believe core0 on the ESP32 is what runs the WiFi interface. How does the UI do communication with Marlin?

1 Like

I’ve managed to build your sources and have a ~1Mb firmware.bin.

I’m doing the build/flash on my Ubuntu laptop, so I’ll study the .sh files and make my own variant of that.

Meanwhile, I need to figure out where I stashed my leaded resistor collection so I can rework a few of the USB-C ESP32s that I picked up from Ryan.

Looking forward to seeing Marlin running in the jackpot.

2 Likes

You undeniably have mad skills!

1 Like

Jamie has mad skills. I’m just building the source he got working.

1 Like

On that front, some progress…

Took one of the USB-C ESP32s that Ryan had on the store and was clearing out from the first experiments with them. These dev boards have some spotty solder workmanship straight out of the package from wherever overseas they were built. It was working well enough that I was able to flash FluidNC on to it.

From there, I threw a quick and dirty 4.7K pullup on it. More ugly solder :slight_smile:

I then figured out how to trick the FluidNC WiFi installer into installing the binary I built (I cheated… :slight_smile: ) I renamed the original FluidNC firmware.bin and replaced it with the one I built. The installer happily flashed it.

Next, I reset.
Looky here: Marlin on ESP32, about to go into a Jackpot board (Was still just sitting on my breadboard when this boot happened, thus it being unhappy)

configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:13220
ho 0 tail 12 room 4
load:0x40080400,len:3028
entry 0x400805e4
start
 External Reset
 Brown out Reset
 Watchdog Reset
Marlin 2.1.2.1
echo: Last Updated: 2023-05-16 | Author: (Jamie, Jackpot Test Firmware)
echo: Compiled: Nov 12 2023
echo: Free Memory: 253880  PlannerBufferBytes: 1472
echo:EEPROM version mismatch (EEPROM=? Marlin=V88)
echo:AP started 
echo:192.168.0.1
E (1562) SPIFFS: mount failed, -10025
echo:Hardcoded Default Settings Loaded
echo:Settings Stored (664 bytes; crc 26772)
echo:EEPROM Initialized
Testing X connection... echo:HTTP server started
Error: All LOW
Testing X2 connection... Error: All LOW
Testing Y connection... Error: All LOW
Testing Y2 connection... Error: All LOW
Testing Z connection... Error: All LOW
Testing I connection... Error: All LOW
echo:192.168.0.1
echo:No SD card

I will probably flash a couple of more, since I picked up a couple more host boards to slap the ESP32 into while I hack at them:

Next up, downgrade the UI, put the ESP32 onto the Jackpot, then find a mechanical host to hook it up to. Sadly, no LR3 here, so I’ll have to muck around with some kind of test setup.

At any rate, this doesn’t seem too terrible and there’s hope for this being viable.

1 Like

It boots, so I think that means you’re 95% of the way there! :laughing:

3 Likes

The last 5% takes 95% of the time :stuck_out_tongue_winking_eye:

1 Like

The bigger the blob, the better the job!

Okay, the xmas craziness has settled down and I think most of the jackpot issues have been fixed. I have learned a lot in the last couple months. I just reread this thread, and understand a bit more of it now. It was so far over my head when you did this.

Still blows my mind that you guys can do things like this. It still feels like magic the code you guys can write.

Your multiplexer tweaks, do you think those are worth getting into Marlin?

I guess even higher level. Is the jackpot worth running in Marlin. I know it gives us Idex, and the possibility of marlin based expansion modules, but there are lots of other boards out there.

Working on this new printer, I am realizing I would love to run it on a Jackpot, I am proud of it and would love to just have everything running it at RMRRF. Klipper would also be great but you already have it working on Marlin. I just am not sure how much of a edit you had to make to get the multiplexing to work, and if it would get in the way of other machines.

I am asking in private because I do not want to stir the pot if you are over it. If that is the case I can try to get what you have going and try one of my printers with it, an SSR for the mains powered bed, maybe another for the hotend (need to double-check the capacity).

2 Likes