News for hackers. Stuff that matters.
Re:How to Write a Bootloader from Scratch by Koshkin on Thursday October 27, 2022 @01:44PM (#33361209)
(For a Cortex-M based microcontroller)
Re:How to Write a Bootloader from Scratch by kaycebasques on Thursday October 27, 2022 @02:09PM (#33361571)
(n00b q) are there big differences for Cortex-A and Cortex-M bootloaders? Any helpful tutorials for Cortex-A if so?
Re:How to Write a Bootloader from Scratch by megous on Thursday October 27, 2022 @02:30PM (#33361867)
Yes. DRAM initiazization, MMU, exception levels, trusted-firmware, initialization of specialized coprocessors for system power states management, more complicated storage access options (SD card/eMMC), etc. etc.
Re:How to Write a Bootloader from Scratch by sbf501 on Thursday October 27, 2022 @03:57PM (#33363153)
Most of those aren't Cortex-A specific, you've just listed mostly peripherals that are typically initialized in the application space (except for a secure boot).

E.g. you aren't going to go into power savings mode during boot, nor are you going to initialize peripherals (because their contexts will be lost once you jump to the application).

Initializing assymetric processors can be done in application space with a variety of tools (AMP) as well. I haven't seen a need to initialize them during bootloader1 phase, but there are lot of use cases.

Re:How to Write a Bootloader from Scratch by megous on Thursday October 27, 2022 @10:34PM (#33366894)
Majority of Cortex-A cores are in complex SoCs, where you have to do all of the above and more if you want to boot something like Linux.
Re:How to Write a Bootloader from Scratch by sbf501 on Saturday October 29, 2022 @12:25AM (#33380952)
What are you talking about? The MCU is the first thing to boot. Wait, do you not know what a bootloader is? It's not GRUB.
Re:How to Write a Bootloader from Scratch by megous on Sunday October 30, 2022 @11:54AM (#33395520)
Yes, I wrote one bootloader for a SoC, and read through several other bootloaders to be able to make modifications to them. I've also reverse engineered several binary only bootloaders for undocumented MCUs to be able to write sane Linux based flashing tools for them.

Kinda know what bootloader is. And, while I don't care about the naming, I know several people who would vehemently disagree with you that grub is not a bootloader. They'd say that only grub is a bootloader, and anything else running prior to that is platform firmware.

Cortex-A is not typically used in MCUs, so I don't see what you mean by "The MCU is the first thing to boot".

Re:How to Write a Bootloader from Scratch by auxym on Thursday October 27, 2022 @02:25PM (#33361815)
Cortex-A appears to be way more vendor-implementation dependent. For example, I remember reading that the Raspberry Pi SoC, which uses a Cortex-A72 core, actually boots off its GPU.
Re:How to Write a Bootloader from Scratch by fra on Thursday October 27, 2022 @03:46PM (#33363022)
Yes, an important qualifier! In practice the vast majority of embedded projects out there are on cortex M, with a bit of xtensa (ESP32) and a bit of RISC-V.
Re:How to Write a Bootloader from Scratch by chinabot on Thursday October 27, 2022 @06:48PM (#33365043)
and 32-Bit microprocessors are still only about 1/3 of total microprocessors by volume (source https://www.ednasia.com/8-bit-mcu-still-alive-and-kicking/)
Re:How to Write a Bootloader from Scratch by hra5th on Thursday October 27, 2022 @01:57PM (#33361388)
For Cortex-M embedded topics, memfault's blog is simply one of the best out there. Consistently great posts even though they are written by a bunch of different authors. I go back to https://interrupt.memfault.com/blog/cortex-m-fault-debug all the time when debugging hard faults on different systems.

Even if you regularly write embedded code for Cortex-M MCUs, scroll through their list of posts and you'll find several that will teach you something new and useful.

Re:How to Write a Bootloader from Scratch by RealityVoid on Thursday October 27, 2022 @04:57PM (#33363938)
I'm a bit jealous of the fact they have such good blog posts. I did a deep dive on a couple of different architectures and always wanted to write something so nice and useful for other people with the stuff I know.
Re:How to Write a Bootloader from Scratch by dang on Thursday October 27, 2022 @02:22PM (#33361757)
Related:

From zero to main(): How to write a bootloader from scratch - https://news.ycombinator.com/item?id=24635383 - Sept 2020 (44 comments)

Re:How to Write a Bootloader from Scratch by kaycebasques on Thursday October 27, 2022 @03:04PM (#33362422)
The CMSIS-DAP adapter referenced in the tutorial is discontinued. Can one of you hardware pros point me to a suitable replacement?

Also asked the author here: https://mobile.twitter.com/kaycebasques/status/1585708384531...

Re:How to Write a Bootloader from Scratch by codys on Thursday October 27, 2022 @03:22PM (#33362685)
Re:How to Write a Bootloader from Scratch by fra on Thursday October 27, 2022 @03:45PM (#33363012)
Author here. It's surprising how hard CMSIS-DAP adapters are to find. The two options shared by codys look reasonable, but I'm working on putting together a better option.
Re:How to Write a Bootloader from Scratch by zwirbl on Thursday October 27, 2022 @04:00PM (#33363203)
I'm using https://github.com/probe-rs/hs-probe most of the time, sometimes I get out a jlink
Re:How to Write a Bootloader from Scratch by scoutt on Friday October 28, 2022 @08:14AM (#33370425)
We use these in production because the IO signals are buffered: https://www.artekit.eu/products/debug/ak-cmsis-dap/
Re:How to Write a Bootloader from Scratch by joko42 on Thursday October 27, 2022 @07:51PM (#33365657)
"Zero to main" is the best resource there is about writing bootloaders. Wrote my first boatloader with the help of this series.