e-puck2 programmer development: Difference between revisions

From GCtronic wiki
Jump to navigation Jump to search
(Created page with "===Flashing the programmer=== First of all to update the programmer's firmware you need to enter DFU mode (device firmware upgrade). To do it refer to section [http://www.gctr...")
 
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
===Flashing the programmer===
[{{fullurl:e-puck2}} e-puck2 main wiki]<br/>
First of all to update the programmer's firmware you need to enter DFU mode (device firmware upgrade). To do it refer to section [http://www.gctronic.com/doc/index.php?title=e-puck2#Using_the_DFU Using the DFU], in particular Note 2.<br/>
The programmer will be recognized as <code>STM Device in DFU Mode</code> device.


====Linux====
=Get the source code=
In order to update the programmer firmware you need an utility called <code>dfu-util</code>.<br/>
The programmer firmware source code can be downloaded with the command:<br/>
To install it issue the command <code>sudo apt-get install dfu-util</code>.<br/>
<code>git clone --recursive https://github.com/e-puck2/e-puck2-programmer</code><br/>
Then issue the following command to upload the firmware: <code>sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000 -D programmer-firmware.bin</code>


====Windows====
==Building==
For Windows users it is available an application called <code>DfuSe</code> released by STMicroelectronics. You can download it from [http://projects.gctronic.com/epuck2/en.stsw-stm32080_DfuSe_Demo_V3.0.5.zip DfuSe_V3.0.5.zip].<br/>
In order to build the firmware you need the <code>arm-none-eabi</code> toolchain installed. Then you can issue the following commands from the <code>src</code> directory of the repo root:<br/>
When the program is started, the programmer in DFU mode will be automatically detected as shown in figure 1. Then you need to open the compiled firmware by clicking on <code>choose</code> and then locating the file,  as shown in figure 2. Now click on the <code>upgrade</code> button, a warning message will be shown, confirm the action by clicking on <code>yes</code> as shown in figure 3. If all is ok you'll be prompted with a message saying that the upgrade was successfull as shown in figure 4.<br/>
<code>make clean</code><br/>
<span class="plainlinks">
<code>make</code><br/>
<table>
The result is a bin file named <code>e-puck2_programmer.bin</code> that you can find in the <code>src/build</code> directory.<br/>
<tr>
 
<td align="center">[1]</td>
=Configuring the Programmer's settings=
<td align="center">[2]</td>
The on-board programmer of the e-puck2 is based on the [https://github.com/blacksphere/blackmagic/wiki Blackmagic probe open source project] firmware. <br>
<td align="center">[3]</td>
Some functionalities has been added on top of the original project to be able to control some functions of the robot, for example the power on or power off.  
<td align="center">[4]</td>
 
</tr>
To access to the available commands of the programmer, it is needed to connect to the programmer with a GDB console. <br>
<tr>
To do so, you have to type the following command in a terminal window with the com port used by the '''e-puck2 GDB Server'' port of your e-puck2 :
<td>[http://projects.gctronic.com/epuck2/wiki_images/dfu1.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/dfu1.png">]</td>
<pre>
<td>[http://projects.gctronic.com/epuck2/wiki_images/dfu2.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/dfu2.png">]</td>
arm-none-eabi-gdb
<td>[http://projects.gctronic.com/epuck2/wiki_images/dfu3.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/dfu3.png">]</td>
target extended-remote your_gdb_com_port
<td>[http://projects.gctronic.com/epuck2/wiki_images/dfu4.png <img width=250 src="http://projects.gctronic.com/epuck2/wiki_images/dfu4.png">]</td>
</pre>
</tr>
 
</table>
Once connected to the programmer with GDB, you can type
</span><br/>
<pre>monitor help</pre> or <pre>mon help</pre> to print the available commands of the programmer.
 
One command in particular is useful, which is <code>mon select_mode</code>. It is used to select in which mode the  '''e-puck2 Serial Monitor''' com port will work.<br>
mode 1 = the serial monitor is connected to the UART port of the main processor<br>
mode 2 = the serial monitor is connected to the UART of the ESP32<br>
mode 3 = the serial monitor works as a Aseba CAN to USB translator<br>
 
The choice made for the mode is the only setting that is stored in a flash zone of the programmer, which means the choice is remembered, even if the robot is completely turned off.
 
Note : in mode 1 and 3, GDB can be used over the bluetooth connection of the e-puck2. But it is much slower than with USB and it doesn't work with Windows due to GDB limitations on this OS.
 
By being connected with GDB, you can also use the standard GDB command to program and debug the main processor of the e-puck2.

Latest revision as of 05:58, 17 June 2020

e-puck2 main wiki

Get the source code

The programmer firmware source code can be downloaded with the command:
git clone --recursive https://github.com/e-puck2/e-puck2-programmer

Building

In order to build the firmware you need the arm-none-eabi toolchain installed. Then you can issue the following commands from the src directory of the repo root:
make clean
make
The result is a bin file named e-puck2_programmer.bin that you can find in the src/build directory.

Configuring the Programmer's settings

The on-board programmer of the e-puck2 is based on the Blackmagic probe open source project firmware.
Some functionalities has been added on top of the original project to be able to control some functions of the robot, for example the power on or power off.

To access to the available commands of the programmer, it is needed to connect to the programmer with a GDB console.
To do so, you have to type the following command in a terminal window with the com port used by the 'e-puck2 GDB Server port of your e-puck2 :

arm-none-eabi-gdb 
target extended-remote your_gdb_com_port

Once connected to the programmer with GDB, you can type

monitor help

or

mon help

to print the available commands of the programmer.

One command in particular is useful, which is mon select_mode. It is used to select in which mode the e-puck2 Serial Monitor com port will work.
mode 1 = the serial monitor is connected to the UART port of the main processor
mode 2 = the serial monitor is connected to the UART of the ESP32
mode 3 = the serial monitor works as a Aseba CAN to USB translator

The choice made for the mode is the only setting that is stored in a flash zone of the programmer, which means the choice is remembered, even if the robot is completely turned off.

Note : in mode 1 and 3, GDB can be used over the bluetooth connection of the e-puck2. But it is much slower than with USB and it doesn't work with Windows due to GDB limitations on this OS.

By being connected with GDB, you can also use the standard GDB command to program and debug the main processor of the e-puck2.