mirror of
https://github.com/micropython/micropython.git
synced 2025-12-25 14:20:12 +01:00
Compare commits
35 Commits
v1.13
...
parse-byte
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
949b55691c | ||
|
|
d64154c730 | ||
|
|
414537711d | ||
|
|
39b465ca83 | ||
|
|
20f1bd0a14 | ||
|
|
4ddb838f8b | ||
|
|
d7576c4ba7 | ||
|
|
d88eab7445 | ||
|
|
c7d334e047 | ||
|
|
25e24b2c3c | ||
|
|
022d6a9798 | ||
|
|
3417b28eaf | ||
|
|
9624f10825 | ||
|
|
545354cb2a | ||
|
|
76b564ca47 | ||
|
|
a7f5c64d21 | ||
|
|
f6e6776d6f | ||
|
|
d9d9b0a300 | ||
|
|
1db008349c | ||
|
|
bb254ba0ea | ||
|
|
5e76ea4aff | ||
|
|
b4078cbbf3 | ||
|
|
e52758da22 | ||
|
|
be2387885b | ||
|
|
b084ab966e | ||
|
|
72912c753a | ||
|
|
be020eb2c3 | ||
|
|
1c0343f9d9 | ||
|
|
2d9531a777 | ||
|
|
238b5f5f89 | ||
|
|
c23a2eabf5 | ||
|
|
6cdf8167f7 | ||
|
|
127d1f5a2b | ||
|
|
61398ab45a | ||
|
|
5bf649f370 |
22
.gitattributes
vendored
22
.gitattributes
vendored
@@ -7,7 +7,6 @@
|
||||
*.bat text eol=crlf
|
||||
|
||||
# These are binary so should never be modified by git.
|
||||
*.a binary
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
*.dxf binary
|
||||
@@ -16,11 +15,16 @@
|
||||
# These should also not be modified by git.
|
||||
tests/basics/string_cr_conversion.py -text
|
||||
tests/basics/string_crlf_conversion.py -text
|
||||
ports/stm32/pybcdc.inf_template -text
|
||||
ports/stm32/usbhost/** -text
|
||||
ports/cc3200/hal/aes.c -text
|
||||
ports/cc3200/hal/aes.h -text
|
||||
ports/cc3200/hal/des.c -text
|
||||
ports/cc3200/hal/i2s.c -text
|
||||
ports/cc3200/hal/i2s.h -text
|
||||
ports/cc3200/version.h -text
|
||||
stmhal/pybcdc.inf_template -text
|
||||
stmhal/usbd_* -text
|
||||
stmhal/boards/*/stm32f4xx_hal_conf.h -text
|
||||
stmhal/cmsis/** -text
|
||||
stmhal/hal/** -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
|
||||
|
||||
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
@@ -1 +0,0 @@
|
||||
github: micropython
|
||||
18
.github/workflows/docs.yml
vendored
18
.github/workflows/docs.yml
vendored
@@ -1,18 +0,0 @@
|
||||
name: Build docs
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- docs/**
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v1
|
||||
- name: Install Python packages
|
||||
run: pip install Sphinx
|
||||
- name: Build docs
|
||||
run: make -C docs/ html
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -20,14 +20,14 @@
|
||||
######################
|
||||
*.swp
|
||||
|
||||
# Build directories
|
||||
# Build directory
|
||||
######################
|
||||
build/
|
||||
build-*/
|
||||
|
||||
# Test failure outputs
|
||||
######################
|
||||
tests/results/*
|
||||
tests/*.exp
|
||||
tests/*.out
|
||||
|
||||
# Python cache files
|
||||
######################
|
||||
|
||||
27
.gitmodules
vendored
27
.gitmodules
vendored
@@ -7,32 +7,7 @@
|
||||
url = https://github.com/atgreen/libffi
|
||||
[submodule "lib/lwip"]
|
||||
path = lib/lwip
|
||||
url = https://git.savannah.gnu.org/r/lwip.git
|
||||
url = http://git.savannah.gnu.org/r/lwip.git
|
||||
[submodule "lib/berkeley-db-1.xx"]
|
||||
path = lib/berkeley-db-1.xx
|
||||
url = https://github.com/pfalcon/berkeley-db-1.xx
|
||||
[submodule "lib/stm32lib"]
|
||||
path = lib/stm32lib
|
||||
url = https://github.com/micropython/stm32lib
|
||||
branch = work-F4-1.13.1+F7-1.5.0+L4-1.3.0
|
||||
[submodule "lib/nrfx"]
|
||||
path = lib/nrfx
|
||||
url = https://github.com/NordicSemiconductor/nrfx.git
|
||||
[submodule "lib/mbedtls"]
|
||||
path = lib/mbedtls
|
||||
url = https://github.com/ARMmbed/mbedtls.git
|
||||
[submodule "lib/asf4"]
|
||||
path = lib/asf4
|
||||
url = https://github.com/adafruit/asf4
|
||||
[submodule "lib/tinyusb"]
|
||||
path = lib/tinyusb
|
||||
url = https://github.com/hathach/tinyusb
|
||||
[submodule "lib/mynewt-nimble"]
|
||||
path = lib/mynewt-nimble
|
||||
url = https://github.com/apache/mynewt-nimble.git
|
||||
[submodule "lib/btstack"]
|
||||
path = lib/btstack
|
||||
url = https://github.com/bluekitchen/btstack.git
|
||||
[submodule "lib/nxp_driver"]
|
||||
path = lib/nxp_driver
|
||||
url = https://github.com/hathach/nxp_driver.git
|
||||
|
||||
440
.travis.yml
440
.travis.yml
@@ -1,395 +1,67 @@
|
||||
# global options
|
||||
dist: xenial
|
||||
language:
|
||||
- c
|
||||
sudo: required
|
||||
dist: trusty
|
||||
language: c
|
||||
compiler:
|
||||
- gcc
|
||||
cache:
|
||||
directories:
|
||||
- "${HOME}/persist"
|
||||
env:
|
||||
global:
|
||||
- MAKEOPTS="-j4"
|
||||
git:
|
||||
submodules: false
|
||||
|
||||
# define the successive stages
|
||||
stages:
|
||||
- name: test
|
||||
before_script:
|
||||
# Extra CPython versions
|
||||
# - sudo add-apt-repository -y ppa:fkrull/deadsnakes
|
||||
# Extra gcc versions
|
||||
# - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
- sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded
|
||||
- sudo dpkg --add-architecture i386
|
||||
- sudo apt-get update -qq || true
|
||||
- sudo apt-get install -y python3 gcc-multilib pkg-config libffi-dev libffi-dev:i386 qemu-system gcc-mingw-w64
|
||||
- sudo apt-get install -y --force-yes gcc-arm-none-eabi
|
||||
# For teensy build
|
||||
- sudo apt-get install realpath
|
||||
# For coverage testing
|
||||
# cpp-coveralls 0.4 conflicts with urllib3 preinstalled in Travis VM
|
||||
- sudo pip install cpp-coveralls==0.3.12
|
||||
- gcc --version
|
||||
- arm-none-eabi-gcc --version
|
||||
- python3 --version
|
||||
|
||||
# define the jobs for the stages
|
||||
# approx order of the jobs has longest running first to optimise total time
|
||||
jobs:
|
||||
include:
|
||||
# check code formatting
|
||||
- stage: test
|
||||
os: linux
|
||||
dist: bionic
|
||||
name: "code formatting"
|
||||
before_install:
|
||||
- sudo apt-add-repository --yes --update ppa:pybricks/ppa
|
||||
install:
|
||||
- sudo apt-get install uncrustify python3-pip
|
||||
- uncrustify --version
|
||||
- pip3 install --user black
|
||||
- black --version
|
||||
script:
|
||||
- tools/codeformat.py
|
||||
- git diff --exit-code
|
||||
script:
|
||||
- make -C mpy-cross
|
||||
- make -C minimal CROSS=1 build/firmware.bin
|
||||
- ls -l 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-
|
||||
|
||||
# zephyr port
|
||||
- stage: test
|
||||
name: "zephyr port build"
|
||||
services:
|
||||
- docker
|
||||
before_install:
|
||||
- docker pull zephyrprojectrtos/ci:v0.11.8
|
||||
- >
|
||||
docker run --name zephyr-ci -d -it
|
||||
-v "$(pwd)":/micropython
|
||||
-e ZEPHYR_SDK_INSTALL_DIR=/opt/sdk/zephyr-sdk-0.11.3
|
||||
-e ZEPHYR_TOOLCHAIN_VARIANT=zephyr
|
||||
-w /micropython/ports/zephyr
|
||||
zephyrprojectrtos/ci:v0.11.8
|
||||
- docker ps -a
|
||||
install:
|
||||
- docker exec zephyr-ci west init --mr v2.3.0 /zephyrproject
|
||||
- docker exec -w /zephyrproject zephyr-ci west update
|
||||
- docker exec -w /zephyrproject zephyr-ci west zephyr-export
|
||||
script:
|
||||
- docker exec zephyr-ci bash -c "make clean; ./make-minimal ${MAKEOPTS}"
|
||||
- docker exec zephyr-ci bash -c "make clean; ./make-minimal ${MAKEOPTS} BOARD=frdm_k64f"
|
||||
- docker exec zephyr-ci bash -c "make clean; make ${MAKEOPTS}"
|
||||
- docker exec zephyr-ci bash -c "make clean; make ${MAKEOPTS} BOARD=frdm_k64f"
|
||||
- docker exec zephyr-ci bash -c "make clean; make ${MAKEOPTS} BOARD=mimxrt1050_evk"
|
||||
- docker exec zephyr-ci bash -c "make clean; make ${MAKEOPTS} BOARD=reel_board"
|
||||
# run tests without coverage info
|
||||
#- (cd tests && MICROPY_CPYTHON3=python3.4 ./run-tests)
|
||||
#- (cd tests && MICROPY_CPYTHON3=python3.4 ./run-tests --emit native)
|
||||
|
||||
# unix port on OSX (first in list because the build VM takes a long time to start)
|
||||
- stage: test
|
||||
os: osx
|
||||
osx_image: xcode11.3
|
||||
name: "unix port build with clang on OSX"
|
||||
env:
|
||||
- PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- make ${MAKEOPTS} -C ports/unix submodules
|
||||
- make ${MAKEOPTS} -C ports/unix deplibs
|
||||
- make ${MAKEOPTS} -C ports/unix
|
||||
# OSX has poor time resolution and the following tests do not have the correct output
|
||||
- (cd tests && ./run-tests --exclude 'uasyncio_(basic|heaplock|lock|wait_task)')
|
||||
# check for additional compiler errors/warnings
|
||||
- make ${MAKEOPTS} -C ports/unix VARIANT=coverage submodules
|
||||
- make ${MAKEOPTS} -C ports/unix VARIANT=coverage
|
||||
after_failure:
|
||||
- tests/run-tests --print-failures
|
||||
# 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)
|
||||
|
||||
# stm32 port
|
||||
- stage: test
|
||||
name: "stm32 port build"
|
||||
install:
|
||||
# need newer gcc version for Cortex-M7 support
|
||||
- sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
|
||||
- sudo apt-get update -qq || true
|
||||
- sudo apt-get install gcc-arm-embedded libnewlib-arm-none-eabi
|
||||
- arm-none-eabi-gcc --version
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- make ${MAKEOPTS} -C ports/stm32 submodules
|
||||
- git submodule update --init lib/btstack
|
||||
- make ${MAKEOPTS} -C ports/stm32 BOARD=NUCLEO_F091RC
|
||||
- make ${MAKEOPTS} -C ports/stm32 BOARD=PYBV11 MICROPY_PY_WIZNET5K=5200 MICROPY_PY_CC3K=1
|
||||
- make ${MAKEOPTS} -C ports/stm32 BOARD=PYBD_SF2
|
||||
- make ${MAKEOPTS} -C ports/stm32 BOARD=PYBD_SF6 NANBOX=1 MICROPY_BLUETOOTH_NIMBLE=0 MICROPY_BLUETOOTH_BTSTACK=1
|
||||
- make ${MAKEOPTS} -C ports/stm32 BOARD=NUCLEO_H743ZI CFLAGS_EXTRA='-DMICROPY_PY_THREAD=1'
|
||||
- make ${MAKEOPTS} -C ports/stm32 BOARD=NUCLEO_L073RZ
|
||||
- make ${MAKEOPTS} -C ports/stm32 BOARD=STM32L476DISC
|
||||
- make ${MAKEOPTS} -C ports/stm32 BOARD=NUCLEO_WB55
|
||||
- make ${MAKEOPTS} -C ports/stm32/mboot BOARD=PYBV10 CFLAGS_EXTRA='-DMBOOT_FSLOAD=1 -DMBOOT_VFS_LFS2=1'
|
||||
- make ${MAKEOPTS} -C ports/stm32/mboot BOARD=PYBD_SF6
|
||||
- make ${MAKEOPTS} -C ports/stm32/mboot BOARD=NUCLEO_WB55
|
||||
# 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)
|
||||
|
||||
# qemu-arm port
|
||||
- stage: test
|
||||
dist: bionic # needed for more recent version of qemu-system-arm with mps2-an385 target
|
||||
name: "qemu-arm port build and tests"
|
||||
install:
|
||||
- sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi qemu-system
|
||||
- arm-none-eabi-gcc --version
|
||||
- qemu-system-arm --version
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- make ${MAKEOPTS} -C ports/qemu-arm CFLAGS_EXTRA=-DMP_ENDIANNESS_BIG=1
|
||||
- make ${MAKEOPTS} -C ports/qemu-arm clean
|
||||
- make ${MAKEOPTS} -C ports/qemu-arm -f Makefile.test test
|
||||
after_failure:
|
||||
- grep --text "FAIL" ports/qemu-arm/build/console.out
|
||||
|
||||
# unix coverage
|
||||
- stage: test
|
||||
name: "unix coverage build and tests"
|
||||
install:
|
||||
- sudo apt-get install python3-pip
|
||||
- sudo pip install cpp-coveralls
|
||||
- sudo pip3 install setuptools
|
||||
- sudo pip3 install pyelftools
|
||||
- gcc --version
|
||||
- python3 --version
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- make ${MAKEOPTS} -C ports/unix VARIANT=coverage submodules
|
||||
- make ${MAKEOPTS} -C ports/unix VARIANT=coverage deplibs
|
||||
- make ${MAKEOPTS} -C ports/unix VARIANT=coverage
|
||||
# run the main test suite
|
||||
- make -C ports/unix VARIANT=coverage test_full
|
||||
- (cd tests && MICROPY_CPYTHON3=python3 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-multitests.py multi_net/*.py) || travis_terminate 1
|
||||
# test building native mpy modules
|
||||
- make -C examples/natmod/features1 ARCH=x64
|
||||
- make -C examples/natmod/features2 ARCH=x64
|
||||
- make -C examples/natmod/btree ARCH=x64
|
||||
- make -C examples/natmod/framebuf ARCH=x64
|
||||
- make -C examples/natmod/uheapq ARCH=x64
|
||||
- make -C examples/natmod/urandom ARCH=x64
|
||||
- make -C examples/natmod/ure ARCH=x64
|
||||
- make -C examples/natmod/uzlib ARCH=x64
|
||||
# test importing .mpy generated by mpy_ld.py
|
||||
- MICROPYPATH=examples/natmod/features2 ./ports/unix/micropython-coverage -m features2
|
||||
- (cd tests && ./run-natmodtests.py extmod/{btree*,framebuf*,uheapq*,ure*,uzlib*}.py)
|
||||
# run coveralls coverage analysis (try to, even if some builds/tests failed)
|
||||
- (cd ports/unix && coveralls --root ../.. --build-root . --gcov $(which gcov) --gcov-options '\-o build-coverage/' --include py --include extmod)
|
||||
after_failure:
|
||||
- tests/run-tests --print-failures
|
||||
|
||||
# unix coverage 32-bit
|
||||
- stage: test
|
||||
name: "unix coverage 32-bit build and tests"
|
||||
install:
|
||||
- sudo apt-get install gcc-multilib libffi-dev:i386
|
||||
- sudo apt-get install python3-pip
|
||||
- sudo pip3 install setuptools
|
||||
- sudo pip3 install pyelftools
|
||||
- gcc --version
|
||||
- python3 --version
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- make ${MAKEOPTS} -C ports/unix MICROPY_FORCE_32BIT=1 VARIANT=coverage submodules
|
||||
- make ${MAKEOPTS} -C ports/unix MICROPY_FORCE_32BIT=1 VARIANT=coverage deplibs
|
||||
- make ${MAKEOPTS} -C ports/unix MICROPY_FORCE_32BIT=1 VARIANT=coverage
|
||||
# run the main test suite
|
||||
- make -C ports/unix MICROPY_FORCE_32BIT=1 VARIANT=coverage test_full || travis_terminate 1
|
||||
# test building native mpy modules
|
||||
- make -C examples/natmod/features1 ARCH=x86
|
||||
- make -C examples/natmod/features2 ARCH=x86
|
||||
- make -C examples/natmod/btree ARCH=x86
|
||||
- make -C examples/natmod/framebuf ARCH=x86
|
||||
- make -C examples/natmod/uheapq ARCH=x86
|
||||
- make -C examples/natmod/urandom ARCH=x86
|
||||
- make -C examples/natmod/ure ARCH=x86
|
||||
- make -C examples/natmod/uzlib ARCH=x86
|
||||
# test importing .mpy generated by mpy_ld.py
|
||||
- MICROPYPATH=examples/natmod/features2 ./ports/unix/micropython-coverage -m features2
|
||||
- (cd tests && ./run-natmodtests.py --arch x86 extmod/{btree*,framebuf*,uheapq*,ure*,uzlib*}.py)
|
||||
after_failure:
|
||||
- tests/run-tests --print-failures
|
||||
|
||||
# standard unix port
|
||||
- stage: test
|
||||
name: "unix port build and tests"
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- make ${MAKEOPTS} -C ports/unix submodules
|
||||
- make ${MAKEOPTS} -C ports/unix deplibs
|
||||
- make ${MAKEOPTS} -C ports/unix
|
||||
- make ${MAKEOPTS} -C ports/unix test
|
||||
- (cd tests && MICROPY_CPYTHON3=python3 MICROPY_MICROPYTHON=../ports/unix/micropython ./run-perfbench.py 1000 1000)
|
||||
after_failure:
|
||||
- tests/run-tests --print-failures
|
||||
|
||||
# unix nanbox/float (and using Python 2 to check it can run the build scripts)
|
||||
- stage: test
|
||||
name: "unix nanbox/float port build and tests"
|
||||
install:
|
||||
- sudo apt-get install gcc-multilib libffi-dev:i386
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross PYTHON=python2
|
||||
- make ${MAKEOPTS} -C ports/unix VARIANT=nanbox submodules
|
||||
- make ${MAKEOPTS} -C ports/unix PYTHON=python2 VARIANT=nanbox deplibs
|
||||
- make ${MAKEOPTS} -C ports/unix PYTHON=python2 VARIANT=nanbox
|
||||
- make ${MAKEOPTS} -C ports/unix PYTHON=python2 VARIANT=nanbox test_full || travis_terminate 1
|
||||
- make ${MAKEOPTS} -C ports/unix clean
|
||||
- make ${MAKEOPTS} -C ports/unix CFLAGS_EXTRA="-DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT"
|
||||
- make ${MAKEOPTS} -C ports/unix test
|
||||
after_failure:
|
||||
- tests/run-tests --print-failures
|
||||
|
||||
# unix stackless/float with clang
|
||||
- stage: test
|
||||
name: "unix stackless/float port build and tests with clang"
|
||||
install:
|
||||
- sudo apt-get install clang
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross CC=clang
|
||||
- make ${MAKEOPTS} -C ports/unix submodules
|
||||
- make ${MAKEOPTS} -C ports/unix CC=clang CFLAGS_EXTRA="-DMICROPY_STACKLESS=1 -DMICROPY_STACKLESS_STRICT=1"
|
||||
- make ${MAKEOPTS} -C ports/unix CC=clang test || travis_terminate 1
|
||||
- make ${MAKEOPTS} -C ports/unix clean
|
||||
- make ${MAKEOPTS} -C ports/unix CC=clang CFLAGS_EXTRA="-DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT"
|
||||
- make ${MAKEOPTS} -C ports/unix CC=clang test
|
||||
after_failure:
|
||||
- tests/run-tests --print-failures
|
||||
|
||||
# unix with sys.settrace
|
||||
- stage: test
|
||||
name: "unix port with sys.settrace build and tests"
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- make ${MAKEOPTS} -C ports/unix MICROPY_PY_BTREE=0 MICROPY_PY_FFI=0 MICROPY_PY_USSL=0 CFLAGS_EXTRA="-DMICROPY_PY_SYS_SETTRACE=1" test || travis_terminate 1
|
||||
- make ${MAKEOPTS} -C ports/unix clean
|
||||
- make ${MAKEOPTS} -C ports/unix MICROPY_PY_BTREE=0 MICROPY_PY_FFI=0 MICROPY_PY_USSL=0 CFLAGS_EXTRA="-DMICROPY_STACKLESS=1 -DMICROPY_STACKLESS_STRICT=1 -DMICROPY_PY_SYS_SETTRACE=1" test
|
||||
after_failure:
|
||||
- tests/run-tests --print-failures
|
||||
|
||||
# minimal unix port with tests
|
||||
- stage: test
|
||||
name: "minimal unix port build and tests"
|
||||
script:
|
||||
- make ${MAKEOPTS} -C ports/unix VARIANT=minimal
|
||||
- (cd tests && MICROPY_CPYTHON3=python3 MICROPY_MICROPYTHON=../ports/unix/micropython-minimal ./run-tests -e exception_chain -e self_type_check -e subclass_native_init -d basics)
|
||||
after_failure:
|
||||
- tests/run-tests --print-failures
|
||||
|
||||
# windows port via mingw
|
||||
- stage: test
|
||||
name: "windows port build via mingw"
|
||||
install:
|
||||
- sudo apt-get install gcc-mingw-w64
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- make ${MAKEOPTS} -C ports/windows CROSS_COMPILE=i686-w64-mingw32-
|
||||
|
||||
# esp32 w/ESP-IDFv3 port
|
||||
- stage: test
|
||||
name: "esp32 ESP-IDFv3 port build"
|
||||
install:
|
||||
- sudo apt-get install python3-pip
|
||||
- sudo pip3 install 'pyparsing<2.4'
|
||||
- curl -L https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz | tar zxf -
|
||||
- export PATH=$(pwd)/xtensa-esp32-elf/bin:$PATH
|
||||
- git clone https://github.com/espressif/esp-idf.git
|
||||
- export IDF_PATH=$(pwd)/esp-idf
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- git -C esp-idf checkout $(grep "ESPIDF_SUPHASH_V3 :=" ports/esp32/Makefile | cut -d " " -f 3)
|
||||
- git -C esp-idf submodule update --init components/json/cJSON components/esp32/lib components/esptool_py/esptool components/expat/expat components/lwip/lwip components/mbedtls/mbedtls components/micro-ecc/micro-ecc components/nghttp/nghttp2 components/nimble components/bt
|
||||
- make ${MAKEOPTS} -C ports/esp32 submodules
|
||||
- make ${MAKEOPTS} -C ports/esp32
|
||||
|
||||
# esp32 w/ESP-IDFv4 port
|
||||
- stage: test
|
||||
name: "esp32 ESP-IDFv4 port build"
|
||||
install:
|
||||
- sudo apt-get install python3-pip
|
||||
- sudo pip3 install 'pyparsing<2.4'
|
||||
- curl -L https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-amd64.tar.gz | tar zxf -
|
||||
- export PATH=$(pwd)/xtensa-esp32-elf/bin:$PATH
|
||||
- git clone https://github.com/espressif/esp-idf.git
|
||||
- export IDF_PATH=$(pwd)/esp-idf
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- git -C esp-idf checkout $(grep "ESPIDF_SUPHASH_V4 :=" ports/esp32/Makefile | cut -d " " -f 3)
|
||||
- git -C esp-idf submodule update --init components/bt/controller/lib components/bt/host/nimble/nimble components/esp_wifi/lib_esp32 components/esptool_py/esptool components/lwip/lwip components/mbedtls/mbedtls
|
||||
- make ${MAKEOPTS} -C ports/esp32 submodules
|
||||
- make ${MAKEOPTS} -C ports/esp32
|
||||
|
||||
# esp8266 port
|
||||
- stage: test
|
||||
name: "esp8266 port build"
|
||||
install:
|
||||
- wget https://github.com/jepler/esp-open-sdk/releases/download/2018-06-10/xtensa-lx106-elf-standalone.tar.gz
|
||||
- zcat xtensa-lx106-elf-standalone.tar.gz | tar x
|
||||
- export PATH=$(pwd)/xtensa-lx106-elf/bin:$PATH
|
||||
script:
|
||||
- make ${MAKEOPTS} -C mpy-cross
|
||||
- make ${MAKEOPTS} -C ports/esp8266 submodules
|
||||
- make ${MAKEOPTS} -C ports/esp8266
|
||||
- make ${MAKEOPTS} -C ports/esp8266 BOARD=GENERIC_512K
|
||||
- make ${MAKEOPTS} -C ports/esp8266 BOARD=GENERIC_1M
|
||||
|
||||
# nrf port
|
||||
- stage: test
|
||||
name: "nrf port build"
|
||||
install:
|
||||
# need newer gcc version for Cortex-M33 support
|
||||
- sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
|
||||
- sudo apt-get update -qq || true
|
||||
- sudo apt-get install gcc-arm-embedded
|
||||
- sudo apt-get install libnewlib-arm-none-eabi
|
||||
- arm-none-eabi-gcc --version
|
||||
script:
|
||||
- ports/nrf/drivers/bluetooth/download_ble_stack.sh s140_nrf52_6_1_1
|
||||
- make ${MAKEOPTS} -C ports/nrf submodules
|
||||
- make ${MAKEOPTS} -C ports/nrf BOARD=pca10040
|
||||
- make ${MAKEOPTS} -C ports/nrf BOARD=microbit
|
||||
- make ${MAKEOPTS} -C ports/nrf BOARD=pca10056 SD=s140
|
||||
- make ${MAKEOPTS} -C ports/nrf BOARD=pca10090
|
||||
|
||||
# bare-arm and minimal ports, with size-diff check
|
||||
- stage: test
|
||||
name: "bare-arm and minimal ports build and size-diff check"
|
||||
install:
|
||||
- sudo apt-get install gcc-multilib libffi-dev:i386 gcc-arm-none-eabi libnewlib-arm-none-eabi
|
||||
- gcc --version
|
||||
- arm-none-eabi-gcc --version
|
||||
script:
|
||||
# starts off at either the ref/pull/N/merge FETCH_HEAD, or the current branch HEAD
|
||||
- git checkout -b pull_request # save the current location
|
||||
- git remote add upstream https://github.com/micropython/micropython.git
|
||||
- git fetch --depth=100 upstream
|
||||
# build reference, save to size0
|
||||
# ignore any errors with this build, in case master is failing
|
||||
- git checkout `git merge-base --fork-point upstream/master pull_request`
|
||||
- git show -s
|
||||
- tools/metrics.py clean bm
|
||||
- tools/metrics.py build bm | tee ~/size0 || true
|
||||
# build PR/branch, save to size1
|
||||
- git checkout pull_request
|
||||
- git log upstream/master..HEAD
|
||||
- tools/metrics.py clean bm
|
||||
- tools/metrics.py build bm | tee ~/size1 || travis_terminate 1
|
||||
# compute diff of the code sizes
|
||||
- tools/metrics.py diff --error-threshold 0 ~/size0 ~/size1
|
||||
|
||||
# cc3200 port
|
||||
- stage: test
|
||||
name: "cc3200 port build"
|
||||
install:
|
||||
- sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi
|
||||
script:
|
||||
- make ${MAKEOPTS} -C ports/cc3200 BTARGET=application BTYPE=release
|
||||
- make ${MAKEOPTS} -C ports/cc3200 BTARGET=bootloader BTYPE=release
|
||||
|
||||
# samd port
|
||||
- stage: test
|
||||
name: "samd port build"
|
||||
install:
|
||||
- sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi
|
||||
script:
|
||||
- make ${MAKEOPTS} -C ports/samd submodules
|
||||
- make ${MAKEOPTS} -C ports/samd
|
||||
|
||||
# teensy port
|
||||
- stage: test
|
||||
name: "teensy port build"
|
||||
install:
|
||||
- sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi
|
||||
script:
|
||||
- make ${MAKEOPTS} -C ports/teensy
|
||||
|
||||
# powerpc port
|
||||
- stage: test
|
||||
name: "powerpc port build"
|
||||
install:
|
||||
- sudo apt-get install gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross
|
||||
script:
|
||||
- make ${MAKEOPTS} -C ports/powerpc UART=potato
|
||||
- make ${MAKEOPTS} -C ports/powerpc UART=lpc_serial
|
||||
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)
|
||||
|
||||
@@ -762,6 +762,7 @@ today. The names appear in order of pledging.
|
||||
1642 Udine
|
||||
1643 Simon Critchley
|
||||
1644 Sven Haiges, Germany
|
||||
1645 Yi Qing Sim
|
||||
1646 "silicium" ("silicium_one", if "silicium" is busy)
|
||||
1648 Andy O'Malia, @andyomalia
|
||||
1650 RedCamelApps.com
|
||||
|
||||
@@ -11,7 +11,7 @@ It's also ok to drop file extensions.
|
||||
|
||||
Besides prefix, first line of a commit message should describe a
|
||||
change clearly and to the point, and be a grammatical sentence with
|
||||
final full stop. First line should fit within 72 characters. Examples
|
||||
final full stop. First line should fit within 78 characters. Examples
|
||||
of good first line of commit messages:
|
||||
|
||||
py/objstr: Add splitlines() method.
|
||||
@@ -19,20 +19,16 @@ of good first line of commit messages:
|
||||
docs/machine: Fix typo in reset() description.
|
||||
ports: Switch to use lib/foo instead of duplicated code.
|
||||
|
||||
After the first line add an empty line and in the following lines describe
|
||||
the change in a detail, if needed, with lines fitting within 75 characters
|
||||
(with an exception for long items like URLs which cannot be broken). Any
|
||||
change beyond 5 lines would likely require such detailed description.
|
||||
After the first line, add an empty line and in following lines describe
|
||||
a change in a detail, if needed. Any change beyond 5 lines would likely
|
||||
require such detailed description.
|
||||
|
||||
To get good practical examples of good commits and their messages, browse
|
||||
the `git log` of the project.
|
||||
|
||||
When committing you are encouraged to sign-off your commit by adding
|
||||
"Signed-off-by" lines and similar, eg using "git commit -s". If you don't
|
||||
explicitly sign-off in this way then the commit message, which includes your
|
||||
name and email address in the "Author" line, implies your sign-off. In either
|
||||
case, of explicit or implicit sign-off, you are certifying and signing off
|
||||
against the following:
|
||||
MicroPython doesn't require explicit sign-off for patches ("Signed-off-by"
|
||||
lines and similar). Instead, the commit message, and your name and email
|
||||
address on it construes your sign-off of the following:
|
||||
|
||||
* That you wrote the change yourself, or took it from a project with
|
||||
a compatible license (in the latter case the commit message, and possibly
|
||||
@@ -46,35 +42,19 @@ against the following:
|
||||
copyright for your changes (for smaller changes, the commit message
|
||||
conveys your copyright; if you make significant changes to a particular
|
||||
source module, you're welcome to add your name to the file header).
|
||||
* Your contribution including commit message will be publicly and
|
||||
indefinitely available for anyone to access, including redistribution
|
||||
under the terms of the project's license.
|
||||
* Your signature for all of the above, which is the "Signed-off-by" line
|
||||
or the "Author" line in the commit message, includes your full real name and
|
||||
* Your signature for all of the above, which is the 'Author' line in
|
||||
the commit message, and which should include your full real name and
|
||||
a valid and active email address by which you can be contacted in the
|
||||
foreseeable future.
|
||||
|
||||
Code auto-formatting
|
||||
====================
|
||||
|
||||
Both C and Python code are auto-formatted using the `tools/codeformat.py`
|
||||
script. This uses [uncrustify](https://github.com/uncrustify/uncrustify) to
|
||||
format C code and [black](https://github.com/psf/black) to format Python code.
|
||||
After making changes, and before committing, run this tool to reformat your
|
||||
changes to the correct style. Without arguments this tool will reformat all
|
||||
source code (and may take some time to run). Otherwise pass as arguments to
|
||||
the tool the files that changed and it will only reformat those.
|
||||
|
||||
Python code conventions
|
||||
=======================
|
||||
|
||||
Python code follows [PEP 8](https://legacy.python.org/dev/peps/pep-0008/) and
|
||||
is auto-formatted using [black](https://github.com/psf/black) with a line-length
|
||||
of 99 characters.
|
||||
Python code follows [PEP 8](http://legacy.python.org/dev/peps/pep-0008/).
|
||||
|
||||
Naming conventions:
|
||||
- Module names are short and all lowercase; eg pyb, stm.
|
||||
- Class names are CamelCase, with abbreviations all uppercase; eg I2C, not
|
||||
- Class names are CamelCase, with abreviations all uppercase; eg I2C, not
|
||||
I2c.
|
||||
- Function and method names are all lowercase with words separated by
|
||||
a single underscore as necessary to improve readability; eg mem_read.
|
||||
@@ -84,12 +64,7 @@ Naming conventions:
|
||||
C code conventions
|
||||
==================
|
||||
|
||||
C code is auto-formatted using [uncrustify](https://github.com/uncrustify/uncrustify)
|
||||
and the corresponding configuration file `tools/uncrustify.cfg`, with a few
|
||||
minor fix-ups applied by `tools/codeformat.py`. When writing new C code please
|
||||
adhere to the existing style and use `tools/codeformat.py` to check any changes.
|
||||
The main conventions, and things not enforceable via the auto-formatter, are
|
||||
described below.
|
||||
When writing new C code, please adhere to the following conventions.
|
||||
|
||||
White space:
|
||||
- Expand tabs to 4 spaces.
|
||||
@@ -150,7 +125,7 @@ Braces, spaces, names and comments:
|
||||
foo(x + TO_ADD, some_value - 1);
|
||||
}
|
||||
|
||||
for (int my_counter = 0; my_counter < x; ++my_counter) {
|
||||
for (int my_counter = 0; my_counter < x; my_counter++) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
MicroPython Code of Conduct
|
||||
===========================
|
||||
|
||||
The MicroPython community is made up of members from around the globe with a
|
||||
diverse set of skills, personalities, and experiences. It is through these
|
||||
differences that our community experiences great successes and continued growth.
|
||||
When you're working with members of the community, this Code of Conduct will
|
||||
help steer your interactions and keep MicroPython a positive, successful, and
|
||||
growing community.
|
||||
|
||||
Members of the MicroPython community are open, considerate, and respectful.
|
||||
Behaviours that reinforce these values contribute to a positive environment, and
|
||||
include: acknowledging time and effort, being respectful of differing viewpoints
|
||||
and experiences, gracefully accepting constructive criticism, and using
|
||||
welcoming and inclusive language.
|
||||
|
||||
Every member of our community has the right to have their identity respected.
|
||||
The MicroPython community is dedicated to providing a positive experience for
|
||||
everyone, regardless of age, gender identity and expression, sexual orientation,
|
||||
disability, physical appearance, body size, ethnicity, nationality, race, or
|
||||
religion (or lack thereof), education, or socio-economic status.
|
||||
|
||||
Unacceptable behaviour includes: harassment, trolling, deliberate intimidation,
|
||||
violent threats or language directed against another person; insults, put downs,
|
||||
or jokes that are based upon stereotypes, that are exclusionary, or that hold
|
||||
others up for ridicule; unwelcome sexual attention or advances; sustained
|
||||
disruption of community discussions; publishing others' private information
|
||||
without explicit permission; and other conduct that is inappropriate for a
|
||||
professional audience including people of many different backgrounds.
|
||||
|
||||
This code of conduct covers all online and offline presence related to the
|
||||
MicroPython project, including GitHub and the forum. If a participant engages
|
||||
in behaviour that violates this code of conduct, the MicroPython team may take
|
||||
action as they deem appropriate, including warning the offender or expulsion
|
||||
from the community. Community members asked to stop any inappropriate behaviour
|
||||
are expected to comply immediately.
|
||||
|
||||
Thank you for helping make this a welcoming, friendly community for everyone.
|
||||
|
||||
If you believe that someone is violating the code of conduct, or have any other
|
||||
concerns, please contact a member of the MicroPython team by emailing
|
||||
contact@micropython.org.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
This Code of Conduct is licensed under the Creative Commons
|
||||
Attribution-ShareAlike 3.0 Unported License.
|
||||
|
||||
Attributions
|
||||
------------
|
||||
|
||||
Based on the Python code of conduct found at https://www.python.org/psf/conduct/
|
||||
@@ -3,6 +3,6 @@ make sure that you are acquainted with Contributor Guidelines:
|
||||
|
||||
https://github.com/micropython/micropython/wiki/ContributorGuidelines
|
||||
|
||||
as well as the Code Conventions, which includes details of how to commit:
|
||||
and Code Conventions:
|
||||
|
||||
https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2020 Damien P. George
|
||||
Copyright (c) 2013, 2014 Damien P. George
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
102
README.md
102
README.md
@@ -1,4 +1,4 @@
|
||||
[](https://travis-ci.com/micropython/micropython) [](https://coveralls.io/r/micropython/micropython?branch=master)
|
||||
[](https://travis-ci.org/micropython/micropython) [](https://coveralls.io/r/micropython/micropython?branch=master)
|
||||
|
||||
The MicroPython project
|
||||
=======================
|
||||
@@ -34,25 +34,24 @@ Major components in this repository:
|
||||
core library.
|
||||
- mpy-cross/ -- the MicroPython cross-compiler which is used to turn scripts
|
||||
into precompiled bytecode.
|
||||
- ports/unix/ -- a version of MicroPython that runs on Unix.
|
||||
- ports/stm32/ -- a version of MicroPython that runs on the PyBoard and similar
|
||||
- unix/ -- a version of MicroPython that runs on Unix.
|
||||
- stmhal/ -- a version of MicroPython that runs on the PyBoard and similar
|
||||
STM32 boards (using ST's Cube HAL drivers).
|
||||
- ports/minimal/ -- a minimal MicroPython port. Start with this if you want
|
||||
- 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.
|
||||
HTML documentation is available at http://docs.micropython.org (be sure
|
||||
to select needed board/port at the bottom left corner).
|
||||
|
||||
Additional components:
|
||||
- ports/bare-arm/ -- a bare minimum version of MicroPython for ARM MCUs. Used
|
||||
- bare-arm/ -- a bare minimum version of MicroPython for ARM MCUs. Used
|
||||
mostly to control code size.
|
||||
- ports/teensy/ -- a version of MicroPython that runs on the Teensy 3.1
|
||||
- teensy/ -- a version of MicroPython that runs on the Teensy 3.1
|
||||
(preliminary but functional).
|
||||
- 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/ -- a version of MicroPython that runs on Espressif's ESP8266 SoC.
|
||||
- ports/esp32/ -- a version of MicroPython that runs on Espressif's ESP32 SoC.
|
||||
- ports/nrf/ -- a version of MicroPython that runs on Nordic's nRF51 and nRF52 MCUs.
|
||||
- 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.
|
||||
- extmod/ -- additional (non-core) modules implemented in C.
|
||||
- tools/ -- various tools, including the pyboard.py module.
|
||||
- examples/ -- a few example Python scripts.
|
||||
@@ -60,20 +59,7 @@ Additional components:
|
||||
The subdirectories above may include READMEs with additional info.
|
||||
|
||||
"make" is used to build the components, or "gmake" on BSD-based systems.
|
||||
You will also need bash, gcc, and Python 3.3+ available as the command `python3`
|
||||
(if your system only has Python 2.7 then invoke make with the additional option
|
||||
`PYTHON=python2`).
|
||||
|
||||
The MicroPython cross-compiler, mpy-cross
|
||||
-----------------------------------------
|
||||
|
||||
Most ports require the MicroPython cross-compiler to be built first. This
|
||||
program, called mpy-cross, is used to pre-compile Python scripts to .mpy
|
||||
files which can then be included (frozen) into the firmware/executable for
|
||||
a port. To build mpy-cross use:
|
||||
|
||||
$ cd mpy-cross
|
||||
$ make
|
||||
You will also need bash and Python (at least 2.7 or 3.3).
|
||||
|
||||
The Unix version
|
||||
----------------
|
||||
@@ -86,8 +72,8 @@ Alternatively, fallback implementation based on setjmp/longjmp can be used.
|
||||
|
||||
To build (see section below for required dependencies):
|
||||
|
||||
$ cd ports/unix
|
||||
$ make submodules
|
||||
$ cd unix
|
||||
$ make axtls
|
||||
$ make
|
||||
|
||||
Then to give it a try:
|
||||
@@ -99,7 +85,7 @@ Use `CTRL-D` (i.e. EOF) to exit the shell.
|
||||
Learn about command-line options (in particular, how to increase heap size
|
||||
which may be needed for larger applications):
|
||||
|
||||
$ ./micropython -h
|
||||
$ ./micropython --help
|
||||
|
||||
Run complete testsuite:
|
||||
|
||||
@@ -118,50 +104,44 @@ Standard library modules come from
|
||||
External dependencies
|
||||
---------------------
|
||||
|
||||
Building MicroPython ports may require some dependencies installed.
|
||||
|
||||
For Unix port, `libffi` library and `pkg-config` tool are required. On
|
||||
Building Unix version requires some dependencies installed. For
|
||||
Debian/Ubuntu/Mint derivative Linux distros, install `build-essential`
|
||||
(includes toolchain and make), `libffi-dev`, and `pkg-config` packages.
|
||||
|
||||
Other dependencies can be built together with MicroPython. This may
|
||||
be required to enable extra features or capabilities, and in recent
|
||||
versions of MicroPython, these may be enabled by default. To build
|
||||
these additional dependencies, in the port directory you're
|
||||
interested in (e.g. `ports/unix/`) first execute:
|
||||
Other dependencies can be built together with MicroPython. Oftentimes,
|
||||
you need to do this to enable extra features or capabilities. To build
|
||||
these additional dependencies, first fetch git submodules for them:
|
||||
|
||||
$ make submodules
|
||||
$ git submodule update --init
|
||||
|
||||
This will fetch all the relevant git submodules (sub repositories) that
|
||||
the port needs. Use the same command to get the latest versions of
|
||||
submodules as they are updated from time to time. After that execute:
|
||||
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:
|
||||
|
||||
$ 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 enable/disable use of dependencies, edit
|
||||
`ports/unix/mpconfigport.mk` file, which has inline descriptions of the options.
|
||||
For example, to build SSL module (required for `upip` tool described above,
|
||||
and so enabled by default), `MICROPY_PY_USSL` should be set to 1.
|
||||
to `make deplibs`. To actually enabled use of dependencies, edit
|
||||
`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.
|
||||
|
||||
For some ports, building required dependences is transparent, and happens
|
||||
automatically. But they still need to be fetched with the `make submodules`
|
||||
command.
|
||||
In `unix/mpconfigport.mk`, you can also disable some dependencies enabled
|
||||
by default, like FFI support, which requires libffi development files to
|
||||
be installed.
|
||||
|
||||
The STM32 version
|
||||
-----------------
|
||||
The STM version
|
||||
---------------
|
||||
|
||||
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,
|
||||
arm-none-eabi-gcc and arm-none-eabi-newlib packages. Otherwise, try here:
|
||||
The "stmhal" 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 ports/stm32
|
||||
$ make submodules
|
||||
$ cd stmhal
|
||||
$ make
|
||||
|
||||
You then need to get your board into DFU mode. On the pyboard, connect the
|
||||
@@ -175,14 +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 ports/stm32/ directory for further details.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
MicroPython is an open-source project and welcomes contributions. To be
|
||||
productive, please be sure to follow the
|
||||
[Contributors' Guidelines](https://github.com/micropython/micropython/wiki/ContributorGuidelines)
|
||||
and the [Code Conventions](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md).
|
||||
Note that MicroPython is licenced under the MIT license, and all contributions
|
||||
should follow this license.
|
||||
See the README.md file in the stmhal/ directory for further details.
|
||||
|
||||
48
bare-arm/Makefile
Normal file
48
bare-arm/Makefile
Normal file
@@ -0,0 +1,48 @@
|
||||
include ../py/mkenv.mk
|
||||
|
||||
# qstr definitions (must come before including py.mk)
|
||||
QSTR_DEFS = qstrdefsport.h
|
||||
|
||||
# include py core make definitions
|
||||
include $(TOP)/py/py.mk
|
||||
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
|
||||
INC += -I.
|
||||
INC += -I$(TOP)
|
||||
INC += -I$(BUILD)
|
||||
|
||||
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
|
||||
CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
|
||||
|
||||
#Debugging/Optimization
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -ggdb
|
||||
else
|
||||
CFLAGS += -Os -DNDEBUG
|
||||
endif
|
||||
|
||||
LDFLAGS = -nostdlib -T stm32f405.ld -Map=$@.map --cref
|
||||
LIBS =
|
||||
|
||||
SRC_C = \
|
||||
main.c \
|
||||
# printf.c \
|
||||
string0.c \
|
||||
malloc0.c \
|
||||
gccollect.c \
|
||||
|
||||
SRC_S = \
|
||||
# startup_stm32f40xx.s \
|
||||
gchelper.s \
|
||||
|
||||
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o))
|
||||
|
||||
all: $(BUILD)/firmware.elf
|
||||
|
||||
$(BUILD)/firmware.elf: $(OBJ)
|
||||
$(ECHO) "LINK $@"
|
||||
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
$(Q)$(SIZE) $@
|
||||
|
||||
include $(TOP)/py/mkrules.mk
|
||||
97
bare-arm/main.c
Normal file
97
bare-arm/main.c
Normal file
@@ -0,0 +1,97 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "py/nlr.h"
|
||||
#include "py/compile.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/repl.h"
|
||||
#include "py/mperrno.h"
|
||||
|
||||
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
|
||||
nlr_buf_t nlr;
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
|
||||
qstr source_name = lex->source_name;
|
||||
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
|
||||
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true);
|
||||
mp_call_function_0(module_fun);
|
||||
nlr_pop();
|
||||
} else {
|
||||
// uncaught exception
|
||||
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
mp_init();
|
||||
do_str("print('hello world!', list(x+1 for x in range(10)), end='eol\\n')", MP_PARSE_SINGLE_INPUT);
|
||||
do_str("for i in range(10):\n print(i)", MP_PARSE_FILE_INPUT);
|
||||
mp_deinit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
||||
mp_raise_OSError(MP_ENOENT);
|
||||
}
|
||||
|
||||
mp_import_stat_t mp_import_stat(const char *path) {
|
||||
return MP_IMPORT_STAT_NO_EXIST;
|
||||
}
|
||||
|
||||
mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
|
||||
|
||||
void nlr_jump_fail(void *val) {
|
||||
while (1);
|
||||
}
|
||||
|
||||
void NORETURN __fatal_error(const char *msg) {
|
||||
while (1);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) {
|
||||
printf("Assertion '%s' failed, at file %s:%d\n", expr, file, line);
|
||||
__fatal_error("Assertion failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
int _lseek() {return 0;}
|
||||
int _read() {return 0;}
|
||||
int _write() {return 0;}
|
||||
int _close() {return 0;}
|
||||
void _exit(int x) {for(;;){}}
|
||||
int _sbrk() {return 0;}
|
||||
int _kill() {return 0;}
|
||||
int _getpid() {return 0;}
|
||||
int _fstat() {return 0;}
|
||||
int _isatty() {return 0;}
|
||||
*/
|
||||
|
||||
void *malloc(size_t n) {return NULL;}
|
||||
void *calloc(size_t nmemb, size_t size) {return NULL;}
|
||||
void *realloc(void *ptr, size_t size) {return NULL;}
|
||||
void free(void *p) {}
|
||||
int printf(const char *m, ...) {return 0;}
|
||||
void *memcpy(void *dest, const void *src, size_t n) {return NULL;}
|
||||
int memcmp(const void *s1, const void *s2, size_t n) {return 0;}
|
||||
void *memmove(void *dest, const void *src, size_t n) {return NULL;}
|
||||
void *memset(void *s, int c, size_t n) {return NULL;}
|
||||
int strcmp(const char *s1, const char* s2) {return 0;}
|
||||
int strncmp(const char *s1, const char* s2, size_t n) {return 0;}
|
||||
size_t strlen(const char *s) {return 0;}
|
||||
char *strcat(char *dest, const char *src) {return NULL;}
|
||||
char *strchr(const char *dest, int c) {return NULL;}
|
||||
#include <stdarg.h>
|
||||
int vprintf(const char *format, va_list ap) {return 0;}
|
||||
int vsnprintf(char *str, size_t size, const char *format, va_list ap) {return 0;}
|
||||
|
||||
#undef putchar
|
||||
int putchar(int c) {return 0;}
|
||||
int puts(const char *s) {return 0;}
|
||||
|
||||
void _start(void) {main(0, NULL);}
|
||||
66
bare-arm/mpconfigport.h
Normal file
66
bare-arm/mpconfigport.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <stdint.h>
|
||||
|
||||
// options to control how MicroPython is built
|
||||
|
||||
#define MICROPY_QSTR_BYTES_IN_HASH (1)
|
||||
#define MICROPY_ALLOC_PATH_MAX (512)
|
||||
#define MICROPY_EMIT_X64 (0)
|
||||
#define MICROPY_EMIT_THUMB (0)
|
||||
#define MICROPY_EMIT_INLINE_THUMB (0)
|
||||
#define MICROPY_COMP_MODULE_CONST (0)
|
||||
#define MICROPY_COMP_CONST (0)
|
||||
#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (0)
|
||||
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
|
||||
#define MICROPY_MEM_STATS (0)
|
||||
#define MICROPY_DEBUG_PRINTERS (0)
|
||||
#define MICROPY_ENABLE_GC (0)
|
||||
#define MICROPY_HELPER_REPL (0)
|
||||
#define MICROPY_HELPER_LEXER_UNIX (0)
|
||||
#define MICROPY_ENABLE_SOURCE_LINE (0)
|
||||
#define MICROPY_ENABLE_DOC_STRING (0)
|
||||
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
|
||||
#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0)
|
||||
#define MICROPY_PY_ASYNC_AWAIT (0)
|
||||
#define MICROPY_PY_BUILTINS_BYTEARRAY (0)
|
||||
#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
|
||||
#define MICROPY_PY_BUILTINS_ENUMERATE (0)
|
||||
#define MICROPY_PY_BUILTINS_FROZENSET (0)
|
||||
#define MICROPY_PY_BUILTINS_REVERSED (0)
|
||||
#define MICROPY_PY_BUILTINS_SET (0)
|
||||
#define MICROPY_PY_BUILTINS_SLICE (0)
|
||||
#define MICROPY_PY_BUILTINS_PROPERTY (0)
|
||||
#define MICROPY_PY___FILE__ (0)
|
||||
#define MICROPY_PY_GC (0)
|
||||
#define MICROPY_PY_ARRAY (0)
|
||||
#define MICROPY_PY_ATTRTUPLE (0)
|
||||
#define MICROPY_PY_COLLECTIONS (0)
|
||||
#define MICROPY_PY_MATH (0)
|
||||
#define MICROPY_PY_CMATH (0)
|
||||
#define MICROPY_PY_IO (0)
|
||||
#define MICROPY_PY_STRUCT (0)
|
||||
#define MICROPY_PY_SYS (0)
|
||||
#define MICROPY_CPYTHON_COMPAT (0)
|
||||
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
|
||||
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
|
||||
#define MICROPY_USE_INTERNAL_PRINTF (0)
|
||||
|
||||
// type definitions for the specific machine
|
||||
|
||||
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
|
||||
|
||||
#define UINT_FMT "%lu"
|
||||
#define INT_FMT "%ld"
|
||||
|
||||
typedef int32_t mp_int_t; // must be pointer size
|
||||
typedef uint32_t mp_uint_t; // must be pointer size
|
||||
typedef long mp_off_t;
|
||||
|
||||
// dummy print
|
||||
#define MP_PLAT_PRINT_STRN(str, len) (void)0
|
||||
|
||||
// extra built in names to add to the global namespace
|
||||
#define MICROPY_PORT_BUILTINS \
|
||||
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
|
||||
|
||||
// We need to provide a declaration/definition of alloca()
|
||||
#include <alloca.h>
|
||||
1
bare-arm/qstrdefsport.h
Normal file
1
bare-arm/qstrdefsport.h
Normal file
@@ -0,0 +1 @@
|
||||
// qstrs specific to this port
|
||||
63
cc3200/Makefile
Normal file
63
cc3200/Makefile
Normal file
@@ -0,0 +1,63 @@
|
||||
# Select the board to build for: if not given on the command line,
|
||||
# then default to WIPY
|
||||
BOARD ?= WIPY
|
||||
ifeq ($(wildcard boards/$(BOARD)/.),)
|
||||
$(error Invalid BOARD specified)
|
||||
endif
|
||||
|
||||
# Make 'release' the default build type
|
||||
BTYPE ?= release
|
||||
|
||||
# Port for flashing firmware
|
||||
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 ../../localconfig.mk
|
||||
|
||||
CROSS_COMPILE ?= arm-none-eabi-
|
||||
|
||||
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -march=armv7e-m -mabi=aapcs -mcpu=cortex-m4 -msoft-float -mfloat-abi=soft -fsingle-precision-constant -Wdouble-promotion
|
||||
CFLAGS = -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) -Os
|
||||
CFLAGS += -g -ffunction-sections -fdata-sections -fno-common -fsigned-char -mno-unaligned-access
|
||||
CFLAGS += -Iboards/$(BOARD)
|
||||
CFLAGS += $(CFLAGS_MOD)
|
||||
|
||||
LDFLAGS = -Wl,-nostdlib -Wl,--gc-sections -Wl,-Map=$@.map
|
||||
|
||||
FLASH_SIZE_WIPY = 2M
|
||||
FLASH_SIZE_LAUNCHXL = 1M
|
||||
|
||||
ifeq ($(BTARGET), application)
|
||||
# qstr definitions (must come before including py.mk)
|
||||
QSTR_DEFS = qstrdefsport.h $(BUILD)/pins_qstr.h
|
||||
# include MicroPython make definitions
|
||||
include $(TOP)/py/py.mk
|
||||
include application.mk
|
||||
else
|
||||
ifeq ($(BTARGET), bootloader)
|
||||
include bootmgr/bootloader.mk
|
||||
else
|
||||
$(error Invalid BTARGET specified)
|
||||
endif
|
||||
endif
|
||||
|
||||
# always include MicroPython make rules
|
||||
include $(TOP)/py/mkrules.mk
|
||||
|
||||
erase:
|
||||
cc3200tool -p $(PORT) format_flash --size $(FLASH_SIZE_$(BOARD))
|
||||
|
||||
deploy:
|
||||
cc3200tool -p $(PORT) \
|
||||
write_file bootmgr/build/$(BOARD)/$(BTYPE)/bootloader.bin /sys/mcuimg.bin \
|
||||
write_file build/$(BOARD)/$(BTYPE)/mcuimg.bin /sys/factimg.bin
|
||||
|
||||
# Files *.ucf and *ucf.signed.bin come from CC3200SDK-SERVICEPACK
|
||||
# package from http://www.ti.com/tool/cc3200sdk
|
||||
servicepack:
|
||||
cc3200tool -p $(PORT) \
|
||||
write_file --file-size=0x20000 --signature ota_1.0.1.6-2.7.0.0.ucf.signed.bin \
|
||||
ota_1.0.1.6-2.7.0.0.ucf /sys/servicepack.ucf
|
||||
@@ -18,7 +18,7 @@ APP_INC += -Iutil
|
||||
APP_INC += -Ibootmgr
|
||||
APP_INC += -I$(BUILD)
|
||||
APP_INC += -I$(BUILD)/genhdr
|
||||
APP_INC += -I$(TOP)/ports/stm32
|
||||
APP_INC += -I$(TOP)/stmhal
|
||||
|
||||
APP_CPPDEFINES = -Dgcc -DTARGET_IS_CC3200 -DSL_FULL -DUSE_FREERTOS
|
||||
|
||||
@@ -73,11 +73,13 @@ APP_MISC_SRC_C = $(addprefix misc/,\
|
||||
help.c \
|
||||
mpirq.c \
|
||||
mperror.c \
|
||||
mpexception.c \
|
||||
)
|
||||
|
||||
APP_MODS_SRC_C = $(addprefix mods/,\
|
||||
modmachine.c \
|
||||
modnetwork.c \
|
||||
modubinascii.c \
|
||||
moduos.c \
|
||||
modusocket.c \
|
||||
modussl.c \
|
||||
@@ -111,12 +113,12 @@ APP_CC3100_SRC_C = $(addprefix drivers/cc3100/src/,\
|
||||
APP_SL_SRC_C = $(addprefix simplelink/,\
|
||||
oslib/osi_freertos.c \
|
||||
cc_pal.c \
|
||||
)
|
||||
)
|
||||
|
||||
APP_TELNET_SRC_C = $(addprefix telnet/,\
|
||||
telnet.c \
|
||||
)
|
||||
|
||||
|
||||
APP_UTIL_SRC_C = $(addprefix util/,\
|
||||
cryptohash.c \
|
||||
fifo.c \
|
||||
@@ -124,33 +126,31 @@ APP_UTIL_SRC_C = $(addprefix util/,\
|
||||
random.c \
|
||||
socketfifo.c \
|
||||
)
|
||||
|
||||
|
||||
APP_UTIL_SRC_S = $(addprefix util/,\
|
||||
cortex_m3_get_sp.s \
|
||||
gchelper.s \
|
||||
sleeprestore.s \
|
||||
)
|
||||
|
||||
|
||||
APP_MAIN_SRC_C = \
|
||||
main.c \
|
||||
mptask.c \
|
||||
mpthreadport.c \
|
||||
serverstask.c \
|
||||
fatfs_port.c \
|
||||
|
||||
|
||||
APP_LIB_SRC_C = $(addprefix lib/,\
|
||||
oofatfs/ff.c \
|
||||
oofatfs/ffunicode.c \
|
||||
oofatfs/option/unicode.c \
|
||||
libc/string0.c \
|
||||
mp-readline/readline.c \
|
||||
netutils/netutils.c \
|
||||
timeutils/timeutils.c \
|
||||
utils/gchelper_native.c \
|
||||
utils/pyexec.c \
|
||||
utils/interrupt_char.c \
|
||||
utils/sys_stdio_mphal.c \
|
||||
)
|
||||
|
||||
APP_STM_SRC_C = $(addprefix ports/stm32/,\
|
||||
|
||||
APP_STM_SRC_C = $(addprefix stmhal/,\
|
||||
bufhelper.c \
|
||||
irq.c \
|
||||
)
|
||||
@@ -158,7 +158,6 @@ APP_STM_SRC_C = $(addprefix ports/stm32/,\
|
||||
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(APP_FATFS_SRC_C:.c=.o) $(APP_RTOS_SRC_C:.c=.o) $(APP_FTP_SRC_C:.c=.o) $(APP_HAL_SRC_C:.c=.o) $(APP_MISC_SRC_C:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(APP_MODS_SRC_C:.c=.o) $(APP_CC3100_SRC_C:.c=.o) $(APP_SL_SRC_C:.c=.o) $(APP_TELNET_SRC_C:.c=.o) $(APP_UTIL_SRC_C:.c=.o) $(APP_UTIL_SRC_S:.s=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(APP_MAIN_SRC_C:.c=.o) $(APP_LIB_SRC_C:.c=.o) $(APP_STM_SRC_C:.c=.o))
|
||||
OBJ += $(BUILD)/lib/utils/gchelper_m3.o
|
||||
OBJ += $(BUILD)/pins.o
|
||||
|
||||
# List of sources for qstr extraction
|
||||
233
cc3200/boards/make-pins.py
Normal file
233
cc3200/boards/make-pins.py
Normal file
@@ -0,0 +1,233 @@
|
||||
#!/usr/bin/env python
|
||||
"""Generates the pins file for the CC3200."""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import csv
|
||||
|
||||
|
||||
SUPPORTED_AFS = { 'UART': ('TX', 'RX', 'RTS', 'CTS'),
|
||||
'SPI': ('CLK', 'MOSI', 'MISO', 'CS0'),
|
||||
#'I2S': ('CLK', 'FS', 'DAT0', 'DAT1'),
|
||||
'I2C': ('SDA', 'SCL'),
|
||||
'TIM': ('PWM'),
|
||||
'SD': ('CLK', 'CMD', 'DAT0'),
|
||||
'ADC': ('CH0', 'CH1', 'CH2', 'CH3')
|
||||
}
|
||||
|
||||
def parse_port_pin(name_str):
|
||||
"""Parses a string and returns a (port, gpio_bit) tuple."""
|
||||
if len(name_str) < 3:
|
||||
raise ValueError("Expecting pin name to be at least 3 characters")
|
||||
if name_str[:2] != 'GP':
|
||||
raise ValueError("Expecting pin name to start with GP")
|
||||
if not name_str[2:].isdigit():
|
||||
raise ValueError("Expecting numeric GPIO number")
|
||||
port = int(int(name_str[2:]) / 8)
|
||||
gpio_bit = 1 << int(int(name_str[2:]) % 8)
|
||||
return (port, gpio_bit)
|
||||
|
||||
|
||||
class AF:
|
||||
"""Holds the description of an alternate function"""
|
||||
def __init__(self, name, idx, fn, unit, type):
|
||||
self.name = name
|
||||
self.idx = idx
|
||||
if self.idx > 15:
|
||||
self.idx = -1
|
||||
self.fn = fn
|
||||
self.unit = unit
|
||||
self.type = type
|
||||
|
||||
def print(self):
|
||||
print (' AF({:16s}, {:4d}, {:8s}, {:4d}, {:8s}), // {}'.format(self.name, self.idx, self.fn, self.unit, self.type, self.name))
|
||||
|
||||
|
||||
class Pin:
|
||||
"""Holds the information associated with a pin."""
|
||||
def __init__(self, name, port, gpio_bit, pin_num):
|
||||
self.name = name
|
||||
self.port = port
|
||||
self.gpio_bit = gpio_bit
|
||||
self.pin_num = pin_num
|
||||
self.board_pin = False
|
||||
self.afs = []
|
||||
|
||||
def add_af(self, af):
|
||||
self.afs.append(af)
|
||||
|
||||
def print(self):
|
||||
print('// {}'.format(self.name))
|
||||
if len(self.afs):
|
||||
print('const pin_af_t pin_{}_af[] = {{'.format(self.name))
|
||||
for af in self.afs:
|
||||
af.print()
|
||||
print('};')
|
||||
print('pin_obj_t pin_{:4s} = PIN({:6s}, {:1d}, {:3d}, {:2d}, pin_{}_af, {});\n'.format(
|
||||
self.name, self.name, self.port, self.gpio_bit, self.pin_num, self.name, len(self.afs)))
|
||||
else:
|
||||
print('pin_obj_t pin_{:4s} = PIN({:6s}, {:1d}, {:3d}, {:2d}, NULL, 0);\n'.format(
|
||||
self.name, self.name, self.port, self.gpio_bit, self.pin_num))
|
||||
|
||||
def print_header(self, hdr_file):
|
||||
hdr_file.write('extern pin_obj_t pin_{:s};\n'.format(self.name))
|
||||
|
||||
|
||||
class Pins:
|
||||
def __init__(self):
|
||||
self.board_pins = [] # list of pin objects
|
||||
|
||||
def find_pin(self, port, gpio_bit):
|
||||
for pin in self.board_pins:
|
||||
if pin.port == port and pin.gpio_bit == gpio_bit:
|
||||
return pin
|
||||
|
||||
def find_pin_by_num(self, pin_num):
|
||||
for pin in self.board_pins:
|
||||
if pin.pin_num == pin_num:
|
||||
return pin
|
||||
|
||||
def find_pin_by_name(self, name):
|
||||
for pin in self.board_pins:
|
||||
if pin.name == name:
|
||||
return pin
|
||||
|
||||
def parse_af_file(self, filename, pin_col, pinname_col, af_start_col):
|
||||
with open(filename, 'r') as csvfile:
|
||||
rows = csv.reader(csvfile)
|
||||
for row in rows:
|
||||
try:
|
||||
(port_num, gpio_bit) = parse_port_pin(row[pinname_col])
|
||||
except:
|
||||
continue
|
||||
if not row[pin_col].isdigit():
|
||||
raise ValueError("Invalid pin number {:s} in row {:s}".format(row[pin_col]), row)
|
||||
# Pin numbers must start from 0 when used with the TI API
|
||||
pin_num = int(row[pin_col]) - 1;
|
||||
pin = Pin(row[pinname_col], port_num, gpio_bit, pin_num)
|
||||
self.board_pins.append(pin)
|
||||
af_idx = 0
|
||||
for af in row[af_start_col:]:
|
||||
af_splitted = af.split('_')
|
||||
fn_name = af_splitted[0].rstrip('0123456789')
|
||||
if fn_name in SUPPORTED_AFS:
|
||||
type_name = af_splitted[1]
|
||||
if type_name in SUPPORTED_AFS[fn_name]:
|
||||
unit_idx = af_splitted[0][-1]
|
||||
pin.add_af(AF(af, af_idx, fn_name, int(unit_idx), type_name))
|
||||
af_idx += 1
|
||||
|
||||
def parse_board_file(self, filename, cpu_pin_col):
|
||||
with open(filename, 'r') as csvfile:
|
||||
rows = csv.reader(csvfile)
|
||||
for row in rows:
|
||||
# Pin numbers must start from 0 when used with the TI API
|
||||
if row[cpu_pin_col].isdigit():
|
||||
pin = self.find_pin_by_num(int(row[cpu_pin_col]) - 1)
|
||||
else:
|
||||
pin = self.find_pin_by_name(row[cpu_pin_col])
|
||||
if pin:
|
||||
pin.board_pin = True
|
||||
|
||||
def print_named(self, label, pins):
|
||||
print('')
|
||||
print('STATIC const mp_rom_map_elem_t pin_{:s}_pins_locals_dict_table[] = {{'.format(label))
|
||||
for pin in pins:
|
||||
if pin.board_pin:
|
||||
print(' {{ MP_ROM_QSTR(MP_QSTR_{:6s}), MP_ROM_PTR(&pin_{:6s}) }},'.format(pin.name, pin.name))
|
||||
print('};')
|
||||
print('MP_DEFINE_CONST_DICT(pin_{:s}_pins_locals_dict, pin_{:s}_pins_locals_dict_table);'.format(label, label));
|
||||
|
||||
def print(self):
|
||||
for pin in self.board_pins:
|
||||
if pin.board_pin:
|
||||
pin.print()
|
||||
self.print_named('board', self.board_pins)
|
||||
print('')
|
||||
|
||||
def print_header(self, hdr_filename):
|
||||
with open(hdr_filename, 'wt') as hdr_file:
|
||||
for pin in self.board_pins:
|
||||
if pin.board_pin:
|
||||
pin.print_header(hdr_file)
|
||||
|
||||
def print_qstr(self, qstr_filename):
|
||||
with open(qstr_filename, 'wt') as qstr_file:
|
||||
pin_qstr_set = set([])
|
||||
af_qstr_set = set([])
|
||||
for pin in self.board_pins:
|
||||
if pin.board_pin:
|
||||
pin_qstr_set |= set([pin.name])
|
||||
for af in pin.afs:
|
||||
af_qstr_set |= set([af.name])
|
||||
print('// Board pins', file=qstr_file)
|
||||
for qstr in sorted(pin_qstr_set):
|
||||
print('Q({})'.format(qstr), file=qstr_file)
|
||||
print('\n// Pin AFs', file=qstr_file)
|
||||
for qstr in sorted(af_qstr_set):
|
||||
print('Q({})'.format(qstr), file=qstr_file)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="make-pins.py",
|
||||
usage="%(prog)s [options] [command]",
|
||||
description="Generate board specific pin file"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-a", "--af",
|
||||
dest="af_filename",
|
||||
help="Specifies the alternate function file for the chip",
|
||||
default="cc3200_af.csv"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-b", "--board",
|
||||
dest="board_filename",
|
||||
help="Specifies the board file",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p", "--prefix",
|
||||
dest="prefix_filename",
|
||||
help="Specifies beginning portion of generated pins file",
|
||||
default="cc3200_prefix.c"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-q", "--qstr",
|
||||
dest="qstr_filename",
|
||||
help="Specifies name of generated qstr header file",
|
||||
default="build/pins_qstr.h"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-r", "--hdr",
|
||||
dest="hdr_filename",
|
||||
help="Specifies name of generated pin header file",
|
||||
default="build/pins.h"
|
||||
)
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
pins = Pins()
|
||||
|
||||
print('// This file was automatically generated by make-pins.py')
|
||||
print('//')
|
||||
if args.af_filename:
|
||||
print('// --af {:s}'.format(args.af_filename))
|
||||
pins.parse_af_file(args.af_filename, 0, 1, 3)
|
||||
|
||||
if args.board_filename:
|
||||
print('// --board {:s}'.format(args.board_filename))
|
||||
pins.parse_board_file(args.board_filename, 1)
|
||||
|
||||
if args.prefix_filename:
|
||||
print('// --prefix {:s}'.format(args.prefix_filename))
|
||||
print('')
|
||||
with open(args.prefix_filename, 'r') as prefix_file:
|
||||
print(prefix_file.read())
|
||||
pins.print()
|
||||
pins.print_qstr(args.qstr_filename)
|
||||
pins.print_header(args.hdr_filename)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -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)/ports/stm32/%.o: CFLAGS += -Os
|
||||
$(BUILD)/stmhal/%.o: CFLAGS += -Os
|
||||
else
|
||||
$(error Invalid BTYPE specified)
|
||||
endif
|
||||
74
cc3200/fatfs_port.c
Normal file
74
cc3200/fatfs_port.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013-2017 Damien P. George
|
||||
* Parts of this file are (C)ChaN, 2014, from FatFs option/syscall.c
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "py/runtime.h"
|
||||
#include "lib/oofatfs/ff.h"
|
||||
#include "lib/timeutils/timeutils.h"
|
||||
#include "mods/pybrtc.h"
|
||||
|
||||
#if _FS_REENTRANT
|
||||
// Create a Synchronization Object
|
||||
// This function is called in f_mount() function to create a new
|
||||
// synchronization object, such as semaphore and mutex.
|
||||
// A return of 0 indicates failure, and then f_mount() fails with FR_INT_ERR.
|
||||
int ff_cre_syncobj(FATFS *fatfs, _SYNC_t *sobj) {
|
||||
vSemaphoreCreateBinary((*sobj));
|
||||
return (int)(*sobj != NULL);
|
||||
}
|
||||
|
||||
// Delete a Synchronization Object
|
||||
// This function is called in f_mount() function to delete a synchronization
|
||||
// object that created with ff_cre_syncobj function.
|
||||
// A return of 0 indicates failure, and then f_mount() fails with FR_INT_ERR.
|
||||
int ff_del_syncobj(_SYNC_t sobj) {
|
||||
vSemaphoreDelete(sobj);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Request Grant to Access the Volume
|
||||
// This function is called on entering file functions to lock the volume.
|
||||
// When a 0 is returned, the file function fails with FR_TIMEOUT.
|
||||
int ff_req_grant(_SYNC_t sobj) {
|
||||
return (int)(xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE);
|
||||
}
|
||||
|
||||
// Release Grant to Access the Volume
|
||||
// This function is called on leaving file functions to unlock the volume.
|
||||
void ff_rel_grant(_SYNC_t sobj) {
|
||||
xSemaphoreGive(sobj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
DWORD get_fattime(void) {
|
||||
timeutils_struct_time_t tm;
|
||||
timeutils_seconds_since_2000_to_struct_time(pyb_rtc_get_seconds(), &tm);
|
||||
|
||||
return ((tm.tm_year - 1980) << 25) | ((tm.tm_mon) << 21) |
|
||||
((tm.tm_mday) << 16) | ((tm.tm_hour) << 11) |
|
||||
((tm.tm_min) << 5) | (tm.tm_sec >> 1);
|
||||
}
|
||||
@@ -27,7 +27,8 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "py/runtime.h"
|
||||
#include "py/mpstate.h"
|
||||
#include "py/obj.h"
|
||||
#include "lib/timeutils/timeutils.h"
|
||||
#include "lib/oofatfs/ff.h"
|
||||
#include "extmod/vfs.h"
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include "py/mpstate.h"
|
||||
#include "py/mphal.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/objstr.h"
|
||||
@@ -45,6 +46,7 @@
|
||||
#include "systick.h"
|
||||
#include "prcm.h"
|
||||
#include "pin.h"
|
||||
#include "mpexception.h"
|
||||
#include "telnet.h"
|
||||
#include "pybuart.h"
|
||||
#include "utils.h"
|
||||
@@ -141,13 +143,17 @@ void mp_hal_delay_ms(mp_uint_t delay) {
|
||||
}
|
||||
}
|
||||
|
||||
void mp_hal_set_interrupt_char (int c) {
|
||||
mpexception_set_interrupt_char (c);
|
||||
}
|
||||
|
||||
void mp_hal_stdout_tx_str(const char *str) {
|
||||
mp_hal_stdout_tx_strn(str, strlen(str));
|
||||
}
|
||||
|
||||
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
|
||||
if (MP_STATE_PORT(os_term_dup_obj)) {
|
||||
if (mp_obj_is_type(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
|
||||
if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
|
||||
uart_tx_strn(MP_STATE_PORT(os_term_dup_obj)->stream_o, str, len);
|
||||
} else {
|
||||
MP_STATE_PORT(os_term_dup_obj)->write[2] = mp_obj_new_str_of_type(&mp_type_str, (const byte *)str, len);
|
||||
@@ -183,7 +189,7 @@ int mp_hal_stdin_rx_chr(void) {
|
||||
if (telnet_rx_any()) {
|
||||
return telnet_rx_char();
|
||||
} else if (MP_STATE_PORT(os_term_dup_obj)) { // then the stdio_dup
|
||||
if (mp_obj_is_type(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
|
||||
if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
|
||||
if (uart_rx_any(MP_STATE_PORT(os_term_dup_obj)->stream_o)) {
|
||||
return uart_rx_char(MP_STATE_PORT(os_term_dup_obj)->stream_o);
|
||||
}
|
||||
@@ -64,6 +64,5 @@ extern void HAL_SystemDeInit (void);
|
||||
extern void HAL_IncrementTick(void);
|
||||
extern void mp_hal_set_interrupt_char (int c);
|
||||
|
||||
#define mp_hal_stdio_poll(poll_flags) (0) // not implemented
|
||||
#define mp_hal_delay_us(usec) UtilsDelay(UTILS_DELAY_US_TO_COUNT(usec))
|
||||
#define mp_hal_ticks_cpu() (SysTickPeriodGet() - SysTickValueGet())
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user