Home Artists Posts Import Register

Content

Throughout Marlin's 5-year-long history, all its high level movement, G-code handlers, and main loop code has lived together in a single file. growing in size with each new release. With Marlin 1.1.5 (out now!), this file has ballooned to over 13,000 lines of code. Any code guru will tell you that's generally bad practice!

With Marlin 1.1, my focus was on cleaning up the existing code without doing a total refactoring (geekspeak for rearranging the furniture), and I've tried to use my privileged position as a Project Member to ensure that new code follows the same standards. So, Marlin 1.1.5 is amazing and awesome (don't get me wrong) but, alas, it's not perfect!

Marlin 2.0 gives us the opportunity to fix all the things about Marlin that have been bugging both developers who need to manage the codebase, and users who just want to tweak code for their own purposes. As we transition to a new age, let's take a brief look at the things about Marlin that we can finally bid a fond farewell…

Flat Codebase

Prior to Arduino 1.6.8, you had to keep all of a project's source files together in the same folder, with no subfolders allowed in #include. You could turn parts of a sketch into libraries to work around this, but, seriously…

For Marlin 1.1 I took the time to split up large files into many smaller ones, but this can only go so far. With Marlin 2, source files are now grouped into folders according to their role in the project, including config, core, feature, gcode, HAL, libs, pins, etc.

AVR-only

Marlin is based on Grbl and Sprinter circa 2011, which only target the Arduino platform, and PJRC has put together an Arduino-compatible Teensy platform. As a result, Marlin 1.1.5 supports 76 distinct 8-bit boards, but has not graduated to more powerful 32-bit boards.

Arduino has made it easy to target their 32-bit "Due" platform, so several Marlin forks sprang up for Due, RAMPS-FD, and other ARM-Cortex M3 boards. However, few forks (with the notable exception of MK4Due) bothered to keep up with ongoing Marlin development. Meanwhile, the main Marlin project had yet to choose its preferred 32-bit path.

Marlin 2 introduces a hardware access layer so that it can support more boards going forward. This also means that for the most powerful boards, Marlin can include much more sophisticated high level code, incorporate more kinds of sensors, and make machines more intelligent in addition to running cooler and smoother.

Bad Encapsulation

Up to now, Marlin has maintained most of its core variables in global space. Since Marlin was originally built on a pure C codebase, and AVR boards are generally used for more modest sketches, as Marlin continued to build around its original foundations, variables applying to many features accumulated in the Marlin_main.cpp file.

Unbeknownst to many code developers, you can get almost identical linker behavior without the usual C++ overhead by making a class entirely static, which also makes it a singleton. Files like stepper.* and planner.* already grouped common code, so it was relatively easy to transition these to static singletons.

With Marlin 2 almost all common code will be grouped in singleton objects, and variables that go with a feature will be grouped with that feature. This will make it somewhat easier to extend Marlin without stepping on other code.

Gratitude!

I feel immense gratitude to all my supporters and patrons, who have helped me to remain firm in tough times and obtain the freedom to put my weekdays into helping make Marlin the best RepRap firmware for the next generation. I will continue to work hard to keep it moving forward!

I've gotten a lot of feedback and encouragement from the wider community since I started posting as @MarlinFirmware on Twitter, and through the help of Joel Telling and others putting out the word, Josef Průša joined the campaign, jumping me over the half-way hurdle to my goal!

Some have suggested that I should increase my goal if I want to achieve more than just covering the basic costs of development and documentation, and that by setting the goal higher this may in fact attract more patrons because it demonstrates a more serious commitment.

While I agree with these fair points —and I do want to produce more video-based documentation for Marlin especially— I have been hesitant to promise more than code and website content until I have a more controlled situation. It's gradually been improving, but I'm looking for a new place to live (in Austin, TX) now. Perhaps raising my goal to a more realistic level would in fact help. I tend to think in terms of 1980's economics, and I see that my accustomed rent level is rarely a great situation nowadays!

In regard to campaign promotion, I would obviously rather spend my time on programming and 3D printing, but I'm open to any ideas about promotion that you might have. And, I want to express my gratitude to all current patrons in some material way, whether it be a custom-designed poster or coffee mug or "Marlin Inside" sticker…. I'm not sure yet. I will explore the kinds of options that exist for getting stuff like this out to you guys, in recognition of your direct contribution to today's Marlin.

Files

(No title)

Comments

Anonymous

Just get all the blogs to feature you a bit....I would never have known about your Marlin involvement had I not been browsing the net and searching wordpress to link....I found your details at <a href="https://www.th3dstudio.com/knowledge-base/th3d-unified-firmware/" rel="nofollow noopener" target="_blank">https://www.th3dstudio.com/knowledge-base/th3d-unified-firmware/</a>