Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better build system #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ platformio.sublime*
platformio.pro*
tests
research
.pio
.vscode
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The ```git clone --recursive``` above not only cloned the MavESP8266 repository

### Wiring it up

User level (as well as wiring) instructions can be found here: https://pixhawk.org/peripherals/8266
User level (as well as wiring) instructions can be found [here for px4](https://docs.px4.io/en/telemetry/esp8266_wifi_module.html) and [here for ArduPilot](http://ardupilot.org/copter/docs/common-esp8266-telemetry.html)

* Resetting to Defaults: In case you change the parameters and get locked out of the module, all the parameters can be reset by bringing the GPIO02 pin low (Connect GPIO02 pin to GND pin).

Expand Down
47 changes: 25 additions & 22 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,41 @@
# http://docs.platformio.org/en/latest/projectconf.html
#

# A sign `#` at the beginning of the line indicates a comment
# Comment lines are ignored.

# Simple and base environment
# [env:mybaseenv]
# platform = %INSTALLED_PLATFORM_NAME_HERE%
# framework =
# board =
#
# Automatic targets - enable auto-uploading
# targets = upload

# The upload speed below (921600) has worked fine for all modules I tested. If you have upload issues,
# try reducing to 115200.

# Set mavesp version

[version]
build_flags = !echo "-DPIO_SRC_REV="$(git rev-parse HEAD) "-DPIO_BUILD_DATE="$(date +%%Y-%%m-%%d) "-DPIO_BUILD_TIME="$(date +%%H:%%M:%%S)
major = 1
minor = 2
build = 2

[env:esp12e]
platform = espressif8266
# Generate version string (e.g "1.2.2") and flags

[version_env]
version_string = ${version.major}.${version.minor}.${version.build}
version_flags = "-DMAVESP8266_VERSION_MINOR="${version.minor} "-DMAVESP8266_VERSION_MAJOR="${version.major} "-DMAVESP8266_VERSION_BUILD="${version.build} "-DVERSION_STRING="${version_env.version_string}

# General settings
# - Set platform and framework
# - Generate revision, date and time flags
# - Run prebuild script to set firmware name

[env]
platform = [email protected]
framework = arduino
build_flags = !echo "-DPIO_SRC_REV="$(git rev-parse HEAD) "-DPIO_BUILD_DATE="$(date +%%Y-%%m-%%d) "-DPIO_BUILD_TIME="$(date +%%H:%%M:%%S) ${version_env.version_flags}
extra_scripts = pre:platformio_prebuild.py

# Platform specific settings

[env:esp12e]
board = esp12e
build_flags = ${version.build_flags} -Wl,-Tesp8266.flash.4m.ld
build_flags = ${env.build_flags} -Wl,-Tesp8266.flash.4m.ld

[env:esp01_1m]
platform = espressif8266
framework = arduino
board = esp01_1m
build_flags = ${version.build_flags}

[env:esp01]
platform = espressif8266
framework = arduino
board = esp01
build_flags = ${version.build_flags}
14 changes: 14 additions & 0 deletions platformio_prebuild.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Import("env")

# retrieve build flags
my_flags = env.ParseFlags(env['BUILD_FLAGS'])
defines = {k: v for (k, v) in my_flags.get("CPPDEFINES")}

version_string = defines.get("VERSION_STRING") # e.g. "1.2.2"
board_name = env["BOARD"] # e.g. "esp01m"

# replace dots in version if linker can't find the path
#version_string = version_string.replace(".","_")

# set board and version in firmware name
env.Replace(PROGNAME="mavesp-{}-{}".format(board_name, version_string))
5 changes: 1 addition & 4 deletions src/mavesp8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ class MavESP8266GCS;

#define HEARTBEAT_TIMEOUT 10 * 1000

//-- TODO: This needs to come from the build system
#define MAVESP8266_VERSION_MAJOR 1
#define MAVESP8266_VERSION_MINOR 2
#define MAVESP8266_VERSION_BUILD 2
//-- The version is set from the build system (major, minor and build)
#define MAVESP8266_VERSION ((MAVESP8266_VERSION_MAJOR << 24) & 0xFF00000) | ((MAVESP8266_VERSION_MINOR << 16) & 0x00FF0000) | (MAVESP8266_VERSION_BUILD & 0xFFFF)

//-- Debug sent out to Serial1 (GPIO02), which is TX only (no RX).
Expand Down
4 changes: 2 additions & 2 deletions src/mavesp8266_httpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
* @author Gus Grubba <[email protected]>
*/

#include <ESP8266WebServer.h>

#include "mavesp8266.h"
#include "mavesp8266_httpd.h"
#include "mavesp8266_parameters.h"
#include "mavesp8266_gcs.h"
#include "mavesp8266_vehicle.h"

#include <ESP8266WebServer.h>

const char PROGMEM kTEXTPLAIN[] = "text/plain";
const char PROGMEM kTEXTHTML[] = "text/html";
const char PROGMEM kACCESSCTL[] = "Access-Control-Allow-Origin";
Expand Down