Skip to content

Oscilloscope test binary is broken #9

@CounterCycle

Description

@CounterCycle

From looking at the uploaded source, I see the oscilloscope binary has some changes to introduce canaries around DMA buffers.

One such case being here where the buffer is defined as:

struct Points 
{ 
uint32_t canary1[64];
uint32_t dataPoints32[maxSamples / 2];
uint32_t canary2[64]; 
};

Points sPoints;
uint32_t *dataPoints32 = (uint32_t *)&sPoints.dataPoints32;

While the original code defines the array as:

uint32_t dataPoints32[maxSamples / 2];

But this changes the type of the dataPoints32 global variable from an array to a pointer. When taking the address and casting to a uint16_t* here this causes a problem.

uint16_t *dataPoints = (uint16_t *)&dataPoints32;

Rather than taking the address of an array, this takes the address of a pointer. Instead of the intended cast from uint32_t* to uint16_t*, it is casting from a uint32_t** to a uint16_t*

Therefore, the dataPoints pointer does not point to the DMA buffer, and the attempts to use it lead to accessing random global variables.

Also, the maxSamples variable in the uploaded code is set to 64, which should be 128 bytes for the dataPoints32 buffer, but the precompiled binary available in this repo does not match this, instead containing a 4096 byte buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions