Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Dec 26, 2023
  2. Dec 22, 2023
  3. Dec 21, 2023
    • Damien George's avatar
    • Nicko van Someren's avatar
      rp2/rp2_dma: Introduce a new rp2.DMA class for control over DMA xfers. · cfc212b1
      Nicko van Someren authored
      
      This commit implements fairly complete support for the DMA controller in
      the rp2 series of microcontrollers.  It provides a class for accessing the
      DMA channels through a high-level, Pythonic interface, and functions for
      setting and manipulating the DMA channel configurations.
      
      Creating an instance of the rp2.DMA class claims one of the processor's DMA
      channels.  A sensible, per-channel default value for the ctrl register can
      be fetched from the DMA.pack_ctrl() function, and the components of this
      register can be set via keyword arguments to pack_ctrl().
      
      The read, write, count and ctrl attributes of the DMA class provide
      read/write access to the respective registers of the DMA controller.  The
      config() method allows any or all of these values to be set simultaneously
      and adds a trigger keyword argument to allow the setup to immediately be
      triggered.  The read and write attributes (or keywords in config()) accept
      either actual addresses or any object that supports the buffer interface.
      The active() method provides read/write control of the channel's activity,
      allowing the user to start and stop the channel and test if it is running.
      
      Standard MicroPython interrupt handlers are supported through the irq()
      method and the channel can be released either by deleting it and allowing
      it to be garbage-collected or with the explicit close() method.
      
      Direct, unfettered access to the DMA controllers registers is provided
      through a proxy memoryview() object returned by the DMA.registers attribute
      that maps directly onto the memory-mapped registers.  This is necessary for
      more fine-grained control and is helpful for allowing chaining of DMA
      channels.
      
      As a simple example, using DMA to do a fast memory copy just needs:
      
          src = bytearray(32*1024)
          dest = bytearray(32*1024)
          dma = rp2.DMA()
          dma.config(read=src, write=dest, count=len(src) // 4,
              ctrl=dma.pack_ctrl(), trigger=True)
      
          # Wait for completion
          while dma.active():
              pass
      
      This API aims to strike a balance between simplicity and comprehensiveness.
      
      Signed-off-by: default avatarNicko van Someren <nicko@nicko.org>
      Signed-off-by: default avatarDamien George <damien@micropython.org>
      cfc212b1
    • Sebastian Romero's avatar
      nrf/main: Add /flash and /flash/lib to sys.path. · e4d3ab33
      Sebastian Romero authored
      
      This allows to follow good practice and have libraries live in the lib
      folder which means they will be found by the runtime without adding this
      path manually at runtime.
      
      Signed-off-by: default avatarSebastian Romero <s.romero@arduino.cc>
      e4d3ab33
    • Peter Züger's avatar
      py/mkrules.mk: Fix dependency file generation for compiler wrappers. · d69e69ad
      Peter Züger authored
      When compiling with distcc, it does not understand the -MD flag on its own.
      This fixes the interaction by explicitly adding the -MF option.
      
      The error in distcc is described here under "Problems with gcc -MD":
      https://www.distcc.org/faq.html
      
      
      
      Signed-off-by: default avatarPeter Züger <zueger.peter@icloud.com>
      d69e69ad
    • Peter Züger's avatar
      extmod/vfs_lfs: Fix lfs cache_size calculation. · ce42c9ee
      Peter Züger authored
      
      The calculation of the lfs2 cache_size was incorrect, the maximum allowed
      size is block_size.
      
      The cache size must be: "a multiple of the read and program sizes, and a
      factor of the block size".
      
      Signed-off-by: default avatarPeter Züger <zueger.peter@icloud.com>
      ce42c9ee
    • Maarten van der Schrieck's avatar
      ports: Fix sys.stdout.buffer.write() return value. · 3bca93b2
      Maarten van der Schrieck authored
      
      MicroPython code may rely on the return value of sys.stdout.buffer.write()
      to reflect the number of bytes actually written. While in most scenarios a
      write() operation is successful, there are cases where it fails, leading to
      data loss. This problem arises because, currently, write() merely returns
      the number of bytes it was supposed to write, without indication of
      failure.
      
      One scenario where write() might fail, is where USB is used and the
      receiving end doesn't read quickly enough to empty the receive buffer. In
      that case, write() on the MicroPython side can timeout, resulting in the
      loss of data without any indication, a behavior observed notably in
      communication between a Pi Pico as a client and a Linux host using the ACM
      driver.
      
      A complex issue arises with mp_hal_stdout_tx_strn() when it involves
      multiple outputs, such as USB, dupterm and hardware UART. The challenge is
      in handling cases where writing to one output is successful, but another
      fails, either fully or partially. This patch implements the following
      solution:
      
      mp_hal_stdout_tx_strn() attempts to write len bytes to all of the possible
      destinations for that data, and returns the minimum successful write
      length.
      
      The implementation of this is complicated by several factors:
      - multiple outputs may be enabled or disabled at compiled time
      - multiple outputs may be enabled or disabled at runtime
      - mp_os_dupterm_tx_strn() is one such output, optionally containing
        multiple additional outputs
      - each of these outputs may or may not be able to report success
      - each of these outputs may or may not be able to report partial writes
      
      As a result, there's no single strategy that fits all ports, necessitating
      unique logic for each instance of mp_hal_stdout_tx_strn().
      
      Note that addressing sys.stdout.write() is more complex due to its data
      modification process ("cooked" output), and it remains unchanged in this
      patch. Developers who are concerned about accurate return values from
      write operations should use sys.stdout.buffer.write().
      
      This patch might disrupt some existing code, but it's also expected to
      resolve issues, considering that the peculiar return value behavior of
      sys.stdout.buffer.write() is not well-documented and likely not widely
      known. Therefore, it's improbable that much existing code relies on the
      previous behavior.
      
      Signed-off-by: default avatarMaarten van der Schrieck <maarten@thingsconnected.nl>
      3bca93b2
    • Maarten van der Schrieck's avatar
      extmod/os_dupterm: Let mp_os_dupterm_tx_strn() return num bytes written. · 91ee8ac8
      Maarten van der Schrieck authored
      
      In case of multiple outputs, the minimum successful write length is
      returned.  In line with this, in case any output has a write error, zero is
      returned.
      
      In case of no outputs, -1 is returned.
      
      The return value can be used to assess whether writes were attempted, and
      if so, whether they succeeded.
      
      Signed-off-by: default avatarMaarten van der Schrieck <maarten@thingsconnected.nl>
      91ee8ac8
  4. Dec 20, 2023
  5. Dec 19, 2023
  6. Dec 18, 2023
  7. Dec 17, 2023
  8. Dec 15, 2023
  9. Dec 14, 2023
  10. Dec 13, 2023
  11. Dec 12, 2023