1. 18 Jan, 2021 3 commits
    • Damien George's avatar
      stm32/mboot: Add support for signed and encrypted firmware updates. · c6f33427
      Damien George authored
      This commit adds support to stm32's mboot for signe, encrypted and
      compressed DFU updates.  It is based on inital work done by Andrew Leech.
      
      The feature is enabled by setting MBOOT_ENABLE_PACKING to 1 in the board's
      mpconfigboard.mk file, and by providing a header file in the board folder
      (usually called mboot_keys.h) with a set of signing and encryption keys
      (which can be generated by mboot_pack_dfu.py).  The signing and encryption
      is provided by libhydrogen.  Compression is provided by uzlib.  Enabling
      packing costs about 3k of flash.
      
      The included mboot_pack_dfu.py script converts a .dfu file to a .pack.dfu
      file which can be subsequently deployed to a board with mboot in packing
      mode.  This .pack.dfu file is created as follows:
      - the firmware from the original .dfu is split into chunks (so the
        decryption can fit in RAM)
      - each chunk is compressed, encrypted, a header added, then signed
      - a special final chunk is added with a signature of the entire firmware
      - all chunks are concatenated to make the final .pack.dfu file
      
      The .pack.dfu file can be deployed over USB or from the internal filesystem
      on the device (if MBOOT_FSLOAD is enabled).
      
      See #5267 and #5309 for additional discussion.
      Signed-off-by: default avatarDamien George <damien@micropython.org>
      c6f33427
    • Damien George's avatar
      stm32/mboot/gzstream: Fix lost data decompressing final part of file. · 09e67de3
      Damien George authored
      Prior to this fix, the final piece of data in a compressed file may have
      been lost when decompressing.
      Signed-off-by: default avatarDamien George <damien@micropython.org>
      09e67de3
    • Damien George's avatar
      lib/libhydrogen: Add new libhydrogen submodule. · 0ce69486
      Damien George authored
      This library is a small and easy-to-use cryptographic library which is well
      suited to embedded systems.
      Signed-off-by: default avatarDamien George <damien@micropython.org>
      0ce69486
  2. 22 Dec, 2020 2 commits
  3. 18 Dec, 2020 7 commits
  4. 17 Dec, 2020 5 commits
  5. 14 Dec, 2020 6 commits
  6. 10 Dec, 2020 2 commits
  7. 09 Dec, 2020 3 commits
  8. 08 Dec, 2020 3 commits
  9. 07 Dec, 2020 9 commits
    • Glenn Ruben Bakke's avatar
      nrf: Change selected boards to utilize pre-flashed bootloader. · d0b8554d
      Glenn Ruben Bakke authored
      The nrf52840-mdk-usb-dongle and pca10050 comes with a pre-flashed
      bootloader (OpenBootloader).
      
      This commit updates the boards "mpconfigboard.mk" to use DFU as
      default flashing method and set the corresponding BOOTLOADER
      settings such that nrf52840_open_bootloader_1.2.x.ld linker
      script is used.
      
      The default DFU flashing method can be disabled by issuing "DFU=0"
      when invoking make. This will lead to "segger" being used as default
      flashing tool. When using "DFU=0", the linker scripts will not
      compensate for any MBR and Bootloader region being present, and might
      overwrite them if they were present.
      
      The commit also removes the custom linker script specific to
      nrf52840-mdk-usb-dongle as it now points to a generic.
      
      Updated nrf52840-mdk-usb-dongle's README.md to be more clear on
      how to deploy the built firmware.
      
      The port README.md has also been updated. In the list of target
      boards a new column has been added to indicate which bootloader
      is present on the target board. And for consistency, changed all
      examples in the README.md to use "deploy" instead of "flash".
      d0b8554d
    • Glenn Ruben Bakke's avatar
    • Glenn Ruben Bakke's avatar
      nrf/Makefile: Add support for flashing with nrfutil. · 634f6df3
      Glenn Ruben Bakke authored
      An additional Makefile parameter NRFUTIL_PORT can be set in order
      to define the serial port to used for the DFU (Default: /dev/ttyACM0).
      
      The "nrfutil" that is used as flasher towards OpenBootloader is
      available for installation through Python "pip".
      
      In case of SD=s140, SoftDevice ID 0xB6 is passed to nrfutil's package
      generation which corresponds to SoftDevice s140 v6.1.1.
      634f6df3
    • Glenn Ruben Bakke's avatar
      nrf/Makefile: Add bootloader specific section. · 718397a3
      Glenn Ruben Bakke authored
      Add the option for "mpconfigboard.mk" to define whether the
      board hosts a bootloader or not. The BOOTLOADER make variable
      must be set to the name of the bootloader.
      
      When the BOOTLOADER name is set it is also required to supply
      the BOOTLOADER_VERSION_MAJOR and the BOOTLOADER_VERSION_MINOR
      from the "mpconfigboards.mk". These will be used to resolve which
      bootloader linker script that should be passed to the linker.
      
      The BOOTLOADER section also supplies the C-compiler with
      BOOTLOADER_<bootloader name>=<version major><version minor>
      as a compiler define. This is for future use in case a bootloader
      needs to do modification to the startup files or similar (like
      setting the VTOR specific to a version of a bootloader).
      718397a3
    • Glenn Ruben Bakke's avatar
      nrf/boards: Update memory.ld to include bootloader offsets. · 24896886
      Glenn Ruben Bakke authored
      Adding variables that can be set from other linker scripts:
      
      - _bootloader_head_size:
          Bootloader flash offset in front of the application.
      
      - _bootloader_tail_size:
          Bootloader offset from the tail of the flash.
          In case the bootloader is located at the end.
      
      - _bootloader_head_ram_size:
          Bootloader RAM usage in front of the application.
      
      Updated calculations of application flash and RAM.
      24896886
    • Joris Peeraer's avatar
      py/mpprint: Fix length calculation for strings with precision-modifier. · 5020b14d
      Joris Peeraer authored
      Two issues are tackled:
      
      1. The calculation of the correct length to print is fixed to treat the
         precision as a maximum length instead as the exact length.
         This is done for both qstr (%q) and for regular str (%s).
      
      2. Fix the incorrect use of mp_printf("%.*s") to mp_print_strn().
      
         Because of the fix of above issue, some testcases that would print
         an embedded null-byte (^@ in test-output) would now fail.
         The bug here is that "%s" was used to print null-bytes. Instead,
         mp_print_strn is used to make sure all bytes are outputted and the
         exact length is respected.
      
      Test-cases are added for both %s and %q with a combination of precision
      and padding specifiers.
      5020b14d
    • Jonathan Bruchim's avatar
      zephyr: Guard I2C code with appropriate ifdef config. · dde0735a
      Jonathan Bruchim authored
      To reduce binary code size when not using I2C.
      Signed-off-by: default avatarJonathan Bruchim <yonbruchim@gmail.com>
      dde0735a
    • Maureen Helm's avatar
      zephyr: Replace broken shell_net_iface() with more general shell_exec(). · 92a5ee6a
      Maureen Helm authored
      The zephyr function net_shell_cmd_iface() was removed in zephyr v1.14.0,
      therefore the MicroPython zephyr port did not build with newer zephyr
      versions when CONFIG_NET_SHELL=y. Replace with a more general
      shell_exec() function that can execute any zephyr shell command. For
      example:
      
      >>> zephyr.shell_exec("net")
      
      Subcommands:
        allocs     :Print network memory allocations.
        arp        :Print information about IPv4 ARP cache.
        conn       :Print information about network connections.
        dns        :Show how DNS is configured.
        events     :Monitor network management events.
        gptp       :Print information about gPTP support.
        iface      :Print information about network interfaces.
        ipv6       :Print information about IPv6 specific information and
                    configuration.
        mem        :Print information about network memory usage.
        nbr        :Print neighbor information.
        ping       :Ping a network host.
        pkt        :net_pkt information.
        ppp        :PPP information.
        resume     :Resume a network interface
        route      :Show network route.
        stacks     :Show network stacks information.
        stats      :Show network statistics.
        suspend    :Suspend a network interface
        tcp        :Connect/send/close TCP connection.
        vlan       :Show VLAN information.
        websocket  :Print information about WebSocket connections.
      
      >>> zephyr.shell_exec("kernel")
      
      kernel - Kernel commands
      Subcommands:
        cycles   :Kernel cycles.
        reboot   :Reboot.
        stacks   :List threads stack usage.
        threads  :List kernel threads.
        uptime   :Kernel uptime.
        version  :Kernel version.
      Signed-off-by: default avatarMaureen Helm <maureen.helm@nxp.com>
      92a5ee6a
    • Damien George's avatar
      stm32/Makefile: Change -O0 to -Og for DEBUG=1 builds. · cb1bb759
      Damien George authored
      The -Og optimisation level produces a more realistic build, gives a better
      debugging experience, and generates smaller code than -O0, allowing debug
      builds to fit in flash.
      
      This commit also assigns variables in can.c to prevent warnings when -Og is
      used, and builds a board in CI with DEBUG=1 enabled.
      Signed-off-by: default avatarDamien George <damien@micropython.org>
      cb1bb759