hardware.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. Adding support for new hardware
  2. ===============================
  3. This page will give a short overview on how to add support
  4. for new hardware to Gluon.
  5. Hardware requirements
  6. ---------------------
  7. Having an ath9k (or ath10k) based WLAN adapter is highly recommended,
  8. although other chipsets may also work. VAP (multiple SSID) support
  9. is a requirement.
  10. .. _hardware-adding-profiles:
  11. Adding profiles
  12. ---------------
  13. The vast majority of devices with ath9k WLAN is based on the ar71xx target of LEDE.
  14. If the hardware you want to add support for is ar71xx, adding a new profile
  15. is sufficient.
  16. Profiles are defined in ``targets/*`` in a shell-based DSL (so common shell
  17. command syntax like ``if`` can be used).
  18. The ``device`` command is used to define an image build for a device. It takes
  19. two or three parameters.
  20. The first parameter defines the Gluon profile name, which is used to refer to the
  21. device and is part of the generated image name. The profile name must be same as
  22. the output of the following command (on the target device), so the autoupdater
  23. can work::
  24. lua -e 'print(require("platform_info").get_image_name())'
  25. The second parameter defines the name of the image files generated by LEDE. Usually,
  26. it is also the LEDE profile name; for devices that still use the old image build
  27. code, a third parameter with the LEDE profile name can be passed. The profile names
  28. can be found in the image Makefiles in ``lede/target/linux/<target>/image/Makefile``.
  29. Examples::
  30. device tp-link-tl-wr1043n-nd-v1 tl-wr1043nd-v1
  31. device alfa-network-hornet-ub hornet-ub HORNETUB
  32. Suffixes and extensions
  33. '''''''''''''''''''''''
  34. By default, image files are expected to have the extension ``.bin``. In addition,
  35. the images generated by LEDE have a suffix before the extension that defaults to
  36. ``-squashfs-factory`` and ``-squashfs-sysupgrade``.
  37. This can be changed using the ``factory`` and ``sysupgrade`` commands, either at
  38. the top of the file to set the defaults for all images, or for a single image. There
  39. are three forms with 0 to 2 arguments (all work with ``sysupgrade`` as well)::
  40. factory SUFFIX .EXT
  41. factory .EXT
  42. factory
  43. When only an extension is given, the default suffix is retained. When no arguments
  44. are given, this signals that no factory (or sysupgrade) image exists.
  45. Aliases
  46. '''''''
  47. Sometimes multiple models use the same LEDE images. In this case, the ``alias``
  48. command can be used to create symlinks and additional entries in the autoupdater
  49. manifest for the alternative models.
  50. Standalone images
  51. '''''''''''''''''
  52. On targets without *per-device rootfs* support in LEDE, the commands described above
  53. can't be used. Instead, ``factory_image`` and ``sysupgrade_image`` are used::
  54. factory_image PROFILE IMAGE .EXT
  55. sysupgrade_image PROFILE IMAGE .EXT
  56. Again, the profile name must match the value printed by the aforementioned Lua
  57. command. The image name must match the part between the target name and the extension
  58. as generated by LEDE and is to be omitted when no such part exists.
  59. Packages
  60. ''''''''
  61. The ``packages`` command takes an arbitrary number of arguments. Each argument
  62. defines an additional package to include in the images in addition to the default
  63. package sets defined by LEDE. When a package name is prefixed by a minus sign, the
  64. packages are excluded instead.
  65. The ``packages`` command may be used at the top of a target definition to modify
  66. the default package list for all images, or just for a single device (when the
  67. target supports *per-default rootfs*).
  68. Configuration
  69. '''''''''''''
  70. The ``config`` command allows to add arbitary target-specific LEDE configuration
  71. to be emitted to ``.config``.
  72. Notes
  73. '''''
  74. On devices with multiple WLAN adapters, care must also be taken that the primary MAC address is
  75. configured correctly. ``/lib/gluon/core/sysconfig/primary_mac`` should contain the MAC address which
  76. can be found on a label on most hardware; if it does not, ``/lib/gluon/upgrade/010-primary-mac``
  77. in ``gluon-core`` might need a fix. (There have also been cases in which the address was incorrect
  78. even on devices with only one WLAN adapter, in these cases a LEDE bug was the cause).
  79. Adding support for new hardware targets
  80. ---------------------------------------
  81. Adding a new target is much more complex than adding a new profile. There are two basic steps
  82. required for adding a new target:
  83. Package adjustments
  84. '''''''''''''''''''
  85. One package that may need adjustments for new targets is ``libplatforminfo`` (to be found in
  86. `packages/gluon/libs/libplatforminfo <https://github.com/freifunk-gluon/packages/tree/master/libs/libplatforminfo>`_).
  87. If the new platform works fine with the definitions found in ``default.c``, nothing needs to be done. Otherwise,
  88. create a definition for the added target or subtarget, either by symlinking one of the files in the ``templates``
  89. directory, or adding a new source file.
  90. On many targets, Gluon's network setup scripts (mainly in the package ``gluon-core``)
  91. won't run correctly without some adjustments, so better double check that everything is fine there (and the files
  92. ``primary_mac``, ``lan_ifname`` and ``wan_ifname`` in ``/lib/gluon/core/sysconfig/`` contain sensible values).
  93. Build system support
  94. ''''''''''''''''''''
  95. A definition for the new target must be created under ``targets``, and it must be added
  96. to ``targets/targets.mk``. The ``GluonTarget`` macro takes one to three arguments:
  97. the target name, the Gluon subtarget name (if the target has subtargets), and the
  98. LEDE subtarget name (if it differs from the Gluon subtarget). The third argument
  99. can be used to define multiple Gluon targets with different configuration for the
  100. same LEDE target, like it is done for the ``ar71xx-tiny`` target.
  101. After this, is should be sufficient to call ``make GLUON_TARGET=<target>`` to build the images for the new target.