You could say that my experience with Arduino is limited, and that is true, since I’ve mostly worked with WinAvr and Studio… I have always found Arduino to be lacking (masking accesss to peripherals, using the one-fits-all approach e.g. System timer using timer0) with simple controllers like the 8-bit avrs.
Coming to stm32duino, I would ask a few questions related to architecture:
1. What can one do to control what code is generated by default (a blinky sketch compiles to circa 12k whereas under Gcc-Arm–Eclipse it takes less than 2k). I understand that code supporting USB VCP must be included, and that the bootloader is also taking about 1k, but still, it seems too much. I spemt a bit of time trying to understand Wirish.h and Boards but the inclusions are so recursive that frankly, you lost me.
2. Can you suggest a different approach to using the arduino functions such as DigitalWrite, AnalogRead, etc without going down to register level? The SPL libraries by ST are more balanced in my opinion…
3. Are you planning a revamp to the editor? While the Arduino editor is adequate for simple projects, I find it’s lacking for more complex ones…
4. I believe warnings are suppressed during build time. Can they be enabled easily?
5. What about debug- within the IDE? Again, for a simple (avr based) debugging with leds and serial is probably adequate, but for mor complex projects it is really a good feature to have.
Thanks, and appologies if these are duplicated questions.
Stefan
for example:
This has been discussed many times on the forum. There are various reasons why the code size is larger than you might imagine.
This includes things like USB support, and the way the 32 bit compiler works.
Its not worth re-iterating here, what has been discussed at length in other threads
Re: 2
For SPL
See https://github.com/avikde/koduino
For HAL
See https://github.com/stm32duino
Re: Questions 3,4 and 5
We use the standard Arduino IDE, (normally at the latest release version); So..No, we don’t have any extra IDE features.
The codebase is just a “Third Party Core’ as defined by Arduino themselves. https://github.com/arduino/Arduino/wiki … cification
I believe there are posts on using Visual Micro too.
I believe there are posts on using Visual Micro too.
Actually, the reason I posted initially was (is) that I think the amount of work put in thus far is appreciable, however, it looks to me like the overall approach could do with some re-assesment; personally, I moved over to an Eclipse-based solution because of the points made above.
Out of respect for the work you gentlemen and ladies put in to create and maintain the system, I wanted to provide some feedback, trying to point out what was an issue for me, hoping that you would see it as constructive criticism. Again, not trying to point out the obvious, but we’re now talking about embedded computers that exceed the processing power of my first computer (yep, I’m that old
) so (imo) the toolset could use some brushing up.
I also think it is not happenstance that, for instance, Nucleo boards adopt Arduino pinout headers, nor that some IDE providers (e.g Attolic) chose to open
up their systems free of charge…I think it is all happening because Arduino changed the way things are done &seen. All I am saying now is that, maybe, you could comsider adjusting the Arduino STM32 approach to suit…
Thanks again, and best wishes
Stefan
Personally I have just installed Eclipse with the Arduino plugin V4. Rick and other people posted some pretty good advice on how to set it up to use our core.
But we don’t develop any IDE, so even though we would like things like debugging to be incorporated in the Arduino IDE, that is not our focus.
The focus of the forums is to keep developing a core which was created by leaflabs to be compatible with Arduino, so people can transition easily from one to the other.
If you dont need any compatibility with Arduino, as you mentioned Atollic is free, and Segger has an IDE that’s free for non-comercial use, and then there is Eclipse. The CubeMX is a great tool to generate configuration files and peripheral libraries.
But when you want the arduino simplicity to work, then all lwo level stuff needs to be abstracted, and that results in those 12KB of basic code. Setting up usb, 2x i2c, 2/3 spi, 8 timers, clocks for all those, flash settings, core frequency, etc.
There have been several discussions in the forum on reducing the amount of flash and ram used for basic stuff, and we made quite some progress, but there is a limit.
STM is developing a new Arduino core based on their HAL, and takes much more RAM and flash for just blinking a led. That’s the cost of abstracting.
You could of course modify your core, so if for example if you dont plan to use i2c and spi, the peripherals don’t get initialized.
Still using 12KB on an MCU with 128KB, leaves you over 100KB free for code, and if that’s not enought, you can buy an stm32f103RCT6 board with 256KB (actual 512KB on most cases). Taking that into acount, the cost of 12KB used to nicely initialize everything for you doesn’t seem like a big cost.
Based on my experience with Eclipse, I do recommend EmBitz for it’s higher speed and debugging features, such as live view of variables, symbolic access of peripheral registers, and EB monitor. Like Eclipse, EmBitz is free.
Yep, precisely – this is why I was chiming in. Lots of good code and examples, then you either port it or re-write because it’s too troublesome to build within the IDE’ s limitations imposed by the Arduino interface
[…]
If you dont need any compatibility with Arduino, as you mentioned Atollic is free, and Segger has an IDE that’s free for non-comercial use, and then there is Eclipse. The CubeMX is a great tool to generate configuration files and peripheral libraries.
Actually I use St-link v2 (and I’ve got two Nucleos which have their own st-link). Works a treat under AC6, gnu-arm-eclipse, Attolic. Maybe others too…
With Cube… Well, I use it for pinout planning and clock hints but otherwise, I shun HAL
I am the SPL kind of guy… Maybe I will switch to HAL sometime, not just yet tho.
But when you want the arduino simplicity to work, then all lwo level stuff needs to be abstracted, and that results in those 12KB of basic code. Setting up usb, 2x i2c, 2/3 spi, 8 timers, clocks for all those, flash settings, core frequency, etc.
You know, I always wondered what’s wrong with using #includes and a PeripheralInit() instead of having it pre-defined And hidden away… Who uses *all* periphs on a chip anyway? Not to mention that, for instance with SPI (which is quite handy nowadays) having multiple ports open – or communicating with different slaves at different speeds and settings – could do with improvements, especially under the pre-defined setup… Just my opinion, of course
STM is developing a new Arduino core based on their HAL, and takes much more RAM and flash for just blinking a led. That’s the cost of abstracting.
Not so sure about the Ram, but one difference with HAL that I could see is that HAL perform more “complete” functions (e.g. inits) when compared to SPL. For instance, an SPL USART init requires clock enabling, GPIO setup, peripheral setup, maybe pin remapping. Under HAL it’s just one function. However I prefer the SPL way, and for time-critical sections, direct register access… Performance Improvements are quite pronounced there.
If you ask me, the main driver for HAL is implementing best practices when it comes to exception management. Also, makes it easier for the programmer to get by without reading the extensive chip documentation… Which all comes with the cost of unnecessary wasted cycles… I still remember the “old days” when assembly programmers where downtalking high-level code monkeys because of wasted resources. We all know how that one ended, but I feel that HAL is a bit over the top for my needs – at least for now…
You could of course modify your core, so if for example if you dont plan to use i2c and spi, the peripherals don’t get initialized.
That I tried, and found to be too involved and it’s IMHO the wrong approach – it should go – i need it, i enable it rather than the other way round… Too much hw, you see…
Still using 12KB on an MCU with 128KB, leaves you over 100KB free for code, and if that’s not enought, you can buy an stm32f103RCT6 board with 256KB (actual 512KB on most cases). Taking that into acount, the cost of 12KB used to nicely initialize everything for you doesn’t seem like a big cost.
There is nothing wrong for you, and for a lot of other people. But Arduino mainly appeals to the people that doesn’t necessarily needs to know how to initialize an SPI port, a few timers, cpu clocks, etc. That is the whole target or Arduino, and that is what this core is mainly about, although you still can have low level access to anything you want.
Also for many of the reasons mentioned in this thread, i’m currently working in visual studio with visualgdb & the cubemx code generator. i got great debugging, can create code for any stm32, far better IDE, …
But i’m very grateful this arduino port a IDE exists for doing the simple stuff, and it was also what allowed me to get started with all of this withouth a huge learning curve upfront
.
Also for many of the reasons mentioned in this thread, i’m currently working in visual studio with visualgdb & the cubemx code generator. i got great debugging, can create code for any stm32, far better IDE, …
But i’m very grateful this arduino port a IDE exists for doing the simple stuff, and it was also what allowed me to get started with all of this withouth a huge learning curve upfront
.
Some folks I know use “Visual Micro” which integrates openocd/gdb. So debugging should be possible there as well. Haven’t tried it myself though, I’m a Unix guy …
1. Install NppExec plugin
2. Add following commands:
Compile Sketch
//save current file
NPP_SAVE
cd "$(CURRENT_DIRECTORY)"
"c:\Program Files (x86)\Arduino\arduino_debug.exe" --pref build.path="$(CURRENT_DIRECTORY)/build" --verify "$(FULL_CURRENT_PATH)"
Need to figure out how to switch the IDE between target device types now though ![]()
Need to figure out how to switch the IDE between target device types now though ![]()
Probably overkill, but there is a scripable automation system for Windows called AutoIt, which you could use to change menu options in the IDE, and could run those scripts from NPP.
Probably overkill, but there is a scripable automation system for Windows called AutoIt, which you could use to change menu options in the IDE, and could run those scripts from NPP.
"c:\Program Files (x86)\Arduino\arduino_debug.exe" --pref serial.port="COM9" --pref serial.port.file="COM9"
java.io.IOException: Cannot run program “{runtime.hardware.path}/tools/win/maple_upload.bat”: CreateProcess error=2, The system cannot find the file specified
Some more tinkering and should hopefully sort it.
Is anyone using any of the C tools for NPP that allow you to look up where a function is defined and view it etc.
I’ve not figured out yet how to tell NPP that .ino should be treated as c++, if anyone has then please let me know
Is anyone using any of the C tools for NPP that allow you to look up where a function is defined and view it etc.
Go to 'Settings'->'Preferences'
Click on 'Auto-Completion' in the left hand list
Tick 'Enable auto-completion on each input'
Select 'Function and word completion'
Tick 'Ignore numbers' (if you wish)
Click 'Close'
Go to 'Settings'->'Preferences'
Click on 'Auto-Completion' in the left hand list
Tick 'Enable auto-completion on each input'
Select 'Function and word completion'
Tick 'Ignore numbers' (if you wish)
Click 'Close'
Clean
cd "$(CURRENT_DIRECTORY)"
cmd /c del "$(CURRENT_DIRECTORY)/build" /F /S /Q
I’ll create a NPP config thread and move everything over.
I’ll create a NPP config thread and move everything over.
