Anker M5 on Klipper - Help!

Basic Information:

:ballot_box_with_check: Printer Model: Anker M5
:ballot_box_with_check: MCU / Printerboard: Anker ST32F407
:ballot_box_with_check: klippy.log

Hello,

I have one of the new Anker M5 printers and I am trying to ‘force’ Klipper on to it. Honestly, the M5 hardware is great but is is based on Marlin on the mainboard, fed movements over UART by an embedded Linux board for UI and connectivity. So no input shaping, plus you need to tolerate whatever spyware Anker put on there (it sends all your gcode and a png to Amazon AWS). I can imagine a lot of people would love to get it running Klipper.

I happen to have a spare mainboard so I’m trying to get Klipper on that, controlled from a Pi as a first step. However I’m struggling!

First up, I can tell you this board is based on an ST32F407 with in-built 1MB flash. It usually talks over UART3 (PD8, PD9) to the linux part of the M5, but it also has UART1 (PA9, PA10) exposed on a header presumably for factory programming. I’m trying to get Klipper talking on UART1 as it is easier to work with. In addition it has an un-populated USB header which is usually dead to the world, but does become active for programming when the ST32 is in bootloader mode.

Yes, I can put it in bootloader mode, but doing that requires soldering a 0402 resistor so many people will not be comfortable doing it. However, as a first step to confirm working firmware and pinout I think that’s the best route to flashing. When we can make Klipper work this way, maybe we can see about making it flash over CLI from the Pi.

Right now I can do either!

I use make menuconfig with the attached settings. (What is the GPIO set at startup setting?)

klippy.log (233.4 KB)

Then I flash the klipper.bin using cube-programmer (both USB or UART via FTDI work).

I set the Printer.cfg MCU serial to my uart adaptor… but no connection.

All I see is Printer Not Ready. Or for a while I see ‘Unkown’ but then later the same as before.

All this is not to mention my lack of success flashing Klipper from CLI both in run-mode and bootloader mode.

I can confirm the MCU is flashing correctly by Cube-Programmer using a test program that outputs a repeating message over UART1. (created for me by a kind soul on EEVBlog Forum).

It makes me wonder if there are some kind of issues related to e-fuses or run-time bootloader things that are above my pay grade??

Your insight would be appreciated! I don’t see why this should be so much different than an SKR Pro that also uses the ST32F407.

(FWIW the way the board comes from Anker it seems to have read protection enabled, all I get from ST Programmer is FFFF. That doesn’t mean we can’t flash it with something new though.)

Sorry for splitting the post. Frankly this forum is impossible as a new user, I am not allowed to include enough attachments or images in a post.

I cannot contribute any more but your serial indicates that no klipper is running on the board. You can easily check with the dmesg command. A Klipper flashed board board looks like:

[1133725.739926] usb 5-1: USB disconnect, device number 3
[1133726.232733] usb 5-1: new full-speed USB device number 4 using ohci-platform
[1133726.467691] usb 5-1: New USB device found, idVendor=1d50, idProduct=614e, bcdDevice= 1.00
[1133726.467702] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1133726.467705] usb 5-1: Product: lpc1769
[1133726.467709] usb 5-1: Manufacturer: Klipper
[1133726.467712] usb 5-1: SerialNumber: 0C70001625813AAF86E06B5CC32000F5

For what it is worth, your “make menuconfig” choices don’t look correct. You should not set any of the “low-level features”. You should not set any “gpio pins at startup”, you should not set a custom baud rate. If you are flashing Klipper via an external programmer to the start of flash, then you should set the bootloader offset to “no bootloader”.

The clock speed is dependent on the board. If you don’t know it, and if you are using UART for communication, you can try setting it to “internal clock” during initial debugging.

-Kevin

Thanks for your reply.

I think the main issue was that I needed to select ‘No Bootloader’. It is working now!

I just need to figure out all the pins and such to build a printer.cfg

If there is no bootloader, what sets the function of the pins that have multiple possible functions, such as output or ADC etc?

P.S. What does 'set GPIO pins at startup" do or why would it be used? I couldn’t find much by googling it.

The set GPIO pins at startup option initializes GPIO pins high or low. This is only necessary if you have a pin that requires initialization before the host (Klippy) connects to the MCU. A common example is that some boards have a USB discovery pin. Klippy cannot connect without USB on these boards so the MCU must initialize this pin.

If there is no bootloader, what sets the function of the pins that have multiple possible functions, such as output or ADC etc?

Pins are configured in printer.cfg. After the host connects to the MCU the configuration is sent so pin initialization can occur.

I’m aware that printer.cfg can set what a pin is assigned to for example pin 3 could be set as the nozzle temperature sensor. Assuming pin 3 IS an ADC with a thermistor attached, it should work.

However, is there something in Klipper that sets pin 3 to function as an ADC? Some pins are multi-function and need to be set to do the job you want.

Here is what that looks like when using STM32 Cube IDE: I could set this pin to function as UART4_TX or it could be a GPIO_Input, or a GPIO_Output, or an ADC etc… If it were setup as an ADC here, I could not use it as a UART even if I wrote my main code to do so.

When you assign a pin to a specific job in printer.cfg does it ‘set up’ that pin for the appropriate function?

Yes. When a pin is configured in printer.cfg it is assigned a type by the host (digital, analog, peripheral, etc). Without getting too far into the weeds, the configuration sent to the MCU differentiates by type. The MCU source has an abstraction layer that parses the configuration then calls the low level setup code for the specific platform. In the case of stm32 devices the alternate function register will be appropriately set during pin init.

That’s pretty cool :slight_smile:

Hello,

Sorry to revive this old thread!

My friend is going to try flashing Klipper on his Anker M5 soon. The board as mentioned above runs an ST32F407 and it currently has Marlin installed.

I’m sure that it has a bootloader because the M5 printer has updated itself in the past without needing to enter the ST DFU mode or short any ‘boot’ pins. Does Marlin include its own bootloader for ST32?

If so, what size bootloader should I select in Make Config and will Klipper flash it natively or do I need to install something?

Thank you!

Have you made any progress on this project? I’m considering tackling it as well.