Welcome! Log In Create A New Profile

Advanced

Problem building Duet firmware

Posted by dc42 
Problem building Duet firmware
December 21, 2013 01:15PM
I'm trying to rebuild the Duet firmware so that I can sort out the problem with the IR sensor. I've downloaded the firmware source from [github.com] and also installed all the libraries at [github.com] as mentioned in the README file. But when I try to built it under Arduino 1.5.5 I get a lot of errors, starting with::

In file included from /Platform.h:2,
from /RepRapFirmware.h:52,
from GCodes.cpp:26:
C:\Users\David\Documents\Arduino\libraries\SD_HSMCI/SD_HSMCI.h:52:17: error: sam.h: No such file or directory
In file included from /RepRapFirmware.h:52,
from GCodes.cpp:26:
/Platform.h:73:26: error: ethernet_sam.h: No such file or directory

Where can I find these two missing include files?
Re: Problem building Duet firmware
December 21, 2013 05:12PM
@DC42, I just updated my firmware from [github.com]
I.e. all compiled ready to use.

You may also want to see my post here [forums.reprap.org]
with Markus' reply which was most useful.
Re: Problem building Duet firmware
December 21, 2013 07:08PM
Hi Treth, I'm not trying to update my firmware to latest (I've already done that), I'm interested in modifying it so that I can solve the problem that I (and others) have of the IR sensor being too sensitive to ambient lighting conditions.
Re: Problem building Duet firmware
December 21, 2013 08:29PM
I'll ask Adrian - I can't say I've tried building it. It looks like it's missing the SD card libraries. Stay tuned.

Ian
RepRapPro tech support
Re: Problem building Duet firmware
December 21, 2013 08:38PM
Hi ,
You need proper SD and Ethernet library, I don't know if this suit your duet ? [github.com]
[github.com]
Re: Problem building Duet firmware
December 22, 2013 03:20AM
Hi tru168,

Thanks, however that doesn't address the problem. I already have the Ethernet and SD libraries. The SD header file you linked to on github looks the same as the one I already have, and has the same references to sam.h and undefined types U8, S8 etc. The Ethernet library you linked to still doesn't have the file Ethernet_sam.h.

I found there is a file called sam.h in the Arduino core, however it isn't on the include file search path.

My guess is that the Duet firmware is built with an old version of the Arduino IDE, and that between that old version and the current 1.5.5, the search path has been changed and the Ethernet library for Due has been merged into the standard one. Maybe Ian can confirm tomorrow which version of Arduino IDE is needed to build the firmware?

[EDIT: File platform.h is already including ethernet.h, so I guess ethernet_sam.h is an additional file that is required.]

Edited 1 time(s). Last edit at 12/22/2013 03:22AM by dc42.
Re: Problem building Duet firmware
December 22, 2013 06:07AM
Adrian uses Eclipse to write the firmware, not Arduino IDE. Not sure that helps! I'm waiting for a response from him.

Ian
RepRapPro tech support
Re: Problem building Duet firmware
December 22, 2013 09:36AM
Oops! Been with Marlin firmware for quite sometimes and forgot this new Duet board not running arduino based Marlin firmware!

Edited 1 time(s). Last edit at 12/22/2013 09:38AM by tru168.
Re: Problem building Duet firmware
December 28, 2013 12:03AM
Hello dc42!

This seems to work for me (on Linux Mint 15 both 32-bit & 64-bit)

It produces a RepRapFirmware.bin, that I have not flashed yet...
I'm waiting for a brave soul to test if the binary is valid / non-lethal grinning smiley

Update: The binary is valid and the "Upload Sketch" button works, see step 9

Step 1 - Installing Arduino 1.5.4 with Due support

Download 32-bit @ [downloads.arduino.cc]
Download 64-bit @ [downloads.arduino.cc]
  • Extract and move to /usr/local/arduino-1.5.4
Step 2 - Installing Eclipse Juno C/C++ SR2
  • Create Eclipse workspace folder: /home/user/workspace
  • Create RepRapFirmware project folder: /home/user/workspace/RepRapFirmware
  • Create Arduino library folder: /home/user/workspace/RepRapFirmware/Libraries
Download 32-bit @ [www.eclipse.org]
Download 64-bit @ [www.eclipse.org]
  • Extract and move to /usr/local/eclipse
  • Start Eclipse: /usr/local/eclipse/eclipse
  • Check "Use this as the default" to use this workspace by default
  • Click "OK" to accept workspace location /home/user/workspace
Step 3 - Installing the Arduino Eclipse plugin
  • Click "Help" menu -> Install New Software...
  • Enter "Work with" URL:
    http://www.baeyens.it/eclipse/V2
  • Press enter to refresh the software source
  • Uncheck "Group items by category" checkbox
  • Select "Arduino eclipse extensions" item
  • Click "Next", "Next", accept the agreement
  • Click "Finish" to install the Arduino plugin
  • Click "OK" when warned for unsigned content
  • Click "Yes" to restart Eclipse
Step 4 - Configuring the Arduino Eclipse plugin
  • Click "Window" menu -> "Preferences"
  • Unfold "General"
  • Click "Workspace"
  • Check "Save automatically before build"
  • Click "Arduino"
  • Enter "Arduino IDE path" /usr/local/arduino-1.5.4
  • Enter "Arduino Library path" /home/user/workspace/RepRapFirmware/Libraries
  • Click "OK" to apply the changes
Step 5 - Create RepRapFirmware project
  • Close the "Welcome to Eclipse" screen
  • Click "Arduino" menu -> "New Sketch"
  • Enter "Project name" RepRapFirmware
  • Click "Next"
  • Select "/usr/local/arduino-1.5.4/hardware/arduino/sam/boards.txt"
  • Select "Board" Arduino Due (Native USB Port)
  • Enter "Port" /dev/ttyACM0 (Your port name can be different!)
  • Click "Finish"
  • Exit Eclipse
Step 6 - Download the RepRapFirmware source code
  • Visit RepRapFirmware @ [github.com]
  • Click "Download ZIP" button on the right side of the page
  • Copy contents of "RepRapFirmware-master.zip" to /home/user/workspace/RepRapFirmware
  • Click "Replace all" when other files with the same name already exist.
Step 7 - Copy the Arduino libraries to the firmware folder
  • Visit Arduino libraries @ [github.com]
  • Click "Download ZIP" button on the right side of the page
  • Extract "Arduino-libraries-master.zip" to /home/user/workspace/RepRapFirmware/Libraries
  • Copy /usr/local/arduino-1.5.4/hardware/arduino/sam/libraries/Wire to /home/user/workspace/RepRapFirmware/Libraries
  • The Libraries folder should contain: EMAC, Lwip, MCP4461, SamNonDuePin, SD_HSMCI and Wire
Step 8 - Creating the Due firmware binary
  • Start Eclipse: /usr/local/eclipse/eclipse
  • Click "Project" menu -> "Build all"
  • Console shows the compiler output
Step 9 - Install the firmware on the Duet
  • Press Duet "MCU Erase" button
  • Press Duet "Reset" button
  • Wait while the board restarts
  • This can take up to 40 seconds
  • Click "Upload Sketch" button
  • Console shows the upload progress
Have fun!

Edited 2 time(s). Last edit at 12/28/2013 06:44PM by 3D-ES.


RS-Online Ormerod #263, Kossel mini with Minitronics, Prusa i3 MK2
Re: Problem building Duet firmware
December 28, 2013 02:50AM
Thanks, 3D-ES! I was going to try to get it building under Atmel Studio, but if Eclipse has Arduino integration (which I wasn't aware of) then I guess using Eclipse will be easier. I'll give it a go.
Re: Problem building Duet firmware
December 28, 2013 09:25AM
I didn't know it either, but I already like it smiling smiley

The Arduino plugin is based on the AVR Eclipse plugin: [forum.arduino.cc]

An old but interesting video of the developer demonstrating the serial monitor using V1 of the plugin and Arduino 1.0.1: [eclipse.baeyens.it]
Jan is using Windows so I guess the RepRapFirmware can also be built on a Windows platform if you convert the Linux paths to Windows paths.

Arduino Eclipse plugin FAQ: [www.baeyens.it]
Arduino forum discussion about the plugin: [forum.arduino.cc]
Information about using Eclipse: [playground.arduino.cc]
Re: Problem building Duet firmware
December 30, 2013 03:14PM
Adrian has updated the firmware build instructions, in the bottom part of the README here: [github.com]

Quote
Adrian Bowyer

Compiling from Source

RepRap Frimware was developed using the Eclipse IDE, which is much more powerful for big software projects than the Arduino IDE.

We use Eclipse Juno, which is available here:

[www.eclipse.org]

You will also need the Eclipse Arduino support:

[www.baeyens.it]

And the Arduino IDE itself (make sure you get the one for the Due/Duet - version 1.5.5 at the time of writing):

[arduino.cc]

Finally you will need our libraries for driving the periphearls:

[github.com]

Start by getting the Arduino IDE programming your Duet with a simple Hello World program that prints to the USB (SerialUSB.print("Hello World"); on the Due/Duet, not Serial.print("Hello World");... )

Then install Eclipse and the Arduino plugin.

Make temporary copise of RepRapFirmware.cpp and RepRapFirmware.h from your download in another folder (you will only need to do this once).

Finally use Eclipse to open the Arduino project called RepRapFirmware in the folder where you have downloaded the RepRap Firmware code. Tell Eclipse to use the Arduino-libraries files you downloaded as the local libraries. Eclipse will complain that the project already exists (which it does - it is your download). Ignore this and it will open the project anyway.

Annoyingly the first time it may also overwrite RepRapFirmware.cpp and RepRapFirmware.h. So close the project, overwrite its overwrites with the two files you saved, open the project again and refresh it. Everything should now be ship-shape. Add the libraries

Wire
EMAC
Lwip
MCP4461
SamNonDuePin
SD_HSMCI

to your project. Under no circumstances be tempted to add standard Arduino libraries for devices like Ethernet - these are for the Due, and will not work on the Duet.

You should now be able to compile the code and upload the result to the Duet.

Ian
RepRapPro tech support
Re: Problem building Duet firmware
December 31, 2013 08:43AM
Hello Ian,

I am missing the Wire library when I follow Adrian's instructions...

Update: Sorry, false alarm, I don't know what I did wrong before, it seems to be compiling fine now without the library here...

The project configuration points to the Wire library in ${workspace_loc:/RepRapFirmware/Libraries/Wire}
since the Arduino-libraries collection does not include the Wire library, it is not installed and cannot be found.

I have found this library in /usr/local/arduino-1.5.4/hardware/arduino/sam/libraries/

Things that could be done to fix this issue:

OR: Add the Wire library folder to the RepRapPro Arduino library collection.
OR: Add the instruction to manually copy the Wire library to the Libraries folder.
OR: Change .cproject to point to /usr/local/arduino-1.5.4/hardware/arduino/sam/libraries/Wire

Also: When you use arduino-1.5.5 instead of 1.5.4 you need to edit some paths,
the project configuration file in the repository is configured to use Arduino 1.5.4!

Edited 1 time(s). Last edit at 12/31/2013 08:52AM by 3D-ES.
Re: Problem building Duet firmware
January 01, 2014 01:47PM
Ian, thanks for the instructions. Unfortunately, I'm still having problems. When I try to open the project in Eclipse, I get these errors from the Arduino plugin:



Then when I try to build the project, it says it can't find make.exe. I guess I can edit the path to fix that one (shame Eclipse doesn't come with an installer that sets it up already), but I don't know what to do about the null pointer exceptions. As you may have guessed, I'm running under Windows.



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: Problem building Duet firmware
January 01, 2014 04:38PM
Hi dc42,

I have managed to build the firmware on Windows Vista,
since I have not seen your error before, I don't know the fix.

I have added my working project configuration files to this post,
you might be able to find out what is missing in your configuration.

Some info:

I have my workspace at C:\Users\Daan\workspace
I have installed Arduino 1.5.4 1.5.5 to C:\Program files\Arduino
I have installed Eclipse Juno Service Release 2

Update 1:

I have flashed the firmware and I am not quite there yet...!
Pronterface reports that my nozzle temperature is 300C tongue sticking out smiley

Update 2:

The temperature reading is normal now.
I had to replace Arduino 1.5.5 with 1.5.4!

You can manually update the file org.eclipse.cdt.core.prefs:
  • Change A.RUNTIME.IDE.VERSION/value=155 to 154
  • Change A.VERSION/value=1.5.5 to 1.5.4
I have replaced the file with a 1.5.4 version, you don't need to edit.

Edited 3 time(s). Last edit at 01/01/2014 05:22PM by 3D-ES.


RS-Online Ormerod #263, Kossel mini with Minitronics, Prusa i3 MK2
Attachments:
open | download - .cproject (6.8 KB)
open | download - .project (2.4 KB)
open | download - language.settings.xml (896 bytes)
open | download - org.eclipse.cdt.core.prefs (34.6 KB)
Re: Problem building Duet firmware
January 02, 2014 08:17AM
I finally got the firmware to build, by a combination of installing 32-bit Eclipse instead of 64-bit, choosing a path for my Eclipse workspace with no spaces in it, installing Arduino 1.5.4 in a path with no spaces in it, and editing lots of paths in the configuration files (looks like it was the same changes 3DES made). I'll test whether the rebuilt firmware works later today, but right now I need to go out for a walk to work off some frustration.

Edited 1 time(s). Last edit at 01/02/2014 08:18AM 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: Problem building Duet firmware
January 02, 2014 08:41AM
Hi dc42

Sorry this has been difficult for you. I expect Eclipse works differently under Ubuntu (which is what Adrian uses) and I haven't had time to do this myself, either, to troubleshoot the problems. Hopefully you're sorted now. Hope you had a nice walk!

Ian
RepRapPro tech support
Re: Problem building Duet firmware
January 02, 2014 09:13AM
Awesome! Thank you for not giving up!

Now you are able to compile I have a question for you:

Can you compile the firmware without any changes and test if it runs stable?

When I am using the original RRP firmware binary, my Ormerod has never crashed.
When I am using my own compiled firmware binary it seems to crash regurlarly at random:

- The printer stops printing.
- The communication times out.
- The nozzle got a bit overheated...

This almost looks like I experience brown-out problems when running my firmware.
But it also happens when I am not using the bed heater, so it must be something else...

I have compiled RepRapFirmware.bin on 32-bit Linux, 64-bit Linux and 32-bit Windows,
all three files are nearly identical, only some timestamps and path locations are different.

When I compare my binaries with the RepRapPro binary, I find that there
is a chunk of code at hex offset 0x3940 that seems to be extra / different.

Maybe the build environment / configuration at RepRapPro is different?

Since I can't read binary data I am curious if you achieve different results.
I don't want to bother RepRapPro yet, it might be something stupid I did...

So... If you experience instability, please complain here, I am feeling alone right now grinning smiley
Re: Problem building Duet firmware
January 02, 2014 12:16PM
Doing a binary diff of the RepRapFirmware.bin file I built with the one on github, I get much the same thing. There are quite a few sporadic diffs, mostly values increased by either 0x1C or 0x38, so probably jump/call destination addresses. Then starting at offset 0x3948 the file is completely different. So the code at that address has apparently changed and grown.

Maybe Adrian is using an older version of the libraries?

I've run out of filament, and I haven't found a local supplier, so I won't be printing anything for a day or two.



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: Problem building Duet firmware
January 02, 2014 10:55PM
I am running on a built firmware and so far it seems as stable as the orig.

I built it on windows 7 using more or less the instructions in Adrians readme.
All worked fine except for having to add 2 include paths as eclipse could not find a couple of .h files.

I am using the Arduino 1.5.4.

Most of the 'trick' to making it work without a LOT of path changes was to NOT copy the settings file from the orig repositary

i.e. install Eclipse + arduino software exactly as the readme.

Create a new arduino project "RepRapFirmware"

Close the project.

Copy all of the github repositary EXCEPT the settings files (.setttings and .cproject)

Make a new directory workspace\RepRapFirmware\Libraries and copy the library modules into it

Reopen the RepRapFirmware project, Refresh (F5) go to Arduino/add libraries, you should see all the 'extra libs' available as private libraries
add these + the arduino Wire library into the project

Build.

I had 2 missing .h files, and had to add the approriate directories into the C include directories in the project.

Have not done a binary diff of the resulting firmware yet (need to get a binary capable diff for windows)
but the resulting binary seems to be working as well as the official released one.
Re: Problem building Duet firmware
January 03, 2014 06:44AM
Thanks for restoring my hope! smiling smiley

My firmware usually crashes in 3 minutes,
so I am obviously doing something different!

@ dc42:

Mine even crashes when I am doing nothing,
so you can test if it runs stable doing nothing...

My scenario:

- I plug in the USB cable
- Windows sound: Device connected!
- Wait a few minutes while doing nothing.
- Windows sound: Device disconnected!
- Windows sound: Device connected!
- And now it won't respond anymore...

I don't have much time this weekend,
I'll try to get back to this problem asap!


RS-Online Ormerod #263, Kossel mini with Minitronics, Prusa i3 MK2
Re: Problem building Duet firmware
January 03, 2014 07:58AM
I have uploaded my repositary to github

[github.com]

There are no changes at all to the code base, just the build environment to allow it to be built on windows.

I included the libs I used in the base so it should build exactly as mine is which seems to work OK.

For ref my setup has Arduino-1.5.4 and eclipse and the workspace all loaded on the root of the X:\
x:\arduino-1.5.4
x:\eclipse
x:\workspace

Chris
Re: Problem building Duet firmware
January 03, 2014 09:14AM
If you get disconnects on the USB, it is often due to interference on the USB, this is a commonly reported problem with many RepRap type setups. I find it happens when my fridge switches. Using better quality USB cables, shorter cables, a USB hub, or attaching ferrites to the cable all may help.

If the heaters continue running, then it is probably a USB drop out, although several other things are possible, e.g. a CPU reset.

Due to a Windows bug, you need to close the COM port, disconnect and reconnect the USB cable, then reopen the port to get the comms back, In some cases you need to shut down the application before replugging the USB.


What is Open Source?
What is Open Source Hardware?
Open Source in a nutshell: the Four Freedoms
CC BY-NC is not an Open Source license
Re: Problem building Duet firmware
January 03, 2014 12:15PM
I've now loaded the firmware I built, and run some tests on the bed heater, checking XYZ axis movement at intervals. It's been running for 30 50 minutes now with no problems. So the rebuilt firmware seems OK.

I also took a look at the map file. If the .bin file is a straight binary image, with no extra header, then the 0x3948 offset where the code is different corresponds exactly to the address of function rstc_set_external_reset in module ./Libraries/Lwip/lwip/src/sam/netif/ethernetif.c. The strange thing is that although this file is called from ethernetif.c, it is actually defined in a .c file in the Arduino 1.5.4 library. Maybe the linker is inlining it (does the gnu linker do that?).

Edited 1 time(s). Last edit at 01/03/2014 12:15PM 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: Problem building Duet firmware
January 03, 2014 08:46PM
>>Maybe the linker is inlining it (does the gnu linker do that?).

It can, but I thought you had to ask for it explicitly, then again the eclipse build is so complicated it could be asking for anything at all !!

-----
-flto[=n]
This option runs the standard link-time optimizer. When invoked with source code, it generates GIMPLE (one of GCC's internal representations) and writes it to special ELF sections in the object file. When the object files are linked together, all the function bodies are read from these ELF sections and instantiated as if they had been part of the same translation unit.
Re: Problem building Duet firmware
January 07, 2014 05:09AM
Thank you all.
I can now compile the code, I was pulling my hair out cursing at the errors that I was getting.

Paul


RS Ormerod No 436
Re: Problem building Duet firmware
January 07, 2014 01:08PM
Out of interest I have tried to compile the firmware with the 1.5.5 libraries. I just get a problem with network/ethernet.sam. Eclipse is reporting

Unresolved inclusion:
- fatal error: lwip/src/include/lwip/netif.h: No such file or directory

But it is there so anyone any idea what is going wrong?

Thanks
Alan
Re: Problem building Duet firmware
January 07, 2014 01:14PM
Hello Alan

Quote
alanbattersby
Out of interest I have tried to compile the firmware with the 1.5.5 libraries. I just get a problem with network/ethernet.sam. Eclipse is reporting

Unresolved inclusion:
- fatal error: lwip/src/include/lwip/netif.h: No such file or directory

But it is there so anyone any idea what is going wrong?

Thanks
Alan

I haven't yet, I am still trying to calibrate my printer, but its on my to do list.

Paul


RS Ormerod No 436
Re: Problem building Duet firmware
January 09, 2014 03:45AM
@bobc

Quote

If you get disconnects on the USB, it is often due to interference on the USB, this is a commonly reported problem with many RepRap type setups. I find it happens when my fridge switches. Using better quality USB cables, shorter cables, a USB hub, or attaching ferrites to the cable all may help.

Thank you very much!

Yesterday the Ormerod lost it's connection using the official firmware...!

I have replaced the USB cable and have printed for 3 hours without any problems smiling smiley
I don't understand why that cable suddenly picks up interference, it used to work fine!

My firmware seems to be running stable now, even if the binary contents is different!

@allenbattersby

I have seen this error, and I 'fixed' it by starting again with a fresh workspace...
There seems to be a magic path that you need to follow when building the firmware.

My Arduino 1.5.5 firmware did not work, my temperature readings were incorrect...


RS-Online Ormerod #263, Kossel mini with Minitronics, Prusa i3 MK2
Re: Problem building Duet firmware
January 09, 2014 04:00AM
Quote
3D-ES
My firmware seems to be running stable now, even if the binary contents is different!

RRP have now updated the libraries in github with the changes they were using. I can now build binaries that match the released ones, save for a few strings near the end which have the build path embedded within them.

Edited 1 time(s). Last edit at 01/09/2014 04:01AM 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].
Sorry, only registered users may post in this forum.

Click here to login