This part of the site is now the Primary. The original site is still available for reference at - caggius.wordpress.com
After allowing VSCode and Platform IO to auto update on startup of Code I was able to build Marlin V2.0.9.3 in 25.158 seconds with no errors and a couple of warnings.
VS Code is now available as an M1 ARM only native build (it is also now available in universal and Intel formats)
M1 Arm latest version is V1.81.0
PlatformIO IDE is now Core 6.1.9 Home 3.4.4
VS Code is now available as an M1 ARM only native build (it is also now available in universal and Intel formats)
M1 Arm latest version is V1.67.1 dated May 6th 2022
PlatformIO IDE is now V2.4.3
Marlin is now V2.0.9.3
The January 2021 process, see below, can still be used with the levels of Compiler, Platform Io and Malin as shown above.
The mega2560 check build took my M1 mac mini 12.1 seconds.
The LPC1768, MOTHERBOARD BOARD_BTT_SKR_V1_3, check build took my M1 mac mini 26.0 seconds a small 2.4 second improvement.
As I do not intend to use this version I have not performed a full migration and rebuild for my AM8 configuration, yet.
Download the latest VSCode compiler, as of January 2021, this is Version 1.52.1 and the name has been shortened to "Code"
Go to https://code.visualstudio.com and press the "Download for Mac" link.
Do not download the full Visual Studio Community 2019 for Mac 2019 package.
The package you need should download as a 95MB zip file named VSCode-darwin.zip
If you end up with a dmg file then you probably have the wrong package!
Install the Compiler
In finder double click on the package to unzip the file and create the application file Visual Studio Code.app
Drag this to your applications folder.
Start the Compiler and Authorise it
Start Visual Studio Code (VSCode) from Launchpad or Finder->Applications.
Depending your security preferences you will have to either accept the “file downloaded from internet” prompt or go into System Preferences -> Security & Privacy -> General Tab and change Allow Apps downloaded from “App Store and identified developers and then approve VSC.
Install the PlatformIO IDE (Integrated Development Environment) Extension
From the VSCode application Menu Bar select Code -> Preferences -> Extensions and start typing “PlatformIO IDE“ in the search box. After about 4 characters it should be the top entry in the list below.
At the time of writing (Jan 2021) the Current Version is 2.2.1.
Click the Install button next to the PlatformIO entry.
The install should only take a minute or so. I never trust programs to complete feature installs cleanly without a restart, so after clicking on the "Reload Now" button, when complete, I would close VSCode by selecting Code -> Quit.
Download the Latest Marlin Source Zip File (Approx 13Mb).
You have a choice here, you can either use VSCode's Clone Repository facility, or you can just download a copy of Marlin from their web site.
I prefer that latter as I remain in control of updates and it is likely that I will run with a working configuration for months if not years and I will not rebuild it every time it changes.
Go to http://marlinfw.org
Click on the “Download” Button.
Select the latest Release Option, at the time of writing (Jan 2021) this is 2.0.7.2
Click on “2.0.x.zip” The download should start and prompt you to choose a save folder. Once the download is complete, double click on the zip file in Finder and the Archive Utility will extract the source to the Marlin-2.0.x folder.
At this point I personally would rename this folder to include the version and download date e.g. M2072-0114
Then I would relocate the folder to the root or the home directory in order to shorten the filename path lengths in the compiler. As long path lengths cause lots of file not found errors !
Restart VSCode and load the Marlin Project
Start VSCode from Launchpad or Finder->Applications.
Wait until the PlatformIO IDE tab opens up. If it does not open automatically then click on the Alien face Icon in the left hand margin toolbar.Under “Quick Access” select “Open”.
Then in the “Open Project” pane navigate to your Marlin directory “M2072-0114” and click on the "Open M2072-0114" button. You may need to scroll down in the file selector window to find the button !
The Project's files will now appear in the left hand pane
Validate the Installation.
Try building the Marlin project as downloaded, with the default Mega2560 processor. I would not make any changes yet, as if the project does not compile we will know that the problem is purely with the installation and not our code changes.
At the bottom of the VSCode window is a blue bar, just click on the tick icon to start the build.
The first build is always the longest as it checks dependencies and then compiles all the files, later builds may only compile a subset of the files. On my daughters Pentium 987 this is 9 minutes, on the 2012 I7 Macbook around 3 minutes, and on the new Mac Mini M1 a fraction of a minute. If everything is OK you should see a green bar with something like “==== 1 succeeded in 00:02:25.234 ====”.
Note: You may also notice the “Problems(4)” counter and if you scroll up through the build window you will find some compiler warnings shown in yellow. This is normal for Marlin and I ignore all of these.
Now check the LPC1768/9 build libraries by rebuilding with the correct LPC1768/9 processor for your BTT Board.
Open the platformio.ini file in VSCode
In the left hand window make sure that your project directory is expanded. If you can not see the .github entry at the top then click on “>M2072-0114” to expand the file tree.
Now scroll down to the bottom and locate “platformio.ini” and left click on it to open it in an editor window in VSCode.
Search for “default_envs” (approximately line 21)
Change the line “default_envs = mega2560” to read
for the SKR 1.3 or non-turbo SKR 1.4 set “default_envs = LPC1768”
for the SKR 1.4 Turbo only set “default_envs = LPC1769”
Now save the modified file (File->Save) or (cmd+S)
Now in the left hand window click on the Marlin Directory to expand it and click on the Configuration.h file to open it in VSCode (as above)
Search for MOTHERBOARD (approximately line 130).
Change the line MOTHERBOARD BOARD_RAMPS_14_EFB” to read
for SKR 1.3 to MOTHERBOARD BOARD_BTT_SKR_V1_3
for SKR 1.4 to MOTHERBOARD BOARD_BTT_SKR_V1_4
for SKR 1.4 Turbo to MOTHERBOARD BOARD_BTT_SKR_V1_4_TURBO
Save the file (File->Save) or (cmd+S)
Now click on the Tick Icon in the bottom blue toolbar to start the build.
If successful there will be the “1 succeeded” showing in the build window.
On the M1 this now takes just 28.4 Seconds !
Now we can update the Marlin Configuration and rebuild for our Printer.
Now that we have proven the build system is good, we can go ahead and make the several hundred changes to configuration.h and configuration_adv.h for our own specific design of machine. Though I would also recommend breaking this step into several stages if you can.
When you are ready hit the Tick for a fresh and final build (we hope). It will however need modifying again once you have done the PID calibration runs.
Note: For the next 3 sections if you are using an SKR 1.4 or Turbo board then you will need to replace LPC1768 with LPC1769 below…
Copy firmware.bin to the SKR Board
There are 3 ways to get the firmware on the SKR.
Unplug the SDCard from the SKR and plug it in your computer then Manual copy the firmware.bin file to the SDCard
Mount the SKR Board and use Finder to copy firmware.bin file to the SKR
Mount the SKR Board and configure platform.io for autocopy
Manual Upload
If you have followed the instructions above you will not have configured the upload path to enable automatic transfer of the firmware.bin file to the printer.
Copy the .pio/build/LPC1768/firmware.bin file to the SKR’s SDCard replace it and reboot the printer to replace the existing firmware.
Note: As the output folder tree “.pio” starts with a ‘.’ the Mac OS will assume that this is a system directory and hide it from the end user. On a Mac in Finder you can toggle the ability to see hidden directories or files by using the keyboard toggle Cmd+ Shift+ ”.” all at the same time.
Mount the SKR Board and Manual Upload
I have labelled my printers SDCard SKR13 so that when the printer is powered up, and USB connected to my Mac, I get an SKR13 disk icon on my desktop. When I have a good build that I want on the printer I simply drag and drop the firmware.bin file to the SKR13 disk.
There are a couple of things that may catch you out on this approach:
to make this external disk icon appear you need to navigate to Finder -> Preferences -> General -> Show these items on the desktop and select External disks.
if you have configured Marlin to use the SDCARD as the gcode source , i.e. SDCARD_CONNECTION = ONBOARD in configuration_adv.h, then Marlin will, on power up, take ownership of the SDCard and it will become invisible to the Mac until you execute Release Media in the Marlin Menus and then replug the USB cable.
Configure Auto Upload
You can should you wish configure platformIO to copy the firmware.bin file to your USB connected printer by configuring the upload_port parameter in platformio.ini.
For an Arduino Mega this would be the USB serial port that the Mega is attached to, but for a BTT SKR board this is simply the path that the boards SDCard is mounted to when the SKR is connected by USB to your computer.
On Windows this done by adding upload_port = E:/ (where E is the drive letter or mount point for the SDcard) to the [env:LPC1768] section of platformIO.ini typically just after build_flags.
On Mac we simply use the drive mount point in my case this would be upload_port = /volumes/SKR13/
To execute the transfer after a Tick build then click on the -> (right arrow) next to the Tick icon. To build and automatically transfer simply start the build with the -> icon.