Giter Club home page Giter Club logo

uc-makefile's Introduction

uC-Makefile

A Makefile for popular Microcontrollers supporting Energia (msp430 and tivac boards) and Arduino-1.8.x (avr, attiny, esp8266 and esp32 boards).

If:

  • You'd prefer to be using vi or emacs to the Arduino IDE
  • Your preferred source tree layout differs from Arduino's
  • You want to program more than one type of board at the same time
  • You want more control over the build process than it gives you (e.g., compiler optimisation levels)
  • ... then this is for you!

Configuration

Install the makefile fragments in somedir.

Create a Makefile in your sketch directory, such as this, for a TI Launchpad:

BOARD := MSP-EXP430FR5739LP
include msp430.mk

For an Arduino Uno, the equivalent would be:

BOARD := uno
include avr.mk

A minimal Makefile must specify a BOARD and include only one core. See the documentation for core-specific options.

Invoke with:

make -I somedir

Note: installing the fragments in a directory on Gnu Make's include path means you can simply do:

make

See the documentation.

Supported Cores

Note: Energia is no longer developed. Its cores are now integrated with Arduino via this repository.

Credits

  • elpaso's Makefile for msp430 provided inspiration.
  • attiny support is largely due to SpenceKonde's ATTinyCore

uc-makefile's People

Contributors

jscrane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

uc-makefile's Issues

Permit libraries to be specified in Makefile

Currently, like Arduino, libraries are determined by grepping for includes in the sketch.

It would be good to be able to preset REQUIRED_LIBS in the Makefile, and add to this by grepping as now.

Also rename LIBRARIES to LIBRARY_PATH, and allow adding to it. Then rename REQUIRED_LIBS to LIBRARIES.

All-in-one

Have a single include for all architectures, with defines for each scoped by processor family.

Aim is to allow a single makefile to build a sketch for multiple architectures.

get esp8266 networking info from boards.txt

LWIP_OPTS ?= lm2f
LWIP_INC = $(shell sed -ne "s/$(BOARD).menu.ip.$(IP_OPTS).build.lwip_include=\(.*\)/\1/p" $(BOARDS))
LWIP_LIB = $(shell sed -ne "s/$(BOARD).menu.ip.$(IP_OPTS).build.lwip_lib=\(.*\)/\1/p" $(BOARDS))
LWIP_FLAGS = $(shell sed -ne "s/$(BOARD).menu.ip.$(IP_OPTS).build.lwip_flags=\(.*\)/\1/p" $(BOARDS))

Make terminal program configurable

Currently it's hardwired to minicom.

TERM ?= minicom
TERM_FLAGS ?= -D $(UPLOAD_PORT) -b $(TERM_SPEED)

term:
   $(TERM) $(TERM_FLAGS)
TERM := screen
TERM_FLAGS := $(UPLOAD_PORT) $(TERM_SPEED) -ixon -ixoff

spiffs

fs:
  mkspiffs -c $(SPIFFS_DIR) -b $(SPIFFS_BLOCKSIZE) -p $(SPIFFS_PAGESIZE) -s $(SPIFFS_SIZE) $(IMAGE)

Compiling libraries

Should follow the Arduino guidelines:

The source code found in src folder and all its subfolders is compiled and linked in the user’s sketch. Only the src folder is added to the include search path (both when compiling the sketch and the library). When the user imports a library into their sketch (from the "Tools > Import Library" menu), an #include statement will be added for all header (.h) files in the src/ directory (but not its subfolders).

Core Library Dependencies

Starting with version 3.0.0, the esp32 core has refactored its libraries in a way which requires including a library's dependencies as well, e.g., to use WiFi need to include its dependency Network as well:

#include <Network.h>
#include <WiFi.h>

Otherwise the compilation will fail:

In file included from /home/steve/.arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/WiFi/src/WiFiSTA.h:29,
                 from /home/steve/.arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/WiFi/src/WiFi.h:33,
                 from Radar.ino:4:
/home/steve/.arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/WiFi/src/WiFiGeneric.h:39:10: fatal error: Network.h: No such file or directory
   39 | #include "Network.h"
      |          ^~~~~~~~~~~
compilation terminated.
make: *** [build-targets.mk:68: Radar.ino.cpp.o] Error 1

More information here.

update-core target

.arduino15/preferences.txt

boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json,https://dl.espressif.com/dl/package_esp32_index.json,http://drazzy.com/package_drazzy.com_index.json

bring stm32 up-to-date

should be possible to use in stm32 Makefiles

BOARD := GenF1
PNUM := HY-TINY...

however there are issues with variable substitution around this.

Fix ESP8266 build failure with latest version 2.5.0-dev

/home/steve/sketchbook/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/CertStoreSDBearSSL.cpp:20:16: fatal error: SD.h: No such file or directory
#include <SD.h>
^
compilation terminated.
ucmk.mk:78: recipe for target '.lib//home/steve/sketchbook/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/CertStoreSDBearSSL.cpp.o' failed

use $(.VARIABLES) to automate boiler-plating variable definitions

It ought to be possible to automate away this sort of thing (esp32.mk):

build.flash_mode := $($(build.board).build.flash_mode)
build.flash_size := $($(build.board).build.flash_size)
build.flash_freq := $($(build.board).menu.FlashFreq.$(FLASH_FREQ).build.flash_freq)
build.boot := $($(build.board).build.boot)
build.partitions := $($(build.board).menu.PartitionScheme.$(PARTITION_SCHEME).build.partitions)

See this discussion (SO).

platform.txt handling

This would be a good solution to the problem of tracking changes in each release.

Simple preprocessing with sed allows it to be read into gnu make:

$  sed -e "s/{/\${/g" -e "/^\#/d" -e "/^$/d" < ~/.arduino15/packages/esp8266/hardware/esp8266/2.5.1/platform.txt

Problems:

  • generating targets from recipes
  • "implicit" platform variables, exact semantics is unclear, will have to supply them for now.

Support pre- and post-build hooks correctly

See the specification.

This is required for arduino-esp32 2.0.10.

`# Set -DARDUINO_CORE_BUILD only on core file compilation
file_opts.path={build.path}/file_opts
recipe.hooks.prebuild.set_core_build_flag.pattern=bash -c ": > {file_opts.path}"
recipe.hooks.core.prebuild.set_core_build_flag.pattern=bash -c "echo '-DARDUINO_CORE_BUILD' > {file_opts.path}"
recipe.hooks.core.postbuild.set_core_build_flag.pattern=bash -c ": > {file_opts.path}"

recipe.hooks.prebuild.set_core_build_flag.pattern.windows=cmd /c type nul > {file_opts.path}
recipe.hooks.core.prebuild.set_core_build_flag.pattern.windows=cmd /c echo "-DARDUINO_CORE_BUILD" > {file_opts.path}
recipe.hooks.core.postbuild.set_core_build_flag.pattern.windows=cmd /c type nul > {file_opts.path}
`

esp8266 size target

clean up the output of "size" command: look at recipe.size.regex and friends in platform.txt

Recipes to run the preprocessor

See here.

For detecting which libraries to include in the build, and for generating function prototypes, (just) the preprocessor is run. For this, the recipe.preproc.macros recipe exists. This recipe must run the preprocessor on a given source file, writing the preprocessed output to a given output file, and generate (only) preprocessor errors on standard output. This preprocessor run should happen with the same defines and other preprocessor-influencing-options as for normally compiling the source files.

This came to light trying to compile src/TommyPROM/HardwareVerify: it fails due to a missing function prototype.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.