TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Where to start in writing my own bootloader?

8 pointsby Shanedoraover 6 years ago
I would like to write my own bootloader for a arm cortex-m4 processor. Read a few articles, searched a few blogs but I'm still struggling in finding the right resources. I'm looking for a deeper dive into the instruction on how and less "here is the code".

5 comments

lovelearningover 6 years ago
I&#x27;ll recommend two books. I don&#x27;t know if these are the &quot;best&quot; books on the subject, but <i>I</i> found them useful for some system-level experiments I did on an Odroid. They explain both the big picture and implementation details:<p>1) <i>Professional Embedded ARM Development, by Langbridge [1]</i><p>This one is more about ARM instructions than about bootloaders or embedded OSes, but it does cover bootloaders in detail with case studies of some relatively unknown embedded boards, of the well-known Raspberry Pi, and of modern bootloader software like u-boot.<p>2) <i>Building Embedded Systems, by Gu [2]</i><p>This book is broader than the one above, covering all kinds of embedded systems. It&#x27;s the better book to understand the big picture, and understand how all the components (bootloader, OS, SoC, hardware buses, storage) interact. It does cover bootloaders but not in depth and not with case studies.<p>[1]: <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Professional-Embedded-Development-James-Langbridge&#x2F;dp&#x2F;111878894X" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Professional-Embedded-Development-Jam...</a><p>[2]: <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Building-Embedded-Systems-Programmable-Hardware&#x2F;dp&#x2F;148421918X&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Building-Embedded-Systems-Programmabl...</a>
conorppover 6 years ago
Some bootloaders can be really simple. Here is one I wrote recently for my security key product (this particular code is for an ARM M3).<p><a href="https:&#x2F;&#x2F;github.com&#x2F;SoloKeysSec&#x2F;solo&#x2F;blob&#x2F;master&#x2F;targets&#x2F;efm32boot&#x2F;src&#x2F;main.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;SoloKeysSec&#x2F;solo&#x2F;blob&#x2F;master&#x2F;targets&#x2F;efm3...</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;SoloKeysSec&#x2F;solo&#x2F;blob&#x2F;master&#x2F;targets&#x2F;efm32boot&#x2F;src&#x2F;boot.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;SoloKeysSec&#x2F;solo&#x2F;blob&#x2F;master&#x2F;targets&#x2F;efm3...</a><p>Like what others mention, it really depends on documentation from the vendor for the chipset you&#x27;re working with. I mainly copied and pasted code from a form post by the vendor.<p>And of course link to the security key product :)<p><a href="https:&#x2F;&#x2F;solokeys.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;solokeys.com&#x2F;</a>
davelnewtonover 6 years ago
I&#x27;m not sure what you&#x27;re actually looking for. It might help if you defined what you considered a &quot;bootloader&quot; to be. Are you trying to bring up an existing OS or app? Are you trying to initialize the processor prior to running your own code?
评论 #18114510 未加载
MrTonyDover 6 years ago
A couple of times I wrote bootloaders for new chips. I relied heavily on the chip vendors documentation. It was usually almost non-existent, and no more than text saying what things I had to do in what sequence. But taking that info, then looking at other bootloaders for operating systems (to see if there was environment specific things I should be considering) I was able to create boot loaders.
评论 #18114530 未加载
anitilover 6 years ago
At the end of the day, a bootloader is just memcpy, and a jump (with a few details like setting up a stack, any serial ports etc).<p>You usually can have quite a bit of help by looking at the generated code from your compiler that sets up a simple &#x27;main(...){ while(1); }&#x27; program. Often it&#x27;ll be in your toolchain as a .S file or similar.