{"id":8942,"date":"2019-03-25T10:14:27","date_gmt":"2019-03-25T09:14:27","guid":{"rendered":"https:\/\/blogs.mentor.com\/colinwalls\/?p=8942"},"modified":"2026-03-26T16:56:46","modified_gmt":"2026-03-26T20:56:46","slug":"programming-on-bare-metal","status":"publish","type":"post","link":"https:\/\/blogs.sw.siemens.com\/embedded-software\/2019\/03\/25\/programming-on-bare-metal\/","title":{"rendered":"Programming on bare metal"},"content":{"rendered":"<p>I am surprised by how often I am asked about how one might go about programming on \u201cbare metal\u201d &#8211; i.e. without the support of an OS of any kind. Historically, this was a common approach &#8211; maybe no other option was available. However, modern engineers, faced with the idea of filling a completely empty memory with their own code, are often somewhat flummoxed \u2026<!--more--><\/p>\n<p>In the early days of embedded systems development, software was rather minimal and often something of an afterthought. Commonly, it was developed by the same engineer(s) who had designed the hardware and, naturally, their code interacted very closely with the electronics. They understood all the nuances of the hardware\u2019s behavior, so it was not seen as a particular challenge.<\/p>\n<p><a href=\"https:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/51\/2019\/03\/1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-8943\" src=\"https:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/51\/2019\/03\/1-520x320.png\" alt=\"\" width=\"200\" height=\"123\" \/><\/a><\/p>\n<p>As systems became somewhat more sophisticated, software specialists began to be involved, but they tended to be engineers with a significant knowledge and understanding of hardware, so they too were quite happy programming close to the hardware.<\/p>\n<p><a href=\"https:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/51\/2019\/03\/2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-8944\" src=\"https:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/51\/2019\/03\/2-520x521.png\" alt=\"\" width=\"200\" height=\"200\" \/><\/a><\/p>\n<p>As complexity increased, the single software engineer became a team. Different team members would have different types of expertise. Those with good hardware knowledge would encapsulate that expertise in software modules that provided a clean interface and concealed the complexity of hardware interaction; these modules were termed <em>drivers<\/em>.<\/p>\n<p><a href=\"https:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/51\/2019\/03\/3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-8945\" src=\"https:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/51\/2019\/03\/3-520x777.png\" alt=\"\" width=\"200\" height=\"299\" \/><\/a><\/p>\n<p>With increasingly powerful microprocessors\/microcontrollers and larger memories, the need for a rational program structure drove the adoption of real-time operating systems (RTOSes) that enabled the use of a multi-tasking model. It was a natural progression for the drivers to become part of the RTOS.<\/p>\n<p>But, what about programming on bare metal today?<\/p>\n<p>Although the largest proportion of modern embedded software designs are implemented utilizing an OS of some kind, there are a couple of circumstances when doing without \u2013 programming on bare metal \u2013 may be a reasonable decision:<\/p>\n<ol>\n<li>If the application is extremely simple and is implemented, perhaps, on a low-end processor.<\/li>\n<li>If there is a need to extract every last cycle of CPU power for the application and the overhead introduced by an OS is unacceptable.<\/li>\n<\/ol>\n<p>(1) is a real possibility and makes sense. (2) is much less likely, as powerful CPUs are very readily available and cheap; a careful choice of OS, focusing on <a href=\"https:\/\/www.mentor.com\/embedded-software\/nucleus\/\" target=\"_blank\" rel=\"noopener noreferrer\">high-efficiency RTOS products<\/a>, would make most sense. In both cases, thought must be given to possible future enhancements to the software. If further development is likely, starting out with a scalable program structure is a worthwhile investment.<\/p>\n<p><a href=\"http:\/\/www.linkedin.com\/in\/colinwalls\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-6579\" src=\"http:\/\/s3-blogs.mentor.com\/colinwalls\/files\/2014\/01\/linkedin.png\" alt=\"\" width=\"40\" height=\"40\" \/><\/a><a href=\"https:\/\/twitter.com\/colin_walls\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-6583\" src=\"http:\/\/s3-blogs.mentor.com\/colinwalls\/files\/2014\/01\/twitter.png\" alt=\"\" width=\"40\" height=\"40\" \/><\/a><a href=\"https:\/\/www.facebook.com\/colinwalls.author\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-6591\" src=\"http:\/\/s3-blogs.mentor.com\/colinwalls\/files\/2014\/01\/facebook.png\" alt=\"\" width=\"40\" height=\"40\" \/><\/a><a href=\"http:\/\/blogs.mentor.com\/colinwalls\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-6599\" src=\"http:\/\/s3-blogs.mentor.com\/colinwalls\/files\/2014\/01\/wordpress.jpg\" alt=\"\" width=\"44\" height=\"44\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am surprised by how often I am asked about how one might go about programming on \u201cbare metal\u201d &#8211;&#8230;<\/p>\n","protected":false},"author":71677,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spanish_translation":"","french_translation":"","german_translation":"","italian_translation":"","polish_translation":"","japanese_translation":"","chinese_translation":"","footnotes":""},"categories":[1],"tags":[701,435,511,300,304,374,378,309],"industry":[],"product":[],"coauthors":[],"class_list":["post-8942","post","type-post","status-publish","format-standard","hentry","category-news","tag-bare-metal","tag-device-drivers","tag-drivers","tag-embedded-software","tag-nucleus","tag-nucleus-os","tag-nucleus-rtos","tag-rtos"],"_links":{"self":[{"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/posts\/8942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/users\/71677"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/comments?post=8942"}],"version-history":[{"count":1,"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/posts\/8942\/revisions"}],"predecessor-version":[{"id":10773,"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/posts\/8942\/revisions\/10773"}],"wp:attachment":[{"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/media?parent=8942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/categories?post=8942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/tags?post=8942"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/industry?post=8942"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/product?post=8942"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/embedded-software\/wp-json\/wp\/v2\/coauthors?post=8942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}