Skip to content

Multiple CRC Issues (multiple code copies, crc.h #define CRC16 means CRC32/CRC_CCITT functionality cannot be used, etc) #2637

Closed
@simonqhughes

Description

@simonqhughes

There are multiple issues with the CRC code available in mbedos as described in the following:

Issue 1: Multiple copies of crc.[ch] present in the tree, in the wrong locations

The crc.h/c platform independent code appears in platform dependent target subdirs e.g.:

mbed-os/hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K66F/TARGET_FRDM/crc.c
mbed-os/hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K66F/TARGET_FRDM/crc.h
mbed-os/hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_MCU_K64F/TARGET_FRDM/crc.c
mbed-os/hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_MCU_K64F/TARGET_FRDM/crc.h

The issues are:

  • The code should be located in a platform independent location e.g. hal/common.
  • There should only be 1 version of the code common to all platforms.

Issue 2: crc.h #define CRC16 means CRC32/CRC_CCITT functionality cannot be used

The following lines of code is present in crc.h:

/*
 * Select the CRC standard from the list that follows.
 */
#define CRC16

This means:

  • the CRC32 and CRC_CCITT implementations cannot be used
  • a command line -DCRC32 or -DCRC_CCITT does not override the default CRC16 behaviour

Issue 3: crc.h Interface does not allow clients to use CRC16 and CRC32 functionality within the same build.

  • Currently, K64F mbed_overrides.c::mbed_mac_address() uses crcSlow() to compute a hash for generating mac addresses.
  • all application code must use CRC16. e.g. the flash journal implementation on K64F requires a CRC32 implementation but crc.h/c is built for CRC16 for mbed_overrides.c::mbed_mac_address(), hence leading to duplicate code (flash journal will implement a crc32 implementation).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions