Modify and Generate D11-Firmware

Hello,
Please I need to make some slight modifications to D11-Firmware, compile again and reprogram mkrmotorshield (indeed is a nano motor carrier). I honestly haven't found the way to do it.

Which board should I chose from Tools->Boards ? I am not able to see "mkrmotorshield" as it is indicated in the header comments inside the D11-Firmware.ino file.

The idea is to use the Nano 33 IoT to send the new compiled binary through i2c as it is contemplated in Flasher.

I would like help please.

The MKRMotor Carrier is a shield that will work with several different MKR family boards. (You have a Nano-compatible version instead? In that case, it ought to work with several different Nano boars.)
You should set your "board" to "Nano 33 IOT", if that's the board that you're using that contains the CPU.

Never mind; I see you were talking about firmware in the motor board itself.

In order to make sure to provide a useful reference for everyone who might have a similar question in the future, I'm going to provide complete instructions. I hope you'll forgive me if some of this information is obvious to you. It might not be for everyone and I'd rather provide too much information than too little. Those who already know a step are welcome to skim over it.

Install the Arduino boards platform for the ATSAMD11 chip on the motor carrier

Unfortunately, Arduino never bothered to provide Boards Manager installation support for this platform, so you must install it manually.

  1. Start the Arduino IDE if it's not already running.
  2. Select File > Preferences from the Arduino IDE menus.
  3. Take note of the path shown in the "Sketchbook location" preference.
  4. Click the Cancel button.
  5. Download the boards platform by clicking this link:
    https://github.com/arduino/ArduinoCore-samd/archive/refs/heads/mkrmotorcarrier.zip
  6. Unzip the downloaded file ArduinoCore-samd-mkrmotorcarrier.zip
  7. Movve the unzipped folder to the following location:
    <sketchbook location>/hardware/arduino-development/samd
    
    The folder structure must look exactly like this:
    <sketchbook location>
    |_ hardware
       |_ arduino-development
          |_samd
             |_ boards.txt
             |_ etc.
    
  8. Restart the Arduino IDE.
    The IDE won't notice a manually installed platform until it has been restarted.

Install the "MattairTech SAM M0+ Boards" platform

This is done to get the version of the SAMD toolchain that is compatible with the boards platform used for the ATSAMD11 microcontroller on the motor carrier.

  1. Enter the following URL into the "Additional Boards Manager URLs" field:
    https://www.mattairtech.com/software/arduino/package_MattairTech_index.json
    
    If there are already Additional Boards Manager URLs there, separate them with commas.
  2. Click the OK button.
  3. Select Tools > Board > Boards Manager from the Arduino IDE's menus.
  4. Wait for the updates to finish.
  5. Scroll down through the list of boards platforms until you see "MattairTech SAM M0+ Boards". Click on it.
  6. From the dropdown version menu, select "1.l6.16".
  7. Click the Install button.
  8. Wait for the installation to finish.
  9. Click the Close button.

Install the "ArduinoMotorCarrier" library

This is necessary to get the "D11-Firmware" sketch.

If you already have the library installed, or you have downloaded the sketch alone, you can skip to the next step.

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE's menus.
  2. Wait for the update to finish.
  3. In the "Filter your search" field, type "ArduinoMotorCarrier".
  4. Press Enter.
  5. Scroll down through the list of libraries until you see "ArduinoMotorCarrier by Arduino". Click on it.
  6. Click the Install button.
  7. Wait for the installation to finish.
  8. Click the Close button.

Compile the firmware

  1. Select File > Preferences from the Arduino IDE menus.
  2. Take note of the path shown in the "Sketchbook location" preference.
  3. Click the Cancel button.
  4. Copy the folder at the following path:
    <sketchbook location>/libraries/ArduinoMotorCarrier/extras/D11-Firmware
    
    to some convenient location outside the library folder.
    The Arduino IDE treats the sketches in the libraries folders as read only and we need to be able to write to the sketch folder, so it's necessary to move it even if you don't need any modifications.
  5. Select File > Open from the Arduino IDE menus.
  6. Select the file D11-Firmware.ino from the folder where you moved the sketch in the previous step.
  7. Click the Open button.
  8. Make any modifications you would like to the "D11-Firmware" sketch.
  9. Select Tools > Board > MattairTech SAM M0+ Boards (in sketchbook) > MKR Motor Shield from the Arduino IDE menus.
  10. Select Tools > Bootloader Size > 4KB bootloader from the Arduino IDE menus.
  11. Select Tools > Pinmap > Complete from the Arduino IDE menus.
  12. Select Tools > Link time optimization > Enabled from the Arduino IDE menus.
  13. Select Sketch > Export compiled Binary from the Arduino IDE menus.
  14. Wait for the compilation to finish successfully.
  15. Select Sketch > Show Sketch Folder from the Arduino IDE menus.

This will open the "D11-Firmware" sketch folder in your file browser software. You will see there a file named D11-Firmware.ino.MKRMotorShield.bin. That is the firmware that was generated from the sketch you compiled.

If you have an Atmel ICE or other CMSIS-DAP compliant programmer/debug probe attached to the SWD header on the carrier then you can use Sketch > Upload Using Programmer instead of "Export compiled Binary" to directly flash the firmware to the ATSAMD11 via the Arduino IDE. In this case, you can use the Tools > Bootloader Size > No bootloader, which will give more program memory for the firmware sketch to use.

NOTE: This complex sketch contains essential source code under its src subfolder. Unfortunately, the classic Arduino IDE's File > Save As... functionality has a bug that causes the src subfolder to be lost when you save a sketch to a new location. So make sure you manually copy the sketch to a new location if you need multiple copies of it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.