On Thu, Mar 25, 2010 at 7:56 AM, Myles Watson mylesgw@gmail.com wrote:
It seems like others must have this problem of needing to force a binary blob into a struct.
Hi, I've only been following this at a distance. I assume this all happens after memory is turned on. Why not just have a function to fill the struct given the binary blob? I'm starting to worry about all the tricks people want to play with gcc.
Memory is on. The blob is in flash, and the first bit of the blob is the header with the length field.
We do a memcpy from flash to the struct, but first we have to cast it to a header so we can read out the length to copy. Gcc doesn't like the cast, so we just declare that we have the header stored in flash.
One way to solve it would be to copy the header first, then read the length and copy the rest...
It doesn't seem like there are any clean ways to do it. The way it's done now depends on the unsigned character array being 4-byte aligned.
Thanks, Myles