From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Lior Weintraub <liorw@pliops.com>,
"barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: Porting barebox to a new SoC
Date: Sun, 28 May 2023 17:35:48 +0200 [thread overview]
Message-ID: <f4aae166-1cc4-6255-1fde-7a52c7872bd8@pengutronix.de> (raw)
In-Reply-To: <PR3P195MB05550502A2AD5D21F032A22BC3459@PR3P195MB0555.EURP195.PROD.OUTLOOK.COM>
Hello Lior,
On 28.05.23 15:04, Lior Weintraub wrote:
> Hi,
>
> I tried to follow the porting guide on https://www.barebox.org/doc/latest/devel/porting.html# but couldn't follow the instructions.
> I would like to port barebox to a new SoC (which is not a derivative of any known SoC).
> It has the following:
> * Single Cortex A53
> * SRAM (4MB) located on address 0xC000000000
Nice, that's plenty. But do you have DRAM as well for barebox to extract
itself into and for Linux to start from? If 4M is indeed all you got,
you will need to tweak barebox a bit.
> The below patch shows my initial test to try and have a starting point.
> I am setting env variables:
> export ARCH=arm64
> export CROSS_COMPILE=/home/pliops/workspace/ARM/arm-gnu-toolchain/bin/aarch64-none-elf-
Note that barebox is normally built by a Linux toolchain, e.g. aarch64-linux-gnu- running
in freestanding mode. This doesn't seem to be your issue though, but just something to
keep in mind.
> Then I build with:
> make spider_defconfig && make
>
> This gives an error:
> aarch64-none-elf-gcc: error: unrecognized argument in option '-mabi=apcs-gnu'
> aarch64-none-elf-gcc: note: valid arguments to '-mabi=' are: ilp32 lp64
> aarch64-none-elf-gcc: error: unrecognized command-line option '-msoft-float'
> aarch64-none-elf-gcc: error: unrecognized command-line option '-mno-unaligned-access'
> /home/pliops/workspace/simplest-linux-demo/barebox/scripts/Makefile.build:140: recipe for target 'scripts/mod/empty.o' failed
> make[2]: *** [scripts/mod/empty.o] Error 1
>
> Not sure why the compiler flags get -mabi=apcs-gnu when I explicitly set CONFIG_CPU_V8 and the arch/arm/Makefile has:
> ifeq ($(CONFIG_CPU_V8), y)
> CFLAGS_ABI :=-mabi=lp64
CONFIG_CPU_V8 doesn't have a prompt. That means it's a "hidden" symbol that
can only be selected by other config options. Without CONFIG_CPU_V8, barebox'
build system assumes you are building for 32-bit. Note that ARCH=arm64 and
ARCH=arm are the same architecture in barebox (arch/arm). The boards you
select is what defines what compiler options will be used.
If you did savedefconfig, the resulting defconfig should have shown you
that CONFIG_CPU_V8 is getting lost.
> The changes I did:
I inserted some comments below and will reply with a revised version
that adds sine if the needed boilerplate.
> From 848b5f9b18bb1bb96d197cbc1b368ee0a729d581 Mon Sep 17 00:00:00 2001
> From: Lior Weintraub <liorw@pliops.com>
> Date: Sun, 28 May 2023 15:51:44 +0300
> Subject: [PATCH 1/1] Initial Pliops Spider board
>
> ---
> arch/arm/boards/pliops/spider/Makefile | 4 ++++
> arch/arm/boards/pliops/spider/board.c | 26 ++++++++++++++++++++++
> arch/arm/boards/pliops/spider/lowlevel.c | 28 ++++++++++++++++++++++++
> arch/arm/configs/spider_defconfig | 3 +++
> 4 files changed, 61 insertions(+)
> create mode 100644 arch/arm/boards/pliops/spider/Makefile
> create mode 100644 arch/arm/boards/pliops/spider/board.c
> create mode 100644 arch/arm/boards/pliops/spider/lowlevel.c
> create mode 100644 arch/arm/configs/spider_defconfig
>
> diff --git a/arch/arm/boards/pliops/spider/Makefile b/arch/arm/boards/pliops/spider/Makefile
> new file mode 100644
> index 0000000000..da63d2625f
> --- /dev/null
> +++ b/arch/arm/boards/pliops/spider/Makefile
> @@ -0,0 +1,4 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +obj-y += board.o
> +lwl-y += lowlevel.o
> diff --git a/arch/arm/boards/pliops/spider/board.c b/arch/arm/boards/pliops/spider/board.c
> new file mode 100644
> index 0000000000..17cdd5e2b9
> --- /dev/null
> +++ b/arch/arm/boards/pliops/spider/board.c
> @@ -0,0 +1,26 @@
> +#include <bbu.h>
> +#include <boot.h>
> +#include <bootm.h>
> +#include <common.h>
> +#include <deep-probe.h>
> +#include <environment.h>
> +#include <fcntl.h>
> +#include <globalvar.h>
> +
> +static int spider_board_probe(struct device *dev)
> +{
> + /* Do some board-specific setup */
> + return 0;
> +}
> +
> +static const struct of_device_id spider_board_of_match[] = {
> + { .compatible = "spider,spider-board" },
The first part before the comma is the vendor, so you will want
something like pliops,spider-evk (board is quite generic, evk = evaluation kit?)
> + { /* sentinel */ },
> +};
> +
> +static struct driver spider_board_driver = {
> + .name = "board-spider",
> + .probe = spider_board_probe,
> + .of_compatible = spider_board_of_match,
> +};
> +device_platform_driver(spider_board_driver);
> \ No newline at end of file
> diff --git a/arch/arm/boards/pliops/spider/lowlevel.c b/arch/arm/boards/pliops/spider/lowlevel.c
> new file mode 100644
> index 0000000000..f3d5a27647
> --- /dev/null
> +++ b/arch/arm/boards/pliops/spider/lowlevel.c
> @@ -0,0 +1,28 @@
> +#include <common.h>
> +#include <asm/barebox-arm.h>
> +
> +#define BASE_ADDR (0xD000307000)
> +#define GPRAM_ADDR (0xC000000000)
> +#define MY_STACK_TOP (0xC000000000 + SZ_2M) // Set the stack 2MB from GPRAM start (excatly in the middle)
> +static inline void spider_serial_putc(void *base, int c)
> +{
> +// if (!(readl(base + UCR1) & UCR1_UARTEN))
> +// return;
> +//
> +// while (!(readl(base + USR2) & USR2_TXDC));
> +//
> +// writel(c, base + URTX0);
> +}
Also consider defining PUTC_LL. This is useful for very early debugging.
> +ENTRY_FUNCTION_WITHSTACK(start_spider_board, MY_STACK_TOP, r0, r1, r2)
Current implementation of ENTRY_FUNCTION_WITHSTACK assumes MY_STACK_TOP
to be within the first 4G. The compiler will warn you when it gets
truncated. This can be fixed, but I am wondering if the SRAM address
is indeed correct? Many IPs have limitation on how big addresses they
handle, so RAM more often than not starts below 4G.
> +{
> + extern char __dtb_spider_board_start[];
> + void *fdt;
You miss arm_cpu_lowlevel_init() here. See my patch.
> +
> + relocate_to_current_adr();
> + setup_c();
> +
> + pbl_set_putc(spider_serial_putc, (void *)BASE_ADDR);
> +
> + barebox_arm_entry(GPRAM_ADDR, SZ_2M, __dtb_spider_board_start);
> +}
> diff --git a/arch/arm/configs/spider_defconfig b/arch/arm/configs/spider_defconfig
> new file mode 100644
> index 0000000000..b4c4a32de0
> --- /dev/null
> +++ b/arch/arm/configs/spider_defconfig
> @@ -0,0 +1,3 @@
> +CONFIG_TEXT_BASE=0x4000000000
This causes a cryptic error message, because BAREBOX_MAX_BARE_INIT_SIZE
is 0xffff_ffff at most, which is less than the text base here.
You should just set it to 0 and enable CONFIG_RELOCATABLE. That way
barebox is executable from any address.
Note, that even on 64-bit platforms, barebox itself was always placed in
the lower 4G, so may run into some more issues that need to be fixed
first (if you don't have any RAM < 4G).
By the way, the most recent SoC being posted for upstream inclusion
is Jules' series for Allwinner/Sunxi:
https://lore.barebox.org/barebox/20230524234328.82741-1-jmaselbas@zdiv.net/T/#t
You may find it useful to take a look at it.
Cheers,
Ahmad
> +CONFIG_64BIT=y
> +CONFIG_CPU_V8=y
--
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 |
next prev parent reply other threads:[~2023-05-28 15:37 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-28 13:04 Lior Weintraub
2023-05-28 15:35 ` Ahmad Fatoum [this message]
2023-05-28 15:37 ` [PATCH v2] " Ahmad Fatoum
2023-05-28 20:15 ` Lior Weintraub
2023-05-29 13:34 ` Lior Weintraub
2023-05-29 19:03 ` Ahmad Fatoum
2023-05-30 20:10 ` Lior Weintraub
2023-05-31 6:10 ` Ahmad Fatoum
2023-05-31 8:05 ` Lior Weintraub
2023-05-31 8:40 ` Ahmad Fatoum
2023-05-31 16:13 ` Lior Weintraub
2023-05-31 17:55 ` Ahmad Fatoum
2023-05-31 17:59 ` Ahmad Fatoum
2023-06-01 8:54 ` Lior Weintraub
2023-06-01 9:29 ` Ahmad Fatoum
2023-06-01 11:45 ` Lior Weintraub
2023-06-01 12:35 ` Ahmad Fatoum
2023-06-06 12:54 ` Lior Weintraub
2023-06-06 14:34 ` Ahmad Fatoum
2023-06-12 9:27 ` Lior Weintraub
2023-06-12 12:28 ` Ahmad Fatoum
2023-06-12 14:59 ` Lior Weintraub
2023-06-12 15:07 ` Ahmad Fatoum
2023-06-13 12:39 ` Lior Weintraub
2023-06-13 12:50 ` Ahmad Fatoum
2023-06-13 13:27 ` Lior Weintraub
2023-06-14 6:42 ` Lior Weintraub
2023-06-16 16:20 ` Ahmad Fatoum
2023-06-19 6:40 ` Lior Weintraub
2023-06-19 15:22 ` Ahmad Fatoum
2023-06-25 20:33 ` Lior Weintraub
2023-06-30 5:52 ` Ahmad Fatoum
2023-08-03 11:17 ` Lior Weintraub
2023-08-22 8:00 ` Ahmad Fatoum
2023-08-22 8:48 ` Lior Weintraub
2023-09-07 8:32 ` Ahmad Fatoum
2023-09-07 9:07 ` Lior Weintraub
2023-09-07 9:35 ` Ahmad Fatoum
2023-09-07 11:02 ` Lior Weintraub
2023-09-12 6:04 ` Lior Weintraub
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=f4aae166-1cc4-6255-1fde-7a52c7872bd8@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=liorw@pliops.com \
/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