Add a Board Configuration File

This section requires embedXcode+.

With embedXcode+, you can easily create and customise a board configuration file for a new board.

You only need to define its settings and optionally a specific programmer.

The specific board configuration file My Board can also be added to the templates so it'll appear when creating a new project.

Create a Configuration File for a New Board

To add a configuration file for a new board,

  • Call the menu File > New > New File... or press Cmd+N.

  • Select the macOS option.

  • Scroll down to the embedXcode+ group.

  • Select Board Configuration Settings File.

The Board Configuration Settings File allows to define the settings for a new board, including a specific programmer.

  • Type in the Name of the new board.

  • Select Default for the Wiring / Arduino framework, or

  • Select mbed for an mbed-enabled board.

  • Click on Next.

  • Continue with Define a New Board for the Wiring / Arduino Framework or Define a New mbed-Enabled Board.

Define a New Board for the Wiring / Arduino Framework

When Default is selected, the new Board Configuration Settings File comes with an example for the Wiring / Arduino framework.

//
//  newBoard.xcconfig 
//  Board config file
//  ----------------------------------
//  Developed with embedXcode
//
//  Project     embed1
//
//  Created by  Rei Vilo on sept. 30, 2017
//  Copyright   (c) 2017 http://embeddedcomputing.weebly.com
//  Licence     <#Licence#>
//
// Last update: Mar 05, 2014 release 138

// Board identifier
// See Boards.txt for <tag>.name=Arduino Uno (16 MHz)
//
BOARD_TAG  = uno

// Port (optionnal)
// most common are /dev/tty.usbserial*, /dev/tty.usbmodem* or /dev/tty.uart*
//
BOARD_PORT = /dev/tty.usbmodem*

// References for Xcode code-sense
// See Boards.txt for <tag>.build.mcu=<GCC_PREPROCESSOR_DEFINITIONS>
//
GCC_PREPROCESSOR_DEFINITIONS = __AVR_ATmega328P__ ARDUINO

// Specify the full path and name of the application
// with /Contents/Resources/Java/** after
//
HEADER_SEARCH_PATHS = $(ARDUINO_APP)/** $(SKETCHBOOK_DIR)/Libraries/**

// Maximum RAM size in bytes
// given by <tag>.upload.maximum_ram_size in boards.txt for Maple and Teensy
// given by <tag>.upload.maximum_data_size in boards.txt for Arduino 1.5.x
//
MAX_RAM_SIZE = 2048

Specify the following variables:

BOARD_TAG is the unique identifier of the board, found in the Boards.txt file.

BOARD_TAG  = uno
BOARD_PORT defines the USB port to be used.
BOARD_PORT = /dev/tty.usbmodem*

This parameter is optional. To know the name of the USB port, proceed as follow:

  • Open the Terminal window,

  • Plug the board,

  • Launch the command ls /dev/tty.usb*.

$ ls /dev/tty.usb*
/dev/tty.usbmodem0E100631
  • Read the answer, here /dev/tty.usbmodem0E100631.

  • Change the value of BOARD_PORT accordingly.

BOARD_PORT = /dev/tty.usbmodem*

The generic character * allows other values for the port, for example /dev/tty.usbmodem0E100641.

  • DELAY_PRE_SERIAL defines a delay in seconds before opening the Console.
DELAY_PRE_SERIAL = 5
  • GCC_PREPROCESSOR_DEFINITIONS is the name of the micro-controller of the board, found in the Boards.txt file.
GCC_PREPROCESSOR_DEFINITIONS = __AVR_ATmega328P__ ARDUINO
  • HEADER_SEARCH_PATHS needs to be updated with the reference of the IDE, with the full path in prefix and detailed folders ended with /** in suffix.

For example, for the Arduino IDE, the correct reference is the following:

HEADER_SEARCH_PATHS = /Applications/Arduino.app/Contents/Resources/Java/**

For mbed-enabled boards, the path is set to the mbed folder.

HEADER_SEARCH_PATHS = ~/Library/embedXcode/mbed/**

This parameter improves the selection of the headers for code-sense.

  • MAX_RAM_SIZE gives the number of bytes of SRAM. Read the specification sheet of the MCU to find the correct value.
MAX_RAM_SIZE = 2048

Additional parameters for the programmer can be set according to the procedure Define a Specific Programmer for a New Board .

Changes done to the board configuration file aren't updated automatically, because the parameters are loaded only once when the board configuration file is selected.

To take the new parameters into account,

  • Select another board.

  • Select again the board you are working on.

Define a Specific Programmer for a New Board

Additionally, embedXcode+ offers options to use a different programmer on the same board configuration settings file.

This section applies to the boards supported by a Wiring / Arduino like IDE. The IDE includes the central file boards.txt contains all the parameters of the boards.

Set Programmer Options

Only specify the parameters when the values are different from the default ones.

  • AVRDUDE_SPECIAL states that a specific configuration is set for the programmer. Otherwise, comment the line.
AVRDUDE_SPECIAL = 1
  • AVRDUDE_PROGRAMMER provides the name of the specific programmer. Otherwise, the variable isn’t required: just comment the line.
AVRDUDE_PROGRAMMER = usbtiny
  • AVRDUDE_BAUDRATE provides the speed for upload. If the speed differs from the default setting, specify it. Otherwise, the variable isn’t required: just comment the line.
AVRDUDE_BAUDRATE = 9600
  • AVRDUDE_OTHER_OPTIONS provides a free variable, for example for selecting verbose output or erasing flash.
AVRDUDE_OTHER_OPTIONS = -v
  • If the programmer doesn’t feature a serial port, set AVRDUDE_NO_SERIAL_PORT to 1.
AVRDUDE_NO_SERIAL_PORT = 1
  • Otherwise, set AVRDUDE_NO_SERIAL_PORT to O or comment the line. The port to be used is defined by BOARD_PORT.

Define Boot-Loader Options

Only specify the parameters when the values are different from the default ones.

  • If the specific boot-loader is already supported like MiniCore for AVR MCUs, set BOOTLOADER to its name.
BOOTLOADER = minicore
  • Otherwise, set the AVRDUDE_CONF variable to the specific avrdude.conf.
AVRDUDE_CONF = $(HOME)/Library/Arduino15/packages/MiniCore/hardware/avr/1.0.3/avrdude.conf

For more information on how to install the MiniCore boot-loader,

Define Compatible MCU

Many ATmega MCUs are compatible and Arduino provides support to most of them. For example, the ATmega328 is compatible with the ATmega328P. However, Arduino doesn’t support the ATmega328 but supports the ATmega328P.

  • If the speed is different, just define F_CPU, otherwise comment the line to use the default value provided by the IDE.
F_CPU = 20000000L

However, each MCU has a unique signature required by the programmer. For example, the signature of the ATmega328 is 0x1e 0x95 0x14 while the compatible ATmega328P has 0x1e 0x95 0x0f.

The programmer checks the signature of the MCU, so the exact reference of the MCU needs to be specified to AVRDUDE.

In that case,

  • Specify AVRDUDE_MCU as the MCU for the programmer only:
AVRDUDE_MCU = atmega328

Set Fuses Options

  • Optionally, fuses can be set, including ISP_LOCK_FUSE_PRE, ISP_LOCK_FUSE_POST, ISP_HIGH_FUSE, ISP_LOW_FUSE and ISP_EXT_FUSE.
ISP_LOCK_FUSE_PRE = 0x3f
ISP_LOCK_FUSE_POST = 0x0f
ISP_HIGH_FUSE = 0xde
ISP_LOW_FUSE = 0xff
ISP_EXT_FUSE = 0x05

If those variables aren’t defined on the board configuration file, default values are provided by the IDE.

  • To by-pass the fuses, set AVR_IGNORE_FUSES to 1, otherwise set the value to 0 or comment the line.
AVR_IGNORE_FUSES = 1
  • Please refer to the documentation of the MCUs for the correct values. Incorrect values may damage the MCU.

Read Warnings

You may also need to update the FTDI drivers to use a programmer.

Some options, as the values for the fuses, are critical and may freeze the MCU.

  • Please refer to the documentation provided by the manufacturers for the correct values, for example the Atmel  website.

These options have been tested with the 5V FTDI basic programmer from Sparkfun, the USB tinyISP AVR programmer kit  from Adafruit and the USB ASP programmer  from Protostack.

Add a Board to the Templates

The Configurations group includes one board configuration called My board for the Wiring / Arduino framework or My Board (mbed) for the mbed framework. This specific board can be edited and included in the embedXcode+ template for later use in new projects.

  • To add a board to the templates,

  • Find and edit the board configuration My board under the Configurations group.

  • Open the Finder on the Documents folder and launch the Update My Board utility for the Wiring / Arduino framework.

  • Follow the instructions of the utility. Select the file My board.xcconfig or My Board and press Choose.

The utility copies the board configuration file into the embedXcode+ templates Example, Local Library and Sketch. Then it display a message.

  • Click OK to close the utility.

In case the selected file had an invalid extension, the utility stops and displays an error message.

  • Click OK to close the utility.

  • Create a new project.

The new My Board is now listed among the boards.