.xml file transfer using THREAD protocol

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

.xml file transfer using THREAD protocol

Jump to solution
1,877 Views
sivatejareddyva
Contributor III

Hello,

i am trying to push an xml file from end device to router eligible device. Is it a good idea? should i fragment the data ?

Regards,

Siva

Labels (1)
Tags (1)
1 Solution
1,481 Views
Alexandru-Lilia
NXP Employee
NXP Employee

Hello Siva,

Glad to hear you have been progressing with your application.

Yes, Test Tool breaks the file into fragments. Take a look at the following screenshot:

ss_log_ota.jpg

What I've highlighted are the initial bytes that were send when I've initiated the transfer of two different files. The first one was too large for Test Tool (1.2 MB) and broke after the two chunks sent, and the second successfully sent the file with, by adding FF padding to multiple of 1 KB I believe.

Observations:

  • Test Tool OTA transfer was not created for regular file transfers; for example it doesn't work for big files (at 1.2 MB it cracked for me)
  • you should transmit the size beforehand so that you would know how many bytes you will need: it seems that first 66 bytes (first chunk and 2 bytes from chunk 2) are filled with information about image
  • don't forget to add the OTA bootloader on the client (even though you will not use it to rewrite the image, it seems that it OTA client isn't working without it);btldr.jpg
  • after I gave some thought to OTA transfer, I came to the conclusion that the other approach, with CoAP messages exchange, is better; even though there is more work to do, you can control exactly how you want to send the file;

Best of luck,

Lilian

View solution in original post

10 Replies
1,481 Views
saleem_kala-janssen
NXP Apps Support
NXP Apps Support

Hi sivatejareddyvangimalla‌,

if you are happy with Lilian's answer can you please mark this question as answered?

Thanks - and feel free to let us know how we can support you.

Best regards,

Saleem

0 Kudos
1,482 Views
Alexandru-Lilia
NXP Employee
NXP Employee

Hello Siva,

Glad to hear you have been progressing with your application.

Yes, Test Tool breaks the file into fragments. Take a look at the following screenshot:

ss_log_ota.jpg

What I've highlighted are the initial bytes that were send when I've initiated the transfer of two different files. The first one was too large for Test Tool (1.2 MB) and broke after the two chunks sent, and the second successfully sent the file with, by adding FF padding to multiple of 1 KB I believe.

Observations:

  • Test Tool OTA transfer was not created for regular file transfers; for example it doesn't work for big files (at 1.2 MB it cracked for me)
  • you should transmit the size beforehand so that you would know how many bytes you will need: it seems that first 66 bytes (first chunk and 2 bytes from chunk 2) are filled with information about image
  • don't forget to add the OTA bootloader on the client (even though you will not use it to rewrite the image, it seems that it OTA client isn't working without it);btldr.jpg
  • after I gave some thought to OTA transfer, I came to the conclusion that the other approach, with CoAP messages exchange, is better; even though there is more work to do, you can control exactly how you want to send the file;

Best of luck,

Lilian

1,481 Views
sivatejareddyva
Contributor III

Hello Lillian,

Please look at the image below 

pastedImage_1.png

I have generated a .bin out of my .xml and started OTA with out looking at the register address which has crashed the client as expected. I think i can flash it with original.

Is there any information about setting up new register address ? can Test tool help in modifying that ? 

if it is possible, how do i read the transferred data on the client side ?

Regards,

Siva   

0 Kudos
1,481 Views
Alexandru-Lilia
NXP Employee
NXP Employee

Hi Siva,

Is there any information about setting up new register address ? can Test tool help in modifying that ? 

What you encountered is not a matter of Test Tool configuration, but of the application you have on the client. What happened is that you didn't instruct the application what to do with the received chunk. By default, as mentioned in my previous comment, the function called for the chunk is "OTA_PushImageChunk", which does the following: "Places the next image chunk into the external FLASH. The CRC will not be computed." (extracted from its description). Here is where you add your function that will send on serial line the chunk to the computer.

Regards,

Lilian

1,481 Views
Alexandru-Lilia
NXP Employee
NXP Employee

Hello Siva,

should i fragment the data ?

Yes, the data should be fragmented in 1280 byte chunks, given that Thread uses IPv6. Take a look at this resource for clarification.

i am trying to push an xml file from end device to router eligible device. Is it a good idea?

Yes, Thread protocol is often used for such tasks.

A suggestion I want to give you, look how an OTA transfer is made, which basically does what you want to do, it reads a firmware and sends it to another device, the difference here being the location where the data is stored.

Let me know if I answered your questions and feel free to ask more if you need help.

All the best,

Lilian

0 Kudos
1,481 Views
sivatejareddyva
Contributor III

Hello Lilian,

Thank you for replying.

I understood that data needs to be fragmented. But, i am currently using Router eligible device and end device demos on two KW41Z. 

My application would be transferring an .xml file from end device to router eligible device. 

Will i have to have a companion like K64F ?

Thank you,

Siva   

0 Kudos
1,481 Views
Alexandru-Lilia
NXP Employee
NXP Employee

Hello again,

My application would be transferring an .xml file from end device to router eligible device. 

The two KW41Z are enough to transfer the file.

Will i have to have a companion like K64F ?

It depends on what you want to do with the file, but just for passing the file from one device to another the two KW41Z are enough. 

If you want and if you are allowed, you can tell me more about what you are trying to do with this transfer and I will help you how I can.

Regards,

Lilian

1,481 Views
sivatejareddyva
Contributor III

Hello Lilian,

Here is what i am trying to do,

I am trying to transfer a log file (.xml) using THREAD from one computer to another. To prove this, i may have to show that transfer of  .xml is possible using THREAD. Based on your replies, it is very evident that transferring .xml is very similar to OTA update where i may have to choose different registers to store the fragmented .xml (i believe that it is converted into binary before fragmenting). 

I would like to take your suggestion regarding how to start with it.

Thankyou,

Siva

0 Kudos
1,481 Views
Alexandru-Lilia
NXP Employee
NXP Employee

Hi Siva,

If you want to use the OTA approach you have to modify "OTA_PushImageChunk" function call from "OtaClient_UpgradeImage" function, found in *sdk_folder*\middleware\wireless\nwk_ip_1.2.5\examples\common\app_ota_client.c file.

Your function replacement should take the chunk and send it on serial to the destination computer. The function that helps you do this is "THCI_transmitPayload", found in *sdk_folder*\middleware\wireless\nwk_ip_1.2.5\base\thci\thci.c. Define a new OpCode in "nwkOpCode_t" enum found in *sdk_folder*\middleware\wireless\nwk_ip_1.2.5\base\interface\thci.h, so that you would know what kind of message you will get.

Now you have to reassemble the chunks into the file.xml on the destination computer.

Observations:

  • make sure that you have in the project THREAD_USE_THCI enabled on both, the server and the client. (found in .\middleware\wireless\nwk_ip_1.2.5\examples\reed_ota_client\config\config.h)
  • you should use "reed_ota_client" from the SDK to receive the file and "hcd_ota_server" to transfer it. More informations about OTA transfer in *sdk_folder*\docs\wireless\Thread\Kinetis Thread Stack Over-the-Air (OTA) Firmware Update User's Guide.pdf

Another approach would be to send COAP messages. Requirements and observations:

  • both devices should be host_controlled_device (not necessary, but recommended)
  • you can simulate the transmission of chunks with TestTool for debug. See the picture attached bellow. You should create URI path for this type of messages, (name it as you want, e.g. "/xml") and use it when you initialize the COAP instance (see function "APP_SendLedCommand" from *sdk_fldr*\middleware\wireless\nwk_ip_1.2.5\examples\reed_ota_client\src\router_eligible_device_app_ota_client.c so you will make and idea how your function should look like); coap_send.jpg
  • now the continuation is similar to the OTA approach; send on the serial the chunks and reassemble them on the computer, see the details above

 

I hope the information I provided will be helpful.

Regards,

Lilian

1,481 Views
sivatejareddyva
Contributor III

Hey Lilian,

The two approaches really look awesome. 

I have worked on coAP transactions and was able to create my own uri path for an external analog sensor which was very interesting. I believe that i will need to perform more than one coAP transaction for one complete transfer of file. And so, i would choose the OTA approach and modify the address to store the chunks and transfer it serially to my client. 

One more question out of my curiosity. Is fragmentation not a part of this operation ? Looks like we are dealing with chunks, but not on how we got them from original .xml file. 

Regards,

Siva

0 Kudos