forked from Neutree/micropython
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mbedtls support #93
Open
arlucio
wants to merge
353
commits into
pulkin:master
Choose a base branch
from
arlucio:mbed
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Damien George <[email protected]>
As an example of how to use mboot on a WB series MCU. Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
Commit 8675858 switched to using the CMSIS provided SystemInit function which sets VTOR to 0x00000000 (previously it was 0x08000000). A VTOR of 0x00000000 will be correct on some MCUs but not on others where the built-in bootloader is remapped to this address, via __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH(). To make sure mboot has the correct vector table, this commit explicitly sets VTOR to the correct value of 0x08000000. Signed-off-by: Damien George <[email protected]>
This is the same as a902b69 but applied to mboot's Makefile. Signed-off-by: Damien George <[email protected]>
And use it in py/objdict.c instead of mp_obj_is_dict_type. Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
An OrderedDict can now be used for the locals when creating a type explicitly via type(name, bases, locals). Signed-off-by: Damien George <[email protected]>
This adds support for freezing an entire directory while keeping the directory as part of the import path. For example freeze("path/to/library", "module") will recursively freeze all scripts in "path/to/library/module" and have them importable as "from module import ...". Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
Previously, if FAT was not enabled but LFS1/2 was then MICROPY_PY_IO_FILEIO would be disabled and file binary-mode was not supported. Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
This was missed in commit 120368b Signed-off-by: Damien George <[email protected]>
There's no need to do a directory listing to search for the given firmware filename, it just takes extra time and code size. Instead this commit changes it so that the requested firmware file is opened immediately and will abort if the file couldn't be opened. This also allows to specify files in a directory. Signed-off-by: Damien George <[email protected]>
This commit factors the code for files and streaming to separate source files (vfs_fat.c and gzstream.c respectively) and introduces an abstract gzstream interface to make it easier to plug in different filesystems. Signed-off-by: Damien George <[email protected]>
Mboot now supports FAT, LFS1 and LFS2 filesystems, to load firmware from. The filesystem needed by the board must be explicitly enabled by the configuration variables MBOOT_VFS_FAT, MBOOT_VFS_LFS1 and MBOOT_VFS_LFS2. Boards that previously used FAT implicitly (with MBOOT_FSLOAD enabled) must now add the following config to mpconfigboard.h: #define MBOOT_VFS_FAT (1) Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
By passing through the I2C instance to the application callbacks, the application can implement multiple I2C slave devices on different peripherals (eg I2C1 and I2C2). This commit also adds a proper rw argument to i2c_slave_process_addr_match for F7/H7/WB MCUs, and enables the i2c_slave_process_tx_end callback. Mboot is also updated for these changes. Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
uint types in viper mode can now be used for all binary operators except floor-divide and modulo. Fixes issue micropython#1847 and issue micropython#6177. Signed-off-by: Damien George <[email protected]>
This allows complex binary operations to fail gracefully with unsupported operation rather than raising an exception, so that special methods work correctly. Signed-off-by: Damien George <[email protected]>
Before this commit the USB VCP TX ring-buffer used the basic implementation where it can only be filled to a maximum of buffer size-1. For a 1024 size buffer this means the largest packet that can be sent is 1023. Once a packet of this size is sent the next byte copied in goes to the final byte in the buffer, so must be sent as a 1 byte packet before the read pointer can be wrapped around to the beginning. So in large streaming transfers, watching the USB sniffer you basically get alternating 1023 byte packets then 1 byte packets. This commit changes the ring-buffer implementation to a scheme that doesn't have the full-size limitation, and the USB VCP driver can now achieve a constant stream of full-sized packets. This scheme introduces a restriction on the size of the buffer: it must be a power of 2, and the maximum size is half of the size of the index (in this case the index is 16-bit, so the maximum size would be 32767 bytes rounded to 16384 for a power-of-2). But this is not a big limitation because the size of the ring-buffer prior to this commit was restricted to powers of 2 because it was using a mask-based method to wrap the indices. For an explanation of the new scheme see https://www.snellman.net/blog/archive/2016-12-13-ring-buffers/ The RX buffer could likely do with a similar change, though as it's not read from in chunks like the TX buffer it doesn't present the same issue, all that's lost is one byte capacity of the buffer. USB VCP TX throughput is improved by this change, potentially doubling the speed in certain cases.
Signed-off-by: Damien George <[email protected]>
The implementation internally uses sector erase to wipe everything except the sector(s) that mboot lives in (by erasing starting from APPLICATION_ADDR). The erase command can take some time (eg an STM32F765 with 2MB of flash takes 8 to 10 seconds). This time is normally enough to make pydfu.py fail with a timeout. The DFU standard includes a mechanism for the DFU device to request a longer timeout as part of the get-status response just before starting an operation. This timeout functionality has been implemented here.
So the caller can tell when an invalid address is used and can take appropriate action.
This is required for some DFU programmers, eg ST's DfuSe demo PC app. Signed-off-by: Damien George <[email protected]>
Previous commits removed the ability for one I2C/SPI constructor to construct both software- or hardware-based peripheral instances. Such construction is now split to explicit soft and non-soft types. This commit makes both types available in all ports that previously could create both software and hardware peripherals: machine.I2C and machine.SPI construct hardware instances, while machine.SoftI2C and machine.SoftSPI create software instances. This is a breaking change for use of software-based I2C and SPI. Code that constructed I2C/SPI peripherals in the following way will need to be changed: machine.I2C(-1, ...) -> machine.SoftI2C(...) machine.I2C(scl=scl, sda=sda) -> machine.SoftI2C(scl=scl, sda=sda) machine.SPI(-1, ...) -> machine.SoftSPI(...) machine.SPI(sck=sck, mosi=mosi, miso=miso) -> machine.SoftSPI(sck=sck, mosi=mosi, miso=miso) Code which uses machine.I2C and machine.SPI classes to access hardware peripherals does not need to change. Signed-off-by: Damien George <[email protected]>
With a warning that this way of constructing software I2C/SPI is deprecated. The check and warning will be removed in a future release. This should help existing code to migrate to the new SoftI2C/SoftSPI types. Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
This provides microsecond accuracy. Signed-off-by: Damien George <[email protected]>
It requires mp_hal_time_ns() to be provided by a port. This function allows very accurate absolute timestamps. Enabled on unix, windows, stm32, esp8266 and esp32. Signed-off-by: Damien George <[email protected]>
So it can be enabled without modifying the source. Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
Signed-off-by: Damien George <[email protected]>
DMA2 clock and registers should be left in their current state in the H7 build.
Changes are: - Fix missing IRQ handler when SDMMC2 is used instead of SDMMC1 with H7 MCUs. - Removed outdated H7 series compatibility macros. - Defined common IRQ handler macro for F4 series.
The new functions provide FUS/WS status, version and SYS HCI commands: - stm.rfcore_status() - stm.rfcore_fw_version(fw_id) - stm.rfcore_sys_hci(ogf, ocf, cmd)
This commit adds a script that can be run on-device to install FUS and WS binaries from the filesystem. Instructions for use are provided in the rfcore_firmware.py file. The commit also removes unneeded functionality from the existing rfcore.py debug script (and renames it rfcore_debug.py).
This WS update to 1.9.0.0.4 broke the workaround used in rfcore for OCF_CB_SET_EVENT_MASK2, so fix it to support WS 1.8 and 1.9.
The flash can sometimes be in an already-unlocked state, and attempting to unlock it again will cause an immediate reset. So make _Flash.unlock() check FLASH_CR_LOCK to get the current state. Also fix some magic numbers for FLASH_CR_LOCK AND FLASH_CR_STRT. The machine.reset() could be removed because it no longer crashes now that the flash unlock is fixed. Signed-off-by: Jim Mussared <[email protected]>
Signed-off-by: Jim Mussared <[email protected]>
When installing WS firmware, the very first GET_STATE can take several seconds to respond (especially with the larger binaries like BLE_stack_full). Allows stm.rfcore_sys_hci to take an optional timeout, defaulting to SYS_ACK_TIMEOUT_MS (which is 250ms). Signed-off-by: Jim Mussared <[email protected]>
The last argument of TUD_CDC_DESCRIPTOR() is the endpoint size (or wMaxPacketSize), not the CDC RX buffer size (which can be larger than the endpoint size). Signed-off-by: Damien George <[email protected]>
Adding a port number other then 443 to a PyPI URL may be needed if a local server like devpi is used.
This is a generally useful feature and because it's part of the object model it cannot be added at runtime by some loadable Python code, so enable it on the standard unix build.
To align with unix and stm32 ports.
* Updated to the last version of Micropython * Reverted commit c846c69 that produced performance drop (also was generating bugs on make with mbedtls) * Added mbedtls related files as on other ports Additional info on PR
I think you should be more specific about what kinds of errors you experienced in the past. Besides, I cannot add code that has problems at linking stage. You may look into Otherwise I would at least try to use the built-in mbedtls to conserve a portion flash memory. There is a fair chance that the built-in library works even better. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tested connection using axTLS and with this update using mbedtls, and I can say after that using mbedtls it is working much better, more stable, not giving errors which I was having a lot using axTLS.
For this to work it was necessary to update to the last version of Micropython and to revert commit c846c69 that produced performance drop and was generating bugs on make with mbedtls. I added mbedtls related files based on stm32 port.
The C SDK originally already has mbedtls files so on build it generates lots of errors of "multiple definitions" and other errors, but in the end it builds ok and generates the hex working properly. If anyone knows if there is a way to exclude the mbedtls files of C SDK in the Makefile, would be great.
I'm using it this way and it is working well, but would be great if anyone that understands better Makefiles, to help with the errors produced on build.