From b54a36436ee1940c795584c7400ec28e6dd06366 Mon Sep 17 00:00:00 2001 From: Alex Charlton Date: Wed, 30 Oct 2024 20:46:08 -0700 Subject: [PATCH 1/5] boards: beaglev_fire: document flashing board In addition to some minor corrections, document the process of flashing the board. Signed-off-by: Alex Charlton --- boards/beagle/beaglev_fire/doc/index.rst | 54 +++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/boards/beagle/beaglev_fire/doc/index.rst b/boards/beagle/beaglev_fire/doc/index.rst index e5e28f8cf727a..1e26e58b5c4ce 100644 --- a/boards/beagle/beaglev_fire/doc/index.rst +++ b/boards/beagle/beaglev_fire/doc/index.rst @@ -15,11 +15,17 @@ hobbyists, and researchers to explore and experiment with RISC-V technology. Building ======== +There are three board configurations provided for the BeagleV-Fire: + +* ``beaglev_fire_polarfire_e51``: Uses only the E51 core +* ``beaglev_fire_polarfire_u54``: Uses the U54 cores +* ``beaglev_fire_polarfire_u54_smp``: Uses the U54 cores with CONFIG_SMP=y + Applications for the ``beaglev_fire`` board configuration can be built as usual: .. zephyr-app-commands:: :zephyr-app: samples/hello_world - :board: beaglev_fire + :board: beaglev_fire_polarfire_u54 :goals: build Debugging @@ -76,3 +82,49 @@ and load the binary: load break main continue + +Flashing +======== +When using the PolarFire `Hart Software Services `_ along with Zephyr, you need to use the `hss-payload-generator `_ tool to generate an image that HSS can boot. + +.. code-block:: yaml + + set-name: 'ZephyrImage' + + # Define the entry point address for each hart (U54 cores) + hart-entry-points: + u54_1: '0x80000000' + + # Define the payloads (ELF binaries or raw blobs) + payloads: + : + exec-addr: '0x80000000' # Where Zephyr should be loaded + owner-hart: u54_1 # Primary hart that runs Zephyr + priv-mode: prv_m # Start in Machine mode + skip-opensbi: true # Boot directly without OpenSBI + +After generating the image, you can flash it to the board by restarting a board that's connected over USB and UART, interrupting the HSS boot process with a key press, and then running the ``mmc`` and ``usbdmsc`` commands: + +.. code-block:: bash + + Press a key to enter CLI, ESC to skip + Timeout in 1 second + .[6.304162] Character 100 pressed + [6.308415] Type HELP for list of commands + [6.313276] >> mmc + [10.450867] Selecting SDCARD/MMC (fallback) as boot source ... + [10.457550] Attempting to select eMMC ... Passed + [10.712708] >> usbdmsc + [14.732841] initialize MMC + [14.736400] Attempting to select eMMC ... Passed + [15.168707] MMC - 512 byte pages, 512 byte blocks, 30621696 pages + Waiting for USB Host to connect... (CTRL-C to quit) + . 0 bytes written, 0 bytes read + USB Host connected. Waiting for disconnect... (CTRL-C to quit) + / 0 bytes written, 219136 bytes read + +This will cause the board to appear as a USB mass storage device. You can then then flash the image with ``dd`` or other tools like `BalenaEtcher `_: + +.. code-block:: bash + + dd if= of=/dev/sdXD bs=4M status=progress oflag=sync From 14001d5e63243d8981b5cd942e4ea969ff6e1f38 Mon Sep 17 00:00:00 2001 From: Alex Charlton Date: Wed, 30 Oct 2024 20:47:04 -0700 Subject: [PATCH 2/5] boards: beaglev_fire: fix uart uart1 is not connected to anything as far as I can tell. uart0 was the previous correctly selected uart, so this changes back to that. Signed-off-by: Alex Charlton --- boards/beagle/beaglev_fire/beaglev_fire_common.dtsi | 12 ++++++++++++ .../beaglev_fire/beaglev_fire_polarfire_e51.dts | 12 ------------ .../beaglev_fire/beaglev_fire_polarfire_u54.dts | 12 ------------ .../beaglev_fire/beaglev_fire_polarfire_u54_smp.dts | 12 ------------ 4 files changed, 12 insertions(+), 36 deletions(-) diff --git a/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi b/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi index 24b1958a9d9f1..56aa178beecbd 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi +++ b/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi @@ -14,6 +14,18 @@ compatible = "beagle,beaglev-fire", "microchip,mpfs"; aliases { }; + + chosen { + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,sram = &sram1; + }; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + clock-frequency = <150000000>; }; &gpio2 { diff --git a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.dts b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.dts index 5a8537124d4d9..e1556c095280a 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.dts +++ b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.dts @@ -21,16 +21,4 @@ status = "disabled"; }; }; - - chosen { - zephyr,console = &uart0; - zephyr,shell-uart = &uart0; - zephyr,sram = &sram1; - }; -}; - -&uart0 { - status = "okay"; - current-speed = <115200>; - clock-frequency = <150000000>; }; diff --git a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.dts b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.dts index 7c4fba300fd3b..36513a8f6517d 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.dts +++ b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.dts @@ -5,21 +5,9 @@ model = "beagle,beaglev-fire"; compatible = "beagle,beaglev-fire", "microchip,mpfs"; - chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram1; - }; - cpus { cpu@0 { status = "disabled"; }; }; }; - -&uart1 { - status = "okay"; - current-speed = <115200>; - clock-frequency = <150000000>; -}; diff --git a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.dts b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.dts index cf9ed20aa3ee4..9d81bf66e06ec 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.dts +++ b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.dts @@ -4,16 +4,4 @@ / { model = "beagle,beaglev-fire"; compatible = "beagle,beaglev-fire", "microchip,mpfs"; - - chosen { - zephyr,console = &uart1; - zephyr,shell-uart = &uart1; - zephyr,sram = &sram1; - }; -}; - -&uart1 { - status = "okay"; - current-speed = <115200>; - clock-frequency = <150000000>; }; From 649f93cc6e27031654b99b4f8c01539d4417e036 Mon Sep 17 00:00:00 2001 From: Alex Charlton Date: Wed, 30 Oct 2024 20:47:16 -0700 Subject: [PATCH 3/5] boards: beaglev_fire: expand RAM The Fire has 2GB of RAM, so expand sram1 to use it Signed-off-by: Alex Charlton --- boards/beagle/beaglev_fire/beaglev_fire_common.dtsi | 7 +++++++ boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.yaml | 2 +- boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.yaml | 2 +- .../beaglev_fire/beaglev_fire_polarfire_u54_smp.yaml | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi b/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi index 56aa178beecbd..e5c6c15a5f71c 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi +++ b/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi @@ -15,6 +15,13 @@ aliases { }; + soc { + sram1: memory@80000000 { + compatible = "mmio-sram"; + reg = <0x80000000 0x77F80000>; /* Size = 2GB - 0x80000 */ + }; + }; + chosen { zephyr,console = &uart0; zephyr,shell-uart = &uart0; diff --git a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.yaml b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.yaml index bc5ee3de628b0..e31465d9b97c2 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.yaml +++ b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.yaml @@ -4,7 +4,7 @@ type: mcu arch: riscv toolchain: - zephyr -ram: 3840 +ram: 2012741 testing: ignore_tags: - net diff --git a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.yaml b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.yaml index 9204225a7660f..934cf7e06944a 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.yaml +++ b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.yaml @@ -4,7 +4,7 @@ type: mcu arch: riscv toolchain: - zephyr -ram: 3840 +ram: 2012741 testing: ignore_tags: - net diff --git a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.yaml b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.yaml index e8f316014382d..0816256842cd7 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.yaml +++ b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.yaml @@ -4,7 +4,7 @@ type: mcu arch: riscv toolchain: - zephyr -ram: 3840 +ram: 2012741 testing: ignore_tags: - net From a675a1cd30434d39e49141a28024a1cf30b12954 Mon Sep 17 00:00:00 2001 From: Alex Charlton Date: Sun, 3 Nov 2024 14:14:13 -0800 Subject: [PATCH 4/5] boards: beaglev_fire: fix board identifiers in docs Per PR review. Signed-off-by: Alex Charlton --- boards/beagle/beaglev_fire/doc/index.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boards/beagle/beaglev_fire/doc/index.rst b/boards/beagle/beaglev_fire/doc/index.rst index 1e26e58b5c4ce..5d6b2cd6b90e6 100644 --- a/boards/beagle/beaglev_fire/doc/index.rst +++ b/boards/beagle/beaglev_fire/doc/index.rst @@ -17,15 +17,15 @@ Building There are three board configurations provided for the BeagleV-Fire: -* ``beaglev_fire_polarfire_e51``: Uses only the E51 core -* ``beaglev_fire_polarfire_u54``: Uses the U54 cores -* ``beaglev_fire_polarfire_u54_smp``: Uses the U54 cores with CONFIG_SMP=y +* ``beaglev_fire/polarfire/e51``: Uses only the E51 core +* ``beaglev_fire/polarfire/u54``: Uses the U54 cores +* ``beaglev_fire/polarfire/u54/smp``: Uses the U54 cores with CONFIG_SMP=y Applications for the ``beaglev_fire`` board configuration can be built as usual: .. zephyr-app-commands:: :zephyr-app: samples/hello_world - :board: beaglev_fire_polarfire_u54 + :board: beaglev_fire/polarfire/u54 :goals: build Debugging From 3f0e66e0a22e03155e71925d6ad071866728bc8c Mon Sep 17 00:00:00 2001 From: Alex Charlton Date: Sun, 3 Nov 2024 14:19:33 -0800 Subject: [PATCH 5/5] boards: beaglev_fire: fix memory address Per the docs, the memory at address 0x80000000 ends at 0xC0000000. In other words, the address space is 0x40000000, which is only half of the size we want to map. This means that the upper address space previously mapped was overlapping with the space reserved for non-cached memory. Instead, we map the entire 2GB at 0x1000000000, which is the correct address for cached DDR that occupies more than 1 GB. We defined a new node in the device tree for this memory region, `beaglev.ddr_cached_high`. We did not reuse the `soc` node because we needed to redefine the `#address-cells` to be 2, and doing so would have affected other nodes under `soc`. Signed-off-by: Alex Charlton --- boards/beagle/beaglev_fire/beaglev_fire_common.dtsi | 11 +++++++---- .../beaglev_fire/beaglev_fire_polarfire_e51.yaml | 2 +- .../beaglev_fire/beaglev_fire_polarfire_u54.yaml | 2 +- .../beaglev_fire/beaglev_fire_polarfire_u54_smp.yaml | 2 +- boards/beagle/beaglev_fire/doc/index.rst | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi b/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi index e5c6c15a5f71c..086dabbed8470 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi +++ b/boards/beagle/beaglev_fire/beaglev_fire_common.dtsi @@ -15,17 +15,20 @@ aliases { }; - soc { - sram1: memory@80000000 { + beaglev { + #address-cells = <2>; + #size-cells = <1>; + + ddr_cached_high: memory@1000000000 { compatible = "mmio-sram"; - reg = <0x80000000 0x77F80000>; /* Size = 2GB - 0x80000 */ + reg = <0x10 0x00000000 0x80000000>; /* 2GB */ }; }; chosen { zephyr,console = &uart0; zephyr,shell-uart = &uart0; - zephyr,sram = &sram1; + zephyr,sram = &ddr_cached_high; }; }; diff --git a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.yaml b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.yaml index e31465d9b97c2..745c033310b98 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.yaml +++ b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_e51.yaml @@ -4,7 +4,7 @@ type: mcu arch: riscv toolchain: - zephyr -ram: 2012741 +ram: 2048000 testing: ignore_tags: - net diff --git a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.yaml b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.yaml index 934cf7e06944a..e99022d4a1487 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.yaml +++ b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54.yaml @@ -4,7 +4,7 @@ type: mcu arch: riscv toolchain: - zephyr -ram: 2012741 +ram: 2048000 testing: ignore_tags: - net diff --git a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.yaml b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.yaml index 0816256842cd7..809d7fd2c3ebc 100644 --- a/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.yaml +++ b/boards/beagle/beaglev_fire/beaglev_fire_polarfire_u54_smp.yaml @@ -4,7 +4,7 @@ type: mcu arch: riscv toolchain: - zephyr -ram: 2012741 +ram: 2048000 testing: ignore_tags: - net diff --git a/boards/beagle/beaglev_fire/doc/index.rst b/boards/beagle/beaglev_fire/doc/index.rst index 5d6b2cd6b90e6..4cc146f10a2b2 100644 --- a/boards/beagle/beaglev_fire/doc/index.rst +++ b/boards/beagle/beaglev_fire/doc/index.rst @@ -93,12 +93,12 @@ When using the PolarFire `Hart Software Services : - exec-addr: '0x80000000' # Where Zephyr should be loaded + exec-addr: '0x1000000000' # Where Zephyr should be loaded owner-hart: u54_1 # Primary hart that runs Zephyr priv-mode: prv_m # Start in Machine mode skip-opensbi: true # Boot directly without OpenSBI