Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oscilloscope test binary is broken #9

Open
CounterCycle opened this issue Oct 17, 2023 · 0 comments
Open

Oscilloscope test binary is broken #9

CounterCycle opened this issue Oct 17, 2023 · 0 comments

Comments

@CounterCycle
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant