Close

A Question of Cores

A project log for Monoprice Mini Marlin 2.0 Support

Getting Marlin to run on the Monoprice Mini/Malyan M200.

J.C. NelsonJ.C. Nelson 10/18/2018 at 19:150 Comments

At this point it might look like we're done, but the truth is...not really. Why? Because V2 and MP Mini Pro both require STM32070 support.

As noted in previous logs, I implemented a working HAL based on the STM32GENERIC core, but that core is pretty much in hibernation. Turns out, there's a new core in town, ST's Official Arduino Core. It's slowly progressing, as it's something ST wants to work right.

Moving to this core meant switching to the Arduino IDE to build, and I spent a few days just getting everything configured such that I could use a symlinked GIT repo as the core.  Once I did, I dove in, using my work from STM32GENERIC as a guideline.

First blocker: Custom startup files. STM32GENERIC and the ST official core both #include common startup assembly. This is a good approach given how many different variants of ST"s MCUs there are.

But for the M200 series boards (and their M100 cousins) this is a no-go.  As noted previously, the bootloader doesn't set SP and there's an interrupt/systick watcher running which crashes the printer if certain values are overwriten.

So I asked for help, and the core maintainer added the ability to specify a custom startup file. A few hours of hacking later, I had a minimal M200 build running (and crashing).

Problems: 

1. VECT_TAB_OFFSET wasn't defined (again). Had to add it to the boards.txt.

2. Serial support is really, really strange in this core. I'm still wrapping my head around what Serial links to versus Serial1. In the end the working solution was "Serial with generic Serial" and output to Serial1.

3. USB....

In fact, let's drill into USB support. As I noted, the ST core is moving carefully, and CDC support is still under development. That current code doesn't work on 103 devices where timers are in short supply, but I hacked together a direct send/receive implementation, and encountered the next problem:

4. No USB Init. M200V1s require a pullup transistor to be enabled. This is under investigation.

5. Late Watchdog doesn't work. If the bootloader is already running, the IWatchdog fails to initialize and no longer feeds the watchdog correctly.

The first two are fixed for some version of fixed. 3 is undergoing a great deal of study, and 4 is the subject of some investigation. For now I'll likely simply turn the transistor on during System Clock config.

The watchdog will be the subject of my next work. For now I can load a build onto my V1 printer with no USB support and it runs for ~8 seconds before reseting. I believe the fix for this is to have a flag that says "The watchdog is already running" in the library.

We'll see.

Discussions