-
Notifications
You must be signed in to change notification settings - Fork 208
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
An anonymous union can only have non-static data members #43
Comments
The normal reason for this is that you also need to specify the HAL you’re using by defining ATCA_HAL_I2C globally (e.g. add '-DATCA_HAL_I2C' to your cflags) |
Thanks! That gives me undefined references. I guess I missed something else? This is unrelated to the C11 issue right? |
Yes. I understand the c11 vs c++ issue. You have to include the HAL driver file(s) into your build as well. The convention is hal_platform_timer.c and hal_platform_i2c.c etc. What is the platform you’re using? |
what do you mean with platform? |
Ah okay. https://github.com/MicrochipTech/cryptoauthlib/blob/master/lib/CMakeLists.txt is a good reference for everything that is required for building the library. This file will properly build a .so for Linux (cmake does need to be invoked with -DATCA_HAL_I2C=on however) |
I did set that in cmake :) GCC 7.3.1 |
Oh boy. Okay so I haven’t attempted a pi cross compile. I’d have to look up some cmake cross compile stuff. But yes it does appear to be detecting the Windows environment rather than the target. |
I unset WIN32 and APPLE and explicitly set UNIX but there i no change. I am using VisualGDB and I have running projects with that toolchain so in general this is not a problem. |
What are the undefined references? Are they things like hal_i2c_send or is it failing to link against libraries like udev? (That part can be removed from the CMakeLists.txt file. In our next release this will be taken care of automatically but for the moment it tries to link to that always) |
It is things like hal_i2c_send. udev should not be the problem... here the command by cmake: cryptoauthlib/lib/libcryptoauth.so(0): error : undefined reference to hal_i2c_sleep |
Sry to ask, but I cannot find these functions anywhere.. Do you know what I am missing here? EDIT1: Found that I had to do Now I get a segmentation fault again here:
|
I found the error. The Hardware Abstraction Layer could not connect because the default setting of the bus for the i2c bus
I can now get the revision, the serial and random numbers from the chip with the following:
Should this be documented somewhere else? |
This is an area that I think falls less into documentation and more in the area of needing to fail better both at compile (when no HAL is specified) and runtime (when invalid bus/drivers are used). We are working on some improvements to the HAL layers that should be able to pass back better error codes instead of failing in this way. We've done quite a bit of this with the PKCS11 implementation and documentation (as it's primarily driven by Raspberry Pi and Yocto builds) but we have not made that logic generic yet. |
The answer to this (which closed the issue) does not actually address the actual issue (anonymous structs/unions error). This is still an issue. I had to work around this by overriding the atca_iface.h header file with a solution like the OP mentioned. (I did this because of wanting to leave the upstream module intact, since it is for a contribution/integration for another project. It consumes it as a git submodule.) |
I am trying to compile a c++ program with the cryptoauthlib and I get this (title) error in the atca_iface.h. I think this is a c11 feature, which is not compatible with c++:
All named structs in the unnamed union throw the error.
I changed these structs to unnamed structs and it compiles, but I unfortunately get a segmentation fault when calling the init function
ATCA_STATUS atinit(ATCAIface ca_iface);
... I do not call this function directly. I callatcab_init(&cfg_ateccx08a_i2c_default);
Is there a way to use this without modifying the interface like I did and why do I get the segmentation fault?
My hardwaresetup is a CM3 with a ATECC608a connected to I2C 1. The interface is up and I can query it. Do I need to modify the default interface to the correct device type and the correct I2C interface? When I do so I get the same segmentation fault.
Thanks in advance! Greetings i7clock
The text was updated successfully, but these errors were encountered: