├── LICENSE ├── README.md ├── docs ├── LICENSE.txt ├── edgex.md ├── img │ ├── board_uart_1.jpg │ └── board_uart_2.jpg ├── index.md ├── mfx-1.md └── mfx-mini.md ├── mfx-1 └── edgex │ └── package.sh ├── mkdocs.yml └── scripts ├── pppd-creator.sh └── setup-zeromq.sh /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | https://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | Copyright 2015-2019 Mainflux 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | https://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mainflux Gateways 2 | 3 | Mainflux gateways are HW gateways that can be used as a far IoT edge gateways 4 | to connect local devices and send data to Mainflux IoT platform in the cloud or on-prem. 5 | 6 | 7 | Mainflux develops and maintains SW and FW for 2 types of IoT edge gateways: 8 | - *MFX-1*, powerfull ARM-based edge gateway 9 | - *MFX-mini*, modest MIPS-based edge gateway with OpenWrt system 10 | 11 | Mainflux gateways are remotely managed by the Edgeflux application running in the cloud. 12 | 13 | In order to do this management, Edgeflux demands that each edgd gateway runs locally 14 | a network agent, called Edged. 15 | 16 | Edged is a small MQTT client, which connects to Mainflux 17 | and subscribes to channels dedicated for controlplane. 18 | It receives commands via Mainflux from Edgeflux application in the cloud, 19 | then executes these commands locally on the gateway and sends the responses 20 | back to the Edgeflux in the cloud. 21 | 22 | 23 | ## MFX-1 24 | ### HW 25 | MFX-1 is ARM gateway based on [SolidRun's CBi board](https://www.solid-run.com/nxp-family/hummingboard-cbi/). 26 | 27 | It is based on [i.MX6 ARM Cortex-A9 SoM](https://www.solid-run.com/nxp-family/imx6-som/) and has 28 | a lot of very powerful industrial [features](https://www.solid-run.com/nxp-family/hummingboard-cbi/#specifications). 29 | 30 | ### SW 31 | MFX-1 is powered by [EdgeX Foundry](https://www.edgexfoundry.org/) system, specifically crafted for this board 32 | by [Mainflux team](https://www.mainflux.com). 33 | 34 | Mainflux is official Linux Foundation's EdgeX Foundry member and one of the biggest contributors. 35 | SW components running on the MFX-1 gateway are curated, tested and maintained by Mainflux alongside with 36 | top-notch tooling and documentation needed for edge application development. 37 | 38 | ## MFX-mini 39 | MFX-mini is MIPS gateway based on [8Devices' Lima Board](https://www.8devices.com/products/lima). 40 | 41 | ### HW 42 | Lima is a [QCA4531](https://www.qualcomm.com/products/qca4531) chipset based module with a 650 MHz CPU and 802.11n 2x2 (MIMO) radio. 43 | 44 | ### SW 45 | MFX-mini is simple, low-cost, low-power edge node, powered by [OpenWrt](https://openwrt.org/) Linux - a powerful SDK for application development. 46 | 47 | MFX-mini runs `mEdge` (mini-edge) Mainflux firmwre - a minimalistic Edged agent connected 48 | to Mainflux cloud and Mosquitto MQTT broker locally - to enable simple, 49 | highly secure embedded edge IoT platform. 50 | 51 | ## Documentation 52 | Documentation is located in the [./docs](docs) directory. 53 | 54 | ## Community 55 | - [Google group](https://groups.google.com/forum/#!forum/mainflux) 56 | - [Gitter](https://gitter.im/mainflux/mainflux) 57 | - [Twitter](https://twitter.com/mainflux) 58 | 59 | ## License 60 | [Apache-2.0](LICENSE) 61 | 62 | -------------------------------------------------------------------------------- /docs/LICENSE.txt: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /docs/edgex.md: -------------------------------------------------------------------------------- 1 | # EdgeX Foundry 2 | [EdgeX Foundry](https://www.edgexfoundry.org/) is an open-source edge system SW based on micro-services. 3 | 4 | MFX-1 SW is based on [Go implementation](https://github.com/edgexfoundry/edgex-go) of EdgeX. 5 | 6 | EdgeX system si monitored and controled via EdgeX SW Management Agent service (SMA), 7 | which exposes HTTP REST API for sending commands and fetching logs and metrics. 8 | 9 | Additionally, Mainflux Edged agent runs on a same gateway and: 10 | - Connects to MQTT broker in the cloud on one side 11 | - Connects to EdgeX SMA via HTTP on the other side 12 | 13 | It serves as a mqtt2http proxy to connect whole gateway to the Mianflux cloud and manipulate EdgeX SMA. 14 | 15 | ## Install 16 | ### Compilation 17 | #### Cross-Compiler 18 | ZMQ demand C++11-compliant cross-compiler, and Debian base `arm-linux-gnueabihf` will not work. 19 | Linaro cross compiler can be used - more info [here](https://www.linaro.org/downloads/). 20 | It can be fetched from [here](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads), 21 | you need to look for `AArch32 target with hard float (arm-linux-gnueabihf)` 22 | 23 | #### ZMQ 24 | In order to cross-compile ZMQ: 25 | 26 | Fetch he last release from [ZMQ GitHub releases](https://github.com/zeromq/libzmq/releases): 27 | ``` 28 | wget https://github.com/zeromq/libzmq/archive/v4.3.1.tar.gz 29 | ``` 30 | 31 | Follow the instructions [here](http://zeromq.org/build:arm): 32 | ``` 33 | ./autogen.sh 34 | ./configure --host=arm-none-linux-gnueabihf CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ 35 | make 36 | ``` 37 | 38 | Produced library will be located in `src/.libs/` 39 | 40 | ##### Gateway 41 | You need the same ZMQ on the gateway as well, as CGO will link it dynamically. 42 | Static linking would demand linking of stdlib and then it demands toolchain and so on. 43 | 44 | So easier way is just to compile and install same version of ZMQ on gateway: 45 | 46 | ``` 47 | sudo apt install -y libtool pkg-config build-essential autoconf automake uuid-dev 48 | ./autogen 49 | ./configure 50 | make 51 | sudo make install 52 | ``` 53 | 54 | 55 | 56 | #### EdgeX Foundry 57 | EdgeX Foundry must be cross-compiled for ARM (in order to speed-up the time of native compilation on resource-modest ARM gateway). 58 | 59 | A [Makefile](edgex/Makefile) in [edgex](edgex) dir can be used, but we need to define ARM based build: 60 | ``` 61 | drasko@Marx:~/go/src/github.com/edgexfoundry/edgex-go$ git diff 62 | diff --git a/Makefile b/Makefile 63 | index 928c1650..05127a48 100644 64 | --- a/Makefile 65 | +++ b/Makefile 66 | @@ -14,12 +14,12 @@ BUILD_DIR := build 67 | ### 68 | # For ARM cross-compilation add something like: 69 | # 70 | -# CC = arm-linux-gnueabi-gcc 71 | -# CGO_LDFLAGS = -L//src/.libs 72 | -# CGO_CFLAGS = -I//include 73 | -# GOOS = linux 74 | -# GOARCH = arm 75 | -# GOARM = 7 76 | +CC = arm-linux-gnueabi-gcc 77 | +CGO_LDFLAGS = -L/home/drasko/edgex/libzmq-4.3.1/src/.libs 78 | +CGO_CFLAGS = -I/home/drasko/edgex/libzmq-4.3.1/include 79 | +GOOS = linux 80 | +GOARCH = arm 81 | +GOARM = 7 82 | ### 83 | FLAGS = GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} GO111MODULE=on 84 | GO_FLAGS = $(FLAGS) CGO_ENABLED=0 85 | ``` 86 | 87 | ##### Configuration 88 | Redis should be used. Example: 89 | ``` 90 | [Databases] 91 | [Databases.Primary] 92 | Host = 'localhost' 93 | Name = 'coredata' 94 | Password = '' 95 | Port = 6379 96 | Username = '' 97 | Timeout = 5000 98 | Type = 'redisdb' 99 | ``` 100 | 101 | This should be put for `core-data`, `core-metadata`, `export-client`, `support-scheduler` and `support-notifications` microservices. 102 | 103 | `support-logging` does not yet have Redis enablement, so `file` setting can be used: 104 | 105 | ``` 106 | [Writable] 107 | Persistence = 'file' 108 | LogLevel = 'INFO' 109 | ``` 110 | 111 | ## Docker 112 | In order to build in Docker, `libzmq` needs to be cross-compiled in the builder container: 113 | - If Debian builder is used (`golang:stretch`), then Linaro toolchain can be used 114 | - If Alpine builder is used (`golang:alpine3.9`) then a [musl](https://www.musl-libc.org/) toolchain must be used, 115 | and this one must be produced. Best is to use [musl-cross-make](https://github.com/richfelker/musl-cross-make). 116 | 117 | Production container must be of a type `arm32v7/`: 118 | - If Debian is used for builder, then production container must also be 119 | Debian (because of `glibc`, and not `musl`), and reccomended container would be `arm32v7/stretch-slim` 120 | - If Alpine is used for builder, then production container can be `arm32v7/alpine` 121 | 122 | ### Toolchain 123 | In order to produce `arm-linux-musleabihf` toolchain needed for Alpine cross-compilation: 124 | ``` 125 | git clone https://github.com/richfelker/musl-cross-make 126 | cd musl-cross-make 127 | cp config.mak.dist config.mak 128 | ``` 129 | 130 | Edit `config.mak` and uncomment `arm-linux-musleabihf` target: 131 | ``` 132 | # TARGET = i486-linux-musl 133 | # TARGET = x86_64-linux-musl 134 | # TARGET = arm-linux-musleabi 135 | TARGET = arm-linux-musleabihf 136 | # TARGET = sh2eb-linux-muslfdpic 137 | ``` 138 | 139 | Then: 140 | ``` 141 | make -j 16 142 | ``` 143 | 144 | This will produce `musl-cross-make/output` directory which you should copy to `docker` dir of EdgeX: 145 | ``` 146 | cp musl-cross-make/output $GOPATH/src/github.com/edgexfoundry/edgex-go/docker/toolchain 147 | ``` 148 | 149 | This is where Dockerfile will look for it. 150 | 151 | ### qemu-arm-static 152 | Production container must install `libzmq` (in the case of Debian this is `libzmq5`), 153 | and since we are in ARM container executables like `apk` will not work. 154 | For that reason we need to add `qemu-arm-static`, like explained [here](https://ownyourbits.com/2018/06/27/running-and-building-arm-docker-containers-in-x86/) or 155 | [here](https://www.balena.io/blog/building-arm-containers-on-any-x86-machine-even-dockerhub/) 156 | 157 | > Alpine images take ~24MB while Strech-Slim images might take ~75MB 158 | 159 | ### Transfering Docker image 160 | Docker images must be transfered to gateway. 161 | 162 | On host: 163 | ``` 164 | docker save -o export-distro.img edgex/export-distro 165 | scp export-distro.img debian@sr-imx6.local:~/ 166 | ``` 167 | 168 | On gateway: 169 | ``` 170 | docker load -i export-distro.img 171 | docker run edgex/export-distro:1.0.0-dev 172 | ``` 173 | -------------------------------------------------------------------------------- /docs/img/board_uart_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainflux/gateways/ecd4909031e23a929f5412d898c812e8ad887e48/docs/img/board_uart_1.jpg -------------------------------------------------------------------------------- /docs/img/board_uart_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mainflux/gateways/ecd4909031e23a929f5412d898c812e8ad887e48/docs/img/board_uart_2.jpg -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | ## Mainflux Gateways 2 | 3 | Mainflux gateways are HW gateways that can be used as a far IoT edge gateways 4 | to connect local devices and send data to Mainflux IoT platform in the cloud or on-prem. 5 | 6 | 7 | Mainflux develops and maintains SW and FW for 2 types of IoT edge gateways: 8 | - MFX-1, powerfull ARM-based edge gateway 9 | - MFX-mini, modest MIPS-based edge gateway with OpenWrt system 10 | 11 | Mainflux gateways are remotely managed by the Edgeflux application running in the cloud. 12 | 13 | In order to do this management, Edgeflux demands that each edgd gateway runs locally 14 | a network agent, called Edged. 15 | 16 | Edged is a small MQTT client, which connects to Mainflux 17 | and subscribes to channels dedicated for controlplane. 18 | It receives commands via Mainflux from Edgeflux application in the cloud, 19 | then executes these commands locally on the gateway and sends the responses 20 | back to the Edgeflux in the cloud. 21 | 22 | 23 | ### MFX-1 24 | #### HW 25 | MFX-1 is ARM gateway based on [SolidRun's CBi board](https://www.solid-run.com/nxp-family/hummingboard-cbi/). 26 | 27 | It is based on [i.MX6 ARM Cortex-A9 SoM](https://www.solid-run.com/nxp-family/imx6-som/) and has 28 | a lot of very powerful industrial [features](https://www.solid-run.com/nxp-family/hummingboard-cbi/#specifications). 29 | 30 | #### SW 31 | MFX-1 is powered by [EdgeX Foundry](https://www.edgexfoundry.org/) system, specifically crafted for this board 32 | by [Mainflux team](https://www.mainflux.com). 33 | 34 | Mainflux is official Linux Foundation's EdgeX Foundry member and one of the biggest contributors. 35 | SW components running on the MFX-1 gateway are curated, tested and maintained by Mainflux alongside with 36 | top-notch tooling and documentation needed for edge application development. 37 | 38 | ### MFX-mini 39 | MFX-mini is MIPS gateway based on [8Devices' Lima Board](https://www.8devices.com/products/lima). 40 | Lima is a [QCA4531](https://www.qualcomm.com/products/qca4531) chipset based module with a 650 MHz CPU and 802.11n 2x2 (MIMO) radio. 41 | 42 | MFX-mini is simple, low-cost, low-power edge node, powered by [OpenWrt](https://openwrt.org/) Linux - a powerful SDK for application development. 43 | 44 | MFX-mini runs `mEdge` (mini-edge) Mainflux firmwre - a minimalistic Edged agent connected 45 | to Mainflux cloud and Mosquitto MQTT broker locally - to enable simple, 46 | highly secure embedded edge IoT platform. 47 | 48 | ## Community 49 | - [Google group](https://groups.google.com/forum/#!forum/mainflux) 50 | - [Gitter](https://gitter.im/mainflux/mainflux) 51 | - [Twitter](https://twitter.com/mainflux) 52 | 53 | ## License 54 | [Apache-2.0](LICENSE) 55 | 56 | 57 | -------------------------------------------------------------------------------- /docs/mfx-1.md: -------------------------------------------------------------------------------- 1 | # MFX-1 Gateway 2 | MFX-1 gateway is based on [SolidRun](https://www.solid-run.com/) boards: 3 | - [CBi board](https://www.solid-run.com/nxp-family/hummingboard-cbi/) for ARM gateway 4 | - [Solid PC](https://www.solid-run.com/intel-braswell-family/solidpc-q4/) for Intel gateway 5 | 6 | ## Documentation 7 | Documentation about Solid Run HW can be found here: https://developer.solid-run.com/ 8 | 9 | In particular, information about i.MX6 SoM can be found here: https://developer.solid-run.com/products/imx6-som/ 10 | 11 | ## UART 12 | UART pins are located on the edge on the board: 13 | 14 | ![](img/board_uart_1.jpg) 15 | 16 | They should be connected to PC via UART-to-USB cable: 17 | 18 | ![](img/board_uart_2.jpg) 19 | 20 | More information can be found [here](https://developer.solid-run.com/knowledge-base/hummingboard-gate-edge-uart-console/). 21 | 22 | Use [Minicom](https://en.wikipedia.org/wiki/Minicom) or other serial terminal to read UART console from the board. 23 | 24 | Official guide can be found [here](https://developer.solid-run.com/knowledge-base/serial-connection/) and [here](https://developer.solid-run.com/knowledge-base/serial-console-usb-uart/) 25 | Note: disable Hardware Flow Control. 26 | 27 | ## Flashing SD card 28 | Instructions can be found here: https://developer.solid-run.com/knowledge-base/flashing-an-sd-card/ 29 | 30 | Software can be downloaded from here: https://developer.solid-run.com/article-categories/i-mx6-software/ 31 | 32 | For SD card jumpers 3-4 and 5-6 need to be set, like explained 33 | [here](https://developer.solid-run.com/knowledge-base/hummingboard-edge-gate-boot-jumpers/) 34 | under `MicroSD 2 jumpers will be needed: (3+4), (5+6)` chapter. 35 | 36 | Once you are greeted by a login prompt, the default username and password are both "debian". 37 | For security reasons there is no root password! If you really need one, you can run `sudo passwd root` to set your own. 38 | 39 | ### Flashing eMMC from SD card 40 | If Debian is used, instructions for flashing eMMC from SD card can be found 41 | [here](https://developer.solid-run.com/knowledge-base/i-mx6-debian/). 42 | 43 | Besically, WiFi has to be enabled first, Debian image then can be downloaded and `dd`-ed directly to the flash. 44 | 45 | ## WiFi 46 | File `/etc/network/interfaces` already includes files from `/etc/network/interfaces.d` directory: 47 | 48 | ``` 49 | root@sr-imx6:~# cat /etc/network/interfaces 50 | # interfaces(5) file used by ifup(8) and ifdown(8) 51 | # Include files from /etc/network/interfaces.d: 52 | source-directory /etc/network/interfaces.d 53 | ``` 54 | 55 | So we need to create file `/etc/network/interfaces.d/wlan0`: 56 | ```root@sr-imx6:~# cat /etc/network/interfaces.d/wlan0 57 | auto wlan0 58 | iface wlan0 inet dhcp 59 | wpa-essid 60 | wpa-psk 61 | ``` 62 | or user builtin connmanctl 63 | 64 | ``` 65 | wpa_passphrase NETWORK_SSID PASS ( obtain psk passphrase ) 66 | sudo connmanctl 67 | enable wifi 68 | scan wifi 69 | services 70 | agent on 71 | connect [access_point] 72 | 73 | ``` 74 | 75 | > After creating this file a restart is needed. Hints can be found [here](https://askubuntu.com/questions/333063/restart-network-interface-after-editing-etc-network-interfaces)m but in the worst case whole gateway can be restarted. 76 | 77 | ## Avahi 78 | ### Rename host 79 | Install Avahi: 80 | [Avahi](https://www.avahi.org/) is mDNS/DNS-SD daemon. 81 | 82 | Install: 83 | ``` 84 | apt install avahi-daemon 85 | ``` 86 | 87 | Now you can access the box via `sr-imx6.local` host alias: 88 | ``` 89 | ssh debian@sr-imx6.local 90 | ``` 91 | 92 | Follow [this thread](https://raspberrypi.stackexchange.com/questions/48056/how-to-login-as-root-remotely) to see how to ssh as a root. 93 | 94 | ## SFTP 95 | Either install Filezilla or use Nautilus: 96 | - In Nautilus window press `Ctrl + L` 97 | - Type `sftp://sr-imx6.local` 98 | 99 | ## Docker 100 | To install Docker, follow the instructions [here](https://docs.docker.com/install/linux/docker-ce/debian/). 101 | 102 | Then follow [post installtion steps](https://docs.docker.com/install/linux/linux-postinstall/) to add user to `docker` group. 103 | 104 | ## 3G-4G Connection 105 | 106 | Following [this instruction](https://www.robertlucian.com/2018/08/29/mobile-network-access-rpi/) basic steps are 107 | ``` 108 | sudo apt-get update && sudo apt-get install -y --no-install-recommends ppp 109 | ``` 110 | use scripts/pppd-creator.sh 111 | 112 | ``` 113 | sudo bash ppp-creator.sh telenor ttyUSB3 114 | 115 | 116 | creating script file : /etc/chatscripts/quectel-chat-connect creating script file : /etc/chatscripts/quectel-chat-disconnect 117 | creating script file : /etc/ppp/peers/gprs 118 | 119 | ``` 120 | edit /etc/ppp/pap-secrets 121 | adding 122 | ``` 123 | #user host pass 124 | telenor * gprs 125 | ``` 126 | then start connection 127 | 128 | ``` 129 | sudo pppd call gprs& 130 | 131 | sudo ifconfig ppp0 //validate connection 132 | ``` 133 | -------------------------------------------------------------------------------- /docs/mfx-mini.md: -------------------------------------------------------------------------------- 1 | # MFX-Mini Gateway 2 | MFX-Mini GW is based on 8Devices' [Lima board](https://www.8devices.com/products/lima). 3 | 4 | Info about Lima board can be found [here](https://www.8devices.com/wiki/lima). 5 | 6 | ## Cross-compiling 7 | Quick info about cross-compiling can be found [here](https://www.8devices.com/wiki/lima:build). 8 | 9 | ## WiFi 10 | Need to edit 2 files: 11 | - `/etc/config/wireless` 12 | - `/etc/config/network` 13 | 14 | ### `/etc/config/wireless` 15 | This file is needed to define STA mode. 16 | 17 | ``` 18 | root@Lima:/# cat /etc/config/wireless 19 | 20 | config wifi-device 'radio0' 21 | option type 'mac80211' 22 | option channel '11' 23 | option hwmode '11g' 24 | option path 'platform/qca953x_wmac' 25 | option htmode 'HT20' 26 | option disabled '0' 27 | 28 | config wifi-iface 29 | option device 'radio0' 30 | option network 'wwan' 31 | option mode 'sta' 32 | option encryption 'psk2' 33 | option ssid 'my_ssid' 34 | option key 'my_password' 35 | ``` 36 | 37 | ### `/etc/config/network` 38 | This file is needed to add WWAN network interface. 39 | 40 | ``` 41 | root@Lima:/# cat /etc/config/network 42 | 43 | config interface 'loopback' 44 | option ifname 'lo' 45 | option proto 'static' 46 | option ipaddr '127.0.0.1' 47 | option netmask '255.0.0.0' 48 | 49 | config globals 'globals' 50 | option ula_prefix 'fd63:6fe1:4c42::/48' 51 | 52 | config interface 'lan' 53 | option type 'bridge' 54 | option ifname 'eth0' 55 | option proto 'static' 56 | option ipaddr '192.168.1.1' 57 | option netmask '255.255.255.0' 58 | option ip6assign '60' 59 | 60 | config interface 'wan' 61 | option ifname 'eth1' 62 | option proto 'dhcp' 63 | 64 | config interface 'wan6' 65 | option ifname 'eth1' 66 | option proto 'dhcpv6' 67 | 68 | config interface 'wwan' 69 | option proto 'dhcp' 70 | ``` 71 | 72 | ### Avahi 73 | ``` 74 | opkg install avahi-daemon 75 | ``` 76 | This will install `avahi-dbus-daemon` (default one). 77 | 78 | Or via feeds and compilation: 79 | ``` 80 | ./scripts/feeds install avahi-dbus-daemon 81 | ``` 82 | 83 | ### Mosquitto 84 | ``` 85 | ./scripts/feeds install mosquitto-ssl 86 | ``` 87 | 88 | #### Upgrade 89 | ``` 90 | scp ./bin/targets/ar71xx/generic/openwrt-ar71xx-generic-lima-squashfs-sysupgrade.bin root@openwrt.local:/tmp 91 | ``` 92 | 93 | Then in Minicom: 94 | ``` 95 | vi /lib/upgrade/keep.d/base-files 96 | ``` 97 | and add `/etc/config/wireless`. 98 | 99 | Then: 100 | ``` 101 | sysupgrade -v /tmp/openwrt-ar71xx-generic-lima-squashfs-sysupgrade.bin 102 | ``` 103 | -------------------------------------------------------------------------------- /mfx-1/edgex/package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2019 4 | # Mainflux 5 | # 6 | # SPDX-License-Identifier: Apache-2.0 7 | 8 | 9 | # Collects EdgeX Go binaries (must be previously built) 10 | # and packages them into a dir alongside with necessary config files. 11 | # This facilitates transfer of binaries to otehr machine 12 | # (for example copy of cross-compiled binaries to ARM gateway) 13 | 14 | DIR=$PWD 15 | CMD_DIR=../cmd 16 | SERVICES=(config-seed export-client core-metadata core-command support-logging \ 17 | support-notifications sys-mgmt-executor sys-mgmt-agent support-scheduler \ 18 | core-data export-distro) 19 | 20 | PKG_DIR=${1:-edgex} 21 | 22 | # Copy binaries and config 23 | mkdir -p $PKG_DIR 24 | for i in "${SERVICES[@]}"; do 25 | mkdir -p $PKG_DIR/$i 26 | cp $CMD_DIR/$i/$i $PKG_DIR/$i 27 | cp -r $CMD_DIR/$i/res $PKG_DIR/$i 2>/dev/null || : 28 | done 29 | 30 | # Copy and modify run script 31 | cp run.sh $PKG_DIR 32 | sed -i 's#BIN_DIR=../cmd#BIN_DIR=.#g' $PKG_DIR/run.sh 33 | #sed -i 's#EDGEX_CONF_DIR=./res#EDGEX_CONF_DIR=.#g' $PKG_DIR/run.sh 34 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019 3 | # Mainflux 4 | # 5 | # SPDX-License-Identifier: Apache-2.0 6 | # 7 | 8 | copyright: Copyright (c) 2015-2019 Mainflux 9 | repo_url: https://github.com/mainflux/mfx-1 10 | site_description: Mainflux IoT System 11 | site_name: Mainflux MFX-1 Gateway 12 | theme: readthedocs 13 | 14 | extra: 15 | logo: docs/img/logo.png 16 | author: 17 | github: mainflux/mfx-1 18 | twitter: mainflux 19 | 20 | markdown_extensions: 21 | - admonition 22 | - toc: 23 | permalink: '#' 24 | 25 | pages: 26 | - Overview: 27 | - About: index.md 28 | - Contributing: CONTRIBUTING.md 29 | - License: LICENSE.txt 30 | - MFX-1: mfx-1.md 31 | - MFX Mini: mfx-mini.md 32 | - EdgeX: edgex.md 33 | -------------------------------------------------------------------------------- /scripts/pppd-creator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "creating directories" 3 | mkdir -p /etc/chatscripts 4 | mkdir -p /etc/ppp/peers 5 | 6 | echo "creating script file : /etc/chatscripts/quectel-chat-connect" 7 | echo " 8 | ABORT \"BUSY\" 9 | ABORT \"NO CARRIER\" 10 | ABORT \"NO DIALTONE\" 11 | ABORT \"ERROR\" 12 | ABORT \"NO ANSWER\" 13 | TIMEOUT 30 14 | \"\" AT 15 | OK ATE0 16 | OK ATI;+CSUB;+CSQ;+COPS?;+CGREG?;&D2 17 | # Insert the APN provided by your network operator, default apn is $1 18 | OK AT+CGDCONT=1,\"IP\",\"\\T\",,0,0 19 | OK ATD*99# 20 | CONNECT" > /etc/chatscripts/quectel-chat-connect 21 | 22 | 23 | echo "creating script file : /etc/chatscripts/quectel-chat-disconnect" 24 | echo " 25 | ABORT \"ERROR\" 26 | ABORT \"NO DIALTONE\" 27 | SAY \"\nSending break to the modem\n\" 28 | "" +++ 29 | "" +++ 30 | "" +++ 31 | SAY \"\nGoodbay\n\"" > /etc/chatscripts/quectel-chat-disconnect 32 | 33 | 34 | echo "creating script file : /etc/ppp/peers/gprs" 35 | echo " 36 | /dev/$2 115200 37 | # The chat script, customize your APN in this file 38 | connect 'chat -s -v -f /etc/chatscripts/quectel-chat-connect -T $1' 39 | # The close script 40 | disconnect 'chat -s -v -f /etc/chatscripts/quectel-chat-disconnect' 41 | # Hide password in debug messages 42 | hide-password 43 | # The phone is not required to authenticate 44 | noauth 45 | # Debug info from pppd 46 | debug 47 | # If you want to use the HSDPA link as your gateway 48 | defaultroute 49 | # pppd must not propose any IP address to the peer 50 | noipdefault 51 | # No ppp compression 52 | novj 53 | novjccomp 54 | noccp 55 | ipcp-accept-local 56 | ipcp-accept-remote 57 | local 58 | # For sanity, keep a lock on the serial line 59 | lock 60 | modem 61 | dump 62 | nodetach 63 | # Hardware flow control 64 | nocrtscts 65 | remotename 3gppp 66 | ipparam 3gppp 67 | ipcp-max-failure 30 68 | # Ask the peer for up to 2 DNS server addresses 69 | usepeerdns" > /etc/ppp/peers/gprs 70 | -------------------------------------------------------------------------------- /scripts/setup-zeromq.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | # Download zeromq 4 | # Ref http://zeromq.org/intro:get-the-software 5 | wget https://github.com/zeromq/libzmq/releases/download/v4.3.1/zeromq-4.3.1.tar.gz 6 | 7 | # Unpack tarball package 8 | tar xvzf zeromq-4.3.1.tar.gz 9 | 10 | # Install dependency 11 | sudo apt-get update && \ 12 | sudo apt-get install -y libtool pkg-config build-essential autoconf automake uuid-dev 13 | 14 | # Create make file 15 | cd zeromq-4.3.1 16 | ./configure 17 | 18 | # Build and install(root permission only) 19 | sudo make install 20 | 21 | # Install zeromq driver on linux 22 | sudo ldconfig 23 | 24 | # Check installed 25 | ldconfig -p | grep zmq 26 | 27 | # Expected 28 | ############################################################ 29 | # libzmq.so.5 (libc6,x86-64) => /usr/local/lib/libzmq.so.5 30 | # libzmq.so (libc6,x86-64) => /usr/local/lib/libzmq.so 31 | ############################################################ 32 | --------------------------------------------------------------------------------