Use Sphinx for documentation

This change makes the API documentation look much nicer.

Also build instructions were moved from README to docs.
This commit is contained in:
Martin Jäger
2021-12-16 15:54:05 +01:00
parent ce90f7710b
commit 4568267288
38 changed files with 527 additions and 2853 deletions
+35
View File
@@ -0,0 +1,35 @@
Building and Flashing
=====================
As the ``main`` branch may contain unstable code, make sure to select the desired release branch
(see GitHub for a list of releases and branches):
.. code-block:: bash
git switch <your-release>-branch
west update
The ``app`` subfolder contains all application source files and the CMake entry point to build the
firmware, so we go into that directory first.
.. code-block:: bash
cd app
Initial board selection (see ``boards`` subfolder for correct names):
.. code-block:: bash
west build -b <board-name>@<revision>
The appended ``@<revision>`` specifies the board version according to the above table. It can be
omitted if only a single board revision is available or if the default (most recent) version should
be used. See also
`here <https://docs.zephyrproject.org/latest/application/index.html#application-board-version>`_
for more details regarding board revision handling in Zephyr.
Flash with specific debug probe (runner), e.g. J-Link:
.. code-block:: bash
west flash -r jlink
+89
View File
@@ -0,0 +1,89 @@
Customization
=============
This firmware is developed to allow easy customization for individual use-cases. Below options
based on the Zephyr devicetree and Kconfig systems try to allow customization without changing
any of the files tracked by git, so that a `git pull` does not lead to conflicts with local
changes.
Hardware-specific changes
-------------------------
In Zephyr, all hardware-specific configuration is described in the
`Devicetree <https://docs.zephyrproject.org/latest/guides/dts/index.html>`_.
The file ``boards/arm/board_name/board_name.dts`` contains the default devicetree specification
(DTS) for a board. It is based on the DTS of the used MCU, which is included from the main Zephyr
repository.
In order to overwrite the default devicetree specification, so-called overlays can be used. An
overlay file can be specified via the west command line. If it is stored as ``board_name.overlay``
in the ``app`` subfolder, it will be recognized automatically when building the firmware for that
board.
Application firmware configuration
----------------------------------
For configuration of the application-specific features, Zephyr uses the
`Kconfig system <https://docs.zephyrproject.org/latest/guides/kconfig/index.html>`_.
The configuration can be changed using ``west build -t menuconfig`` command or manually by changing
the prj.conf file (see ``Kconfig`` file for possible options).
Similar to DTS overlays, Kconfig can also be customized per board. Create a folder ``app/boards``
and a file ``board_name.conf`` in that folder. The configuration from this file will be merged with
the ``prj.conf`` automatically.
Change the battery type
"""""""""""""""""""""""
By default, the charge controller is configured for maintainance-free VRLA gel battery
(``CONFIG_BAT_TYPE_GEL``). Possible other pre-defined options are ``CONFIG_BAT_TYPE_FLOODED``,
``CONFIG_BAT_TYPE_AGM``, ``CONFIG_BAT_TYPE_LFP``, ``CONFIG_BAT_TYPE_NMC`` and
``CONFIG_BAT_TYPE_NMC_HV``.
The number of cells is automatically selected by Kconfig to get 12V nominal voltage. It can also
be manually specified via ``CONFIG_BAT_NUM_CELLS``.
To compile the firmware with default settings for 12V LiFePO4 batteries, add the following to
``prj.conf`` or the board-specific ``.conf`` file:
.. code-block:: bash
CONFIG_BAT_TYPE_LFP=y
CONFIG_BAT_NUM_CELLS=4
Configure serial for ThingSet protocol
""""""""""""""""""""""""""""""""""""""
By default, the charge controller uses the serial interface in the UEXT connector for the
`ThingSet protocol <https://libre.solar/thingset/>`_. This allows to use WiFi modules with ESP32
without any firmware change.
Add the following configuration if you prefer to use the serial of the additional debug RX/TX pins
present on many boards:
.. code-block:: bash
CONFIG_UEXT_SERIAL_THINGSET=n
To disable regular data publication in one-second interval on ThingSet serial at startup add the
following configuration:
.. code-block:: bash
CONFIG_THINGSET_SERIAL_PUB_DEFAULT=n
Custom functions (separate C/C++ files)
---------------------------------------
If you want experiment with some completely new functions for the charge controller, new files
should be stored in a subfolder ``src/custom``.
To add the files to the firmware build, create an own CMakeLists.txt in the folder and enable the
Kconfig option ``CONFIG_CUSTOMIZATION``.
If you think the customization could be relevant for others, please consider sending a pull request.
Integrating features into the upstream charge controller firmware guarantees that the feature stays
up-to-date and that it will not accidentally break after changes in the original firmware.
+19
View File
@@ -0,0 +1,19 @@
Troubleshoting
==============
This page contains a collection of often encountered issues and solutions.
Errors with STM32L072 MCU using OpenOCD
---------------------------------------
The standard OpenOCD settings sometimes fail to flash firmware to this MCU, which is used in the
MPPT 1210 HUS and the PWM charge controller.
Try one of these workarounds:
1. Change OpenOCD settings to ``adapter_khz 500`` in ``openocd-path/scripts/target/stm32l0.cfg``.
2. Use other tools or debug probes such as `STM32CubeProgrammer`_ or `Segger J-Link`_.
.. _STM32CubeProgrammer: https://www.st.com/en/development-tools/stm32cubeprog.html
.. _Segger J-Link: https://www.segger.com/products/debug-probes/j-link/
+22
View File
@@ -0,0 +1,22 @@
Unit Tests
==========
Core functions of the firmware are covered by unit-tests (located in ``tests`` directory). Build
and run the tests with the following command:
.. code-block:: bash
cd tests
west build -p -b native_posix -t run
Conformance testing
-------------------
We are using Continuous Integration to perform several checks for each commit or pull-request. In
order to run the same tests locally (recommended before pushing to the server) use the script
``check.sh`` or ``check.bat`` in the ``scripts`` folder:
.. code-block:: bash
./scripts/check.sh # use check.bat on Windows
+52
View File
@@ -0,0 +1,52 @@
Workspace Setup
===============
This guide assumes you have already installed the Zephyr SDK and the ``west`` tool according to the
`Zephyr documentation <https://docs.zephyrproject.org/latest/getting_started/>`_.
Below commands initialize a new workspace and pull all required source files:
.. code-block:: bash
# create a new west workspace and pull the charge controller firmware
west init -m https://github.com/LibreSolar/charge-controller-firmware west-workspace
cd west-workspace/charge-controller-firmware
# pull Zephyr upstream repository and modules (may take a while)
west update
Afterwards, most important folders in your workspace will look like this:
.. code-block:: bash
west-workspace/ # contains .west/config
│
├── charge-controller-firmware/ # application firmware repository
│ ├── app/ # application source files
│ ├── boards/ # board specifications
│ ├── tests/ # unit test source files
│ └── west.yml # main manifest file
│
├── modules/ # modules imported by Zephyr and CC firmware
|
├── tools/ # tools used by Zephyr
│
└── zephyr/ # upstream Zephyr repository
If you already have a west workspace set up (e.g. for other Libre Solar firmware), you can also
re-use it to avoid having many copies of upstream Zephyr and modules:
.. code-block:: bash
# go to your workspace directory
cd your-zephyr-workspace
# pull the charge controller firmware
git clone https://github.com/LibreSolar/charge-controller-firmware
cd charge-controller-firmware
# re-configure and update the workspace
# (to be done each time you switch between applications in same workspace)
west config manifest.path charge-controller-firmware
west update