diff options
-rw-r--r-- | parser.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -1274,8 +1274,25 @@ static int Go_Float_eprom51(gchar** response, int channel, char *loc_string,char return OK; break; - case query_param: - return query_float(response, *(float *)(&globals.Flash.flash_start + eprom_loc)); + case query_param:{ + // The basic issue here is that this pointer isn't aligned. Which + // should actually be a problem as ARMv7 has unaligned access support + // and it's hardcoded to be on.. the issue is that not all instructions + // can do unaliged accesses and the previous code generated one of those + // instructions. The kernel traps the access and kills the process. + // You should see something like this in dmesg: + // [494223.471575] Alignment trap: not handling instruction edd37a00 at [<00011d12>] + // [494223.479380] Unhandled fault: alignment exception (0x001) at 0x00050d66 + // + // I use memcpy here to copy the variable out into a temp + // variable on the stack which is aligned. + // There are probably other bits of code that will trigger this because of + // the use of offsets into the struct.. It might be an idea to write some macros + // for pushing and pulling bits from the struct. + float temp; + memcpy(&temp, (float *)(&globals.Flash.flash_start + eprom_loc),sizeof(float)); + return query_float(response, temp); + } break; default: |