2014-09-09 15:08:46 +00:00
|
|
|
Adding support for new hardware
|
|
|
|
===============================
|
|
|
|
This page will give a short overview on how to add support
|
|
|
|
for new hardware to Gluon.
|
|
|
|
|
|
|
|
Hardware requirements
|
|
|
|
---------------------
|
2019-12-28 17:40:33 +00:00
|
|
|
Having an ath9k, ath10k or mt76 based WLAN adapter is highly recommended,
|
2014-09-09 15:08:46 +00:00
|
|
|
although other chipsets may also work. VAP (multiple SSID) support
|
2018-01-19 13:16:58 +00:00
|
|
|
is a requirement.
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2019-12-14 18:06:21 +00:00
|
|
|
.. _device-class-definition:
|
|
|
|
|
|
|
|
Device classes
|
|
|
|
--------------
|
|
|
|
Gluon currently is aware of two device classes. Depending on the device class, different
|
|
|
|
features can be installed onto the device.
|
|
|
|
|
|
|
|
The ``tiny`` device-class contains devices with the following limitations:
|
|
|
|
|
|
|
|
* All devices with less than 64 MB of system memory
|
|
|
|
* All devices with less than 7 MB of usable firmware space
|
|
|
|
* Devices using a single ath10k radio and less than 128MB of system memory
|
2017-01-18 16:21:43 +00:00
|
|
|
|
2014-09-09 15:08:46 +00:00
|
|
|
.. _hardware-adding-profiles:
|
|
|
|
|
|
|
|
Adding profiles
|
|
|
|
---------------
|
2018-07-10 20:57:40 +00:00
|
|
|
The vast majority of devices with ath9k WLAN is based on the ar71xx target of OpenWrt.
|
2018-01-19 13:16:58 +00:00
|
|
|
If the hardware you want to add support for is ar71xx, adding a new profile
|
|
|
|
is sufficient.
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
Profiles are defined in ``targets/*`` in a shell-based DSL (so common shell
|
2018-01-19 13:16:58 +00:00
|
|
|
command syntax like ``if`` can be used).
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
The ``device`` command is used to define an image build for a device. It takes
|
|
|
|
two or three parameters.
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
The first parameter defines the Gluon profile name, which is used to refer to the
|
|
|
|
device and is part of the generated image name. The profile name must be same as
|
|
|
|
the output of the following command (on the target device), so the autoupdater
|
|
|
|
can work::
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
lua -e 'print(require("platform_info").get_image_name())'
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2019-04-01 01:02:35 +00:00
|
|
|
While porting Gluon to a new device, it might happen that the profile name is
|
|
|
|
unknown. Best practise is to generate an image first by using an arbitrary value
|
2018-03-12 02:28:28 +00:00
|
|
|
and then executing the lua command on the device and use its output from then on.
|
|
|
|
|
2018-07-10 20:57:40 +00:00
|
|
|
The second parameter defines the name of the image files generated by OpenWrt. Usually,
|
|
|
|
it is also the OpenWrt profile name; for devices that still use the old image build
|
|
|
|
code, a third parameter with the OpenWrt profile name can be passed. The profile names
|
2019-04-01 01:02:35 +00:00
|
|
|
can be found in the image Makefiles in ``openwrt/target/linux/<target>/image/Makefile``.
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
Examples::
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
device tp-link-tl-wr1043n-nd-v1 tl-wr1043nd-v1
|
|
|
|
device alfa-network-hornet-ub hornet-ub HORNETUB
|
|
|
|
|
|
|
|
Suffixes and extensions
|
|
|
|
'''''''''''''''''''''''
|
|
|
|
|
|
|
|
By default, image files are expected to have the extension ``.bin``. In addition,
|
2018-07-10 20:57:40 +00:00
|
|
|
the images generated by OpenWrt have a suffix before the extension that defaults to
|
2017-01-18 16:21:43 +00:00
|
|
|
``-squashfs-factory`` and ``-squashfs-sysupgrade``.
|
|
|
|
|
|
|
|
This can be changed using the ``factory`` and ``sysupgrade`` commands, either at
|
|
|
|
the top of the file to set the defaults for all images, or for a single image. There
|
|
|
|
are three forms with 0 to 2 arguments (all work with ``sysupgrade`` as well)::
|
|
|
|
|
|
|
|
factory SUFFIX .EXT
|
|
|
|
factory .EXT
|
|
|
|
factory
|
|
|
|
|
|
|
|
When only an extension is given, the default suffix is retained. When no arguments
|
|
|
|
are given, this signals that no factory (or sysupgrade) image exists.
|
|
|
|
|
|
|
|
Aliases
|
|
|
|
'''''''
|
|
|
|
|
2018-07-10 20:57:40 +00:00
|
|
|
Sometimes multiple models use the same OpenWrt images. In this case, the ``alias``
|
2017-01-18 16:21:43 +00:00
|
|
|
command can be used to create symlinks and additional entries in the autoupdater
|
|
|
|
manifest for the alternative models.
|
|
|
|
|
|
|
|
Standalone images
|
|
|
|
'''''''''''''''''
|
|
|
|
|
2018-07-10 20:57:40 +00:00
|
|
|
On targets without *per-device rootfs* support in OpenWrt, the commands described above
|
2017-01-18 16:21:43 +00:00
|
|
|
can't be used. Instead, ``factory_image`` and ``sysupgrade_image`` are used::
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
factory_image PROFILE IMAGE .EXT
|
|
|
|
sysupgrade_image PROFILE IMAGE .EXT
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
Again, the profile name must match the value printed by the aforementioned Lua
|
|
|
|
command. The image name must match the part between the target name and the extension
|
2018-07-10 20:57:40 +00:00
|
|
|
as generated by OpenWrt and is to be omitted when no such part exists.
|
2017-01-18 16:21:43 +00:00
|
|
|
|
|
|
|
Packages
|
|
|
|
''''''''
|
|
|
|
|
|
|
|
The ``packages`` command takes an arbitrary number of arguments. Each argument
|
|
|
|
defines an additional package to include in the images in addition to the default
|
2018-07-10 20:57:40 +00:00
|
|
|
package sets defined by OpenWrt. When a package name is prefixed by a minus sign, the
|
2017-01-18 16:21:43 +00:00
|
|
|
packages are excluded instead.
|
|
|
|
|
|
|
|
The ``packages`` command may be used at the top of a target definition to modify
|
|
|
|
the default package list for all images, or just for a single device (when the
|
|
|
|
target supports *per-default rootfs*).
|
|
|
|
|
|
|
|
|
|
|
|
Configuration
|
|
|
|
'''''''''''''
|
|
|
|
|
2019-03-10 19:15:25 +00:00
|
|
|
The ``config`` command allows to add arbitrary target-specific OpenWrt configuration
|
2017-01-18 16:21:43 +00:00
|
|
|
to be emitted to ``.config``.
|
|
|
|
|
|
|
|
Notes
|
|
|
|
'''''
|
2014-09-09 15:08:46 +00:00
|
|
|
|
|
|
|
On devices with multiple WLAN adapters, care must also be taken that the primary MAC address is
|
|
|
|
configured correctly. ``/lib/gluon/core/sysconfig/primary_mac`` should contain the MAC address which
|
2016-05-23 19:02:05 +00:00
|
|
|
can be found on a label on most hardware; if it does not, ``/lib/gluon/upgrade/010-primary-mac``
|
2014-09-09 15:08:46 +00:00
|
|
|
in ``gluon-core`` might need a fix. (There have also been cases in which the address was incorrect
|
2018-07-10 20:57:40 +00:00
|
|
|
even on devices with only one WLAN adapter, in these cases a OpenWrt bug was the cause).
|
2017-01-18 16:21:43 +00:00
|
|
|
|
2014-09-09 15:08:46 +00:00
|
|
|
|
|
|
|
Adding support for new hardware targets
|
|
|
|
---------------------------------------
|
2017-01-18 16:21:43 +00:00
|
|
|
|
2014-09-09 15:08:46 +00:00
|
|
|
Adding a new target is much more complex than adding a new profile. There are two basic steps
|
|
|
|
required for adding a new target:
|
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
Package adjustments
|
|
|
|
'''''''''''''''''''
|
|
|
|
|
2017-02-12 05:11:43 +00:00
|
|
|
One package that may need adjustments for new targets is ``libplatforminfo`` (to be found in
|
2016-09-04 12:25:20 +00:00
|
|
|
`packages/gluon/libs/libplatforminfo <https://github.com/freifunk-gluon/packages/tree/master/libs/libplatforminfo>`_).
|
2017-02-12 05:11:43 +00:00
|
|
|
If the new platform works fine with the definitions found in ``default.c``, nothing needs to be done. Otherwise,
|
|
|
|
create a definition for the added target or subtarget, either by symlinking one of the files in the ``templates``
|
|
|
|
directory, or adding a new source file.
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2017-04-12 02:22:45 +00:00
|
|
|
On many targets, Gluon's network setup scripts (mainly in the package ``gluon-core``)
|
2014-09-09 15:08:46 +00:00
|
|
|
won't run correctly without some adjustments, so better double check that everything is fine there (and the files
|
|
|
|
``primary_mac``, ``lan_ifname`` and ``wan_ifname`` in ``/lib/gluon/core/sysconfig/`` contain sensible values).
|
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
Build system support
|
|
|
|
''''''''''''''''''''
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2017-01-18 16:21:43 +00:00
|
|
|
A definition for the new target must be created under ``targets``, and it must be added
|
|
|
|
to ``targets/targets.mk``. The ``GluonTarget`` macro takes one to three arguments:
|
|
|
|
the target name, the Gluon subtarget name (if the target has subtargets), and the
|
2018-07-10 20:57:40 +00:00
|
|
|
OpenWrt subtarget name (if it differs from the Gluon subtarget). The third argument
|
2017-01-18 16:21:43 +00:00
|
|
|
can be used to define multiple Gluon targets with different configuration for the
|
2018-07-10 20:57:40 +00:00
|
|
|
same OpenWrt target, like it is done for the ``ar71xx-tiny`` target.
|
2014-09-09 15:08:46 +00:00
|
|
|
|
2015-07-12 20:37:09 +00:00
|
|
|
After this, is should be sufficient to call ``make GLUON_TARGET=<target>`` to build the images for the new target.
|