Setup

Name

Setup -- Preparing the M5208EVBe board for eCos Development

Overview

In a typical development environment the M5208EVBe board boots from flash into the RedBoot ROM monitor. eCos applications are configured for a RAM startup, and then downloaded and run via either ethernet or serial using the m68k-elf-gdb debugger. Preparing the board therefore involves programming a suitable RedBoot image into flash memory. Alternatively it is possible to use a BDM hardware debug module to load and run a RAMBDM startup application, with no need to install RedBoot into flash first. Some functionality provided by RedBoot via virtual vectors will not be available in that scenario. In particular the ethernet driver will not be able to access an fconfig setting for the MAC address, and instead it will use a fixed address controlled by a configuration option.

Setting Up BDM

The recommended BDM debug solution is the Ronetix PEEDI. This requires a configuration file peedi.m5208evbe.cfg which can be found in the platform HAL's misc directory. The configuration file will initialize the hardware in the same way as the ROM startup code. It will need minor edits, for example to specify the correct license keys and to select the CORE_FLASH respectively for the M5208EVBe or M5208EVB. For full details see the Ronetix documentation.

Once the PEEDI is set up applications can be linked against an eCos configuration built with RAMBDM startup mode. That is largely equivalent to RAM startup but disables the use of virtual vectors, so it does not assume that RedBoot is present. Applications can then be run via m68k-elf-gdb:

% m68k-elf-gdb install/tests/kernel/current/tests/tm_basic
…
(gdb) target remote peedi:9000
Remote debugging using peedi:9000
0x00015b6c in ?? ()
(gdb) load
Loading section .m68k_start, size 0xa4 lma 0x40010000
Loading section .text, size 0xaadc lma 0x400100a4
Loading section .rodata, size 0xfc1 lma 0x4001ab80
Loading section .data, size 0x14c lma 0x4001bb44
Start address 0x40010000, load size 48269
Transfer rate: 250 KB/sec, 8044 bytes/write.
(gdb) break cyg_test_exit
Breakpoint 1 at 0x40016670: file /work/ecos/ecospro-common/packages/infra/current/src/tcdiag.cxx, line 316.
(gdb) continue
Continuing.

Breakpoint 1, cyg_test_exit () at /work/ecos/ecospro-common/packages/infra/current/src/tcdiag.cxx:316
316	cyg_test_exit(void)
$
    

The application output will go via the configured HAL diagnostics channel, as per CYGHWR_HAL_M68K_MCFxxxx_DIAGNOSTICS_PORT. The default settings will send the output via UART0 at 115200 baud, 8 bits, no parity, and 1 stop bit. The baud rates can be changed via the configuration option CYGNUM_HAL_M68K_MCFxxxx_DIAGNOSTICS_BAUD. It is also possible to set the diagnostics port to discard all output or to use the gdb hwdebug fileio channel. The latter requires running an extra gdb command after loading the application:

…
(gdb) load
Loading section .m68k_start, size 0xa4 lma 0x40010000
Loading section .text, size 0xaa9c lma 0x400100a4
Loading section .rodata, size 0xfc1 lma 0x4001ab40
Loading section .data, size 0x150 lma 0x4001bb04
Start address 0x40010000, load size 48209
Transfer rate: 250 KB/sec, 8034 bytes/write.
(gdb) set hwdebug
(gdb) break cyg_test_exit
Breakpoint 1 at 0x40016670: file /work/ecos/ecospro-common/packages/infra/current/src/tcdiag.cxx, line 316.
(gdb) continue
…
    

The application output will now be sent to gdb, which will display it.

Installing RedBoot

The following RedBoot configurations are supported for the M5208EVBe and M5208EVB boards:

StartupDescriptionUseFiles
ROMRuns from the board's flashredboot_ROM.ecmredboot.elf, redboot.bin
RAMUsed for upgrading ROM versionredboot_RAM.ecmredboot.elf, redboot.bin

Note that the RAM and RAMBDM startups are equivalent as far as RedBoot is concerned. The RAM startup version of RedBoot can be run either via BDM or on top of an already installed ROM RedBoot. eCosPro releases come with prebuilt RedBoot images renamed to incorporate the startup type, for example redboot_ROM.bin. It is the ROM RedBoot binary that needs to be programmed into flash at location 0x00000000. This may involve a third party flash programming utility. Alternatively it is possible to first run up the RAM startup version via BDM and then use that to program the ROM binary into flash. The eCosPro installation's "loaders/m5208evbe" directory contains the prebuilt RedBoot images for the M5208EVBe target and the "loaders/m5208evb" directory the prebuilt RedBoot images for the M5208EVB. The following example assumes you are using a Ronetix PEEDI BDM debugger to load the appropriate RAM RedBoot prebuilt for your target.

% m68k-elf-gdb <path>/redboot.elf
…
(gdb) target remote peedi:9000
Remote debugging using peedi:9000
fis_lookup (name=0x4001bc80 "@\001\ufffd8", num=0x40016a7a) at /work/ecos/ecospro-common/packages/redboot/current/src/flash.c:267
267	{
(gdb) load
Loading section .m68k_start, size 0x98 lma 0x40010000
Loading section .text, size 0x16dd8 lma 0x40010098
Loading section .rodata, size 0x3afc lma 0x40026e70
Loading section .data, size 0xb08 lma 0x4002a96c
Start address 0x40010000, load size 111732
Transfer rate: 274 KB/sec, 12414 bytes/write.
(gdb) continue
    

The RAM RedBoot will now output its banner and prompt via UART0, again at 115200 baud 8 bits no parity 1 stopbit, and will accept commands:

+**Warning** FLASH configuration checksum error or invalid key
Use 'fconfig -i' to [re]initialize database
Ethernet eth0: MAC address 00:ff:12:34:56:78
IP: 10.1.1.181/255.255.255.0, Gateway: 10.1.1.241
Default server: 0.0.0.0
DNS server IP: 10.1.1.240, DNS domain name: <null>

RedBoot(tm) bootstrap and debug environment [RAM]
…
Platform: M5208EVBe (Freescale MCF5208)                            
RAM: 0x40000000-0x41000000 [0x40036424-0x40fed000 available]                    
FLASH: 0x00000000-0x007fffff, 64 x 0x10000 blocks, 64 x 0x10000 blocks          
RedBoot>
    

At this stage the RedBoot flash management initialization has not yet happened so the warning about the configuration checksum error is expected. In this example RedBoot is using a default MAC address and has contacted a local bootp server to get the IP address information. To perform the flash initialization use the fis init command.

RedBoot> fis init
About to initialize [format] FLASH image system - continue (y/n)? y
** Initialize FLASH Image System                                               
... Erase from 0x007f0000-0x007fffff: .                                         
... Program from 0x40ff0000-0x41000000 to 0x007f0000: .
RedBoot>
    

Now the block of flash at location 0x007F0000 holds information about the various flash blocks, allowing other flash management operations to be performed. The next step is to set up RedBoot's non-volatile configuration values:

RedBoot> fconfig -i
Initialize non-volatile configuration - continue (y/n)? y
Run script at boot: false
Use BOOTP for network configuration: true
Default server IP address:
DNS server IP address:
GDB connection port: 9000
Force console for special debug messages: false
Network hardware address [MAC]: 0x00:0xff:0x12:0x34:0x01:0x15
Network debug at boot time: false
Update RedBoot non-volatile configuration - continue (y/n)? y
... Erase from 0x007f0000-0x007fffff: .
... Program from 0x40ff0000-0x41000000 to 0x007f0000: .
RedBoot>
    

For most of these configuration variables the default value will be acceptable, at least initially. If there is no suitable BOOTP service running on the local network then BOOTP should be disabled, and instead RedBoot will prompt for a fixed IP address, netmask, and addresses for the local gateway and DNS server. The other exception is the network hardware address, also known as MAC address. All boards should be given a unique MAC address, not the one in the above example. If there are two boards on the same network trying to use the same MAC address then the resulting behaviour is undefined.

It is now possible to load the flash-resident version of RedBoot. Because of the way that flash chips work this involves first loading it into RAM and then programming it into flash.

RedBoot> load -r -m ymodem -b %{freememlo}
    

The ROM startup build of redboot.bin should now be uploaded using the terminal emulator. The file is a raw binary and should be transferred using the Y-modem protocol.

CRaw file loaded 0x40036800-0x40051dfb, assumed entry at 0x40036800
xyzModem - CRC mode, 878(SOH)/0(STX)/0(CAN) packets, 3 retries
RedBoot>
    

Once RedBoot has been loaded into RAM it can be programmed into flash:

RedBoot> fis create RedBoot -b %{freememlo}                                     
An image named 'RedBoot' exists - continue (y/n)? y                             
... Erase from 0x00000000-0x0001ffff: ..                                        
... Program from 0x40036800-0x40051dfc to 0x00000000: ..                        
... Erase from 0x007f0000-0x007fffff: .                                         
... Program from 0x40ff0000-0x41000000 to 0x007f0000: .                         
RedBoot>
    

The flash-resident version of RedBoot has now been programmed at location 0x00000000, and the flash info block at 0x007F0000 has been updated. The initial setup is now complete. The BDM gdb session is no longer required so can be ctrl-C'd and exited. BDM can be disconnected if desired. When the board is powercycled the ROM version of RedBoot should now start up:

+... waiting for BOOTP information
Ethernet eth0: MAC address 00:ff:12:34:01:15
IP: 10.1.1.182/255.255.255.0, Gateway: 10.1.1.241
Default server: 0.0.0.0, DNS server IP: 10.1.1.240

RedBoot(tm) bootstrap and debug environment [ROM]
…
Platform: M5208EVBe (Freescale MCF5208)
RAM: 0x40000000-0x41000000 [0x4000be10-0x40fed000 available]
FLASH: 0x00000000-0x007fffff, 64 x 0x10000 blocks, 64 x 0x10000 blocks
RedBoot>
    

When RedBoot issues its prompt it is also ready to accept connections from m68k-elf-gdb, allowing eCos applications to be downloaded and debugged.

Occasionally it may prove necessary to update the installed RedBoot image. This can be done via BDM, as above, or by loading a RAM RedBoot binary via the ROM RedBoot's load -r -m ymodem -b 0x40010000 and started with the go command. The ROM version can then be loaded into memory and programmed into flash as before.

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_rom
$ cd redboot_rom
$ ecosconfig new m5208evbe redboot
$ ecosconfig import $ECOS_REPOSITORY/hal/m68k/mcf52xx/mcf520x/m5208evbe/<vsn>/misc/redboot_ROM.ecm
$ ecosconfig resolve
$ ecosconfig tree
$ make
    

At the end of the build the install/bin subdirectory should contain the required file redboot.bin, as well as the ELF executable redboot.elf. Rebuilding the RAM involves basically the same process but using the file redboot_RAM.ecm. For the older M5208EVB board the "ecosconfig new m5208evbe redboot" command in the above example should replaced by "ecosconfig new m5208evb redboot".

2017-02-09
Documentation license for this page: eCosPro License