Compiling Marlin for a Creality Ender-3

Preamble

Compiling Marlin for a Creality Ender-3.

Links

Bootloaders

Hex files

Other useful links

Stack exchange related

Summary

Processor/Board

The Creality Ender-3 controller board uses a ATmega1284, not the ATmega2560, so not a standard Mega2560 board derivative, therefore you can’t just compile for the Mega in Arduino IDE. You have to use the Sanguino files (boards.txt) etc. from here, github.com/Lauszus/Sanguino.

Download the .ZIP and unzip. Then place the Sanguino-master directory in:

Windows

...\My Documents\Arduino\hardware\

so that you have

...\My Documents\Arduino\hardware\Sanguino-master\avr

Mac OSX

~/Arduino/hardware/

so that you have

~/Arduino/hardware/Sanguino-master\avr

Restart the Arduino IDE, if it already open.

Bootloader

The controller board does not have a bootloader, see TH3D Unified Firmware Package

^ – CR-10, Ender 2, and Ender 3 Printers need the bootloader. You will need to follow the CR-10 bootloader guide to flash it before you can load the firmware. You can use our Uno kit to flash the bootloader on your board.

Best way is to export the .hex file and upload that. In the Arduino IDE use the menu Sketch > Export Compiled Binary to obtain a .hex file. Then upload that to the controller board using either How do I get a .hex file on to my Arduino? or this answer to How to install a .hex firmware?

Dependancy

Marlin depends upon the U8glib library, see github.com/olikraus/u8glib. Download the .ZIP and install into the Arduino IDE, via the menu option Sketch > Include Library > Add .ZIP Library…

There is no need to restart the Arduino IDE.

A sample boards.txt files

boards.txt from Using the ATmega1284 with the Arduino IDE, although this did not work too well, but included here as an example.
##############################################################
atmega1284e8.name=ATmega1284 @ 8 MHz (internal oscillator; BOD disabled)
atmega1284e8.upload.tool=arduinoisp

atmega1284e8.upload.maximum_size=131072
atmega1284e8.upload.maximum_data_size=16384

atmega1284e8.bootloader.tool=avrdude
atmega1284e8.bootloader.low_fuses=0xE2
atmega1284e8.bootloader.high_fuses=0x99
atmega1284e8.bootloader.extended_fuses=0xFF
atmega1284e8.bootloader.unlock_bits=0x3F
atmega1284e8.bootloader.lock_bits=0x3F
atmega1284e8.bootloader.file=empty.hex

atmega1284e8.build.mcu=atmega1284p
atmega1284e8.build.f_cpu=8000000L
atmega1284e8.build.board=AVR_ATMEGA1284E8
atmega1284e8.build.core=empty
atmega1284e8.build.variant=standard
##############################################################
atmega1284e1.name=ATmega1284 @ 1 MHz (internal oscillator; BOD disabled)
atmega1284e1.upload.tool=arduinoisp

atmega1284e1.upload.maximum_size=131072
atmega1284e1.upload.maximum_data_size=16384

atmega1284e1.bootloader.tool=avrdude
atmega1284e1.bootloader.low_fuses=0x62
atmega1284e1.bootloader.high_fuses=0x99
atmega1284e1.bootloader.extended_fuses=0xFF
atmega1284e1.bootloader.unlock_bits=0x3F
atmega1284e1.bootloader.lock_bits=0x3F
atmega1284e1.bootloader.file=empty.hex

atmega1284e1.build.mcu=atmega1284p
atmega1284e1.build.f_cpu=1000000L
atmega1284e1.build.board=AVR_ATMEGA1284E1
atmega1284e1.build.core=empty
atmega1284e1.build.variant=standard
##############################################################

Put this in a file, on OSX,/Users/user/Arduino/hardware/Creality/avras well as a file called platforms.txtcontaining the following lines

name=Creality
version=1.0

Like so:

Location of files
Location of files

This creates a menu:

Created menu for ATmega1284
Created menu for ATmega1284

However, as stated, this doesn’t work correctly when compiling, as this error is produced almost immediately:

Arduino: 1.8.3 (Mac OS X), Board: "ATmega1284 @ 8 MHz (internal oscillator; BOD disabled)"

recipe.preproc.macros pattern is missing

Error compiling for board ATmega1284 @ 8 MHz (internal oscillator; BOD disabled).

The MightyCore helped compilation a lot, and the compilation continues until the link stage, but resulted in an error:

[...] program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: [...]\AppData\Local\Temp\arduino_build_855633/Marlin.ino.elf section `.text' will not fit in region `text'

.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s