The Raspberry Pi 4 board is a very popular mini-computer for learning about computing or even for more serious applications. The board also exists in an integrated configuration with a keyboard: the Raspberry Pi 400.
It is generally used with a Linux distribution, but it is possible to run Minimacy directly, in bare metal.
Many baremetal projects exist for Raspberry Pi 4 and have inspired this version of Minimacy. Their authors are: Rene Stange, Zoltan Baldaszti, Adam Greenwood-Byrne, ...
[
](html)
#Getting Started
Steps:
- Assumes prior familiarity with Minimacy on a host computer
- Prepare the SD card and launch blink
- Connect the console, launch the romdisk.server.mcy program on the host
- Understand how disks work in baremetal mode
- Modify boot.mcy
- Use the flash disk
##Minimacy
Minimacy is a highly cross-platform technology: computers, mobile phones, and embedded baremetal.
When working on embedded products, you will generally develop the components of your application on your computer, then transfer them to the embedded product.
This implies that you are already familiar with Minimacy on a computer. This guide assumes you have already installed Minimacy, that you know how to run programs (*.mcy files), and that you have some basic knowledge of the Minimacy language.
This guide covers the Raspberry Pi 4 board (and the Raspberry Pi 400), as it is the best documented. You should have:
- A Raspberry Pi 4 board, regardless of its memory size
- A computer (Windows, Linux, Mac)
- A USB / USB-C cable to power the Raspberry Pi 4 board
- A USB / UART cable to connect the CONSOLE output of the Raspberry Pi 4 board to the computer. This cable can also power the Raspberry Pi 4 board.
- A micro-SD card formatted in FAT32
- A micro-SD card reader for your computer
##Blink
Insert the SD card into your computer.
Verify that the card is formatted as FAT32.
First copy the following official files. You can also find them on the Raspberry Pi GitHub repository: [github link](https://github.com/raspberrypi/firmware/tree/master/boot)
- [bcm2711-rpi-4-b.dtb](http://minimacy.net/book/rsc/rpi4/bcm2711-rpi-4-b.dtb)
- [fixup4.dat](http://minimacy.net/book/rsc/rpi4/fixup4.dat)
- [start4.elf](http://minimacy.net/book/rsc/rpi4/start4.elf)
- [LICENCE.broadcom](http://minimacy.net/book/rsc/rpi4/LICENCE.broadcom)
Then copy the two files specific to Minimacy: the Rasbperry Pi 4 configuration file and the Minimacy virtual machine, named minimacyRpi4.img:
- [config.txt](http://minimacy.net/book/rsc/rpi4/config.txt)
- [minimacyRpi4.img](http://minimacy.net/book/rsc/rpi4/minimacyRpi4.img)
At this point, the SD card contains everything needed to use Minimacy. All that is missing is the application you want to run.
[
](html)
By default, Minimacy launches the boot.mcy program found:
- On a computer: in the ./programs/ directory
- On Raspberry Pi 4: at the root of the SD card
At the root of the SD card, create a file boot.mcy with the following content:
fun blink(state)=
led(state);
onTimeout(500, lambda()= blink(!state));;
fun main() =
blink(true);;
This program blinks the green LED on the Raspberry Pi 4 board, toggling its state every 500 milliseconds.
Eject the SD card from your computer and insert it into the Raspberry Pi 4 board.
Connect the Raspberry Pi 4 board to your computer using the USB/USB-C cable.
The board powers on (steady red LED), and after a few seconds, the green LED starts blinking.
Congratulations! You have just run your first bare metal embedded program on Raspberry Pi 4. And you only needed a text editor of your choice!
For the rest of the getting-started guide, delete the boot.mcy file from the SD card.
##Console
To develop efficiently, you need to interact with the Raspberry Pi 4 console. This is a text-mode interface accessible from your computer, based on a serial (UART) connection initialized at 115,200 bps (8 bits, no parity, 1 stop bit).
To do this:
- Connect the USB/UART cable: one end to your computer, the other to the pins of the Raspberry Pi 4 as shown in the image below:
[
](html)
- Pin 6: ground
- Pin 8: TX (the board sends data to the computer)
- Pin 10: RX (the board receives data from the computer)
Additionally, if your USB/UART cable has a 5V output (red cable in the image), you can connect it to pin 2. You will then no longer need the USB/USB-C cable mentioned in the previous chapter. Note: this does not work for the Raspberry Pi 400, which must continue to be powered via the USB/USB-C cable.
It is also recommended to solder a small RESET switch to the board:
[
](html)
This will save you from unplugging the board and potentially damaging your connectors every time you want to restart.
Then on your computer, launch the program ./programs/romdisk/romdisk.server.mcy
As a reminder:
- On Windows: double-click the romdisk.server.mcy file, and associate *.mcy files with ./bin/minimacy.exe if not already done.
- On Linux: from the minimacy directory, run:
>./bin/minimacy ./programs/romdisk/romdisk.server.mcy
- On macOS: from the minimacy directory, run:
>./bin/minimacyMac ./programs/romdisk/romdisk.server.mcy
In all cases, you will see the following output:
>Bootdisk server & console - 2026 - Sylvain Huet
>-----------------------------------------------
>(edit the bootdisk content in file romdisk/romdisk.server.txt)
This program tries to detect available serial connections. If it finds only one, it uses it automatically. If it finds several, it asks you to choose. For example:
>Available serial ports:
>1. COM6: USB Serial Port
>2. COM5: Silicon Labs CP210x USB to UART Bridge
>Enter number>
Restart the Raspberry Pi 4 board, either by unplugging/replugging the USB-C cable, or by pressing the RESET button on the board (see above for how to solder this button).
The following messages appear:
>> RAM : 2 GB
>> Board rev : b03115
>> MAC : fc8957dd3ad8
>> Serial : 10000000815db0ac
>> VC memory : 79691776 bytes (0x3b400000 - 0x40000000)
>> Clock rate : 600000000 Hz (max 1500000000 Hz) -> 600000000 Hz
>> Minimacy - Sylvain Huet - 2020-26 - 2.1.0/RPi4
>> ----
>> 64 bits
>> Memory strip 0: 985661440 bytes (0x1d1000 - 0x3add1000)
>> Memory strip 1: 1073741824 bytes (0x40000000 - 0x80000000)
>> Memory length : 2017460224 bytes (0x78400000)
>
>File list:
>Disk image size: 0 bytes
>Sent time: Wed, 11 Mar 2026 14:15:58 UTC
>++
>> Current working directory: [empty]
>> Default user directory : [empty]
>> BIOS compiled in 53 ms
>> current time: Wed, 11 Mar 2026 14:15:59 UTC
>> compiling 'baremetal.rpi4.boot'
>> compiling 'driver.rpi4.usb.storage'
>> compiling 'driver.rpi4.usb'
>> compiling 'driver.rpi4.usb.keyboard'
>> compiling 'driver.rpi4.usb.hid'
>> compiling 'driver.rpi4.usb.mouse'
>> compiling 'driver.rpi4.usb.hub'
>> compiling 'driver.rpi4.eth'
>> compiling 'driver.rpi4.sd'
>> compiling 'core.storage.format'
>> compiling 'core.storage.fat32'
>> compiling 'core.util.cache'
>> compiling 'core.storage.romdisk'
>> compiled in 83 ms
>> USB: Link up, 5.0 Gbps x1
>> USB: Device 'ven2109-3431, dev9-0-1 [3]'
>> USB: Product 'USB2.0 Hub'
>> USB: Interface int-9-0-0
>> USB: Start hub
>> USB: Wait for hub powered up (4 ports)
>> Eth: init
>> Eth: not connected
>> EMMC: version 1, 15.267.840 sectors (512 bytes per sector)
>> Storage: check volume sd0
>> Storage: check partition sd0:0
>> Storage: found fat32 partition (7.812.939.776 Bytes, cluster size: 4096): NO NAME
>> Building romdisk, depth 2
>> compiling 'boot'
>> compiled in 0 ms
>] █
By default, on a new Raspberry Pi 4 board, the boot goes to the top-level: you can enter commands.
For example:
>] 1+2
>-> Int: 3 (0x3)
You can turn on the green LED:
>] led(true)
>-> Bool: true
##Behind the Magic
Let us break down the boot message. The first six lines display the board's characteristics.
>> RAM : 2 GB
>> Board rev : b03115
>> MAC : fc8957dd3ad8
>> Serial : 10000000815db0ac
>> VC memory : 79691776 bytes (0x3b400000 - 0x40000000)
>> Clock rate : 600000000 Hz (max 1500000000 Hz) -> 600000000 Hz
On the last line, we can see that the frequency is left at 600 MHz even though it could be raised to 1.5 GHz. Doing so could cause the board to overheat and be damaged.
>> Minimacy - Sylvain Huet - 2020-26 - 2.1.0/RPi4
>> ----
>> 64 bits
At board startup, you can verify the version of Minimacy. This is a 64-bit version since the Raspberry Pi 4 board uses an arm64 microprocessor.
>> Memory strip 0: 985661440 bytes (0x1d1000 - 0x3add1000)
>> Memory strip 1: 1073741824 bytes (0x40000000 - 0x80000000)
>> Memory length : 2017460224 bytes (0x78400000)
On Raspberry Pi 4 boards, the RAM usable by Minimacy is split into two parts, on either side of the VC (VideoCore) memory:
- 940 MB in the lower portion
- Between 1 and 3 GB in the upper portion, depending on the RAM installed on your Raspberry Pi 4 (2 or 4 GB). In our example, the board has 2 GB of RAM, so the upper portion is exactly 1 GB.
>
>File list:
>Disk image size: 0 bytes
>Sent time: Wed, 11 Mar 2026 14:15:58 UTC
>++
At startup, the Raspberry Pi 4 board interacts with the romdisk.server.mcy program running on the computer. This program is not just a simple terminal: when it receives the message, it understands that the Raspberry Pi 4 board is requesting boot information. This information is of two types:
- The current time on the computer, which allows the Raspberry Pi 4 board to set its clock.
- A "disk image" containing files whose use we will see shortly. Here the disk is empty (Disk image size: 0 bytes).
Since the Raspberry Pi 4 board has no backup battery, the time is not preserved when the board is powered off.
>> Current working directory: [empty]
>> Default user directory : [empty]
>> BIOS compiled in 53 ms
>> current time: Wed, 11 Mar 2026 14:15:59 UTC
These four lines are also present in the computer version of Minimacy. In baremetal mode, the working and user directories are always empty (root directory).
The BIOS is compiled in under 100 ms. It is exactly the same BIOS as on the computer version.
On a computer, Minimacy finds these files in the ./rom/bios/ directory.
In baremetal mode, a set of files are already "hard-coded" in the Minimacy firmware. These are primarily the files from the ./rom/bios, ./rom/core, ./rom/baremetal, ./rom/driver directories, as well as the boot.mcy file in the ./programs/ directory. We will see later how to modify this list and recompile the firmware.
Once the BIOS is compiled, the Raspberry Pi 4 version of Minimacy first executes the baremetal.rpi4.boot.mcy program:
>> compiling 'baremetal.rpi4.boot'
>> compiling 'driver.rpi4.usb.storage'
>> compiling 'driver.rpi4.usb'
>> compiling 'driver.rpi4.usb.keyboard'
>> compiling 'driver.rpi4.usb.hid'
>> compiling 'driver.rpi4.usb.mouse'
>> compiling 'driver.rpi4.usb.hub'
>> compiling 'driver.rpi4.eth'
>> compiling 'driver.rpi4.sd'
>> compiling 'core.storage.format'
>> compiling 'core.storage.fat32'
>> compiling 'core.util.cache'
>> compiling 'core.storage.romdisk'
>> compiled in 83 ms
This hardware boot compiles the various drivers: SD card, Ethernet controller, USB (keyboard, mouse, storage). This takes less than 100 ms.
>> USB: Link up, 5.0 Gbps x1
>> USB: Device 'ven2109-3431, dev9-0-1 [3]'
>> USB: Product 'USB2.0 Hub'
>> USB: Interface int-9-0-0
>> USB: Start hub
>> USB: Wait for hub powered up (4 ports)
>> Eth: init
>> Eth: not connected
>> EMMC: version 1, 15.267.840 sectors (512 bytes per sector)
>> Storage: check volume sd0
>> Storage: check partition sd0:0
>> Storage: found fat32 partition (7.812.939.776 Bytes, cluster size: 4096): NO NAME
>> Building romdisk, depth 2
>> compiling 'boot'
>> compiled in 0 ms
We can see that it found a partition on the SD card. In our case, the SD card is 8 GB and its partition is named "NO NAME".
Then the hardware boot initializes all these components before launching the boot.mcy program, which by default starts the top-level with the "consoleStart" command. The default boot.mcy code is simply:
fun main() =
consoleStart(nil);;
##Disks in Baremetal Mode
To go further, you need to understand the "disk" structure in Minimacy.
There are three levels:
- A "volume" corresponds to a physical storage medium.
- A "partition" is a subdivision of a volume. It can be formatted in several ways, but Minimacy only recognizes FAT32 format. A volume can contain multiple partitions, though there is usually only one.
- Finally, a "mount" defines the file path in Minimacy through which a partition is accessed.
For example, if a partition contains a file /bar/test.txt, and it is mounted with:
- Mount path: /foo/
- Partition path: /bar/
Then Minimacy can access the file via the path /foo/test.txt.
The fs() command allows you to visualize this structure. On a Raspberry Pi 4 with an SD card containing no *.mcy files:
>] fs()
>Volumes:
>Volume Access SectorSize NbSectors TotalSize
>------ ------ ---------- --------- ---------
>sd0 writable 512 15.267.840 7G
>romdisk1 readonly 779.952 1 761k
>
>Partitions:
>Volume Access TotalSize Partition
>------ ------ --------- ---------
>sd0 writable 7G NO NAME
>romdisk1 readonly 761k NATIVE
>
>Mounts:
>Id Volume Partition Access Mount Path Partition Path
>-- ------ --------- ------ ---------- --------------
>0 sd0 NO NAME writable [empty] /
>1 romdisk1 NATIVE readonly [empty] [empty]
There are two volumes:
- romdisk1: a disk hard-coded in the firmware, discussed in the previous chapter.
- sd0: the SD card, which in our case is 8 GB with a partition named "NO NAME".
Each volume provides one partition:
- NO NAME: the SD card partition
- NATIVE: the romdisk partition
The last section "Mounts" shows how these partitions are mounted and in what order: SD card (index/Id 0) then romdisk (index/Id 1). This means that when Minimacy looks for a file, it searches first on the SD card, then in the NATIVE partition (romdisk).
You can view the contents of these disks:
>] dir(nil)
>DIRECTORY | Tue, 10 Mar 2026 15:56:32 UTC | 0: System Volume Information/
>DIRECTORY | Thu, 01 Jan 1970 00:00:00 UTC | 1: baremetal/
>DIRECTORY | Thu, 01 Jan 1970 00:00:00 UTC | 1: bios/
>DIRECTORY | Thu, 01 Jan 1970 00:00:00 UTC | 1: core/
>DIRECTORY | Thu, 01 Jan 1970 00:00:00 UTC | 1: driver/
>1594 | Tue, 10 Mar 2026 16:19:20 UTC | 0: LICENCE.broadcom
>51955 | Tue, 30 Aug 2022 10:43:32 UTC | 0: bcm2711-rpi-4-b.dtb
>39 | Thu, 01 Jan 1970 00:00:00 UTC | 1: boot.mcy
>483 | Tue, 10 Mar 2026 16:06:32 UTC | 0: config.txt
>5399 | Tue, 30 Aug 2022 10:43:32 UTC | 0: fixup4.dat
>1196252 | Wed, 11 Mar 2026 15:38:54 UTC | 0: minimacyRpi4.img
>2249280 | Tue, 30 Aug 2022 10:43:32 UTC | 0: start4.elf
>12 element(s)
The visible files come from both the SD card and the romdisk. The romdisk files have no real date since they are embedded in the firmware — their Unix timestamp is 0, dating them to 01/01/1970.
You also notice on each line "0:" or "1:" just before the file or directory name, indicating whether files are on mount index 0 (SD card) or mount index 1 (romdisk).
Now, place the following boot.mcy file back on the SD card (one line has been added compared to the Blink chapter):
fun blink(state)=
led(state);
onTimeout(500, lambda()= blink(!state));;
fun main() =
blink(true);
consoleStart(nil);;
Restart the Raspberry Pi 4 board.
This time the console shows:
>> Storage: check volume sd0
>> Storage: check partition sd0:0
>> Storage: found fat32 partition (7.812.939.776 Bytes, cluster size: 4096): NO NAME
>> Building romdisk, depth 2
>> - boot.mcy: 151 bytes
What is important to understand is that the Minimacy firmware cannot read files from the SD card on its own. The firmware contains only the Minimacy compiler and runtime written in pure C. The SD driver and the FAT32 library are applications written in the Minimacy language; the compiler cannot call them since it can only compile programs from romdisks. Things are different on a computer, where Minimacy can access the disk via the OS and ANSI functions such as fopen(), fread(), etc.
How then, in the baremetal version, can the compiler compile files located on the SD card?
The solution is as follows: when a FAT32 partition is found, the hardware boot program (baremetal.rpi4.boot.mcy) loads all *.mcy files found up to depth 2 in the directory tree and turns them into a romdisk — a large character string that is then mounted as a disk:
>> Building romdisk, depth 2
>> - boot.mcy: 151 bytes
Then Minimacy launches the boot.mcy program:
>> compiling 'boot'
>> compiled in 0 ms
>] █
The green LED blinks, and you can enter commands.
This time the fs() command returns more lines:
>] fs()
>Volumes:
>Volume Access SectorSize NbSectors TotalSize
>------ ------ ---------- --------- ---------
>romdisk2 readonly 172 1 172
>sd0 writable 512 15.267.840 7G
>romdisk1 readonly 779.952 1 761k
>
>Partitions:
>Volume Access TotalSize Partition
>------ ------ --------- ---------
>romdisk2 readonly 172 NO NAME:*.mcy
>sd0 writable 7G NO NAME
>romdisk1 readonly 761k NATIVE
>
>Mounts:
>Id Volume Partition Access Mount Path Partition Path
>-- ------ --------- ------ ---------- --------------
>0 romdisk2 NO NAME:*.mcy readonly [empty] [empty]
>1 sd0 NO NAME writable [empty] /
>2 romdisk1 NATIVE readonly [empty] [empty]
You will notice the new romdisk2 volume and a new partition:
- NO NAME:*.mcy: the partition containing the *.mcy files found on the SD card
When a Minimacy application looks for a file, it searches in this order: romdisk2, sd0, romdisk1.
When the compiler looks for a file, it searches in this order: romdisk2, romdisk1, since it only knows about romdisks.
##Modifying boot.mcy
At this point, to "work" and for example modify the boot.mcy program, the procedure seems cumbersome:
- Remove the SD card
- Reinsert it into the computer
- Open, edit, save the boot.mcy file
- Remove the SD card
- Reinsert it into the Raspberry Pi 4 board
- Restart or press the RESET button on the board
We need a faster solution, because in software development it is essential that the modify/test loop be as fluid as possible.
What we want is the minimal workflow:
- Modify the boot.mcy program on the computer
- Restart the board
As mentioned above, the romdisk.server.mcy program running on the computer is not just a terminal: when it receives the message, it can transmit a romdisk that will override the files present on the card. We simply need to define the list of files to include in this romdisk.
For the rest of the getting-started guide, delete the boot.mcy file from the SD card again.
Edit the file ./programs/romdisk/romdisk.server.txt on the computer. List the files one per line, with no leading spaces or tabs (otherwise the line is ignored):
>#to comment files, just insert a tab before the path
>boot.mcy
Now edit the file ./programs/boot.mcy on the computer as follows:
fun main() =
echoLn "Hello, world!";
consoleStart(nil);;
Press the RESET button on the Raspberry Pi 4 board (or unplug and replug the power cable if you have not soldered a RESET button).
This time the console shows the following for the BOOTDISK block:
>
>File list:
>+ boot.mcy
>Disk image size: 84 bytes
>Sent time: Tue, 03 Feb 2026 17:29:04 UTC
>+=
We can see that the computer sent a romdisk of 84 bytes, containing only the boot.mcy file.
Then, at the end, our "Hello, world!" message:
>> compiling 'boot'
>> compiled in 0 ms
>Hello, world!
>]
Compilation happens on the fly.
On the computer, modify boot.mcy again, replacing the content with:
fun main() =
echoLn "Compilation is so fast!";
consoleStart(nil);;
Save, restart the board, the console now ends with:
>> compiling 'boot'
>> compiled in 0 ms
>Compilation is so fast!
>]
The development modify/test loop is optimal!
You can visualize the disk structure:
>] fs()
>Volumes:
>Volume Access SectorSize NbSectors TotalSize
>------ ------ ---------- --------- ---------
>sd0 writable 512 15.267.840 7G
>romdisk0 readonly 86 1 86
>romdisk1 readonly 779.952 1 761k
>
>Partitions:
>Volume Access TotalSize Partition
>------ ------ --------- ---------
>sd0 writable 7G NO NAME
>romdisk0 readonly 86 BOOTDISK
>romdisk1 readonly 761k NATIVE
>
>Mounts:
>Id Volume Partition Access Mount Path Partition Path
>-- ------ --------- ------ ---------- --------------
>0 romdisk0 BOOTDISK readonly [empty] [empty]
>1 sd0 NO NAME writable [empty] /
>2 romdisk1 NATIVE readonly [empty] [empty]
We can see that there is now a romdisk0 volume, containing the BOOTDISK partition and mounted at index 0, meaning every file is searched first in this romdisk.
In summary, for efficient development on the Raspberry Pi 4 board:
- Use the Bootdisk to load the files you are working on into the board: list them in ./programs/romdisk/romdisk.server.txt.
- Edit these files on the computer and restart the board, which reloads them in the sequence.
Once the application is ready, you can either:
- Copy these files to an SD card and insert it into the Raspberry Pi 4 board.
- Embed these files in the NATIVE romdisk of the firmware and recompile it (covered later).
Then remove the files from the Bootdisk (e.g., by commenting them out in ./programs/romdisk/romdisk.server.txt).
The board is now autonomous and can operate without the computer.
#Developing an Application
Steps:
- Using the network
- Using the expansion port
Due to Minimacy's highly cross-platform nature, applications developed for the Raspberry Pi 4 board have almost no differences from those developed for the computer version of Minimacy:
- All pure computation is identical.
- File access is identical.
- Use of the clock is identical.
- The console works the same way.
Two aspects however present differences:
- Network configuration
- Use of the expansion port, which has no equivalent on a computer
##Network Configuration
On a computer, the operating system handles configuring and managing network connections: when your application starts, the network is already ready. On the Raspberry Pi 4, the hardware boot (baremetal.rpi4.boot.mcy) only initializes the driver for the Ethernet port, but cannot guess the configuration you need. For each port, three configuration types are possible:
- Inactive
- With a static IP address
- With a dynamic IP address obtained via DHCP
You can view the result of this initialization with the net() command:
>] net()
>Name MAC IP Mask Gateway DNS
>---- --- -- ---- ------- ---
>eth0 fc:89:57:dd:3a:d8 ... ... ... ...
>lo 127.0.0.1 255.0.0.0 ... ...
The Ethernet port is named 'eth0'. It has no IP address yet.
Note: the port only appears if the Ethernet port is already connected to another device when you power on the card.
It is therefore up to your application, generally in the main() function of boot.mcy, to define this configuration.
Here is how to configure the Ethernet port with DHCP:
use core.net.ipOverEth;;
fun main ()=
netDhcp(netUp("eth0"));
...
;;
The same with a static IP:
use core.net.ipOverEth;;
fun main ()=
netStatic(netUp("eth0"), "169.254.1.1", "255.255.0.0", nil, nil);
...
;;
Note the use of core.net.ipOverEth, a readable but somewhat complex package that implements in the Minimacy language an IP layer with ARP, UDP, DHCP, and TCP.
From there, you can use the network just as on a computer.
##Expansion Port
The expansion port provides access to power (ground, 3.3V, 5V) and the following interfaces:
- uart1
- spi0, spi3, spi4, spi5, spi6
- i2c0, i2c1, i2c3, i2c4, i2c5, i2c6
- numerous GPIOs
The UART port is named "uart1" and can be accessed using the serialOpen() function, just as on a computer:
- Pin 34: ground (this is an example, as ground is also accessible on other pins)
- Pin 32: TX (the board sends data to the computer)
- Pin 33: RX (the board receives data from the computer)
For GPIO, SPI, and I2C, you can use the packages driver.rpi4.gpio.mcy, driver.rpi4.spi.mcy, and driver.rpi4.i2c.mcy.
#Going Further
Steps
- Creating the NATIVE romdisk
- Recompiling Minimacy
- The hardware boot
##NATIVE Romdisk
As we have seen previously, the Minimacy firmware includes the content of a number of *.mcy files that allow it to boot until it is able to read the flash or SD card in FAT32 format to find additional resources. These files are grouped in the NATIVE romdisk, defined by the file:
>./baremetal/raspberry-pi/raspberry-pi-native-romdisk.h
This file is not present in the git archive. To compile the Minimacy firmware, you must first generate it.
To generate it, you first define the files to include. They are defined in the same way as the bootdisk, but in the following file:
>./programs/romdisk/romdisk.native.rpi.txt
By default, this includes: the BIOS, the baremetal files, the drivers, and the libraries from the ./rom/core directory. It also includes the boot.mcy file that will be used for startup.
You can add any files you want, including your own application files. Remember that you list one file per line, with no leading spaces or tabs (otherwise the line is ignored).
Then launch the program:
>./programs/romdisk/romdisk.native.rpi.mcy
As a reminder:
- On Windows: double-click the romdisk.native.rpi.mcy file, and associate *.mcy files with ./bin/minimacy.exe if not already done.
- On Linux: from the minimacy directory, run:
>./bin/minimacy ./programs/romdisk/romdisk.native.rpi.mcy
- On macOS: from the minimacy directory, run:
>./bin/minimacyMac ./programs/romdisk/romdisk.native.rpi.mcy
The program displays the list of files included in the romdisk and the path of the resulting file:
>../baremetal/raspberry-pi/raspberry-pi-native-romdisk.h
It is now possible to recompile the Minimacy firmware.
##Firmware Compilation
To compile the firmware, we use the ARM toolchain for bare metal: aarch64-none-elf-gcc.
This toolchain is available here: [Download link](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads)
Opening a terminal on Windows or Linux, you should be able to run:
>> aarch64-none-elf-gcc --version
>aarch64-none-elf-gcc (Arm GNU Toolchain 11.3.Rel1) 11.3.1 20220712
>Copyright (C) 2021 Free Software Foundation, Inc.
>This is free software; see the source for copying conditions. There is NO
>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Once the toolchain is installed, open a terminal and go to the ./baremetal/raspberry-pi directory.
Run:
>make clean
>make rpi4
The firmware is generated in: ./bin/minimacyRpi4.img
You can copy it yourself to the SD card. However, if you are on Windows and the SD card appears as drive D, simply run:
>make copy-d4
##Hardware Boot
When Minimacy starts, it always compiles the same BIOS files (located in ./rom/bios) and then launches the BIOS.
Once the BIOS is launched, Minimacy starts the application. By default on a computer, this is the program ./programs/boot.mcy.
On the Raspberry Pi 4, this is the program ./baremetal/baremetal.rpi4.boot.mcy.
It is fairly short and you can read it. It simply:
- Initializes USB
- Initializes Ethernet
- Initializes the SD card
Then:
- Mounts the SD card partitions at the root
- Searches for *.mcy files and optionally creates a romdisk
- Mounts USB key partitions under usb/
- Does not create a romdisk for these partitions (the code is present but disabled)
Finally:
- Launches the "boot.mcy" program.