From 9215d7aa7a043c947a942fc3759f120f0c0e7dd3 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 4 Jan 2023 22:33:52 +0000 Subject: [PATCH 1/4] Fix #375, Separate network logic in pc-rtems to support generic targets --- fsw/pc-rtems/make/build_options.cmake | 2 +- fsw/pc-rtems/src/cfe_psp_start.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fsw/pc-rtems/make/build_options.cmake b/fsw/pc-rtems/make/build_options.cmake index 919675a6..8bd396df 100644 --- a/fsw/pc-rtems/make/build_options.cmake +++ b/fsw/pc-rtems/make/build_options.cmake @@ -7,7 +7,7 @@ # This indicates where to install target binaries created during the build # Note - this should be phased out in favor of the staging dir from OSAL BSP -set(INSTALL_SUBDIR "eeprom") +set(INSTALL_SUBDIR "nonvol") # Some upper-level code may be gated on _RTEMS_OS_ being defined # This is for compatibility with older build scripts which defined this symbol, diff --git a/fsw/pc-rtems/src/cfe_psp_start.c b/fsw/pc-rtems/src/cfe_psp_start.c index 5d03d17f..aee22890 100644 --- a/fsw/pc-rtems/src/cfe_psp_start.c +++ b/fsw/pc-rtems/src/cfe_psp_start.c @@ -33,8 +33,9 @@ #include #include #include -#include -#include +/* TODO Only needed for network setup, move? */ +//#include +//#include extern int rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching); @@ -63,6 +64,8 @@ extern int rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching) rtems_id RtemsTimerId; +/* TODO in pc but not in generic... might be the only unique stuff? */ +#if 0 static unsigned char ethernet_address[6] = {0x00, 0x04, 0x9F, 0x00, 0x27, 0x61}; static char net_name_str[] = "fxp1"; static char ip_addr_str[] = "10.0.2.17"; @@ -78,9 +81,11 @@ static struct rtems_bsdnet_ifconfig netdriver_config = { /* more options can follow */ }; + struct rtems_bsdnet_config rtems_bsdnet_config = { .ifconfig = &netdriver_config, .bootp = rtems_bsdnet_do_dhcp_failsafe, /* fill if DHCP is used*/ }; +#endif /* ** 1 HZ Timer "ISR" @@ -200,7 +205,9 @@ void CFE_PSP_Main(void) /* ** Set up the virtual FS mapping for the "/cf" directory */ - Status = OS_FileSysAddFixedMap(&fs_id, "/mnt/eeprom", "/cf"); + /* TODO maybe make this into a config... or just switch to nonvol */ + // Status = OS_FileSysAddFixedMap(&fs_id, "/mnt/eeprom", "/cf"); + Status = OS_FileSysAddFixedMap(&fs_id, "/nonvol", "/cf"); if (Status != OS_SUCCESS) { /* Print for informational purposes -- From c2190f162b138df7f790ff84ca654751373f59f8 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 5 Jan 2023 14:47:17 +0000 Subject: [PATCH 2/4] Fix #375, removed network setup call (will squash later) --- fsw/pc-rtems/src/cfe_psp_start.c | 3 +++ unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-start.c | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fsw/pc-rtems/src/cfe_psp_start.c b/fsw/pc-rtems/src/cfe_psp_start.c index aee22890..618070d6 100644 --- a/fsw/pc-rtems/src/cfe_psp_start.c +++ b/fsw/pc-rtems/src/cfe_psp_start.c @@ -117,6 +117,8 @@ int timer_count = 0; */ int CFE_PSP_Setup(void) { + /* TODO this hangs the dev board when using rki2 since network is already set up */ +#if 0 rtems_status_code status; /* @@ -128,6 +130,7 @@ int CFE_PSP_Setup(void) { printf("Network init not successful: %s / %s (continuing)\n", rtems_status_text(status), strerror(errno)); } +#endif return RTEMS_SUCCESSFUL; } diff --git a/unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-start.c b/unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-start.c index ffa95577..567475a9 100644 --- a/unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-start.c +++ b/unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-start.c @@ -43,7 +43,6 @@ void Test_CFE_PSP_Setup(void) /* Test for printf due to error from rtems_bsdnet_initialize_network (function still returns RTEMS_SUCCESSFUL) */ UT_SetDefaultReturnValue(UT_KEY(PCS_rtems_bsdnet_initialize_network), -1); UtAssert_INT32_EQ(CFE_PSP_Setup(), PCS_RTEMS_SUCCESSFUL); - UtAssert_STUB_COUNT(PCS_printf, 1); } void Test_OS_Application_Startup(void) @@ -82,4 +81,4 @@ void Test_CFE_PSP_Main(void) * failure of OS_FileSysAddFixedMap, and 1 from CFE_PSP_InitProcessorReservedMemory */ UtAssert_STUB_COUNT(OS_printf, 5); UT_ResetState(UT_KEY(OS_printf)); /* Reset so cleared for future tests */ -} \ No newline at end of file +} From 35cfcefd4b8d134436073d3c49b1634d883b56f0 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez Pedraza" Date: Thu, 18 Jan 2024 00:37:38 +0000 Subject: [PATCH 3/4] Enable networking when using TARFS --- fsw/pc-rtems/src/cfe_psp_start.c | 54 ++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/fsw/pc-rtems/src/cfe_psp_start.c b/fsw/pc-rtems/src/cfe_psp_start.c index 618070d6..f60db23f 100644 --- a/fsw/pc-rtems/src/cfe_psp_start.c +++ b/fsw/pc-rtems/src/cfe_psp_start.c @@ -87,6 +87,46 @@ struct rtems_bsdnet_config rtems_bsdnet_config = { }; #endif +#if RTEMS_INCLUDE_TARFS /* TODO Is there a better networking-related define we can use here? */ + +#include + +/* TODO Remove these pragmas and fix warnings generated */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" +#pragma GCC diagnostic ignored "-Woverflow" + +/* + * Network configuration + */ + +/* Set default IP and MAC if not defined */ +#ifndef CONFIG_ETH_IP +#define CONFIG_ETH_IP "192.168.1.67" +#endif +#ifndef CONFIG_ETH_MAC +#define CONFIG_ETH_MAC {0x00, 0x80, 0x7F, 0x22, 0x61, 0x7A} +#endif + +/* Table used by network interfaces that register themselves using the + * network_interface_add routine. From this table the IP address, netmask + * and Ethernet MAC address of an interface is taken. + * + * The network_interface_add routine puts the interface into the + * rtems_bsnet_config.ifconfig list. + * + * Set IP Address and Netmask to NULL to select BOOTP. + */ +struct ethernet_config interface_configs[] = +{ + { CONFIG_ETH_IP, "255.255.255.0", CONFIG_ETH_MAC} +}; +#define INTERFACE_CONFIG_CNT (sizeof(interface_configs)/sizeof(struct ethernet_config) - 1) + +#pragma GCC diagnostic pop + +#endif + /* ** 1 HZ Timer "ISR" */ @@ -117,8 +157,10 @@ int timer_count = 0; */ int CFE_PSP_Setup(void) { - /* TODO this hangs the dev board when using rki2 since network is already set up */ -#if 0 + +/* Only initialize the network if not using the rki2 */ +#if RTEMS_INCLUDE_TARFS /* TODO Is there a better networking-related define? */ + rtems_status_code status; /* @@ -130,6 +172,14 @@ int CFE_PSP_Setup(void) { printf("Network init not successful: %s / %s (continuing)\n", rtems_status_text(status), strerror(errno)); } + else + { + printf("Network initialized\n\n"); + } + rtems_bsdnet_show_inet_routes(); + printf("\n"); + rtems_bsdnet_show_if_stats(); + printf("\n"); #endif return RTEMS_SUCCESSFUL; From 22fe1811f61d0619ddacd642d59d20e7bac67c62 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Mon, 26 Feb 2024 14:23:09 +0000 Subject: [PATCH 4/4] Fix #375, Progress on pc-rtems generic target support --- fsw/pc-rtems/src/cfe_psp_start.c | 21 +++++++++++++++++ unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h | 2 ++ .../ut-stubs/override_inc/drvmgr/drvmgr.h | 23 +++++++++++++++++++ .../override_inc/drvmgr/drvmgr_confdefs.h | 23 +++++++++++++++++++ .../ut-stubs/override_inc/rtems/confdefs.h | 23 +++++++++++++++++++ .../override_inc/rtems/rtems_bsdnet.h | 2 ++ .../ut-stubs/src/rtems-bsdnet-stubs.c | 12 +++++++++- 7 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr_confdefs.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/rtems/confdefs.h diff --git a/fsw/pc-rtems/src/cfe_psp_start.c b/fsw/pc-rtems/src/cfe_psp_start.c index f60db23f..1444b252 100644 --- a/fsw/pc-rtems/src/cfe_psp_start.c +++ b/fsw/pc-rtems/src/cfe_psp_start.c @@ -99,6 +99,27 @@ struct rtems_bsdnet_config rtems_bsdnet_config = { /* * Network configuration */ +/* TODO move to a separate file */ +#include +#include + +#include "bsp_rtems_cfg.h" + +#include + +/* Configure Driver manager */ +#if defined(RTEMS_DRVMGR_STARTUP) && defined(LEON3) /* if --drvmgr was given to configure */ + /* Add Timer and UART Driver for this example */ + #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART + #endif +#endif +#define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRETH /* TODO make dependent on OSAL NETWORK config */ + +#include /* Set default IP and MAC if not defined */ #ifndef CONFIG_ETH_IP diff --git a/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h b/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h index 4dd65ea3..0b4866dd 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h @@ -27,5 +27,7 @@ extern int PCS_rtems_fxp_attach(struct PCS_rtems_bsdnet_ifconfig *, int) extern void PCS_rtems_bsdnet_do_dhcp_failsafe(void); extern int PCS_rtems_bsdnet_initialize_network(void); extern const char *PCS_rtems_status_text(PCS_rtems_status_code); +extern void PCS_rtems_bsdnet_show_inet_routes(void); +extern void PCS_rtems_bsdnet_show_if_stats(void); #endif diff --git a/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr.h b/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr.h new file mode 100644 index 00000000..6372a4fb --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr.h @@ -0,0 +1,23 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* PSP coverage stub replacement for drvmgr.h */ +#ifndef OVERRIDE_DRVMGR_H +#define OVERRIDE_DRVMGR_H + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr_confdefs.h b/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr_confdefs.h new file mode 100644 index 00000000..a834df81 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr_confdefs.h @@ -0,0 +1,23 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* PSP coverage stub replacement for drvmgr_confdefs.h */ +#ifndef OVERRIDE_DRVMGR_CONFDEFS_H +#define OVERRIDE_DRVMGR_CONFDEFS_H + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/rtems/confdefs.h b/unit-test-coverage/ut-stubs/override_inc/rtems/confdefs.h new file mode 100644 index 00000000..03f3ef75 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/rtems/confdefs.h @@ -0,0 +1,23 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* PSP coverage stub replacement for confdefs.h */ +#ifndef OVERRIDE_CONFDEFS_H +#define OVERRIDE_CONFDEFS_H + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/rtems/rtems_bsdnet.h b/unit-test-coverage/ut-stubs/override_inc/rtems/rtems_bsdnet.h index c0dda61b..07ec4fb2 100644 --- a/unit-test-coverage/ut-stubs/override_inc/rtems/rtems_bsdnet.h +++ b/unit-test-coverage/ut-stubs/override_inc/rtems/rtems_bsdnet.h @@ -26,5 +26,7 @@ #define rtems_bsdnet_do_dhcp_failsafe PCS_rtems_bsdnet_do_dhcp_failsafe #define rtems_bsdnet_initialize_network PCS_rtems_bsdnet_initialize_network #define rtems_fxp_attach PCS_rtems_fxp_attach +#define rtems_bsdnet_show_inet_routes PCS_rtems_bsdnet_show_inet_routes +#define rtems_bsdnet_show_if_stats PCS_rtems_bsdnet_show_if_stats #endif diff --git a/unit-test-coverage/ut-stubs/src/rtems-bsdnet-stubs.c b/unit-test-coverage/ut-stubs/src/rtems-bsdnet-stubs.c index 57499c4f..59104636 100644 --- a/unit-test-coverage/ut-stubs/src/rtems-bsdnet-stubs.c +++ b/unit-test-coverage/ut-stubs/src/rtems-bsdnet-stubs.c @@ -50,4 +50,14 @@ int PCS_rtems_bsdnet_initialize_network(void) int PCS_rtems_fxp_attach(struct PCS_rtems_bsdnet_ifconfig *config, int attaching) { return UT_DEFAULT_IMPL(PCS_rtems_fxp_attach); -} \ No newline at end of file +} + +void PCS_rtems_bsdnet_show_inet_routes(void) +{ + UT_DEFAULT_IMPL(PCS_rtems_bsdnet_show_inet_routes); +} + +void PCS_rtems_bsdnet_show_if_stats(void) +{ + UT_DEFAULT_IMPL(PCS_rtems_bsdnet_show_if_stats); +}