Hello!
Recently, a couple of articles have been published on GT
for and
against the use of Arduino for something more profitable than blinking lights and creating home weather stations. The usual such discourse from the world of technology, when technology is becoming more and more accessible to the general population, has floated, we know.
Having a technical education and a university specialty directly related to the programming of microcontrollers, I understand those who are against. And having many years of experience in commercialization not only of my own, but also to a greater degree of other people's knowledge and skills, I perfectly understand those who are behind.
You are right, and you are also right, but the truth is, as always, somewhere
near the middle.
First of all, you need to understand what the dispute is about. Arduino is not only beautifully packaged by Italians in PCBs and microcontroller boxes, and not only the Arduino IDE development environment. First of all, these are libraries for rapid development, and in my opinion they are the most valuable. If you look at the schematic diagrams of Arduino boards, then we will not see anything particularly impressive. The development environment ... Let's just say, a
little does not reach the Borland C ++ sample of 1994 .
As we know, these libraries are distributed under the GNU license, they can be taken and used without deducting royalties to their creators. Such a business model requires you to earn on anything other than license fees. So they earn, producing and selling in a beautiful package for 20 bucks that the electronics engineer will buy for 20 cents.
And what is important here is not that they are such greedy bourgeois, robbing the working people and worthy of censure from all progressive humanity, but why they can do that. Because:
- We were at the right time in the right place and were the first to see those opportunities that others did not see;
- Made available to the consumer what was previously available to a narrow circle of limited persons;
- Beautifully all packed and presented to the consumer in a ready-to-use form.
Now, about why and how to cross the developments of the consumer segment of entertaining electronics with the development cycle of a commercial project. In this cycle, the Arduino ecosystem has one very valuable feature — development speed.
Speed ​​is the ratio of the distance traveled to time. The greater the speed, the faster we will do the work, or the more work we will do in the allotted time and hypothetically earn more money per unit of time.
Imagine, the customer approached you, he has some personal requirements, and you don’t have in the bins of the Homeland an almost 86% finished project with similar functional characteristics. Any customer has two main questions:
- How much will it cost?
- When will it be ready?
(very often he needs the answer “yesterday” to the second question)
The answer is a healthy programmer | Arduinschika answer |
We need to conduct a pre-project study, draw up a technical task, carry out a series of iterations to clarify it and after its approval we will say in how many months we will be ready to present you the first prototype for further clarification of the functional requirements and product characteristics. | Tomorrow I will present you a prototype, as I see it, and we will discuss the details. The cost of the finished product with the circulation of M pieces will be from X to Y and it will take approximately Z weeks. |
According to the experience of commercial activity, I dare say that the customer will choose the path of the Arduinschik
smoker .
')
Further about how to use Arduino for their own selfish purposes, with
blackjack and group development, version control, project documentation and other stuffed swans from the world of commercial development.
In fact, everything is very simple. For this, apart from the developers, you need a development environment and a stand on which they can develop. C ++, it is in Africa C ++, AVR and Arduino remains AVR.
As a medium, consider Eclipse.
Here is a very good article on how to configure Eclipse first to work with the AVR Toolchain, and then connect the Arduino libraries and flash the LED on Uno.
And here it is even better , but in English.
I will supplement them a little with some rake, which I have stepped on, maybe it will save someone a couple of hours of time.
All of the following is described for Linux and Leonardo. For Windows, you must first install
MinGW / msys .
To build all the sources included in the Arduino core, you need to set the preprocessor constants correctly. If you look at the source code of the libraries, you can see a lot of conditional compilation structures #ifdef #else #endif. In the article on the link, the author scored all this, taking the finished .a file compiled by the Arduino IDE. But not all libraries fall into the core, for example, SPI and Ethernet do not fall, and the same jokes with conditional compilation are waiting for them.
It is very easy to figure out which constants and how to set.
- Launch the Arduino IDE
- Choose a board that we use as a stand
- File - Settings - Show detailed output - Compiler
- Run the compilation and carefully read the console, look for the strings of the form
*** avr-g++ -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Leonardo"' ***
All that is specified with the -D key (except for F_CPU, Eclipse will add it itself) must be added in the compiler settings in Eclipse.

In order for the compiler to find all the .h files that we want to use in the project, you need to specify the path to them in the settings. There are two ways. You can specify absolute paths to the Arduino IDE folders or link the library to the project and specify the relative path from {workspase} / {ProjName}. The second method will allow you to compile the kernel in Eclipse, although there is no fundamental difference, and in the Arduino IDE and Eclipse avr-g ++ is responsible for the compilation.
Additionally, we indicate the path to pins_arduino.h for the board we use in the project.

In order not to break the coherent structure of the files of the library main.cpp from it we will not. Just turn it on as it is from the kernel into the project, and call your file by some other name. You do not need to declare the main () function in it, it already exists in main.cpp, initializes everything you need and calls the loop () function in an infinite loop, the linker collects everything as it should.
Wednesday is ready to go. We write in much the same way as in the Arduino IDE, but here we observe a little more strictly the observance of the canons of C ++. And at any moment we can go down from high-level programming to the floor below. If there is not enough speed to work with ports via digitalWrite, we write directly to the ports.
Alas, the habit of hanging the processor by calling
delay(5000);
Eclipse does not treat. This is taught somewhere, whether in high school, or junior high school, it penetrates so deeply into a person that no moralizing can guide a person on the right path.
For fill and Arduino IDE and Eclipse use the utility programmer AVRDude. She really knows Uno boards under the name “arduino”, but she refuses to recognize cheaper Leonardo types under this name.
Go to the boards.txt and find out that for the programmer
leonardo.upload.protocol=avr109
The programmer in AVRDude settings is called “Atmel AppNote AVR109 Boot Loader”, here it is:

The only inconvenience is that Eclipse will not do this
leonardo.upload.use_1200bps_touch=true
It is necessary to press reset with pens before loading.
Well and in the conclusion the same project collected in Arduino IDE
28 432 (99%) . 28 672 .
1 254 (48%) , 1 306 . : 2 560 .
and in eclipse
Invoking: Print Size
avr-size --format=avr --mcu=atmega32u4 EthernetController.elf
AVR Memory Usage
----------------
Device: atmega32u4
Program: 27834 bytes (84.9% Full)
(.text + .data + .bootloader)
Data: 1257 bytes (49.1% Full)
(.data + .bss + .noinit)
Finished building: sizedummy
Trifle, but for finishing off just these half a kilo and not enough.