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

Make use of DCT API? #195

Closed
vshymanskyy opened this issue Aug 4, 2023 · 31 comments
Closed

Make use of DCT API? #195

vshymanskyy opened this issue Aug 4, 2023 · 31 comments
Labels
enhancement New feature or request no-issue-activity pending It is a feature/bug-fix request, currently on hold

Comments

@vshymanskyy
Copy link

vshymanskyy commented Aug 4, 2023

I need to store some settings in the form of key-value pairs in the NVM (Flash).
Overall, I'm trying to get support for Ameba devices for my Preferences library.

One option I found is to use DCT:

// initial DCT
ret = dct_init(DCT_BEGIN_ADDR, MODULE_NUM, VARIABLE_NAME_SIZE, VARIABLE_VALUE_SIZE, 1, 0);
// register module
ret = dct_register_module(example_dct_module);
// open module
ret = dct_open_module(&dct_handle, example_dct_module);

However, looks like the DCT library is not linked, I'm getting:

undefined reference to `dct_init(unsigned long, unsigned short, unsigned short, unsigned short, unsigned char, unsigned char)'
collect2: error: ld returned 1 exit status

Another option is to use some kind of a File system (I see FATFS, but can it be used on the system flash?).

Also, to store any data in the flash, I need to define a dedicated region / partition in the flash memory.
What's the best practice to do that?

@xidameng please advise

@vshymanskyy
Copy link
Author

I overlooked the "C" linkage. It builds successfully like this:

extern "C" {
  #include <dct.h>
}

I also had to add "-I{ameba.sdkpath}/component/common/file_system/dct" to the compiler.ameba.c.include in platform.txt. It would be great if it was included by default.

Didn't test It yet. I need to define a dedicated region / partition in the flash memory.

@vshymanskyy
Copy link
Author

vshymanskyy commented Aug 4, 2023

So yeah, DCT actually works as a back-end for the Preferences library:

Preferences_Test/Preferences_Test.ino:142:test_bytes:PASS
Preferences_Test/Preferences_Test.ino:144:test_zero_bytes:PASS
Preferences_Test/Preferences_Test.ino:146:test_utf8_key:PASS
Preferences_Test/Preferences_Test.ino:147:test_utf8_value:PASS
Preferences_Test/Preferences_Test.ino:148:test_remove_key:PASS
Preferences_Test/Preferences_Test.ino:149:test_clear_namespace:PASS

@vshymanskyy
Copy link
Author

So, there are 2 questions left:

  • "-I{ameba.sdkpath}/component/common/file_system/dct" needs to be added to compiler.ameba.c.include in platform.txt.
  • I need to define the flash region for the DCT. I noticed that DCT only requires the start address during initialization, the size is not specified explicitly. What's the best practice to configure the DCT?

@S10143806H
Copy link
Contributor

S10143806H commented Aug 7, 2023

@vshymanskyy ,

The dct function is default wrapped in lib_dct.a under /variants/common_libs/, therefore, to compile dct successfully, you may add in "-I{ameba.sdkpath}/component/common/file_system/dct" in platform.txt

For the DCT configuration, please refer to our standard sdk example located at ambd_sdk\component\common\example\dct. (https://github.com/ambiot/ambd_sdk/tree/dev/component/common/example/dct)

Please do let us know if there are any other things that we could assist you with. And is there any chance that you could pull request this feature upon compilation is done? By the way, xidameng has already left the team.

Thank you for your support.

@vshymanskyy
Copy link
Author

The Device Configuration Table support was added and pushed to GitHub.
@S10143806H would you consider this:

  1. Adding the required include path to the platform.txt
  2. Adding the Preferneces library to your library package by default? https://github.com/vshymanskyy/Preferences

@vshymanskyy
Copy link
Author

vshymanskyy commented Aug 8, 2023

@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@vshymanskyy
Copy link
Author

@M-ichae-l @xidameng let me know if this is something you would consider

@M-ichae-l
Copy link
Contributor

M-ichae-l commented Aug 30, 2023

@vshymanskyy
Thanks for bring it out. As we have discovered, there is no example for DCT demo at arduino level Arduino_package/hardware/libraries

But there is a lib_dct.a at compilations process. So as you have provided the Preference. Why not just do the Pull Request, as a submodule of the SDK?

  • you can still maintain your own code at your repo
  • it can be a part of the ambd_arduino SDK, we will give you the credit

@S10143806H
Copy link
Contributor

The Device Configuration Table support was added and pushed to GitHub. @S10143806H would you consider this:

  1. Adding the required include path to the platform.txt
  2. Adding the Preferneces library to your library package by default? https://github.com/vshymanskyy/Preferences

Hi @vshymanskyy ,
Sorry for the late reply.

  • Could you please define what is Device Configuration Table referring to? I could not find any related code in your repo. Thanks
  1. As answered previously, the line including lib_dct.a have exited in platform.txt: https://github.com/ambiot/ambd_arduino/blob/8e9512a7ac1372b6cc123127da36324f8d0002a2/Arduino_package/hardware/platform.txt#L83C1-L83C1

  2. Yes, you could go ahead with Pull Request your examples into our SDK upon verification. I have tested your examples but both of them seems could not compile successfully in AmebaD Arduino environment.
    image
    image

Therefore, maybe could you please clarify what are things that I could do to help you with your Pull Request contribution. And we could proceed to review your codes. Thank you.

@vshymanskyy
Copy link
Author

vshymanskyy commented Aug 31, 2023

@vshymanskyy
Copy link
Author

Updated one of the examples so it doesn't rely on Print::printf(): https://github.com/vshymanskyy/Preferences/blob/main/examples/StartCounter/StartCounter.ino

@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions
Copy link

This issue was closed because it has been inactive for 7 days since being marked as stale.

@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@vshymanskyy
Copy link
Author

will get to it soon

@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@M-ichae-l M-ichae-l added enhancement New feature or request pending It is a feature/bug-fix request, currently on hold and removed no-issue-activity labels Oct 30, 2023
Copy link

This issue is stale because it has been open for 14 days with no activity.

@vshymanskyy
Copy link
Author

still not there;) sorry!

@M-ichae-l
Copy link
Contributor

M-ichae-l commented Nov 30, 2023

@vshymanskyy
Thanks for the patient, I have create a submodule of your repo main branch. #5a4b8b79ede9ec2502da29b34cd89e65749bfad6
You may want to review the update. If any update or debug I will help to merge.
However, Please note that there is no early release version for current SDK with your submodule. Once your review is one, I will help to create a early release version SDK.

Copy link

This issue is stale because it has been open for 14 days with no activity.

@vshymanskyy
Copy link
Author

I'm alive!

@M-ichae-l
Copy link
Contributor

@vshymanskyy
Could you review about the submodule system for the example you have ported?

Copy link

This issue is stale because it has been open for 14 days with no activity.

@vshymanskyy
Copy link
Author

@M-ichae-l please elaborate, Didn't get your question

Copy link

This issue is stale because it has been open for 14 days with no activity.

@vshymanskyy
Copy link
Author

@M-ichae-l ?

@M-ichae-l
Copy link
Contributor

M-ichae-l commented Jan 23, 2024

@vshymanskyy
Can you review the submodule here https://github.com/ambiot/ambd_arduino/tree/dev/Arduino_package/hardware/libraries
2024-1-23_16-1-31

If there is no further issue, we will add your repo into the SDK by submodule.

Copy link

github-actions bot commented Feb 6, 2024

This issue is stale because it has been open for 14 days with no activity.

@vshymanskyy
Copy link
Author

vshymanskyy commented Feb 9, 2024

ok, i should be able to verify it during the weekend.
sorry for a delay, the project that used it was put on hold, so i need to setup the environment again.
this holds back any progress

@vshymanskyy
Copy link
Author

Looks like everything is correct. Closing the ticket.
Thanks for all your help and support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request no-issue-activity pending It is a feature/bug-fix request, currently on hold
Projects
None yet
Development

No branches or pull requests

3 participants