-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Add tinyCBOR external library and apply mynewt upstream patch from intel/tinycbor#83 #5912
Add tinyCBOR external library and apply mynewt upstream patch from intel/tinycbor#83 #5912
Conversation
@vrahane I think we should also include integration with Kconfig and CMake in this PR. Otherwise this will not be usable by Zephyr modules. We cannot build with make because that does not work on Windows. Something like this: https://github.com/zephyrproject-rtos/zephyr/blob/master/ext/hal/nordic/CMakeLists.txt#L7 |
@vrahane in the first commit message, can you remove |
Codecov Report
@@ Coverage Diff @@
## master #5912 +/- ##
=======================================
Coverage 52.63% 52.63%
=======================================
Files 410 410
Lines 40041 40041
Branches 7779 7779
=======================================
Hits 21074 21074
Misses 15767 15767
Partials 3200 3200 Continue to review full report at Codecov.
|
I understand having the full repo makes it easier later to rebase, but I'm not sure we should include things like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should live in ext/lib/tinycbor
and not in ext/tinycbor
Should mynewt changes not first be upstreamed to intel/tinycbor before taking it in to zephyr repo? |
@vanwinkeljan they should, but they won't make it in time for Zephyr 1.11. This is a stopgap solution until @thiagomacieira merges those. |
I'll join zephyr-devel and ask questions. I want to have native support for |
@thiagomacieira thanks, although the work so far has been done by Mynewt developers. I'll ask them to join zephyr-devel as well. |
e034b7a
to
1cb6558
Compare
@carlescufi I have made changes as per the review and the builds are now successful as well. Thank you. |
@vrahane Cool! One thing, though. You need to use interactive rebase to edit the pull request history into a coherent set of patches, rather than addressing review with commits at the end of the series, like the "Make changes as per PR review" one that is present right now. Here is the workflow document: http://docs.zephyrproject.org/contribute/contribute_guidelines.html#contribution-workflow |
@mbolivar I generally prefer rebasing as well. The only issue here is that the first commit is the vanilla version of tinycbor, second applies the mynewt patch on top of it and the third one specifically adds Kconfig, changes directories and deletes git metadata files from the library. If the patch(second commit) were to be ever reverted, minimal changes would have to be made to the CMake files, Kconfig and menuconfig which is added by the third commit. Hence, the third commit. Maybe I should name it differently instead of just a PR review changes, Any thoughts appreciated ? |
@vrahane That is fine but you cannot name a commit "Make changes as per PR review". You need to name commits after what they contain. |
@vrahane also the removal of non-needed files should not really be in this 3rd commit. Those files should really never have been included in the first place, we can always trace back the diffs from the imported files to the next commit changes with the patch from the TinyCBOR upstream PR regardless of these files being included or not. In fact, we only need the diffs on the relevant files for Zephyr. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please just import the files we need to build the library and drop everything else? We should not include any of the CI, IDE, project scripts and such, those will just trigger all kind of violations when we do license scanning and IP management. Just keep the C and header files we need for building and drop everything else. Maybe later when we have better repository management we can import complete tree, but not now.
6ccce74
to
5eab55f
Compare
Thank you @nashif and @carlescufi for going through it. As per your reviews and zephyr policies, I have done the following:
|
@vrahane I think it would be cleaner if we did this in a slightly different way: Commit 1: Add the required TinyCBOR files only, without the 83 patch That said I am OK with merging this as-is if @nashif is as well |
@vrahane also can you please remove everything that is not required for building? Files like |
@vrahane Also please change the first commit so it only contains the |
@thiagomacieira do you have c based tests for tinycbor that we could adapt for Zephyr? All I can see in the tree are QT based tests |
Not yet, no. That's why I asked you last Friday for how to use Travis with Zephyr. I need to write a couple, though I will focus only on the Zephyr-specific code (yet to be written) that integrates with |
The TinyCBOR library is a small Concise Binary Object Representation (CBOR) encoder and decoder library, optimized for very fast operation with very small footprint. Origin: TinyCBOR License: MIT URL: https://github.com/intel/tinycbor Version: 0.5.0-beta1 commit: 497066ee87dd54341adaa1195bf15ad11ee33b20 Purpose: Introduction of TinyCBOR Maintained-by: External Signed-off-by: Vipul Rahane <vipulrahane@apache.org>
For a full description of changes see the commit message URL: https://github.com/zephyrproject-rtos/tinycbor/tree/zephyr Signed-off-by: Vipul Rahane <vipulrahane@apache.org>
7d44f5e
to
5c6cfd1
Compare
ext/lib/encoding/tinycbor/Kconfig
Outdated
|
||
config CBOR_ENCODER_NO_CHECK_USER | ||
bool | ||
prompt "No check user for cbor encoder" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better text: This option controls whether the CborEncoder checks whether the user passed valid arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a prompt message, hence you cannot put a long descriptive text there.
|
||
if TINYCBOR | ||
|
||
config CBOR_NO_DFLT_WRITER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe find a better name for this? At least get rid of the acronym.
I've been calling this the ability to encode to a linear buffer, as opposed to a net_buf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestion ?
ext/lib/encoding/tinycbor/Kconfig
Outdated
help | ||
This option enables floating point support. | ||
|
||
config CBOR_NO_HALF_FLOAT_TYPE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option should control the decode_half
function we've been having problems with too.
ext/lib/encoding/tinycbor/Kconfig
Outdated
help | ||
This option enables half float type support. | ||
|
||
config CBOR_WITHOUT_OPEN_MEMSTREAM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary, since there is no open_memstream support in Zephyr. It's a Glibc extension to POSIX, though I think Apple recently added to their libc too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting we should remove open_memstream.c altogether from the sources ?
ext/lib/encoding/tinycbor/Kconfig
Outdated
config CBOR_WITHOUT_OPEN_MEMSTREAM | ||
bool | ||
prompt "without open memstream" | ||
default n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? Note that the #define is negative ("without'), so this makes a double negative and you're saying with open_memstream
, which Zephyr doesn't have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this needs to get fixed. Thank you.
1779bab
to
2edd586
Compare
I discussed this with @ccollins476ad and we tested a few things out on the Zephyr-SDK. Based on the findings, I have made two commits above: 2635b19: ext: lib: tinycbor: make HF type conditional
2edd586: ext: lib: tinycbor: Fix build issues
ii. The following source file requires glibc which is not part of Zephyr and hence it is compiled
This solves most of the issues if not all. I have also changed prompt messages to make it more aesthetic. Please let me know if this works. I have kept it as separate commits so that everybody can take a look at it. I can further combine it into a single commit or maybe split it into multiple based on what feedback I get. |
The changes look good, with minor changes. I'd like the half and full-FP support changes in TinyCBOR. |
@vrahane Thanks for all the changes related to building with and without newlib. These commits that modify |
2edd586
to
13c0dcf
Compare
Sorry @SebastianBoe, did not mean to add you as a reviewer. |
13c0dcf
to
79e43fa
Compare
@carlescufi I have made the above half/full FP changes to the PR to https://github.com/zephyrproject-rtos/tinycbor/tree/zephyr after squashing. |
- Make half float encode/decode conditional - src/cborpretty.c, src/cbortojson.c and src/cborvalidation.c conditionally include math.h and half float type support - Conditionally include math.h in src/compilersupport_p.h to avoid newlib libc from getting compiled in - Conditionally compile src/cborparser_dup_string.c if newlib libc is compiled in Signed-off-by: Vipul Rahane <vipulrahane@apache.org>
Include both build an configuration files required to build TinyCBOR with Zephyr. Signed-off-by: Vipul Rahane <vipulrahane@apache.org>
79e43fa
to
d57e9bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now
@nashif mind taking another look at this? |
use of chained buffers functionality for tinycbor while it is in development on
https://github.com/intel/tinycbor
cbor_encoder_get_buffer_size() as part of cbor_buf_writer APIs
NULL compare at the end of string and moving it out of the iterate_string_chunks(). This is to
avoid buffer specific parser calls in the function
buffer which can be used for comparison in the parser tests instead of calculating the offset
make the encoder and parser use new function of encoder_writer and decoder_reader without
breaking backwards compatibility.
is because we want a default reader/writer to avoid API changes.
taking pointers as input parameters
have access to the buffer directly
grab a string that is divided in chunks which spans across multiple chained buffers
Fixes #3081
Signed-off-by: Vipul V Rahane vipul@runtime.io