The plumCore (IoT) framework
A modular framework for data logging, remote data acquisition and low power wireless mesh networks.
The name represents a seed found in a plum fruit - the core of the plum. Although not used in this manner it sounds sufficiently good to be used as a name for a totally unrelated project.
What is it?
plumCore is a C framework using the microkernel/services pattern. FreeRTOS scheduler is used as the microkernel providing task scheduling and a basic IPC. All the rest is implemented as modular services. A plumCore service provides interfaces used by other services. Interface dependencies are either discovered in runtime (service locator pattern) or injected (dependency injection). Even the service locator is implemented as a service. Most of the code looks like and behaves in an OOP manner. From the user standpoint, a tree-structured CLI (command line interface) is available to configure the device.
plumCore is not meant to be run on dataloggers powered by primary batteries lasting for years. It is not very-low-power friendly as it is not its design goal. It is intended to be used in medium power applications with power requiremens in the tens to hundreds of milliwats range where the actual power consumption of the MCU itself doesn't play a significant role. This is the case of various remotely operated measurement/DAQ systems with optional on-site data processing. The main target application during the development are modular devices for the natWatch project, most of them are powered by solar energy.
Status of the project
The project started a few years ago as a framework for wireless mesh network (MANET) routers. The development stalled a bit and now it is being refactored and enhanced to be actually usable for remote data logging and data acquisition.
Getting and running the plumCore
The current development release source code is available on GitHub https://github.com/iqyx/plumcore/tree/develop
You will need a Linux machine and some additional software to build the sources:
- gcc-arm-none-eabi >= 6, from https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2
- protobuf-python >= 3.4.0, from https://github.com/google/protobuf/releases/download/v3.4.0/protobuf-python-3.4.0.tar.gz
- gitpython (pip install gitpython)
- pyyaml (pip install pyyaml)
After cloning the repository and selecting the required branch, edit config/default.yaml file and do:
# Fetch all required libraries git submodule init git submodule update # Build the nanopb library using make cd lib/other/nanopb/generator/proto && make && cd ../../../../.. # Build the libopencm3 library using make cd lib/libopencm3 && make && cd ../.. scons proto scons scons program
If a selected port requires a bootloader, you have to program it first. Then use the bootloader or a SWD programmer to program the plumCore binary itself. The binary will be located in the bin/ directory.
The build output should look like:
$ scons scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... Compiling services/stm32-watchdog/watchdog.o Creating library services/stm32-watchdog/libstm32-watchdog.a ranlib services/stm32-watchdog/libstm32-watchdog.a Compiling services/stream-over-mqtt/stream_over_mqtt.o Creating library services/stream-over-mqtt/libstream-over-mqtt.a ranlib services/stream-over-mqtt/libstream-over-mqtt.a ... ... Compiling services/interfaces/uxbdevice.o Compiling services/interfaces/uxbslot.o Compiling services/interfaces/plog/client.o Compiling services/interfaces/plog/descriptor.o Compiling services/interfaces/clock/descriptor.o Linking bin/plumcore-plumpot-cellular-0.5.0-split-into-modules.6+2067d83.20180929.elf Creating binary firmware bin/plumcore-plumpot-cellular-0.5.0-split-into-modules.6+2067d83.20180929.bin Generating new firmware signing key bin/test_key.key 1+0 records in 1+0 records out 32 bytes (32 B) copied, 0.000147496 s, 217 kB/s Creating firmware image bin/plumcore-plumpot-cellular-0.5.0-split-into-modules.6+2067d83.20180929.fw verified section at 0x08010000, data 0x08010008, len 176080 bytes firmware version section at 0x08010008, data 0x08010010, len 43 bytes hardware compatibility section at 0x0801003b, data 0x08010043, len 9 bytes dummy section at 0x0801004c, data 0x08010054, len 932 bytes firmware section at 0x080103f8, data 0x08010400, len 175064 bytes verification section at 0x0803afd8, data 0x0803afe0, len 156 bytes sha512 hash section at 0x0803afe0, data 0x0803afe8, len 64 bytes ed25519 signature section at 0x0803b028, data 0x0803b030, len 64 bytes pubkey fingerprint section at 0x0803b070, data 0x0803b078, len 4 bytes scons: done building targets.
Programming output:
$ scons program scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... openocd -s /usr/share/openocd/scripts/ -f interface/stlink-v2-1.cfg -f target/stm32f4x_stlink.cfg -c "init" -c "reset init" -c "flash write_image erase bin/plumcore-plumpot-cellular-0.5.0-split-into-modules.6+2067d83.20180929.fw 0x08010000 bin" -c "reset" -c "shutdown" Open On-Chip Debugger 0.10.0+dev-00313-gbae7605 (2018-03-01-21:55) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html WARNING: interface/stlink-v2-1.cfg is deprecated, please switch to interface/stlink.cfg WARNING: target/stm32f4x_stlink.cfg is deprecated, please switch to target/stm32f4x.cfg Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD adapter speed: 2000 kHz adapter_nsrst_delay: 100 none separate Info : Unable to match requested speed 2000 kHz, using 1800 kHz Info : Unable to match requested speed 2000 kHz, using 1800 kHz Info : clock speed 1800 kHz Info : STLINK v2 JTAG v27 API v2 SWIM v15 VID 0x0483 PID 0x374B Info : using stlink api v2 Info : Target voltage: 0.000000 Error: target voltage may be too low for reliable debugging Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints Info : Listening on port 3333 for gdb connections Info : Unable to match requested speed 2000 kHz, using 1800 kHz Info : Unable to match requested speed 2000 kHz, using 1800 kHz adapter speed: 1800 kHz target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x08006290 msp: 0x20010000 Info : Unable to match requested speed 8000 kHz, using 4000 kHz Info : Unable to match requested speed 8000 kHz, using 4000 kHz adapter speed: 4000 kHz auto erase enabled Info : device id = 0x10006431 Info : flash size = 512kbytes wrote 196608 bytes from file bin/plumcore-plumpot-cellular-0.5.0-split-into-modules.6+2067d83.20180929.fw in 4.465176s (42.999 KiB/s) Info : Unable to match requested speed 2000 kHz, using 1800 kHz Info : Unable to match requested speed 2000 kHz, using 1800 kHz adapter speed: 1800 kHz shutdown command invoked scons: done building targets.
Output on the serial console looks like: (including the uBLoad bootloader)
### uBLoad (umeshFw bootloader), plumpot-cellular platform ### version develop, 2b73024, 2016-04-26 13:29:14 +0200, build date 2017-08-29 11:32:25 CEST INFO: clog initialized INFO: led1: LED module initialized INFO: spi_flash: flash id 00014014 INFO: spi_flash: flash detected Spansion S25FL208K, size 1048576 bytes INFO: spi_flash: flash id 00014014 INFO: sffs: filesystem mounted successfully INFO: sffs: sectors t=256 e=251 u=2 f=0 d=3 o=0, pages t=3840 e=3785 u=6 o=49 INFO: sffs: space total 983040 bytes, used 1536 bytes, free 981504 bytes INFO: config: loading saved running configuration Press [enter] to interrupt the boot process.................... INFO: fw_image: parsing firmware image... INFO: fw_image: firmware vector table found at 0x08010400 INFO: fw_image: firmware structure check & parsing OK INFO: ubload: jumping to user code [] INFO: plocator: service initialized [] INFO: rtc1: module RTC initialized [] INFO: rtc1: current date/time is 2018-09-29T12:09:22Z [2008-09-29T12:09:22Z] INFO: led_stat: LED module initialized [2008-09-29T12:09:22Z] INFO: prng: module PRNG-simple initialized [2008-09-29T12:09:22Z] INFO: profiler: FIFO time profiler initialized, queue length 100 [2008-09-29T12:09:22Z] INFO: spi2: module SPI bus initialized using default settings [2008-09-29T12:09:22Z] INFO: spi2_flash1: SPI device initialized on bus spi2 [2008-09-29T12:09:22Z] INFO: flash1: flash detected Spansion S25FL208K, size 1048576 bytes [2008-09-29T12:09:22Z] INFO: sffs: filesystem mounted successfully [2008-09-29T12:09:22Z] INFO: sffs: sectors t=256 e=251 u=2 f=0 d=3 o=0, pages t=3840 e=3785 u=6 o=49 [2008-09-29T12:09:22Z] INFO: sffs: space total 983040 bytes, used 1536 bytes, free 981504 bytes [2008-09-29T12:09:22Z] INFO: adc-stm32: ADC initialized [2008-09-29T12:09:22Z] INFO: gsm-quectel: initialized [2008-09-29T12:09:22Z] INFO: gsm1_usart: module USART initialized using default settings [2008-09-29T12:09:22Z] INFO: gsm-quectel: starting [2008-09-29T12:09:22Z] INFO: gsm-quectel: powering up [2008-09-29T12:09:22Z] INFO: i2c-sensors: initialized [2008-09-29T12:09:22Z] INFO: puxb: module initialized [2008-09-29T12:09:23Z] INFO: puxb-discovery: module initialized [2008-09-29T12:09:23Z] INFO: watchdog: started, period = 20000ms, prio = 0 [2008-09-29T12:09:23Z] DEBUG: stream-mqtt: initialized [2008-09-29T12:09:23Z] INFO: system-clock: system clock timer started [2008-09-29T12:09:23Z] INFO: stm32-rtc: RTC ready, skipping initialization [2008-09-29T12:09:23Z] INFO: system: initializing services... [2008-09-29T12:09:23Z] INFO: login1: module loginmgr initialized on interface 'console' [2008-09-29T12:09:23Z] ERROR: gsm-quectel: module startup timeout Press any key to activate this console. [2008-09-29T12:09:27Z] INFO: sensor-over-can: module initialized [2008-09-29T12:09:27Z] INFO: sensor-over-can: module initialized [2008-09-29T12:09:27Z] INFO: sensor-over-can: module initialized [2008-09-29T12:09:27Z] INFO: sensor-over-can: module initialized [2008-09-29T12:09:27Z] INFO: plog-router: plog message router started [2008-09-29T12:09:27Z] INFO: plog-sensor: plog sensor upload service started [2008-09-29T12:09:28Z] ERROR: gsm-quectel: no response from the modem [2008-09-29T12:09:28Z] INFO: gsm-quectel: requesting stop [2008-09-29T12:09:30Z] INFO: gsm-quectel: powering down [2008-09-29T12:09:30Z] WARNING: gsm-quectel: module is already powered down [2008-09-29T12:09:30Z] INFO: gsm-quectel: stopped