Data Bus Error - General Exception while transferring data over Bluetooth

I am transferring Hex Records over Bluetooth and saving the data in external flash memory and keep getting an exception when transferring large files.

I have a small test file that flashes an Led for quick tests (about 374 hex records) and do not have a problem with this but a normal update will use about 40% of the flash memory of a PIC32MX795F512L.

The exception occurs at different download percentage points and so never in the same place.

The address from the exception points to a stack overflow in the function

void vTaskSwitchContext( void )

I am trying to figure out what to do here.

You should set configCHECK_FOR_STACK_OVERFLOW to e.g. 2 in your FreeRTOSConfig.h. This might help (it’s not a magic silver bullet - stack overflows are really hard to detect by the running SW itself) to nail the actual task causing the stack overflow. Then try to increase the stack size of that task. If this doesn’t help there might be real bugs in your software stack e.g. an unwanted recursion etc.
Then good luck finding them :wink:

The define configCHECK_FOR_STACK_OVERFLOW was originally set to 3 and always stops at the same instruction in the same function.

Changing the define configCHECK_FOR_STACK_OVERFLOW to 2 and re-testing stops at the same instruction but in the function “void vListInsertEnd(…)”

The instruction is LW V1, 0(V0).

Although this happens at different percentage points in the download process the exception is always on the same instruction in the same function depending on what constant the define is set to.

I would have to refamiliarise myself with MIPS assembly code, but that instruction seems to be loading a value from a zero byte offset from whatever address is in V0. So I assume V0 is pointing to an invalid address. If you look at the C code that is running at that point, rather than the assembly, you will probably see what is writing to an invalid address and why (for example, have you incremented off the end of valid memory?).

Thank you for your help.
I am narrowing down the problem slowly.
I will let you know when I do.


Databus errors on the PIC32 are typically due to accessing an out of bounds address. As Richard said, it is possible that your download code is trying to access an address outside of the valid RAM space.

1 Like