From: Sascha Hauer <s.hauer@pengutronix.de>
To: Antony Pavlov <antonynpavlov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] MIPS: add generic device tree 2nd stage support
Date: Wed, 13 Mar 2024 08:55:11 +0100 [thread overview]
Message-ID: <ZfFb330vlcclb_tz@pengutronix.de> (raw)
In-Reply-To: <20240310215434.1220451-1-antonynpavlov@gmail.com>
On Mon, Mar 11, 2024 at 12:54:34AM +0300, Antony Pavlov wrote:
> Building and running barebox for 32-bit malta:
>
> export ARCH=mips
> export CROSS_COMPILE=mips-linux-gnu-
> make -s qemu-malta_defconfig
> sed -i "s/# \(CONFIG_BOARD_MIPS_GENERIC_DT\) is not set/\1=y/" .config
> make -s oldconfig
> make -s
> qemu-system-mips -M malta -cpu 24Kf -m 256M \
> -nographic -serial mon:stdio \
> -bios images/barebox-qemu-malta.img \
> -net user,tftp=$(pwd) -net nic,model=e1000
>
> Building and running barebox for 64-bit malta:
>
> export ARCH=mips
> export CROSS_COMPILE=mips-linux-gnu-
> make -s qemu-malta64el_defconfig
> sed -i "s/# \(CONFIG_BOARD_MIPS_GENERIC_DT\) is not set/\1=y/" .config
> make -s oldconfig
> make -s
> qemu-system-mips64el -M malta -cpu MIPS64R2-generic -m 256M \
> -nographic -serial mon:stdio \
> -bios images/barebox-qemu-malta.img.swapped \
> -net user,tftp=$(pwd) -net nic,model=e1000
>
> Use bootm to run barebox-dt-2nd.img (external device tree):
>
> barebox@qemu malta:/ dhcp
> barebox@qemu malta:/ cp /mnt/tftp/images/barebox-dt-2nd.img barebox.img
> barebox@qemu malta:/ cp /mnt/tftp/arch/mips/dts/qemu-malta.dtb .
> barebox@qemu malta:/ imd barebox.img
> barebox@qemu malta:/ bootm -o qemu-malta.dtb barebox.img
>
> Use bootm to run barebox-qemu-malta.img (encapsulated device tree):
>
> barebox@qemu malta:/ dhcp
> barebox@qemu malta:/ cp /mnt/tftp/images/barebox-qemu-malta.img barebox.img
> barebox@qemu malta:/ imd barebox.img
> barebox@qemu malta:/ bootm barebox.img
>
> N.B. Use just the same commands for both 32-bit and 64-bit malta boards.
>
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> arch/mips/Kconfig | 10 ++++++++++
> arch/mips/boards/Makefile | 2 ++
> arch/mips/boards/board-dt-2nd.S | 35 +++++++++++++++++++++++++++++++++
> arch/mips/boot/main_entry-pbl.c | 4 ++++
> arch/mips/lib/bootm.c | 13 ++++++++++--
> 5 files changed, 62 insertions(+), 2 deletions(-)
>
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 63ba6aa9d5a..14062dee347 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -319,6 +319,16 @@ config 64BIT
>
> endchoice
>
> +config BOARD_MIPS_GENERIC_DT
> + select BOARD_GENERIC_DT
> + depends on OFDEVICE
> + bool "Build generic MIPS device tree 2nd stage image"
> + help
> + This enables compilation of a generic image that can be started 2nd
> + stage from barebox or from qemu. It picks up a device tree passed
> + in a1 like the Kernel does.
> + The image will be called images/barebox-dt-2nd.img
> +
> menu "MIPS specific settings"
>
> config CMD_MIPS_CPUINFO
> diff --git a/arch/mips/boards/Makefile b/arch/mips/boards/Makefile
> index 9402035856c..c4ce599c934 100644
> --- a/arch/mips/boards/Makefile
> +++ b/arch/mips/boards/Makefile
> @@ -13,3 +13,5 @@ obj-$(CONFIG_BOARD_QEMU_MALTA) += qemu-malta/
> obj-$(CONFIG_BOARD_RZX50) += ritmix-rzx50/
> obj-$(CONFIG_BOARD_TPLINK_MR3020) += tplink-mr3020/
> obj-$(CONFIG_BOARD_TPLINK_WDR4300) += tplink-wdr4300/
> +
> +pbl-$(CONFIG_BOARD_MIPS_GENERIC_DT) += board-dt-2nd.o
> diff --git a/arch/mips/boards/board-dt-2nd.S b/arch/mips/boards/board-dt-2nd.S
> new file mode 100644
> index 00000000000..a1465f09e36
> --- /dev/null
> +++ b/arch/mips/boards/board-dt-2nd.S
> @@ -0,0 +1,35 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Startup Code for generic MIPS device tree 2nd stage image
> + *
> + * Copyright (C) 2024 Antony Pavlov <antonynpavlov@gmail.com>
> + */
> +
> +#include <asm/asm.h>
> +#include <asm/pbl_macros.h>
> +#include <linux/sizes.h>
> +
> +ENTRY_FUNCTION(start_dt_2nd)
> +
> + /* save device tree address in v1 */
> + move v1, a1
> +
> + mips_cpu_setup
> +
> + copy_to_link_location start_dt_2nd
> +
> + stack_setup
> +
> + /* pbl_main_entry() computes fdt_len by itself
> + * if fdt == fdt_end */
> + move a0, v1 /* fdt */
> + move a1, v1 /* fdt_end */
> + PTR_LI a2, SZ_256M /* ram_size */
Could this be taken from dt finally? I think it's good enough for now,
but would be a nice improvement.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2024-03-13 7:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-10 21:54 Antony Pavlov
2024-03-13 7:51 ` Sascha Hauer
2024-03-13 7:55 ` Sascha Hauer [this message]
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=ZfFb330vlcclb_tz@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=antonynpavlov@gmail.com \
--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