Skip to content

Commit

Permalink
Add Dockerfile for an easier compilation process
Browse files Browse the repository at this point in the history
  • Loading branch information
Peque committed Jun 28, 2019
1 parent 63fc9ee commit a835e54
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 45 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM fedora:30

ENV LANG C.UTF-8

RUN dnf update -y \
&& dnf install -y \
arm-none-eabi-gcc \
arm-none-eabi-newlib \
curl \
git \
make \
openocd \
python \
wget \
which \
&& dnf clean all
RUN alias python='python3'

VOLUME /bulebule
WORKDIR /bulebule
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
DOCKER_RUN = sudo docker run -v $$(pwd):/bulebule:Z -u $$(id -u):$$(id -g) bulebule

default: src/main.elf

src/main.elf:
${DOCKER_RUN} make -s -C src/

.PHONY: libopencm3
libopencm3:
${DOCKER_RUN} scripts/setup_libopencm3.sh

.PHONY: clean
clean:
${DOCKER_RUN} make -s -C src/ clean

.PHONY: docker
docker:
sudo docker build -t bulebule .
98 changes: 53 additions & 45 deletions docs/source/brain.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
.. index:: brain

*****
Brain
*****


.. index:: microcontroller

Microcontroller
===============

Expand All @@ -33,57 +29,60 @@ T
6
Temperature range, -40 to 85 ºC

.. index:: dependencies

Dependencies
============
Compiling
=========

In order to work with this project we need to install some dependencies first:
This project requires some tools and dependencies:

- The GCC ARM compiler and debugger.
- A C standard library implementation.
- OpenOCD for programing and debugging.
- `OpenOCD`_ for programing and debugging.

In Fedora we can easily install those dependencies with:
We will also be using the `libopencm3`_ firmware library. Our workspace is
based on the `simple template
<https://github.com/libopencm3/libopencm3-template>`_ from that project.

.. code-block:: bash
We can manually install all those tools and dependencies in our system or we
can use Docker, which is a much more convenient approach.

dnf install arm-none-eabi-gcc arm-none-eabi-gdb arm-none-eabi-newlib openocd
#. Clone the project including submodules to get `libopencm3`_:

.. code-block:: bash
.. index:: workspace
git clone --recursive git@github.com:Bulebots/bulebule.git
cd bulebule
Workspace
=========
#. Create the Docker image:

We will be using the `libopencm3`_ firmware library. Our workspace is based on
the `simple template
<https://github.com/libopencm3/libopencm3-template>`_ from that project.
.. code-block:: bash
make docker
#. Clone the project including submodules to get libopencm3:
#. Setup and compile `libopencm3`_:

.. code-block:: bash
git clone --recursive git@github.com:Theseus/bulebule.git
make libopencm3
#. Setup libopencm3:
#. Compile the source code with:

.. code-block:: bash
cd bulebule/
./scripts/setup_libopencm3.sh
make
#. Compile Bulebule
#. We can clean the compilation files with:

.. code-block:: bash
cd src/
make
make clean
.. note:: The makefile on the :code:`src` folder combines the
:code:`libopencm3.target.mk` file, the board STM32F1 makefile and the
Bulebule project relative paths.


.. index:: programmer

Programmer
Expand All @@ -92,14 +91,19 @@ Programmer
The programmer is a generic ST-Link V2. Connecting this programmer to the
board is very simple, just make sure to connect these pins together:

=========== ===========
Board Programmer
=========== ===========
3V3 3.3V
SWIO SWDIO
SWCLK SWCLK
GND GND
=========== ===========
=================== ===================
Board Programmer
=================== ===================
3V3 **<unconnected>**
**<unconnected>** 3.3V
SWIO SWDIO
SWCLK SWCLK
GND GND
=================== ===================

.. warning:: Note that the 3V3 line is not connected. We will be using the
battery to power the mouse while flashing it. This way we avoid having two
power sources on the microcontroller board while programming.

.. note:: The programmer uses an USB interface, which means we might need to
set the proper permissions for our user:
Expand All @@ -121,8 +125,20 @@ GND GND
udevadm control --reload-rules
To program the microcontroller we are using `OpenOCD`_. We need to specify
the interface and target configuration files:
Flashing
========

Having the programmer connected, we can flash the microcontroller with::

make -C src/ flash


OpenOCD
=======

To program the microcontroller we can also directly use `OpenOCD`_. We need to
specify the interface and target configuration files:

.. code-block:: bash
Expand All @@ -146,13 +162,7 @@ Or halt and re-run::
> reset halt
> reset run


.. index:: flashing

Flashing
========

We can flash the microcontroller using OpenOCD (assuming we are already
We can flash the microcontroller using OpenOCD as well (assuming we are already
connected with `telnet`)::

> program filename.elf verify reset
Expand All @@ -174,8 +184,6 @@ Binary files need the flash address to be specified::
> program filename.bin verify reset 0x08000000


.. index:: debugging

Debugging
=========

Expand Down

0 comments on commit a835e54

Please sign in to comment.