Embedded TCP/IP stack  3.9.3
FNET Bootloader Quick Start

Requirements

Tools used during this quick start:

Step by step

Follow these steps to run the FNET Bootloader:

  • Prepare your evaluation board according to your board User Manual.
  • Use USB or RS-232 male/female DB-9 serial cable to connect your PC (through COM port) to the evaluation board.
  • Connect the evaluation board to an Ethernet network.
  • Power the board up.
  • Invoke the terminal program on the PC to which the evaluation board is connected and configure it to:
    • Bits per second: 115200.
    • Data bits: 8.
    • Parity: none.
    • Stop bits: 1.
    • Flow control: None.

      fnet_serial_setup.jpg
      Serial port setup
  • Start TFTP Server:
    • Start TFTP Server application. Go to [Start]->[Programs]->[Tftpd32]->[Tftpd32]
    • Press the [Settings] button and set the TFTP server base directory (for example C:\TFTP-Root):

      fnet_tftp_setup.jpg
      Tftpd32 Settings
    • Press [OK]:

      fnet_tftp_start.jpg
      Tftpd32
Prepare the example-application image file that is to be downloaded by the TFTP Bootloader:
  • Open the project:
    fnet\fnet_demos\boards\<board_name>\shell_boot\<compiler_name>\
    
  • In the IDE choose the Release target.
  • Compile the project.
  • The fnet_firmware.srec file should appear in directory with binaries.
    Copy this S-record file to the TFTP Server Base Directory (by default, it is C:\TFTP-Root).
  • Close the project.
Prepare the FNET TFTP Bootloader:
  • Open the project:
    fnet\fnet_demos\boards\<board_name>\boot\<compiler_name>\
    
  • In the IDE choose Release target.
  • Compile the project.
  • Flash the program to the board.
  • Now the TFTP Bootloader is ready to be used.
    You may update or backup the firmware with help of TFTP firmware client or TFTP firmware server.

TFTP firmware client

  • Reset the board, press the RESET button on the board.
  • In your terminal program window you should see the FNET Bootloader welcome message:
    Parameters loaded from Flash.
    
    *******************************************
     FNET Bootloader
    ************************************************
     FNET TCP/IP Stack for MCF52259
     Version 2.0.0
     Built Oct 12 2012 at 15:00:04 by CW
    ************************************************
     Interface        : eth0
     IPv4 Address     : 192.168.0.22 <manual>
     IPv4 Subnet mask : 255.255.255.0
     IPv4 Gateway     : 0.0.0.0
     MAC Address      : 00:04:9f:14:59:56
     Link Status      : connected
     TX Packets       : 2
     RX Packets       : 0
     Free Heap        : 14128
     DHCP Client      : disabled
     TFTP Server      : disabled
    
     Enter 'help' for command list.
    ************************************************
    
    Startup script: tftps
    ************************************************
     TFTP Server started.
     IPv4 Address     : 192.168.0.22
    ************************************************
    BOOT>
    
  • The Bootloader is now ready to accept user commands. Enter the help command to display a list of all commands available within the shell of the Bootloader:
    BOOT> help
    >   help                                 - Display this help message
    >    set [<parameter> <value>]           - Set parameter
    >    get [<parameter>]                   - Get parameters
    >   info                                 - Show detailed status
    >   dhcp [release]                       - Start DHCP client
    >   tftp [<image name>[<server ip>[<type>]]]- TFTP firmware loader
    > tftpup [<image name>[<server ip>[<type>]]]- TFTP firmware uploader
    >  tftps [release]                       - TFTP firmware server
    >    mem                                 - Show memory map
    >  erase all|[0x<erase address> <bytes>] - Erase flash memory
    >   save                                 - Save parameters to the FLASH
    >     go [0x<address>]                   - Start application at address
    >  reset                                 - Reset the board
    BOOT>
    
  • Check Bootloader parameters. Enter the get command to see the parameter values:
    get
     ip      : 192.168.0.22
     netmask : 255.255.255.0
     gateway : 0.0.0.0
     mac     : 00:04:9f:14:59:56
     boot    : stop
     delay   : 5
     script  : dhcp; erase all; tftp; set boot go; save; go
     raw     : 0x0
     tftp    : 192.168.0.5
     image   : fnet_firmware.srec
     type    : srec
     go      : 0x0
    BOOT>
    
  • To change the default parameters the set command should be used. To understand its syntax, enter the set command without parameters:
    BOOT> set
    Valid 'set' options:
     ip      : <board IP address>
     netmask : <netmask IP address>
     gateway : <gateway IP address>
     mac     : <ethernet address>
     boot    : <stop|go|script>
     delay   : <seconds>
     script  : <command script>
     raw     : 0x<address>
     tftp    : <TFTP server IP address>
     image   : <Image-file name to load with TFTP>
     type    : <srec|bin|raw>
     go      : 0x<entry point address>
    BOOT> 
    
  • Brief description of the Bootloader parameters:
    • ip : Default IPv4 address of the board.
    • netmask : Default IPv4 Network netmask.
    • gateway : Default IPv4 address of the gateway.
    • mac : Ethernet MAC address.
    • boot : Bootloader booting modes:
      • stop = the bootloader stops at the shell prompt.
      • go = the bootloader jumps to the entry point address defined by the go parameter.
      • script = the bootloder executes a command script located in the script parameter.
    • delay : After the bootup, the bootloader will wait specified number of seconds before it executes the boot-mode defined by the boot parameter. During this time a countdown is printed, which can be interrupted by pressing any key. It is ignored for the stop booting mode.
    • script : The command script is automatically executed when the boot parameter is set to the script value and the initial countdown is not interrupted. This script may contain any command supported by the application shell. The commands must be split by semicolon operator.
    • go : Default entry point address to start execution at. It is used by the bootloader in the go booting mode as the default entry point. Also it is used as the default address for the go shell command if no address is provided as an argument.
      NOTE: This parameter is updated by the TFTP loader automatically if the type parameter is set to the srec value. The S-record file format contains the entry point information.
    • tftp : This is the default TFTP server IP address to be used for network download if no address is provided for the tftp shell command.
    • image : This is the default file name to download if no file name is provided for the tftp shell command.
    • type : Type of the file to download by the TFTP loader:
      • srec = S-record file (default type). This file format contains both the address data as well as the entry point information.
      • hex = Intel HEX file. This file format does not contain the entry point, so go parameter must be set additionally.
      • bin = CodeWarrior binary file. This file format does not contain the entry point, so go parameter must be set additionally
      • raw = Raw binary file. For this type of file, the raw parameter (load address) must be set before the TFTP loader start.
    • raw : Load address for a raw-binary file used by the TFTP loader. It's used only if the type parameter is set to the raw value.
  • Check if the parameter values are set correctly to suit your needs. Most probably, you will have a different TFTP server IP address. For example, to change it to the 10.171.89.219 address, enter:
    BOOT> set tftp 10.171.88.219
     tftp    : 10.171.88.219
    BOOT>
    
  • For example, to change the script parameter (use the backslash-escape symbol before each semicolon):
    BOOT> set script 'erase all\; tftp\; set boot go\; save\; reset'
     script  : erase all; tftp; set boot go; save; reset
    BOOT>
    
  • When all parameters are set correctly for your system, set the boot parameter to the script value.
    BOOT> set boot script
     boot    : script
    BOOT>
    
  • Enter the save command to save all run-time parameters to a non-volatile memory (it is located in the last erase page of the on-chip flash memory).
    BOOT> save
    Parameters saved
    BOOT>
    
    NOTE: The save command does not save the ip parameter in case it was allocated by a DHCP IPv4 server to avoid IPv4 address conflict during the system startup.
  • Reset the board, press the RESET button on the board. On reset, the Bootloader will start in script booting mode.
    Let`s analyze the script parameter value of the example provided above:
    dhcp; erase all; tftp; set boot go; save; go
    
    This script has the following steps:
    1. dhcp = starts DHCP client service and tries to update the IPv4 parameters (ip, gateway and netmask) from DHCP server. If the DHCP service will fail to retrieve the IP parameter from a DHCP server, the bootloder will continue with the old IP settings.
    2. erase all = erases all Flash memory blocks. To see the memory map enter the mem command:
      BOOT> mem
      
         Memory type       Start         End
        ----------------------------------------
        FLASH            0x00000000   0x0007FFFF
      
      BOOT>
      
    3. tftp = downloads the image-file (the file name defined by the image parameter) from the TFTP server (the server ip address defined by the tftp parameter), loads it to the Flash memory, checks if the written data are correct. Also, it checks a checksum and updates the go parameter if the type is set to the srec value.
      If the TFTP loading is failed, the bootloader will print an error message, stop script execution, and stay in the bootloader shell waiting for user actions (reset or parameters change).
    4. set boot go = Changes the bootloder booting mode to the go mode.
    5. save = Saves all run-time parameters to persistent memory to be available during the next startup.
      NOTE: The save command does not save the ip parameter in case it was allocated by a DHCP server to avoid IP address conflict during the system startup.
    6. go = Jumps to the application entry-point. As we use S-record image file the entry-point go parameter is updated automatically.
  • On reset, in the terminal window you should see:
    Parameters loaded from Flash.
    
    ************************************************
     FNET Bootloader
    ************************************************
     FNET TCP/IP Stack for MCF52259
     Version 2.0.0
     Built Oct 12 2012 at 15:00:04 by CW
    ************************************************
     Interface        : eth0
     IPv4 Address     : 192.168.0.22 <manual>
     IPv4 Subnet mask : 255.255.255.0
     IPv4 Gateway     : 0.0.0.0
     MAC Address      : 00:04:9f:14:59:56
     Link Status      : connected
     TX Packets       : 3
     RX Packets       : 0
     Free Heap        : 14128
     DHCP Client      : disabled
     TFTP Server      : disabled
    
     Enter 'help' for command list.
    ************************************************
    Press any key to stop (script):   0
    
    dhcp; erase all; tftp; set boot go; save; go
    Press [Ctr+C] to cancel.
    Sending DHCP discover...
    
    ************************************************
     DHCP has updated/renewed parameters:
    ************************************************
     Interface    : eth0
     IP address   : 10.171.88.220
     Subnet mask  : 255.255.254.0
     Gateway      : 10.171.88.254
    
    Cancelled
    Erasing...
     0x00000000 to 0x0000bfff skipped
     0x0000c000 to 0x0007efff erased
     0x0007f000 to 0x0007ffff skipped
    Press [Ctr+C] to cancel.
    TFTP downloading 'fnet_firmware.srec'c) from 192.168.0.5 : -
    Entry point set to 0x00019d14
    
    TFTP completed (270204 bytes)
     boot    : go
    Parameters saved
    go 0x00019d14
    
    
    Parameters loaded from Flash.
    
    ************************************************
     FNET Shell Demo (bootloader aware)
    ************************************************
     FNET TCP/IP Stack for MCF52259
     Version 2.0.0
     Built Oct  5 2012 at 13:52:57 by CW
    ************************************************
     Interface        : eth0
     IPv4 Address     : 192.168.0.22 <manual>
     IPv6 Address     : fe80::204:9fff:fe13:5250 <autoconfigurable>
     IPv4 Subnet mask : 255.255.255.0
     IPv4 Gateway     : 0.0.0.0
     IPv4 DNS         : 0.0.0.0
     MAC Address      : 00:04:9f:14:59:56
     Link Status      : connected
     TX Packets       : 5
     RX Packets       : 0
     Free Heap        : 30320
     HTTP Server      : disabled
     DHCP Client      : disabled
     TELNET Server    : disabled
    
     Enter 'help' for command list.
    ************************************************
    
    SHELLB> 
    
  • Now the Bootloader is in the go mode and every time on the system reset it will start the loaded application automatically.
Note
  • The tftpup command is useful for the firmware backup before it gets overwritten in the Flash memory. This feature enables to restore the system in case the new firmware has issues.
    This command uploads content of the on-chip Flash memory, except FNET Bootloader reserved blocks, to the TFTP server. The TFTP server IP address is defined by the tftp parameter. The image-file name on the remote TFTP server is defined by the image parameter. Format of the created file (S-record, CodeWarrior binary or raw binary) is defined by type parameter.
  • The Bootloder is able to run in IPv6 mode, by disabling IPv4 and enabling IPv6 in fnet_user_config.h.

TFTP firmware server

The TFTP server is started automatically during the bootloader start-up in normal boot mode. It allows to update or backup the firmware from a remote TFTP client running on host PC without the serial-console command line interface. Format of the image file (S-record, CodeWarrior binary or raw binary) is defined by type parameter.

  • You may check TFTP server status, enter info command:
    BOOT> info
     Interface        : eth0
     IPv4 Address     : 192.168.0.22 <manual>
     IPv4 Subnet mask : 255.255.255.0
     IPv4 Gateway     : 0.0.0.0
     MAC Address      : 00:04:9F:14:38:50
     Link status      : connected
     TX Packets       : 5
     RX Packets       : 144
     DHCP client      : disabled
     TFTP server      : enabled
    BOOT> 
    
  • If the TFTP server is stopped, you may enter the tftps command to start it:
    BOOT> tftps
    ************************************************
     TFTP Server started.
     IPv4 Address     : 192.168.0.22
    ************************************************
    
  • Start TFTP client on your PC:
    • Start TFTP Client application. Go to [Start]->[Programs]->[Tftpd32]->[Tftpd32]
    • Press the [Settings] button and set the "TFTP client" check-box

      fnet_tftp_cln_setup.jpg
      Tftpd32 Settings
    • Press [OK]:
  • You may now update firmware:
    • Be sure that the Bootloader TFTP server is started.
    • Set parameters of the TFTP Client:
      • Host: the IP address of your evaluation board.
      • Port: it should be set to the standard TFTP server port number 69.
      • Local File: the full path of the image file that will be uploaded to the board.
      • Remote File: set to the value of the bootloader-parameter image. By default it is set to the shell_boot_intflash.elf.S19 value.
      • Block size: set to Default or 512.
    • Start firmware update by pressing the [Put] button.

      fnet_tftp_cln_put.jpg
      Tftpd32 TFTP client
    • The TFTP server receives the write request, checks if the requested file name corresponds to the value of the image parameter, starts the erasing of the flash memory, downloads and writes image file to the flash memory, updates the go parameter to the new entry point, sets the boot parameter to the go value, saves changed parameters to the flash, and finally starts application. In the terminal window you should see:
      BOOT> TFTP downloading 'fnet_firmware.srec' (srec) from 192.168.0.5:
      Erasing...
       0x00000000 to 0x0000BFFF skipped
       0x0000C000 to 0x0007EFFF erased
       0x0007F000 to 0x0007FFFF skipped
      BOOT>
      Entry point set to 0x00019638
      
      TFTP completed (234244 bytes)
       boot    : go
      Parameters saved
      go 0x00019638
      
      
      Parameters loaded from Flash.
      
      ************************************************
       FNET Shell Demo (bootloader aware)
      ************************************************
       FNET TCP/IP Stack for MCF52259
       Version 2.0.0
       Built Oct  5 2012 at 13:52:57 by CW
      ************************************************
       Interface        : eth0
       IPv4 Address     : 192.168.0.22 <manual>
       IPv6 Address     : fe80::204:9fff:fe13:5250 <autoconfigurable>
       IPv4 Subnet mask : 255.255.255.0
       IPv4 Gateway     : 0.0.0.0
       IPv4 DNS         : 0.0.0.0
       MAC Address      : 00:04:9f:14:59:56
       Link Status      : connected
       TX Packets       : 5
       RX Packets       : 0
       Free Heap        : 30320
       HTTP Server      : disabled
       DHCP Client      : disabled
       AUTOIP Service   : disabled
       TELNET Server    : disabled
       LLMNR Server     : disabled
      
       Enter 'help' for command list.
      ************************************************
      
      SHELLB> 
      
    • Finally you should receive message about successfully transmitted image file:

      fnet_tftp_cln_put_end.jpg
      File was uploaded
  • Also you may backup the firmware. The TFTP firmware server can upload content of the on-chip Flash memory, except FNET Bootloader reserved blocks, to a TFTP client:
    • Be sure that the TFTP server is enabled:
      BOOT> info
       Interface        : eth0
       IP address       : 10.171.88.22 (set manually)
       Subnet mask      : 255.255.255.0
       Gateway          : 10.171.88.254
       MAC address      : 00:04:9F:11:20:42
       Link status      : connected
       TX Packets       : 4
       RX Packets       : 128
       DHCP client      : disabled
       TFTP server      : enabled
      BOOT>
    • Set parameters of the TFTP Client:
      • Host : the IP address of your evaluation board.
      • Port : should be set to the standard TFTP server port number 69.
      • Local File : the file that is used for firmware backup (for example backup.srec).
      • Remote File : set to the value of the bootloader-parameter image. By default it is set to the shell_boot_intflash.elf.S19 value.
      • Block size : set to Default or 512.
    • Start firmware download by pressing the [Get] button.

      fnet_tftp_cln_get.jpg
      Tftpd32 TFTP client
    • The TFTP server receives the read request, checks if the requested file name corresponds to the value of the image parameter, generates image file and uploads it to the remote TFTP client. In the terminal window you should see:
      BOOT> TFTP uploading 'fnet_firmware.srec' (srec) to 10.198.0.5:
      
      TFTP completed (1211274 bytes)
      
    • Finally you should receive message about successfully transmitted image file :

      fnet_tftp_cln_get_end.jpg
      File was downloaded
      Note
      The Bootloder is able to run in IPv6 mode, by disabling IPv4 and enabling IPv6 in fnet_user_config.h.

© 2005-2017 by Andrey Butok. http://fnet.sourceforge.net