1. 29 Aug, 2020 3 commits
  2. 28 Aug, 2020 1 commit
  3. 27 Aug, 2020 3 commits
    • Michael Buesch's avatar
      extmod/machine_i2c: Fix buffer overrun if 'addrsize' is bigger than 32. · cef678b2
      Michael Buesch authored
      The memory operation functions read_mem() and write_mem() create a
      temporary buffer on the local C stack for the address bytes with the size
      of 4 bytes.  This buffer is filled in a loop from the user supplied address
      and address length.  If the user supplied 'addrsize' is bigger than 32, the
      local buffer is overrun.
      
      Fix this by raising an exception for invalid 'addrsize' values.
      Signed-off-by: default avatarMichael Buesch <m@bues.ch>
      cef678b2
    • stijn's avatar
      tests/run-tests: Make test output directory configurable. · 0c3f9d58
      stijn authored
      A configurable result directory is advantageous because it enables
      using a dedicated location, eventually outside of the source tree,
      instead of forcing the output files into a fixed directory which might
      also contain other files already. For that reason the default output
      directory also has been changed to tests/results/.
      0c3f9d58
    • stijn's avatar
      tests/run-tests: Use absolute paths where possible. · 405893af
      stijn authored
      Replace some usages of paths relative to the current working directory
      with absolute paths relative to the tests directory.
      
      Fixes and resulting changes:
      - default values of MICROPYTHON and MPYCROSS are absolute paths and
        always correct
      - likewise, the correct full paths for tools and extmod directories
        are appended to sys.path
      - printing/cleaning failures works properly since it expects the .exp
        and .out files in the tests directory which is also where they
        are written to now, plus no more need for changing directories
      
      This fixes #5872 and allows running custom tests which use run-tests
      without having to cd to the tests directory first, and the test output
      still is in the tests/ directory instead of the current working directory.
      
      Discovery of tests and all skip test logic based on paths relative to
      the current working directory remains unchanged which essentially means
      that for running most of MicroPython's own tests, run-tests must still
      be ran from within it's directory, so document that.
      405893af
  4. 26 Aug, 2020 5 commits
  5. 25 Aug, 2020 1 commit
    • Damien George's avatar
      extmod/vfs_lfs: Add mtime support to littlefs files. · 2acc0878
      Damien George authored
      This commit adds support for modification time of files on littlefs v2
      filesystems, using file attributes.  For some background see issue #6114.
      
      Features/properties of this implementation:
      - Only supported on littlefs2 (not littlefs1).
      - Uses littlefs2's general file attributes to store the timestamp.
      - The timestamp is 64-bits and stores nanoseconds since 1970/1/1 (if the
        range to the year 2554 is not enough then additional bits can be added to
        this timestamp by adding another file attribute).
      - mtime is enabled by default but can be disabled in the constructor, eg:
        uos.mount(uos.VfsLfs2(bdev, mtime=False), '/flash')
      - It's fully backwards compatible, existing littlefs2 filesystems will work
        without reformatting and timestamps will be added transparently to
        existing files (once they are opened for writing).
      - Files without timestamps will open correctly, and stat will just return 0
        for their timestamp.
      - mtime can be disabled or enabled each mount time and timestamps will only
        be updated if mtime is enabled (otherwise they will be untouched).
      Signed-off-by: default avatarDamien George <damien@micropython.org>
      2acc0878
  6. 22 Aug, 2020 7 commits
  7. 21 Aug, 2020 6 commits
    • Martin Milata's avatar
    • Michael Buesch's avatar
      tools/pyboard.py: Replace eval() of received data with alternative. · 60cf2c09
      Michael Buesch authored
      Prior to this commit, pyboard.py used eval() to "parse" file data received
      from the board.  Using eval() on received data from a device is dangerous,
      because a malicious device may inject arbitrary code execution on the PC
      that is doing the operation.
      
      Consider the following scenario:
      
      Eve may write a malicious script to Bob's board in his absence.  On return
      Bob notices that something is wrong with the board, because it doesn't work
      as expected anymore.  He wants to read out boot.py (or any other file) to
      see what is wrong.  What he gets is a remote code execution on his PC.
      
      Proof of concept:
      
      Eve:
      
        $ cat boot.py
        _print = print
        print = lambda *x, **y: _print("os.system('ls /; echo Pwned!')", end="\r\n\x04")
        $ ./pyboard.py -f cp boot.py :
        cp boot.py :boot.py
      
      Bob:
      
        $ ./pyboard.py -f cp :boot.py /tmp/foo
        cp :boot.py /tmp/foo
        bin   chroot  dev  home  lib32  media  opt   root  sbin  sys  usr
        boot  config  etc  lib   lib64  mnt    proc  run   srv   tmp  var
        Pwned!
      
      There's also the possibility that the device is malfunctioning and sends
      random and possibly dangerous data back to the PC, to be eval'd.
      
      Fix this problem by using ast.literal_eval() to parse the received bytes,
      instead of eval().
      Signed-off-by: default avatarMichael Buesch <m@bues.ch>
      60cf2c09
    • Dave Hylands's avatar
      stm32/pin_defs_stm32: Fix pin printing to show IN mode correctly. · 8727c4e2
      Dave Hylands authored
      Prior to this commit, if you configure a pin as an output type (I2C in this
      example) and then later configure it back as an input, then it will report
      the type incorrectly.  Example:
      
          >>> import machine
          >>> b6 = machine.Pin('B6')
          >>> b6
          Pin(Pin.cpu.B6, mode=Pin.IN)
          >>> machine.I2C(1)
          I2C(1, scl=B6, sda=B7, freq=420000)
          >>> b6
          Pin(Pin.cpu.B6, mode=Pin.ALT_OPEN_DRAIN, pull=Pin.PULL_UP, af=Pin.AF4_I2C1)
          >>> b6.init(machine.Pin.IN)
          >>> b6
          Pin(Pin.cpu.B6, mode=Pin.ALT_OPEN_DRAIN, af=Pin.AF4_I2C1)
      
      With this commit the last print now works:
      
          >>> b6
          Pin(Pin.cpu.B6, mode=Pin.IN)
      8727c4e2
    • Zenix27's avatar
      docs: Change `\*` to `*` in argument lists. · e76c7466
      Zenix27 authored
      Latest versions of Sphinx (at least 3.1.0) do not need the `*` escaped and
      will render the `\` in the output if it is there, so remove it.
      
      Fixes issue #6209.
      e76c7466
    • Maureen Helm's avatar
      travis: Add zephyr build to CI. · 17689a71
      Maureen Helm authored
      Adds a job to build the zephyr port in CI using the same docker container
      that the zephyr project uses for its own CI.
      
      Always make clean zephyr builds to ensure we don't just rebuild C code, but
      we also rebuild Kconfig and dts.  This is required when switching between
      boards, which have different Kconfigs and device trees.
      
      Uses the tagged zephyr 2.3.0 release.
      Signed-off-by: default avatarMaureen Helm <maureen.helm@nxp.com>
      17689a71
    • Maureen Helm's avatar
      zephyr: Include storage/flash_map.h unconditionally. · ac94e06f
      Maureen Helm authored
      Include storage/flash_map.h unconditionally so we always have access to the
      FLASH_AREA_LABEL_EXISTS macro, even if CONFIG_FLASH_MAP is not defined.
      
      This fixes a build error for the qemu_x86 board:
      
      main.c:108:63: error: missing binary operator before token "("
        108 |     #elif defined(CONFIG_FLASH_MAP) && FLASH_AREA_LABEL_EXISTS(storage)
            |                                                               ^
      ../../py/mkrules.mk:88: recipe for target 'build/genhdr/qstr.i.last' failed
      Signed-off-by: default avatarMaureen Helm <maureen.helm@nxp.com>
      ac94e06f
  8. 12 Aug, 2020 1 commit
    • Damien George's avatar
      extmod/vfs_reader: Fix mp_reader_new_file to open file in "rb" mode. · 60f5b941
      Damien George authored
      mp_reader_new_file() is used to read in files for importing, either .py or
      .mpy files, for the lexer and persistent code loader respectively.  In both
      cases the file should be opened in raw bytes mode: the lexer handles
      unicode characters itself, and .mpy files contain 8-bit bytes by nature.
      
      Before this commit importing was working correctly because, although the
      file was opened in text mode, all native filesystem implementations (POSIX,
      FAT, LFS) would access the file in raw bytes mode via mp_stream_rw()
      calling mp_stream_p_t.read().  So it was only an issue for non-native
      filesystems, such as those implemented in Python.  For Python-based
      filesystem implementations, a call to mp_stream_rw() would go via IOBase
      and then to readinto() at the Python level, and readinto() is only defined
      on files opened in raw bytes mode.
      Signed-off-by: default avatarDamien George <damien@micropython.org>
      60f5b941
  9. 08 Aug, 2020 1 commit
  10. 02 Aug, 2020 1 commit
    • Damien George's avatar
      py/persistentcode: Maintain root ptr list of imported native .mpy code. · 9883d8e8
      Damien George authored
      On ports where normal heap memory can contain executable code (eg ARM-based
      ports such as stm32), native code loaded from an .mpy file may be reclaimed
      by the GC because there's no reference to the very start of the native
      machine code block that is reachable from root pointers (only pointers to
      internal parts of the machine code block are reachable, but that doesn't
      help the GC find the memory).
      
      This commit fixes this issue by maintaining an explicit list of root
      pointers pointing to native code that is loaded from an .mpy file.  This
      is not needed for all ports so is selectable by the new configuration
      option MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE.  It's enabled by default
      if a port does not specify any special functions to allocate or commit
      executable memory.
      
      A test is included to test that native code loaded from an .mpy file does
      not get reclaimed by the GC.
      
      Fixes #6045.
      Signed-off-by: default avatarDamien George <damien@micropython.org>
      9883d8e8
  11. 26 Jul, 2020 3 commits
  12. 25 Jul, 2020 1 commit
  13. 24 Jul, 2020 6 commits
  14. 22 Jul, 2020 1 commit
    • Glenn Ruben Bakke's avatar
      nrf: Enable more features for all targets. · caaaa2b1
      Glenn Ruben Bakke authored
      Enabling the following features for all targets, except for nrf51
      targets compiled to be used with SoftDevice:
      
      - MICROPY_PY_ARRAY_SLICE_ASSIGN
      - MICROPY_PY_SYS_STDFILES
      - MICROPY_PY_UBINASCII
      caaaa2b1