Skip to content

Commit

Permalink
all: Update Makefiles and others to build with new ports/ dir layout.
Browse files Browse the repository at this point in the history
Also renames "stmhal" to "stm32" in documentation and everywhere else.
  • Loading branch information
dpgeorge committed Sep 6, 2017
1 parent 01dd780 commit 4a93801
Show file tree
Hide file tree
Showing 51 changed files with 150 additions and 161 deletions.
11 changes: 0 additions & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@
# These should also not be modified by git.
tests/basics/string_cr_conversion.py -text
tests/basics/string_crlf_conversion.py -text
stmhal/pybcdc.inf_template -text
stmhal/usbd_* -text
stmhal/boards/*/stm32f4xx_hal_conf.h -text
stmhal/usbdev/** -text
stmhal/usbhost/** -text
cc3200/hal/aes.c -text
cc3200/hal/aes.h -text
cc3200/hal/des.c -text
cc3200/hal/i2s.c -text
cc3200/hal/i2s.h -text
cc3200/version.h -text
ports/stm32/pybcdc.inf_template -text
ports/stm32/usbd_* -text
ports/stm32/boards/*/stm32f4xx_hal_conf.h -text
Expand Down
46 changes: 23 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,40 @@ before_script:

script:
- make -C mpy-cross
- make -C minimal CROSS=1 build/firmware.bin
- ls -l minimal/build/firmware.bin
- make -C ports/minimal CROSS=1 build/firmware.bin
- ls -l ports/minimal/build/firmware.bin
- tools/check_code_size.sh
- mkdir -p ${HOME}/persist
# Save new firmware for reference, but only if building a main branch, not a pull request
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cp minimal/build/firmware.bin ${HOME}/persist/; fi'
- make -C unix deplibs
- make -C unix
- make -C unix nanbox
- make -C bare-arm
- make -C qemu-arm test
- make -C stmhal
- make -C stmhal BOARD=PYBV11 MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1
- make -C stmhal BOARD=STM32F769DISC
- make -C stmhal BOARD=STM32L476DISC
- make -C teensy
- make -C cc3200 BTARGET=application BTYPE=release
- make -C cc3200 BTARGET=bootloader BTYPE=release
- make -C windows CROSS_COMPILE=i686-w64-mingw32-
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cp ports/minimal/build/firmware.bin ${HOME}/persist/; fi'
- make -C ports/unix deplibs
- make -C ports/unix
- make -C ports/unix nanbox
- make -C ports/bare-arm
- make -C ports/qemu-arm test
- make -C ports/stm32
- make -C ports/stm32 BOARD=PYBV11 MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1
- make -C ports/stm32 BOARD=STM32F769DISC
- make -C ports/stm32 BOARD=STM32L476DISC
- make -C ports/teensy
- make -C ports/cc3200 BTARGET=application BTYPE=release
- make -C ports/cc3200 BTARGET=bootloader BTYPE=release
- make -C ports/windows CROSS_COMPILE=i686-w64-mingw32-

# run tests without coverage info
#- (cd tests && MICROPY_CPYTHON3=python3.4 ./run-tests)
#- (cd tests && MICROPY_CPYTHON3=python3.4 ./run-tests --emit native)

# run tests with coverage info
- make -C unix coverage
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests)
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests -d thread)
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --emit native)
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --via-mpy -d basics float)
- make -C ports/unix coverage
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests)
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -d thread)
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests --emit native)
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests --via-mpy -d basics float)

# run coveralls coverage analysis (try to, even if some builds/tests failed)
- (cd unix && coveralls --root .. --build-root . --gcov $(which gcov) --gcov-options '\-o build-coverage/' --include py --include extmod)
- (cd ports/unix && coveralls --root ../.. --build-root . --gcov $(which gcov) --gcov-options '\-o build-coverage/' --include py --include extmod)

after_failure:
- (cd tests && for exp in *.exp; do testbase=$(basename $exp .exp); echo -e "\nFAILURE $testbase"; diff -u $testbase.exp $testbase.out; done)
- (grep "FAIL" qemu-arm/build/console.out)
- (grep "FAIL" ports/qemu-arm/build/console.out)
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ Major components in this repository:
core library.
- mpy-cross/ -- the MicroPython cross-compiler which is used to turn scripts
into precompiled bytecode.
- unix/ -- a version of MicroPython that runs on Unix.
- stmhal/ -- a version of MicroPython that runs on the PyBoard and similar
- ports/unix/ -- a version of MicroPython that runs on Unix.
- ports/stm32/ -- a version of MicroPython that runs on the PyBoard and similar
STM32 boards (using ST's Cube HAL drivers).
- minimal/ -- a minimal MicroPython port. Start with this if you want
- ports/minimal/ -- a minimal MicroPython port. Start with this if you want
to port MicroPython to another microcontroller.
- tests/ -- test framework and test scripts.
- docs/ -- user documentation in Sphinx reStructuredText format. Rendered
HTML documentation is available at http://docs.micropython.org (be sure
to select needed board/port at the bottom left corner).

Additional components:
- bare-arm/ -- a bare minimum version of MicroPython for ARM MCUs. Used
- ports/bare-arm/ -- a bare minimum version of MicroPython for ARM MCUs. Used
mostly to control code size.
- teensy/ -- a version of MicroPython that runs on the Teensy 3.1
- ports/teensy/ -- a version of MicroPython that runs on the Teensy 3.1
(preliminary but functional).
- pic16bit/ -- a version of MicroPython for 16-bit PIC microcontrollers.
- cc3200/ -- a version of MicroPython that runs on the CC3200 from TI.
- esp8266/ -- an experimental port for ESP8266 WiFi modules.
- ports/pic16bit/ -- a version of MicroPython for 16-bit PIC microcontrollers.
- ports/cc3200/ -- a version of MicroPython that runs on the CC3200 from TI.
- ports/esp8266/ -- an experimental port for ESP8266 WiFi modules.
- extmod/ -- additional (non-core) modules implemented in C.
- tools/ -- various tools, including the pyboard.py module.
- examples/ -- a few example Python scripts.
Expand All @@ -72,7 +72,7 @@ Alternatively, fallback implementation based on setjmp/longjmp can be used.

To build (see section below for required dependencies):

$ cd unix
$ cd ports/unix
$ make axtls
$ make

Expand Down Expand Up @@ -115,33 +115,33 @@ these additional dependencies, first fetch git submodules for them:
$ git submodule update --init

Use this same command to get the latest versions of dependencies, as
they are updated from time to time. After that, in `unix/` dir, execute:
they are updated from time to time. After that, in `ports/unix/` dir, execute:

$ make deplibs

This will build all available dependencies (regardless whether they
are used or not). If you intend to build MicroPython with additional
options (like cross-compiling), the same set of options should be passed
to `make deplibs`. To actually enabled use of dependencies, edit
`unix/mpconfigport.mk` file, which has inline descriptions of the options.
`ports/unix/mpconfigport.mk` file, which has inline descriptions of the options.
For example, to build SSL module (required for `upip` tool described above),
set `MICROPY_PY_USSL` to 1.

In `unix/mpconfigport.mk`, you can also disable some dependencies enabled
In `ports/unix/mpconfigport.mk`, you can also disable some dependencies enabled
by default, like FFI support, which requires libffi development files to
be installed.

The STM version
---------------
The STM32 version
-----------------

The "stmhal" port requires an ARM compiler, arm-none-eabi-gcc, and associated
The "stm32" port requires an ARM compiler, arm-none-eabi-gcc, and associated
bin-utils. For those using Arch Linux, you need arm-none-eabi-binutils and
arm-none-eabi-gcc packages. Otherwise, try here:
https://launchpad.net/gcc-arm-embedded

To build:

$ cd stmhal
$ cd ports/stm32
$ make

You then need to get your board into DFU mode. On the pyboard, connect the
Expand All @@ -155,4 +155,4 @@ Then to flash the code via USB DFU to your device:
This will use the included `tools/pydfu.py` script. If flashing the firmware
does not work it may be because you don't have the correct permissions, and
need to use `sudo make deploy`.
See the README.md file in the stmhal/ directory for further details.
See the README.md file in the ports/stm32/ directory for further details.
2 changes: 1 addition & 1 deletion docs/reference/constrained.rst
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ After importing the modules, execute:
Then copy and paste all the Q(xxx) lines into a text editor. Check for and
remove lines which are obviously invalid. Open the file qstrdefsport.h which
will be found in stmhal (or the equivalent directory for the architecture in
will be found in ports/stm32 (or the equivalent directory for the architecture in
use). Copy and paste the corrected lines at the end of the file. Save the file,
rebuild and flash the firmware. The outcome can be checked by importing the
modules and again issuing:
Expand Down
2 changes: 1 addition & 1 deletion examples/pins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Print a nice list of pins, their current settings, and available afs.
# Requires pins_af.py from stmhal/build-PYBV10/ directory.
# Requires pins_af.py from ports/stm32/build-PYBV10/ directory.

import pyb
import pins_af
Expand Down
2 changes: 1 addition & 1 deletion extmod/modframebuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#if MICROPY_PY_FRAMEBUF

#include "stmhal/font_petme128_8x8.h"
#include "ports/stm32/font_petme128_8x8.h"

typedef struct _mp_obj_framebuf_t {
mp_obj_base_t base;
Expand Down
2 changes: 1 addition & 1 deletion mpy-cross/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ SRC_C = \
# Add fmode when compiling with mingw gcc
COMPILER_TARGET := $(shell $(CC) -dumpmachine)
ifneq (,$(findstring mingw,$(COMPILER_TARGET)))
SRC_C += windows/fmode.c
SRC_C += ports/windows/fmode.c
endif

OBJ = $(PY_O)
Expand Down
2 changes: 1 addition & 1 deletion mpy-cross/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "py/gc.h"
#include "py/stackctrl.h"
#ifdef _WIN32
#include "windows/fmode.h"
#include "ports/windows/fmode.h"
#endif

// Command line options, with their defaults
Expand Down
2 changes: 1 addition & 1 deletion ports/bare-arm/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../py/mkenv.mk
include ../../py/mkenv.mk

# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h
Expand Down
2 changes: 1 addition & 1 deletion ports/cc3200/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PORT ?= /dev/ttyUSB1
# If the build directory is not given, make it reflect the board name.
BUILD ?= build/$(BOARD)/$(BTYPE)

include ../py/mkenv.mk
include ../../py/mkenv.mk
-include ../../localconfig.mk

CROSS_COMPILE ?= arm-none-eabi-
Expand Down
4 changes: 2 additions & 2 deletions ports/cc3200/application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ APP_INC += -Iutil
APP_INC += -Ibootmgr
APP_INC += -I$(BUILD)
APP_INC += -I$(BUILD)/genhdr
APP_INC += -I$(TOP)/stmhal
APP_INC += -I$(TOP)/ports/stm32

APP_CPPDEFINES = -Dgcc -DTARGET_IS_CC3200 -DSL_FULL -DUSE_FREERTOS

Expand Down Expand Up @@ -151,7 +151,7 @@ APP_LIB_SRC_C = $(addprefix lib/,\
utils/sys_stdio_mphal.c \
)

APP_STM_SRC_C = $(addprefix stmhal/,\
APP_STM_SRC_C = $(addprefix ports/stm32/,\
bufhelper.c \
irq.c \
)
Expand Down
2 changes: 1 addition & 1 deletion ports/cc3200/bootmgr/bootloader.mk
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ $(BUILD)/misc/%.o: CFLAGS += -Os
$(BUILD)/simplelink/%.o: CFLAGS += -Os
$(BUILD)/drivers/cc3100/%.o: CFLAGS += -Os
$(BUILD)/py/%.o: CFLAGS += -Os
$(BUILD)/stmhal/%.o: CFLAGS += -Os
$(BUILD)/ports/stm32/%.o: CFLAGS += -Os
else
$(error Invalid BTYPE specified)
endif
Expand Down
2 changes: 1 addition & 1 deletion ports/esp8266/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../py/mkenv.mk
include ../../py/mkenv.mk

# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h
Expand Down
2 changes: 1 addition & 1 deletion ports/esp8266/esp_mphal.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void ets_event_poll(void);
// C-level pin HAL
#include "etshal.h"
#include "gpio.h"
#include "esp8266/modmachine.h"
#include "modmachine.h"
#define MP_HAL_PIN_FMT "%u"
#define mp_hal_pin_obj_t uint32_t
#define mp_hal_get_pin_obj(o) mp_obj_get_pin(o)
Expand Down
2 changes: 1 addition & 1 deletion ports/esp8266/modules/ds18x20.py
2 changes: 1 addition & 1 deletion ports/esp8266/modules/onewire.py
2 changes: 1 addition & 1 deletion ports/esp8266/modules/upip.py
2 changes: 1 addition & 1 deletion ports/esp8266/modules/upip_utarfile.py
2 changes: 1 addition & 1 deletion ports/minimal/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../py/mkenv.mk
include ../../py/mkenv.mk

CROSS = 0

Expand Down
2 changes: 1 addition & 1 deletion ports/pic16bit/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../py/mkenv.mk
include ../../py/mkenv.mk

# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h
Expand Down
2 changes: 1 addition & 1 deletion ports/qemu-arm/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ../py/mkenv.mk
include ../../py/mkenv.mk
-include mpconfigport.mk

# qstr definitions (must come before including py.mk)
Expand Down
4 changes: 2 additions & 2 deletions ports/stm32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif
# If the build directory is not given, make it reflect the board name.
BUILD ?= build-$(BOARD)

include ../py/mkenv.mk
include ../../py/mkenv.mk
-include mpconfigport.mk
include boards/$(BOARD)/mpconfigboard.mk

Expand Down Expand Up @@ -206,7 +206,7 @@ SRC_C = \
timer.c \
led.c \
pin.c \
pin_defs_stmhal.c \
pin_defs_stm32.c \
pin_named_pins.c \
bufhelper.c \
dma.c \
Expand Down
6 changes: 3 additions & 3 deletions ports/stm32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bytecode. The cross-compiler is built and run on the host machine, using:
$ make -C mpy-cross
```
This command should be executed from the root directory of this repository.
All other commands below should be executed from the stmhal/ directory.
All other commands below should be executed from the ports/stm32/ directory.

An ARM compiler is required for the build, along with the associated binary
utilities. The default compiler is `arm-none-eabi-gcc`, which is available for
Expand Down Expand Up @@ -71,7 +71,7 @@ Or using `dfu-util` directly:

ST Discovery or Nucleo boards have a builtin programmer called ST-LINK. With
these boards and using Linux or OS X, you have the option to upload the
`stmhal` firmware using the `st-flash` utility from the
`stm32` firmware using the `st-flash` utility from the
[stlink](https://github.com/texane/stlink) project. To do so, connect the board
with a mini USB cable to its ST-LINK USB port and then use the make target
`deploy-stlink`. For example, if you have the STM32F4DISCOVERY board, you can
Expand Down Expand Up @@ -101,7 +101,7 @@ a mini USB cable to its ST-LINK USB port and then use the make target
$ make BOARD=STM32F4DISC deploy-openocd

The `openocd` program, which writes the firmware to the target board's flash,
is configured via the file `stmhal/boards/openocd_stm32f4.cfg`. This
is configured via the file `ports/stm32/boards/openocd_stm32f4.cfg`. This
configuration should work for all boards based on a STM32F4xx MCU with a
ST-LINKv2 interface. You can override the path to this configuration by setting
`OPENOCD_CONFIG` in your Makefile or on the command line.
Expand Down
2 changes: 1 addition & 1 deletion ports/stm32/boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/

// This board doesn't really have USB, but the stmhal codebase doesn't build
// This board doesn't really have USB, but the stm32 codebase doesn't build
// without some USB defined, so we leave this on for now.
#define USE_USB_FS

Expand Down
2 changes: 1 addition & 1 deletion ports/stm32/boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/

// This board doesn't really have USB, but the stmhal codebase doesn't build
// This board doesn't really have USB, but the stm32 codebase doesn't build
// without some USB defined, so we leave this on for now.
#define USE_USB_FS

Expand Down
2 changes: 1 addition & 1 deletion ports/stm32/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/

// This board doesn't really have USB, but the stmhal codebase doesn't build
// This board doesn't really have USB, but the stm32 codebase doesn't build
// without some USB defined, so we leave this on for now.
#define USE_USB_FS

Expand Down
2 changes: 1 addition & 1 deletion ports/stm32/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "py/builtin.h"

const char *stmhal_help_text =
const char *stm32_help_text =
"Welcome to MicroPython!\n"
"\n"
"For online help please visit http://micropython.org/help/.\n"
Expand Down
2 changes: 1 addition & 1 deletion ports/stm32/modules/lcd160cr.py
2 changes: 1 addition & 1 deletion ports/stm32/modules/lcd160cr_test.py
Loading

0 comments on commit 4a93801

Please sign in to comment.