Starter questions on microcontroller programming development tools - embedded

I was recently assigned a micro-controller programming task. I will need to program on MKL05Z32VFM4 device.
I was reading some programming tutorials on Microchip Technology's MPLAB IDE X, because that seems to have the most information, but looks like that IDE is only for Microchip products.
What development tools should I choose for MKL05Z32VFM4? Are there a generic IDE and simulator environment? Are there some tutorials for me to start to look at?
I apologize for a basic question. I am a decent general software developer, but I am very new to this area.

(this post will be partly useless if you plan to use some commercial toolchain like Keil, IAR or sth like that)
For ARM Cortex devices you have quite a lot of options available (; If you're in a mood for a bit of automatic translation you could check my website - I wrote a tutorial about (open source) toolchain for ARM - http://www.freddiechopin.info/pl/artykuly/35-arm/59-arm-toolchain-tutorial - unfortunately it's not translated to English, so you'll have to use google translate. There are also some other resources that you might find useful, especially my template/example projects for such toolchain (in Download). If you ever used Eclipse, Makefile and GCC this whole subject should be easy for you. Most of example projects will be close to what you need, but you should probably check example for STM32 (any) - which is a Cortex-M3, and the example for LPC1114 - which is a Cortex-M0.
As for the simulator, I personally think they're not worth the trouble, recent GCC toolchains disable it anyway, as it's only instruction simulator, you won't be able to easily simulate peripherals. If you want to simulate instructions just write your code for PC as it will work the same way (; If you need to check something on the real hardware you can use GDB and JTAG. As long as it's not some extremely expensive proprietary design (you can - again - check my website for other options) the tools are almost free - OpenOCD (GDB Server) is open-source, and you can buy a FTx232 based JTAG (the most popular kind for OpenOCD) starting at ~30$.
Big commercial toolchains sometimes have simulators with peripherals simulation, but these cost a few thousand € / year (;
Google around for "ARM Cortex" with keywords like: toolchain, gcc, openocd, debugging, jtag etc. to find some articles - there's a lot of it in the network.
Your question is really general, so pretty hard to answer, as we don't know what tools are you going to use, are you planing to use some external libraries, what type of work are you going to do with these devices etc.
From my experience contact with embedded world is often a huge shock for developers of PC software. It mostly works the same, but because resources are constrained you really should do things differently. You don't have "+infinity" of RAM, you should usually try to fit a lot of things in ROM and so on. And of course there's only C and C++, but in C++ you shouldn't use some of it's features (exceptions, RTTI, iostreams, parts of STL, ...), dynamic allocation of memory is not a good idea generally (with the chip you mentioned - 4kB of RAM - it's out of question in my opinion).
The chip you mentioned is really tiny, so it will probably be a bigger shock (;
Try to ask some specific question and give some more details about your project so we could give more detailed answers (;

That's a Cortex-M0 device. You can find lots of information online. You can start at arm.com. As far as toolchains go, gcc and clang are both free and support ARM and will work fine. You can get ARM's tools too, if that's what you're into. JTAG for debugging is going to cost you - most people use ARM's in-house RealView debugger or Trace32 from Lauterbach. I've also used the BDI3000 from Abatron.

It looks like a Freescale MCU. Freescale's IDE of choice is CodeWarrior.

A good place to start is the part manufacturer's site, generally they will have tools or links to recommended third parties as well as application notes and libraries. Start at the Freescale Kinetis KL0 series "Software & Tools" page.
Freescale's own CodeWarrior tool is Eclipse based.

Related

It's possible to interact with opencv and screen outside vm window?

I worked with smalltalk as hobby when Pharo born. A lot of years passed without touching it, and I'm sure a lot of things happened in smalltalk world. Now I have some projects in my mind and my main idea was to develop using python but I'm thinking to retake this enviroment I loved. One of this projects is about using opencv for recognition from a Webcam, recognition of screen changes in other windows, and painting specific things on screen (a board game).
My idea is to develop on Linux and Windows, and release on Windows/Linux/Mac. Right now which ST flavour fits the interaction I need? Right now what's the main difference between Pharo an Squeak?
Thanks.
I'm sure there are more qualified people around to answer this question. I'll try to be as objective as possible, but these are only my opinions others can see it otherwise. I will write only short description for each.
The interaction would have to be done via FFI.
I also don't know every dialect there is. For example, I haven't heard of trufflesqueak before.
To fit your picture windows/linux/mac:
These smalltalk(s) have the VM support you require (in random order): GemStone, Pharo, Squeak, Cuis-Smalltalk
GemStone/S - is a distributed Smalltalk system with a massive, persistent memory. Offers free usage and also has a commercial support. Very nice Smalltalk with many platforms supported. Windows is supported only as client.
Pharo is a open-source implementation which was originally forked from Squeak. Nice environment, which you know, but it needs to cleanup the code. It has very fast development cycle. In my eyes, the newest VMs have stability issues. The description here on SO.
Squeak the original Smalltalk-80 implementation with plenty of legacy code, but the VM is quite stable and lately it works very nice. The description here on SO.
Cuis-Smalltalk is a multiplatform Smalltalk-80 implementation. Cuis shares the OpenSmalltalk Virtual Machine with Squeak, Pharo and Newspeak. I did not see any projects created in Cuis, maybe somebody can correct me.
Other interesting smalltalks:
Dolphin (windows only) - nice smalltalk for Windows. Supports integration with Windows and calling windows code.
Smalltalk/X - for Windows and Linux VM (there is MacOS VM port for Smalltalk/X but it is not public yet, maybe it will appear on Smalltalk/X-jv later on). Developed by eXept mainly by Claus Gettinger. There is an independent branch Smalltalk/X-jv - list of features and the description on SO.
Commercial Smalltalks
You can try these out, but you for commercial use you have to pay license fee.
VAST owned by instantiations - they are working on MacOS support but it is not there yet. Very mature Smalltalk with commercial support.
Cincom's VisualWorks - The development is somewhat lacking lately but still Smalltalk with company behind it.
Pharo Spec (the widget library) has a Gtk3 backend that can be used to develop application in any platform (there are a few targeting windows), and I know there was work done using OpenCV, but you will have more luck asking that in our discord channel (https://discord.gg/QewZMZa) or any of our mailing lists (check links here: https://pharo.org/community).

How to make a normal C library work with embedded environment?

I was recently asked about how to use a C library (Cello in this case) in an embedded environment, but I'm not sure how to go about that.
Is it correct to say that if a library can be compiled in the embedded environment, it can be used?
Should I care about making the library more lightweight or something like that?
Any suggestions are appreciated.
To have it compile is the bare minimum. Notably most embedded systems are freestanding systems, such as microcontroller and RTOS applications. Compilers for freestanding systems need not provide all standard library headers, the only mandatory ones are (C17 4/6):
<float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>,
<stddef.h>, <stdint.h>, <stdnoreturn.h>
In addition, the embedded system need not support floating point arithmetic. Some systems implement software floating point support, but using that is very bad practice. If your MCU does not have a FPU, you should not be using floating point arithmetic, or you picked the wrong MCU for the task, period.
"I need to represent this number with decimals internally or to the user" is not a valid reason for using floating point. Fixed point arithmetic should be used for that. You only need floating point if you are to use math libraries like math.h and more advanced math.
Traditionally, embedded system compilers have been slow to adapt the latest C standard. It's been quite a while since C11 release now though, so at the moment all useful compilers have caught up with it (C17 only contains minor changes so we can likely ignore that one). Historically, embedded compilers have been horribly bad at this though, so remain sceptical. There shouldn't be any reason to pick a compiler without C11 support for new product development.
Summary for getting the lib to compile (bare minimum):
Does the library use hosted system headers, and if so does the embedded compiler support them?
Does the library use floating point and if so does the target system have a FPU, or at least a software floating point lib?
Does the library rely on the latest C standards and if so does the embedded compiler support them?
With that out of the way, you have to consider if the library is at all written to be portable. Did they take care with things like integer types, enums and alignment? Are they using stdint.h or are they using "sloppy typing" int all over the place? Did they consider endianess? Is the lib using dynamic allocation, which is banned in most embedded systems? Is it compatible with industry standards like MISRA-C? And so on.
Then there's optimizations to consider on top of that. Optimizing code for microcontrollers is very different than optimizing code for PC CPUs.
A brief glance at the various "compiler switches" (#ifdef) present usually gives a clue of how portable the code is. Looking (very briefly) at this cello lib, they seem to have considered porting between mainstream x86 systems but that's it. You would have to rewrite pretty much the whole lib if you were to port it to an embedded system. The work effort depends on how alien the target CPU is compared to x86. Porting to a high end Cortex-A with Little Endian might not require much effort. Porting to some low-end crap MCU would require a monumental effort.
Code portability is a big topic and requires very competent C programmers. To make the very same code run on for example a x86-64 and a crappy 8-bit MCU is not a trivial task.
Professional libs like protocol stacks usually come with a system port for a specific MCU, where they have not just taken generic portability in account, but also the specific system.
Not all libraries that can be compiled, can be used in embedded environments. Libraries that use malloc and free (or their C++ counterparts) are dangerous and therefore should be handled with care. These libraries can result in undeterministic behaviour because of memory allocations failing.
It is possible that the standard C STD could be wholly compiled for embedded devices but that doesn't mean that you'll have much use for printf or scanf. So a better question before you ask if you can compile it is should you use it. Cello seems like a fun experiment but isn't a stable platform to develop something real on. It can be done though and an example of that is the Espruino.
Most of the time it is a bad idea to rewrite a library to be 'lightweight' or more importantly in an embedded environment: statically allocated. You are probably not as smart as those people or won't put in the time needed to create a complete functional embedded fork which is as stable as the original or even better. Don't be dissuaded for a fun little side project but don't depend on it for a real project.
Another problem could be that the library is too big for your microcontroller. The Atmega32a only has 32KB of programmable flash. To take a C++ example of the top of my head: boost won't fit in that space even for all the highly useable tools that it provides.

Atmel C compiler manual?

I'm just getting started with the Attiny84 on AVR Studio 5 (based off of Visual Studio). However, I cant find the C programmers manual for it so I can figure out how to write ISR's, address GPIO pins, etc... Any ideas where I could find the manual for it?
Just looking at the AVR Studio 5 web page, it looks as though it can use the GCC compiler--not sure what other compilers it might be able to use.
The GCC compiler is an open-source compiler used for many platforms, so documentation is available for that from many places on the Internet.
The other thing I could suggest is taking a different approach: start by looking at some publicly available code for the AVR. AVR Studio 5 is in beta, but I expect it wouldn't be hugely different from what has already been in use for several years (AVR Studio 4 etc). AVR Freaks is a good resource for looking at AVR code done by others, for a wide range of applications.
It takes a bit of hunting down, but according to this press release, the integrated compiler is GCC. The GCC documentation is at http://gcc.gnu.org/onlinedocs/ for all versions.
In the 4.6.0 release, AVR specific sections are:
3.17.2 AVR Options
6.37.8 AVR Variable Attributes
The Atmel AVR Studio 5 web page claims that it has several hundred example projects included, I am sure than many of them include interrupt handler examples.
So the official manual is located here (provided by Atmel Applications Engineer):
http://www.nongnu.org/avr-libc/user-manual/modules.html
It had all the information I needed to get up and running.
I too am just getting started with AVR Studio 5. When doing GPIO, interrupts etc, I think you will want to leverage the code already provided in the ASF (Atmel Software Framework). Under the Project menu use the "Select Drivers from ASF..." to select the pieces you need. Alternately you can load sample projects targeted for your processor. I found the AVR Studio screencasts on the Atmel site (they are also on YouTube) worth watching.

Arm Board Bring Up

Can anybody tell me where I can find information related to How to Bringup any arm board? I am looking for an overview as I am novice in ARM related stuffs. Any link/document will do ...It will be gr8 help if i can look for a case-study
any arm based board can be considered..I am looking for just a case study...simple in few steps??
Every single ARM "board" will be different. Read the datasheet for the ARM chip you have, that should have a section near the start about booting. Also, read the datasheet about your board, as it made have flash/boot loaders on there. If there are no loaders on the board, you'll have to either set the jumpers for the ARM (if that type supoprts it) to read from external rom, or JTAG the initial boot code into it.
Basically: Read the datasheets. Programming a device like an ARM isn't your usual compile/run stratergy like most software, especially not in the first stage.
edit:
If you don't even have a board yet, try going for this one:
http://beagleboard.org/
It has and ARM on it (as well as a decent GPU).
Check the DLP-2232PB-G evaluation kit from FTDI. Looks great for newbies trying to get into microcontrollers, and it comes with everything you need. It's a PIC controller - not an ARM controller, but the easiest starting point that I've seen... and same basic methods of development.
I would start with any documentation the IC manufacturer may have on "getting started".
http://free-electrons.com/doc/porting-kernel.odp
This link gives a good overview of the bringup of the board with a CPU for which the linux support package is available.
Linux sources in arch/arm have mach-* which are cpus supported by Linux Kernel.
With in the mach-* dir, there are some board specific files that are board specific BSPs.
You can take the process elucidated in this article and try using in your case.
Check out the ok6410-h at http://www.arm9board.net/sel/prddetail.aspx?id=348&pid=200
Quit a nice kicking-start kit coming with everyting you would ever need: documentations, source code, example programs.
recommendable for both newbies and experienced.

F/OSS for the PIC24?

I'm learning embedded programming with the PIC24, and I'm looking for something "real-world" to dig into to help me learn. Are there any free software projects that might be targeting to the PIC? Anything that I could help port, or a niche I could try to fill?
Quite old (2005) but may help you to start:
http://www.gnupic.org/
For example, gpsim at http://www.dattalo.com/gnupic/gpsim.html
If you are looking for software projects, look up gputils - is the open source assembler and linker, and sdcc - an open source c/c++ compiler (lacks a PIC24 port).
If you are looking for embedded projects, there is nothing specific that comes to mind. However, do visit the piclist to pick up code snippets and learn from examples. Some of the best PIC coders contribute there.
If you are looking for hardware projects, there are verilog PIC16/18 cores on opencores but no PIC24 cores yet.
So, there's plenty to suit all tastes.