Unsolved QT for Arduino development - Mega boards
I was looking for something better than the Arduino IDE and I came across a post that described how to use QT Creator for Arduino development:
Having given this a try I found that since the post is quite old, some adjustments were required. I am using QT4 from the Ubuntu repository on Linux Mint 19.2 with Cinnamon. The combination works very well for the UNO, but I can't get it to work with the MEGA2560? From the Arduino point of view, all one needs to do is change the Makefile to reflect the change of board (i.e. change BOARD_TAG from uno to mega). However, when I try to deploy the application to the Mega, the IDE sits forever with the Run options greyed out. When I close the application, a message pops up to tell me that there is a deployment in progress and asks me whether I want to cancel it so I choose 'yes' and QT Creator closes. Choosing 'No' repeats the cycle.
I had to change the Makefile as follows (in accordance with the instructions in Arduino.mk):
ARDUINO_DIR = /usr/share/arduino ARDMK_DIR = /usr/share/arduino # Set to YOUR avrtools path AVR_TOOLS_DIR = /usr/share/arduino/hardware/tools/avr TARGET = main ARDUINO_LIBS = BOARD_TAG = uno MONITOR_PORT = /dev/ttyACM0 # Avrdude code #ARDUINO_PORT = /dev/ttyACM0 AVRDUDE_ARD_PROGRAMMER = arduino AVRDUDE_ARD_BAUDRATE = 115200 include /usr/share/arduino/Arduino.mk
I also had to change 'raw_update' to just 'update'. Has anyone had success deploying from QT to the Mega 2560 board?
I was going to have a look at Eclipse, but am still having problems getting that up and running. The version in the Ubuntu repository is really old, even older than QT Creator 4.5.2 I think!
BTW, is there any way of expanding the tiny compose window?
With a bit more investigation, I figured out how to compile and upload to the Mega 2560, at least in a terminal window. It was necessary to change, not only the board tag, but also the programmer type from 'arduino' to 'wiring'. My Makefile for the Mega 2560 now looks like this:
ARDUINO_DIR = /usr/share/arduino ARDMK_DIR = /usr/share/arduino AVR_TOOLS_DIR = /usr/share/arduino/hardware/tools/avr TARGET = main ARDUINO_LIBS = BOARD_TAG = mega2560 MONITOR_PORT = /dev/ttyACM0 #MCU = atmega1250 #F_CPU = 16000000 # Avrdude code #ARDUINO_PORT = /dev/ttyACM0 AVRDUDE_ARD_PROGRAMMER = wiring AVRDUDE_ARD_BAUDRATE = 115200 include /usr/share/arduino/Arduino.mk
This is sufficient to be able to compile and upload with:
$ make upload
However, there is still the problem of getting the Mega board recognized in QT. I can set up an alternative Makefile (e.g. Makefile.mega2560) with the required parameters, and then create a new Run profile in QT Creator. here I can add a new Deploy task with a make parameter of -f Makefile.mega2560. However the IDE does not recognize the Mega hardware. For example, while Serial0 is recognized, Serial1 is not so any code that mega specific hardware will not compile because the compiler does not recognize the objects or definitions. I will investigate this further and report back if I figure it out.
BTW, I figured out how to drag the top of the compose window upwards with the up/down arrow in the black circle. Didn't notice it at first.
your link in the first post is broken, so its hard to know what you are doing.
Can you fix that, please?
Not sure how it got condensed like that, but I have updated it. Should be OK now.
Thanks. From the updated link I see, that a Generic Project is used.
In that case, the project definitions have to be done yourself, Creator does not know (and doesn't care) what's inside the
Makefileor passed to the
So I think you need some other includes, or provide a `#define' for the mega2560.
Can you show us the relevant definitions for Serial0 and Serial1?
@aha_1980 , I have come to the same conclusion as you outline here. If I want to compile for anything other than a Uno board, I have to run make directly in terminal. I can live with that but I was hoping that there was a better way. My investigation of Eclipse was rather underwhelming, but I found QT very useful, at least as an editor and error checker (particularly for classes) and to do proof on concept testing.
Serial0 and Serial1 are part of the Arduino framework. I only have to include <Arduino.h> in my project. However, compiling in QT will only recognize Serial0. I did some investigating along the lines you suggest and discovered that the Ardiono IDE does some pre-processing behind the scenes, although I didn't find and details. Looking through various Arduino library files, there are some symbols defined (e.g. #define ARDUINO_AVR_MEGA) but they seem to be "read-only", i.e. to determine rather than to set which board I am using. If I use them then the compiler complains about a duplicate definition or ignores it. In the Makefile, the board is set with:
BOARD_TAG = mega
However, as you say, QT does not see that. The identification of an appropriate define might be a question for the Arduino forum. Its is difficult to know where to draw the line between Arduino stuff and C++ sometimes so I hope I haven't gone too much OT.
Hi @qcontinuum said in QT for Arduino development - Mega boards:
You can put such defines in the <project>.defines file, it will be prepended to all project files.
Changing the Makefile to use for build should be possible too: Press Ctrl+5 and you are in the projects setup page. You can specify the make command here, and you should even be able to create several build configurations (I've not tested that, but I think it works).
After all, it should be enough fun to code for these micros.
If you, however, need to change them regularly, that may be a bit tedious...
Sorry, I tried Ctrl-F5, but it does absolutely nothing.
@qcontinuum I said
Ctrl+5which switches to Projects mode; not Ctrl+F5 ;)
Yes, so you did. Sorry my mistake. Its just the same as clicking Projects on the left hand side which is were I went anyway. Thanks.