Flashing Firmware in new control/display cards?

Hi Forum Folke,

Printing newbie here. Yeah, I can hear the groans now! :wink:

I’ve had an Ender 3 since Christmas, and have made plenty of decent headway with overcoming the learning curve. I was a mechanic for most of my working life, so the mechanical end of things is trivial for me… but it’s the coding side that has me quaking in my boots, as I’ve never written a single line of code of any kind, not even in Basic.

I just upgraded to a BigTreeTech SKR Mini E3 version 2, which was bundled with a TFT35 E3 version 2 touchscreen color display. Neither has firmware flashed into them; they’re blank slates.

As I understand it, I need to take several files (configuration.h and configuration_adv.h for the control card, and a couple of different ones for the display card), load them into a development environment like Visual Basic (with the platform IO extension, and the Marlin AutoBuild extension which is supposed to make the process easier), make any adjustments to the appropriate lines (commenting out or un-commenting to enable the option), then “build” or “compile” the file into an binary file that is then uploaded into the appropriate card.

Sounds simple enough in theory, especially as the files in question seem to be like “swiss-army kinves,” with tons of possible options and settings already written in, but mostly commented out so they’re not active.

Also, there are a bunch of “example” files available in GitHub for different make/model printers. I found one for mine in the BigTreeTech pages in GitHub, for my cards and printer.

My question is this: can I just take that “example” configuration.h file and compile and load it into the card? I’ve seen a couple of warnings on the Marlin site cautioning against doing that, but no reason is given for this warning. The prevailing opinion there seems to be take the basic Marlin 2.1.2.1 file, configure it appropriately, then compile and load IT. Not sure why this is better and I’d like to understand this before proceeding.

The other question I have is that I don’t think I can flash both cards simultaneously (correct me if I’m wrong), in which case is there a “preferred order” to flash the cards in?

I do have a copy of the “configuration.h” file that shipped with the printer on a little 8GB micro-SD card, so at least I have that for reference. Went nuts trying to find out how to back up the firmware already in the printer (I’ve upgraded enough computer systems to know that you NEED to back up before proceeding), before I found the already-provided file, so that much is taken care of. I can “reset to original” should things go sideways on me.

Any direction from those familiar with the process would be greatly appreciated; there’s a wealth of info in GitHub, but I find that site a bit overwhelming and difficult to use… often scouring high and low trying to locate files (still looking for pins.h, after finally finding boards.h.)

Much appreciated!

I recently setup an SKR E3 v2 on my Ender 3 v1 and this is the initial instructions I followed.
https://www.reddit.com/r/3Dprinting/comments/n7or5u/marlin_20x_guide_skr_mini_e3_v20_ender_3/

My end goal was adding filament break sensor, Input Shaper and BL Touch capabilities but I started out with getting Marlin 2.1.2.1 working first and then moved from there.

The SKR E3 I got just needed the firmware.bin file copied to an uSD card and when the SKR E3 is powered up with that uSD card it will load the firmware.bin file and if successful it will rename the firmware.bin file to FIRMWARE.CUR.

This tutorial talks about using PlatformIO with Microsoft VSCode and some auto configurator which should make building easier but I don’t run Microsoft stuff so I run PlatformIO from the CLI interface( pio run ) so this does work but yes, there are lots of configuration and configuration_adv files setting to adjust. But they are documented well.

No groans!

It’s because as Marlin changes, the contents of that file change, so if you copy an older configuration.h in and build a newer Marlin with it, the configuration may not work.

I’d suggest following @dougl’s path here. Though you’ll probably want to use the VSCode graphical interface. I’m like Doug and use the command line myself, but Doug and I have both lived on the command line for decades. For getting started, you’ll probably be happier with the UI.

You’ll have more questions as you go along. That’s cool! We can help. :smiling_face:

Thanks Gents for the prompt and helpful replies!

@ dougl: Thanks for the link; never thought to scour reddit for this kind of info. I don’t really “do” reddit, or FaceBook, or a lot of popular things.

I chucked Windows some time ago; Win10 had a lot of issues that there were no fixes forthcoming for… they were too busy developing Win11. “100% disk use,” constant dropping of bluetooth connctivity, refusal to connect to my wifi with the cryptic message: “Can’t connect to this network”… and others. Running Linux Mint now, but it has versions of Visual Studio and PlatformIO.

While I go back to the DOS 3.0 days, I was never really comfortable with the command line; I was a one-finger hunt-and-peck “typist,” which doesn’t work well for command-line work. By the time I learned to touch-type (Mavis Beacon Teaches Typing 3.0), I was so far behind the curve and running Windows that I never ‘caught up.’ I can follow instructions, but left to my own devices, I’m a clear and present danger to myself and my system. :wink:

@mcdanlj: Thanks for the welcome and assurances. I dislike it when someone says “Don’t do this!” and doesn’t explain why. I didn’t know if they were for reference purposes only and wouldn’t work at all, or would mess things up somehow. Might not work is annoying but benign overall. Nice to know!

Sounds like you might have some interest in learning more. No obligation to follow any of this, but just in case, I’ll describe a little bit here.

A lot of this can be done from the GUI in VSCode, I just literally don’t know how. I only know the command line… So I’ll describe the command line here, and maybe it helps if you want to use the GUI?

It turns out that as you learn more, you can use those reference configuration files. It’s just that there’s potentially a lot to learn. The way I would use them is:

  1. Check out the version they were made with in git
  2. Make a local branch from that version
  3. Copy in the configuration header files
  4. Commit those changes to my local branch
  5. Merge the version I want to move to into my local branch, resolving any conflicts

There’s a lot of implicit “knowing how to use Git” wrapped up in there, though!

Right now, I think that 2.1.2.1 is actually the latest release. So if the configuration files are actually for 2.1.2.1 you can download the 2.1.2.1 release, or check it out in Git, if you installed Git, then copy those files into place, then build.

So if you downloaded those two files to the /tmp directory and have Git installed, you might just do this:

git checkout 2.1.2.1
git branch my-btt-e3
cp /tmp/Configuration.h /tmp/Configuration_adv.h Marlin/
git diff
git add Marlin
git commit -m 'updated to btt configuration
  • The checkout checks out the tagged release that it sounds like the files come from.
  • The branch creates a new local (on your computer) branch for you to keep your own configuration on.
  • The cp copies the files into the location they lie
  • The diff shows what is different between the 2.1.2.1 release and the files you just copied in
  • The add tells git “Save copies of the files in the Marlin directory for me to commit”
  • The commit saves that configuration on your my-btt-e3 branch.

Then later you’d be able to update to a new version of Marlin while preserving your configuration. Let’s say 2.1.2.2 bug fix was released.

git checkout my-btt-e3
git fetch origin
git merge 2.1.2.2
  • The checkout makes sure you are on your branch
  • The fetch copies all the latest changes to your computer, but doesn’t change any of the files you have checked out
  • The merge fairly intelligently works out how to keep both the official updates in the (theoretical at least for now) 2.1.2.2 release and the changes in the configuration! As long as it works, it automatically commits it to your local branch. It will tell you if anything went wrong; otherwise it will have merged the configuration together. It’s almost magic. :smiling_face:

You can do that over and over again and it keeps on working.

And when it doesn’t you can ask for help. :smiley:

Anyway, even if that’s not (yet?) directly helpful, maybe it’s a little interesting?

Ya, I was surprised to find that kind of HowTo on reddit but I’ll evaluate and use information where found and a google search turned up the Reddit link. I also likely started with Configuration and Configuration_adv.h files from the Marlin configuration repo to start with and then updated and/or verified changes to the Configuration files based on the HowTo found on Reddit.

…/./Configurations-release-2.1.2.1/config/examples/Creality/Ender-5/BigTreeTech SKR Mini E3 2.0/Configuration.h
…/./Configurations-release-2.1.2.1/config/examples/Creality/Ender-5/BigTreeTech SKR Mini E3 2.0/Configuration_adv.h

likely found here: Configuring Marlin | Marlin Firmware

1 Like

@mcdanlj: Definitely interesting. It’s an entire world I know nothing about. Feels a bit like trying to learn a new language (spoken, as in Russian or Japanese), and at 70 years old, that’s no easy task!

Wasn’t aware that Git had a GUI… tried installing it, but post-install it wants a license # (for commercial use), but no advice anywhere on how to use it non-commercially for free. Roadblock #1.

Tried building the vendor provided configuration file in Visual Studio, and immediately I’m looking at 70+ errors (see screenshot:)

Roadblock #2. Likely more to follow…

No idea if I can just comment these out since they don’t apply to this machine. From what I understand, error 59 is because the “#if enabled” statement is supposed to refer to something that should exist elsewhere in this file but doesn’t? Don’t know, way above my pay grade! :wink:

I can more or less follow your flow working from the command line, but it requires a depth of knowledge that I just don’t possess at this time. I think I like your way better, but again, I’m not qualified to go that route.

And it IS interesting… and a bit discouraging, as it starkly reveals how very little I know and how much I need to know!

You shouldn’t need to download anything more — vscode should include support for all the git operations already. I just don’t know how! And you almost certainly don’t need even that…

Seeing that @dougl found that sample configuration files for your hardware are already in the source, you don’t need to do anything of that git magic. It should be copying the sample files into place and building, I think.

That error means something else is wrong.

Can you describe in detail what you are doing when you get that error?

Did you follow these instructions?

https://docs.platformio.org/en/stable/integration/ide/vscode.html

If not, what instructions did you follow for installing platformio?

I mcdanlj,

I installed MS Visual Studio (Linux version), then from within VS, installed both the PlatformIO and the MarlinAutoBuild extensions. They both seemed to install without issues, other than prompting me for some additional things to be installed.

I gather that MarlinAutoBuild handles what needs to be done in PlatformIO so know-nothings like me don’t have to deal with that too.

I’ve found config files for my specific hardware and printer both at Marlin and at the BTT, and they appear to be identical. They were buried kinda deep in my file structure, so I made a directory much closer to root and put them in there.

I open Visual Studio, and call the PlatformIO extension. I can’t load the configuration file directly into PlatformIO; it insists on a project file from a folder that has a platform.ini file in it too… which none of mine have. If I switch to MarlinAutoBuild, it wants me to open a “Marlin 2.x.x” folder… not a specific file. Okay, I open the folder that I put just off the root that has my configuration files and a few other directories in it. It’s okay with that, and shows me a tree in the left panel with the directory name, and the four configuration files. I double-clicn on “configuration.h” file and it opens in the IDE, with various color codings appearing after a moment as it loads the file. As soon as it’s done loading, I guess it’s ready to edit. However, if I hover the pointer over the file in the tree, it’s red and says “this file has xxx errors in it.” If I hit “F8,” it goes to the first error, which is the screenshot I posted above.

I did see a Youtube video (link was in the reddit page that dougl posted), and if I could get past the heavy (Italian?) accent, I might be able to make sense of it. Not to rag on him; I have “auditory processing issues,” and can’t make sense of conversation in noisy areas, nor can I deal with heavy accents. I’m going to keep watching it with the audio off and see if I can pick up more on what he’s doing rather than what he’s saying. I did catch something about Visual Studio and PlatformIO and MarlinAutoBuild taking some time to get things going, and that after everyone was happy, those errors will clear up.

Haven’t reached that point, obviously. No progress meter, so I can’t tell if it’s locked up or not. It does go totally unresponsive frequently, but whether that’s because it actually froze or because it’s too busy initializing to be bothered with me jiggling it’s elbow, I don’t know.

So I’m not really doing anything yet other than loading the file and using F8 to spot the errors… can’t get any further than that.

The Arduino IDE is another alternative to Visual Studio, but that’s even worse, as it’s not printer board specific, it’s processor specific; you have to pick the board, and it’s all Atmel and ARM and other processor makes. My card uses a STM32F103RCT6… but of course, that isn’t offered in the list to pick from, and there’s no provision to enter your processor/board… just choose from list.

I would have thought the instructions would have asked you to copy the machine specific Configuration.h and Configuration_adv.h files OVER the existing ones in the Marlin/ directory. I don’t know what VSCode does about copying files or if you’re expected to do a full copy and paste of the contents of the files using 2 different editors. I just copied the files using my commandline and because of my commandline use I also had to edit platformio.ini file to generate the correct targets but your MarlinAutoBuild stuff should handle that.

Probably look back at the instructions on how to deal with the custom Configuration.h files, it probably hinted at how to get them into the VSCode environment.

You can’t just make some new random location for them.

You need to overwrite the existing copies in the Marlin/ subdirectory of the Marlin source code release.

The “Marlin 2.x.x folder” is a release of Marlin.

Click that big button.

image

Download the 2.1.2.1.zip file.

When you unzip it, you will get a Marlin-2.1.2.1 directory.

Copy the Configuration.h and Configuration_adv.h examples into Marlin-2.1.2.1/Marlin

Then build in the Marlin-2.1.2.1 directory. It should pick up the platformio.ini file in that directory and do the right thing.

You’re almost there, I think, even though it probably doesn’t feel like it. :smiling_face:

2 Likes

DING_DING_DING!!!

And that was all it took! There is so much talk of the configuration.h file, that I assumed (and that’s where I went wrong right there!) that all I had to do was load that one file into Visual Studio and it would do the rest. It WILL do the rest, but only if it has the entire Marlin folder, not just the configuration files.

I have a much clearer picture of the process and how it works now, thanks to your gentle prompting.

Went smoothly and I managed to produce two firmware.bin files. The first one gave me a warning that the Maple files were deprecated, and to use a non-Maple file. I was given six or seven to choose from, and I guessed wrong. Re-did it using the non-maple that had my microprocessor numbers on it and ran it. Same warnings as the first one about removing jumpers somewhere if I use the tCL Touch touchless homing; I saved the output from the terminal for reference when it comes to that.

Your help was invaluable, if for no other reason than keeping me from going off the deep end. The hand-holding is very much appreciated… NOW I can breathe easier, continue printing, and slowly learn something about code and compiling.

You da MAN!

4 Likes

@dougl’s help finding that the example configurations included ones you don’t need to change was key to the simple solution. :key:

The fact that the two of us had different insights to help is part of why I like this being a place where people ask for and get help in public — the other being that the next person with a similar problem might find the answer already written.

3 Likes