├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── pull_request_template.md └── workflows │ ├── codeql-build.yml │ ├── format-check.yml │ └── static-analysis.yml ├── CHANGELOG.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── cfe_ts_crc.c └── cfe_ts_crc_version.h /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Code snips** 24 | If applicable, add references to the software. 25 | 26 | **System observed on:** 27 | - Hardware 28 | - OS: [e.g. Linux 4.4] 29 | - Versions [e.g. cFE 6.6, OSAL 4.2, PSP 1.3 for mcp750, any related apps] 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | 34 | **Reporter Info** 35 | Full name and company/organization if applicable 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context about the feature request here. 21 | 22 | **Requester Info** 23 | Full name and company/organization if applicable 24 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | **Describe the contribution** 2 | A clear and concise description of what the contribution is. 3 | - Include explicitly what issue it addresses [e.g. Fixes #X] 4 | 5 | **Testing performed** 6 | Steps taken to test the contribution: 7 | 1. Build steps '...' 8 | 1. Execution steps '...' 9 | 10 | **Expected behavior changes** 11 | A clear and concise description of how this contribution will change behavior and level of impact. 12 | - API Change: xxx (if applicable) 13 | - Behavior Change: xxx (if applicable) 14 | - Or no impact to behavior 15 | 16 | **System(s) tested on** 17 | - Hardware: [e.g. PC, SP0, MCP750] 18 | - OS: [e.g. Ubuntu 18.04, RTEMS 4.11, VxWorks 6.9] 19 | - Versions: [e.g. cFE 6.6, OSAL 4.2, PSP 1.3 for mcp750, any related apps or tools] 20 | 21 | **Additional context** 22 | Add any other context about the contribution here. 23 | 24 | **Third party code** 25 | If included, identify any third party code and provide text file of license 26 | 27 | **Contributor Info - All information REQUIRED for consideration of pull request** 28 | Full name and company/organization/center of all contributors ("Personal" if individual work) 29 | - If NASA Civil Servant Employee or GSFC Contractor on SES II 30 | - Address/email/phone and contract/task information (if applicable) must be on file 31 | - Else if Company 32 | - **HAND SIGNED** Company CLA must be on file (once per release): [Company CLA](https://github.com/nasa/cFE/blob/master/docs/GSC_18128_Corp_CLA_form_1219.pdf) 33 | - Else if Individual 34 | - **HAND SIGNED** Individual CLA must be on file (once per release): [Individual CLA](https://github.com/nasa/cFE/blob/master/docs/GSC_18128_Ind_CLA_form_1219.pdf) 35 | -------------------------------------------------------------------------------- /.github/workflows/codeql-build.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL Analysis" 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | codeql: 9 | name: Codeql 10 | uses: nasa/cFS/.github/workflows/codeql-reusable.yml@main 11 | with: 12 | component-path: tools/tblCRCTool 13 | make: 'make -C build/tools/tblCRCTool' 14 | -------------------------------------------------------------------------------- /.github/workflows/format-check.yml: -------------------------------------------------------------------------------- 1 | name: Format Check 2 | 3 | # Run on all push and pull requests 4 | on: 5 | push: 6 | pull_request: 7 | 8 | jobs: 9 | format-check: 10 | name: Run format check 11 | uses: nasa/cFS/.github/workflows/format-check.yml@main 12 | -------------------------------------------------------------------------------- /.github/workflows/static-analysis.yml: -------------------------------------------------------------------------------- 1 | name: Static Analysis 2 | 3 | # Run on all push and pull requests 4 | on: 5 | push: 6 | pull_request: 7 | 8 | jobs: 9 | 10 | static-analysis: 11 | name: Run cppcheck 12 | uses: nasa/cFS/.github/workflows/static-analysis.yml@main 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Development Build: equuleus-rc1+dev2 4 | - updating tblCRCTool to use new versioning system 5 | - See 6 | 7 | ## Development Build: v1.3.0-rc4+dev28 8 | - Replace exit(1) with preferred macro EXIT_FAILURE 9 | - See 10 | 11 | ## Development Build: v1.3.0-rc4+dev24 12 | - Create CHANGELOG.md 13 | - See 14 | 15 | ## Development Build: v1.3.0-rc4+dev18 16 | - https://github.com/nasa/tblCRCTool/pull/70 17 | - See 18 | 19 | ## Development Build: v1.3.0-rc4+dev14 20 | - Update Copyright Headers 21 | - Standardize version.h 22 | - See and 23 | 24 | ## Development Build: v1.3.0-rc4+dev7 25 | - Remove explicit filename doxygen comments 26 | - See 27 | 28 | ## Development Build: v1.3.0-rc4+dev2 29 | - Set baseline for cFS-Caelum-rc4: v1.3.0-rc4 30 | - Update mission rev to use 0xFF for development version 31 | - See 32 | 33 | ## Development Build: v1.2.0-rc1+dev33 34 | - Add printf conversion casts to fix Raspberry-Pi4 compilation error 35 | - Cast ssize_t to long and uint32 to unsigned long for printf. 36 | - This matches the %d and %lX conversions, respectively. 37 | - Implement Coding Standard in CodeQL 38 | - See and 39 | 40 | ## Development Build: v1.2.0-rc1+dev25 41 | - Add Testing Tools to the Security Policy 42 | - Check lseek return and exit/error processing updates 43 | - See 44 | 45 | ## Development Build: v1.2.0-rc1+dev19 46 | - Changes CLI "help" option to use two dashes: `--help` 47 | - Adds static analysis and format check to continuous integration workflow. Adds workflow status badges to ReadMe. 48 | - Adds CodeQL Analysis to continuous integration workflow. 49 | - See 50 | 51 | ## Development Build: v1.2.0-rc1+dev12 52 | - Documentation: Add `Security.md` with instructions on reporting vulnerabilities 53 | - Removes unimplemented CRC cases to eliminate static analysis warnings 54 | - See 55 | 56 | ## Development Build: v1.2.0-rc1+dev3 57 | - Use `sizeof()` instead of a hard coded value for the table file header size to keep this tool in sync if the size of the cFE file or table header should ever change. 58 | - Update version baseline to v1.2.0-rc1 59 | - Set REVISION number to 99 to indicate development version 60 | - See 61 | 62 | ## Development Build: 1.1.0+dev7 63 | - Create a version header file 64 | - Report version when responding to `-help` command 65 | - See 66 | 67 | ## Development Build: 1.1.1 68 | - Apply Code Style 69 | - See 70 | 71 | ## **_OFFICIAL RELEASE: 1.1.0 - Aquila_** 72 | - Minor updates (see https://github.com/nasa/tblCRCTool/pull/12) 73 | - Released as part of cFE 6.7.0, Apache 2.0 74 | 75 | ## **_OFFICIAL RELEASE: 1.0.0a_** 76 | - Released as part of cFE 6.6.0a, Apache 2.0 77 | 78 | NOTE - there are other parameter set management schemes used with the cFS (JSON, csv, etc) which may be more applicable for modern missions. Contact the community as detailed below for more information. 79 | 80 | ## Known issues 81 | 82 | This ground utility was developed for a specific mission/configuration, and may not be applicable for general use. 83 | 84 | ## Getting Help 85 | 86 | For best results, submit issues:questions or issues:help wanted requests at https://github.com/nasa/cFS. 87 | 88 | Official cFS page: http://cfs.gsfc.nasa.gov 89 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMake recipe for building tblCRCTool 2 | # 3 | 4 | # This tool references the definitions of the CFE_TBL_FileHdr_t and CFE_FS_Header_t 5 | # structures, which are defined in the CFE header files. This, in turn, requires 6 | # the common_types.h file from OSAL and the global cfe_mission_cfg.h file. 7 | include_directories(${MISSION_BINARY_DIR}/inc) 8 | include_directories(${osal_MISSION_DIR}/src/os/inc) 9 | include_directories(${cfe-core_MISSION_DIR}/src/inc) 10 | 11 | add_executable(cfe_ts_crc cfe_ts_crc.c) 12 | 13 | install(TARGETS cfe_ts_crc DESTINATION host) 14 | 15 | 16 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guide 2 | 3 | Please see our [top-level contributing guide](https://github.com/nasa/cFS/blob/main/CONTRIBUTING.md) for more information on how to contribute. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Static Analysis](https://github.com/nasa/tblCRCTool/workflows/Static%20Analysis/badge.svg) 2 | ![Format Check](https://github.com/nasa/tblCRCTool/workflows/Format%20Check/badge.svg) 3 | 4 | # Core Flight System : Framework : Tool : Table CRC Generator 5 | 6 | This repository contains NASA's Table CRC Generator Tool (tblCRCTool), which is a framework component of the Core Flight System. 7 | 8 | This lab application is a ground utility to generate binary table CRCs for cFS. It is intended to be located in the `tools/tblCRCTool` subdirectory of a cFS Mission Tree. The Core Flight System is bundled at https://github.com/nasa/cFS (which includes this tool as a submodule), which includes build and execution instructions. 9 | 10 | ## Known issues 11 | 12 | This ground utility was developed for a specific mission/configuration, and may not be applicable for general use. 13 | 14 | ## Getting Help 15 | 16 | For best results, submit issues:questions or issues:help wanted requests at https://github.com/nasa/cFS. 17 | 18 | Official cFS page: http://cfs.gsfc.nasa.gov 19 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | To report a vulnerability for the tblCRCTool subsystem please [submit an issue](https://github.com/nasa/tblCRCTool/issues/new/choose). 6 | 7 | For general cFS vulnerabilities please [open a cFS framework issue](https://github.com/nasa/cfs/issues/new/choose) and see our [top-level security policy](https://github.com/nasa/cFS/security/policy) for additional information. 8 | 9 | In either case please use the "Bug Report" template and provide as much information as possible. Apply appropriate labels for each report. For security related reports, tag the issue with the "security" label. 10 | 11 | ## Testing 12 | 13 | **Disclaimer: nasa/tblCRCTool is not responsible for any liability incurred under the [Apache License 2.0](https://github.com/nasa/tblCRCTool/blob/main/LICENSE).** 14 | 15 | Testing is an important aspect our team values to improve tblCRCTool. 16 | 17 | To view tools used for the cFS bundle, see our [top-level security policy](https://github.com/nasa/cFS/security/policy). 18 | 19 | ### CodeQL 20 | 21 | The [tblCRCTool CodeQL GitHub Actions workflow](https://github.com/nasa/tblCRCTool/actions/workflows/codeql-build.yml) is available to the public. To review the results, fork the tblCRCTool repository and run the CodeQL workflow. 22 | 23 | CodeQL is ran for every push and pull-request on all branches of tblCRCTool in GitHub Actions. 24 | 25 | For the CodeQL GitHub Actions setup, visit https://github.com/github/codeql-action. 26 | 27 | ### Cppcheck 28 | 29 | The [tblCRCTool Cppcheck GitHub Actions workflow and results](https://github.com/nasa/tblCRCTool/actions/workflows/static-analysis.yml) are available to the public. To view the results, select a workflow and download the artifacts. 30 | 31 | Cppcheck is ran for every push on the main branch and every pull request on all branches of tblCRCTool in Github Actions. 32 | 33 | For more information about Cppcheck, visit http://cppcheck.sourceforge.net/. 34 | 35 | ## Additional Support 36 | 37 | For additional support, submit a GitHub issue. You can also email the cfs community at cfs-community@lists.nasa.gov. 38 | 39 | You can subscribe to the mailing list [here](https://lists.nasa.gov/mailman/listinfo/cfs-community) that includes all the community members/users of the NASA core Flight Software (cFS) product line. The mailing list is used to communicate any information related to the cFS product such as current releases, bug findings and fixes, enhancement requests, community meeting notifications, sending out meeting minutes, etc. 40 | 41 | If you wish to report a cybersecurity incident or concern, please contact the NASA Security Operations Center either by phone at 1-877-627-2732 or via email address soc@nasa.gov. 42 | -------------------------------------------------------------------------------- /cfe_ts_crc.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” 3 | * 4 | * Copyright (c) 2020 United States Government as represented by the 5 | * Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 9 | * not use this file except in compliance with the License. You may obtain 10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | ************************************************************************/ 18 | 19 | /* 20 | * This program calculates the CRC-16/ARC of a given table file. 21 | * 22 | * Algorithm: 23 | * - Name: CRC-16/ARC 24 | * - Polynomial: 0x8005 25 | * - Initialization: 0x0000 26 | * - Reflect Input/Output: true 27 | * - XorOut: 0x0000 28 | * 29 | * Inputs: One string containing the filename of the table file to CRC. 30 | * 31 | * Outputs: Prints to the terminal the filename, size, and CRC. 32 | * Returns 0 if successful. 33 | * 34 | * Author: Mike Blau, GSFC Code 582 35 | */ 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include "cfe_ts_crc_version.h" 44 | 45 | #include "cfe_version.h" 46 | 47 | /* These headers are needed for CFE_FS_Header_t and CFE_TBL_File_Hdr_t, respectively. 48 | * This uses the OSAL definition of fixed-width types, even thought this tool 49 | * is not using OSAL itself. 50 | */ 51 | #include "common_types.h" 52 | #include "cfe_fs_extern_typedefs.h" 53 | #include "cfe_tbl_extern_typedefs.h" 54 | 55 | /* 56 | ** Function Prologue 57 | ** 58 | ** Function: CalculateCRC (originated from lro-cfe-4.2.1 delivery - 2/4/09) 59 | ** 60 | ** Purpose: Perform a CRC calculation on a range of memory. 61 | ** 62 | */ 63 | uint32 CalculateCRC(void *DataPtr, uint32 DataLength, uint32 InputCRC) 64 | { 65 | int32 i; 66 | int16 Index; 67 | int16 Crc = 0; 68 | uint8 *BufPtr; 69 | 70 | static const uint16 CrcTable[256] = { 71 | 72 | 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 73 | 0xC481, 0x0440, 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 74 | 0xC901, 0x09C0, 0x0880, 0xC841, 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, 0x1E00, 0xDEC1, 75 | 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, 76 | 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 77 | 0xF281, 0x3240, 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 78 | 0xFF01, 0x3FC0, 0x3E80, 0xFE41, 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, 0x2800, 0xE8C1, 79 | 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, 80 | 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 81 | 0x2080, 0xE041, 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, 0x6600, 0xA6C1, 0xA781, 0x6740, 82 | 0xA501, 0x65C0, 0x6480, 0xA441, 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, 0xAA01, 0x6AC0, 83 | 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, 84 | 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 85 | 0xB681, 0x7640, 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, 0x5000, 0x90C1, 0x9181, 0x5140, 86 | 0x9301, 0x53C0, 0x5280, 0x9241, 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, 0x9C01, 0x5CC0, 87 | 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, 88 | 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 89 | 0x4C80, 0x8C41, 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, 0x8201, 0x42C0, 0x4380, 0x8341, 90 | 0x4100, 0x81C1, 0x8081, 0x4040}; 91 | 92 | Crc = (int16)(0xFFFF & InputCRC); 93 | BufPtr = (uint8 *)DataPtr; 94 | 95 | for (i = 0; i < DataLength; i++, BufPtr++) 96 | { 97 | Index = ((Crc ^ *BufPtr) & 0x00FF); 98 | Crc = ((Crc >> 8) & 0x00FF) ^ CrcTable[Index]; 99 | } 100 | 101 | return Crc; 102 | } 103 | 104 | int main(int argc, char **argv) 105 | { 106 | ssize_t readSize; 107 | off_t skipSize = 0; 108 | ssize_t fileSize = 0; 109 | uint32 fileCRC = 0; 110 | int fd; 111 | char buffer[100]; 112 | off_t offsetReturn = 0; 113 | char VersionString[CFE_TS_CRC_CFG_MAX_VERSION_STR_LEN]; 114 | 115 | /* check for valid input */ 116 | if ((argc != 2) || (strncmp(argv[1], "--help", 100) == 0)) 117 | { 118 | snprintf(VersionString, CFE_TS_CRC_CFG_MAX_VERSION_STR_LEN, 119 | "%s %s %s (Codename %s), Last Official Release: %s %s)", 120 | "tblCRCTool", CFE_TS_CRC_REVISION == 0 ? "Development Build" : "Release", 121 | CFE_TS_CRC_VERSION, CFE_TS_CRC_BUILD_CODENAME, "tblCRCTool", CFE_TS_CRC_LAST_OFFICIAL); 122 | printf("%s\n", VersionString); 123 | printf("\nUsage: cfe_ts_crc [filename]\n"); 124 | exit(EXIT_FAILURE); 125 | } 126 | /* Set to skip the header (116 bytes) */ 127 | skipSize = sizeof(CFE_FS_Header_t) + sizeof(CFE_TBL_File_Hdr_t); 128 | 129 | /* open the input file if possible */ 130 | fd = open(argv[1], O_RDONLY); 131 | if (fd < 0) 132 | { 133 | printf("\ncfe_ts_crc error: can't open input file!\n"); 134 | perror(argv[1]); 135 | exit(EXIT_FAILURE); 136 | } 137 | /* seek past the number of bytes requested */ 138 | offsetReturn = lseek(fd, skipSize, SEEK_SET); 139 | if (offsetReturn != skipSize) 140 | { 141 | printf("\ncfe_ts_crc error: lseek failed!\n"); 142 | printf("%s\n", strerror(errno)); 143 | exit(EXIT_FAILURE); 144 | } 145 | 146 | /* read the input file 100 bytes at a time */ 147 | do 148 | { 149 | readSize = read(fd, buffer, sizeof(buffer)); 150 | if (readSize < 0) 151 | { 152 | printf("\ncfe_ts_crc error: file read failed!\n"); 153 | printf("%s\n", strerror(errno)); 154 | exit(EXIT_FAILURE); 155 | } 156 | fileCRC = CalculateCRC(buffer, readSize, fileCRC); 157 | fileSize += readSize; 158 | } while (readSize > 0); 159 | 160 | /* print the size/CRC results */ 161 | printf("\nTable File Name: %s\nTable Size: %ld Bytes\nExpected TS Validation CRC: " 162 | "0x%08lX\n\n", 163 | argv[1], (long)fileSize, (unsigned long)fileCRC); 164 | 165 | /* Close file and check*/ 166 | if (close(fd) != 0) 167 | { 168 | printf("\nerror: Cannot close file!\n"); 169 | printf("%s\n", strerror(errno)); 170 | exit(EXIT_FAILURE); 171 | } 172 | 173 | return 0; 174 | } 175 | -------------------------------------------------------------------------------- /cfe_ts_crc_version.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” 3 | * 4 | * Copyright (c) 2020 United States Government as represented by the 5 | * Administrator of the National Aeronautics and Space Administration. 6 | * All Rights Reserved. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 9 | * not use this file except in compliance with the License. You may obtain 10 | * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | ************************************************************************/ 18 | 19 | /*! @file 20 | * @brief Purpose: 21 | * @details Provide version identifiers for the ELF to cFE Table Converter. @n 22 | * See @ref cfsversions for version and build number and description 23 | * 24 | */ 25 | 26 | #ifndef CFE_TS_CRC_VERSION_H 27 | #define CFE_TS_CRC_VERSION_H 28 | 29 | /* 30 | * Development Build Macro Definitions 31 | */ 32 | #define CFE_TS_CRC_BUILD_NUMBER 2 /*!< @brief Number of commits since baseline */ 33 | #define CFE_TS_CRC_BUILD_BASELINE "equuleus-rc1" /*!< @brief Development Build: git tag that is the base for the current */ 34 | #define CFE_TS_CRC_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */ 35 | #define CFE_TS_CRC_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */ 36 | 37 | /* 38 | * Version Macros, see \ref cfsversions for definitions. 39 | */ 40 | #define CFE_TS_CRC_MAJOR_VERSION 1 /*!< @brief Major version number */ 41 | #define CFE_TS_CRC_MINOR_VERSION 1 /*!< @brief Minor version number */ 42 | #define CFE_TS_CRC_REVISION 0 /*!< @brief Revision version number. Value of 0 indicates a development version.*/ 43 | 44 | /** 45 | * @brief Last official release. 46 | */ 47 | #define CFE_TS_CRC_LAST_OFFICIAL "v3.1.0" 48 | 49 | /*! 50 | * @brief Mission revision. 51 | * 52 | * Reserved for mission use to denote patches/customizations as needed. 53 | * Values 1-254 are reserved for mission use to denote patches/customizations as needed. NOTE: Reserving 0 and 0xFF for 54 | * cFS open-source development use (pending resolution of nasa/cFS#440) 55 | */ 56 | #define CFE_TS_CRC_MISSION_REV 0xFF 57 | 58 | /* 59 | * Tools to construct version string 60 | */ 61 | #define CFE_TS_CRC_STR_HELPER(x) #x /*!< @brief Helper function to concatenate strings from integer macros */ 62 | #define CFE_TS_CRC_STR(x) \ 63 | CFE_TS_CRC_STR_HELPER(x) /*!< @brief Helper function to concatenate strings from integer macros */ 64 | 65 | /*! @brief Development Build Version Number. 66 | * @details Baseline git tag + Number of commits since baseline. @n 67 | * See @ref cfsversions for format differences between development and release versions. 68 | */ 69 | #define CFE_TS_CRC_VERSION CFE_TS_CRC_BUILD_BASELINE CFE_TS_CRC_STR(CFE_TS_CRC_BUILD_NUMBER) 70 | 71 | /** 72 | * @brief Max Version String length. 73 | * 74 | * Maximum length that a tblCRCTool version string can be. 75 | * 76 | */ 77 | #define CFE_TS_CRC_CFG_MAX_VERSION_STR_LEN 256 78 | 79 | #endif /* CFE_TS_CRC_VERSION_H */ 80 | --------------------------------------------------------------------------------