Build and upload¶
To build and upload a project,
- Select the target All or Fast.
- Press the button Run or press Cmd+B.
The sketch is going to be built and linked, and the resulting executable uploaded to the board and open.
At the end, the Terminal application opens a serial console.
Customise the serial port¶
The serial port is used for the upload of the sketches and for the console.
By default, embedXcode uses the names of the serial port defined in the board configuration file and set the speed to 9600 for the serial console.
Both parameters can be changed.
Change the upload serial port¶
Each platform has a different implementation of the USB port naming. Arduino uses the physical USB port of the Mac while each LaunchPad has a unique port name.
Now, two issues may appear:
Some USB hubs change the USB port names.
When Mac goes to sleep and then wakes up, USB ports are enumerated with an different name.
In either case, the following error message is displayed when trying to upload.
As a solution,
- Open the main
# BOARD_PORT is optional # !!! Help: https://bit.ly/2yUvq0h # If not defined, BOARD_PORT = /dev/tty.usb* (default) # #BOARD_PORT = /dev/tty.usbmodem*
- Uncomment the line
BOARD_PORTby removing the leading
#BOARD_PORT = /dev/tty.usbmodem1* BOARD_PORT = /dev/tty.usbmodem1*
- Edit the line and either specify a more general name.
BOARD_PORT = /dev/tty.usbmodem*.
- Or enter the specific USB port name of the board.
BOARD_PORT = /dev/tty.usbmodem1403
To know the USB port name of the active board, proceed as follow:
Launch a Terminal window
Plug the board on the USB port.
Run the following command and note the name of the port.
$ ls /dev/tty.usb* /dev/tty.usbmodem1403
Change the serial console speed¶
By default, the speed of the serial console is 9600. To change the speed,
Open the main
Uncomment the line
SERIAL_BAUDRATEand set the desired speed.
# SERIAL_BAUDRATE for the serial console, 9600 by default # !!! Help: https://bit.ly/2AUEcgp # Uncomment and specify another speed # SERIAL_BAUDRATE = 19200
Change the optimisation options¶
By default, the optimisation options are set to standard. To change them,
Open the main
Uncomment the line
OPTIMISATIONand set the desired options.
# OPTIMISATION for the optimisation and debugger levels # !!! Help: https://bit.ly/2kheSLz # Uncomment and specify another options # OPTIMISATION = -O0 -g3
Upload when multiple boards are connected¶
This section requires the embedXcode+ edition.
Select among two Arduino connected boards¶
In case two similar boards are connected, for example two Arduino boards, a window lists the connections and ask to select one:
The first port is the default option.
To select the default port, press Enter, click on the button 1 or wait 10 seconds.
To select the second port, click on the button 2.
The following message is added to the Log navigator:
==== 2 ports available ==== 1: /dev/tty.usbmodem1411 2: /dev/tty.usbmodem1421 ==== /dev/tty.usbmodem1411 port selected ====
This feature works with the Arduino boards and the boards using a serial through USB connection.
A similar option is available for the LaunchPad boards using an XDS110 programmer-debugger.
Other boards may not provide this feature, as they use a different protocol that combines different services under a single USB port.
Select among multiple boards connected through serial¶
As an alternative for the previous case and for other boards as well, the following procedure is valid as long as each board has a unique name for the serial port which is used to upload the executable.
- Use the exact name of the serial through USB port the board is connected to.
In the example below, let’s consider two projects: one for the Arduino Uno board and another for the Arduino Mega board.
Connect the first board, here the Arduino Uno board.
Open a Terminal window and launch
% ls /dev/tty.* /dev/tty.usbmodem1411
Note the serial port for the first board, here
/dev/tty.usbmodem1411for the Arduino Uno board.
Connect the second board, here the Arduino Mega board.
Perform the same
% ls /dev/tty.* /dev/tty.usbmodem1411 /dev/tty.usbmodem1421
- Note the serial port for the second board, here
/dev/tty.usbmodem1421for the Arduino Mega board.
In the example, the Arduino Uno is connected to port
/dev/tty.usbmodem1411 and the Arduino Mega to port
- Create two projects, one for the Arduino Uno board and another for the Arduino Mega board.
On the project for the Arduino Uno board,
Arduino Uno.xcconfigboard configuration file,
# !!! Help: https://bit.ly/2yUvq0h # If not defined, BOARD_PORT = /dev/tty.usb* (default) # BOARD_PORT = /dev/tty.usbmodem1411
- Run the
On the project for the Arduino Mega board,
Arduino Mega 2560.xcconfigboard configuration file,
BOARD_PORT = /dev/tty.usbmodem1421
- Run the
Fasttarget for each project.
This feature works with the Arduino boards and other boards as well, as long as each board has a unique name for the serial port which is used to upload the executable.
Select among multiple boards connected through XDS110¶
In case multiple boards are connected through XDS110 and the XDS110 has been selected as uploader, a window lists the serial numbers of the boards and ask to select one.
On the example below, two CC1352 LaunchPad boards are connected.
- Select one serial number and click on OK.
This feature works with selected LaunchPad boards featuring an XDS110 programmer-debugger, as long as each board has a unique serial number. The serial number is used for identification when uploading the executable.
For more information,
- Please refer to the section Upload to LaunchPad boards with XDS110 .
Upload to boards with multiple USB profiles¶
Some boards use the USB connection to simulate a keyboard or a mouse. For example, the
KeyboardMessage example for the Arduino Leonardo board sends key-strokes as a keyboard. Similarly, the
ButtonMouseControl example for the Arduino Leonardo board smiluates mouse clicks.
The Arduino Leonardo board exposes two USB ports: one when connected as a serial device, and another when operating as a keyboard or a mouse.
Connect the Arduino Leonardo board.
Open a Terminal window and launch
Press the Reset button on the Arduino Leonardo board and keep running
% ls /dev/tty.* /dev/tty.usbmodem14101 % ls /dev/tty.* /dev/tty.usbmodemHIDPC1
The two USB ports exposed by Arduino Leonardo board are
/dev/tty.usbmodem14101 when connected as a serial device, and
/dev/tty.usbmodemHIDPC1 when operating as a keyboard, or
/dev/tty.usbmodemHIDFG1 when operating as a mouse.
HID stands for Human Interface Device.
On the project for the Arduino Leonardo board,
Arduino Leonardo.xcconfigboard configuration file,
BOARD_PORT = /dev/tty.usbmodem14101 /dev/tty.usbmodemHIDPC1
- Set the
DELAY_BEFORE_UPLOADvalue long enough to allow the Mac to enumerate the USB ports.
DELAY_BEFORE_UPLOAD = 3
Recommended values range from 2 to 5 seconds.
- Run the
The board will be reset on the
/dev/tty.usbmodemHIDPC1 HID port and the executable uploaded through the
/dev/tty.usbmodem14101 serial port.
This procedure has been tested on the Arduino Leonardo board.
Display the Report Navigator¶
The Report Navigator provides information about the compilation and the size of the final binary file.
- To display the Report Navigator, call the menu View > Navigators > Show Report Navigator, or press Cmd+8 or click on the rightmost icon.
The Report Navigator provides the detail of the whole process.
Once compilation is completed, the Report Navigator displays the total size of the sketch on the flash memory and an estimation of the RAM usage.
It also provides the elapsed time spent for building and linking.
---- Size ---- Binary sketch size: 880 bytes (of a 16384 byte maximum) Estimated SRAM used: 22 bytes (of a 512 byte maximum) Elapsed time: 0.3 s ==== Make done ====
The embedXcode+ edition provides additional information with remaining free memory and percentages.
---- Size ---- Estimated Flash: 880 bytes used (5.3% of 16384 maximum), 15504 bytes free (94.7%) Estimated SRAM: 22 bytes used (4.2% of 512 maximum), 490 bytes free (95.8%) Elapsed time: 1.1 s ==== Make done ====
Display the serial console on a Terminal window¶
If the target All or Fast is selected, once the sketch is built, linked and uploaded to the board, the Terminal application opens a serial console with the
To launch the serial console in a Terminal window,
- Select the target Serial.
- Click on Run.
macOS may ask for permission.
- Click on OK.
The serial console is bi-directional: it displays data sent by the board on the Terminal window, and sends data typed in the Terminal window to the board.
For more information on the
- Please refer to the official Screen User’s Manual .
To close the serial connection,
- Use the Ctrl+A Ctrl+K key sequence.
- Then press Y to confirm.
Otherwise, the USB port is no longer listed. This is a bug on the USD drivers with macOS .
For the moment, the serial console isn’t displayed on the debug pane in the main Xcode window.
On the embedXcode+ edition, an option allows not to open the serial console after the upload.
- Please refer to the procedure at the section Manage the serial console after upload .