cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
junglert
Visitor
Visitor
503 Views
Registered: ‎10-18-2019

SDK: Integer Pointer dereference shifts value by four bytes

Hello,

I try to debug the mircoblaze raw API echo server in SDK on an Artix7. I send an uint32_t to the server and want to change it in the recv_callback function and send it back. Copy the payloadpointer to dataPtr works, but dereference it to payloadvalue shifts the value by four bytes.

I dont know how to solve this issue.

Thank you for your help!

Jonas

sdk_ptr_issue.jpg
0 Kudos
Reply
3 Replies
ibaie
Xilinx Employee
Xilinx Employee
409 Views
Registered: ‎10-06-2016

Hi @junglert 

Seems to be an issue with the pointer data types or so... taking a look to the code I don't really spot the issue :S

Can you display the memory content of payload? I would also do a quick test using the following code:

payloadvalue = *(uint32_t*) p -> payload;

Regards


Ibai
Don’t forget to reply, kudo, and accept as solution.
junglert
Visitor
Visitor
362 Views
Registered: ‎10-18-2019

Hi,

Thank You for your reply, with your mentioned code I get the same results as before.

I recognized in the memory, that the pointer always takes the bytevalue of the even 4 byte adresses. So when the pointer is on 0x38d76 he takes the uint32 value of the 0x38d74 adresses. Looks like an alignment issue on the microblaze, but SDK displays the correct values. Are there any settings for the microblades where i can adjust this, so the microblaze shifts the 4 bytes of the uint32 to the right order? 

sdk_screenshot.PNG
0 Kudos
Reply
junglert
Visitor
Visitor
351 Views
Registered: ‎10-18-2019

For now I solved this problem with this workaround:

uint32_t payloadValue;
uint16_t payloadLength;
uint32_t *tempStoragePtr, *payloadPtr;

payloadPtr = (uint32_t*) p -> payload;
payloadLength = p -> len;

tempStoragePtr = (uint32_t*) malloc(payloadLength);

memcpy(tempStoragePtr, payloadPtr, payloadLength);


payloadValue = *tempStoragePtr;

 

But it would be nice, if someone find a better solution.

0 Kudos
Reply