1. Got a question or need help troubleshooting? Post to the troubleshooting forum or Search the forums!

Learning to compile the Marlin Firmware - step by step, cause I was a dummy...

Discussion in 'Troubleshooting' started by supercazzola, Feb 10, 2018.

  1. supercazzola

    supercazzola Active Member

    Joined:
    Jun 1, 2017
    Messages:
    424
    Likes Received:
    111
    I am starting from scratch. I had zero experience compiling Marlin. Took me half the day. Figured I would share the steps so you, too, could start to play with the features in Marlin that Robo is not using yet.

    Hope this post will help others too timid to try. It is really not all that crazy, but seems overwhelming at first.

    Here is what I did.
    Before I tackled compiling Waldo's version of the Marlin f/w, I started with Robo's, just to convince myself I could. Then I moved on to the excellent work @WheresWaldo did, with the hopes of using UBL and eventually the g-code controlled lighting mod. I already have the light mod that @Kilrah came up with, and love it. Thank you both for all of your contributions to these forums. Along with others, you have helped me numerous times.

    Without further delay, the steps:

    1. installed GitHub desktop from here: https://desktop.github.com/
    2. installed Arduino IDE from here: https://www.arduino.cc/en/Main/Software
    3. in the GitHub IDE, I downloaded the Robo f/w from https://github.com/Robo3D/Marlin
    4. in the Arduino IDE, I opened this file: Marlin.ino
    5. in the Arduino IDE, I tried to compile, and quickly got an error: Pins for this chip not defined in Arduino.h!
    6. in the Arduino IDE, I set the board type to Arduino / Genuino Mega or Mega 2560. I got this info from reading through @WheresWaldo comments in his code. It wasn't obvious to me, so that is why I am emphasizing it here. Tried to compile again, success in compiling.
    7. in the Arduino IDE, I chose sketch, export compiled binary. That made the hex files (for R2 and C2).
    8. now the fun began. I downloaded @WheresWaldo version from here: https://github.com/WheresWaldo/Marlin_for_R2/tree/1.1.8
    9. in the Arduino IDE, I opened the Marlin.ino file inside the folder from @WheresWaldo
    10. compiled it and exported the hex file. Now once the parts come in from China, I will be able to make the light mods as specified in this excellent mod: http://community.robo3d.com/index.php?threads/g-code-controlled-case-lighting.19871/
    In the meantime, I will load the hex file from #10 above and try to get UBL working with my R2, as outlined by @WheresWaldo in this thread: http://community.robo3d.com/index.php?threads/marlin-for-the-r2-ubl-enabled.19405/

    Thanks again, and I hope this thread will help owners of the R2 play more with the capabilities of Marlin on their R2.
     
    #1 supercazzola, Feb 10, 2018
    Last edited: Feb 10, 2018
  2. tkoco

    tkoco - -.- --- -.-. ---
    Staff Member

    Joined:
    May 7, 2018
    Messages:
    721
    Likes Received:
    273
    Is there a way to "unbrick" the main board when it refuses to flash firmware?
     
  3. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    23,912
    Likes Received:
    7,338
    The Arduino Mega has a couple of ways to forcibly clear/overwrite the program memory. I am not sure if the Robo custom board supports any of that...
     
  4. tkoco

    tkoco - -.- --- -.-. ---
    Staff Member

    Joined:
    May 7, 2018
    Messages:
    721
    Likes Received:
    273
    Any links to that information?
     
  5. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    23,912
    Likes Received:
    7,338
  6. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    23,912
    Likes Received:
    7,338
    It is possible (but not likely) that Robo used a custom bootloader on their board.
     
  7. tkoco

    tkoco - -.- --- -.-. ---
    Staff Member

    Joined:
    May 7, 2018
    Messages:
    721
    Likes Received:
    273
    What I have learned from my bricking experience:

    1) It is best to have an external computer talk directly to the main Arduino board. Using the Octoprint interface can result in a non-responsive Arduino board - especially if you are experimenting with the Marlin code.

    2) A non-responsive Arduino can be rescued.

    2a) You will need the Arduino IDE as described above by @supercazzola ( for Linux users, install this as root via sudo. ).
    2b) Then down load the source for the latest Robo Marlin firmware ( See R2 FAQ ).
    2c) Unpack the source code in the Arduino directory ( created by installing the Arduino IDE )
    2d) Then load the Marlin.ino file ( as described above ) . You may have to drill down to find the file.
    2e) Unplug the Raspberry Pi from the Arduino board and plug in the external computer. ( via USB cabling ). Power up the R2 if not already turned on.
    2f) Use the upload command. For Linux users, you will need to add your login name to the dialout group found in the /etc/group file. Log out and then login for it to take effect. It is a permissions issue with Linux.
    2g) Power cycle the R2 printer. ( turn off and then turn on )
     
    #7 tkoco, Aug 12, 2020
    Last edited: Aug 12, 2020
    mark tomlinson likes this.
  8. Lance Weston

    Lance Weston Active Member

    Joined:
    Jun 2, 2018
    Messages:
    664
    Likes Received:
    230

    All of the codes I have submitted and are working were compile with Marlin Arduino 1.8.9 and here is my link:
    https://drive.google.com/file/d/1IyeNEKdW3KH3-SoI0Oe_LZBBG-V0agYO/view?usp=sharing

    This is the last code generated and I got it from Jason on his last day of work. It is completely tested and working. It is the basis for all of my code modifications, here is my link:
    https://drive.google.com/file/d/1-9G3DqEJBj6Ij6g693GBRFivEWTn7be-/view?usp=sharing

    I found that I had to define a port number as well even when not programming a board directly. When programming Ramps boards, the first programming had to be at the computer. Thereafter, if the uploading plugin is installed in Octoprint I could take the hex code generated by the compile and put it on a USB drive. Then using the LCD got to files and just load the hex file.
     
    supercazzola likes this.
  9. tkoco

    tkoco - -.- --- -.-. ---
    Staff Member

    Joined:
    May 7, 2018
    Messages:
    721
    Likes Received:
    273
    I noticed that when I compile Marlin, I get 2 *.hex files generated. One of them is labeled as "*boot*.hex" . Which firmware is the correct one to upload to the Arduino board?
     
  10. tkoco

    tkoco - -.- --- -.-. ---
    Staff Member

    Joined:
    May 7, 2018
    Messages:
    721
    Likes Received:
    273
  11. Lance Weston

    Lance Weston Active Member

    Joined:
    Jun 2, 2018
    Messages:
    664
    Likes Received:
    230
    do not load the boot hex, you will destroy your board, or so I have read.
     
  12. Lance Weston

    Lance Weston Active Member

    Joined:
    Jun 2, 2018
    Messages:
    664
    Likes Received:
    230
  13. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    23,912
    Likes Received:
    7,338
    Some boards are OK with redoing the bootloader (which is what the one named boot.hex is), but 99 times out of a 100 you really do not need to. Not all boards are OK with you reloading the bootloader :)

    Just use the other one.
     
  14. tkoco

    tkoco - -.- --- -.-. ---
    Staff Member

    Joined:
    May 7, 2018
    Messages:
    721
    Likes Received:
    273
    That is nice to know. Thank you Mark.
     
  15. tkoco

    tkoco - -.- --- -.-. ---
    Staff Member

    Joined:
    May 7, 2018
    Messages:
    721
    Likes Received:
    273
  16. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    23,912
    Likes Received:
    7,338
    I will download it for you. You have a google drive/one drive/etc you want me to upload it to for you?
     
  17. Lance Weston

    Lance Weston Active Member

    Joined:
    Jun 2, 2018
    Messages:
    664
    Likes Received:
    230
    sorry, I left it tagged for only one person. I re-tagged file for everyone to download
     
    mark tomlinson likes this.
  18. tkoco

    tkoco - -.- --- -.-. ---
    Staff Member

    Joined:
    May 7, 2018
    Messages:
    721
    Likes Received:
    273
    Got it. Thank you, Lance
     

Share This Page