• Support
  • Articles
  • Resources
  • Products

Automating firmware upgrade/transfer using Tera Term ymodem interface.

Moderator: boris

6 postsPage 1 of 1

yogeshk
Newbie

Posts:
6
Joined: Sat May 06, 2017 5:35 am
by yogeshk » Sat May 06, 2017 5:18 pm
I was wondering if I can get some advice on how best to achieve the same with a Macro, that I can do via the Tera Term UI to transfer fimrware to a micro controller using the ymodem file send interface.

Currently here is what I need to do via the Tera Term UI to upgrade the firmware on an existing ARM based micro controller.

1) Connect to the COMM port to which the Micro-controller has been connected via USB using Tera-Term.
2) Continuously send carriage return/press enter key via the keyboard, while hitting the reset on the Micro-controller, so it breaks into its
bootloader interface.
3) type "upgrade ymodem" at the bootloader prompt and hit enter.
4) Use the tera-term I send the firmware file via by clicking on the Menu "File->Transfer->Ymodem->Send".

I figured a way to do until step 2. But once the bootloader prompt shows up, I am not sure how to proceed ahead and transfer the file via the ymodem interface to the micro controller.

Has anyone done this before or if there was a forum article addressing something similar, can you please point me to that forum article?

Thanks,
Yogesh
Trevor
Guru

Posts:
480
Joined: Wed Jul 26, 2006 8:47 am
by Trevor » Sat May 06, 2017 5:45 pm
Sure, I have done this lots in the past. Something like this would do it:

Code: Select all

  1. sendln "upgrade ymodem"
  2. ; wait for whatever the response is (if there is one) using wait or waitln
  3.  
  4. ymodemsend "C:\firmware.bin"
  5. if result then
  6.     messagebox 'Success' 'YMODEM'
  7. else
  8.     messagebox 'File transfer failure' 'YMODEM'
  9. endif
yogeshk
Newbie

Posts:
6
Joined: Sat May 06, 2017 5:35 am
by yogeshk » Sat May 06, 2017 6:19 pm
Thanks a lot Trevor for taking the time to respond. I will give that a shot. After the upgrade ymodem command, I usually immediately try to begin the transfer.

Thanks,
Yogesh
yogeshk
Newbie

Posts:
6
Joined: Sat May 06, 2017 5:35 am
by yogeshk » Sat May 06, 2017 7:08 pm
One of the issues I am facing is that timing the reset of the micro-controller and sending the carriage return characters and then ensuring that the bootloader prompt shows up and then send the "upgrade ymodem" command.

Currently I am doing it a crude way based on a counter once the reset button is hit as shown below. Although it works I am not convinced without verifying if I am actually at the bootloader prompt, I shouldn't be sending the "upgrade ymodem" command.

The bootloader command prompt looks like this "bootloader :>". Is there a way to check if I am at this prompt?

Code: Select all

  1. ;
  2. Openning Serial connection using COM port.
  3. constr = '/C='
  4. strconcat constr param2
  5. strconcat constr ' /BAUD=115200'
  6.  
  7. connect constr
  8.  
  9. testlink
  10.  
  11. if result = 2 then
  12.     ; Assigning new title to TeraTerm window
  13.     settitle constr
  14.  
  15.     ;start sending the carriage return command to the micro-controller.
  16.     for i 1 200
  17.       send 13
  18.     next
  19.    
  20.     ;at this point i am assuming the bootloader command is presented. ex: bootloader :>
  21.     sendln "upgrade ymodem"
  22.    
  23.     ; Delay for 1 second
  24.     pause 1
  25.    
  26.     ; wait for whatever the response is (if there is one) using wait or waitln
  27.     ymodemsend "C:\Users\yogeshk\Downloads\TestFirmware.bin"
  28. else
  29.     ; Assigning new title to TeraTerm window
  30.     settitle 'not connected'
  31. endif
  32.  
Trevor
Guru

Posts:
480
Joined: Wed Jul 26, 2006 8:47 am
by Trevor » Sun May 07, 2017 12:24 pm
Hi Yogesh,
I would do it like this.

Code: Select all

  1. ; Openning Serial connection using COM port.
  2. sprintf2 constr '/C=%s /BAUD=115200' param2
  3. connect constr
  4.  
  5. testlink
  6. if result == 2 then
  7.     ; Assigning new title to TeraTerm window
  8.     settitle constr
  9.  
  10.     ;start sending the carriage return command to the micro-controller.    
  11.     timeout = 0
  12.     mtimeout = 100 ; 100 ms
  13.     flushrecv
  14.     for i 1 100 ; 100 * 100ms = 10 seconds
  15.         send 13
  16.         wait '>'
  17.         if result == 1 then
  18.             break
  19.         endif
  20.     next
  21.    
  22.     if result == 1 then
  23.         ;at this point i am assuming the bootloader command is presented. ex: bootloader :>
  24.         sendln "upgrade ymodem"
  25.        
  26.         ; Delay for 1 second
  27.         pause 1
  28.        
  29.         ymodemsend "C:\Users\yogeshk\Downloads\TestFirmware.bin"
  30.         if result == 0 then
  31.             ; deal with ymodem file send failure
  32.         endif
  33.     else
  34.         ; deal with timeout accessing bootloader
  35.     endif
  36. else
  37.     ; Assigning new title to TeraTerm window
  38.     settitle 'not connected'
  39. endif


Regards
Trevor
Last edited by Trevor on Mon May 08, 2017 8:32 am, edited 1 time in total.
yogeshk
Newbie

Posts:
6
Joined: Sat May 06, 2017 5:35 am
by yogeshk » Sun May 07, 2017 8:46 pm
Thanks once again Trevor for taking the time to respond. That helped a lot, it works much more better now.

Thanks,
Yogesh
Display posts from previous:
Sort by:

6 postsPage 1 of 1

Users browsing this forum: No registered users
cron