On the job I ran into the programming of the controller AT91SA7A3, for this IAR is used. But since I am lazy to keep the second system, an attempt was made to ensure the possibility of programming, debugging and firmware under my beloved Ubuntu. And now, after two weeks of communication with the wall through obscene vocabulary (the wallpaper started to move as much), I managed to set up this whole economy. And since perhaps I will not be the only one, I will write how it is done.
So, I had: an AT91SAM7A3-EK board, an Atmel SAM-ICE JTAG adapter, a computer with Ubuntu 11.04, half a pack of cigarettes and a couple of coffee mugs. Good kit. Go!
1) Go to the Eclipse website (http://www.eclipse.org) and download the Eclipse IDE for C / C ++ Developers for our system. The latest version is Eclipse 3.7 Indigo.
2) We go to the site of the OpenOCD project (http://developer.berlios.de/projects/openocd/) and download the OpenOCD 0.5.0 sources.
3) Follow the compiler. I chose Sourcery G ++, since it is updated, unlike ARMGCC. Download IA32 GNU / Linux TAR.
4) Optional: as long as all of this is pumped out, you can go to smoke.
5) Unpack the Eclipse archive into the directory we need (I have this / home / user / arm, the eclipse folder will appear).
6) Extract the compiler archive to the correct directory (I have this / home / user / arm, the folder will appear arm-2011.03 or something like that, the numbers may differ).
7) Go to Synaptic, install the usb-dev package, we will need it later.
8) Unpack the archive with OpenOCD, better to the home folder, it will be a little easier with the paths.
9) We start the terminal, jump to the folder with the source of OpenOCD (the one that just unpacked) and write the following commands:
./configure --enable-jlink
sudo make
sudo make install
')
The --enable-jlink key is needed to enable support for our SAM-ICE, for this we also put a usb-dev sachet.
10) Optional: while all this is going, you can go for coffee.
11) Now we also write the following in the console: sudo gedit / etc / environment.
In the opened file we add the path to our compiler, it should be approximately the following:
PATH = "/ usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / sbin: / bin: / usr / games: /home/user/arm/arm-2011.03/bin "
Restart the car and (optionally) go to smoke.
12) The machine rebooted, launch Eclipse from the folder, select the workspace and tick it in order not to climb anymore. We go to Help-> Install New Software, there we poke into the Add button, write the name Zylincdt, the address
opensource.zylin.com/zylincdt , press OK, tick the only package in the Zylin Embedded CDT window, and follow the instructions of the installer. After installing Eclipse will restart. Now we create a new project: go to File-> New-> C Project, select the Makefile project-> Empty project, Toolchain-Other Toolchain, give the project a name and click Finish. Now for the time we turn off Eclipse.
13) Go to the / usr / local / share / openocd / scripts / target folder and look for the configuration file with our controller in the name. There was no mine (AT91SAM7A3), but it was quickly found in Google and slightly tweaked with pens. If there is, fine. We connect SAM-ICE to the computer and the board, we supply power to the board. We start the terminal and write the following:
sudo openocd -f interface / jlink.cfg -c "jtag_rclk 30; gdb_flash_program enable; gdb_memory_map disable" -f target / at91sam7a3.cfg
Attention! If you have a different adapter or another board, replace jlink.cfg and at91sam7a3.cfg with the files you need.
OpenOCD should start and show us a bunch of information, among which there will be a chip model. Minimize the terminal window.
14) Go to the Atmel website and look for a trial project. There is a somewhat crooked system, so I will immediately give a direct link to the project under our AT91SAM7A3-EK
board :
www.atmel.com/dyn/resources/...ing_started.zip . Download, unpack, remember where unpacked. We return to Eclipse, right-click on our project, select Import, there the General-File System. We indicate to him the folder where the freshly minded project was unpacked, we indicate what files are needed (you can just select everything and not suffer) and click Finish.
15) Go to the project's Makefile, find the string CROSS_COMPILE = arm-elf- and replace it with CROSS_COMPILE = arm-none-eabi-. Save the Makefile, go to the Project-> Build Project and observe how everything is compiled and assembled. If everything is done correctly, the output will be two files * .elf and * .bin.
16) Create in the folder home (or somewhere else the files gdbinit_sram and gdbinit_flash, in which we write the following.
gdbinit_sram:
target remote localhost: 3333
monitor reset init
monitor halt
printf "____Target halted ____ \ n"
set $ mem_a = * 0x00000000
set $ mem_c = $ mem_a
set $ mem_a = $ mem_a + 1
set * 0x00000000 = $ mem_a
set $ mem_b = * 0x00000000
if ($ mem_a == $ mem_b)
set * 0x00000000 = $ mem_c
printf "____ Remap_is_Done ____ \ n"
else
printf "____ Remap_is_Not ____ \ n"
set * 0xFFFFFF00 = 1
printf "____ Remap_is_Done ____ \ n"
end
monitor reg pc 0x00000000
monitor arm7_9 dbgrq enable
monitor gdb_breakpoint_override hard
load
hbreak / * here we indicate the breakpoint * /
continue
condition 1
gdbinit_flash:
target remote localhost: 3333
monitor reset init
monitor halt
printf "____Target halted ____ \ n"
set $ mem_a = * 0x00000000
set $ mem_c = $ mem_a
set $ mem_a = $ mem_a + 1
set * 0x00000000 = $ mem_a
set $ mem_b = * 0x00000000
if ($ mem_a == $ mem_b)
printf "____ Remap_is_Not ____ \ n"
set * 0x00000000 = $ mem_c
set * 0xFFFFFF00 = 1
printf "____ Remap_is_Done ____ \ n"
else
printf "____ Remap_is_Done ____ \ n"
end
monitor arm7_9 dcc_downloads enable
monitor arm7_9 fast_memory_access enable
monitor flash erase_sector 0 0 15
monitor flash probe 0
monitor flash write_bank 0 / * here specify the path to the firmware file * / 0
monitor reset run
kill
17) Now we set up the debugger. We go to Run-> Debug Configuration, we create 2 new configurations there: Zylin Embedded Debug (Native) sram (for debugging) and Zylin Embedded Debug (Native) flash (for firmware). Now by tabs.
Main: C / C ++ Application specify the path and file name, the one that * .elf is needed for debugging, * .bin- for firmware.
Debugger: GDB Debuger-specify the path to our debugger, in our case it will be so home / user / arm / arm-2011.03 / bin / arm-none-eabi-gdb,
GDB Command File-here we specify the path to the corresponding gdbinit file.
Commands: in the Initialze Command field is empty.
Common tab: check Debug under Display in the favorites menu.
We press Apply, we are convinced that we are running OpenOCD, click Debug. A window should appear with debug information if the sram configuration is running. Optionally, you can add windows with an overview of variables, memory, disassembly, and so on.
Voila, it works.
Now a small addition. It is better not to delete the downloaded project — there is a header file that describes a bunch of constants to facilitate working with registers, there are Startup files, there is a linker script (which is important) and most importantly, a Makefile that describes how the memory will be distributed in the files for the debugger and programmer. For me, it's better to transfer them to each new project and edit the Makefile a bit. And life will be beautiful.
PS A little later, I realized that if I could move my brain a little, the same could be done using the ARM tulechain, but the need disappeared and I didn’t do it.