Name
Setup — Preparing the STM32L4R9-DISCO Board for eCos Development
Overview
The STM32L4R9-DISCO motherboard incorporates a ST-Link interface, which is used to provide hardware debug support for eCos application development. Applications can be loaded, run and debugged either via the command line GDB debugger arm-eabi-gdb, or via the Eclipse IDE. These host tools communicate with the target via a “GDB server” intermediary that supports a specific JTAG-based hardware debugger (e.g. JLinkGDBServer for the Segger J-Link, or OpenOCD for the J-Link and other hardware debuggers).
Normally for release applications the ROM
startup type would be used, with the application programmed into
the on-chip flash for execution when the board boots. It is still
possible to use the hardware debugging support to debug such
flash-based ROM applications, and this may be the desired approach
if the application is too large for execution from on-chip SRAM,
or where all of the SRAM is required for application run-time use.
If off-chip Non-Volatile Memory (NVM) is used to hold the main application then the board can boot from the internal flash using a suitable boot loader. For example, the eCosPro BootUp ROM loader, where the BootUp code can start the main application (after an optional update sequence).
If required, it is still possible to program a GDB stub
or RedBoot ROM
image into on-chip
Flash and download and debug via a serial connection (using
USART1). In that case, 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 as
appropriate. However, the space available to applications
with this approach is so limited as to make it essentially
impractical.
Programming ROM images
The JTAG connection and suitable host software (e.g. The OpenOCD package openocd tool, or the Segger J-Link JLinkGDBServer) can be used to program the flash.
Both these GDB servers can directly program flash based applications from the GDB load command. For example, assuming that openocd is running on the same host as GDB, and is connected to the target board the following will program the “bootup.elf” application into the on-chip flash:
$arm-eabi-gdb install/bin/bootup.elf
GNU gdb (eCosCentric GNU tools 7.3.0c) 8.1 [ … GDB output elided … ] (gdb) target remote localhost:3333 hal_reset_vsr () atpath
/hal_misc.c:171 (gdb)load
Loading section .rom_vectors, size 0x14 lma 0x8000000 Loading section .text, size 0x3adc lma 0x8000018 Loading section .rodata, size 0x6c0 lma 0x8003af8 Loading section .data, size 0x6dc lma 0x80041b8 Start address 0x8000018, load size 18572 Transfer rate: 14 KB/sec, 4643 bytes/write. (gdb)
If using JLinkGDBServer, the approach is identical, apart from using port 2231 to connect to the server.
Alternatively, the openocd telnet interface can
be used to manually program the flash. By default the
openocd session provides a comand-line via port
4444
. Consult the OpenOCD documentation for
more details if a non-default openocd
configuration is being used.
With a telnet connection established to the openocd any binary data can easily be written to the on-chip flash. e.g.
$telnet localhost 4444
Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Open On-Chip Debugger >flash write_image test.bin 0x08000000
wrote 32518 bytes from file test.bin in 1.073942s (29.569 KiB/s)
To create a binary for flash programming the arm-eabi-objcopy command is used. This converts the, ELF format, linked application into a raw binary. For example:
$ arm-eabi-objcopy -O binary programname
programname
.bin
2024-03-18 | eCosPro License |