Programming ARM controllers in Eclipse on Ubuntu: how it's done
For work are faced with the programming of the controller AT91SA7A3 using IAR. But as to keep the second system I'm lazy, was attempted to enable the programming, debugging and firmware under Ubuntu favorite. And now, after two weeks of communication with the wall by means of obscene language(much as the Wallpaper began to move), managed all this stuff to configure. And because, maybe I'm not the only one I will write how to do it.
So, I had the charge AT91SAM7A3-EK JTAG-adapter Atmel SAM-ICE, a computer with Ubuntu 11.04, half a pack of cigarettes and a couple of cups of coffee. Nice kit. Go!
1) Go to Eclipse website (http://www.eclipse.org), and download under our system the Eclipse IDE for C/C++ Developers. The latest version thereof is Eclipse 3.7 Indigo.
2) Go to project OpenOCD (http://developer.berlios.de/projects/openocd/) and pumped the OpenOCD 0.5.0 source code.
3) follow the compiler. I chose Sourcery G++, as it is updated, unlike ARMGCC. Download IA32 GNU/Linux TAR.
4) Optional: while all this is pumped out, you can go to smoke.
5) Extract the Eclipse files in the right directory(mine is /home/user/arm folder appears in eclipse).
6) Unpack the archive of the compiler in the right directory (mine is /home/user/arm folder appears arm-2011.03 or something similar, may be different numbers).
7) Go to Synaptic, install the package usb-dev, we'll need it next.
8) Unpack the archive with OpenOCD, it is better in the home folder, will be a little easier with paths.
9) Run the terminal, jump into the sources folder OpenOCD(the one you just unpacked) and write the following commands:
./configure --enable-jlink
sudo make
sudo make install
The --enable-jlink need to enable our SAM-ICE, for this we put the bag in the usb dev.
10) Optional: while all this is going to go for coffee.
11)Now, just in the console write the following: sudo gedit /etc/environment.
In the opened file add the path to our compiler, you should get 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"
Reboot the machine and (optionally) go to smoke.
12) the Machine is rebooted, launch Eclipse from the folder, choose the workspace and put a check, so do not climb. Go to Help- > Install New Software, there poking the button Add write a name Zylincdt, opensource.zylin.com/zylincdt, jamiem OK, put a check mark on a single packet in the window Zylin Embedded CDT, and follow the instructions of the installer.After the installation Eclipse will restart. Now create a new project: go to File- > New- > C Project, select Makefile project- > Empty project Toolchain-Other Toolchain, give the project a name and jamiem Finish. Now at the time we turn off the Eclipse.
13) Go to the folder /usr/local/share/openocd/scripts/target and look where the configuration file of our controller in the name. My(AT91SAM7A3) was not, but he was quickly found in Google and slightly tweaked handles. If there is, fine. Connected SAM-ICE to the PC and the Board, serves on the Board power. 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 other fee-replace the jlink.cfg at91sam7a3.cfg to the desired file.
Should start OpenOCD and show us a bunch of information, among which will be the model of the chip. Collapsible window of the terminal.
14) Go to Atmel and are looking for a trial project. There are a few curve system, so I immediately give the direct link to the project under our charge AT91SAM7A3-EK: www.atmel.com/dyn/resources/...ing_started.zip. Download, unzip, and remember where you unpacked. Back in Eclipse, right click on our project, select Import, there General-File System. He referred to the folder where you unpacked sviashchennaia project, and indicate what files you need(you can just highlight and not to suffer) and jamiem Finish.
15) Go to the project's Makefile, find the line CROSS_COMPILE=arm-elf and replacing it with a CROSS_COMPILE=arm-none-eabi-.Maintain the Makefile, go to Project-> Build Project and seeing how everything is compiled and collected. If done correctly the output will be two files *.elf and *.bin.
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 specify the point of 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 you specify the path to the firmware file*/ 0
monitor reset run
kill
17) Now configure the debugger. Go to Run- > Debug Configuration, there create 2 new configurations: Zylin Embedded Debug(Native) sram(for debug) and Zylin Embedded Debug(Native) flash(for firmware). Now for the tabs.
Main: C/C++ Application, specify the path and file name, the *.elf need to debug, *.bin for the firmware.
Debugger: GDB Debuger-specify the path to our debugger, in our case, it would be so home/user/arm/arm-2011.03/bin/arm-none-eabi-gdb,
GDB Command File-here you specify the path to the appropriate file gdbinit.
Commands: in the Initialze Command is empty.
Common tab: check Debug under Display in favorites menu.
Click Apply, make sure we have OpenOCD running, click Debug. You should see the window with debugging information, if you are running the configuration sram. Optionally, you can add Windows with the survey variables, memory, disassembly and so on.
Voila, everything works.
Now a small addition. Better don't delete the downloaded project there is a header file that defines a bunch of constants to facilitate the work with the registers, there are Startup files there is a script lincrusta(which is important) and most importantly-a Makefile describing how it will be allocated memory in the files for the debugger and the programmer. I'd rather transfer them to each new project and slightly edit the Makefile. And life will be wonderful.
P. S. a Little later, I realized that if a little loaf, the same thing could be done using toolchain for ARM, but the need has disappeared and I did not want to do this.
Article based on information from habrahabr.ru
So, I had the charge AT91SAM7A3-EK JTAG-adapter Atmel SAM-ICE, a computer with Ubuntu 11.04, half a pack of cigarettes and a couple of cups of coffee. Nice kit. Go!
1) Go to Eclipse website (http://www.eclipse.org), and download under our system the Eclipse IDE for C/C++ Developers. The latest version thereof is Eclipse 3.7 Indigo.
2) Go to project OpenOCD (http://developer.berlios.de/projects/openocd/) and pumped the OpenOCD 0.5.0 source code.
3) follow the compiler. I chose Sourcery G++, as it is updated, unlike ARMGCC. Download IA32 GNU/Linux TAR.
4) Optional: while all this is pumped out, you can go to smoke.
5) Extract the Eclipse files in the right directory(mine is /home/user/arm folder appears in eclipse).
6) Unpack the archive of the compiler in the right directory (mine is /home/user/arm folder appears arm-2011.03 or something similar, may be different numbers).
7) Go to Synaptic, install the package usb-dev, we'll need it next.
8) Unpack the archive with OpenOCD, it is better in the home folder, will be a little easier with paths.
9) Run the terminal, jump into the sources folder OpenOCD(the one you just unpacked) and write the following commands:
./configure --enable-jlink
sudo make
sudo make install
The --enable-jlink need to enable our SAM-ICE, for this we put the bag in the usb dev.
10) Optional: while all this is going to go for coffee.
11)Now, just in the console write the following: sudo gedit /etc/environment.
In the opened file add the path to our compiler, you should get 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"
Reboot the machine and (optionally) go to smoke.
12) the Machine is rebooted, launch Eclipse from the folder, choose the workspace and put a check, so do not climb. Go to Help- > Install New Software, there poking the button Add write a name Zylincdt, opensource.zylin.com/zylincdt, jamiem OK, put a check mark on a single packet in the window Zylin Embedded CDT, and follow the instructions of the installer.After the installation Eclipse will restart. Now create a new project: go to File- > New- > C Project, select Makefile project- > Empty project Toolchain-Other Toolchain, give the project a name and jamiem Finish. Now at the time we turn off the Eclipse.
13) Go to the folder /usr/local/share/openocd/scripts/target and look where the configuration file of our controller in the name. My(AT91SAM7A3) was not, but he was quickly found in Google and slightly tweaked handles. If there is, fine. Connected SAM-ICE to the PC and the Board, serves on the Board power. 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 other fee-replace the jlink.cfg at91sam7a3.cfg to the desired file.
Should start OpenOCD and show us a bunch of information, among which will be the model of the chip. Collapsible window of the terminal.
14) Go to Atmel and are looking for a trial project. There are a few curve system, so I immediately give the direct link to the project under our charge AT91SAM7A3-EK: www.atmel.com/dyn/resources/...ing_started.zip. Download, unzip, and remember where you unpacked. Back in Eclipse, right click on our project, select Import, there General-File System. He referred to the folder where you unpacked sviashchennaia project, and indicate what files you need(you can just highlight and not to suffer) and jamiem Finish.
15) Go to the project's Makefile, find the line CROSS_COMPILE=arm-elf and replacing it with a CROSS_COMPILE=arm-none-eabi-.Maintain the Makefile, go to Project-> Build Project and seeing how everything is compiled and collected. If done correctly the output will be two files *.elf and *.bin.
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 specify the point of 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 you specify the path to the firmware file*/ 0
monitor reset run
kill
17) Now configure the debugger. Go to Run- > Debug Configuration, there create 2 new configurations: Zylin Embedded Debug(Native) sram(for debug) and Zylin Embedded Debug(Native) flash(for firmware). Now for the tabs.
Main: C/C++ Application, specify the path and file name, the *.elf need to debug, *.bin for the firmware.
Debugger: GDB Debuger-specify the path to our debugger, in our case, it would be so home/user/arm/arm-2011.03/bin/arm-none-eabi-gdb,
GDB Command File-here you specify the path to the appropriate file gdbinit.
Commands: in the Initialze Command is empty.
Common tab: check Debug under Display in favorites menu.
Click Apply, make sure we have OpenOCD running, click Debug. You should see the window with debugging information, if you are running the configuration sram. Optionally, you can add Windows with the survey variables, memory, disassembly and so on.
Voila, everything works.
Now a small addition. Better don't delete the downloaded project there is a header file that defines a bunch of constants to facilitate the work with the registers, there are Startup files there is a script lincrusta(which is important) and most importantly-a Makefile describing how it will be allocated memory in the files for the debugger and the programmer. I'd rather transfer them to each new project and slightly edit the Makefile. And life will be wonderful.
P. S. a Little later, I realized that if a little loaf, the same thing could be done using toolchain for ARM, but the need has disappeared and I did not want to do this.
Комментарии
Отправить комментарий