How-To: Develop without any IDE

This guide describes how you can work with ARM / STM32 / ChibiOS without using any IDEs because we all know, IDEs are annoying and stupid.

What you need

In this tutorial we use the following software:

Please note that you can use any text editor which matches your needs.

Setup your Project

ChibiOS makes it very easy to build your project. Just to your projects top level directory and type 'make'. If you don't have any project ready, choose an example project out of the demos folder in chibios. When you did everything right, the last lines of the output should look like the following:

Linking build/ch.elf
Creating build/ch.hex
Creating build/ch.bin
Creating build/ch.dmp
Done

Setup OpenOCD and GDB

Next, we start the OpenOCD server. Open a terminal window and OpenOCD matching your configuration. You must keep the terminal window open, when you close it, OpenOCD will close as well. If OpenOCD could connect to your JTAG correctly, you should see something like this:

[tectu@TecWork vitfit]$ sudo openocd
[sudo] password for tectu: 
Open On-Chip Debugger 0.7.0-dev-00053-g4a5dc09 (2012-10-25-00:22)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m3 reset_config sysresetreq
Info : clock speed 1000 kHz
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0)
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints

Now, where our OpenOCD server is ready, we can open GDB and connect to the OpenOCD server:

arm-none-eabi-gdb path/to/your/ch.elf

The GDB command line will show up. My project's name is 'vitfit' here.

[tectu@TecWork vitfit]$ arm-none-eabi-gdb build/vitfit.elf 
GNU gdb (GNU Tools for ARM Embedded Processors) 7.3.1.20120613-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-linux-gnu --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/tectu/projects/vitfit/build/vitfit.elf...done.
(gdb) 

Setup Target

From now on, every command is meant for the GDB command line and not for your bash. Next, we connect from our GDB to our target:

(gdb) target extended localhost:3333

Since typing a lot is getting annoying, we can take advantage of the command parser of GDB and use the short version:

(gdb) tar ext :3333

If everything went right, we have to reset and halt our target to make it ready to receive the image:

(gdb) monitor reset halt

Please note that the command monitor means that the following commands are not GDB but OpenOCD related. Therefore we cannot use any short version because it's not visible for the GDB command parser. The sort version is therefore:

(gdb) mon reset halt

Now we can finally load our code into the MCU:

(gdb) load

If you didn't start GDB with the path of the ELF file as an argument or using the file command afterwards, you have to specify the path as an argument of load. Please note that it is highly recommended to start GDB with the ELF file as an argument because you won't have the important debugging symbols available afterwards.

If everything went right, you should have an output like this:

(gdb) load
Loading section startup, size 0x130 lma 0x8000000
Loading section .text, size 0x197d4 lma 0x8000130
Loading section .data, size 0x16c lma 0x8019908
Start address 0x8000130, load size 105072
Transfer rate: 22 KB/sec, 11674 bytes/write.
(gdb) 

Now we can start execute and debug our program:

(gdb) run

GDB will tell you that the target is already running. Please confirm the the warning by typing 'y'. Your code is executing now.

You can now stop your code at any time by pressing CTRL^C to start the actual debugging.

Debugging

After pressing Ctrl^C the executions stops and the gdb command line shows up again. Also, because we loaded the debugging symbols as mentioned before, we get an exact description of where the execution has been halted. In this case, in the while(TRUE) in the main.c:

VitFitThread (arg=0x0) at main.c:100
100	while(TRUE);
(gdb)

Continuing

Whenever the execution of your program has stopped, you can use continue to continue at the point where you currently are:

(gdb) continue

Breakpoints

Set

To set a break point, you use the following syntax: break <file>.c:<linenumber>. In this example, we do set a breakpoint at line 238 in our file main.c. Please note that the system halts BEFORE the given line gets exacuted:

(gdb) break main.c:238

You can now run your code by typing run. As soon as your program reaches the first break point, it will halt and the GDB console pops up (the (gdb) thing).

Delete

To delete a break point, you need to know it's ID. You can get a list of the currently set break points by typing the command info break. You can then delete a breakpoint by using the command delete <ID>.

Step through code

This guide should follow soon™

Backtrace

This guide should follow soon™

 
chibios/community/guides/work_without_ide.txt · Last modified: 2013/02/22 18:10 by tectu
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.3