mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jules Maselbas <jmaselbas@zdiv.net>
To: barebox@lists.infradead.org
Cc: Jules Maselbas <jmaselbas@zdiv.net>
Subject: [PATCH v3 6/6] Documentation: sunxi: Add some documentation
Date: Wed, 12 Feb 2025 11:48:42 +0100	[thread overview]
Message-ID: <20250212104842.504-7-jmaselbas@zdiv.net> (raw)
In-Reply-To: <20250212104842.504-1-jmaselbas@zdiv.net>

Add some user documentation on how to build a second stage barebox image,
and how to boot from u-boot.

Signed-off-by: Jules Maselbas <jmaselbas@zdiv.net>
---
 Documentation/boards/sunxi.rst | 116 +++++++++++++++++++++++++++++++++
 1 file changed, 116 insertions(+)
 create mode 100644 Documentation/boards/sunxi.rst

diff --git a/Documentation/boards/sunxi.rst b/Documentation/boards/sunxi.rst
new file mode 100644
index 0000000000..8d00507434
--- /dev/null
+++ b/Documentation/boards/sunxi.rst
@@ -0,0 +1,116 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Allwinner sunxi
+===============
+
+Boot process
+------------
+
+On power-up Allwinner SoC starts in boot ROM, aka BROM, which will search
+for a bootable image (eGON header): first from the SD card, then from eMMC.
+If no image is found then the boot ROM will enter into FEL mode that can be
+used for programming and recovery through USB.
+
+Some board may have a button to enter FEL mode at startup. If not, another
+way to enter FEL mode is to not have a valid bootable eGON image, this can
+be achieved by erasing existing eGON image headers.
+
+.. note::
+
+   Currently Barebox cannot boot directly on Allwinner sunxi SoC and can
+   only be used as a secondary bootloader, requiring u-boot to initialize
+   the SDRAM controller and starting the TF-A and optionally Crust.
+
+
+Building barebox second stage
+-----------------------------
+
+The generic ``barebox-dt-2nd.img`` armv8 image should enable all the needed
+drivers.
+
+To build the image do:
+
+.. code-block:: sh
+
+  export ARCH=arm CROSS_COMPILE=aarch64-linux-gnu-
+  make multi_v8_defconfig
+  make
+
+Installing barebox second stage
+-------------------------------
+
+Copy the built ``barebox-dt-2nd.img`` image into the first fat partition
+of the boot medium.
+
+.. code-block:: sh
+
+  # mount /dev/sdX1 /mnt/${mount_dir}
+  # cp ${build_dir}/images/barebox-dt-2nd.img /mnt/${mount_dir}
+  # umount /mnt/${mount_dir}
+
+
+Booting barebox from U-Boot
+---------------------------
+
+Currently Barebox can only be started as a second stage, and relies on
+U-Boot for the SDRAM initialisation and to start the TF-A.
+
+.. code-block:: console
+
+  # on u-boot console, `mmc 0:1` is the first partition on the sd card
+  fatload mmc 0:1 0x42000000 barebox-dt-2nd.img
+  fatload mmc 0:1 0x44000000 dtbs-lts/allwinner/sun50i-a64-pine64-plus.dtb
+  booti 0x42000000 - 0x44000000
+
+.. note::
+
+   A FIT image might be built and used instead of directly using the `barebox-dt-2nd.img`,
+   this hasn't been tested yet, but using a FIT image sound like a better option.
+
+See also the general documentation on :ref:`second_stage`.
+
+Building Arm Trusted Firmware (TF-A)
+------------------------------------
+
+.. note::
+
+   This step is currently only needed when building U-Boot.
+   This step is also documented in U-Boot documention.
+
+Boards using a 64-bit Soc (A64, H5, H6, H616, R329) require the BL31 stage of
+the Arm Trusted Firmware-A firmware. This provides the reference
+implementation of secure software for Armv8-A, offering PSCI and SMCCC
+services. Allwinner support is fully mainlined. To build bl31.bin:
+
+.. code-block:: sh
+
+  git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
+  cd trusted-firmware-a
+  make CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50i_a64 DEBUG=1
+  cp build/sun50i_a64/debug/bl31.bin ${barebox_dir}/firmware/sun50i-a64-bl31.bin
+
+The target platform (``PLAT=``) for A64 and H5 SoCs is sun50i_a64, for the H6
+sun50i_h6, for the H616 sun50i_h616, and for the R329 sun50i_r329.
+
+Building U-Boot image
+---------------------
+
+Please refere to the relevant U-Boot_ build documentation (or ``/doc/board/allwinner/sunxi.rst`` in u-boot src tree).
+
+.. _U-Boot: https://docs.u-boot.org/en/latest/board/allwinner/sunxi.html#building-the-u-boot-image
+
+
+Installing the first stage bootloader
+-------------------------------------
+
+Installing on a (micro-) SD card
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The bootable image, a eGON header followed by the actual image, must be
+located at the fixed offset of 8192 bytes (8KB) from the start of the
+disk (sector 16).
+
+.. code-block:: sh
+
+  # copy the bootable fsbl image (including eGON header) into disk sdX
+  dd if=${fsbl.img} of=/dev/sdX bs=512 seek=16
-- 
2.48.1




  parent reply	other threads:[~2025-02-12 10:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12 10:48 [PATCH v3 0/6] Initial support for Allwinner A64 SoC Jules Maselbas
2025-02-12 10:48 ` [PATCH v3 1/6] clk: divider: add error code propagation Jules Maselbas
2025-02-12 10:48 ` [PATCH v3 2/6] clk: Add clock driver for sun50i-a64 Jules Maselbas
2025-02-12 10:48 ` [PATCH v3 3/6] pinctrl: Add sun50i-a64 pinctrl driver Jules Maselbas
2025-02-12 10:48 ` [PATCH v3 4/6] mci: Add sunxi-mmc driver Jules Maselbas
2025-02-12 10:48 ` [PATCH v3 5/6] ARM: sunxi: Introduce mach-sunxi Jules Maselbas
2025-02-12 10:48 ` Jules Maselbas [this message]
2025-02-14 10:31 ` [PATCH v3 0/6] Initial support for Allwinner A64 SoC Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250212104842.504-7-jmaselbas@zdiv.net \
    --to=jmaselbas@zdiv.net \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox