Re: doctest rtems example
Hi Sam, Thanks for the post. The website for the code is: https://github.com/doctest/doctest I have been using this and I can port tests between Linux and RTEMS. I like it because it works and it is a single header. There is no need to build and link libraries. Chris On 16/6/2023 11:07 pm, Sam Price wrote: > /* Tell doctest to not use its own main */ > #define DOCTEST_CONFIG_IMPLEMENT > /* tell doctest to not use sigint that rtems does not have */ > #define DOCTEST_CONFIG_NO_POSIX_SIGNALS > #include "doctest.h" > > /* Setup command line part */ > const char rtems_test_name[] = "DOCTEST UNIT TESTS"; > > static int run_doctest_tests(int argc, char **argv) { > > // Initialize doctest context > doctest::Context context(argc, argv); > > int test_result = context.run(); // run queries, or run tests unless --no-run > > if(context.shouldExit()) // honor query flags and --exit > return test_result; > return 0; > } > > rtems_shell_cmd_t Shell_DOCTEST_Command = { > "doctest", /* name */ > "doctest [doctest options]", /* usage */ > "tests", /* topic */ > run_doctest_tests, /* command */ > NULL, /* alias */ > NULL /* next */ > }; > > /* Inside of your Init add the following prior to starting shell */ > rtems_task Init(rtems_task_argument ignored) > { > > > rtems_shell_add_cmd_struct(&Shell_DOCTEST_Command); > /* Note i made this high priority, some of my tests require priority access. > */ > /* It may be better to use 100, and use the following in your test > rtems_task_priority old_priority; > rtems_task_set_priority(RTEMS_SELF, 0, &old_priority); > ... > rtems_task_set_priority(RTEMS_SELF, old_priority, 0x0); > */ > > rtems_shell_init("shell0", 20 * 1024, 2, "/dev/console", 0, 1, NULL); > ... > } > > TEST_CASE("testing the addition function") { > CHECK((2 + 2) == 4); > CHECK((2 + 2) == 4.0); > } > ___ > 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
Re: BSP .inc files and .cfg files
On 17/6/2023 5:30 am, Joel Sherrill wrote: > On Fri, Jun 16, 2023 at 3:18 AM Philip Kirkpatrick > mailto:p.kirkpatr...@reflexaerospace.com>> > wrote: > > For the RPU patch, I'll add removing this to my next pass at it. > > If there is some transformation on the linked executable needed to download > it, > I hope you document that entire process in the Users Guide. :) I suspect there is a whole book on how that could be done. On the Versal it may be as simple as an SMC call but I would need to check the calls on the Versal [1]. I think it would take a binary image in DDR. I am not sure what is needed on the ZymqMP? Chris [1] https://github.com/kiwichris/rtems-xilinx-xrt/tree/main/rtems ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: bsps/xilinx-zynqmp : Add BSP for RPU
On 17/6/2023 5:14 am, Gedare Bloom wrote: > On Fri, Jun 16, 2023 at 2:17 AM Philip Kirkpatrick > wrote: >> On Fri, Jun 16, 2023 at 7:14 AM Chris Johns wrote: >>> >>> On 15/6/2023 6:16 pm, Philip Kirkpatrick wrote: Thanks for all the good feedback. RE Joel: I'll fix my sloppy formatting that you caught and submit a revised patch. If I'm realistic about my schedule, I probably won't be able to get to it until next week. For xttcps_hw.h, there already is one #ifndef __rtems__ around the #includes, but on review there is another spot where I got lazy and used a #if 0. I'll correct that too. Other than that, the file is unmodified. On the discussion about a shared space, I'll leave that decision up to you. Tell me what you want and I can adjust as needed, or it could be done in a follow-on patch. >>> >>> Should the RPU BSP be located under bsps/arm/xilinx-rpu? >> >> >> I went back and forth on that decision and decided to keep them combined >> since the APU and RPU share a moderate amount of code. However, I can >> definitely see an argument that they are different enough to split. If you >> want it the other way, I can make that change when I address the other items. Thanks, I think this is worth while. > I think we should split it out. Shared code should likely be > refactored to arm/shared depending what that is. Agreed. I am fine with the code moving, leaving the arm/xilinx-zynqmp BSP as is because it may be removed (see below). > I'm not sure that carrying forward a 32-bit arm/xilinx-zynqmp makes > sense now that we have a functional aarch64 port. Splitting the RPU > out will make it easier to make that decision. I agree. I think it is confusing. I also think it should happen before 6. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[libbsd 6-freebsd-12 PATCH v2] rtemsbsd/versal_slcr: Fix Versal GEM clock set
From: Aaron Nyholm --- rtemsbsd/sys/arm64/xilinx/versal_slcr.c | 30 + rtemsbsd/sys/arm64/xilinx/versal_slcr.h | 6 + 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/rtemsbsd/sys/arm64/xilinx/versal_slcr.c b/rtemsbsd/sys/arm64/xilinx/versal_slcr.c index 74ebde91..fea3abab 100644 --- a/rtemsbsd/sys/arm64/xilinx/versal_slcr.c +++ b/rtemsbsd/sys/arm64/xilinx/versal_slcr.c @@ -80,8 +80,9 @@ cgem_set_ref_clk(int unit, int frequency) { struct versal_slcr_softc *sc = versal_slcr_softc_p; int div, last_error = 0; - uint64_t clk_ctrl, pll_ctrl; + uint64_t clk_ctrl, pll_ctrl, to_xpd_ctrl; uint32_t clk_ctrl_val, pll_ctrl_val, pll_freq, pll_reset, pll_bypass; + uint32_t clk_src_sel, to_xpd_ctrl_val, to_xpd_div, to_xpd_freq; if (!sc) return (-1); @@ -126,15 +127,36 @@ cgem_set_ref_clk(int unit, int frequency) } /* Apply divider */ - pll_freq >>= (pll_ctrl_val & VERSAL_SLCR_PLL_CTRL_DIV_MASK) >> VERSAL_SLCR_PLL_CTRL_DIV_SHIFT; + pll_freq >>= (pll_ctrl_val & VERSAL_SLCR_PLL_CTRL_DIV_MASK) >> VERSAL_SLCR_PLL_CTRL_DIV_SHIFT; + + /* Check if routed through {X}PLL_TO_XPD_CLK to GEM{unit}_REF_CLK and adjust */ + clk_src_sel = (clk_ctrl_val & VERSAL_SLCR_GEM_CLK_CTRL_SRCSEL_MASK); + to_xpd_ctrl = 0; + if (clk_src_sel == VERSAL_SLCR_GEM_CLK_CTRL_SRCSEL_P_PLL) { + to_xpd_ctrl = VERSAL_SLCR_PPLL_TO_XPD_CTRL; + } else if (clk_src_sel == VERSAL_SLCR_GEM_CLK_CTRL_SRCSEL_N_PLL) { + to_xpd_ctrl = VERSAL_SLCR_NPLL_TO_XPD_CTRL; + } + + if (to_xpd_ctrl != 0) { + to_xpd_ctrl_val = RD4(sc, to_xpd_ctrl); + to_xpd_div = (to_xpd_ctrl_val & VERSAL_SLCR_XPD_CLK_CTRL_DIVISOR_MASK); + to_xpd_div = to_xpd_div >> VERSAL_SLCR_XPD_CTRL_DIV_SHIFT; + if (to_xpd_div == 0) { + to_xpd_div = 1; + } + to_xpd_freq = pll_freq / to_xpd_div; + } else { + to_xpd_freq = pll_freq; + } /* Find suitable divisor. Linear search, not the fastest method but hey. */ for (div = 1; div <= VERSAL_SLCR_GEM_CLK_CTRL_DIVISOR_MAX; div++) { -int div_freq = pll_freq / div; + int div_freq = to_xpd_freq / div; int error = abs(frequency - div_freq); if (error >= last_error && last_error != 0) { - div--; + div--; break; } last_error = error; diff --git a/rtemsbsd/sys/arm64/xilinx/versal_slcr.h b/rtemsbsd/sys/arm64/xilinx/versal_slcr.h index e1c967ac..121c1e0a 100644 --- a/rtemsbsd/sys/arm64/xilinx/versal_slcr.h +++ b/rtemsbsd/sys/arm64/xilinx/versal_slcr.h @@ -78,6 +78,12 @@ #define VERSAL_SLCR_GEM_CLK_CTRL_SRCSEL_R_PLL(1<<0) #define VERSAL_SLCR_GEM_CLK_CTRL_SRCSEL_N_PLL(3<<0) +#define VERSAL_SLCR_PPLL_TO_XPD_CTRL (VERSAL_SLCR_CRF_OFFSET + 0x100) +#define VERSAL_SLCR_NPLL_TO_XPD_CTRL (VERSAL_SLCR_CRF_OFFSET + 0x104) +#define VERSAL_SLCR_XPD_CLK_CTRL_DIVISOR_MAX 0x3ff +#define VERSAL_SLCR_XPD_CLK_CTRL_DIVISOR_MASK (VERSAL_SLCR_XPD_CLK_CTRL_DIVISOR_MAX<<8) +#define VERSAL_SLCR_XPD_CTRL_DIV_SHIFT 8 + #define VERSAL_DEFAULT_PS_CLK_FREQUENCY #ifdef _KERNEL -- 2.25.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
rtemsbsd/versal_slcr: Fix Versal GEM clock set
Updated formatting. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel