Welcome! Log In Create A New Profile

Advanced

Marlin Sketch Too Big

Posted by unlimitedbacon 
Marlin Sketch Too Big
January 29, 2015 07:00PM
I'm trying to compile Marlin with graphic LCD support. The board I'm using is the Brainwave Pro with an AT90USB1286. It only has 128 Kib of flash memory, but the Arduino sketch compiles to 142,8000 bytes. Anyone have any ideas for reducing the firmware size enough to fit on this chip?
Re: Marlin Sketch Too Big
January 29, 2015 10:21PM
Marlin is really bloated with comments, extra languages, support for multiple board types, etc. You can delete anything that has a double slash // in front of it to start, and can carefully remove almost everything that is not related to your board...

Edited 1 time(s). Last edit at 01/29/2015 10:22PM by MindRealm.


-David

Find me online at:
Thingiverse
Instructables.com
LinkedIn
Facebook

Check out my FolgerTech Prusa i3 (plexi) at MindRealm.net
Re: Marlin Sketch Too Big
January 30, 2015 03:50AM
Removing comments will make no difference to the size of the compiled binary. The support for multiple board types is mostly implemented by conditional compilation, so there is little or no saving to make there. The graphic LCD support needs a font bitmap in the program memory, which takes up quite a few Kb. So it may simply not all fit in 128k.

Why not get a modern 32-bit controller such as Duet or Smoothie instead?



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Marlin Sketch Too Big
January 30, 2015 09:37AM
I disagree. Every character in the sketch increases the size of the compiled file. Give it a shot and note the file size in the status window in the Arduino IDE...


-David

Find me online at:
Thingiverse
Instructables.com
LinkedIn
Facebook

Check out my FolgerTech Prusa i3 (plexi) at MindRealm.net
Re: Marlin Sketch Too Big
January 30, 2015 11:43AM
Quote
MindRealm
Every character in the sketch increases the size of the compiled file. Give it a shot and note the file size in the status window in the Arduino IDE...

Perhaps you are confusing the size of the source code file with the sizeof the binary? Removing comments has no effect on the size of the compiled file. Neither does changing a veryLongVariableNameLikeThis to something shorter. Try it and you will see. But of course both changes will make the source file smaller.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Marlin Sketch Too Big
January 30, 2015 12:49PM
Quote
MindRealm
I disagree. Every character in the sketch increases the size of the compiled file. Give it a shot and note the file size in the status window in the Arduino IDE...

Comments and variable names in the source code are for human interpretation. The job of the compiler is to generate machine code that the microprocessor will understand. As the microprocessor doesn't need comments to run the code, they should be stripped by the compiler. Variable names simply become addresses in memory where the value of the variable can be stored.

So as dc42 mentioned, removing the comments should only effect the size of the source code, not the size of the compiled file that is uploaded to the chip. Though I to was thinking of trying to remove alternate languages and such for my delta firmware. Glad that dc42 pointed out the conditional compilation.
Re: Marlin Sketch Too Big
January 30, 2015 02:33PM
dc42, I would like to get a 32 bit board at some point but unfortunately thats not possible at the moment.

I tried disabling EEPROM support and that freed up a few kilobytes. By my calculations, the bitmaps in DOGMbitmaps.h are only 1082 bytes total. I could remove those, but thats still not enough to get it under 128 K. The firmware without LCD support is only about 90 KiB.
Re: Marlin Sketch Too Big
January 30, 2015 05:48PM
AFAIK the extra code size from adding the mono graphics display support comes from two places: the display library (which I think is U8glib), and the menu code. Can you tell from the map file how much each takes up?

You may be able to reduce the size of U8glib by removing options for supporting other displays, or other interface modes to the display.

Edited 1 time(s). Last edit at 01/30/2015 05:49PM by dc42.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Marlin Sketch Too Big
January 30, 2015 09:19PM
I have included the output of avr-objdump -t Marlin.cpp.elf
Attachments:
open | download - Marlin.map (113 KB)
Re: Marlin Sketch Too Big
February 03, 2015 05:16PM
Question, do you have to use Marlin?

I noticed the other day that Repetier v91 for my Rostock Mini was only 120k with LCD support, and I didn't have to add the U8glib library (which is likely why it looks worse).

Obviously this would just be a temporary fix until you could upgrade your board.
Re: Marlin Sketch Too Big
February 04, 2015 02:45PM
That could work, although Repetier doesn't support the Viki 2.0 (yet).
Re: Marlin Sketch Too Big
February 24, 2015 10:46AM
Did you managed to make a smaller firmware? I am also experiencing sketch-size problems with LCD support for Sanguinololu ATmega 644P. Would like to know what is possible. When it's to hard maybe it's an idea to just use a cheap tablet, I've heard there's a good app to send gcode and control reprap..
Re: Marlin Sketch Too Big
February 24, 2015 07:07PM
upgrade your chip to a 1284p for twice the ram, if its a DIP eg

If not, upgrade to a board with more ram Standard ramps, or any of the many varianats as long as they dont have a 644p.

If your feeling really adventurious try a smoothieboard, they are wonderful.
Re: Marlin Sketch Too Big
March 05, 2015 04:26AM
Interesting, and disturbing, I just hit the "Sketch too big" error too after adding Repraps Discount Graphic Smart LCD support and I DO already have a Atmega1284P with 128k code space !

I have a Melzi 2.0 with Atmega1284P MCU, all I've done is to add SD and graphic LCD support, and the compiled code is 22 bytes over 128K.

I only bought this board a couple of months ago...
Martin
Re: Marlin Sketch Too Big
March 05, 2015 04:39AM
I checked the before and after compiled size of Marlin development version with inclusion of the //#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER option.

Without = 75,624 bytes
With = 129,046 bytes

Wow that's a LOT of extra bytes for the smart controller, near double....

Can anyone else verify the code increase when //#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER is uncommented ?

Martin
Re: Marlin Sketch Too Big
March 06, 2015 05:55PM
Mr Sneezy, that is pretty close to the difference I see when I enable VIKI 2.0 support. I bet this can be reduced but I havn't gotten around to analyzing the symbol map and seeing what can be thrown out.
Re: Marlin Sketch Too Big
March 08, 2015 08:40PM
That's for confirming that for VIKI display.

I wonder if the Marlin Dev's know how close the code size is too 128K with the LCD added (as in a bit over 128K actually) ?
They may be able to do a bit of code size optimisation and get it well under, so the 128K reprap boards are not obsoleted so quickly.

Where do the Dev's go to get user feedback ?

Thanks,
Martin

Edited 1 time(s). Last edit at 03/08/2015 08:40PM by mr.sneezy.
Re: Marlin Sketch Too Big
March 18, 2015 05:45PM
I submitted an issue on the Marlin GitHub page.

[github.com]
Re: Marlin Sketch Too Big
March 19, 2015 08:31AM
Quote
unlimitedbacon
I submitted an issue on the Marlin GitHub page.

[github.com]
Hey thanks, I see there was some suggestions there that would reduce code size, and I've asked a question about which one makes sense to do first to get under 128K.
It's not hard to comment out a few lines of unused code, and worth noting that here for the next guy to make life easier.
I'll see if we get a good answer or two and transcribe it here.
Re: Marlin Sketch Too Big
March 19, 2015 09:54AM
Have you tried to flash the hex file generated by the Arduino IDE to the MCU?

When I compile Marlin it does generate a file that is 300K bytes in size, however when writing to the Arduino avrdude reports that only 122526 were written to flash i.e. much less than 128k (and yes I am using a 128x64 Graphics LCD).

Edited 1 time(s). Last edit at 03/19/2015 09:55AM by AndrewBCN.
Sorry, only registered users may post in this forum.

Click here to login