Hello,
I'm having some problems with the generic CC3000 driver.
I am using a processor that has a 16 bit memory access. Because of this, any 16 bit value (like an unsigned short) must be aligned to a 16 bit address.
For instance this struct is 4 bytes, 2 chars, and 1 short. But my compiler must align the short to a 16 bit address. It also pads out a struct to even number of bytes.
So, for me, this struct is sizeof 6. This really seems to make everything not work. I don't think I can get my compiler to pack the struct do to the HW design.
Has anyone reworked the code to avoid "sizeof"?
typedef struct _hci_cmnd_hdr_t
{
unsigned char ucType;
unsigned short usOpcode;
unsigned char ucLength;
} hci_cmnd_hdr_t;
Thanks,
Tim
No experience with your platform. Noticed from your other thread that you are using a MSP430. From posts that I have seen, packed structures are supported the IAR and later versions of the TI compiler. IAR uses pragma PACK. TI's uses GNU style pack sttributes on the structure. GNU support must be enabled.
I'm using a Freescale 56F8366 Digital Signal Controller.
Each memory address is 16 bits. They allow for byte addressing to put 2 8 bit values into a 16 bit memory location, but a 16 bit value must be aligned. So any struct that has an odd number of 8 bit values, followed by a 16 bit value will require a padding byte between them to make sure the 16 bit value is aligned.
The generic driver code attempts to send a struct by casting it to a unsigned char * and assumes that the structure is laid out in memory without any padding. A recieve also attempts to cast a unsigned char * to a pointer to a structure and assumes the bytes will fall into place.
When I try it, my sizeof call returns a different value because of the padding. This causes extra bytes to be sent and I assume the LS Research board doesn't know what to do with it. Additionally, when I recieve a packet, the cast to a structure doesn't work and therefore the values in the structure don't make sense. And then of course things don't work.
This could be solved by properly packing and unpacking the unsigned char buffers to and from the structures instead of blindly casting them and hoping the data is in the right place and order.
Unless someone can tell me otherwise I think I am looking at either rewriting the driver, or looking elsewhere for a simular solution.
Sounds like you're got firm understanding of the problem. I guess you could try asking Freescale about compiler options. It's more than just alignment. There is always the possibility of an endianess problem. Rewriting the driver for manual unpacking and packing would make the driver easier to port to other processors. Avoiding unaligned accesses also makes for faster code. Some justification.
Yup, you're exactly right.
I guess I would have expected something offered up as a "Platform Independent WiFi Driver" to take some of these things into account.
I'm hoping someone from TI can point me towards something that I missed.
Hi Tim,
In our upcoming release we've changed the code to use "streaming" macros in each location that transfers data to\ from the CC3000 to the MCU.Basically coping the data byte by byte.I believe that this change will solve your porting issue. Sorry for the trouble you've been having so far.
The release is expected any day now.
Thanks,Alon.S
Thanks Alon,
It sounds like the new code would be helpful.
Is there an actualy release day? Or is it possible to get a hold of it prior to release. I'm in the process of evaulating this product, so most of the work I am doing will never make it to an end user.
No date yet, please ping the forum by e/o the week, I hope to have more information.
Hi Alon,
Just checking in on this one to see if the updated code is available yet.
Thanks again!
Paul
Any update on the timing of this new software?
Not yet, sorry.
Any esitmated date?
Is there someone else I can contact?
If not, I will look elsewhere for a wifi solution.
Sorry for the delayed response.We will release a new package by e/o the month.
Any update on this?
Tim, the new releases is available now and is posted here:
http://processors.wiki.ti.com/index.php/CC3000_Wi-Fi_Downloads#CC3000_Wi-Fi_Downloads
----------------------------------------------------------------------------------------------------------Please click the Verify Answer button on this post if it answers your question.----------------------------------------------------------------------------------------------------------