Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: Option to use zephyr CRC-16 implementation #84

Open
JordanYates opened this issue Jan 11, 2025 · 1 comment
Open

feature request: Option to use zephyr CRC-16 implementation #84

JordanYates opened this issue Jan 11, 2025 · 1 comment
Assignees

Comments

@JordanYates
Copy link

Zephyr already has a collection of CRC-16 implementations that can already be compiled into an application before Memfault is enabled.
Having a (potentially) duplicated CRC-16 implementation just for Memfault is a waste of ROM (>0.5kB in this case).

I see two options to enable this:

  1. An option to explicitly call Zephyrs implementation from the memfault port
  2. An option to exclude the memfault_crc16_ccitt_compute implementation entirely and allow the user to provide one

Note: #83 probably needs to be resolved before this to avoid causing much confusion.

@noahp
Copy link
Contributor

noahp commented Jan 13, 2025

Thanks for submitting this request @JordanYates ! We'll include an option to enable a user-provided implementation of memfault_crc16_ccitt_compute (renamed as memfault_crc16_compute as part of the changes for #83 ), which can be implemented like so using the Zephyr library version:

#include <zephyr/sys/crc.h>

uint16_t memfault_crc16_compute(uint16_t crc_initial_value, const void *data,
                                size_t data_len_bytes) {
  return crc16_itu_t(crc_initial_value, data, data_len_bytes);
}

Note that you can use #define MEMFAULT_CRC16_LOOKUP_TABLE_ENABLE 0 to use a smaller implementation in the Memfault SDK, that is close to the Zephyr library implementation in size (44 bytes / 38 bytes), at the expense of performance. However if you are already using crc16_itu_t in your application, we will support that use case in the next SDK release. Let us know if you need that support urgently, otherwise it will be scheduled for some time next week I think.

@noahp noahp self-assigned this Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants