CodeBlocks Arduino IDE - real C++ IDE for Arduino development (rev.20130827)

CodeBlocks Arduino IDE is a complete out-of-box C++ IDE for Arduino development. It will be liked by software engineers demanding a more powerful IDE and those who need to heavily modify or develop Arduino libraries. I have been maintaining the project basically to provide myself a productive and flexible Arduino development environment. Right now I only release for Windows builds, while someone else has forked my code (but seems not updating often) and provdes some instructions how to use the IDE on Linux.

Download Latest Release

Changelog

Release 20130428

Improved Arduino Builder integration with CodeBlocks (no need to close the window after uploading)
Updated several Arduino libraries (OBD, MPU6050, MultiLCD)
Compile with -O2 instead of -Os when target MCU has 64KB or larger program memory

Release 20130401

Fixed stop running button not terminating simulation process bug
All compiled files now stored in build directory in project path
Improving user experience of project wizard in several aspects
Re-added “Simulator - Debug” target for debugging in simulation

Release 20130329

Automatically building referenced Arduino libraries
Built Arduino core files now cached for improving project building speed
Fixed issues with Microduino
Fixed a bug causing wrong board type choice on uploading
Arduino Builder 0.8.3

Release 20130324

Updated Arduino core and library files to 1.0.4
Arduino Builder 0.8.1

Release 20130322

Including project folder in include file search path by default
Arduino Builder 0.8.0

Release 20130319

Added opening serial terminal right after uploading
Updated Arduino Uploader to 0.7.1

Release 20130318

Added MCU operating frequency option (16/12/8 Mhz)
Added support for Microduino Core+ (ATMega644PA)
Updated Arduino Uploader to 0.7.0

Release 20130308

Windows XP compatibility issue fixed
Arduino Uploader updated
Added “-lm” option in linking command line

Release 20130302

Using Arduino Uploader GUI version for uploading
Changed default sketch file extension from .cpp to .ino

Something about the simulator

As you may have noticed (in the screenshot above, there are two simulator targets in every Arduino project created with the project wizard. These are for building and running an Arduino sketch on PC. The idea is to re-write the underlying Arduino core files (and some AVR C routines) to simulate the behavior of a AVR chip (SFR, interrupts) and Arduino (digital/analog pins, serial UART). As an Arduino sketch is built with AVR-GCC, the code can be compiled with x86-GCC with no modification and so are the most libraries. As is running on PC as a native program, the program logic can be debugged more easily within the IDE (by GDB, with break point, single step, variable watch etc.). For the hardware simulation, right now I have only implemented serial UART simulation with hardware serial port on PC. This is useful for debugging code dealing with any serial devices by connecting the device directly to PC via a USB-TTL adapter. I have managed to run a sketch based on TinyGPS with a USB GPS receiver.
For example, to use PC serial port COM5 to simulate Arduino’s Serial1, you can do like this in the sketch:

Serial1.begin(115200, 5);

This will open PC serial port COM5 and subsequential calls to Serial1 will act on the PC serial port.

I will keep working on this API-level simulator and the next hardware to be simulated will be LCD and SD device. Progress will always be published together with the release of IDE distribution as the simlator is useless without the IDE. It’s source code is located in ardusim sub-directory of the package.

cbwizard.png

Updated again. The latest release now supports uploading to Arduino by clicking IDE's run button (or press F9 to build and run). This is like running a compiled binary on PC. The simulation target (which simulate Arduino API) is also being developed as a portion of the IDE now.

I've made some progress in the API-level Arduino simulator, which is also included in the new release. Serial UART can be simulated now with hardware serial port on PC. This will be very useful to debug serial communication.

Revision 20130306 fixed Windows XP compatibility issues.

Looks very interesting!!!

Just installed this, works great! So much better than the official Arduino IDE! Thanks a lot!

Thanks for your compliment. An update is just released. The IDE maybe a little bit tricky for non-progreammers but once you grab it, it's definitely more efficient. I will write some tutorials in future.

This version does everything I need. It allows me to specify a 12 MHz clock rate for my project which is a 3.3v ATmega328p which does not support 16 MHz clock. My project can now proceed. I just put a scope on my 10 millisecond interrupt and it happens every 10 ms, which proves the code now is using a 12 MHz clock. Thank you Stanley. Nice job and thank you for the great tool you have generously provided.

So glad to see it works for you.

Great project, but how can i add a custom library ?

In Arduino Ide, i put the files to "E:\Eigene Dateien\Arduino\libraries" and i can work with it.

How does this work in codeblocks?

Andree

Of course.
Simply place the library files in the sketch folder and add the .cpp file into the project (choose menu Project->Add Files).

Thanks, but did not work.

Windows-XP.
Starting codeblocks, create new arduino project “test”.
Copy folder “RTClib” to folder “C:\arduino\test”.
Add “RTClib\RTClib.h” + “RTClib\RTClib.cpp” to project.
edit “scetch.ino”
#include <Wire.h>
#include “RTClib.h”

compile…
C:\arduino\test\RTClib\RTClib.cpp|4|fatal error: Wire.h: No such file or directory|

RTClib.cpp 4: #include <Wire.h>

I bet you have not changed build target from “Simulator” to an actual arduino board type. You also need to enable compile and link option for Wire library (right click the Wire.cpp in libraries sub-folder in project view).

You are right, now Build target "Mega260" , sorry about that.

sketch.ino|3|error: RTClib.h: No such file or directory.

Ok, set up a search path to RTClib - directory under build options.

its working now.

Thanks a lot.

Andree

Hi, I'd like to know if somehow we can use the simulator to mock digitalRead/analogRead/interupt signals?

stanleyhuang: CodeBlocks Arduino IDE is a complete out-of-box C++ IDE for Arduino development most suitable for software engineers demanding a more powerful IDE and those who need to heavily modify or develop Arduino libraries. I have been maintaining the project basically to provide myself a productive and flexible Arduino development environment. Now I mainly release for Windows only, while someone else has forked my code on github and maintain the linux port.

Actually you can hack into the core files under ardusim directory (forked from arduino core files) to do whatever you want when arduino APIs are called.

tianshuo: Hi, I'd like to know if somehow we can use the simulator to mock digitalRead/analogRead/interupt signals?

I will include "." in search path by default.

Andree: You are right, now Build target "Mega260" , sorry about that.

sketch.ino|3|error: RTClib.h: No such file or directory.

Ok, set up a search path to RTClib - directory under build options.

its working now.

Thanks a lot.

Andree

I see them alright, but I'm not sure where should I start from. I guess maybe the simulator could listen to a port for signals? Could someone give an example using wiring_analog.c?

stanleyhuang: Actually you can hack into the core files under ardusim directory (forked from arduino core files) to do whatever you want when arduino APIs are called.

tianshuo: Hi, I'd like to know if somehow we can use the simulator to mock digitalRead/analogRead/interupt signals?

Actully my long-term goal is to implement a simulator which acts like a http server and use HTML to render the simulation. About hacking into arduino core files, taking digitalWrite as an example, I just added one line at the end like this:

void digitalWrite(uint8_t pin, uint8_t val)
{
    uint8_t timer = digitalPinToTimer(pin);
    uint8_t bit = digitalPinToBitMask(pin);
    uint8_t port = digitalPinToPort(pin);
    volatile uint8_t *out;

    if (port == NOT_A_PIN) return;

    // If the pin that support PWM output, we need to turn it off
    // before doing a digital write.
    if (timer != NOT_ON_TIMER) turnOffPWM(timer);

    out = portOutputRegister(port);

    uint8_t oldSREG = SREG;
    cli();

    if (val == LOW) {
        *out &= ~bit;
    } else {
        *out |= bit;
    }

    SREG = oldSREG;

#ifdef ARDUSIM
    fprintf(stderr, "[MCU] Pin %d state changed to %s\n", pin, val ? "HIGH" : "LOW");
#endif
}

tianshuo: I see them alright, but I'm not sure where should I start from. I guess maybe the simulator could listen to a port for signals? Could someone give an example using wiring_analog.c?

Project path is added as include file search path by default in latest release.

Andree: You are right, now Build target "Mega260" , sorry about that.

sketch.ino|3|error: RTClib.h: No such file or directory.

Ok, set up a search path to RTClib - directory under build options.

its working now.