[PATCH rtems 05/12] bsps/imxrt1052: PLL config based on speed grade

2023-05-04 Thread Christian Mauderer
---
 bsps/arm/imxrt/start/clock-arm-pll-config.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/bsps/arm/imxrt/start/clock-arm-pll-config.c 
b/bsps/arm/imxrt/start/clock-arm-pll-config.c
index 12ad1867eb..2a0148e73a 100644
--- a/bsps/arm/imxrt/start/clock-arm-pll-config.c
+++ b/bsps/arm/imxrt/start/clock-arm-pll-config.c
@@ -26,8 +26,15 @@
  */
 
 #include "fsl_clock_config.h"
+#include 
 
 const clock_arm_pll_config_t armPllConfig_BOARD_BootClockRUN = {
+#if (IMXRT_SPEEDGRADE == '6')
 .loopDivider = 100,
+#elif (IMXRT_SPEEDGRADE == '5')
+.loopDivider = 88,
+#else
+#error unknown speed grade of i.MXRT processor
+#endif
 .src = 0,
 };
-- 
2.35.3

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


[PATCH rtems 01/12] bsp/imxrt: Add script to import mcux-sdk

2023-05-04 Thread Christian Mauderer
NXP now offers the support library in a mcux-sdk git repository instead
of in zip files. The git repository supports multiple controllers of the
i.MXRT family instead of a single one.

This commit adds a script that is a (very hacky) parser for the the
cmake files in the mcux-sdk. It copies all necessary files and creates
yml spec files for the controllers that have been imported.

The script is only intended as a helper for updating the files. It is
not necessary for using the BSP.
---
 bsps/arm/imxrt/import_from_mcux_sdk.py | 293 +
 1 file changed, 293 insertions(+)
 create mode 100755 bsps/arm/imxrt/import_from_mcux_sdk.py

diff --git a/bsps/arm/imxrt/import_from_mcux_sdk.py 
b/bsps/arm/imxrt/import_from_mcux_sdk.py
new file mode 100755
index 00..2dfe224865
--- /dev/null
+++ b/bsps/arm/imxrt/import_from_mcux_sdk.py
@@ -0,0 +1,293 @@
+#!/usr/bin/env python3
+
+""" Parse the cmake files from mcux_sdk and import the sources to RTEMS.
+This script is a ugly hack and it might doesn't work with newer mcux_sdk
+versions.
+
+Provide a number of the cmake files in `devices/MIMXRT*/all_lib_device_*.cmake`
+as parameter to this script. The file format is expected to be quite fixed.
+Don't give anything else to the script. It won't work.
+"""
+
+import argparse
+import logging
+from enum import Enum
+from pathlib import Path
+import re
+from slugify import slugify
+import shutil
+import yaml
+
+class states(Enum):
+IDLE = 0
+ADD_MODULE_PATH = 1
+ADD_CFILES = 2
+ADD_HFILES = 3
+SKIP_TILL_ENDIF = 4
+
+def find_file(name, paths):
+for p in paths:
+path = Path(p)
+f = path / f'{name}.cmake'
+if f.exists():
+return f.resolve(strict=True)
+return None
+
+def get_path_from_line(line, cmake, rel_to = None):
+current_list_dir = str(Path(cmake.name).parent.resolve())
+path = line.strip().replace("${CMAKE_CURRENT_LIST_DIR}", current_list_dir)
+path = Path(path)
+if rel_to is not None:
+p = Path(path)
+path = p.relative_to(rel_to)
+return path
+
+def parse_cmake(cmake, mcux_device, module_path = [], rel_to = None, stack = 
[]):
+logger.info(f"Parse file: {cmake.name}")
+if rel_to is None:
+rel_to = Path(cmake.name).parent.resolve()
+mod_path = module_path.copy()
+state = states.IDLE
+cfiles = []
+hpaths = []
+
+# prevent loops
+if cmake.name in stack:
+logger.warning(f"Loop detected: {' -> '.join(stack)}")
+return cfiles, hpaths
+# Use a shallow copy!
+stack_work = stack[:] + [cmake.name]
+
+for line in cmake:
+logger.debug(f"state: {state}; file: {cmake.name}; line 
'{line.strip()}'")
+
+if state == states.IDLE:
+if "if(${MCUX_DEVICE} STREQUAL " in line:
+equal_to = re.search(r'"(.*)"', line).group(1)
+if equal_to == mcux_device:
+logger.debug(f"MCUX matches {equal_to}")
+else:
+logger.debug(f"MCUX ({mcux_device}) not equal to 
{equal_to}")
+state = states.SKIP_TILL_ENDIF
+elif "endif()" in line:
+state = states.IDLE
+elif ("list" in line) and ("APPEND" in line) and 
("CMAKE_MODULE_PATH" in line):
+state = states.ADD_MODULE_PATH
+elif ("target_sources" in line):
+state = states.ADD_CFILES
+elif ("target_include_directories" in line):
+state = states.ADD_HFILES
+elif ("include(" in line):
+# NOTE: This will also include commented lines. This is
+# necessary because NXP only added the includes as an example 
to
+# the all_lib_device_*.cmake files.
+to_include = re.search(r"\((.*)\)", line).group(1)
+included = find_file(to_include, mod_path)
+logger.debug(f"Search include file: {to_include}; found 
{included}")
+if included is None:
+# log unexpected misses
+if not (to_include.startswith("middleware") or \
+to_include.startswith("CMSIS")):
+logger.error(f"can't find {to_include}")
+elif "rtos" in to_include:
+logger.info("Skip include for other RTOS: ${to_include}")
+elif "utility" in to_include:
+logger.info("Skip utilities: ${to_include}")
+elif "caam" in to_include:
+logger.info("Filter non working driver: ${to_include}")
+elif included.relative_to(rel_to).parts[0] == "drivers" or \
+included.relative_to(rel_to).parts[0] == "devices":
+# we are only interested in drivers
+with open(included, "r") as f:
+cf, hp = parse_cmake(f, mcux_device, mod_path, rel_to, 
stack_w

[PATCH rtems 00/12] bsp/imxrt: Update SDK and prepare for new variant

2023-05-04 Thread Christian Mauderer
Hello,

this patch set for the arm/imxrt BSP family updates the SDK files to the
latest version of the mcux-sdk from NXP and prepares the BSP for further
chip variants. I plan to add a BSP that uses the IMXRT1166 soon.

As a base for the mcux-sdk files, I now use the NXP git repository
instead of zip files that can be downloaded from NXP. I kept the exact
file system structure to make future updates simpler.

To import the files, I used a script. It is not a clean script and it
was only tested on a Linux machine. Despite that, I added that script to
the BSP directory in case someone else ever wants to update the
mcux-sdk. Updating the SDK is also possible without the script. It's
just a lot more manual work. So if we don't want a script in that state
in the repository, I can also just keep it on a private branch.

The patches that import the new SDK files (patch 0002) and remove the
old ones (patch 0004) are too big for the list. I'll only send the
summary. You can find the full patches here:

  0002: 
https://gitlab.com/c-mauderer/rtems/-/commit/2a871672767a95598e5af42373bfebd3eb9440d3
  0004: 
https://gitlab.com/c-mauderer/rtems/-/commit/2a3e104fa808d7f34a1930344d7b39d11cf39f3d

The complete patch set is on this branch:

  https://gitlab.com/c-mauderer/rtems/-/commits/cm/20230504_imxrt/

At the moment, I import the support files for all currently available
i.MXRT* variants. The headers for the CPU registers are really big (a
few megabytes per header) which makes the complete source tree of the
mcux-sdk bigger than 90MB. If preferred, I can remove most variants and
only keep the ones that are currently used or will be used soon
(IMXRT1052 and IMXRT1166) to reduce the size.

Best regards

Christian


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


[PATCH rtems 04/12] bsps/imxrt: Adapt to new mcux-sdk version

2023-05-04 Thread Christian Mauderer
Remove the old NXP MCUXpresso SDK and adapt the BSP so that it uses the
new mcux-sdk.


NOTE: Due to the size, this is only the summary of the patch. You can find the
full version here:
https://gitlab.com/c-mauderer/rtems/-/commit/2a871672767a95598e5af42373bfebd3eb9440d3

---
 bsps/arm/imxrt/include/MIMXRT1052.h   | 46183 
 bsps/arm/imxrt/include/MIMXRT1052_features.h  |   688 -
 bsps/arm/imxrt/include/bsp.h  | 1 +
 bsps/arm/imxrt/include/chip.h | 3 +-
 bsps/arm/imxrt/include/fsl_adc.h  |   427 -
 bsps/arm/imxrt/include/fsl_adc_etc.h  |   336 -
 bsps/arm/imxrt/include/fsl_aipstz.h   |   134 -
 bsps/arm/imxrt/include/fsl_aoi.h  |   186 -
 bsps/arm/imxrt/include/fsl_bee.h  |   254 -
 bsps/arm/imxrt/include/fsl_cache.h|   457 -
 bsps/arm/imxrt/include/fsl_clock.h|  1550 -
 bsps/arm/imxrt/include/fsl_cmp.h  |   321 -
 bsps/arm/imxrt/include/fsl_common.h   |   967 -
 bsps/arm/imxrt/include/fsl_csi.h  |   724 -
 bsps/arm/imxrt/include/fsl_dcdc.h |   496 -
 bsps/arm/imxrt/include/fsl_dcp.h  |   569 -
 bsps/arm/imxrt/include/fsl_device_registers.h |41 -
 bsps/arm/imxrt/include/fsl_dmamux.h   |   177 -
 bsps/arm/imxrt/include/fsl_edma.h |   951 -
 bsps/arm/imxrt/include/fsl_elcdif.h   |   747 -
 bsps/arm/imxrt/include/fsl_enc.h  |   458 -
 bsps/arm/imxrt/include/fsl_enet.h |  1855 -
 bsps/arm/imxrt/include/fsl_ewm.h  |   218 -
 bsps/arm/imxrt/include/fsl_flexcan.h  |  1422 -
 bsps/arm/imxrt/include/fsl_flexio.h   |   700 -
 bsps/arm/imxrt/include/fsl_flexio_camera.h|   230 -
 .../imxrt/include/fsl_flexio_camera_edma.h|   130 -
 .../arm/imxrt/include/fsl_flexio_i2c_master.h |   486 -
 bsps/arm/imxrt/include/fsl_flexio_i2s.h   |   560 -
 bsps/arm/imxrt/include/fsl_flexio_i2s_edma.h  |   203 -
 bsps/arm/imxrt/include/fsl_flexio_mculcd.h|   685 -
 .../imxrt/include/fsl_flexio_mculcd_edma.h|   153 -
 bsps/arm/imxrt/include/fsl_flexio_spi.h   |   702 -
 bsps/arm/imxrt/include/fsl_flexio_spi_edma.h  |   207 -
 bsps/arm/imxrt/include/fsl_flexio_uart.h  |   570 -
 bsps/arm/imxrt/include/fsl_flexio_uart_edma.h |   178 -
 bsps/arm/imxrt/include/fsl_flexram.h  |   276 -
 bsps/arm/imxrt/include/fsl_flexram_allocate.h |99 -
 bsps/arm/imxrt/include/fsl_flexspi.h  |   837 -
 bsps/arm/imxrt/include/fsl_flexspi_nor_boot.h |   130 -
 bsps/arm/imxrt/include/fsl_gpc.h  |   231 -
 bsps/arm/imxrt/include/fsl_gpio.h |   342 -
 bsps/arm/imxrt/include/fsl_gpt.h  |   509 -
 bsps/arm/imxrt/include/fsl_iomuxc.h   |  1242 -
 bsps/arm/imxrt/include/fsl_kpp.h  |   180 -
 bsps/arm/imxrt/include/fsl_lpi2c.h|  1266 -
 bsps/arm/imxrt/include/fsl_lpi2c_edma.h   |   157 -
 bsps/arm/imxrt/include/fsl_lpspi.h|  1122 -
 bsps/arm/imxrt/include/fsl_lpspi_edma.h   |   301 -
 bsps/arm/imxrt/include/fsl_lpuart.h   |   866 -
 bsps/arm/imxrt/include/fsl_lpuart_edma.h  |   173 -
 bsps/arm/imxrt/include/fsl_ocotp.h|   153 -
 bsps/arm/imxrt/include/fsl_pin_mux.h  |   942 -
 bsps/arm/imxrt/include/fsl_pit.h  |   332 -
 bsps/arm/imxrt/include/fsl_pmu.h  |   671 -
 bsps/arm/imxrt/include/fsl_pwm.h  |   987 -
 bsps/arm/imxrt/include/fsl_pxp.h  |  1438 -
 bsps/arm/imxrt/include/fsl_qtmr.h |   473 -
 bsps/arm/imxrt/include/fsl_rtwdog.h   |   425 -
 bsps/arm/imxrt/include/fsl_sai.h  |  1572 -
 bsps/arm/imxrt/include/fsl_sai_edma.h |   268 -
 bsps/arm/imxrt/include/fsl_semc.h |   831 -
 bsps/arm/imxrt/include/fsl_snvs_hp.h  |   626 -
 bsps/arm/imxrt/include/fsl_snvs_lp.h  |   555 -
 bsps/arm/imxrt/include/fsl_spdif.h|   746 -
 bsps/arm/imxrt/include/fsl_spdif_edma.h   |   192 -
 bsps/arm/imxrt/include/fsl_src.h  |   602 -
 bsps/arm/imxrt/include/fsl_tempmon.h  |   126 -
 bsps/arm/imxrt/include/fsl_trng.h |   228 -
 bsps/arm/imxrt/include/fsl_tsc.h  |   524 -
 bsps/arm/imxrt/include/fsl_usdhc.h|  1581 -
 bsps/arm/imxrt/include/fsl_wdog.h |   305 -
 bsps/arm/imxrt/include/fsl_xbara.h|   183 -
 bsps/arm/imxrt/include/fsl_xbarb.h|82 -
 bsps/arm/imxrt/include/system_MIMXRT1052.h|   129 -
 .../imxrt/nxp/boards/evkbimxrt1050/pin_mux.c  |  1073 +-
 .../nxp/devices/MIMXRT1052/drivers/fsl_adc.c  |   395 -
 .../devices/MIMXRT1052/drivers/fsl_adc_etc.c  |   433 -
 .../devices/MIMXRT1052/drivers/fsl_aipstz.c   |51 -
 .../nxp/devices/MIMXRT1052/drivers/fsl_aoi.c  |   214 -
 .../nxp/devices/MIMXRT1052/drivers/fsl_bee.c  |   303 -
 .../devices/MIMXRT1052/drivers/fsl_cache.c|   602 -
 .../devices/MI

[PATCH rtems 06/12] bsps/imxrt: Get clock for IMXRT11xx in drivers

2023-05-04 Thread Christian Mauderer
The mcux_sdk has a different interface for getting the clock for
IMXRT11xx than for getting it in IMXRT10xx. Adapt simple drivers to
support that interface.
---
 bsps/arm/imxrt/console/console.c  | 35 +--
 bsps/arm/imxrt/i2c/imxrt-lpi2c.c  | 18 --
 .../imxrt/mcux-sdk/drivers/qtmr_1/fsl_qtmr.c  |  8 +
 bsps/arm/imxrt/spi/imxrt-lpspi.c  | 18 --
 4 files changed, 73 insertions(+), 6 deletions(-)

diff --git a/bsps/arm/imxrt/console/console.c b/bsps/arm/imxrt/console/console.c
index 05320f2c4c..e3f6a091c6 100644
--- a/bsps/arm/imxrt/console/console.c
+++ b/bsps/arm/imxrt/console/console.c
@@ -53,6 +53,7 @@ typedef struct {
   volatile LPUART_Type *regs;
   rtems_vector_number irq;
   const char *path;
+  clock_ip_name_t clock_ip;
   uint32_t src_clock_hz;
   lpuart_config_t config;
 } imxrt_lpuart_context;
@@ -174,12 +175,15 @@ static bool imxrt_lpuart_set_attributes(
   return true;
 }
 
-static uint32_t imxrt_lpuart_get_src_freq(void)
+static uint32_t imxrt_lpuart_get_src_freq(clock_ip_name_t clock_ip)
 {
   uint32_t freq;
+#if IMXRT_IS_MIMXRT10xx
   uint32_t mux;
   uint32_t divider;
 
+  (void) clock_ip; /* Not necessary for i.MXRT1050 */
+
   mux = CLOCK_GetMux(kCLOCK_UartMux);
   divider = 1;
 
@@ -197,10 +201,36 @@ static uint32_t imxrt_lpuart_get_src_freq(void)
 
   divider *= CLOCK_GetDiv(kCLOCK_UartDiv) + 1U;
   freq /= divider;
+#elif IMXRT_IS_MIMXRT11xx
+  /*
+   * FIXME: A future version of the mcux_sdk might provide a better method to
+   * get the clock instead of this hack.
+   */
+  clock_root_t clock_root = clock_ip + kCLOCK_Root_Lpuart1 - kCLOCK_Lpuart1;
+
+  freq = CLOCK_GetRootClockFreq(clock_root);
+#else
+  #error Getting UART clock frequency is not implemented for this chip
+#endif
 
   return freq;
 }
 
+static clock_ip_name_t imxrt_lpuart_clock_ip(volatile LPUART_Type *regs)
+{
+  LPUART_Type *const base_addresses[] = LPUART_BASE_PTRS;
+  static const clock_ip_name_t lpuart_clocks[] = LPUART_CLOCKS;
+  size_t i;
+
+  for (i = 0; i < RTEMS_ARRAY_SIZE(base_addresses); ++i) {
+if (base_addresses[i] == regs) {
+  return lpuart_clocks[i];
+}
+  }
+
+  return kCLOCK_IpInvalid;
+}
+
 static void imxrt_lpuart_init_hardware(imxrt_lpuart_context *ctx)
 {
   (void) LPUART_Init((LPUART_Type *)ctx->regs, &ctx->config,
@@ -378,7 +408,8 @@ static void imxrt_lpuart_init_context_from_fdt(
 bsp_fatal(IMXRT_FATAL_LPI2C_INVALID_FDT);
   }
 
-  ctx->src_clock_hz = imxrt_lpuart_get_src_freq();
+  ctx->clock_ip = imxrt_lpuart_clock_ip(ctx->regs);
+  ctx->src_clock_hz = imxrt_lpuart_get_src_freq(ctx->clock_ip);
 
   LPUART_GetDefaultConfig(&ctx->config);
   ctx->config.enableTx = true;
diff --git a/bsps/arm/imxrt/i2c/imxrt-lpi2c.c b/bsps/arm/imxrt/i2c/imxrt-lpi2c.c
index 783c6e18e6..d3aebc45e0 100644
--- a/bsps/arm/imxrt/i2c/imxrt-lpi2c.c
+++ b/bsps/arm/imxrt/i2c/imxrt-lpi2c.c
@@ -373,12 +373,15 @@ static int imxrt_lpi2c_hw_init(struct imxrt_lpi2c_bus 
*bus)
   return 0;
 }
 
-static uint32_t imxrt_lpi2c_get_src_freq(void)
+static uint32_t imxrt_lpi2c_get_src_freq(clock_ip_name_t clock_ip)
 {
   uint32_t freq;
+#if IMXRT_IS_MIMXRT10xx
   uint32_t mux;
   uint32_t divider;
 
+  (void) clock_ip; /* Not necessary for i.MXRT1050 */
+
   mux = CLOCK_GetMux(kCLOCK_Lpi2cMux);
   divider = 1;
 
@@ -396,6 +399,17 @@ static uint32_t imxrt_lpi2c_get_src_freq(void)
 
   divider *= CLOCK_GetDiv(kCLOCK_Lpi2cDiv) + 1;
   freq /= divider;
+#elif IMXRT_IS_MIMXRT11xx
+  /*
+   * FIXME: A future version of the mcux_sdk might provide a better method to
+   * get the clock instead of this hack.
+   */
+  clock_root_t clock_root = clock_ip + kCLOCK_Root_Lpi2c1 - kCLOCK_Lpi2c1;
+
+  freq = CLOCK_GetRootClockFreq(clock_root);
+#else
+  #error Getting I2C frequency is not implemented for this chip.
+#endif
 
   return freq;
 }
@@ -457,7 +471,7 @@ void imxrt_lpi2c_init(void)
   }
 
   bus->clock_ip = imxrt_lpi2c_clock_ip(bus->regs);
-  bus->src_clock_hz = imxrt_lpi2c_get_src_freq();
+  bus->src_clock_hz = imxrt_lpi2c_get_src_freq(bus->clock_ip);
 
   eno = imxrt_lpi2c_hw_init(bus);
   if (eno != 0) {
diff --git a/bsps/arm/imxrt/mcux-sdk/drivers/qtmr_1/fsl_qtmr.c 
b/bsps/arm/imxrt/mcux-sdk/drivers/qtmr_1/fsl_qtmr.c
index a4e393896b..4c8bd71be5 100644
--- a/bsps/arm/imxrt/mcux-sdk/drivers/qtmr_1/fsl_qtmr.c
+++ b/bsps/arm/imxrt/mcux-sdk/drivers/qtmr_1/fsl_qtmr.c
@@ -92,9 +92,17 @@ rtems_vector_number QTMR_get_IRQ_from_fdt(const void *fdt, 
int node)
 
 uint32_t QTMR_get_src_clk(TMR_Type *base)
 {
+#if IMXRT_IS_MIMXRT10xx
 (void) base;
 
 return CLOCK_GetFreq(kCLOCK_IpgClk);
+#elif IMXRT_IS_MIMXRT11xx
+(void) base;
+
+return CLOCK_GetRootClockMux(kCLOCK_Root_Bus);
+#else
+  #error Getting Timer clock frequency is not implemented for this chip
+#endif
 }
 
 #endif /* __rtems__ */
diff --git a/bsps/arm/imxrt/spi/imxrt-lpspi.c b/bsps/arm/imxrt/spi/imxrt-lpspi.c
index 80b47f9663..62503e4bd8 100644
--- a/bsps/arm/imx

[PATCH rtems 09/12] bsps/imxrt: Support more chip variants in header

2023-05-04 Thread Christian Mauderer
The different variants of the i.MXRT have some minimal differences in
the fsl_flexspi_nor_config.h. Make sure that the header supports the
different chips.
---
 .../imxrt/include/fsl_flexspi_nor_config.h| 49 +++
 1 file changed, 40 insertions(+), 9 deletions(-)

diff --git a/bsps/arm/imxrt/include/fsl_flexspi_nor_config.h 
b/bsps/arm/imxrt/include/fsl_flexspi_nor_config.h
index 4a2a158f50..541eb7e68a 100644
--- a/bsps/arm/imxrt/include/fsl_flexspi_nor_config.h
+++ b/bsps/arm/imxrt/include/fsl_flexspi_nor_config.h
@@ -1,13 +1,14 @@
 /*
- * Copyright (c) 2016, Freescale Semiconductor, Inc.
- * Copyright 2016-2017 NXP
+ * Copyright 2017-2020 NXP
  * All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Based on file for EVKBIMSRT1050 with values for other EVKs integrated.
  */
 
-#ifndef __EVKBIMXRT1050_FLEXSPI_NOR_CONFIG__
-#define __EVKBIMXRT1050_FLEXSPI_NOR_CONFIG__
+#ifndef __FSL_FLEXSPI_NOR_CONFIG__
+#define __FSL_FLEXSPI_NOR_CONFIG__
 
 #include 
 #include 
@@ -15,8 +16,8 @@
 
 /*! @name Driver version */
 /*@{*/
-/*! @brief XIP_BOARD driver version 2.0.0. */
-#define FSL_XIP_BOARD_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
+/*! @brief XIP_BOARD driver version 2.0.1. */
+#define FSL_XIP_BOARD_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
 /*@}*/
 
 /* FLEXSPI memory config block related defintions */
@@ -82,11 +83,39 @@ typedef enum _FlexSpiSerialClockFreq
 kFlexSpiSerialClk_30MHz  = 1,
 kFlexSpiSerialClk_50MHz  = 2,
 kFlexSpiSerialClk_60MHz  = 3,
+#if defined(MIMXRT1011_SERIES)
+kFlexSpiSerialClk_75MHz  = 4,
+kFlexSpiSerialClk_80MHz  = 5,
+kFlexSpiSerialClk_100MHz = 6,
+kFlexSpiSerialClk_120MHz = 7,
+kFlexSpiSerialClk_133MHz = 8,
+#elif defined(MIMXRT1015_SERIES) || defined(MIMXRT1021_SERIES) || 
defined(MIMXRT1024_SERIES)
+kFlexSpiSerialClk_75MHz  = 4,
+kFlexSpiSerialClk_80MHz  = 5,
+kFlexSpiSerialClk_100MHz = 6,
+kFlexSpiSerialClk_133MHz = 7,
+#elif defined(MIMXRT1052_SERIES)
 kFlexSpiSerialClk_75MHz  = 4,
 kFlexSpiSerialClk_80MHz  = 5,
 kFlexSpiSerialClk_100MHz = 6,
 kFlexSpiSerialClk_133MHz = 7,
 kFlexSpiSerialClk_166MHz = 8,
+#elif defined(MIMXRT1042_SERIES) || defined(MIMXRT1062_SERIES) || 
defined(MIMXRT1064_SERIES)
+kFlexSpiSerialClk_75MHz  = 4,
+kFlexSpiSerialClk_80MHz  = 5,
+kFlexSpiSerialClk_100MHz = 6,
+kFlexSpiSerialClk_120MHz = 7,
+kFlexSpiSerialClk_133MHz = 8,
+kFlexSpiSerialClk_166MHz = 9,
+#elif defined(MIMXRT1166_cm4_SERIES) || defined(MIMXRT1166_cm7_SERIES) || \
+  defined(MIMXRT1176_cm4_SERIES) || defined(MIMXRT1176_cm7_SERIES)
+kFlexSpiSerialClk_80MHz  = 4,
+kFlexSpiSerialClk_100MHz = 5,
+kFlexSpiSerialClk_120MHz = 6,
+kFlexSpiSerialClk_133MHz = 7,
+kFlexSpiSerialClk_166MHz = 8,
+kFlexSpiSerialClk_200MHz = 9,
+#endif
 } flexspi_serial_clk_freq_t;
 
 //!@brief FlexSPI clock configuration type
@@ -249,13 +278,15 @@ typedef struct _flexspi_nor_config
 uint32_t sectorSize;//!< Sector size of Serial NOR
 uint8_t ipcmdSerialClkFreq; //!< Clock frequency for IP command
 uint8_t isUniformBlockSize; //!< Sector/Block size is the same
-uint8_t reserved0[2];   //!< Reserved for future use
+uint8_t isDataOrderSwapped; //!< The data order is swapped in OPI DDR 
mode (only i.MXRT11*)
+uint8_t reserved0;  //!< Reserved for future use
 uint8_t serialNorType;  //!< Serial NOR Flash type: 0/1/2/3
 uint8_t needExitNoCmdMode;  //!< Need to exit NoCmd mode before other 
IP command
 uint8_t halfClkForNonReadCmd;   //!< Half the Serial Clock for non-read 
command: true/false
 uint8_t needRestoreNoCmdMode;   //!< Need to Restore NoCmd mode after IP 
commmand execution
 uint32_t blockSize; //!< Block size
-uint32_t reserve2[11];  //!< Reserved for future use
+uint32_t FlashStateCtx; //!< Flash State Context after being 
configured (only i.MXRT11*)
+uint32_t reserve2[10];  //!< Reserved for future use
 } flexspi_nor_config_t;
 
 #ifdef __cplusplus
@@ -265,4 +296,4 @@ extern "C" {
 #ifdef __cplusplus
 }
 #endif
-#endif /* __EVKBIMXRT1050_FLEXSPI_NOR_CONFIG__ */
+#endif /* __FSL_FLEXSPI_NOR_CONFIG__ */
-- 
2.35.3

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


[PATCH rtems 08/12] bsps/imxrt: Remove unmaintained defines

2023-05-04 Thread Christian Mauderer
The defines for the different clock frequencies in the
fsl_clock_config.h do not represent the clock frequencies that have been
set up in the registers. Remove them to avoid someone trusting in
correct values.
---
 bsps/arm/imxrt/include/fsl_clock_config.h | 58 +--
 .../nxp/boards/evkbimxrt1050/clock_config.c   |  2 +-
 2 files changed, 4 insertions(+), 56 deletions(-)

diff --git a/bsps/arm/imxrt/include/fsl_clock_config.h 
b/bsps/arm/imxrt/include/fsl_clock_config.h
index f213ac7e23..5c09daf59d 100644
--- a/bsps/arm/imxrt/include/fsl_clock_config.h
+++ b/bsps/arm/imxrt/include/fsl_clock_config.h
@@ -8,6 +8,7 @@
 #ifndef _CLOCK_CONFIG_H_
 #define _CLOCK_CONFIG_H_
 
+#include 
 #include "fsl_common.h"
 
 
/***
@@ -34,61 +35,7 @@ void BOARD_InitBootClocks(void);
 }
 #endif /* __cplusplus*/
 
-/***
- ** Configuration BOARD_BootClockRUN 
***
- 
**/
-/***
- * Definitions for BOARD_BootClockRUN configuration
- 
**/
-#define BOARD_BOOTCLOCKRUN_CORE_CLOCK 6U /*!< Core clock frequency: 
6Hz */
-
-/* Clock outputs (values are in Hz): */
-#define BOARD_BOOTCLOCKRUN_AHB_CLK_ROOT 6UL
-#define BOARD_BOOTCLOCKRUN_CAN_CLK_ROOT 4000UL
-#define BOARD_BOOTCLOCKRUN_CKIL_SYNC_CLK_ROOT 32768UL
-#define BOARD_BOOTCLOCKRUN_CLKO1_CLK 0UL
-#define BOARD_BOOTCLOCKRUN_CLKO2_CLK 0UL
-#define BOARD_BOOTCLOCKRUN_CLK_1M 100UL
-#define BOARD_BOOTCLOCKRUN_CLK_24M 2400UL
-#define BOARD_BOOTCLOCKRUN_CSI_CLK_ROOT 1200UL
-#define BOARD_BOOTCLOCKRUN_ENET1_TX_CLK 240UL
-#define BOARD_BOOTCLOCKRUN_ENET_125M_CLK 240UL
-#define BOARD_BOOTCLOCKRUN_ENET_25M_REF_CLK 120UL
-#define BOARD_BOOTCLOCKRUN_FLEXIO1_CLK_ROOT 3000UL
-#define BOARD_BOOTCLOCKRUN_FLEXIO2_CLK_ROOT 3000UL
-#define BOARD_BOOTCLOCKRUN_FLEXSPI_CLK_ROOT 16000UL
-#define BOARD_BOOTCLOCKRUN_GPT1_IPG_CLK_HIGHFREQ 7500UL
-#define BOARD_BOOTCLOCKRUN_GPT2_IPG_CLK_HIGHFREQ 7500UL
-#define BOARD_BOOTCLOCKRUN_IPG_CLK_ROOT 15000UL
-#define BOARD_BOOTCLOCKRUN_LCDIF_CLK_ROOT 9642857UL
-#define BOARD_BOOTCLOCKRUN_LPI2C_CLK_ROOT 6000UL
-#define BOARD_BOOTCLOCKRUN_LPSPI_CLK_ROOT 10560UL
-#define BOARD_BOOTCLOCKRUN_LVDS1_CLK 12UL
-#define BOARD_BOOTCLOCKRUN_MQS_MCLK 63529411UL
-#define BOARD_BOOTCLOCKRUN_PERCLK_CLK_ROOT 7500UL
-#define BOARD_BOOTCLOCKRUN_PLL7_MAIN_CLK 2400UL
-#define BOARD_BOOTCLOCKRUN_SAI1_CLK_ROOT 63529411UL
-#define BOARD_BOOTCLOCKRUN_SAI1_MCLK1 63529411UL
-#define BOARD_BOOTCLOCKRUN_SAI1_MCLK2 63529411UL
-#define BOARD_BOOTCLOCKRUN_SAI1_MCLK3 3000UL
-#define BOARD_BOOTCLOCKRUN_SAI2_CLK_ROOT 63529411UL
-#define BOARD_BOOTCLOCKRUN_SAI2_MCLK1 63529411UL
-#define BOARD_BOOTCLOCKRUN_SAI2_MCLK2 0UL
-#define BOARD_BOOTCLOCKRUN_SAI2_MCLK3 3000UL
-#define BOARD_BOOTCLOCKRUN_SAI3_CLK_ROOT 63529411UL
-#define BOARD_BOOTCLOCKRUN_SAI3_MCLK1 63529411UL
-#define BOARD_BOOTCLOCKRUN_SAI3_MCLK2 0UL
-#define BOARD_BOOTCLOCKRUN_SAI3_MCLK3 3000UL
-#define BOARD_BOOTCLOCKRUN_SEMC_CLK_ROOT 7500UL
-#define BOARD_BOOTCLOCKRUN_SPDIF0_CLK_ROOT 3000UL
-#define BOARD_BOOTCLOCKRUN_SPDIF0_EXTCLK_OUT 0UL
-#define BOARD_BOOTCLOCKRUN_TRACE_CLK_ROOT 11733UL
-#define BOARD_BOOTCLOCKRUN_UART_CLK_ROOT 8000UL
-#define BOARD_BOOTCLOCKRUN_USBPHY1_CLK 0UL
-#define BOARD_BOOTCLOCKRUN_USBPHY2_CLK 0UL
-#define BOARD_BOOTCLOCKRUN_USDHC1_CLK_ROOT 19800UL
-#define BOARD_BOOTCLOCKRUN_USDHC2_CLK_ROOT 19800UL
-
+#if IMXRT_IS_MIMXRT10xx
 /*! @brief Arm PLL set for BOARD_BootClockRUN configuration.
  */
 extern const clock_arm_pll_config_t armPllConfig_BOARD_BootClockRUN;
@@ -98,6 +45,7 @@ extern const clock_usb_pll_config_t 
usb1PllConfig_BOARD_BootClockRUN;
 /*! @brief Sys PLL for BOARD_BootClockRUN configuration.
  */
 extern const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN;
+#endif
 
 
/***
  * API for BOARD_BootClockRUN configuration
diff --git a/bsps/arm/imxrt/nxp/boards/evkbimxrt1050/clock_config.c 
b/bsps/arm/imxrt/nxp/boards/evkbimxrt1050/clock_config.c
index 4ab5216ee1..8f6980d0ef 100644
--- a/bsps/arm/imxrt/nxp/boards/evkbimxrt1050/clock_config.c
+++ b/bsps/arm/imxrt/nxp/boards/evkbimxrt1050/clock_config.c
@@ -487,5 +487,5 @@ void BOARD_BootClockRUN(void)
 /* Set GPT2 High frequency reference clock source. */
 IOMUXC_GPR->GPR5 &= ~IOMUXC_GPR_GPR5_VREF_1M_CLK_GPT2_MASK;
 /* Set SystemCoreClock variable. */
-SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
+SystemCoreClock = 6U;
 }
-- 
2.35.3

___
deve

[PATCH rtems 07/12] bsps/shared: Fix header for fsl-edma

2023-05-04 Thread Christian Mauderer
If a different chip variant is used in the i.mxrt BSP, a different
header would have to be included. Make sure that the fsl-edma driver
uses a header that doesn't have to be adapted.
---
 bsps/shared/dev/dma/fsl-edma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bsps/shared/dev/dma/fsl-edma.c b/bsps/shared/dev/dma/fsl-edma.c
index b3e1bb2fc5..3cb91c14e6 100644
--- a/bsps/shared/dev/dma/fsl-edma.c
+++ b/bsps/shared/dev/dma/fsl-edma.c
@@ -40,7 +40,7 @@
 #include 
 #include 
 #ifdef LIBBSP_ARM_IMXRT_BSP_H
-#include 
+#include 
 #endif
 
 #define EDMA_CHANNELS_PER_GROUP 32U
-- 
2.35.3

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


[PATCH rtems 02/12] bsp/imxrt: Update support library from mcux-sdk

2023-05-04 Thread Christian Mauderer
This imports new files from the mcux-sdk support library. NXP now offers
the library as a git repository instead of a zip package. The git
repository supports multiple CPUs from the i.MXRT family:

  https://github.com/nxp-mcuxpresso/mcux-sdk.git

The imported files are from revision

  2b9354539e6e4f722749e87b0bdc22966dc080d9

This revision is the same as MCUXpresso 2.13.0 with small bug fixes.


NOTE: Due to the size, this is only the summary of the patch. You can find the
full version here:
https://gitlab.com/c-mauderer/rtems/-/commit/2a871672767a95598e5af42373bfebd3eb9440d3

---
 .../mcux-sdk/devices/MIMXRT1011/MIMXRT1011.h  |  36631 +
 .../devices/MIMXRT1011/MIMXRT1011_features.h  |572 +
 .../devices/MIMXRT1011/drivers/fsl_clock.c|   1224 +
 .../devices/MIMXRT1011/drivers/fsl_clock.h|   1574 +
 .../MIMXRT1011/drivers/fsl_flexram_allocate.c | 86 +
 .../MIMXRT1011/drivers/fsl_flexram_allocate.h | 87 +
 .../devices/MIMXRT1011/drivers/fsl_iomuxc.h   |591 +
 .../devices/MIMXRT1011/drivers/fsl_nic301.h   |294 +
 .../devices/MIMXRT1011/fsl_device_registers.h | 35 +
 .../MIMXRT1011/gcc/startup_MIMXRT1011.S   |861 +
 .../devices/MIMXRT1011/system_MIMXRT1011.c|221 +
 .../devices/MIMXRT1011/system_MIMXRT1011.h|120 +
 .../MIMXRT1011/xip/fsl_flexspi_nor_boot.c | 49 +
 .../MIMXRT1011/xip/fsl_flexspi_nor_boot.h |124 +
 .../mcux-sdk/devices/MIMXRT1015/MIMXRT1015.h  |  39826 ++
 .../devices/MIMXRT1015/MIMXRT1015_features.h  |581 +
 .../devices/MIMXRT1015/drivers/fsl_clock.c|   1201 +
 .../devices/MIMXRT1015/drivers/fsl_clock.h|   1648 +
 .../MIMXRT1015/drivers/fsl_flexram_allocate.c | 86 +
 .../MIMXRT1015/drivers/fsl_flexram_allocate.h | 87 +
 .../devices/MIMXRT1015/drivers/fsl_iomuxc.h   |570 +
 .../devices/MIMXRT1015/drivers/fsl_nic301.h   |294 +
 .../devices/MIMXRT1015/drivers/fsl_romapi.c   |170 +
 .../devices/MIMXRT1015/drivers/fsl_romapi.h   |554 +
 .../devices/MIMXRT1015/fsl_device_registers.h | 35 +
 .../MIMXRT1015/gcc/startup_MIMXRT1015.S   |924 +
 .../devices/MIMXRT1015/system_MIMXRT1015.c|225 +
 .../devices/MIMXRT1015/system_MIMXRT1015.h|122 +
 .../MIMXRT1015/xip/fsl_flexspi_nor_boot.c | 49 +
 .../MIMXRT1015/xip/fsl_flexspi_nor_boot.h |124 +
 .../mcux-sdk/devices/MIMXRT1024/MIMXRT1024.h  |  47174 +++
 .../devices/MIMXRT1024/MIMXRT1024_features.h  |746 +
 .../devices/MIMXRT1024/drivers/fsl_clock.c|   1249 +
 .../devices/MIMXRT1024/drivers/fsl_clock.h|   1806 +
 .../MIMXRT1024/drivers/fsl_flexram_allocate.c | 86 +
 .../MIMXRT1024/drivers/fsl_flexram_allocate.h | 87 +
 .../devices/MIMXRT1024/drivers/fsl_iomuxc.h   |954 +
 .../devices/MIMXRT1024/drivers/fsl_nic301.h   |294 +
 .../devices/MIMXRT1024/drivers/fsl_romapi.c   |170 +
 .../devices/MIMXRT1024/drivers/fsl_romapi.h   |554 +
 .../devices/MIMXRT1024/fsl_device_registers.h | 36 +
 .../MIMXRT1024/gcc/startup_MIMXRT1024.S   |   1058 +
 .../devices/MIMXRT1024/system_MIMXRT1024.c|251 +
 .../devices/MIMXRT1024/system_MIMXRT1024.h|114 +
 .../MIMXRT1024/xip/fsl_flexspi_nor_boot.c | 49 +
 .../MIMXRT1024/xip/fsl_flexspi_nor_boot.h |124 +
 .../mcux-sdk/devices/MIMXRT1042/MIMXRT1042.h  |  53934 
 .../devices/MIMXRT1042/MIMXRT1042_features.h  |783 +
 .../devices/MIMXRT1042/drivers/fsl_clock.c|   1434 +
 .../devices/MIMXRT1042/drivers/fsl_clock.h|   1985 +
 .../MIMXRT1042/drivers/fsl_flexram_allocate.c | 86 +
 .../MIMXRT1042/drivers/fsl_flexram_allocate.h | 87 +
 .../devices/MIMXRT1042/drivers/fsl_iomuxc.h   |   1156 +
 .../devices/MIMXRT1042/drivers/fsl_nic301.h   |313 +
 .../devices/MIMXRT1042/drivers/fsl_romapi.c   |196 +
 .../devices/MIMXRT1042/drivers/fsl_romapi.h   |639 +
 .../devices/MIMXRT1042/fsl_device_registers.h | 35 +
 .../MIMXRT1042/gcc/startup_MIMXRT1042.S   |   1100 +
 .../devices/MIMXRT1042/system_MIMXRT1042.c|229 +
 .../devices/MIMXRT1042/system_MIMXRT1042.h|118 +
 .../MIMXRT1042/xip/fsl_flexspi_nor_boot.c | 49 +
 .../MIMXRT1042/xip/fsl_flexspi_nor_boot.h |124 +
 .../mcux-sdk/devices/MIMXRT1051/MIMXRT1051.h  |  49292 +++
 .../devices/MIMXRT1051/MIMXRT1051_features.h  |759 +
 .../devices/MIMXRT1051/drivers/fsl_clock.c|   1531 +
 .../devices/MIMXRT1051/drivers/fsl_clock.h|   2039 +
 .../MIMXRT1051/drivers/fsl_flexram_allocate.c | 86 +
 .../MIMXRT1051/drivers/fsl_flexram_allocate.h | 87 +
 .../devices/MIMXRT1051/drivers/fsl_iomuxc.h   |   1241 +
 .../devices/MIMXRT1051/drivers/fsl_nic301.h   |308 +
 .../devices/MIMXRT1051/drivers/fsl_romapi.c   |162 +
 .../devices/MIMXRT1051/drivers/fsl_romapi.h   |565 +
 .../devices/MIMXRT1051/fsl_device_registers.h | 36 +
 .../MIMXRT1051/gcc/startup_MIMXRT1051.S   |   1077 +
 .../devices/MIMXRT1051/system_MIMXRT1051.c|242 +
 .../devices/MI

[PATCH rtems 03/12] bsps/imxrt: (Re-)Apply RTEMS patches to new lib

2023-05-04 Thread Christian Mauderer
Reapply patches used in the old version of the NXP library and apply
patches necessary for the new version of the library.
---
 .../devices/MIMXRT1011/fsl_device_registers.h |   3 +
 .../MIMXRT1011/xip/fsl_flexspi_nor_boot.h |   4 +
 .../devices/MIMXRT1015/fsl_device_registers.h |   3 +
 .../MIMXRT1015/xip/fsl_flexspi_nor_boot.h |   4 +
 .../devices/MIMXRT1024/fsl_device_registers.h |   3 +
 .../MIMXRT1024/xip/fsl_flexspi_nor_boot.h |   4 +
 .../devices/MIMXRT1042/fsl_device_registers.h |   3 +
 .../MIMXRT1042/xip/fsl_flexspi_nor_boot.h |   4 +
 .../devices/MIMXRT1051/fsl_device_registers.h |   3 +
 .../devices/MIMXRT1052/fsl_device_registers.h |   3 +
 .../MIMXRT1052/xip/fsl_flexspi_nor_boot.h |   4 +
 .../devices/MIMXRT1061/fsl_device_registers.h |   3 +
 .../devices/MIMXRT1062/fsl_device_registers.h |   3 +
 .../MIMXRT1062/xip/fsl_flexspi_nor_boot.h |   4 +
 .../devices/MIMXRT1064/fsl_device_registers.h |   3 +
 .../MIMXRT1064/xip/fsl_flexspi_nor_boot.h |   4 +
 .../devices/MIMXRT1165/fsl_device_registers.h |   3 +
 .../devices/MIMXRT1166/fsl_device_registers.h |   3 +
 .../MIMXRT1166/xip/fsl_flexspi_nor_boot.h |   4 +
 .../devices/MIMXRT1171/fsl_device_registers.h |   3 +
 .../devices/MIMXRT1172/fsl_device_registers.h |   3 +
 .../devices/MIMXRT1173/fsl_device_registers.h |   3 +
 .../devices/MIMXRT1175/fsl_device_registers.h |   3 +
 .../devices/MIMXRT1176/fsl_device_registers.h |   3 +
 .../MIMXRT1176/xip/fsl_flexspi_nor_boot.h |   4 +
 .../mcux-sdk/drivers/common/fsl_common.h  | 310 ++
 .../mcux-sdk/drivers/lpuart/fsl_lpuart.c  |  17 +
 .../mcux-sdk/drivers/lpuart/fsl_lpuart.h  |   4 +
 .../imxrt/mcux-sdk/drivers/qtmr_1/fsl_qtmr.c  |  40 +++
 .../imxrt/mcux-sdk/drivers/qtmr_1/fsl_qtmr.h  |  34 ++
 30 files changed, 489 insertions(+)

diff --git a/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1011/fsl_device_registers.h 
b/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1011/fsl_device_registers.h
index 53c8f43a30..43c5531aee 100644
--- a/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1011/fsl_device_registers.h
+++ b/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1011/fsl_device_registers.h
@@ -10,6 +10,9 @@
 #ifndef __FSL_DEVICE_REGISTERS_H__
 #define __FSL_DEVICE_REGISTERS_H__
 
+#ifdef __rtems__
+#include 
+#endif /* __rtems__ */
 /*
  * Include the cpu specific register header files.
  *
diff --git 
a/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1011/xip/fsl_flexspi_nor_boot.h 
b/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1011/xip/fsl_flexspi_nor_boot.h
index 38d5d1833e..5f81090890 100644
--- a/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1011/xip/fsl_flexspi_nor_boot.h
+++ b/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1011/xip/fsl_flexspi_nor_boot.h
@@ -10,9 +10,11 @@
 
 #include 
 #include "fsl_common.h"
+#ifndef __rtems__
 #ifndef BOARD_FLASH_SIZE
 #include "board.h"
 #endif
+#endif /* __rtems__ */
 
 /*! @name Driver version */
 /*@{*/
@@ -108,11 +110,13 @@ typedef struct _boot_data_
 #define FLASH_BASE FlexSPI_AMBA_BASE
 #endif
 
+#ifndef __rtems__
 #if defined(BOARD_FLASH_SIZE)
 #define FLASH_SIZE BOARD_FLASH_SIZE
 #else
 #error "Please define macro BOARD_FLASH_SIZE"
 #endif
+#endif /* __rtems__ */
 #define PLUGIN_FLAG (uint32_t)0
 
 /* External Variables */
diff --git a/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1015/fsl_device_registers.h 
b/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1015/fsl_device_registers.h
index 49f3013f6e..93b5c23d36 100644
--- a/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1015/fsl_device_registers.h
+++ b/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1015/fsl_device_registers.h
@@ -10,6 +10,9 @@
 #ifndef __FSL_DEVICE_REGISTERS_H__
 #define __FSL_DEVICE_REGISTERS_H__
 
+#ifdef __rtems__
+#include 
+#endif /* __rtems__ */
 /*
  * Include the cpu specific register header files.
  *
diff --git 
a/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1015/xip/fsl_flexspi_nor_boot.h 
b/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1015/xip/fsl_flexspi_nor_boot.h
index 38d5d1833e..5f81090890 100644
--- a/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1015/xip/fsl_flexspi_nor_boot.h
+++ b/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1015/xip/fsl_flexspi_nor_boot.h
@@ -10,9 +10,11 @@
 
 #include 
 #include "fsl_common.h"
+#ifndef __rtems__
 #ifndef BOARD_FLASH_SIZE
 #include "board.h"
 #endif
+#endif /* __rtems__ */
 
 /*! @name Driver version */
 /*@{*/
@@ -108,11 +110,13 @@ typedef struct _boot_data_
 #define FLASH_BASE FlexSPI_AMBA_BASE
 #endif
 
+#ifndef __rtems__
 #if defined(BOARD_FLASH_SIZE)
 #define FLASH_SIZE BOARD_FLASH_SIZE
 #else
 #error "Please define macro BOARD_FLASH_SIZE"
 #endif
+#endif /* __rtems__ */
 #define PLUGIN_FLAG (uint32_t)0
 
 /* External Variables */
diff --git a/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1024/fsl_device_registers.h 
b/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1024/fsl_device_registers.h
index edc59521dd..8b33d081e6 100644
--- a/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1024/fsl_device_registers.h
+++ b/bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1024/fsl_device_registers.h
@@ -10,6 +10,9 @@
 #ifndef __FSL

[PATCH rtems 10/12] bsps/imxrt: Make chip start code chip specific

2023-05-04 Thread Christian Mauderer
Some parts of the startup code don't apply for all chips. Make that part
chip specific.
---
 bsps/arm/imxrt/start/bspstart.c  | 4 
 bsps/arm/imxrt/start/bspstarthooks.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/bsps/arm/imxrt/start/bspstart.c b/bsps/arm/imxrt/start/bspstart.c
index 445af04563..6d873f4afd 100644
--- a/bsps/arm/imxrt/start/bspstart.c
+++ b/bsps/arm/imxrt/start/bspstart.c
@@ -47,6 +47,7 @@ uint32_t imxrt_systick_frequency(void)
 
 static void imxrt_disable_wait_mode(void)
 {
+#if IMXRT_IS_MIMXRT10xx
   /*
* Prevent processor from entering WAIT or SLEEP mode when a WFI is executed.
* This would switch off the normal interrupt controller and activate an
@@ -58,6 +59,9 @@ static void imxrt_disable_wait_mode(void)
* every WFI.
*/
   CLOCK_SetMode(kCLOCK_ModeRun);
+#else
+  #error Disabling wait mode not implemented for this chip.
+#endif
 }
 
 void bsp_start(void)
diff --git a/bsps/arm/imxrt/start/bspstarthooks.c 
b/bsps/arm/imxrt/start/bspstarthooks.c
index a84f2a427f..5bd847b1cf 100644
--- a/bsps/arm/imxrt/start/bspstarthooks.c
+++ b/bsps/arm/imxrt/start/bspstarthooks.c
@@ -58,9 +58,11 @@ BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
   BOARD_BootClockRUN();
   BOARD_InitDEBUG_UARTPins();
 
+#if IMXRT_IS_MIMXRT10xx
   /* Reduce frequency for I2C */
   CLOCK_SetDiv(kCLOCK_Lpi2cDiv, 5);
 
   /* Enable EDMA clock. We initialize the EDMA so we need the clock. */
   CLOCK_EnableClock(kCLOCK_Dma);
+#endif
 }
-- 
2.35.3

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


[PATCH rtems 11/12] bsps/imxrt: Move board specific files

2023-05-04 Thread Christian Mauderer
Move the files that are board specific and not specific to the chip
family into a separate folder.
---
 .../evkbimxrt1050}/clock-arm-pll-config.c |  0
 .../boards/evkbimxrt1050/clock_config.c   |  0
 .../evkbimxrt1050}/flash-dcd.c|  0
 .../{nxp => }/boards/evkbimxrt1050/pin_mux.c  |  0
 spec/build/bsps/arm/imxrt/bspimxrt1052.yml| 19 ---
 spec/build/bsps/arm/imxrt/obj.yml |  7 ---
 6 files changed, 16 insertions(+), 10 deletions(-)
 rename bsps/arm/imxrt/{start => boards/evkbimxrt1050}/clock-arm-pll-config.c 
(100%)
 rename bsps/arm/imxrt/{nxp => }/boards/evkbimxrt1050/clock_config.c (100%)
 rename bsps/arm/imxrt/{start => boards/evkbimxrt1050}/flash-dcd.c (100%)
 rename bsps/arm/imxrt/{nxp => }/boards/evkbimxrt1050/pin_mux.c (100%)

diff --git a/bsps/arm/imxrt/start/clock-arm-pll-config.c 
b/bsps/arm/imxrt/boards/evkbimxrt1050/clock-arm-pll-config.c
similarity index 100%
rename from bsps/arm/imxrt/start/clock-arm-pll-config.c
rename to bsps/arm/imxrt/boards/evkbimxrt1050/clock-arm-pll-config.c
diff --git a/bsps/arm/imxrt/nxp/boards/evkbimxrt1050/clock_config.c 
b/bsps/arm/imxrt/boards/evkbimxrt1050/clock_config.c
similarity index 100%
rename from bsps/arm/imxrt/nxp/boards/evkbimxrt1050/clock_config.c
rename to bsps/arm/imxrt/boards/evkbimxrt1050/clock_config.c
diff --git a/bsps/arm/imxrt/start/flash-dcd.c 
b/bsps/arm/imxrt/boards/evkbimxrt1050/flash-dcd.c
similarity index 100%
rename from bsps/arm/imxrt/start/flash-dcd.c
rename to bsps/arm/imxrt/boards/evkbimxrt1050/flash-dcd.c
diff --git a/bsps/arm/imxrt/nxp/boards/evkbimxrt1050/pin_mux.c 
b/bsps/arm/imxrt/boards/evkbimxrt1050/pin_mux.c
similarity index 100%
rename from bsps/arm/imxrt/nxp/boards/evkbimxrt1050/pin_mux.c
rename to bsps/arm/imxrt/boards/evkbimxrt1050/pin_mux.c
diff --git a/spec/build/bsps/arm/imxrt/bspimxrt1052.yml 
b/spec/build/bsps/arm/imxrt/bspimxrt1052.yml
index 348b90bcdb..6c2b3339f9 100644
--- a/spec/build/bsps/arm/imxrt/bspimxrt1052.yml
+++ b/spec/build/bsps/arm/imxrt/bspimxrt1052.yml
@@ -8,10 +8,23 @@ copyrights:
 cppflags: []
 enabled-by: true
 family: imxrt
-includes: []
-install: []
+includes:
+- bsps/arm/imxrt/mcux-sdk/drivers/common
+- bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1052
+- bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1052/drivers
+- bsps/arm/imxrt/mcux-sdk/devices/MIMXRT1052/xip
+install:
+- destination: ${BSP_INCLUDEDIR}/imxrt
+  source:
+  - bsps/arm/imxrt/include/imxrt/imxrt1050.dtsi
+  - bsps/arm/imxrt/include/imxrt/imxrt1050-pinfunc.h
 links:
 - role: build-dependency
   uid: obj-mimxrt1052
-source: []
+source:
+- bsps/arm/imxrt/boards/evkbimxrt1050/clock_config.c
+- bsps/arm/imxrt/boards/evkbimxrt1050/flash-dcd.c
+- bsps/arm/imxrt/boards/evkbimxrt1050/pin_mux.c
+- bsps/arm/imxrt/boards/evkbimxrt1050/clock-arm-pll-config.c
+- bsps/arm/imxrt/dts/imxrt1050-evkb.c
 type: build
diff --git a/spec/build/bsps/arm/imxrt/obj.yml 
b/spec/build/bsps/arm/imxrt/obj.yml
index 96d487dd8b..30ed2fb1d2 100644
--- a/spec/build/bsps/arm/imxrt/obj.yml
+++ b/spec/build/bsps/arm/imxrt/obj.yml
@@ -26,8 +26,6 @@ install:
   - bsps/arm/include/bsp/imx-iomux.h
 - destination: ${BSP_INCLUDEDIR}/imxrt
   source:
-  - bsps/arm/imxrt/include/imxrt/imxrt1050.dtsi
-  - bsps/arm/imxrt/include/imxrt/imxrt1050-pinfunc.h
   - bsps/arm/imxrt/include/imxrt/lpspi.h
   - bsps/arm/imxrt/include/imxrt/memory.h
   - bsps/arm/imxrt/include/imxrt/mpu-config.h
@@ -39,16 +37,11 @@ install:
 links: []
 source:
 - bsps/arm/imxrt/console/console.c
-- bsps/arm/imxrt/dts/imxrt1050-evkb.c
 - bsps/arm/imxrt/i2c/imxrt-lpi2c.c
-- bsps/arm/imxrt/nxp/boards/evkbimxrt1050/clock_config.c
-- bsps/arm/imxrt/nxp/boards/evkbimxrt1050/pin_mux.c
 - bsps/arm/imxrt/spi/imxrt-lpspi.c
 - bsps/arm/imxrt/start/bspstart.c
 - bsps/arm/imxrt/start/bspstarthooks.c
-- bsps/arm/imxrt/start/clock-arm-pll-config.c
 - bsps/arm/imxrt/start/flash-boot-data.c
-- bsps/arm/imxrt/start/flash-dcd.c
 - bsps/arm/imxrt/start/flash-flexspi-config.c
 - bsps/arm/imxrt/start/flash-ivt.c
 - bsps/arm/imxrt/start/imxrt-ffec-init.c
-- 
2.35.3

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


[PATCH rtems 12/12] bsps/imxrt: Make the OCRAM address configurable

2023-05-04 Thread Christian Mauderer
Depending on the chip variant, the OCRAM can have different addresses.
Make it configurable.
---
 spec/build/bsps/arm/imxrt/grp.yml   |  2 ++
 spec/build/bsps/arm/imxrt/linkcmdsmemory.yml|  4 ++--
 spec/build/bsps/arm/imxrt/optmemocramorigin.yml | 17 +
 3 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 spec/build/bsps/arm/imxrt/optmemocramorigin.yml

diff --git a/spec/build/bsps/arm/imxrt/grp.yml 
b/spec/build/bsps/arm/imxrt/grp.yml
index 17b4f48dab..feda472401 100644
--- a/spec/build/bsps/arm/imxrt/grp.yml
+++ b/spec/build/bsps/arm/imxrt/grp.yml
@@ -46,6 +46,8 @@ links:
   uid: optmemnullsz
 - role: build-dependency
   uid: optmemocramnocachesz
+- role: build-dependency
+  uid: optmemocramorigin
 - role: build-dependency
   uid: optmemocramsz
 - role: build-dependency
diff --git a/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml 
b/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml
index 2d8187052f..cf66966b5d 100644
--- a/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml
+++ b/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml
@@ -5,8 +5,8 @@ content: |
 NULL   : ORIGIN = 0x, LENGTH = 
${IMXRT_MEMORY_NULL_SIZE:#010x}
 ITCM   : ORIGIN = ${IMXRT_MEMORY_NULL_SIZE:#010x}, LENGTH = 
${IMXRT_MEMORY_ITCM_SIZE:#010x}
 DTCM   : ORIGIN = 0x2000, LENGTH = 
${IMXRT_MEMORY_DTCM_SIZE:#010x}
-OCRAM  : ORIGIN = 0x2020, LENGTH = 
${IMXRT_MEMORY_OCRAM_SIZE:#010x} - ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}
-OCRAM_NOCACHE  : ORIGIN = 0x2020 + ${IMXRT_MEMORY_OCRAM_SIZE:#010x} - 
${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}, LENGTH = 
${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}
+OCRAM  : ORIGIN = ${IMXRT_MEMORY_OCRAM_ORIGIN}, LENGTH = 
${IMXRT_MEMORY_OCRAM_SIZE:#010x} - ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}
+OCRAM_NOCACHE  : ORIGIN = ${IMXRT_MEMORY_OCRAM_ORIGIN} + 
${IMXRT_MEMORY_OCRAM_SIZE:#010x} - ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}, 
LENGTH = ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}
 PERIPHERAL : ORIGIN = 0x4000, LENGTH = 0x2000
 FLASH_CONFIG   : ORIGIN = ${IMXRT_MEMORY_FLASH_ORIGIN:#010x}, LENGTH = 
${IMXRT_MEMORY_FLASH_CFG_SIZE:#010x}
 FLASH_IVT  : ORIGIN = ${IMXRT_MEMORY_FLASH_ORIGIN:#010x} + 
${IMXRT_MEMORY_FLASH_CFG_SIZE:#010x}, LENGTH = 
${IMXRT_MEMORY_FLASH_IVT_SIZE:#010x}
diff --git a/spec/build/bsps/arm/imxrt/optmemocramorigin.yml 
b/spec/build/bsps/arm/imxrt/optmemocramorigin.yml
new file mode 100644
index 00..c3d08918a7
--- /dev/null
+++ b/spec/build/bsps/arm/imxrt/optmemocramorigin.yml
@@ -0,0 +1,17 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- env-assign: null
+build-type: option
+copyrights:
+- Copyright (C) 2023 embedded brains GmbH (http://www.embedded-brains.de)
+default:
+- enabled-by: true
+  value: 0x2020
+description: |
+  Origin of the OCRAM.
+enabled-by: true
+format: '{:#010x}'
+links: []
+name: IMXRT_MEMORY_OCRAM_ORIGIN
+type: build
-- 
2.35.3

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


Re: [PATCH 2/5] build: Use CSafeLoader if available

2023-05-04 Thread Chris Johns
On 4/5/2023 4:16 pm, Sebastian Huber wrote:
> On 04.05.23 05:35, Chris Johns wrote:
>> On 3/5/2023 7:40 pm, Sebastian Huber wrote:
>>> On 03.05.23 05:30, Chris Johns wrote:
 On 28/4/2023 3:38 pm, Sebastian Huber wrote:
> On 27.04.23 20:27, Gedare Bloom wrote:
>> On Wed, Apr 26, 2023 at 11:46 PM Sebastian Huber
>>   wrote:
>>> On 27.04.23 02:11, Chris Johns wrote:
 On 26/4/2023 6:04 pm, Sebastian Huber wrote:
> The CSafeLoader uses the C libyaml libary to considerably speed up the
> loading of YAML files.
 No from me.
>>> What do you mean with not for me? You have the CSafeLoader available and
>>> it is slow? Do you have some timings before and after the patch set for
>>> a "./waf configure" and "./waf build"? On my systems the configure needs
>>> less than a second with the CSafeLoader and the waf build setup time is
>>> less than 100ms.
>>>
 I do not agree with conditional states of operation in the build system
 that
 depend on packages a host has installed. If speed is an important 
 factor
 all
 users then I suggest you find a means to have it available 
 automatically
 on the
 hosts we support (Linux, FreeBSD, MacOS, Windows MINGW64 and Cygwin.
>>> I am not sure if we should automatically install system Python packages
>>> on user machines.
>>>
>>> The fall back is the Python PyYAML package available through the RTEMS
>>> sources. This is what we use currently. For RTEMS users, this is
>>> acceptable since they are not supposed to touch the YAML files. For
>>> RTEMS maintainers, not having the cache makes working with the build
>>> system more efficient.
>>>
>>> If they system PyYAML package is not installed, then you get now a hint
>>> to install it:
>>>
>>> Setting top to   : 
>>> /home/EB/sebastian_h/src/rtems
>>> Setting out to   :
>>> /home/EB/sebastian_h/src/rtems/build
>>> Regenerate the build specification cache.  Install the PyYAML Python
>>> package to avoid this.  The cache regeneration needs a couple of 
>>> seconds...
>>> Configure board support package (BSP)    : arm/realview_pbx_a9_qemu
>>>
>> I have two questions, which are related to Chris's concern I think.
>> 1. Are the output of PyYAML and C libyaml guaranteed to be consistent?
>
> I trust the PyYAML maintainers that the SafeLoader and CSafeLoader 
> produce the
> same results. With respect to the alternative ItemCache class
> implementation in
> the wscript I am quite confident that this produces the same results. This
> part
> just has to load the item data from the files. The CSafeLoader based 
> ItemCache
> has 53 lines of code.
>
>>
>> 2. Why not make C libyaml part of the RTEMS toolchain?
>>
>> Any dependencies that exist in the build system are (by definition)
>> suitable to be checked/provided by the tool buildset.
>
> Yes, this is an option. If we remove the pickle cache, then we force
> everyone to
> use the libyaml based PyYAML module. Is this really necessary right now?

 If we leave it who would do it? I would like to understand the next 
 question
 before we decide if this is important. The key objective is to have 
 consistent
 performance for every one. If the package is easy to build then we should 
 do it
 when we build the tools and the questions we are having go away.
>>>
>>> The PyYAML package had some security issues in the past. If we ship this
>>> package, who will monitor this package, update it, and write security
>>> advisories?
>>
>> The same way we would handle any security issue. When we become aware we 
>> update
>> what we provide.
> 
> This is a problem from my point of view. Maintenance activities (including
> security related topics) happen by accident in the RTEMS Project. In general,
> each mandatory host tool makes it harder to install RTEMS in certain 
> environments.
> 
>>
>> Is PyYAML a pip package or is it provided by a distro package when using 
>> Linux?
>> My assumption, which may be wrong, is building libyaml (the C part) is all we
>> need to do?
> 
> You can install it through pip, conda, or whatever your host provides as
> packages. I guess you need to build also some Python bindings for libyaml to 
> be
> able to use it.

Using pip with a virtual env is the path I think we should document for users.
With python3 is it easy to do and safe because the packages are contained and
localised to the RTEMS environment. Other solution can be used for those who are
across python and the packages so they can manage themselves.

When I say safe I mean the results are controlled and we are able to provide
support if something is not working as it should.

> For
> most use cases the Python only so

Static analysis

2023-05-04 Thread Sam Price
I was trying to run scan-build on a microblaze build.
However scan-build wasn't seeing any files get built.
I then tried to revert down to the intercept-build command, and it
generated an empty compilation database.
/usr/share/clang/scan-build-py-10/bin/intercept-build --override-compiler  ./waf
Is supposed to dump out a compilation database that scan-build is using.

Sadly its not intercepting the compile commands from waf.

For scan build I think waf should be able to generate the compile
database. Also unsure where to add the waf magic.
def configure(conf):
conf.load('compiler_cxx')
...
conf.load('clang_compilation_database')

And then pass that compile database into scan-build

scan-build -o /path/to/report/directory -p /path/to/compile_commands.json


Somewhere in waf I should be able to add some magic to use cppcheck
but am unsure where to add that logic.

import waftools

def options(opt):
opt.load('cppcheck', tooldir=waftools.location)

def configure(conf):
conf.load('cppcheck')

And then be able to use cppcheck on the build.
waf build --cppcheck
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel