Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suport for ESP32 using Arduino libs #182

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
79cf1bf
Added Arduino IDE 1.6 support and minor fixes
altexdim Apr 23, 2015
d6a94db
Misspelling fixed
altexdim Apr 23, 2015
a8926af
Fixed misspelling
altexdim Apr 23, 2015
8d5deb5
Fixed misspelling
altexdim May 11, 2015
9f4b749
Updated readme for other OS
altexdim May 15, 2015
f8ca0e2
wip
altexdim May 15, 2015
dcc4400
wip
altexdim May 15, 2015
6b6dd07
Fixed path settings for MacOS and Arduino IDE 1.6+
altexdim May 20, 2015
359f456
Fixed arduino.cmake for arduino nano
altexdim Aug 30, 2015
7208928
Added english readme
altexdim Sep 2, 2015
a57e164
Fixed file name
altexdim Sep 2, 2015
a0fae8b
Merge branch 'master' of github.com:altexdim/arduino-cmake into en_re…
altexdim Sep 2, 2015
805637d
Pulled in changes from ncasaril/arduino-cmake
francoiscampbell Jan 20, 2016
f1acfb5
Merge branch 'ncasaril-master'
francoiscampbell Jan 20, 2016
4a76ced
Added .DS_Store to .gitignore
francoiscampbell Jan 20, 2016
402f509
Fixed .gitignore syntax
francoiscampbell Jan 20, 2016
37d2cc2
Made the English README the default one
francoiscampbell Jan 20, 2016
d8cec4c
Respect CMake include path when searching for library dependency dire…
ntninja Feb 6, 2016
13668d9
Added ino and pde files to sources to enable refactorings in CLion. T…
francoiscampbell Feb 17, 2016
12aade6
Merge pull request #2 from alexander255/master
francoiscampbell Feb 17, 2016
3c7817f
Merge branch 'libs-fix'
francoiscampbell Feb 17, 2016
dbd4fe3
Include directories when setting up the library. Added Servo_RECURSE.
francoiscampbell Feb 17, 2016
9d333b7
Improve arduino settings file loading to support more types
Pro Jan 26, 2018
77b6f3d
Load automatically all hardware and platform definitions from SDK_PAT…
Pro Jan 26, 2018
d090c62
Use config files and recipes to generate Arduino burn and compile com…
Pro Jan 30, 2018
7a00b9c
Build for Arduino working
Pro Jan 30, 2018
d2319e2
First successful build with esp32
Pro Jan 30, 2018
1421d0b
Compile with ap example. Not yet working
Pro Feb 2, 2018
cd982e7
Working example for WLAN led
Pro Feb 2, 2018
650a0c0
Add the corresponding compiler settings for esp32
Pro Feb 14, 2018
55c2bfd
Add percentage output for avr-size script
Pro Feb 16, 2018
baa6bc2
Allow empty override path
Pro Apr 17, 2018
2f06918
Allow setting ARDUINO_SDK_PATH as environment variable
Pro Apr 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
build
build/
.idea/

*.DS_Store
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,28 @@
# Description: Arduino CMake example #
# #
#=============================================================================#

# this line is needed only if you use boards with selectable cpu (like mega, pro etc)
# and this line should go before call to "cmake/ArduinoToolchain.cmake"
# this is durty hack and should be fixed somewhen, because it should go to
# particular cmake subdirectory

set(CMAKE_TOOLCHAIN_FILE cmake/ArduinoToolchain.cmake) # Arduino Toolchain


cmake_minimum_required(VERSION 2.8)
#====================================================================#
# Setup Project #
#====================================================================#
project(ArduinoExample C CXX)
project(ArduinoExample)

#print_board_list()
#print_programmer_list()

print_board_list()
print_programmer_list()
# add libraries to project
link_directories(${ARDUINO_SDK}/libraries)

add_subdirectory(example) #add the example directory into build
# add the project directory into build
add_subdirectory(example)
#add_subdirectory(example_esp32)
#add_subdirectory(example_ap)
174 changes: 174 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
Arduino Cmake Example Project
===============================

This is the Cmake project settings for the Arduino platform.
You can use this project as an example to develop C++ programs
in JetBrains CLion IDE for Arduino and using toolchain from
Arduino IDE 1.6+.

This project correctly works and tested in Windows with MinGW,
but it should work in linux and mac with standard cmake/make pakages.

Original cmake project is licensed with
Mozilla Public License, v. 2.0 http://mozilla.org/MPL/2.0/

Readme from the original project is moved to /README.original.rst.
You can find all the authors and contributors there.

Usefull links
-------------------------------
Original project URI: https://github.com/queezythegreat/arduino-cmake

Current project is it's fork with patches from pull requests
https://github.com/queezythegreat/arduino-cmake/pulls
and with my patches that fixes some major and minor bugs
as long as adds other new features.

Some examples are taken from this article http://habrahabr.ru/post/247017/

Differencies between this project and original one
-------------------------------
1. Added patch "Adding support for SDK 1.5"
https://github.com/queezythegreat/arduino-cmake/pull/104
Added support for Arduino IDE 1.5-1.6+.

2. Added patch "fixed bug in find_file method"
https://github.com/queezythegreat/arduino-cmake/pull/109
Now cmake project does not search for arduino toolchain
files in standard windows paths.

3. Added patch "Fix CMP0038 warnings on CMake >= 3.0"
https://github.com/queezythegreat/arduino-cmake/pull/143
Removed warnings.

4. Fixed windows paths to avr-size command. Now we can see the size of the compiled arduino program.

5. Fixed parsing of the boards.txt settings that are used for compilation of the boards (that differs from arduino mega).

6. All compilation settings are taken from original Arduino IDE.
But i dont think i've done it the best way so you can try do better if you want.

7. Removed any differences between all build flavors (debug, release, etc). This is descructive difference between this fork
and original project, that is why you should not try to merge this fork into original project.
I make it because i dont have enough experience in finding the best compile options for these different build types.
So now it uses original Arduino IDE options.

8. Original Readme is saved in README.original.rst

Installing CLion + Arduino IDE + MinGW
-----------------------------------
1. Install MinGW (needed for CLion, includes make, g++, cpp)

This is needed only for windows. In different OS'es you should skip this and continue to
the next - "2. Install Arduino IDE".

1.1. Installing MinGW
http://sourceforge.net/projects/mingw/files/Installer/
Tested on version mingw-get-0.6.2-mingw32-beta-20131004-1

1.2. Run MinGW Installation Manager

1.3. Choose packages from "Basic Setup"
- mingw-developer-toolkit
- mingw32-base
- mingw32-gcc-g++
- msys-base
and push "Apply Changes"

2. Install Arduino IDE 1.6 (needed for building the project, includes avr toolchain)
http://www.arduino.cc/en/Main/OldSoftwareReleases
Tested on version 1.6.3

3. Install and setup JetBrains CLion 1.0

3.1. Install JetBrains CLion 1.0
https://www.jetbrains.com/clion/
Test on version 1.0

3.2. Run CLion

3.3. Setup toolchain
Menu settings "File" -> "Settings"
Choose "Build, Execudion, Deployment" -> "Toolchain"
Setup
- Env: MinGW "c:\mingw"
- cmake: "bundled cmake"

MinGW option only exists in windows.

All is done, you can open project in CLion.

How to move you existing project from Arduino IDE
-----------------------------------

For example, you have your own project named Robot with the following files
- /Robot.ino
- /Chassis.cpp
- /Chassis.h
that already works in Arduino IDE, and you want to move it to CLion IDE.

1. Make new project with name arduino-cmake-robot
Clone this repository:
git clone {THIS_REPO_URI} arduino-cmake-robot

We do not need origin any more, we will use our own project repository.
Remove origin:
git remote rm origin

2. Copy our existing project files Robot
Make folder /robot in the root of new project.
Copy files into this folder. Now we have 3 new files in new project
- /robot/Robot.ino
- /robot/Chassis.cpp
- /robot/Chassis.h

3. Rename Robot.ino into robot.cpp
Now our new files and folders structure is like the following:
- /robot/robot.cpp
- /robot/Chassis.cpp
- /robot/Chassis.h

4. Add standard Arduino library
Add the following line before the very first line of the /robot/robot.cpp file
#include "Arduino.h"

5. Make file with cmake build settings
Copy /example/CMakeLists.txt into /robot/CMakeLists.txt

6. Setup CMakeLists.txt for "robot" project (/robot/CMakeLists.txt)
Set up the name of the project
set(PROJECT_NAME robot)

Set up the target platform.
Example 1. For Arduino Pro (Arduino Pro Mini) it should look like this
set(${PROJECT_NAME}_BOARD pro)
Example 2. For Arduino UNO
set(${PROJECT_NAME}_BOARD uno)

Set up the name of the file, that was previously with INO extension
set(${PROJECT_NAME}_SRCS robot.cpp)
Set up target COM port, which is connect to the board
set(${PROJECT_NAME}_PORT COM3)

7. Set up root folder CMakeLists.txt (/CMakeLists.txt)
Choose correct CPU option for the board.
This name is located in the file
C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt
This is windows path. For other OS'es it will look similar to
"hardware\arduino\avr\boards.txt".

Example 1. For Arduino Pro 16Mhz 5V ATmega 328
we can file the line "pro.menu.cpu.16MHzatmega328=ATmega328 (5V, 16 MHz)"
and than take correct CPU ID "16MHzatmega328", but not the value "ATmega328 (5V, 16 MHz)"
set(ARDUINO_CPU 16MHzatmega328)
Example 2. For Arduino UNO where is no need to define anything, just comment out the CPU ID line,
because Arduino UNO does not have different CPU options
# (commented) set(ARDUINO_CPU 16MHzatmega328)

Add project folder, change "example" to "robot"
# (commented) add_subdirectory(example)
add_subdirectory(robot)

8. Open project in CLion IDE and choose build option "robot" (for compilation only)
or "robot_upload" (for compilation and upload).
Build project (CTRL+F9). After that project starts to build and upload to the Arduino board.
4 changes: 4 additions & 0 deletions README.rst → README.original.rst
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,10 @@ The following options control how **Arduino CMake** is configured:
+---------------------------------+-----------------------------------------------------+
| **ARDUINO_DEFAULT_BOARD** | Default Arduino Board ID, when not specified. |
+---------------------------------+-----------------------------------------------------+
| **ARDUINO_CPU** | Selected CPU from Arduino 1.5 menu boards. For mega |
| | board, for example, you have to set atmega2560 |
| | before including ARDUINO ToolChain |
+---------------------------------+-----------------------------------------------------+
| **ARDUINO_DEFAULT_PORT** | Default Arduino port, when not specified. |
+---------------------------------+-----------------------------------------------------+
| **ARDUINO_DEFAULT_SERIAL** | Default Arduino Serial command, when not specified. |
Expand Down
Loading