From 4a93801c12898898744131f57d79cf216d0861b3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 6 Sep 2017 14:09:13 +1000 Subject: [PATCH] all: Update Makefiles and others to build with new ports/ dir layout. Also renames "stmhal" to "stm32" in documentation and everywhere else. --- .gitattributes | 11 ----- .travis.yml | 46 +++++++++---------- README.md | 34 +++++++------- docs/reference/constrained.rst | 2 +- examples/pins.py | 2 +- extmod/modframebuf.c | 2 +- mpy-cross/Makefile | 2 +- mpy-cross/main.c | 2 +- ports/bare-arm/Makefile | 2 +- ports/cc3200/Makefile | 2 +- ports/cc3200/application.mk | 4 +- ports/cc3200/bootmgr/bootloader.mk | 2 +- ports/esp8266/Makefile | 2 +- ports/esp8266/esp_mphal.h | 2 +- ports/esp8266/modules/ds18x20.py | 2 +- ports/esp8266/modules/onewire.py | 2 +- ports/esp8266/modules/upip.py | 2 +- ports/esp8266/modules/upip_utarfile.py | 2 +- ports/minimal/Makefile | 2 +- ports/pic16bit/Makefile | 2 +- ports/qemu-arm/Makefile | 2 +- ports/stm32/Makefile | 4 +- ports/stm32/README.md | 6 +-- .../boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h | 2 +- .../boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h | 2 +- .../boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h | 2 +- ports/stm32/help.c | 2 +- ports/stm32/modules/lcd160cr.py | 2 +- ports/stm32/modules/lcd160cr_test.py | 2 +- ports/stm32/modules/onewire.py | 2 +- ports/stm32/mpconfigport.h | 4 +- ports/stm32/mphalport.h | 4 +- .../{pin_defs_stmhal.c => pin_defs_stm32.c} | 0 .../{pin_defs_stmhal.h => pin_defs_stm32.h} | 2 +- ports/teensy/Makefile | 8 ++-- ports/teensy/lcd.c | 2 +- ports/unix/Makefile | 6 +-- ports/unix/modules/upip.py | 2 +- ports/unix/modules/upip_utarfile.py | 2 +- ports/windows/.appveyor.yml | 2 +- ports/windows/Makefile | 16 +++---- ports/windows/README.md | 4 +- ports/windows/msvc/genhdr.targets | 2 +- ports/windows/msvc/paths.props | 26 +++++------ ports/windows/msvc/sources.props | 22 ++++----- ports/windows/windows_mphal.h | 2 +- ports/zephyr/Makefile | 2 +- py/mkrules.mk | 2 +- tests/run-tests | 4 +- tools/check_code_size.sh | 2 +- tools/codestats.sh | 44 +++++++++--------- 51 files changed, 150 insertions(+), 161 deletions(-) rename ports/stm32/{pin_defs_stmhal.c => pin_defs_stm32.c} (100%) rename ports/stm32/{pin_defs_stmhal.h => pin_defs_stm32.h} (99%) diff --git a/.gitattributes b/.gitattributes index 6822bd21c2..1ac507944c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/.travis.yml b/.travis.yml index 14d5df0a45..db51567f19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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) diff --git a/README.md b/README.md index 481cac4e42..ff609dba32 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ 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 @@ -45,13 +45,13 @@ Major components in this repository: 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. @@ -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 @@ -115,7 +115,7 @@ 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 @@ -123,25 +123,25 @@ 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 @@ -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. diff --git a/docs/reference/constrained.rst b/docs/reference/constrained.rst index 14286aa262..e7de459bc9 100644 --- a/docs/reference/constrained.rst +++ b/docs/reference/constrained.rst @@ -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: diff --git a/examples/pins.py b/examples/pins.py index ab359f6921..aafdb48133 100644 --- a/examples/pins.py +++ b/examples/pins.py @@ -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 diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index f4e8571297..239302295b 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -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; diff --git a/mpy-cross/Makefile b/mpy-cross/Makefile index 5399b5ae77..53ce50c7ff 100644 --- a/mpy-cross/Makefile +++ b/mpy-cross/Makefile @@ -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) diff --git a/mpy-cross/main.c b/mpy-cross/main.c index ca8d9633fa..225bc4309a 100644 --- a/mpy-cross/main.c +++ b/mpy-cross/main.c @@ -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 diff --git a/ports/bare-arm/Makefile b/ports/bare-arm/Makefile index 90c13de11f..0fcd5d0272 100644 --- a/ports/bare-arm/Makefile +++ b/ports/bare-arm/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk # qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h diff --git a/ports/cc3200/Makefile b/ports/cc3200/Makefile index 4c8b0b8325..81531b1084 100644 --- a/ports/cc3200/Makefile +++ b/ports/cc3200/Makefile @@ -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- diff --git a/ports/cc3200/application.mk b/ports/cc3200/application.mk index 64891a2e7d..19abe66163 100644 --- a/ports/cc3200/application.mk +++ b/ports/cc3200/application.mk @@ -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 @@ -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 \ ) diff --git a/ports/cc3200/bootmgr/bootloader.mk b/ports/cc3200/bootmgr/bootloader.mk index b8aa9082c9..44f1b7f42d 100644 --- a/ports/cc3200/bootmgr/bootloader.mk +++ b/ports/cc3200/bootmgr/bootloader.mk @@ -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 diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index fce11a7d41..70b4ce35c3 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -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 diff --git a/ports/esp8266/esp_mphal.h b/ports/esp8266/esp_mphal.h index 913bd70dc9..194e56f649 100644 --- a/ports/esp8266/esp_mphal.h +++ b/ports/esp8266/esp_mphal.h @@ -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) diff --git a/ports/esp8266/modules/ds18x20.py b/ports/esp8266/modules/ds18x20.py index faae59d909..1ec92d1c99 120000 --- a/ports/esp8266/modules/ds18x20.py +++ b/ports/esp8266/modules/ds18x20.py @@ -1 +1 @@ -../../drivers/onewire/ds18x20.py \ No newline at end of file +../../../drivers/onewire/ds18x20.py \ No newline at end of file diff --git a/ports/esp8266/modules/onewire.py b/ports/esp8266/modules/onewire.py index f6ec745e85..33f30e84f1 120000 --- a/ports/esp8266/modules/onewire.py +++ b/ports/esp8266/modules/onewire.py @@ -1 +1 @@ -../../drivers/onewire/onewire.py \ No newline at end of file +../../../drivers/onewire/onewire.py \ No newline at end of file diff --git a/ports/esp8266/modules/upip.py b/ports/esp8266/modules/upip.py index 20d52a4ab7..130eb69016 120000 --- a/ports/esp8266/modules/upip.py +++ b/ports/esp8266/modules/upip.py @@ -1 +1 @@ -../../tools/upip.py \ No newline at end of file +../../../tools/upip.py \ No newline at end of file diff --git a/ports/esp8266/modules/upip_utarfile.py b/ports/esp8266/modules/upip_utarfile.py index 1498862916..d9653d6a60 120000 --- a/ports/esp8266/modules/upip_utarfile.py +++ b/ports/esp8266/modules/upip_utarfile.py @@ -1 +1 @@ -../../tools/upip_utarfile.py \ No newline at end of file +../../../tools/upip_utarfile.py \ No newline at end of file diff --git a/ports/minimal/Makefile b/ports/minimal/Makefile index c95d639aff..ae295d655e 100644 --- a/ports/minimal/Makefile +++ b/ports/minimal/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk CROSS = 0 diff --git a/ports/pic16bit/Makefile b/ports/pic16bit/Makefile index ebf4fc2e80..970e75d1fb 100644 --- a/ports/pic16bit/Makefile +++ b/ports/pic16bit/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk # qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h diff --git a/ports/qemu-arm/Makefile b/ports/qemu-arm/Makefile index 71403cb5e7..39e13853f4 100644 --- a/ports/qemu-arm/Makefile +++ b/ports/qemu-arm/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk -include mpconfigport.mk # qstr definitions (must come before including py.mk) diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index 58a0a7c7aa..913f0913ec 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -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 @@ -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 \ diff --git a/ports/stm32/README.md b/ports/stm32/README.md index 32b6d41766..bb184e8db6 100644 --- a/ports/stm32/README.md +++ b/ports/stm32/README.md @@ -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 @@ -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 @@ -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. diff --git a/ports/stm32/boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h b/ports/stm32/boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h index c20421f0ff..a1fd2e083f 100644 --- a/ports/stm32/boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h +++ b/ports/stm32/boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h @@ -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 diff --git a/ports/stm32/boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h b/ports/stm32/boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h index e16fba155c..0c424888f8 100644 --- a/ports/stm32/boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h +++ b/ports/stm32/boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h @@ -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 diff --git a/ports/stm32/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h b/ports/stm32/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h index 3d0ce926b5..487ca009f2 100644 --- a/ports/stm32/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h +++ b/ports/stm32/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h @@ -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 diff --git a/ports/stm32/help.c b/ports/stm32/help.c index 87b2af526e..ea0b6921b0 100644 --- a/ports/stm32/help.c +++ b/ports/stm32/help.c @@ -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" diff --git a/ports/stm32/modules/lcd160cr.py b/ports/stm32/modules/lcd160cr.py index c0e180714d..9e63f1d23f 120000 --- a/ports/stm32/modules/lcd160cr.py +++ b/ports/stm32/modules/lcd160cr.py @@ -1 +1 @@ -../../drivers/display/lcd160cr.py \ No newline at end of file +../../../drivers/display/lcd160cr.py \ No newline at end of file diff --git a/ports/stm32/modules/lcd160cr_test.py b/ports/stm32/modules/lcd160cr_test.py index 56f091351b..5f5bcc1281 120000 --- a/ports/stm32/modules/lcd160cr_test.py +++ b/ports/stm32/modules/lcd160cr_test.py @@ -1 +1 @@ -../../drivers/display/lcd160cr_test.py \ No newline at end of file +../../../drivers/display/lcd160cr_test.py \ No newline at end of file diff --git a/ports/stm32/modules/onewire.py b/ports/stm32/modules/onewire.py index f6ec745e85..33f30e84f1 120000 --- a/ports/stm32/modules/onewire.py +++ b/ports/stm32/modules/onewire.py @@ -1 +1 @@ -../../drivers/onewire/onewire.py \ No newline at end of file +../../../drivers/onewire/onewire.py \ No newline at end of file diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h index 326aa2c20a..21142c17b3 100644 --- a/ports/stm32/mpconfigport.h +++ b/ports/stm32/mpconfigport.h @@ -92,7 +92,7 @@ #define MICROPY_PY_BUILTINS_INPUT (1) #define MICROPY_PY_BUILTINS_POW3 (1) #define MICROPY_PY_BUILTINS_HELP (1) -#define MICROPY_PY_BUILTINS_HELP_TEXT stmhal_help_text +#define MICROPY_PY_BUILTINS_HELP_TEXT stm32_help_text #define MICROPY_PY_BUILTINS_HELP_MODULES (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) @@ -345,4 +345,4 @@ static inline mp_uint_t disable_irq(void) { // We need to provide a declaration/definition of alloca() #include -#define MICROPY_PIN_DEFS_PORT_H "pin_defs_stmhal.h" +#define MICROPY_PIN_DEFS_PORT_H "pin_defs_stm32.h" diff --git a/ports/stm32/mphalport.h b/ports/stm32/mphalport.h index 8dd95c470c..939df0b3d2 100644 --- a/ports/stm32/mphalport.h +++ b/ports/stm32/mphalport.h @@ -27,7 +27,7 @@ void mp_hal_set_interrupt_char(int c); // -1 to disable // timing functions -#include "stmhal/irq.h" +#include "irq.h" #define mp_hal_quiet_timing_enter() raise_irq_pri(1) #define mp_hal_quiet_timing_exit(irq_state) restore_irq_pri(irq_state) @@ -44,7 +44,7 @@ static inline mp_uint_t mp_hal_ticks_cpu(void) { // C-level pin HAL -#include "stmhal/pin.h" +#include "pin.h" #define MP_HAL_PIN_FMT "%q" #define MP_HAL_PIN_MODE_INPUT (0) diff --git a/ports/stm32/pin_defs_stmhal.c b/ports/stm32/pin_defs_stm32.c similarity index 100% rename from ports/stm32/pin_defs_stmhal.c rename to ports/stm32/pin_defs_stm32.c diff --git a/ports/stm32/pin_defs_stmhal.h b/ports/stm32/pin_defs_stm32.h similarity index 99% rename from ports/stm32/pin_defs_stmhal.h rename to ports/stm32/pin_defs_stm32.h index 6cf3b1b832..c5b2862835 100644 --- a/ports/stm32/pin_defs_stmhal.h +++ b/ports/stm32/pin_defs_stm32.h @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -// This file contains pin definitions that are specific to the stmhal port. +// This file contains pin definitions that are specific to the stm32 port. // This file should only ever be #included by pin.h and not directly. enum { diff --git a/ports/teensy/Makefile b/ports/teensy/Makefile index 944e281a43..08ecf0f913 100644 --- a/ports/teensy/Makefile +++ b/ports/teensy/Makefile @@ -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 @@ -31,7 +31,7 @@ CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -mfloat INC += -I. INC += -I$(TOP) -INC += -I$(TOP)/stmhal +INC += -I$(TOP)/ports/stm32 INC += -I$(BUILD) INC += -Icore @@ -91,14 +91,14 @@ SRC_C = \ uart.c \ usb.c \ -STM_SRC_C = $(addprefix stmhal/,\ +STM_SRC_C = $(addprefix ports/stm32/,\ gccollect.c \ irq.c \ pin.c \ pin_named_pins.c \ ) -STM_SRC_S = $(addprefix stmhal/,\ +STM_SRC_S = $(addprefix ports/stm32/,\ gchelper.s \ ) diff --git a/ports/teensy/lcd.c b/ports/teensy/lcd.c index e79b7d5acb..e5d6115d75 100644 --- a/ports/teensy/lcd.c +++ b/ports/teensy/lcd.c @@ -1,5 +1,5 @@ #include "py/obj.h" -#include "../stmhal/lcd.h" +#include "../stm32/lcd.h" void lcd_init(void) { } diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 08bd4db306..1a1ea01f79 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -1,5 +1,5 @@ -include mpconfigport.mk -include ../py/mkenv.mk +include ../../py/mkenv.mk FROZEN_DIR = scripts FROZEN_MPY_DIR = modules @@ -188,7 +188,7 @@ include $(TOP)/py/mkrules.mk .PHONY: test test: $(PROG) $(TOP)/tests/run-tests - $(eval DIRNAME=$(notdir $(CURDIR))) + $(eval DIRNAME=ports/$(notdir $(CURDIR))) cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests # install micropython in /usr/local/bin @@ -253,7 +253,7 @@ coverage: BUILD=build-coverage PROG=micropython_coverage coverage_test: coverage - $(eval DIRNAME=$(notdir $(CURDIR))) + $(eval DIRNAME=ports/$(notdir $(CURDIR))) cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests -d thread cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --emit native diff --git a/ports/unix/modules/upip.py b/ports/unix/modules/upip.py index 20d52a4ab7..130eb69016 120000 --- a/ports/unix/modules/upip.py +++ b/ports/unix/modules/upip.py @@ -1 +1 @@ -../../tools/upip.py \ No newline at end of file +../../../tools/upip.py \ No newline at end of file diff --git a/ports/unix/modules/upip_utarfile.py b/ports/unix/modules/upip_utarfile.py index 1498862916..d9653d6a60 120000 --- a/ports/unix/modules/upip_utarfile.py +++ b/ports/unix/modules/upip_utarfile.py @@ -1 +1 @@ -../../tools/upip_utarfile.py \ No newline at end of file +../../../tools/upip_utarfile.py \ No newline at end of file diff --git a/ports/windows/.appveyor.yml b/ports/windows/.appveyor.yml index 84060a1162..a82cf5adc9 100644 --- a/ports/windows/.appveyor.yml +++ b/ports/windows/.appveyor.yml @@ -15,7 +15,7 @@ platform: - x64 build: - project: windows/micropython.vcxproj + project: ports/windows/micropython.vcxproj verbosity: normal test_script: diff --git a/ports/windows/Makefile b/ports/windows/Makefile index a39d348266..b6433300fe 100644 --- a/ports/windows/Makefile +++ b/ports/windows/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk -include mpconfigport.mk # define main target @@ -28,13 +28,13 @@ endif # source files SRC_C = \ - unix/main.c \ - unix/file.c \ - unix/input.c \ - unix/modos.c \ - unix/modmachine.c \ - unix/modtime.c \ - unix/gccollect.c \ + ports/unix/main.c \ + ports/unix/file.c \ + ports/unix/input.c \ + ports/unix/modos.c \ + ports/unix/modmachine.c \ + ports/unix/modtime.c \ + ports/unix/gccollect.c \ windows_mphal.c \ realpath.c \ init.c \ diff --git a/ports/windows/README.md b/ports/windows/README.md index 6d32499032..f1bd405513 100644 --- a/ports/windows/README.md +++ b/ports/windows/README.md @@ -50,8 +50,8 @@ __Stack usage__ The msvc compiler is quite stack-hungry which might result in a "maximum recursion depth exceeded" RuntimeError for code with lots of nested function calls. There are several ways to deal with this: -- increase the threshold used for detection by altering the argument to `mp_stack_set_limit` in `unix/main.c` -- disable detection all together by setting `MICROPY_STACK_CHECK` to "0" in `windows/mpconfigport.h` +- increase the threshold used for detection by altering the argument to `mp_stack_set_limit` in `ports/unix/main.c` +- disable detection all together by setting `MICROPY_STACK_CHECK` to "0" in `ports/windows/mpconfigport.h` - disable the /GL compiler flag by setting `WholeProgramOptimization` to "false" See [issue 2927](https://github.com/micropython/micropython/issues/2927) for more information. diff --git a/ports/windows/msvc/genhdr.targets b/ports/windows/msvc/genhdr.targets index cac3e3ddc4..ee030c9063 100644 --- a/ports/windows/msvc/genhdr.targets +++ b/ports/windows/msvc/genhdr.targets @@ -10,7 +10,7 @@ $(PyBuildDir)genhdr\ $(PyBaseDir)py\ - $(PyBaseDir)unix\qstrdefsport.h + $(PyBaseDir)ports\unix\qstrdefsport.h $(PySrcDir)qstrdefs.h $(DestDir)qstrdefscollected.h $(DestDir)qstrdefs.generated.h diff --git a/ports/windows/msvc/paths.props b/ports/windows/msvc/paths.props index 7166982434..db3af4c0fa 100644 --- a/ports/windows/msvc/paths.props +++ b/ports/windows/msvc/paths.props @@ -3,28 +3,28 @@ True - - $([System.IO.Path]::GetFullPath(`$(MSBuildThisFileDirectory)..\..`))\ - $(PyBaseDir)windows\ + $([System.IO.Path]::GetFullPath(`$(MSBuildThisFileDirectory)..\..\..`))\ + $(PyBaseDir)ports\windows\ $(PyWinDir)build\ diff --git a/ports/windows/msvc/sources.props b/ports/windows/msvc/sources.props index a97686cdc4..b85295ebc0 100644 --- a/ports/windows/msvc/sources.props +++ b/ports/windows/msvc/sources.props @@ -3,16 +3,16 @@ - - + + - - - - - - - + + + + + + + @@ -31,7 +31,7 @@ - - + + diff --git a/ports/windows/windows_mphal.h b/ports/windows/windows_mphal.h index 5a93d4e184..2b7aab44a0 100644 --- a/ports/windows/windows_mphal.h +++ b/ports/windows/windows_mphal.h @@ -25,7 +25,7 @@ */ #include "sleep.h" -#include "unix/mphalport.h" +#include "ports/unix/mphalport.h" #define MICROPY_HAL_HAS_VT100 (0) diff --git a/ports/zephyr/Makefile b/ports/zephyr/Makefile index 5840cc47ec..8b7cb76c38 100644 --- a/ports/zephyr/Makefile +++ b/ports/zephyr/Makefile @@ -26,7 +26,7 @@ ifneq ($(MAKECMDGOALS), clean) include $(Z_EXPORTS) endif -include ../py/mkenv.mk +include ../../py/mkenv.mk include $(TOP)/py/py.mk INC += -I. diff --git a/py/mkrules.mk b/py/mkrules.mk index bf6ad29410..13545eb6f0 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -103,7 +103,7 @@ endif ifneq ($(FROZEN_MPY_DIR),) # to build the MicroPython cross compiler -$(TOP)/mpy-cross/mpy-cross: $(TOP)/py/*.[ch] $(TOP)/mpy-cross/*.[ch] $(TOP)/windows/fmode.c +$(TOP)/mpy-cross/mpy-cross: $(TOP)/py/*.[ch] $(TOP)/mpy-cross/*.[ch] $(TOP)/ports/windows/fmode.c $(Q)$(MAKE) -C $(TOP)/mpy-cross # make a list of all the .py files that need compiling and freezing diff --git a/tests/run-tests b/tests/run-tests index f9c26283dc..14df1e986d 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -13,10 +13,10 @@ from glob import glob # to the correct executable. if os.name == 'nt': CPYTHON3 = os.getenv('MICROPY_CPYTHON3', 'python3.exe') - MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../windows/micropython.exe') + MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../ports/windows/micropython.exe') else: CPYTHON3 = os.getenv('MICROPY_CPYTHON3', 'python3') - MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../unix/micropython') + MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../ports/unix/micropython') # mpy-cross is only needed if --via-mpy command-line arg is passed MPYCROSS = os.getenv('MICROPY_MPYCROSS', '../mpy-cross/mpy-cross') diff --git a/tools/check_code_size.sh b/tools/check_code_size.sh index c5f0c6ffdd..2925ff1689 100755 --- a/tools/check_code_size.sh +++ b/tools/check_code_size.sh @@ -10,7 +10,7 @@ REFERENCE=$HOME/persist/firmware.bin if [ -f $REFERENCE ]; then size_old=$(stat -c%s $REFERENCE) - size_new=$(stat -c%s minimal/build/firmware.bin) + size_new=$(stat -c%s ports/minimal/build/firmware.bin) echo "Old size: $size_old new size: $size_new" if [ $size_new -gt $size_old ]; then echo "Validation failure: Core code size increased" diff --git a/tools/codestats.sh b/tools/codestats.sh index 5272f3e9c1..09284a30de 100755 --- a/tools/codestats.sh +++ b/tools/codestats.sh @@ -9,7 +9,7 @@ # executing because it does not exist in old revisions of the repository. # check that we are in the root directory of the repository -if [ ! -d py -o ! -d unix -o ! -d stmhal ]; then +if [ ! -d py -o ! -d ports/unix -o ! -d ports/stm32 ]; then echo "script must be run from root of the repository" exit 1 fi @@ -23,18 +23,18 @@ AWK=awk MAKE="make -j2" # these are the binaries that are built; some have 2 or 3 depending on version -bin_unix=unix/micropython -bin_stmhal=stmhal/build-PYBV10/firmware.elf -bin_barearm_1=bare-arm/build/flash.elf -bin_barearm_2=bare-arm/build/firmware.elf -bin_minimal=minimal/build/firmware.elf -bin_cc3200_1=cc3200/build/LAUNCHXL/application.axf -bin_cc3200_2=cc3200/build/LAUNCHXL/release/application.axf -bin_cc3200_3=cc3200/build/WIPY/release/application.axf +bin_unix=ports/unix/micropython +bin_stm32=ports/stm32/build-PYBV10/firmware.elf +bin_barearm_1=ports/bare-arm/build/flash.elf +bin_barearm_2=ports/bare-arm/build/firmware.elf +bin_minimal=ports/minimal/build/firmware.elf +bin_cc3200_1=ports/cc3200/build/LAUNCHXL/application.axf +bin_cc3200_2=ports/cc3200/build/LAUNCHXL/release/application.axf +bin_cc3200_3=ports/cc3200/build/WIPY/release/application.axf # start at zero size; if build fails reuse previous valid size size_unix="0" -size_stmhal="0" +size_stm32="0" size_barearm="0" size_minimal="0" size_cc3200="0" @@ -86,7 +86,7 @@ function get_size3() { if [ -r $output ]; then last_rev=$(tail -n1 $output | $AWK '{print $1}') else - echo "# hash size_unix size_stmhal size_barearm size_minimal size_cc3200 pystones" > $output + echo "# hash size_unix size_stm32 size_barearm size_minimal size_cc3200 pystones" > $output last_rev="v1.0" fi @@ -132,37 +132,37 @@ EOF #### unix #### $RM $bin_unix - $MAKE -C unix CFLAGS_EXTRA=-DNDEBUG + $MAKE -C ports/unix CFLAGS_EXTRA=-DNDEBUG size_unix=$(get_size $size_unix $bin_unix) # undo patch if it was applied git checkout unix/modtime.c - #### stmhal #### + #### stm32 #### - $RM $bin_stmhal - $MAKE -C stmhal board=PYBV10 - size_stmhal=$(get_size $size_stmhal $bin_stmhal) + $RM $bin_stm32 + $MAKE -C ports/stm32 board=PYBV10 + size_stm32=$(get_size $size_stm32 $bin_stm32) #### bare-arm #### $RM $bin_barearm_1 $bin_barearm_2 - $MAKE -C bare-arm + $MAKE -C ports/bare-arm size_barearm=$(get_size2 $size_barearm $bin_barearm_1 $bin_barearm_2) #### minimal #### - if [ -r minimal/Makefile ]; then + if [ -r ports/minimal/Makefile ]; then $RM $bin_minimal - $MAKE -C minimal CROSS=1 + $MAKE -C ports/minimal CROSS=1 size_minimal=$(get_size $size_minimal $bin_minimal) fi #### cc3200 #### - if [ -r cc3200/Makefile ]; then + if [ -r ports/cc3200/Makefile ]; then $RM $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3 - $MAKE -C cc3200 BTARGET=application + $MAKE -C ports/cc3200 BTARGET=application size_cc3200=$(get_size3 $size_cc3200 $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3) fi @@ -178,7 +178,7 @@ EOF #### output data for this commit #### - echo "$hash $size_unix $size_stmhal $size_barearm $size_minimal $size_cc3200 $pystones" >> $output + echo "$hash $size_unix $size_stm32 $size_barearm $size_minimal $size_cc3200 $pystones" >> $output done