-
Notifications
You must be signed in to change notification settings - Fork 50
EM Starter Kit
This is a draft document, it is not complete and may describe features that may not yet exist.
This document describes how to use GNU tools for ARC with EM Starter Kit.
Different core templates in EM Starter Kit use different memory maps, and custom linker scripts are required to compile applications that work properly on those templates.
EM4 template has ICCM starting at 0x100 and DCCM at 0x80000000. Linker script and custom crt0.s file can be downloaded from Gist: https://gist.github.com/anthony-kolesov/7214970. To compile applciation use following command:
$ arc-elf-gcc -mEM -Wl,-Tem4.lds -nostartfiles crt0.s test.c
GNU tools for ARC do not support cores with reduced register set.
EM6 template has ICCM starting at 0x100 address and 256 MiB RAM starting at 0x10000000. It is assumed that both code and data segments are mapped to RAM and ICCM is not used. Linker script and custom start up file can be downloaded this Gist https://gist.github.com/anthony-kolesov/7214970. To compile applciation use following command:
$ arc-elf-gcc -mEM -Wl,-Tem6.lds -nostartfiles crt0.s test.c
Windows installer can be downloaded here. It includes GNU tools, OpenOCD and Eclipse IDE with ARC GNU plugin installed (NB: installer is not provided at the momemnt of writing, should be done with 4.8-R2 release).
Toolchain for Linux hosts can be downloaded from Synopsys website as a prebuilt package. It includes GNU tools only. OpenOCD should be built separately. Documentation is available in OpenOCD GitHub repository. In a nutshell:
$ git clone https://github.com/foss-for-synopsys-dwc-arc-processors/openocd.git
$ cd openocd
$ ./bootstrap
$ ./configure --enable-maintainer-mode --disable-werror
$ make
$ make install
OpenOCD for ARC cores works only with FTDI 2232H USB/UART chips only. These chips are used in Digilent HS-1 cable and EM Start Kit.
Download and install 2232H drivers from FTDI web page: http://www.ftdichip.com/Drivers/D2XX.htm
Ensure that FTDI chip is recognized by your OS. On Linux it is possible to use lsusb command to see a list of USB devices. On Windows use "Devices Manager" configuration panel.
Start OpenOCD:
# On Linux:
$ openocd -f /usr/local/share/openocd/scripts/target/snps_starter_kit_arc-em.cfg -c init -c halt -c 'reset halt'
@rem on Windows:
> openocd -f C:\ARC48\share\openocd\scripts\target\snps_starter_kit_arc-em.cfg -c init -c halt -c "reset halt"
OpenOCD will be waiting for GDB connections on TCP port 3333. It can be closed by CTRL+C. It is possible to start OpenOCD from Eclise as an external application.
Write a sample application:
/* simple.c */
int main(void) {
int a, b, c;
a = 1;
b = 2;
c = a + b;
return c;
}
Compile it:
$ arc-elf32-gcc -mEM -g -o simple.elf simple.c
Run GDB, connect to target and run it:
$ arc-elf32-gdb --quiet simple.elf
# connect
(gdb) target remote :3333
# Increase timeout, because OpenOCD can be slow at a times
(gdb) set remotetimeout 15
# load application into target
(gdb) load
# Go to start of main function
(gdb) break main
(gdb) continue
# Resume with usual GDB commands
(gdb) step
(gdb) next
# Go to end of the application
(gdb) break exit
(gdb) continue
Execution should stop at function exit(), invoked with argument 3.
- Communication between OpenOCD and hardware target is slow in some situations. To avoid possible communication issues between GDB and OpenOCD it is recommended to set remote timeout to around 10-15 seconds (default is 2). That also means that loading application into target could take noticeable amount of time, depending on size of application.
- Out of the box it is impossible to perform any input/output operations, like printf, scanf, file IO, etc. Calling any of those function in application will result in a hang (unhandled system call to be exact). It is possible to use UART for text console I/O operations, consult EM Starter Kit documentation and examples for details.
- Baremetal applications has nowhere to exit, and default implementation of function
exit()is a infinite loop. To catch exit from application you should set breakpoint at functionexit()like in the example.