Duet Board Firmware Build Guide

This guide provides instructions for building modified RepRapFirmware for Duet3D control boards. These instructions follow the baseline process documented in the official RepRapFirmware build guide.

Note: For our Duet3D Main Board 6HC, we originally used firmware release 3.5.0, but for building custom RepRapFirmware we now use version 3.6.

MacOS Build Instructions

These instructions will guide you through setting up the development environment and building the firmware on macOS.

1. Install Required Tools

Using Homebrew makes it easy to install the required development tools:

# Install Homebrew if not already installed (see https://brew.sh/)
# Then install the necessary tools:
brew install --cask gcc-arm-embedded
brew install --cask eclipse-cpp

2. Clone Required Repositories

Create a local directory for the firmware and its dependencies, then clone the following repositories:

git clone https://github.com/Duet3D/RepRapFirmware.git --branch 3.6-dev
git clone https://github.com/Duet3D/CANlib.git --branch 3.6-dev
git clone https://github.com/Duet3D/CoreN2G.git --branch 3.6-dev
git clone https://github.com/Duet3D/FreeRTOS.git --branch 3.5-dev
git clone https://github.com/Duet3D/RRFLibraries.git --branch 3.5-dev
git clone https://github.com/Duet3D/WiFiSocketServerRTOS.git --branch main
git clone https://github.com/Duet3D/LibTinyusb.git --branch master

Note: If using your modified RepRapFirmware repository, ensure the directory name remains as RepRapFirmware.

3. Initialize Submodules

For CoreN2G and LibTinyusb, initialize their submodules:

git submodule update --init --recursive CoreN2G
git submodule update --init --recursive LibTinyusb

4. Set Up CrcAppender

Make the CrcAppender tool available to Eclipse:

# Navigate to the CrcAppender directory
cd RepRapFirmware/Tools/CrcAppender/macos-x86_64/

# Make CrcAppender executable (if it isn't already)
sudo chmod +x CrcAppender

# Copy to a directory in your system PATH
sudo cp CrcAppender /usr/local/bin/

5. Launch Eclipse

Launch Eclipse via the terminal to ensure it can find the CrcAppender tool:

  1. Find Eclipse in your Applications folder

  2. Right-click and select ‘Show Package Contents’

  3. Navigate to Contents/MacOS/ and find the ‘eclipse’ executable

  4. Drag this to a terminal window and press return to launch

  5. Keep the terminal window open while using Eclipse

6. Configure Eclipse Workspace

Set up your Eclipse workspace:

  1. Choose a location for your Eclipse workspace

  2. Configure the ArmGccPath variable:

    • Go to Eclipse → Settings → C/C++ → Build → Build Variables

    • Click “Add…”

    • Create variable name ArmGccPath with type Directory

    • Browse to the folder containing your ARM toolchain (e.g., /Applications/ArmGNUToolchain/14.2.rel1/arm-none-eabi/bin)

7. Import Projects

Import each repository as a project:

  1. Go to File → Open Projects from File System → Import source

  2. Select the directory to import

  3. Select all subfolders

  4. Click Finish

Import all these projects: CANLib, CoreN2G, FreeRTOS, LibTinyusb, RepRapFirmware, RRFLibraries, and WifiSocketServerRTOS.

8. Set Build Configurations

For each project, set the appropriate build configuration:

Project

Build Configuration

CANlib

SAME70_RTOS

CoreN2G

SAME70_CAN

FreeRTOS

SAME70

LibTinyusb

SAME70

RepRapFirmware

Duet3_MB6HC

RRFLibraries

SAME70_RTOS

To set a build configuration, right-click on the project → Build Configurations → Set Active.

9. Build the Firmware

  1. First, build the dependency projects individually:

    • CANlib

    • CoreN2G

    • FreeRTOS

    • LibTinyusb

    • RRFLibraries

    For each project, right-click and select “Build Project”.

  2. Once all dependencies are built successfully, build RepRapFirmware:

    • Right-click on the RepRapFirmware project

    • Select “Build Project”

Note: The WiFiSocketServerRTOS project is not built individually but is required for building RepRapFirmware.

  1. The final firmware binary will be located at: RepRapFirmware/Duet3_MB6HC/Duet3Firmware_MB6HC.bin

Windows Build Instructions

[Windows build instructions to be added]

Ubuntu Build Instructions

These instructions will guide you through setting up the development environment and building the firmware on Ubuntu.

1. Install Required Tools

Follow this tutorial to install eclipse-cpp

Check if the gcc arm toolchain is already installed with arm-none-eabi-gcc --version. If it is already installed, locate the path on your system. If not then follow the instructions below to install the toolchain.

  1. From the Toolchain Downloads Website, download the tar.xz file listed under x86_64 Linux hosted cross toolchains → AArch32 bare-metal target (arm-none-eabi)

  2. Unzip the files with the following command:
    sudo tar xf ~/Downloads/arm-gnu-toolchain-<YOUR_VERSION>-x86_64-arm-none-eabi.tar.xz -C /usr/share

  3. Create Symbolic Links for system-wide access

Note: This is not strictly required for the build procedure, but may be helpful later.

sudo ln -s /usr/share/arm-gnu-toolchain-<YOUR_VERSION>-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc /usr/bin/arm-none-eabi-gcc 
sudo ln -s /usr/share/arm-gnu-toolchain-<YOUR_VERSION>-x86_64-arm-none-eabi/bin/arm-none-eabi-g++ /usr/bin/arm-none-eabi-g++
sudo ln -s /usr/share/arm-gnu-toolchain-<YOUR_VERSION>-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb /usr/bin/arm-none-eabi-gdb
sudo ln -s /usr/share/arm-gnu-toolchain-<YOUR_VERSION>-x86_64-arm-none-eabi/bin/arm-none-eabi-size /usr/bin/arm-none-eabi-size
sudo ln -s /usr/share/arm-gnu-toolchain-<YOUR_VERSION>-x86_64-arm-none-eabi/bin/arm-none-eabi-objcopy /usr/bin/arm-none-eabi-objcopy

2. Clone Required Repositories

Create a local directory for the firmware and its dependencies, then clone the following repositories:

git clone https://github.com/CRM-Suite/RepRapFirmware.git --branch 3.6-dev
git clone https://github.com/Duet3D/CANlib.git --branch 3.6-dev
git clone https://github.com/Duet3D/CoreN2G.git --branch 3.6-dev
git clone https://github.com/Duet3D/FreeRTOS.git --branch 3.5-dev
git clone https://github.com/Duet3D/RRFLibraries.git --branch 3.5-dev
git clone https://github.com/Duet3D/WiFiSocketServerRTOS.git --branch main
git clone https://github.com/Duet3D/LibTinyusb.git --branch master

Note: If using your modified RepRapFirmware repository, ensure the directory name remains as RepRapFirmware.

3. Initialize Submodules

For CoreN2G and LibTinyusb, initialize their submodules:

cd ./CoreN2G
git submodule update --init --recursive .
cd ../LibTinyusb
git submodule update --init --recursive .

4. Set Up CrcAppender

Make the CrcAppender tool available to Eclipse:

# Navigate to the CrcAppender directory
cd RepRapFirmware/Tools/CrcAppender/linux-x86_64/

# Make CrcAppender executable (if it isn't already)
sudo chmod +x CrcAppender

# Copy to a directory in your system PATH
sudo cp CrcAppender /usr/local/bin/

5. Launch Eclipse

Launch Eclipse via the terminal or Desktop Shortcut:

  1. If the procedure to create a shortcut from the tutorial was followed, then Eclipse can be searched in the Activities Menu

  2. Otherwise, run eclipse in the terminal.

6. Configure Eclipse Workspace

Set up your Eclipse workspace:

  1. Choose a location for your Eclipse workspace

  2. Configure the ArmGccPath variable:

    • Go to Eclipse → Window → Preferences → C/C++ → Build → Build Variables

    • Click “Add…”

    • Create variable name ArmGccPath with type Directory

    • Browse to the folder containing your ARM toolchain (e.g., /usr/share/arm-gnu-toolchain-<YOUR_VERSION>-x86_64-arm-none-eabi/bin/)

7. Import Projects

Import each repository as a project:

  1. Go to File → Open Projects from File System → Import source

  2. Select the directory to import

  3. Select all subfolders

  4. Click Finish

Import all these projects: CANLib, CoreN2G, FreeRTOS, LibTinyusb, RepRapFirmware, RRFLibraries, and WifiSocketServerRTOS.

8. Set Build Configurations

For each project, set the appropriate build configuration:

Project

Build Configuration

CANlib

SAME70_RTOS

CoreN2G

SAME70_CAN

FreeRTOS

SAME70

LibTinyusb

SAME70

RepRapFirmware

Duet3_MB6HC

RRFLibraries

SAME70_RTOS

To set a build configuration, right-click on the project → Build Configurations → Set Active.

9. Build the Firmware

  1. First, build the dependency projects individually:

    • CANlib

    • CoreN2G

    • FreeRTOS

    • LibTinyusb

    • RRFLibraries

    For each project, right-click and select “Build Project”.

  2. Once all dependencies are built successfully, build RepRapFirmware:

    • Right-click on the RepRapFirmware project

    • Select “Build Project”

Note: The WiFiSocketServerRTOS project is not built individually but is required for building RepRapFirmware.

  1. The final firmware binary will be located at: RepRapFirmware/Duet3_MB6HC/Duet3Firmware_MB6HC.bin