2022-02-08 10:14 PM
I am looking this source codes to use Ymodem protocole,
But I've a question about that,
Line 65 says to us as in below:
/* /-------- Packet in IAP memory ------------------------------------------\
* | 0 | 1 | 2 | 3 | 4 | ... | n+4 | n+5 | n+6 |
* |------------------------------------------------------------------------|
* | unused | start | number | !num | data[0] | ... | data[n] | crc0 | crc1 |
* \------------------------------------------------------------------------/
* the first byte is left unused for memory alignment reasons
According to this informaton PACKET_DATA_INDEX define 4. But I dont understand this because in the Ymodem includes data in 3th byte, why we choose the 4th byte or SOH is the 0th index of the frame, why we get this as a 1
Solved! Go to Solution.
2022-02-09 05:55 AM
OK, that's a little confusing, but it's actually also mentioned in the comment:
* the first byte is left unused for memory alignment reasons
With Cortex-M, the memory alignment is 32 bits, i.e. 4 bytes. So if the 3-bytes header block starts from byte 1, you can start with the data exactly at a double-word boundary. In this respect, byte 0 is simply ignored and the Ymodem header starts from byte 1. That's why the description of byte 0 is "unused".
Does it answer your question?
If the problem is resolved, please mark this topic as answered by selecting Select as best. This will help other users find that answer faster.
/Peter
2022-02-09 05:55 AM
OK, that's a little confusing, but it's actually also mentioned in the comment:
* the first byte is left unused for memory alignment reasons
With Cortex-M, the memory alignment is 32 bits, i.e. 4 bytes. So if the 3-bytes header block starts from byte 1, you can start with the data exactly at a double-word boundary. In this respect, byte 0 is simply ignored and the Ymodem header starts from byte 1. That's why the description of byte 0 is "unused".
Does it answer your question?
If the problem is resolved, please mark this topic as answered by selecting Select as best. This will help other users find that answer faster.
/Peter