
Run a C program bare metal on an ARM Cortex M3 - ingve
https://jacobmossberg.se/posts/2018/08/11/run-c-program-bare-metal-on-arm-cortex-m3.html
======
filereaper
Nice, there aren't really that many guides on bare-metal programming. In
general the difficult part is finding the Memory Maps across all the data-
sheets and programming manuals. ARMs being SOC's these might change across
development boards.

Super appreciate this article, might dust off my of Pandaboard again :)

------
davidgould
I'm just getting started with STM32 and this was very informative. I
especially liked that you chose a minimal example and walked through the tool
chain in detail. It's important to be able to read the compiler output for
debugging and optimization and this presented it well. Thanks!

However, why not mention or explain the widely available and extremely
affordable ST-link2 or the ST Discovery boards? I suspect that for people just
getting started with STM32 these would be more common.

------
progamer2018
I would like to see version of rust language implementation on ARM CPU like
[https://os.phil-opp.com/](https://os.phil-opp.com/)

------
sytelus
This is excellent tutorial! I wonder if there is similar tutorials for C++11.
It would be great to see more information what to do and don't if you want to
run your code on bare metal.

~~~
Koshkin
Rule #1: Do not use C++11. (To be fair, this may depend on which metal - the
language could be perfectly usable on larger systems, but those could be much,
much more difficult to program at the bare metal level in the first place.)

~~~
convolvatron
it would help me alot personally if you gave some context here? i'm on a
project where i'm tooling along happily in C and a new contributor really
thinks we should do it in C++11...and arguably some of the things that we're
currently doing would be somewhat cleaner. "I've always thought C++ was a
mess" is not useful counter. do you have to bring in more runtime? does it
require more messing about with stacks?

~~~
mutac
I honestly think that, at this point, it's often a matter of taste, rather
than technical. What tool do you think will make you more productive and
interested in the project?

I personally don't think there's anything wrong at all with using c++11 (or
any version) on devices like this, so long as the compiler you need to use
provides a stable implementation of it. The new language features of c++11,
like constexpr and move semantics, and the static meta-programming
contraptions that are readily at hand in the STL can all be very helpful to
create manageable and fast embedded systems.

Though it usually isn't a free for all. These things are commonly avoided:

* Exceptions (in many cases this alters the call-return sequence, which can increase code size, and add overhead that may not be acceptable)

* Most of the STL (because either a feature requires exceptions to use safely--like containers, or perhaps because the feature doesn't fit into your code section, or just takes up too much of it to be worthwhile)

* RTTI (which can increase the size of a vtable)

[https://news.ycombinator.com/item?id=12138374](https://news.ycombinator.com/item?id=12138374)

