nasa / fprime

F´ - A flight software and embedded systems framework
https://fprime.jpl.nasa.gov
Apache License 2.0
10.1k stars 1.32k forks source link

Component support for 32-bit systems #3003

Open ethancheez opened 3 weeks ago

ethancheez commented 3 weeks ago
F´ Version v3.5.0
Affected Component Svc.SystemResources, Svc.DpCatalog, Svc.DpWriter, Svc.DpManager, Svc.FileManager

Problem Description

On 32-bit systems, the components listed above implement 64-bit types (U64)

Context / Environment

Operating System: Linux
CPU Architecture: x86_64
Platform: Linux-4.4.0-22621-Microsoft-x86_64-with-glibc2.39
Python version: 3.12.3
CMake version: 3.30.5
Pip version: 24.0
Pip packages:
    fprime-tools==3.5.0
    fprime-gds==3.5.0
    fprime-fpp-*==2.2.0

How to Reproduce

When these macros are set:

#define FW_HAS_64_BIT    0 //!< Architecture supports 64 bit integers
#define FW_HAS_32_BIT    1 //!< Architecture supports 32 bit integers
#define FW_HAS_16_BIT    1 //!< Architecture supports 16 bit integers
#define FW_HAS_F64       0 //!< Architecture supports 64 bit floating point numbers

Expected Behavior

Check if architecture supports FW_HAS_64_BIT, use U64. Otherwise, use U32.

Is it possible to configure your project so that you only include the Svc components only if they are included in your instances.fpp file? i.e. My project instances.fpp does not use Svc.SystemResources, but the project still continues to build Svc.SystemResources which results in the U64 undefined error.

I can use:

set_target_properties(Svc_SystemResources PROPERTIES EXCLUDE_FROM_ALL TRUE)

But was wondering if there was a way to not build those components without inputting this line.

ReggieMarr commented 2 weeks ago

I think this is a good use case to push the development of displayable abstract types. I was playing with this and I think rather than hardcoding a whole bunch of core types using a pattern like this might be more flexible for a wider range of platforms:

    # type SYSTEM_MAX_INT
    struct MEMORY_USAGE_S {
      TOTAL: FwSizeType
      USED: FwSizeType
      NV_TOTAL: FwSizeType
      NV_FREE: FwSizeType
    }

    @ Total system memory usage in KB
    telemetry MEMORY_USAGE: MEMORY_USAGE_S id 0

    @ System's CPU Percentage
    constant NUM_CORES = 15
    struct CPU_USAGE_S {
      AVG: F32,
      CORE: [NUM_CORES] F32
    }
    telemetry CPU_USAGE: CPU_USAGE_S id 4
LeStarch commented 1 day ago

@ethancheez if you build in the deployment directory, it should only build components used. If you build in the root directory, you must specifically exclude these components.

A possible better version would be to use restrict_platforms(FPRIME_HAS_INTEGER64) and add that to platforms, but this is a further future change.