cancel
Showing results for 
Search instead for 
Did you mean: 

Ymodem protocole

DCtech
Associate II

I am looking this source codes to use Ymodem protocole,

https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM324xG_EVAL/Applications/IAP/IAP_Main/inc/ymodem.h

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

0693W00000JP5OOQA1.png

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.