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

HAL wiring api calls to access exflash read/write functions #2540

Merged
merged 2 commits into from
Sep 22, 2022

Conversation

keeramis
Copy link
Contributor

@keeramis keeramis commented Sep 22, 2022

Description

Adds hal wiring API calls to access OTP

Solution

Make the relevant functions available over wiring protected by PARTICLE_USE_UNSTABLE_API

Steps to Test

Example App

#define PARTICLE_USE_UNSTABLE_API
#include "storage_hal.h"

#include "Particle.h"
SYSTEM_MODE(MANUAL)
const uintptr_t NCP_ID_OTP_ADDRESS = 0x00000020;

void setup() {
    uint8_t ncpId = 0;
    int r = hal_storage_read(HAL_STORAGE_ID_OTP, NCP_ID_OTP_ADDRESS, &ncpId, sizeof(ncpId));
    Log.info("Read result: %d / %u == %x", r, ncpId, ncpId);

    ncpId = 0x65;
    r = hal_storage_write(HAL_STORAGE_ID_OTP, NCP_ID_OTP_ADDRESS, &ncpId, sizeof(ncpId));
    Log.info("Write result: %d", r);

    r = hal_storage_read(HAL_STORAGE_ID_OTP, NCP_ID_OTP_ADDRESS, &ncpId, sizeof(ncpId));
    Log.info("Read result after writing: %d / %u == %x", r, ncpId, ncpId);
}

void loop() {
}

Result on P2 (will be similar on trackerM)

0000002148 [app] INFO: Read result: 1 / 255 == ff
0000002154 [app] INFO: Write result: 1
0000002157 [app] INFO: Read result after writing: 1 / 101 == 65

References

SC-108936


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

hal/inc/hal_dynalib_storage.h Outdated Show resolved Hide resolved
@keeramis keeramis marked this pull request as ready for review September 22, 2022 19:28
@keeramis keeramis merged commit fd7593f into develop Sep 22, 2022
@keeramis keeramis deleted the feature/exflash_wiring_api branch September 22, 2022 19:29
@mohitbhoite
Copy link
Contributor

mohitbhoite commented Sep 28, 2022

As a side, I had to use SYSTEM_MODE(MANUAL) otherwise the setup won't execute on unprovisioned devices, i.e., the new Tracker M boards.

@keeramis
Copy link
Contributor Author

@mohitbhoite thanks for pointing that out. I will change the example app accordingly.

@scott-brust scott-brust added this to the 5.1.0 milestone Sep 28, 2022
scott-brust pushed a commit that referenced this pull request Oct 12, 2022
HAL wiring api calls to access exflash read/write functions
@scott-brust scott-brust mentioned this pull request Oct 17, 2022
@scott-brust scott-brust mentioned this pull request Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants