[chbot] Any ARM savvy people?
Robin Gilks
robin at gilks.org
Tue Oct 11 22:16:17 BST 2016
> Hi Robin
>
> I've done lots of work with ARM (probably coming up 20 years now). I've
> never seem something like that. Nor does it raise any aha! flags. ARM is
> generally a very well behaved 32 bit architecture.
>
> arm gcc is also generally a very good compiler with very few issues. All
> the phone sw in an iphone or android is built with it.
>
> If you're still stuck, feel free to send more specific questions my way.
>
> First things first... In general packing is not a good idea for two
> reasons:
>
> 1) Less people do packing therefore more likely to expose "interesting"
> behaviour.
> 2) Packing very seldom saves space.
>
> But that's probably not your problem...
>
> Start off by building with the following flags
> -Wall all warnings
> -Wextra even more warnings
> -Werror make all warnings into errors
> -O0 No optimisation for now.
>
> In general those will pull up any programmer daftness. Saved my bacon many
> times :-).
>
> -- Charles
>
Found it!!
Wall and Werror nailed it.
Immediately after loading the data from external Flash I was doing a CRC
of it to check its integrity. Simple enough, it looks like this:
crc = CRC_CCITT_INIT_VAL;
p = (uint8_t *)RegPointer;
for (i = 0; i < sizeof(RegisterFile); i++)
crc = updcrc_ccitt(*p, crc);
Trouble is, when you declare 'i' like this
uint8_t i;
its not obvious that the "i < sizeof(RegisterFile)" clause is always true
when the data size is > 256 due to the limitation of the size of 'i'.
Quite rightly the compiler made that condition always true by putting in
an infinite loop!!
So easy to miss a declaration half a page away! Now I know to check the
manipulations to all my references to the config data are not restricted
to 8 bits and to keep the extra warning flags in the Makefile!!
--
Robin Gilks
More information about the Chchrobotics
mailing list