[PATCH v1 4/4] libmisc/shell: Improve print messages for flashdev command

2023-10-18 Thread aaron . nyholm
From: Aaron Nyholm 

---
 cpukit/libmisc/shell/main_flashdev.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/cpukit/libmisc/shell/main_flashdev.c 
b/cpukit/libmisc/shell/main_flashdev.c
index ca2454b33c..dc73d3f9db 100644
--- a/cpukit/libmisc/shell/main_flashdev.c
+++ b/cpukit/libmisc/shell/main_flashdev.c
@@ -199,7 +199,7 @@ int flashdev_shell_read(
   }
 
   /* Print buffer out in 32bit blocks */
-  printf("Reading %s at 0x%08x for %d bytes\n", dev_path, address, bytes);
+  printf("Reading %s at 0x%08x for 0x%x bytes\n", dev_path, address, bytes);
   for (int i = 0; i < (bytes/4); i++) {
 printf("%08x ", ((uint32_t*)buffer)[i]);
 if ((i+1)%4 == 0) {
@@ -281,6 +281,13 @@ int flashdev_shell_write(
 return -1;
   }
 
+  printf(
+"Writing %s to %s at 0x%08x for 0x%jx bytes\n",
+file_path,
+dev_path,
+address,
+length
+  );
   /* Create buffer */
   buffer = calloc(1, 0x1000);
 
@@ -358,7 +365,7 @@ int flashdev_shell_erase(
 return -1;
   }
 
-  printf("Erasing at %08x for %x bytes\n", address, bytes);
+  printf("Erasing at 0x%08x for 0x%x bytes\n", address, bytes);
 
   /* Erase flash */
   args.offset = address;
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 3/4] aarch64/versal: Port JFFS2 GQSPI NOR Driver from Zynqmp

2023-10-18 Thread aaron . nyholm
From: Aaron Nyholm 

---
 .../include/bsp/jffs2_xqspipsu.h  |  62 ++
 bsps/aarch64/xilinx-versal/jffs2_xqspipsu.c   | 190 ++
 spec/build/bsps/aarch64/xilinx-versal/grp.yml |   4 +
 .../aarch64/xilinx-versal/objjffs2qspinor.yml |  20 ++
 .../aarch64/xilinx-versal/objxqspiflash.yml   |   2 -
 5 files changed, 276 insertions(+), 2 deletions(-)
 create mode 100644 bsps/aarch64/xilinx-versal/include/bsp/jffs2_xqspipsu.h
 create mode 100644 bsps/aarch64/xilinx-versal/jffs2_xqspipsu.c
 create mode 100644 spec/build/bsps/aarch64/xilinx-versal/objjffs2qspinor.yml

diff --git a/bsps/aarch64/xilinx-versal/include/bsp/jffs2_xqspipsu.h 
b/bsps/aarch64/xilinx-versal/include/bsp/jffs2_xqspipsu.h
new file mode 100644
index 00..4a1cdac7a6
--- /dev/null
+++ b/bsps/aarch64/xilinx-versal/include/bsp/jffs2_xqspipsu.h
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSBSPsAArch64XilinxVersal
+ *
+ * @brief Xilinx Versal QSPI JFFS2 flash driver definitions
+ */
+
+/*
+ * Copyright (C) 2023 Aaron Nyholm
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBBSP_XILINX_VERSAL_JFFS2_XQSPIPSU_H
+#define LIBBSP_XILINX_VERSAL_JFFS2_XQSPIPSU_H
+
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @brief Mount jffs2 filesystem.
+ *
+ * @param[in] mount_dir The directory to mount the filesystem at.
+ * @param[in] qspipsu_ptr A pointer to an initialized QSPI instance.
+ *
+ * @retval 0 Successful operation. Negative number otherwise.
+ */
+int xilinx_versal_nor_jffs2_initialize(
+  const char *mount_dir,
+  XQspiPsu *qspipsu_ptr
+);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LIBBSP_XILINX_VERSAL_JFFS2_XQSPIPSU_H */
diff --git a/bsps/aarch64/xilinx-versal/jffs2_xqspipsu.c 
b/bsps/aarch64/xilinx-versal/jffs2_xqspipsu.c
new file mode 100644
index 00..c84280b420
--- /dev/null
+++ b/bsps/aarch64/xilinx-versal/jffs2_xqspipsu.c
@@ -0,0 +1,190 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2023 Aaron Nyholm
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+typedef struct {
+  rtems_jffs2_flash_control super;
+  XQspiPsu *qspipsu;
+} flash_control;
+
+#ifndef versal
+#define versal
+#endif
+
+/* From the N25Q00A datasheet */
+#define BLOCK_SIZE (128UL * 1024UL) //(64UL * 1024UL)

[PATCH v1 2/4] aarch64/versal: Add flash wrapper for Xilinx GQSPI

2023-10-18 Thread aaron . nyholm
From: Aaron Nyholm 

---
 .../dev/spi/versal_xqspi_flash.c  | 296 ++
 bsps/aarch64/xilinx-versal/include/bsp/irq.h  |   1 +
 .../include/dev/spi/versal_xqspi_flash.h  |  49 +++
 bsps/include/dev/spi/xqspipsu-flash-helper.h  |  24 ++
 bsps/shared/dev/spi/xqspipsu-flash-helper.c   |  16 +
 spec/build/bsps/aarch64/xilinx-versal/grp.yml |   2 +
 .../aarch64/xilinx-versal/objxqspiflash.yml   |  24 ++
 7 files changed, 412 insertions(+)
 create mode 100644 bsps/aarch64/xilinx-versal/dev/spi/versal_xqspi_flash.c
 create mode 100644 
bsps/aarch64/xilinx-versal/include/dev/spi/versal_xqspi_flash.h
 create mode 100644 spec/build/bsps/aarch64/xilinx-versal/objxqspiflash.yml

diff --git a/bsps/aarch64/xilinx-versal/dev/spi/versal_xqspi_flash.c 
b/bsps/aarch64/xilinx-versal/dev/spi/versal_xqspi_flash.c
new file mode 100644
index 00..7771af9dcd
--- /dev/null
+++ b/bsps/aarch64/xilinx-versal/dev/spi/versal_xqspi_flash.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright (C) 2023, 2023 Aaron Nyholm
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+
+uint32_t xqspi_get_jedec_id(rtems_flashdev *flash);
+
+int xqspi_get_flash_type(
+  rtems_flashdev *flash,
+  rtems_flashdev_flash_type *type
+);
+
+int xqspi_page_info_by_off(
+  rtems_flashdev *flash,
+  off_t search_offset,
+  off_t *page_offset,
+  size_t *page_size
+);
+
+int xqspi_page_info_by_index(
+  rtems_flashdev *flash,
+  off_t search_index,
+  off_t *page_offset,
+  size_t *page_size
+);
+
+int xqspi_page_count(
+  rtems_flashdev *flash,
+  int *page_count
+);
+
+int xqspi_write_block_size(
+  rtems_flashdev *flash,
+  size_t *write_block_size
+);
+
+int xqspi_read_wrapper(rtems_flashdev *flash,
+  uintptr_t offset,
+  size_t count,
+  void *buffer
+);
+
+int xqspi_write_wrapper(
+  rtems_flashdev *flash,
+  uintptr_t offset,
+  size_t count,
+  const void *buffer
+);
+
+int xqspi_erase_wrapper(
+  rtems_flashdev *flash,
+  uintptr_t offset,
+  size_t count
+);
+
+uint32_t xqspi_get_jedec_id(rtems_flashdev *flash) {
+  return QspiPsu_NOR_Get_JEDEC_ID(flash->driver);
+}
+
+int xqspi_get_flash_type(
+  rtems_flashdev *flash,
+  rtems_flashdev_flash_type *type
+)
+{
+  *type = RTEMS_FLASHDEV_NOR;
+  return 0;
+}
+
+int xqspi_read_wrapper(
+rtems_flashdev *flash,
+uintptr_t offset,
+size_t count,
+void *buffer
+)
+{
+  XQspiPsu *flash_driver = (XQspiPsu*)flash->driver;
+  uint8_t *tmp_buffer;
+  int status;
+  int startAlign = 0;
+
+  /* Align offset to two byte boundary */
+  if (offset%2) {
+startAlign = 1;
+offset = offset - 1;
+count = count + 1;
+  }
+
+  while (count > MAX_READ_SIZE) {
+/* Read block and copy to buffer */
+status = QspiPsu_NOR_Read(flash_driver, (uint32_t)offset, MAX_READ_SIZE, 
_buffer);
+
+if (status == 0) {
+  memcpy(buffer, tmp_buffer + startAlign, MAX_READ_SIZE - startAlign);
+  /* Update count, offset and buffer pointer */
+  count = count - MAX_READ_SIZE;
+  buffer = buffer + MAX_READ_SIZE - startAlign;
+  offset = offset + MAX_READ_SIZE;
+  /* Clear startAlign once first block read */
+  if (startAlign) {
+startAlign = 0;
+  }
+} else {
+  return status;
+}
+  }
+
+  status = QspiPsu_NOR_Read(flash_driver, (uint32_t)offset, (uint32_t)count, 
_buffer);
+
+  if (status == 0) {
+memcpy(buffer, tmp_buffer + startAlign, count);
+  }
+  return status;
+}
+
+int xqspi_page_info_by_off(
+  rtems_flashdev *flash,
+  off_t search_offset,
+  off_t *page_offset,
+  size_t *page_size
+)
+{
+  *page_size = QspiPsu_NOR_Get_Sector_Size(flash->driver);
+  *page_offset = search_offset - 

Flash and JFFS2 for Versal

2023-10-18 Thread aaron . nyholm
Attached are patches for enabling xilinx's XQSPIPSU driver for the
versal. An addition patch to the flashdev command is attached to improve
usability.


___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1 1/4] bsps: Fix xqspipsu build issues on versal

2023-10-18 Thread aaron . nyholm
From: Aaron Nyholm 

---
 bsps/include/dev/spi/xqspipsu_hw.h | 15 ---
 bsps/shared/dev/spi/xqspipsu_control.c |  7 ---
 bsps/shared/dev/spi/xqspipsu_hw.c  |  5 +++--
 bsps/shared/dev/spi/xqspipsu_options.c |  9 +
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/bsps/include/dev/spi/xqspipsu_hw.h 
b/bsps/include/dev/spi/xqspipsu_hw.h
index a798f9bb89..61e7b3a240 100644
--- a/bsps/include/dev/spi/xqspipsu_hw.h
+++ b/bsps/include/dev/spi/xqspipsu_hw.h
@@ -43,6 +43,7 @@ extern "C" {
 
 /* Include Files */
 
+#include 
 #include "xil_types.h"
 #include "xil_assert.h"
 #include "xil_io.h"
@@ -57,13 +58,13 @@ extern "C" {
 /**
  * QSPI Base Address
  */
-#if defined (versal)
+#if defined (LIBBSP_AARCH64_XILINX_VERSAL_BSP_H)
 #define XQSPIPS_BASEADDR  0XF103U
 #else
 #define XQSPIPS_BASEADDR  0XFF0FU
 #endif
 
-#if defined (versal)
+#if defined (LIBBSP_AARCH64_XILINX_VERSAL_BSP_H)
 #define XQSPIPSU_BASEADDR 0XF1030100U
 #else
 #define XQSPIPSU_BASEADDR 0xFF0F0100U
@@ -141,7 +142,7 @@ extern "C" {
 /**
  * Register: XQSPIPSU_LQSPI
  */
-#if !defined (versal)
+#if !defined (LIBBSP_AARCH64_XILINX_VERSAL_BSP_H)
 #define XQSPIPSU_LQSPI_CR_OFFSET   0X00A0U
 #define XQSPIPSU_LQSPI_CR_LINEAR_MASK 0x8000U /**< LQSPI mode enable */
 #define XQSPIPSU_LQSPI_CR_TWO_MEM_MASK0x4000U /**< Both memories or 
one */
@@ -503,7 +504,7 @@ extern "C" {
 
 #define XQSPIPSU_SEL_SHIFT   0U
 #define XQSPIPSU_SEL_WIDTH   1U
-#if !defined (versal)
+#if !defined (LIBBSP_AARCH64_XILINX_VERSAL_BSP_H)
 #define XQSPIPSU_SEL_LQSPI_MASK0X0U
 #endif
 #define XQSPIPSU_SEL_GQSPI_MASK0X0001U
@@ -938,19 +939,19 @@ extern "C" {
  * Tapdelay Bypass register
  */
 
-#if defined versal
+#if defined LIBBSP_AARCH64_XILINX_VERSAL_BSP_H
 #define IOU_TAPDLY_BYPASS_OFFSET 0X003CU
 #else
 #define IOU_TAPDLY_BYPASS_OFFSET 0X0390U
 #endif
 
 #define IOU_TAPDLY_BYPASS_LQSPI_RX_SHIFT 0X02U
-#if !defined (versal)
+#if !defined (LIBBSP_AARCH64_XILINX_VERSAL_BSP_H)
 #define IOU_TAPDLY_BYPASS_LQSPI_RX_WIDTH 0X01U
 #define IOU_TAPDLY_BYPASS_LQSPI_RX_MASK 0x0004U
 #endif
 
-#if defined versal
+#if defined LIBBSP_AARCH64_XILINX_VERSAL_BSP_H
 #define IOU_TAPDLY_RESET_STATE 0x4U
 #else
 #define IOU_TAPDLY_RESET_STATE 0x7U
diff --git a/bsps/shared/dev/spi/xqspipsu_control.c 
b/bsps/shared/dev/spi/xqspipsu_control.c
index af2400bf4c..f51e335b60 100644
--- a/bsps/shared/dev/spi/xqspipsu_control.c
+++ b/bsps/shared/dev/spi/xqspipsu_control.c
@@ -30,6 +30,7 @@
 
 /* Include Files */
 
+#include 
 #include "xqspipsu_control.h"
 
 /** Constant Definitions */
@@ -241,7 +242,7 @@ s32 XQspipsu_Calculate_Tapdelay(const XQspiPsu 
*InstancePtr, u8 Prescaler)
 
FreqDiv = (InstancePtr->Config.InputClockHz)/Divider;
 
-#if defined (versal)
+#if defined (LIBBSP_AARCH64_XILINX_VERSAL_BSP_H)
if (FreqDiv <= XQSPIPSU_FREQ_37_5MHZ) {
 #else
if (FreqDiv <= XQSPIPSU_FREQ_40MHZ) {
@@ -252,7 +253,7 @@ s32 XQspipsu_Calculate_Tapdelay(const XQspiPsu 
*InstancePtr, u8 Prescaler)
Tapdelay |= (TAPDLY_BYPASS_VALVE_100MHZ <<
 IOU_TAPDLY_BYPASS_LQSPI_RX_SHIFT);
LBkModeReg |= (USE_DLY_LPBK << 
XQSPIPSU_LPBK_DLY_ADJ_USE_LPBK_SHIFT);
-#if defined (versal)
+#if defined (LIBBSP_AARCH64_XILINX_VERSAL_BSP_H)
delayReg |= (u32)USE_DATA_DLY_ADJ  <<

XQSPIPSU_DATA_DLY_ADJ_USE_DATA_DLY_SHIFT;
 #else
@@ -261,7 +262,7 @@ s32 XQspipsu_Calculate_Tapdelay(const XQspiPsu 
*InstancePtr, u8 Prescaler)
((u32)DATA_DLY_ADJ_DLY  
<< XQSPIPSU_DATA_DLY_ADJ_DLY_SHIFT);
 #endif
} else if (FreqDiv <= XQSPIPSU_FREQ_150MHZ) {
-#if defined (versal)
+#if defined (LIBBSP_AARCH64_XILINX_VERSAL_BSP_H)
LBkModeReg |= (USE_DLY_LPBK  << 
XQSPIPSU_LPBK_DLY_ADJ_USE_LPBK_SHIFT) |
(LPBK_DLY_ADJ_DLY1 << 
XQSPIPSU_LPBK_DLY_ADJ_DLY1_SHIFT);
 #else
diff --git a/bsps/shared/dev/spi/xqspipsu_hw.c 
b/bsps/shared/dev/spi/xqspipsu_hw.c
index 6f7708893f..379786ff03 100644
--- a/bsps/shared/dev/spi/xqspipsu_hw.c
+++ b/bsps/shared/dev/spi/xqspipsu_hw.c
@@ -34,6 +34,7 @@
 
 /* Include Files */
 
+#include 
 #include "xqspipsu.h"
 #include "xqspipsu_control.h"
 #if defined (__aarch64__)
@@ -744,11 +745,11 @@ s32 XQspipsu_Set_TapDelay(const XQspiPsu *InstancePtr, 
u32 TapdelayBypass,
if (InstancePtr->IsBusy == (u32)TRUE) {
Status = (s32)XST_DEVICE_BUSY;
} else {
-#if defined (__aarch64__) && (EL1_NONSECURE == 1) && !defined (versal)
+#if defined (__aarch64__) 

[PATCH] bsps/aarch64/zynqmp/nand: Erase using offset

2023-10-18 Thread Kinsey Moore
Prefer use of XNandPsu_Erase instead of XNandPsu_EraseBlock since the
XNandPsu driver does not expose the primitives necessary to ensure
device readiness after the operation is complete.
---
 bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c 
b/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c
index ab0eb1ccd5..b8c5140436 100644
--- a/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c
+++ b/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c
@@ -106,20 +106,14 @@ static int flash_erase(
   XNandPsu *nandpsu = get_flash_control(super)->nandpsu;
   rtems_status_code sc;
   uint32_t BlockSize = nandpsu->Geometry.BlockSize;
-  uint32_t DeviceSize = nandpsu->Geometry.DeviceSize;
-  uint32_t BlockIndex;
-  uint32_t DeviceIndex;
 
   if (offset > nandpsu->Geometry.DeviceSize) {
 return -EIO;
   }
 
-  DeviceIndex = offset / DeviceSize;
-  BlockIndex = (offset % DeviceSize) / BlockSize;
-
   /* Perform erase operation. */
   rtems_mutex_lock(&(get_flash_control(super)->access_lock));
-  sc = XNandPsu_EraseBlock(nandpsu, DeviceIndex, BlockIndex);
+  sc = XNandPsu_Erase(nandpsu, RTEMS_ALIGN_DOWN(offset, BlockSize), BlockSize);
   rtems_mutex_unlock(&(get_flash_control(super)->access_lock));
   if (sc ) {
 return -EIO;
-- 
2.39.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: libdl documentation?

2023-10-18 Thread Chris Johns
On 18/10/2023 7:21 pm, Sebastian Huber wrote:
> I tried to get a bit more familiar with the libdl. Is there some documentation
> available? I tried the user manual, but I see only a work in progress page:
> 
> https://docs.rtems.org/branches/master/user/tools/linker.html

There is this https://git.rtems.org/rtems-tools/tree/linkers/main-page.cpp which
has not been moved across.

> For example, I can use dlopen() to load an object file (ELF). For what do I 
> need
> RAP files?

RAP requires use of the linker. It has some issues that need to be addressed to
be at the same level as the ELF loader. For example I have not looked into TLS
and there is the failure of the tests in the testsuite (dl06).

RAP is an intermediate format where a lot of the required linking can be done on
the host and the file set you need for the target can be collected. This lets
you have a golden base image and a single loadable application.

> Can I load also archives? It seems this can be done through configuration 
> files.
> Are there API calls to do this?

Currently there is no API call available. One could be added if you feel it is
required. I decided you need a valid file system for loading to work so a
configuration file was the simplest method.

Loading from archives is done via the /etc/libdl.conf file:

https://git.rtems.org/rtems/tree/testsuites/libtests/dl10/etc/libdl.conf

The file can be updated at runtime and it is checked on each load for changes.

Note, I did some initial analysis for this at the time the change was made and
if you use runlib on the archives before loading the symbol table for libraries
like libc is manageable.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/2] cpukit/libfs/dosfs: Use enum values for enum init

2023-10-18 Thread Kinsey Moore
---
 cpukit/libfs/src/dosfs/msdos_mknod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libfs/src/dosfs/msdos_mknod.c 
b/cpukit/libfs/src/dosfs/msdos_mknod.c
index 934805c5f1..8fe01e4985 100644
--- a/cpukit/libfs/src/dosfs/msdos_mknod.c
+++ b/cpukit/libfs/src/dosfs/msdos_mknod.c
@@ -44,7 +44,7 @@ int msdos_mknod(
 )
 {
 int  rc = RC_OK;
-fat_file_type_t  type = 0;
+fat_file_type_t  type = FAT_DIRECTORY;
 
 /*
  *  Figure out what type of msdos node this is.
-- 
2.39.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/2] cpukit/score: Convert Thread_Life_state to uint32_t

2023-10-18 Thread Kinsey Moore
Thread_Life_state is used as a bitfield, but is declared as an enum.
This converts the enum typedef to a uint32_t typedef and associated bit
definitions.
---
 cpukit/include/rtems/score/thread.h | 80 ++---
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/cpukit/include/rtems/score/thread.h 
b/cpukit/include/rtems/score/thread.h
index 9a9d2e038f..c1006b8b32 100644
--- a/cpukit/include/rtems/score/thread.h
+++ b/cpukit/include/rtems/score/thread.h
@@ -719,50 +719,50 @@ typedef struct {
  * The individual state flags must be a power of two to allow use of bit
  * operations to manipulate and evaluate the thread life state.
  */
-typedef enum {
-  /**
-   * @brief Indicates that the thread life is protected.
-   *
-   * If this flag is set, then the thread restart or delete requests are 
deferred
-   * until the protection and deferred change flags are cleared.  It is used by
-   * _Thread_Set_life_protection().
-   */
-  THREAD_LIFE_PROTECTED = 0x1,
+typedef uint32_t Thread_Life_state;
 
-  /**
-   * @brief Indicates that thread is restarting.
-   *
-   * If this flag is set, then a thread restart request is in pending. See
-   * _Thread_Restart_self() and _Thread_Restart_other().
-   */
-  THREAD_LIFE_RESTARTING = 0x2,
+/**
+ * @brief Indicates that the thread life is protected.
+ *
+ * If this flag is set, then the thread restart or delete requests are deferred
+ * until the protection and deferred change flags are cleared.  It is used by
+ * _Thread_Set_life_protection().
+ */
+#define THREAD_LIFE_PROTECTED 0x1
 
-  /**
-   * @brief Indicates that thread is terminating.
-   *
-   * If this flag is set, then a thread termination request is in pending.  See
-   * _Thread_Exit() and _Thread_Cancel().
-   */
-  THREAD_LIFE_TERMINATING = 0x4,
+/**
+ * @brief Indicates that thread is restarting.
+ *
+ * If this flag is set, then a thread restart request is in pending. See
+ * _Thread_Restart_self() and _Thread_Restart_other().
+ */
+#define THREAD_LIFE_RESTARTING 0x2
 
-  /**
-   * @brief Indicates that thread life changes are deferred.
-   *
-   * If this flag is set, then the thread restart or delete requests are 
deferred
-   * until the protection and deferred change flags are cleared.  It is used by
-   * pthread_setcanceltype().
-   */
-  THREAD_LIFE_CHANGE_DEFERRED = 0x8,
+/**
+ * @brief Indicates that thread is terminating.
+ *
+ * If this flag is set, then a thread termination request is in pending.  See
+ * _Thread_Exit() and _Thread_Cancel().
+ */
+#define THREAD_LIFE_TERMINATING 0x4
 
-  /**
-   * @brief Indicates that thread is detached.
-   *
-   * If this flag is set, then the thread is detached.  Detached threads do not
-   * wait during termination for other threads to join.  See 
rtems_task_delete(),
-   * rtems_task_exit(), and pthread_detach().
-   */
-  THREAD_LIFE_DETACHED = 0x10
-} Thread_Life_state;
+/**
+ * @brief Indicates that thread life changes are deferred.
+ *
+ * If this flag is set, then the thread restart or delete requests are deferred
+ * until the protection and deferred change flags are cleared.  It is used by
+ * pthread_setcanceltype().
+ */
+#define THREAD_LIFE_CHANGE_DEFERRED 0x8
+
+/**
+ * @brief Indicates that thread is detached.
+ *
+ * If this flag is set, then the thread is detached.  Detached threads do not
+ * wait during termination for other threads to join.  See rtems_task_delete(),
+ * rtems_task_exit(), and pthread_detach().
+ */
+#define THREAD_LIFE_DETACHED 0x10
 
 /**
  * @brief Thread life control.
-- 
2.39.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH v1] bsps/aarch64: translation table walk disable for translations using ttbr1

2023-10-18 Thread Kinsey Moore
This change looks good. TTBR1 isn't used at all under the current RTEMS
configuration and isn't expected to be used in the future.

Kinsey

On Tue, Oct 17, 2023 at 3:57 AM  wrote:

> From: Tian Ye 
>
> ---
>  bsps/aarch64/include/bsp/aarch64-mmu.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/bsps/aarch64/include/bsp/aarch64-mmu.h
> b/bsps/aarch64/include/bsp/aarch64-mmu.h
> index 2101ef4ae0..8c69705230 100644
> --- a/bsps/aarch64/include/bsp/aarch64-mmu.h
> +++ b/bsps/aarch64/include/bsp/aarch64-mmu.h
> @@ -439,7 +439,8 @@ BSP_START_TEXT_SECTION static inline void
> aarch64_mmu_setup( void )
>_AArch64_Write_tcr_el1(
>  AARCH64_TCR_EL1_T0SZ( 0x10 ) | AARCH64_TCR_EL1_IRGN0( 0x1 ) |
>  AARCH64_TCR_EL1_ORGN0( 0x1 ) | AARCH64_TCR_EL1_SH0( 0x3 ) |
> -AARCH64_TCR_EL1_TG0( 0x0 ) | AARCH64_TCR_EL1_IPS( 0x5ULL )
> +AARCH64_TCR_EL1_TG0( 0x0 ) | AARCH64_TCR_EL1_IPS( 0x5ULL ) |
> +AARCH64_TCR_EL1_EPD1
>);
>
>/* Set MAIR */
> --
> 2.34.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

libdl documentation?

2023-10-18 Thread Sebastian Huber

Hello,

I tried to get a bit more familiar with the libdl. Is there some 
documentation available? I tried the user manual, but I see only a work 
in progress page:


https://docs.rtems.org/branches/master/user/tools/linker.html

For example, I can use dlopen() to load an object file (ELF). For what 
do I need RAP files?


Can I load also archives? It seems this can be done through 
configuration files. Are there API calls to do this?


--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel