Skip to content

Creating a custom board for Arduino IDE

AndunHH edited this page Aug 18, 2024 · 1 revision

This page describes how to create a custom board for the arduino IDE. This is necessary, because our spacemouse should report itself as a spacemouse to the PC and not as an arduino any more.

Custom board to emulate the space mouse

The boards.txt file needs an additional board definition, which tells the microprocessor to report the USB identifiers correctly and emulate the 3dconnexion space-mouse.

boards.txt on linux

You find the boards.txt in ~/.arduino15/packages/SparkFun/hardware/avr/1.1.13. If this folder doesn't exist you need to install board support for SparkFun Arduinos.

boards.txt on mac

Please read https://gist.github.com/maunsen/8dbee2bddef027b04a450241c7d36668

boards.txt on windows

C:\Users\AppData\Local\Arduino15\packages\arduino\hardware

Code to add to boards.txt

Here is the addition, which needs to be copied into the boards.txt (e.g. at the bottom).

# Add this to the bottom your boards.txt

################################################################################
################################## Spacemouse based on Pro Micro ###################################
################################################################################
spacemouse.name=SpaceMouse

spacemouse.upload.tool=avrdude
spacemouse.upload.tool.default=avrdude
spacemouse.upload.protocol=avr109
spacemouse.upload.maximum_size=28672
spacemouse.upload.maximum_data_size=2560
spacemouse.upload.speed=57600
spacemouse.upload.disable_flushing=true
spacemouse.upload.use_1200bps_touch=true
spacemouse.upload.wait_for_upload_port=true

spacemouse.bootloader.tool=avrdude
spacemouse.bootloader.tool.default=avrdude
spacemouse.bootloader.unlock_bits=0x3F
spacemouse.bootloader.lock_bits=0x2F
spacemouse.bootloader.low_fuses=0xFF
spacemouse.bootloader.high_fuses=0xD8

spacemouse.build.board=AVR_PROMICRO
spacemouse.build.core=arduino:arduino
spacemouse.build.variant=promicro
spacemouse.build.mcu=atmega32u4
spacemouse.build.usb_product="Spacemouse Pro Wireless (cabled)"
spacemouse.build.usb_manufacturer="3Dconnexion"
spacemouse.build.vid=0x256f
spacemouse.build.extra_flags={build.usb_flags}

############################# Spacemouse Pro Micro 5V / 16MHz #############################
# deleted 3.3V / 8 Mhz variant to avoid bricking

spacemouse.build.pid.0=0xc631
spacemouse.build.pid.1=0xc631
spacemouse.build.pid=0xc631
spacemouse.build.f_cpu=16000000L

spacemouse.bootloader.extended_fuses=0xCB
spacemouse.bootloader.file=caterina/Caterina-promicro16.hex

Common issues with boards.txt:

  • TeachingTech video for proper instructions
  • Teaching Tech followed the instructions here from nebhead with two key differences:
    • Changed the word 'DaemonBite' to 'Spacemouse' in all references.
    • Changed the VID and PID values as per jfedor's instructions: vid=0x256f, pid=0xc631 (SpaceMouse Pro Wireless (cabled))

"pins_arduino.h" not found

Taken from

Windows 11, 2.3.2 Arduino IDE, AVR 1.8.6

I followed every setup step, but was getting complication error "pins_arduino.h" not found.

Checked the file - indeed, not existing, even though it is imported in core

Its the first time I interact with Arduino and I'm not sure if this was suppose to be auto copied or magic imported, but it didn't

Copying the config from variants\leonardo (in my case, I used the board TeachingTech recommended) to version root (...avr\1.8.6) solved it

Changes for Arduino 2.3.2

Check this issue. With Arduino IDE 2.3.2 and Arduino AVR board package 1.8.6 , a few changes in text pasted to boards.txt were needed

#spacemouse.build.variant=promicro
spacemouse.build.variant=leonardo 

#spacemouse.bootloader.file=caterina/Caterina-promicro16.hex
spacemouse.bootloader.file=caterina/Caterina-Leonardo.hex

Also SpaceMouse needs to be added to list of boards supported by Arduino AVR platform in package_index.json, so that you can select it in IDE.

        {
          "name": "SpaceMouse"
        },