diff --git a/CHANGELOG.md b/CHANGELOG.md index e077ac88..96f9c5f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,7 +47,10 @@ will consitute of a breaking change warranting a new major release: - Add parameter interface for core controller - Allow setting the preferred SD card via the new parameter interface of the core controller with domain ID 0 and unque ID 0. - +- Added action commands to reset the PDEC. Also added autonomous reset handling for the PDEC, + because there is no way so send TCs with a faulty PDEC. +- Added `I2C_REBOOT` and `PDEC_REBOOT` events for EIVE system component to ensure ground gets + informed. # [v1.44.1] 2023-04-12 diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index c4b537e8..f09c8c6d 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 285 translations. + * @brief Auto-generated event translation file. Contains 289 translations. * @details - * Generated on: 2023-04-07 17:42:57 + * Generated on: 2023-04-14 20:05:50 */ #include "translateEvents.h" @@ -160,8 +160,11 @@ const char *LOST_BIT_LOCK_PDEC_STRING = "LOST_BIT_LOCK_PDEC"; const char *TOO_MANY_IRQS_STRING = "TOO_MANY_IRQS"; const char *POLL_SYSCALL_ERROR_PDEC_STRING = "POLL_SYSCALL_ERROR_PDEC"; const char *WRITE_SYSCALL_ERROR_PDEC_STRING = "WRITE_SYSCALL_ERROR_PDEC"; +const char *PDEC_TRYING_RESET_WITH_INIT_STRING = "PDEC_TRYING_RESET_WITH_INIT"; +const char *PDEC_TRYING_RESET_NO_INIT_STRING = "PDEC_TRYING_RESET_NO_INIT"; const char *PDEC_RESET_FAILED_STRING = "PDEC_RESET_FAILED"; const char *OPEN_IRQ_FILE_FAILED_STRING = "OPEN_IRQ_FILE_FAILED"; +const char *PDEC_INIT_FAILED_STRING = "PDEC_INIT_FAILED"; const char *IMAGE_UPLOAD_FAILED_STRING = "IMAGE_UPLOAD_FAILED"; const char *IMAGE_DOWNLOAD_FAILED_STRING = "IMAGE_DOWNLOAD_FAILED"; const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; @@ -268,6 +271,7 @@ const char *REBOOT_COUNTER_STRING = "REBOOT_COUNTER"; const char *INDIVIDUAL_BOOT_COUNTS_STRING = "INDIVIDUAL_BOOT_COUNTS"; const char *TRYING_I2C_RECOVERY_STRING = "TRYING_I2C_RECOVERY"; const char *I2C_REBOOT_STRING = "I2C_REBOOT"; +const char *PDEC_REBOOT_STRING = "PDEC_REBOOT"; const char *NO_VALID_SENSOR_TEMPERATURE_STRING = "NO_VALID_SENSOR_TEMPERATURE"; const char *NO_HEALTHY_HEATER_AVAILABLE_STRING = "NO_HEALTHY_HEATER_AVAILABLE"; const char *SYRLINKS_OVERHEATING_STRING = "SYRLINKS_OVERHEATING"; @@ -604,9 +608,15 @@ const char *translateEvents(Event event) { case (12409): return WRITE_SYSCALL_ERROR_PDEC_STRING; case (12410): - return PDEC_RESET_FAILED_STRING; + return PDEC_TRYING_RESET_WITH_INIT_STRING; case (12411): + return PDEC_TRYING_RESET_NO_INIT_STRING; + case (12412): + return PDEC_RESET_FAILED_STRING; + case (12413): return OPEN_IRQ_FILE_FAILED_STRING; + case (12414): + return PDEC_INIT_FAILED_STRING; case (12500): return IMAGE_UPLOAD_FAILED_STRING; case (12501): @@ -819,6 +829,8 @@ const char *translateEvents(Event event) { return TRYING_I2C_RECOVERY_STRING; case (14011): return I2C_REBOOT_STRING; + case (14012): + return PDEC_REBOOT_STRING; case (14100): return NO_VALID_SENSOR_TEMPERATURE_STRING; case (14101): diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index 148ac0b3..30ff46f9 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 171 translations. - * Generated on: 2023-04-07 17:42:57 + * Generated on: 2023-04-14 20:05:50 */ #include "translateObjects.h" diff --git a/generators/bsp_hosted_events.csv b/generators/bsp_hosted_events.csv index af15edff..332a38a3 100644 --- a/generators/bsp_hosted_events.csv +++ b/generators/bsp_hosted_events.csv @@ -145,17 +145,20 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 12300;0x300c;SEND_MRAM_DUMP_FAILED;LOW;Failed to send mram dump command to supervisor handler P1: Return value of commandAction function P2: Start address of MRAM to dump with this command;linux/payload/PlocMemoryDumper.h 12301;0x300d;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;linux/payload/PlocMemoryDumper.h 12302;0x300e;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;linux/payload/PlocMemoryDumper.h -12401;0x3071;INVALID_TC_FRAME;HIGH;No description;linux/ipcore/PdecHandler.h -12402;0x3072;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;linux/ipcore/PdecHandler.h -12403;0x3073;CARRIER_LOCK;INFO;Carrier lock detected;linux/ipcore/PdecHandler.h -12404;0x3074;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);linux/ipcore/PdecHandler.h -12405;0x3075;LOST_CARRIER_LOCK_PDEC;INFO;Lost carrier lock;linux/ipcore/PdecHandler.h -12406;0x3076;LOST_BIT_LOCK_PDEC;INFO;Lost bit lock;linux/ipcore/PdecHandler.h -12407;0x3077;TOO_MANY_IRQS;MEDIUM;Too many IRQs over the time window of one second. P1: Allowed TCs;linux/ipcore/PdecHandler.h -12408;0x3078;POLL_SYSCALL_ERROR_PDEC;MEDIUM;No description;linux/ipcore/PdecHandler.h -12409;0x3079;WRITE_SYSCALL_ERROR_PDEC;HIGH;No description;linux/ipcore/PdecHandler.h -12410;0x307a;PDEC_RESET_FAILED;HIGH;Failed to pull PDEC reset to low;linux/ipcore/PdecHandler.h -12411;0x307b;OPEN_IRQ_FILE_FAILED;HIGH;Failed to open the IRQ uio file;linux/ipcore/PdecHandler.h +12401;0x3071;INVALID_TC_FRAME;HIGH;No description;linux/ipcore/pdec.h +12402;0x3072;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;linux/ipcore/pdec.h +12403;0x3073;CARRIER_LOCK;INFO;Carrier lock detected;linux/ipcore/pdec.h +12404;0x3074;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);linux/ipcore/pdec.h +12405;0x3075;LOST_CARRIER_LOCK_PDEC;INFO;Lost carrier lock;linux/ipcore/pdec.h +12406;0x3076;LOST_BIT_LOCK_PDEC;INFO;Lost bit lock;linux/ipcore/pdec.h +12407;0x3077;TOO_MANY_IRQS;MEDIUM;Too many IRQs over the time window of one second. P1: Allowed TCs;linux/ipcore/pdec.h +12408;0x3078;POLL_SYSCALL_ERROR_PDEC;MEDIUM;No description;linux/ipcore/pdec.h +12409;0x3079;WRITE_SYSCALL_ERROR_PDEC;HIGH;No description;linux/ipcore/pdec.h +12410;0x307a;PDEC_TRYING_RESET_WITH_INIT;LOW;Trying a PDEC reset with complete re-initialization;linux/ipcore/pdec.h +12411;0x307b;PDEC_TRYING_RESET_NO_INIT;LOW;Trying a PDEC reset without re-initialization.;linux/ipcore/pdec.h +12412;0x307c;PDEC_RESET_FAILED;HIGH;Failed to pull PDEC reset to low;linux/ipcore/pdec.h +12413;0x307d;OPEN_IRQ_FILE_FAILED;HIGH;Failed to open the IRQ uio file;linux/ipcore/pdec.h +12414;0x307e;PDEC_INIT_FAILED;HIGH;PDEC initialization failed. This might also be due to the persistent confiuration never becoming available, for example due to SD card issues.;linux/ipcore/pdec.h 12500;0x30d4;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;linux/acs/StrComHandler.h 12501;0x30d5;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;linux/acs/StrComHandler.h 12502;0x30d6;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successfulop;linux/acs/StrComHandler.h @@ -208,7 +211,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 12901;0x3265;NOT_ENOUGH_DEVICES_DUAL_MODE;HIGH;No description;mission/system/acs/SusAssembly.h 12902;0x3266;POWER_STATE_MACHINE_TIMEOUT;MEDIUM;No description;mission/system/acs/SusAssembly.h 12903;0x3267;SIDE_SWITCH_TRANSITION_NOT_ALLOWED;LOW;Not implemented, would increase already high complexity. Operator should instead command the assembly off first and then command the assembly on into the desired mode/submode combination;mission/system/acs/SusAssembly.h -13000;0x32c8;CHILDREN_LOST_MODE;MEDIUM;No description;mission/system/objects/TcsBoardAssembly.h +13000;0x32c8;CHILDREN_LOST_MODE;MEDIUM;No description;mission/system/tcs/TcsBoardAssembly.h 13100;0x332c;GPS_FIX_CHANGE;INFO;Fix has changed. P1: Old fix. P2: New fix 0: Not seen, 1: No Fix, 2: 2D-Fix, 3: 3D-Fix;mission/acs/archive/GPSDefinitions.h 13101;0x332d;CANT_GET_FIX;LOW;Could not get fix in maximum allowed time. P1: Maximum allowed time to get a fix after the GPS was switched on.;mission/acs/archive/GPSDefinitions.h 13200;0x3390;P60_BOOT_COUNT;INFO;P60 boot count is broadcasted once at SW startup. P1: Boot count;mission/power/P60DockHandler.h @@ -262,6 +265,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 14008;0x36b8;INDIVIDUAL_BOOT_COUNTS;INFO;Get the boot count of the individual images. P1: First 16 bits boot count of image 0 0, last 16 bits boot count of image 0 1. P2: First 16 bits boot count of image 1 0, last 16 bits boot count of image 1 1.;mission/sysDefs.h 14010;0x36ba;TRYING_I2C_RECOVERY;MEDIUM;I2C is unavailable. Trying recovery of I2C bus by power cycling all I2C devices.;mission/sysDefs.h 14011;0x36bb;I2C_REBOOT;MEDIUM;I2C is unavailable. Recovery did not work, performing full reboot.;mission/sysDefs.h +14012;0x36bc;PDEC_REBOOT;MEDIUM;PDEC recovery through reset was not possible, performing full reboot.;mission/sysDefs.h 14100;0x3714;NO_VALID_SENSOR_TEMPERATURE;MEDIUM;No description;mission/controller/tcsDefs.h 14101;0x3715;NO_HEALTHY_HEATER_AVAILABLE;MEDIUM;No description;mission/controller/tcsDefs.h 14102;0x3716;SYRLINKS_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index af15edff..332a38a3 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -145,17 +145,20 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 12300;0x300c;SEND_MRAM_DUMP_FAILED;LOW;Failed to send mram dump command to supervisor handler P1: Return value of commandAction function P2: Start address of MRAM to dump with this command;linux/payload/PlocMemoryDumper.h 12301;0x300d;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;linux/payload/PlocMemoryDumper.h 12302;0x300e;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;linux/payload/PlocMemoryDumper.h -12401;0x3071;INVALID_TC_FRAME;HIGH;No description;linux/ipcore/PdecHandler.h -12402;0x3072;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;linux/ipcore/PdecHandler.h -12403;0x3073;CARRIER_LOCK;INFO;Carrier lock detected;linux/ipcore/PdecHandler.h -12404;0x3074;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);linux/ipcore/PdecHandler.h -12405;0x3075;LOST_CARRIER_LOCK_PDEC;INFO;Lost carrier lock;linux/ipcore/PdecHandler.h -12406;0x3076;LOST_BIT_LOCK_PDEC;INFO;Lost bit lock;linux/ipcore/PdecHandler.h -12407;0x3077;TOO_MANY_IRQS;MEDIUM;Too many IRQs over the time window of one second. P1: Allowed TCs;linux/ipcore/PdecHandler.h -12408;0x3078;POLL_SYSCALL_ERROR_PDEC;MEDIUM;No description;linux/ipcore/PdecHandler.h -12409;0x3079;WRITE_SYSCALL_ERROR_PDEC;HIGH;No description;linux/ipcore/PdecHandler.h -12410;0x307a;PDEC_RESET_FAILED;HIGH;Failed to pull PDEC reset to low;linux/ipcore/PdecHandler.h -12411;0x307b;OPEN_IRQ_FILE_FAILED;HIGH;Failed to open the IRQ uio file;linux/ipcore/PdecHandler.h +12401;0x3071;INVALID_TC_FRAME;HIGH;No description;linux/ipcore/pdec.h +12402;0x3072;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;linux/ipcore/pdec.h +12403;0x3073;CARRIER_LOCK;INFO;Carrier lock detected;linux/ipcore/pdec.h +12404;0x3074;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);linux/ipcore/pdec.h +12405;0x3075;LOST_CARRIER_LOCK_PDEC;INFO;Lost carrier lock;linux/ipcore/pdec.h +12406;0x3076;LOST_BIT_LOCK_PDEC;INFO;Lost bit lock;linux/ipcore/pdec.h +12407;0x3077;TOO_MANY_IRQS;MEDIUM;Too many IRQs over the time window of one second. P1: Allowed TCs;linux/ipcore/pdec.h +12408;0x3078;POLL_SYSCALL_ERROR_PDEC;MEDIUM;No description;linux/ipcore/pdec.h +12409;0x3079;WRITE_SYSCALL_ERROR_PDEC;HIGH;No description;linux/ipcore/pdec.h +12410;0x307a;PDEC_TRYING_RESET_WITH_INIT;LOW;Trying a PDEC reset with complete re-initialization;linux/ipcore/pdec.h +12411;0x307b;PDEC_TRYING_RESET_NO_INIT;LOW;Trying a PDEC reset without re-initialization.;linux/ipcore/pdec.h +12412;0x307c;PDEC_RESET_FAILED;HIGH;Failed to pull PDEC reset to low;linux/ipcore/pdec.h +12413;0x307d;OPEN_IRQ_FILE_FAILED;HIGH;Failed to open the IRQ uio file;linux/ipcore/pdec.h +12414;0x307e;PDEC_INIT_FAILED;HIGH;PDEC initialization failed. This might also be due to the persistent confiuration never becoming available, for example due to SD card issues.;linux/ipcore/pdec.h 12500;0x30d4;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;linux/acs/StrComHandler.h 12501;0x30d5;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;linux/acs/StrComHandler.h 12502;0x30d6;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successfulop;linux/acs/StrComHandler.h @@ -208,7 +211,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 12901;0x3265;NOT_ENOUGH_DEVICES_DUAL_MODE;HIGH;No description;mission/system/acs/SusAssembly.h 12902;0x3266;POWER_STATE_MACHINE_TIMEOUT;MEDIUM;No description;mission/system/acs/SusAssembly.h 12903;0x3267;SIDE_SWITCH_TRANSITION_NOT_ALLOWED;LOW;Not implemented, would increase already high complexity. Operator should instead command the assembly off first and then command the assembly on into the desired mode/submode combination;mission/system/acs/SusAssembly.h -13000;0x32c8;CHILDREN_LOST_MODE;MEDIUM;No description;mission/system/objects/TcsBoardAssembly.h +13000;0x32c8;CHILDREN_LOST_MODE;MEDIUM;No description;mission/system/tcs/TcsBoardAssembly.h 13100;0x332c;GPS_FIX_CHANGE;INFO;Fix has changed. P1: Old fix. P2: New fix 0: Not seen, 1: No Fix, 2: 2D-Fix, 3: 3D-Fix;mission/acs/archive/GPSDefinitions.h 13101;0x332d;CANT_GET_FIX;LOW;Could not get fix in maximum allowed time. P1: Maximum allowed time to get a fix after the GPS was switched on.;mission/acs/archive/GPSDefinitions.h 13200;0x3390;P60_BOOT_COUNT;INFO;P60 boot count is broadcasted once at SW startup. P1: Boot count;mission/power/P60DockHandler.h @@ -262,6 +265,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 14008;0x36b8;INDIVIDUAL_BOOT_COUNTS;INFO;Get the boot count of the individual images. P1: First 16 bits boot count of image 0 0, last 16 bits boot count of image 0 1. P2: First 16 bits boot count of image 1 0, last 16 bits boot count of image 1 1.;mission/sysDefs.h 14010;0x36ba;TRYING_I2C_RECOVERY;MEDIUM;I2C is unavailable. Trying recovery of I2C bus by power cycling all I2C devices.;mission/sysDefs.h 14011;0x36bb;I2C_REBOOT;MEDIUM;I2C is unavailable. Recovery did not work, performing full reboot.;mission/sysDefs.h +14012;0x36bc;PDEC_REBOOT;MEDIUM;PDEC recovery through reset was not possible, performing full reboot.;mission/sysDefs.h 14100;0x3714;NO_VALID_SENSOR_TEMPERATURE;MEDIUM;No description;mission/controller/tcsDefs.h 14101;0x3715;NO_HEALTHY_HEATER_AVAILABLE;MEDIUM;No description;mission/controller/tcsDefs.h 14102;0x3716;SYRLINKS_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h diff --git a/generators/bsp_q7s_returnvalues.csv b/generators/bsp_q7s_returnvalues.csv index fcb4a5ee..e450cf02 100644 --- a/generators/bsp_q7s_returnvalues.csv +++ b/generators/bsp_q7s_returnvalues.csv @@ -517,21 +517,21 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x5d05;GOMS_UnknownReplyId;No description;5;GOM_SPACE_HANDLER;mission/power/GomspaceDeviceHandler.h 0x5ea0;PLMEMDUMP_MramAddressTooHigh;The capacity of the MRAM amounts to 512 kB. Thus the maximum address must not be higher than 0x7d000.;160;PLOC_MEMORY_DUMPER;linux/payload/PlocMemoryDumper.h 0x5ea1;PLMEMDUMP_MramInvalidAddressCombination;The specified end address is lower than the start address;161;PLOC_MEMORY_DUMPER;linux/payload/PlocMemoryDumper.h -0x5fa0;PDEC_AbandonedCltuRetval;No description;160;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fa1;PDEC_FrameDirtyRetval;No description;161;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fa2;PDEC_FrameIllegalMultipleReasons;No description;162;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fa3;PDEC_AdDiscardedLockoutRetval;No description;163;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fa4;PDEC_AdDiscardedWaitRetval;No description;164;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fa5;PDEC_AdDiscardedNsVs;No description;165;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fa6;PDEC_NoReportRetval;No description;166;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fa7;PDEC_ErrorVersionNumberRetval;No description;167;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fa8;PDEC_IllegalCombinationRetval;No description;168;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fa9;PDEC_InvalidScIdRetval;No description;169;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5faa;PDEC_InvalidVcIdMsbRetval;No description;170;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fab;PDEC_InvalidVcIdLsbRetval;No description;171;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fac;PDEC_NsNotZeroRetval;No description;172;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fae;PDEC_InvalidBcCc;No description;174;PDEC_HANDLER;linux/ipcore/PdecHandler.h -0x5fb0;PDEC_CommandNotImplemented;Received action message with unknown action id;176;PDEC_HANDLER;linux/ipcore/PdecHandler.h +0x5fa0;PDEC_AbandonedCltuRetval;No description;160;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fa1;PDEC_FrameDirtyRetval;No description;161;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fa2;PDEC_FrameIllegalMultipleReasons;No description;162;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fa3;PDEC_AdDiscardedLockoutRetval;No description;163;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fa4;PDEC_AdDiscardedWaitRetval;No description;164;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fa5;PDEC_AdDiscardedNsVs;No description;165;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fa6;PDEC_NoReportRetval;No description;166;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fa7;PDEC_ErrorVersionNumberRetval;No description;167;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fa8;PDEC_IllegalCombinationRetval;No description;168;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fa9;PDEC_InvalidScIdRetval;No description;169;PDEC_HANDLER;linux/ipcore/pdec.h +0x5faa;PDEC_InvalidVcIdMsbRetval;No description;170;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fab;PDEC_InvalidVcIdLsbRetval;No description;171;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fac;PDEC_NsNotZeroRetval;No description;172;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fae;PDEC_InvalidBcCc;No description;174;PDEC_HANDLER;linux/ipcore/pdec.h +0x5fb0;PDEC_CommandNotImplemented;Received action message with unknown action id;176;PDEC_HANDLER;linux/ipcore/pdec.h 0x60a0;CCSDS_CommandNotImplemented;Received action message with unknown action id;160;CCSDS_HANDLER;mission/com/CcsdsIpCoreHandler.h 0x61a0;RS_RateNotSupported;The commanded rate is not supported by the current FPGA design;160;RATE_SETTER;linux/ipcore/PtmeConfig.h 0x61a1;RS_BadBitRate;Bad bitrate has been commanded (e.g. 0);161;RATE_SETTER;linux/ipcore/PtmeConfig.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index c4b537e8..f09c8c6d 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 285 translations. + * @brief Auto-generated event translation file. Contains 289 translations. * @details - * Generated on: 2023-04-07 17:42:57 + * Generated on: 2023-04-14 20:05:50 */ #include "translateEvents.h" @@ -160,8 +160,11 @@ const char *LOST_BIT_LOCK_PDEC_STRING = "LOST_BIT_LOCK_PDEC"; const char *TOO_MANY_IRQS_STRING = "TOO_MANY_IRQS"; const char *POLL_SYSCALL_ERROR_PDEC_STRING = "POLL_SYSCALL_ERROR_PDEC"; const char *WRITE_SYSCALL_ERROR_PDEC_STRING = "WRITE_SYSCALL_ERROR_PDEC"; +const char *PDEC_TRYING_RESET_WITH_INIT_STRING = "PDEC_TRYING_RESET_WITH_INIT"; +const char *PDEC_TRYING_RESET_NO_INIT_STRING = "PDEC_TRYING_RESET_NO_INIT"; const char *PDEC_RESET_FAILED_STRING = "PDEC_RESET_FAILED"; const char *OPEN_IRQ_FILE_FAILED_STRING = "OPEN_IRQ_FILE_FAILED"; +const char *PDEC_INIT_FAILED_STRING = "PDEC_INIT_FAILED"; const char *IMAGE_UPLOAD_FAILED_STRING = "IMAGE_UPLOAD_FAILED"; const char *IMAGE_DOWNLOAD_FAILED_STRING = "IMAGE_DOWNLOAD_FAILED"; const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; @@ -268,6 +271,7 @@ const char *REBOOT_COUNTER_STRING = "REBOOT_COUNTER"; const char *INDIVIDUAL_BOOT_COUNTS_STRING = "INDIVIDUAL_BOOT_COUNTS"; const char *TRYING_I2C_RECOVERY_STRING = "TRYING_I2C_RECOVERY"; const char *I2C_REBOOT_STRING = "I2C_REBOOT"; +const char *PDEC_REBOOT_STRING = "PDEC_REBOOT"; const char *NO_VALID_SENSOR_TEMPERATURE_STRING = "NO_VALID_SENSOR_TEMPERATURE"; const char *NO_HEALTHY_HEATER_AVAILABLE_STRING = "NO_HEALTHY_HEATER_AVAILABLE"; const char *SYRLINKS_OVERHEATING_STRING = "SYRLINKS_OVERHEATING"; @@ -604,9 +608,15 @@ const char *translateEvents(Event event) { case (12409): return WRITE_SYSCALL_ERROR_PDEC_STRING; case (12410): - return PDEC_RESET_FAILED_STRING; + return PDEC_TRYING_RESET_WITH_INIT_STRING; case (12411): + return PDEC_TRYING_RESET_NO_INIT_STRING; + case (12412): + return PDEC_RESET_FAILED_STRING; + case (12413): return OPEN_IRQ_FILE_FAILED_STRING; + case (12414): + return PDEC_INIT_FAILED_STRING; case (12500): return IMAGE_UPLOAD_FAILED_STRING; case (12501): @@ -819,6 +829,8 @@ const char *translateEvents(Event event) { return TRYING_I2C_RECOVERY_STRING; case (14011): return I2C_REBOOT_STRING; + case (14012): + return PDEC_REBOOT_STRING; case (14100): return NO_VALID_SENSOR_TEMPERATURE_STRING; case (14101): diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 76ce0db3..dbd6cc6e 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 175 translations. - * Generated on: 2023-04-07 17:42:57 + * Generated on: 2023-04-14 20:05:50 */ #include "translateObjects.h" diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index c4b537e8..f09c8c6d 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 285 translations. + * @brief Auto-generated event translation file. Contains 289 translations. * @details - * Generated on: 2023-04-07 17:42:57 + * Generated on: 2023-04-14 20:05:50 */ #include "translateEvents.h" @@ -160,8 +160,11 @@ const char *LOST_BIT_LOCK_PDEC_STRING = "LOST_BIT_LOCK_PDEC"; const char *TOO_MANY_IRQS_STRING = "TOO_MANY_IRQS"; const char *POLL_SYSCALL_ERROR_PDEC_STRING = "POLL_SYSCALL_ERROR_PDEC"; const char *WRITE_SYSCALL_ERROR_PDEC_STRING = "WRITE_SYSCALL_ERROR_PDEC"; +const char *PDEC_TRYING_RESET_WITH_INIT_STRING = "PDEC_TRYING_RESET_WITH_INIT"; +const char *PDEC_TRYING_RESET_NO_INIT_STRING = "PDEC_TRYING_RESET_NO_INIT"; const char *PDEC_RESET_FAILED_STRING = "PDEC_RESET_FAILED"; const char *OPEN_IRQ_FILE_FAILED_STRING = "OPEN_IRQ_FILE_FAILED"; +const char *PDEC_INIT_FAILED_STRING = "PDEC_INIT_FAILED"; const char *IMAGE_UPLOAD_FAILED_STRING = "IMAGE_UPLOAD_FAILED"; const char *IMAGE_DOWNLOAD_FAILED_STRING = "IMAGE_DOWNLOAD_FAILED"; const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; @@ -268,6 +271,7 @@ const char *REBOOT_COUNTER_STRING = "REBOOT_COUNTER"; const char *INDIVIDUAL_BOOT_COUNTS_STRING = "INDIVIDUAL_BOOT_COUNTS"; const char *TRYING_I2C_RECOVERY_STRING = "TRYING_I2C_RECOVERY"; const char *I2C_REBOOT_STRING = "I2C_REBOOT"; +const char *PDEC_REBOOT_STRING = "PDEC_REBOOT"; const char *NO_VALID_SENSOR_TEMPERATURE_STRING = "NO_VALID_SENSOR_TEMPERATURE"; const char *NO_HEALTHY_HEATER_AVAILABLE_STRING = "NO_HEALTHY_HEATER_AVAILABLE"; const char *SYRLINKS_OVERHEATING_STRING = "SYRLINKS_OVERHEATING"; @@ -604,9 +608,15 @@ const char *translateEvents(Event event) { case (12409): return WRITE_SYSCALL_ERROR_PDEC_STRING; case (12410): - return PDEC_RESET_FAILED_STRING; + return PDEC_TRYING_RESET_WITH_INIT_STRING; case (12411): + return PDEC_TRYING_RESET_NO_INIT_STRING; + case (12412): + return PDEC_RESET_FAILED_STRING; + case (12413): return OPEN_IRQ_FILE_FAILED_STRING; + case (12414): + return PDEC_INIT_FAILED_STRING; case (12500): return IMAGE_UPLOAD_FAILED_STRING; case (12501): @@ -819,6 +829,8 @@ const char *translateEvents(Event event) { return TRYING_I2C_RECOVERY_STRING; case (14011): return I2C_REBOOT_STRING; + case (14012): + return PDEC_REBOOT_STRING; case (14100): return NO_VALID_SENSOR_TEMPERATURE_STRING; case (14101): diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 76ce0db3..dbd6cc6e 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 175 translations. - * Generated on: 2023-04-07 17:42:57 + * Generated on: 2023-04-14 20:05:50 */ #include "translateObjects.h" diff --git a/linux/ipcore/PdecHandler.cpp b/linux/ipcore/PdecHandler.cpp index d5e5c0c8..7506dd11 100644 --- a/linux/ipcore/PdecHandler.cpp +++ b/linux/ipcore/PdecHandler.cpp @@ -15,6 +15,7 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw_hal/linux/uio/UioMapper.h" +#include "linux/ipcore/PdecConfig.h" #include "pdec.h" using namespace pdec; @@ -103,21 +104,10 @@ ReturnValue_t PdecHandler::firstLoop() { result = releasePdec(); if (result != returnvalue::OK) { - return returnvalue::FAILED; - } - - // This configuration must be done while the PDEC is not held in reset. - if (OP_MODE == Modes::IRQ) { - // Configure interrupt mask register to enable interrupts - *(registerBaseAddress + PDEC_IMR_OFFSET) = pdecConfig.getImrReg(); - } - result = resetFarStatFlag(); - if (result != returnvalue::OK) { - // Requires reconfiguration and reinitialization of PDEC - triggerEvent(INVALID_FAR); return result; } - return returnvalue::OK; + + return postResetOperation(); } ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { @@ -141,10 +131,11 @@ ReturnValue_t PdecHandler::polledOperation() { if (newTcReceived()) { handleNewTc(); } - checkLocks(); + doPeriodicWork(); break; } case State::PDEC_RESET: { + triggerEvent(pdec::PDEC_TRYING_RESET_WITH_INIT); ReturnValue_t result = pdecToReset(); if (result != returnvalue::OK) { triggerEvent(PDEC_RESET_FAILED); @@ -165,8 +156,8 @@ ReturnValue_t PdecHandler::polledOperation() { // See https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt.html for more information. ReturnValue_t PdecHandler::irqOperation() { ReturnValue_t result = returnvalue::OK; - int fd = -1; - // Used to unmask IRQ + // int fd = -1; + // Used to unmask IRQ uint32_t info = 1; interruptWindowCd.resetTimer(); @@ -182,22 +173,29 @@ ReturnValue_t PdecHandler::irqOperation() { switch (state) { case State::INIT: { result = handleInitState(); - if (result == returnvalue::OK) { - openIrqFile(&fd); + if (result != returnvalue::OK) { + break; + } + openIrqFile(); + if (ptmeResetWithReinitializationPending) { + actionHelper.finish(true, commandedBy, pdec::RESET_PDEC_WITH_REINIITALIZATION); + ptmeResetWithReinitializationPending = false; } break; } case State::PDEC_RESET: { + triggerEvent(pdec::PDEC_TRYING_RESET_WITH_INIT); result = pdecToReset(); if (result != returnvalue::OK) { triggerEvent(PDEC_RESET_FAILED); } + usleep(20); state = State::INIT; break; } case State::RUNNING: { - checkLocks(); - checkAndHandleIrqs(fd, info); + doPeriodicWork(); + checkAndHandleIrqs(info); break; } case State::WAIT_FOR_RECOVERY: @@ -219,27 +217,28 @@ ReturnValue_t PdecHandler::handleInitState() { ReturnValue_t result = firstLoop(); if (result != returnvalue::OK) { if (result == LocalParameterHandler::SD_NOT_READY) { - TaskFactory::delayTask(400); if (initTries == MAX_INIT_TRIES) { - sif::error << "PdecHandler::handleInitState: SD card never " - "becomes ready" - << std::endl; - state = State::WAIT_FOR_RECOVERY; - } else { - state = State::INIT; + sif::error << "PdecHandler::handleInitState: SD card never becomes ready" << std::endl; + initFailedHandler(result); + return result; } + state = State::INIT; + initTries++; + TaskFactory::delayTask(400); return result; } - state = State::WAIT_FOR_RECOVERY; + sif::error << "PDEC: Init failed with reason 0x" << std::hex << std::setw(4) << result + << std::endl; + initFailedHandler(result); return result; } state = State::RUNNING; return returnvalue::OK; } -void PdecHandler::openIrqFile(int* fd) { - *fd = open(uioNames.irq, O_RDWR); - if (*fd < 0) { +void PdecHandler::openIrqFile() { + irqFd = open(uioNames.irq, O_RDWR); + if (irqFd < 0) { sif::error << "PdecHandler::irqOperation: Opening UIO IRQ file" << uioNames.irq << " failed" << std::endl; triggerEvent(OPEN_IRQ_FILE_FAILED); @@ -247,16 +246,16 @@ void PdecHandler::openIrqFile(int* fd) { } } -ReturnValue_t PdecHandler::checkAndHandleIrqs(int fd, uint32_t& info) { - ssize_t nb = write(fd, &info, sizeof(info)); +ReturnValue_t PdecHandler::checkAndHandleIrqs(uint32_t& info) { + ssize_t nb = write(irqFd, &info, sizeof(info)); if (nb != static_cast(sizeof(info))) { sif::error << "PdecHandler::irqOperation: Unmasking IRQ failed" << std::endl; triggerEvent(WRITE_SYSCALL_ERROR_PDEC, errno); - close(fd); + close(irqFd); state = State::INIT; return returnvalue::FAILED; } - struct pollfd fds = {.fd = fd, .events = POLLIN, .revents = 0}; + struct pollfd fds = {.fd = irqFd, .events = POLLIN, .revents = 0}; int ret = poll(&fds, 1, IRQ_TIMEOUT_MS); if (ret == 0) { // No TCs for timeout period @@ -264,7 +263,7 @@ ReturnValue_t PdecHandler::checkAndHandleIrqs(int fd, uint32_t& info) { resetIrqLimiters(); } else if (ret >= 1) { // Interrupt handling. - nb = read(fd, &info, sizeof(info)); + nb = read(irqFd, &info, sizeof(info)); interruptCounter++; if (nb == static_cast(sizeof(info))) { uint32_t pisr = *(registerBaseAddress + PDEC_PISR_OFFSET); @@ -303,7 +302,7 @@ ReturnValue_t PdecHandler::checkAndHandleIrqs(int fd, uint32_t& info) { sif::error << "PdecHandler::irqOperation: Poll error with errno " << errno << ": " << strerror(errno) << std::endl; triggerEvent(POLL_SYSCALL_ERROR_PDEC, errno); - close(fd); + close(irqFd); state = State::INIT; return returnvalue::FAILED; } @@ -335,6 +334,7 @@ MessageQueueId_t PdecHandler::getCommandQueue() const { return commandQueue->get ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { + using namespace pdec; switch (actionId) { case PRINT_CLCW: printClcw(); @@ -342,6 +342,16 @@ ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t c case PRINT_PDEC_MON: printPdecMon(); return EXECUTION_FINISHED; + case RESET_PDEC_NO_REINIITALIZATION: { + pdecResetNoInit(); + return EXECUTION_FINISHED; + } + case RESET_PDEC_WITH_REINIITALIZATION: { + initializeReset(); + ptmeResetWithReinitializationPending = true; + this->commandedBy = commandedBy; + return returnvalue::OK; + } default: return COMMAND_NOT_IMPLEMENTED; } @@ -370,7 +380,7 @@ ReturnValue_t PdecHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifi return returnvalue::FAILED; } // PDEC needs reset to apply this parameter change - state = State::PDEC_RESET; + initializeReset(); return returnvalue::OK; } else if ((domainId == 0) and (uniqueIdentifier == ParameterId::NEGATIVE_WINDOW)) { uint8_t newVal = 0; @@ -392,7 +402,7 @@ ReturnValue_t PdecHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifi return returnvalue::FAILED; } // PDEC needs reset to apply this parameter change - state = State::PDEC_RESET; + initializeReset(); return returnvalue::OK; } return returnvalue::OK; @@ -449,22 +459,13 @@ bool PdecHandler::newTcReceived() { return true; } -void PdecHandler::checkLocks() { - uint32_t clcw = getClcw(); - if (not(clcw & NO_RF_MASK) && not carrierLock) { - triggerEvent(CARRIER_LOCK); - carrierLock = true; - } else if ((clcw & NO_RF_MASK) && carrierLock) { - carrierLock = false; - triggerEvent(LOST_CARRIER_LOCK_PDEC); - } - if (not(clcw & NO_BITLOCK_MASK) && not bitLock) { - triggerEvent(BIT_LOCK_PDEC); - bitLock = true; - } else if ((clcw & NO_BITLOCK_MASK) && bitLock) { - bitLock = false; - triggerEvent(LOST_BIT_LOCK_PDEC); - } +void PdecHandler::doPeriodicWork() { + // scuffed test code + // if(testCntr < 30) { + // triggerEvent(pdec::INVALID_TC_FRAME, FRAME_DIRTY_RETVAL); + // testCntr++; + // } + checkLocks(); } bool PdecHandler::checkFrameAna(uint32_t pdecFar) { @@ -748,6 +749,68 @@ void PdecHandler::resetIrqLimiters() { interruptCounter = 0; } +void PdecHandler::checkLocks() { + uint32_t clcw = getClcw(); + if (not(clcw & NO_RF_MASK) && not carrierLock) { + triggerEvent(CARRIER_LOCK); + carrierLock = true; + } else if ((clcw & NO_RF_MASK) && carrierLock) { + carrierLock = false; + triggerEvent(LOST_CARRIER_LOCK_PDEC); + } + if (not(clcw & NO_BITLOCK_MASK) && not bitLock) { + triggerEvent(BIT_LOCK_PDEC); + bitLock = true; + } else if ((clcw & NO_BITLOCK_MASK) && bitLock) { + bitLock = false; + triggerEvent(LOST_BIT_LOCK_PDEC); + } +} + +void PdecHandler::initFailedHandler(ReturnValue_t reason) { + triggerEvent(pdec::PDEC_INIT_FAILED, reason, 0); + if (ptmeResetWithReinitializationPending) { + actionHelper.finish(false, commandedBy, pdec::RESET_PDEC_WITH_REINIITALIZATION, reason); + ptmeResetWithReinitializationPending = false; + } + state = State::WAIT_FOR_RECOVERY; +} + +void PdecHandler::pdecResetNoInit() { + triggerEvent(pdec::PDEC_TRYING_RESET_NO_INIT); + pdecToReset(); + usleep(20); + releasePdec(); + ReturnValue_t result = postResetOperation(); + if (result != returnvalue::OK) { + // What can we really do here? Event was already triggered if this is due to the FAR flag + // not being reset. + sif::error << "PdecHandler::pdecResetNoInit: Post reset operation failed unexpectedly" + << std::endl; + } +} + +ReturnValue_t PdecHandler::postResetOperation() { + // This configuration must be done while the PDEC is not held in reset. + if (OP_MODE == Modes::IRQ) { + // Configure interrupt mask register to enable interrupts + *(registerBaseAddress + PDEC_IMR_OFFSET) = pdecConfig.getImrReg(); + } + ReturnValue_t result = resetFarStatFlag(); + if (result != returnvalue::OK) { + // Requires reconfiguration and reinitialization of PDEC + triggerEvent(INVALID_FAR); + } + return result; +} + +void PdecHandler::initializeReset() { + if (irqFd != 0) { + close(irqFd); + } + state = State::PDEC_RESET; +} + std::string PdecHandler::getMonStatusString(uint32_t status) { switch (status) { case TC_CHANNEL_INACTIVE: diff --git a/linux/ipcore/PdecHandler.h b/linux/ipcore/PdecHandler.h index 2f0bcca2..882dca50 100644 --- a/linux/ipcore/PdecHandler.h +++ b/linux/ipcore/PdecHandler.h @@ -3,6 +3,8 @@ #include +#include + #include "OBSWConfig.h" #include "PdecConfig.h" #include "eive/definitions.h" @@ -79,73 +81,11 @@ class PdecHandler : public SystemObject, ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, uint16_t startAtIndex) override; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; - - //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame - //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) - //! P2: When frame declared illegal this parameter this parameter gives information about the - //! reason (IReason field of the PDEC_FAR register) - static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); - //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup - static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); - //! [EXPORT] : [COMMENT] Carrier lock detected - static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); - //! [EXPORT] : [COMMENT] Bit lock detected (data valid) - static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); - //! [EXPORT] : [COMMENT] Lost carrier lock - static const Event LOST_CARRIER_LOCK_PDEC = MAKE_EVENT(5, severity::INFO); - //! [EXPORT] : [COMMENT] Lost bit lock - static const Event LOST_BIT_LOCK_PDEC = MAKE_EVENT(6, severity::INFO); - //! [EXPORT] : [COMMENT] Too many IRQs over the time window of one second. P1: Allowed TCs - static constexpr Event TOO_MANY_IRQS = MAKE_EVENT(7, severity::MEDIUM); - static constexpr Event POLL_SYSCALL_ERROR_PDEC = - event::makeEvent(SUBSYSTEM_ID, 8, severity::MEDIUM); - static constexpr Event WRITE_SYSCALL_ERROR_PDEC = - event::makeEvent(SUBSYSTEM_ID, 9, severity::HIGH); - //! [EXPORT] : [COMMENT] Failed to pull PDEC reset to low - static constexpr Event PDEC_RESET_FAILED = event::makeEvent(SUBSYSTEM_ID, 10, severity::HIGH); - //! [EXPORT] : [COMMENT] Failed to open the IRQ uio file - static constexpr Event OPEN_IRQ_FILE_FAILED = event::makeEvent(SUBSYSTEM_ID, 11, severity::HIGH); - private: - static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; - static constexpr Modes OP_MODE = Modes::IRQ; - static const ReturnValue_t ABANDONED_CLTU_RETVAL = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t FRAME_DIRTY_RETVAL = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t AD_DISCARDED_LOCKOUT_RETVAL = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t AD_DISCARDED_WAIT_RETVAL = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); - - //! [EXPORT] : [COMMENT] Received action message with unknown action id - static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); - - static const ReturnValue_t NO_REPORT_RETVAL = MAKE_RETURN_CODE(0xA6); - //! Error in version number and reserved A and B fields - static const ReturnValue_t ERROR_VERSION_NUMBER_RETVAL = MAKE_RETURN_CODE(0xA7); - //! Illegal combination of bypass and control command flag - static const ReturnValue_t ILLEGAL_COMBINATION_RETVAL = MAKE_RETURN_CODE(0xA8); - //! Spacecraft identifier did not match - static const ReturnValue_t INVALID_SC_ID_RETVAL = MAKE_RETURN_CODE(0xA9); - //! VC identifier bits 0 to 4 did not match - static const ReturnValue_t INVALID_VC_ID_MSB_RETVAL = MAKE_RETURN_CODE(0xAA); - //! VC identifier bit 5 did not match - static const ReturnValue_t INVALID_VC_ID_LSB_RETVAL = MAKE_RETURN_CODE(0xAB); - //! N(S) of BC or BD frame not set to all zeros - static const ReturnValue_t NS_NOT_ZERO_RETVAL = MAKE_RETURN_CODE(0xAC); - //! Invalid BC control command - static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); - static const uint32_t QUEUE_SIZE = config::CCSDS_HANDLER_QUEUE_SIZE; - // Action IDs - static const ActionId_t PRINT_CLCW = 0; - // Print PDEC monitor register - static const ActionId_t PRINT_PDEC_MON = 1; - #ifdef TE0720_1CFA static const int CONFIG_MEMORY_MAP_SIZE = 0x400; static const int RAM_MAP_SIZE = 0x4000; @@ -185,17 +125,6 @@ class PdecHandler : public SystemObject, static constexpr uint32_t MAX_ALLOWED_IRQS_PER_WINDOW = 800; - enum class FrameAna_t : uint8_t { - ABANDONED_CLTU, - FRAME_DIRTY, - FRAME_ILLEGAL, - FRAME_ILLEGAL_MULTI_REASON, - AD_DISCARDED_LOCKOUT, - AD_DISCARDED_WAIT, - AD_DISCARDED_NS_VR, - FRAME_ACCEPTED - }; - enum class IReason_t : uint8_t { NO_REPORT, ERROR_VERSION_NUMBER, @@ -213,6 +142,7 @@ class PdecHandler : public SystemObject, Countdown genericCheckCd = Countdown(IRQ_TIMEOUT_MS); object_id_t tcDestinationId; + int irqFd = 0; AcceptsTelecommandsIF* tcDestination = nullptr; @@ -258,6 +188,9 @@ class PdecHandler : public SystemObject, bool carrierLock = false; bool bitLock = false; + MessageQueueId_t commandedBy = MessageQueueIF::NO_QUEUE; + bool ptmeResetWithReinitializationPending = false; + UioNames uioNames; ParameterHelper paramHelper; @@ -266,6 +199,9 @@ class PdecHandler : public SystemObject, uint32_t initTries = 0; + // scuffed test counter. + uint8_t testCntr = 0; + /** * @brief Performs initialization stuff which must be performed in first * loop of running task @@ -282,8 +218,8 @@ class PdecHandler : public SystemObject, ReturnValue_t polledOperation(); ReturnValue_t irqOperation(); ReturnValue_t handleInitState(); - void openIrqFile(int* fd); - ReturnValue_t checkAndHandleIrqs(int fd, uint32_t& info); + void openIrqFile(); + ReturnValue_t checkAndHandleIrqs(uint32_t& info); uint32_t readFar(); @@ -325,6 +261,8 @@ class PdecHandler : public SystemObject, * @brief Checks if carrier lock or bit lock has been detected and triggers appropriate * event. */ + void doPeriodicWork(); + void checkLocks(); void resetIrqLimiters(); @@ -400,6 +338,13 @@ class PdecHandler : public SystemObject, */ void printPdecMon(); + void pdecResetNoInit(); + + ReturnValue_t postResetOperation(); + void initializeReset(); + + void initFailedHandler(ReturnValue_t reason); + std::string getMonStatusString(uint32_t status); }; diff --git a/linux/ipcore/pdec.h b/linux/ipcore/pdec.h index 7485f744..e0e61e10 100644 --- a/linux/ipcore/pdec.h +++ b/linux/ipcore/pdec.h @@ -1,10 +1,94 @@ #ifndef LINUX_OBC_PDEC_H_ #define LINUX_OBC_PDEC_H_ +#include + #include namespace pdec { +static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; +static const ReturnValue_t ABANDONED_CLTU_RETVAL = MAKE_RETURN_CODE(0xA0); +static const ReturnValue_t FRAME_DIRTY_RETVAL = MAKE_RETURN_CODE(0xA1); +static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); +static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); +static const ReturnValue_t AD_DISCARDED_LOCKOUT_RETVAL = MAKE_RETURN_CODE(0xA3); +static const ReturnValue_t AD_DISCARDED_WAIT_RETVAL = MAKE_RETURN_CODE(0xA4); +static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); + +//! [EXPORT] : [COMMENT] Received action message with unknown action id +static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); + +static const ReturnValue_t NO_REPORT_RETVAL = MAKE_RETURN_CODE(0xA6); +//! Error in version number and reserved A and B fields +static const ReturnValue_t ERROR_VERSION_NUMBER_RETVAL = MAKE_RETURN_CODE(0xA7); +//! Illegal combination of bypass and control command flag +static const ReturnValue_t ILLEGAL_COMBINATION_RETVAL = MAKE_RETURN_CODE(0xA8); +//! Spacecraft identifier did not match +static const ReturnValue_t INVALID_SC_ID_RETVAL = MAKE_RETURN_CODE(0xA9); +//! VC identifier bits 0 to 4 did not match +static const ReturnValue_t INVALID_VC_ID_MSB_RETVAL = MAKE_RETURN_CODE(0xAA); +//! VC identifier bit 5 did not match +static const ReturnValue_t INVALID_VC_ID_LSB_RETVAL = MAKE_RETURN_CODE(0xAB); +//! N(S) of BC or BD frame not set to all zeros +static const ReturnValue_t NS_NOT_ZERO_RETVAL = MAKE_RETURN_CODE(0xAC); +//! Invalid BC control command +static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); + +static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; + +//! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame +//! P1: The frame analysis information (FrameAna field of PDEC_FAR register) +//! P2: When frame declared illegal this parameter this parameter gives information about the +//! reason (IReason field of the PDEC_FAR register) +static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); +//! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup +static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); +//! [EXPORT] : [COMMENT] Carrier lock detected +static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); +//! [EXPORT] : [COMMENT] Bit lock detected (data valid) +static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); +//! [EXPORT] : [COMMENT] Lost carrier lock +static const Event LOST_CARRIER_LOCK_PDEC = MAKE_EVENT(5, severity::INFO); +//! [EXPORT] : [COMMENT] Lost bit lock +static const Event LOST_BIT_LOCK_PDEC = MAKE_EVENT(6, severity::INFO); +//! [EXPORT] : [COMMENT] Too many IRQs over the time window of one second. P1: Allowed TCs +static constexpr Event TOO_MANY_IRQS = MAKE_EVENT(7, severity::MEDIUM); +static constexpr Event POLL_SYSCALL_ERROR_PDEC = + event::makeEvent(SUBSYSTEM_ID, 8, severity::MEDIUM); +static constexpr Event WRITE_SYSCALL_ERROR_PDEC = event::makeEvent(SUBSYSTEM_ID, 9, severity::HIGH); +//! [EXPORT] : [COMMENT] Trying a PDEC reset with complete re-initialization +static constexpr Event PDEC_TRYING_RESET_WITH_INIT = + event::makeEvent(SUBSYSTEM_ID, 10, severity::LOW); +//! [EXPORT] : [COMMENT] Trying a PDEC reset without re-initialization. +static constexpr Event PDEC_TRYING_RESET_NO_INIT = + event::makeEvent(SUBSYSTEM_ID, 11, severity::LOW); +//! [EXPORT] : [COMMENT] Failed to pull PDEC reset to low +static constexpr Event PDEC_RESET_FAILED = event::makeEvent(SUBSYSTEM_ID, 12, severity::HIGH); +//! [EXPORT] : [COMMENT] Failed to open the IRQ uio file +static constexpr Event OPEN_IRQ_FILE_FAILED = event::makeEvent(SUBSYSTEM_ID, 13, severity::HIGH); +//! [EXPORT] : [COMMENT] PDEC initialization failed. This might also be due to the persistent +//! confiuration never becoming available, for example due to SD card issues. +static constexpr Event PDEC_INIT_FAILED = event::makeEvent(SUBSYSTEM_ID, 14, severity::HIGH); + +// Action IDs +static constexpr ActionId_t PRINT_CLCW = 0; +// Print PDEC monitor register +static constexpr ActionId_t PRINT_PDEC_MON = 1; +static constexpr ActionId_t RESET_PDEC_NO_REINIITALIZATION = 2; +static constexpr ActionId_t RESET_PDEC_WITH_REINIITALIZATION = 3; + +enum class FrameAna_t : uint8_t { + ABANDONED_CLTU, + FRAME_DIRTY, + FRAME_ILLEGAL, + FRAME_ILLEGAL_MULTI_REASON, + AD_DISCARDED_LOCKOUT, + AD_DISCARDED_WAIT, + AD_DISCARDED_NS_VR, + FRAME_ACCEPTED +}; + static const uint8_t STAT_POSITION = 31; static const uint8_t FRAME_ANA_POSITION = 28; static const uint8_t IREASON_POSITION = 25; diff --git a/mission/sysDefs.h b/mission/sysDefs.h index e8ada9f8..424b5752 100644 --- a/mission/sysDefs.h +++ b/mission/sysDefs.h @@ -90,9 +90,11 @@ static constexpr Event REBOOT_COUNTER = event::makeEvent(SUBSYSTEM_ID, 7, severi static constexpr Event INDIVIDUAL_BOOT_COUNTS = event::makeEvent(SUBSYSTEM_ID, 8, severity::INFO); //! [EXPORT] : [COMMENT] I2C is unavailable. Trying recovery of I2C bus by power cycling all I2C //! devices. -static constexpr Event TRYING_I2C_RECOVERY = event::makeEvent(SUBSYSTEM_ID, 10, severity::MEDIUM); +static constexpr Event TRYING_I2C_RECOVERY = event::makeEvent(SUBSYSTEM_ID, 10, severity::HIGH); //! [EXPORT] : [COMMENT] I2C is unavailable. Recovery did not work, performing full reboot. -static constexpr Event I2C_REBOOT = event::makeEvent(SUBSYSTEM_ID, 11, severity::MEDIUM); +static constexpr Event I2C_REBOOT = event::makeEvent(SUBSYSTEM_ID, 11, severity::HIGH); +//! [EXPORT] : [COMMENT] PDEC recovery through reset was not possible, performing full reboot. +static constexpr Event PDEC_REBOOT = event::makeEvent(SUBSYSTEM_ID, 12, severity::HIGH); } // namespace core diff --git a/mission/system/EiveSystem.cpp b/mission/system/EiveSystem.cpp index f93aa099..eb1c4101 100644 --- a/mission/system/EiveSystem.cpp +++ b/mission/system/EiveSystem.cpp @@ -4,10 +4,12 @@ #include #include #include +#include #include #include #include +#include "linux/ipcore/pdec.h" #include "mission/power/bpxBattDefs.h" #include "mission/power/defs.h" #include "mission/sysDefs.h" @@ -62,6 +64,7 @@ void EiveSystem::performChildOperation() { performSafeRecovery = false; return; } + pdecRecoveryLogic(); i2cRecoveryLogic(); } @@ -86,6 +89,12 @@ ReturnValue_t EiveSystem::initialize() { } coreCtrlQueueId = coreCtrl->getCommandQueue(); + auto* pdecHandler = ObjectManager::instance()->get(objects::PDEC_HANDLER); + if (pdecHandler == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + pdecHandlerQueueId = pdecHandler->getCommandQueue(); + auto* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -105,8 +114,7 @@ ReturnValue_t EiveSystem::initialize() { manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::PCDU_SYSTEM_OVERHEATING)); manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::OBC_OVERHEATING)); - - // manager->subscribeToEvent(eventQueue->getId(), event::getEventId(CoreController::)) + manager->subscribeToEvent(eventQueue->getId(), event::getEventId(pdec::INVALID_TC_FRAME)); return Subsystem::initialize(); } @@ -117,6 +125,12 @@ void EiveSystem::handleEventMessages() { switch (event.getMessageId()) { case EventMessage::EVENT_MESSAGE: switch (event.getEvent()) { + case pdec::INVALID_TC_FRAME: { + if (event.getParameter1() == pdec::FRAME_DIRTY_RETVAL) { + frameDirtyErrorCounter++; + } + break; + } case tcsCtrl::OBC_OVERHEATING: case tcsCtrl::PCDU_SYSTEM_OVERHEATING: { if (isInTransition) { @@ -175,11 +189,11 @@ void EiveSystem::i2cRecoveryLogic() { // Try recovery. executeAction(EXECUTE_I2C_REBOOT, MessageQueueIF::NO_QUEUE, nullptr, 0); } else { + triggerEvent(core::I2C_REBOOT); // We already tried an I2C recovery but the bus is still broken. // Send full reboot request to core controller. - CommandMessage msg; - ActionMessage::setCommand(&msg, core::REBOOT_OBC, store_address_t()); - result = commandQueue->sendMessage(coreCtrlQueueId, &msg); + sendFullRebootCommand(); + return; } } } @@ -258,6 +272,39 @@ void EiveSystem::i2cRecoveryLogic() { void EiveSystem::commandSelfToSafe() { startTransition(satsystem::Mode::SAFE, 0); } +ReturnValue_t EiveSystem::sendFullRebootCommand() { + CommandMessage msg; + ActionMessage::setCommand(&msg, core::REBOOT_OBC, store_address_t()); + return commandQueue->sendMessage(coreCtrlQueueId, &msg); +} + +void EiveSystem::pdecRecoveryLogic() { + if (ptmeResetWasAttempted and ptmeResetWasAttemptedCd.hasTimedOut()) { + ptmeResetWasAttempted = false; + } + if (frameDirtyCheckCd.hasTimedOut()) { + if (frameDirtyErrorCounter >= FRAME_DIRTY_COM_REBOOT_LIMIT) { + // If a PTME reset was already attempted and there is still an issue receiving TC frames, + // reboot the system. + if (ptmeResetWasAttempted) { + triggerEvent(core::PDEC_REBOOT); + // Send reboot command. + sendFullRebootCommand(); + } else { + // Try one full PDEC reset. + CommandMessage msg; + store_address_t dummy{}; + ActionMessage::setCommand(&msg, pdec::RESET_PDEC_WITH_REINIITALIZATION, dummy); + commandQueue->sendMessage(pdecHandlerQueueId, &msg); + ptmeResetWasAttemptedCd.resetTimer(); + ptmeResetWasAttempted = true; + } + } + frameDirtyErrorCounter = 0; + frameDirtyCheckCd.resetTimer(); + } +} + void EiveSystem::commonI2cRecoverySequenceFinish() { alreadyTriedI2cRecovery = true; performI2cReboot = false; diff --git a/mission/system/EiveSystem.h b/mission/system/EiveSystem.h index 504d4317..67f11c3e 100644 --- a/mission/system/EiveSystem.h +++ b/mission/system/EiveSystem.h @@ -9,6 +9,8 @@ class EiveSystem : public Subsystem, public HasActionsIF { public: + static constexpr uint8_t FRAME_DIRTY_COM_REBOOT_LIMIT = 4; + static constexpr ActionId_t EXECUTE_I2C_REBOOT = 10; EiveSystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables, @@ -33,10 +35,19 @@ class EiveSystem : public Subsystem, public HasActionsIF { bool performI2cReboot = false; bool alreadyTriedI2cRecovery = false; + uint8_t frameDirtyErrorCounter = 0; + Countdown frameDirtyCheckCd = Countdown(10000); + // If the PDEC reset was already attempted in the last 2 minutes, there is a high chance that + // only a full reboot will fix the issue. + Countdown ptmeResetWasAttemptedCd = Countdown(120000); + bool ptmeResetWasAttempted = false; + ActionHelper actionHelper; PowerSwitchIF* powerSwitcher = nullptr; std::atomic_uint16_t& i2cErrors; + MessageQueueId_t pdecHandlerQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t bpxBattQueueId = MessageQueueIF::NO_QUEUE; MessageQueueId_t coreCtrlQueueId = MessageQueueIF::NO_QUEUE; MessageQueueId_t actionCommandedBy = MessageQueueIF::NO_QUEUE; @@ -51,6 +62,10 @@ class EiveSystem : public Subsystem, public HasActionsIF { const uint8_t* data, size_t size) override; ReturnValue_t handleCommandMessage(CommandMessage* message) override; + ReturnValue_t sendFullRebootCommand(); + + void pdecRecoveryLogic(); + void i2cRecoveryLogic(); void handleEventMessages(); void commandSelfToSafe(); diff --git a/mission/system/com/ComSubsystem.cpp b/mission/system/com/ComSubsystem.cpp index fa2c31d3..dfcbbd42 100644 --- a/mission/system/com/ComSubsystem.cpp +++ b/mission/system/com/ComSubsystem.cpp @@ -105,9 +105,9 @@ ReturnValue_t ComSubsystem::initialize() { if (result != returnvalue::OK) { return ObjectManager::CHILD_INIT_FAILED; } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(PdecHandler::CARRIER_LOCK), - event::getEventId(PdecHandler::BIT_LOCK_PDEC)); + result = + manager->subscribeToEventRange(eventQueue->getId(), event::getEventId(pdec::CARRIER_LOCK), + event::getEventId(pdec::BIT_LOCK_PDEC)); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ComSubsystem::initialize: Failed to subscribe to events from PDEC " @@ -167,11 +167,11 @@ void ComSubsystem::handleEventMessage(EventMessage *eventMessage) { startRxOnlyRecovery(true); break; } - case PdecHandler::BIT_LOCK_PDEC: { + case pdec::BIT_LOCK_PDEC: { handleBitLockEvent(); break; } - case PdecHandler::CARRIER_LOCK: { + case pdec::CARRIER_LOCK: { handleCarrierLockEvent(); break; } diff --git a/tmtc b/tmtc index f5734260..1f06ea45 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f57342602da3232c0bfecaecb0c10be6d692b384 +Subproject commit 1f06ea4590d6340990fb8d9534a84e7e9de68951