Name

Setup — Preparing the STM32X0G-EVAL Board for eCos Development

Overview

In a typical development environment, the STM32X0G-EVAL board boots from internal flash into either the GDB stubrom or RedBoot. eCos applications are configured for RAM startup and then downloaded and run on the board via the debugger arm-eabi-gdb, or via the Eclipse IDE.

RedBoot Installation

The following RedBoot configurations are supported:

ConfigurationDescriptionUseFile
ROMRedBoot running from internal FLASHredboot_ROM.ecmredboot_ROM.bin
RAMRedBoot running from external RAMredboot_RAM.ecmredboot_RAM.bin
JTAGRedBoot running from external RAM, loaded via JTAGredboot_JTAG.ecmredboot_JTAG.elf

For serial communications, all versions run with 8 bits, no parity, and 1 stop bit at 115200 baud. This rate can be changed using the RedBoot baud command, or in the eCos configuration used for building RedBoot.

Under normal circumstances, RedBoot runs in-place from the internal Flash. The RAM version is provided to allow for updating the resident RedBoot image in Flash. The JTAG version is only used if loading RedBoot into RAM via a JTAG debugger. It is similar to the RAM version, but loads at a lower address within RAM. The ELF format image of this JTAG version of RedBoot can also be loaded and executed from GDB using a JTAG device, to allow it to be debugged.

Programming RedBoot with ST Flash Loader Demonstrator

To program RedBoot into the internal flash either a JTAG debugger that understands the STM32 flash may be used, such as a Ronetix PEEDI , or the ST Flash Loader Demonstrator may be used. Configuration files for the PEEDI have been supplied in the STM32X0G-EVAL HAL package. If no JTAG debugger is available, then RedBoot must be downloaded using the Flash Loader Demonstrator which can be downloaded from the page for the STM32F207IG CPU, in the Design Support->Software & Development Tools->Software Demos section of ST's website at http://www.st.com/internet/mcu/product/245085.jsp#SOFTWARE_AND_DEVELOPMENT_TOOLS. It must be at least version 2.4.0 in order to support the STM32F2xx devices. At time of writing, a direct link to this version is available at http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/SW_DEMO/stm32-stm8_flash_loader_demo.zip.

The following are brief instructions for downloading RedBoot using the Flash Loader Demonstrator. For more complete usage instructions, consult the ST documentation for this tool at http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/USER_MANUAL/CD00171488.pdf

  1. Download the Flash Loader Demonstrator from the ST website and install it on a PC running Windows that has an available RS232 serial port, or with a USB to RS232 adaptor.
  2. Copy the file redboot_ROM.bin from the loaders/stm32x0g_eval sub-directory within your eCosPro installation to a suitable location on the Windows PC.
  3. Connect a null-modem serial cable between the USART serial port (CN16) and the RS232 serial port on the Windows machine.
  4. Move the BOOT0/SW2 switch to the 1 position, ensuring the BOOT1/SW1 switch remains in the 0 position, and press the reset button.
  5. Start the Flash Loader Demonstrator and in the first screen select the COM port connected to the board under Port Name. Ensure that the baud rate is also set at 115200, with Even parity, Echo disabled and Flow control off. Press Next. If you are succesfully connected to the board, you should see the message Target is readable. Please click "Next" to proceed . Press Next and you will be prompted to select a target. Select STM32F2_1024K, then Next to go to the Operation choice page. If any of these steps fail, follow the direction given by the loader to recover.
  6. On the operation choice page select "Download to device" and under "Download from file" either type the location of the redboot_ROM.bin file, or browse to it. Ensure that the "@" field is set to 8000000, the "Global Erase" radio button is selected and that all other options are clear except "Verify after download".
  7. Press "Next" and the loader should download and verify the binary file. The download or verify may fail if the flash has been previously locked, in which case you should select the "Enable/Disable Flash protection" radio button, "Disable" and "Write Protection" drop-down items, press Next and retry the download. Upon successful download press "Close" to exit the loader.
  8. Move the BOOT0/SW2 switch back to the 0 position and press the reset button.

The behaviour of the Flash Loader Demonstrator documented here is that of version 2.4.0. The actual behaviour of newer versions may vary slightly.

Whatever mechanism is used to program RedBoot, something similar to the following output should be seen on the RS232 serial port when the reset button is pressed:

+**Warning** FLASH configuration checksum error or invalid key
Use 'fconfig -i' to [re]initialize database

RedBoot(tm) bootstrap and debug environment [ROM]
eCosCentric certified release, version v3_1_X - built 04:32:11, Feb  3 2012

Copyright (C) 2000-2009 Free Software Foundation, Inc.
Copyright (C) 2003-2012 eCosCentric Limited
RedBoot is free software, covered by the eCos license, derived from the
GNU General Public License. You are welcome to change it and/or distribute
copies of it under certain conditions. Under the license terms, RedBoot's
source code and full license terms must have been made available to you.
Redboot comes with ABSOLUTELY NO WARRANTY.

Platform: ST STM3220G EVAL (Cortex-M3)
RAM: 0x64000000-0x64200000 [0x64003668-0x641dd000 available]
     0x20000000-0x2001f000 [0x20000000-0x2001f000 available]
FLASH: 0x08000000-0x080fffff, 4 x 0x4000 blocks, 1 x 0x10000 blocks, 7 x 0x20000 blocks
RedBoot>

You should now proceed to the section describing how to initialize RedBoot's flash configuration.

Programming RedBoot with Ronetix PEEDI

This section describes how to install RedBoot using a Ronetix PEEDI JTAG debugger.

The PEEDI must be configured to allow communication with your local network, and configured with the parameters for interfacing with the target board. It must then be used to download and program a RedBoot image into the internal flash. The following steps give a typical outline for doing this. Consult the PEEDI documentation for alternative approaches, such as using FTP or HTTP instead of TFTP.

Preparing the Ronetix PEEDI JTAG debugger

  1. Prepare a PC to act as a host and start a TFTP server on it.
  2. Connect the PEEDI JTAG debugger via both serial and ethernet to the host PC and power it on. Use the serial cable supplied with the PEEDI (straight through, not null modem).
  3. Verify the PEEDI is using up-to-date firmware, of version 11.10.1 or later. Older PEEDI firmware does not support the STM32 F2 family correctly, particularly if wishing to use the PEEDI's own 'flash' commands to modify the on-chip Flash. If the firmware is not recent enough, follow the PEEDI User Manual's instructions which describe how to update the PEEDI firmware.
  4. Locate the appropriate file peedi.stm3220g.cfg (STM3220G-EVAL) or peedi.stm3240g.cfg (STM3240G-EVAL and STM3241G-EVAL) within the eCos platform HAL package in the source repository. This will be in the directory packages/hal/cortexm/stm32/stm32x0g/VERSION/misc relative to the root of your eCos installation.
  5. Place the respective configuration file in a location on the PC accessible to the TFTP server. Later you will configure the PEEDI to load this file via TFTP as its configuration file.
  6. Open peedi.stm3220g.cfg or peedi.stm3240g.cfg (as appropriate) in an editor such as emacs or notepad and insert your own license information in the [LICENSE] section.
  7. Install and configure the PEEDI in line with the PEEDI Quick Start Guide or User's Manual, especially configuring PEEDI's RedBoot with the network information. Configure it to use the appropriate peedi.stm3220g.cfg or peedi.stm3240g.cfg target configuration file on the TFTP server at the appropriate point of the config process, for example with a path such as: tftp://192.168.7.9/peedi.stm3220g.cfg
  8. Reset the PEEDI.
  9. Connect to the PEEDI's CLI interface via TCP/IP on the standard telnet port 23. The telnet application is suitable for this. You should see output similar to the following:

    $ telnet 192.168.7.225
    Trying 192.168.7.225...
    Connected to 192.168.7.225.
    Escape character is '^]'.
    
    PEEDI - Powerful Embedded Ethernet Debug Interface
    Copyright (c) 2005-2011 www.ronetix.at - All rights reserved
    Hw:1.2, L:JTAG v1.5 Fw:11.10.1, SN: PD-0000-XXXX-XXXX
    ------------------------------------------------------------
    
    stm3220g>

Preparing the STM32X0G board for programming with PEEDI

Follow the steps in this section in order to allow communication between the board and the host PC, and between the board and the JTAG device.

  1. Connect a null modem DB9 RS232 serial cable between the serial port on the board and a serial port on the host computer.
  2. Start a suitable terminal emulator on the host computer such as minicom on Linux or PuTTY on Windows. Set the communication parameters to 115200 baud, 8 data bits, no parity bit and 1 stop bit with no flow control.
  3. Connect the board to the PEEDI using a 20-pin ARM/Xscale cable from the JTAG interface connector to the Target port on the PEEDI.
  4. Power up the STM32X0G board.
  5. Connect to the PEEDI's telnet CLI on port 23 as before.
  6. Confirm correct connection with the PEEDI with the reset reset command as follows:

    stm3220g> reset reset
    ++ info: RESET and TRST asserted
    ++ info: TRST released
    ++ info: BYPASS check passed
    ++ info: 2 TAP controller(s) detected
    ++ info: TAP 0 : IDCODE = 0x06411041, unknown ID
    ++ info: TAP 1 : IDCODE = 0x4BA00477, Cortex M3 JTAG
    ++ info: RESET released
    ++ info: core #0 connected
    ++ info: core 0: initialized
    
    stm3220g>

Installation into Flash

The following describes the procedure for installing the RedBoot ROM monitor into on-chip Flash. It can also be adapted for installing user applications into Flash.

  1. Locate the redboot_ROM.bin image within the loaders subdirectory of the base of the eCos installation. For applications, use arm-eabi-objcopy -O binary to convert the linked application, in ELF format, into binary format.
  2. Copy the redboot_ROM.bin file into a location on the host computer accessible to its TFTP server.
  3. Connect to the PEEDI's telnet interface, and program the RedBoot image into Flash with the following command, replacing TFTP_SERVER with the address of the TFTP server and /RBPATH with the location of the redboot_ROM.bin file relative to the TFTP server root directory:

    stm3220g> flash program tftp://TFTP_SERVER/RBPATH/redboot_ROM.bin bin 0x08000000 erase
    ++ info: Programming image file: tftp://TFTP_SERVER/RBPATH/redboot_ROM.bin
    ++ info: Programming using agent, buffer = 4096 bytes
    ++ info: At absolute address:    0x08000000
    erasing     at 0x08000000 (sector #0)
    programming at 0x08000000
    programming at 0x08001000
    programming at 0x08002000
    programming at 0x08003000
    erasing     at 0x08004000 (sector #1)
    programming at 0x08004000
    programming at 0x08005000
    programming at 0x08006000
    programming at 0x08007000
    erasing     at 0x08008000 (sector #2)
    programming at 0x08008000
    programming at 0x08009000
    programming at 0x0800A000
    programming at 0x0800B000
    erasing     at 0x0800C000 (sector #3)
    programming at 0x0800C000
    programming at 0x0800D000
    programming at 0x0800E000
    programming at 0x0800F000
    
    ++ info: successfully programmed 64.00 KB in 2.39 sec
    
    stm3220g>

The RedBoot installation is now complete. This can be tested by powering off the board, disconnecting the JTAG, and then powering on the board again. The RedBoot banner should be visible on the serial port:

+**Warning** FLASH configuration checksum error or invalid key
Use 'fconfig -i' to [re]initialize database

RedBoot(tm) bootstrap and debug environment [ROM]
eCosCentric certified release, version v3_1_X - built 04:32:11, Feb  3 2012

Copyright (C) 2000-2009 Free Software Foundation, Inc.
Copyright (C) 2003-2012 eCosCentric Limited
RedBoot is free software, covered by the eCos license, derived from the
GNU General Public License. You are welcome to change it and/or distribute
copies of it under certain conditions. Under the license terms, RedBoot's
source code and full license terms must have been made available to you.
Redboot comes with ABSOLUTELY NO WARRANTY.

Platform: ST STM3220G EVAL (Cortex-M3)
RAM: 0x64000000-0x64200000 [0x64003668-0x641dd000 available]
     0x20000000-0x2001f000 [0x20000000-0x2001f000 available]
FLASH: 0x08000000-0x080fffff, 4 x 0x4000 blocks, 1 x 0x10000 blocks, 7 x 0x20000 blocks
RedBoot>
[Note]Note

An alternative approach would be to use arm-eabi-gdb to load and run the redboot_JTAG.elf file supplied as a prebuilt in the release. Once that instance of RedBoot is running, standard RedBoot commands such as 'load' and 'fis' can be used via the serial RS232 interface to program images to Flash, e.g.:

$ arm-eabi-gdb /path/to/redboot_JTAG.elf
GNU gdb (eCosCentric GNU tools 4.4.5c) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-eabi".
For bug reporting instructions, please see:
<http://bugzilla.ecoscentric.com/>...
Reading symbols from /path/to/redboot_JTAG.elf...done.
(gdb) target remote PEEDI-IP-ADDRESS:2000
Remote debugging using PEEDI-IP-ADDRESS:2000
0x080035a0 in ?? ()
(gdb) load
Loading section .rom_vectors, size 0x8 lma 0x64000000
Loading section .text, size 0xb314 lma 0x64000008
Loading section .rodata, size 0x372c lma 0x6400b320
Loading section .data, size 0x754 lma 0x6400ea50
Start address 0x64000009, load size 61852
Transfer rate: 236 KB/sec, 10308 bytes/write.
(gdb) c
Continuing.

Initializing RedBoot Flash Configuration

RedBoot manages the internal flash for the storage of application programs and configuration data. The flash needs to be initialized with the following commands:

RedBoot> fis init
About to initialize [format] FLASH image system - continue (y/n)? y
*** Initialize FLASH Image System
... Erase from 0x080e0000-0x080fffff: .
... Program from 0x641e0000-0x64200000 to 0x080e0000: .
RedBoot> fconfig -i
Initialize non-volatile configuration - continue (y/n)? y
Run script at boot: false
Console baud rate: 115200
Update RedBoot non-volatile configuration - continue (y/n)? y
... Erase from 0x080e0000-0x080fffff: .
... Program from 0x641e0000-0x64200000 to 0x080e0000: .
RedBoot>

Issue the reset command to RedBoot, and verify the the target board comes up as expected with the correct settings.

You may also need to run the fconfig -i command if you have updated your RedBoot from a previous version with a different configuration which might not have any new config fields used by the newly programmed RedBoot.

Rebuilding RedBoot

Should it prove necessary to rebuild a RedBoot binary, this is done most conveniently at the command line. The steps needed to rebuild the ROM version of RedBoot are:

$ mkdir redboot_stm3220g_rom
$ cd redboot_stm3220g_rom
$ ecosconfig new stm3220g redboot
[ … ecosconfig output elided … ]
$ ecosconfig import $ECOS_REPOSITORY/hal/cortexm/stm32/stm32x0g_eval/VERSION/misc/redboot_ROM.ecm
$ ecosconfig tree
$ make

At the end of the build the install/bin subdirectory should contain the file redboot.bin. This may be programmed to the board using the above procedure, or by using RedBoot's own flash update mechanisms.

The other versions of RedBoot - RAM or JTAG - may be similarly built by choosing the appropriate alternative .ecm file.