View: 5945|Reply: 4

"Bare metal" boot

[Copy link]

1

threads

3

posts

17

credits

Novice

Rank: 1

credits
17
Published in 2021-5-6 10:34:02 | Show all floors |Read mode
Hello everyone,

I'm trying to do a bare metal minimal boot on the Zero 2 (at least, I think that's what I did):

  1. void _start() {
  2.     static constexpr uint32_t GpioRegisterBase = 0x0300B000;
  3.     write_register( GpioRegisterBase + 0x4c, 0x1111'1111 );
  4.     write_register( GpioRegisterBase + 0x58, 0xffff );

  5.     while(true) {}
  6. }
Copy code

Compiled and verified the binary does what I need (position independent). I then used the mksunxiboot tool from the latest u-boot to get an 8KB image, which I wrote to an SDCard at 8KB offset in. When put in the Zero 2, I expected to see the power and status leds turned on. Instead, I got nothing. Now I don't know whether my code doesn't run, or whether it runs, but isn't turning on the leds for whatever reason.

Can anyone help?

  • I know that I'm not initializing the ram or the clocks or, well, anything. My understanding is that it shouldn't matter to such a small program.
  • I know u-boot is doing ... something with the "arm trusted firmware". I have it compiled, but I'd rather not have to use it if I can avoid it. For educational reasons, I'd rather be the one who initializes the RAM and the MMU, and the firmware does both if I let it. At least for now, I do not need to run at EL3, so this shouldn't be a blocker.


1

threads

3

posts

17

credits

Novice

Rank: 1

credits
17
 Author| Published in 2021-5-6 14:44:32 | Show all floors
I've ruled out "arm trusted firmware" being the cause of the problem. When I take u-boot's pre-trusted image, run mksunxiboot on it, and flash it, I do get boot messages on the serial console. So I'm guessing that my code _is_ running, just not setting the GPIOs correctly.

1

threads

3

posts

17

credits

Novice

Rank: 1

credits
17
 Author| Published in 2021-5-9 16:27:44 | Show all floors
I've finally managed to get it working.

The main failure that was blocking me from seeing results was that the machine boots in 32 bit mode. I copied the "switch to 64 bit" code from u-boot, and could finally see the leds lighting up.

0

threads

3

posts

64

credits

Registered member

Rank: 2

credits
64
Published in 2022-12-11 17:40:18 | Show all floors
Can someone please help me explain all that is in relation to a bare metal boot and what it even means? I first heard about this term on https://www.sjhmalu.com/product/20-series-aluminum-extrusion-profile, but ever since then, I've been left confused in respect of. So I really do want to know more about it.

1

threads

26

posts

123

credits

Registered member

Rank: 2

credits
123
Published in 2023-9-27 01:27:03 | Show all floors
Bare metal boot refers to the process of starting a computer or server directly from its hardware, bypassing any operating system or software layers. This approach is crucial for specific applications that demand optimal performance and control, such as high-frequency trading or scientific simulations. When it comes to bare metal boot solutions, www.yonglongalu.com offers cutting-edge hardware provisioning services, ensuring rapid and efficient deployment of servers.
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list