Commit Graph

910 Commits

Author SHA1 Message Date
Damien George
67fd58bbd2 stm32/mboot: Add support for littlefs.
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 <damien@micropython.org>
2020-06-26 21:17:02 +10:00
Damien George
390f32922d stm32/mboot: Decouple stream, filesystem and top-level loading code.
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 <damien@micropython.org>
2020-06-26 21:15:30 +10:00
Damien George
763bd448a4 stm32/mboot: Don't search for firmware on FS, just attempt to open it.
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 <damien@micropython.org>
2020-06-26 21:11:03 +10:00
Damien George
717b5073aa stm32/boards: Enable LFS2 on PYBD_SF3 and PYBD_SF6.
This was missed in commit 120368ba1a

Signed-off-by: Damien George <damien@micropython.org>
2020-06-25 16:32:48 +10:00
Damien George
c5af3217d9 stm32/timer: Support TIM1 on WB MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2020-06-25 16:32:48 +10:00
Damien George
eb9850ef6c stm32/mpconfigport.h: Enable PY_IO_FILEIO when any VFS is enabled.
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 <damien@micropython.org>
2020-06-25 16:32:48 +10:00
Damien George
b4dc4c5b9a stm32/mboot: Use additional CFLAGS to compile string0.c.
This is the same as a902b69dd5 but applied to
mboot's Makefile.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-23 14:00:16 +10:00
Damien George
81a7293ed6 stm32/mboot: Set VTOR on start up to ensure it has the correct value.
Commit 8675858465 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 <damien@micropython.org>
2020-06-23 13:56:20 +10:00
Damien George
6f40e6e131 stm32/boards: Add build-time option for NUCLEO_WB55 to use mboot.
As an example of how to use mboot on a WB series MCU.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-22 14:18:15 +10:00
Damien George
705728369d stm32/mboot: Add support for using mboot with WB MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2020-06-22 14:18:15 +10:00
Damien George
8675858465 stm32/mboot: Use CMSIS system source code for SystemInit function.
There's no need to duplicate this functionality in mboot, the code provided
in stm32lib/CMSIS does the same thing and makes it easier to support other
MCU series.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-22 14:18:15 +10:00
Damien George
a8778c8dc8 stm32/mboot: Use flash routines from main stm32 code rather than custom.
The flash functions in ports/stm32/flash.c are almost identical to those in
ports/stm32/mboot/main.c, so remove the duplicated code in mboot and use
instead the main stm32 code.  This also allows supporting other MCU series.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-22 14:18:15 +10:00
Damien George
736daebfc8 stm32/flash: Add flash_is_valid_addr, and extend sectors for 2MB F7.
Signed-off-by: Damien George <damien@micropython.org>
2020-06-22 14:18:15 +10:00
Damien George
4c8a68df6f stm32/i2cslave: Add support for WB MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2020-06-22 14:18:15 +10:00
Damien George
afd47d58ac stm32/flash: Make flash C-API reusable, and funcs return an error code.
This commit makes the low-level flash C functions usable by code other than
flashbdev.c (eg by mboot).  Changes in this commit are:
- flash_erase() and flash_write() now return an errno error code, a
  negative value on error.
- flash_erase() now automatically locks the flash, as well as unlocking it.
- flash_write() now automatically unlocks the flash, as well as locking it.
- flashbdev.c is modified for the above changes.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-22 14:18:15 +10:00
Damien George
ce326699d7 stm32/powerctrlboot: Include irq.h to get definitions of IRQ priorities.
irq.h is included by py/mphal.h but it's better to be explicit, eg if mboot
uses powerctrlboot.c.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-22 13:47:48 +10:00
Damien George
5f3c2f1fa8 stm32/irq: Clean up irq.h so it does not depend on core uPy defines.
The irq.h file now just provides low-level IRQ definitions and priorities.
All Python binding definitions are moved to modmachine.h, with some
renaming of pyb -> machine, and also the machine_idle definition (was
pyb_wfi) is moved to modmachine.c.

The cc3200 and teensy ports are updated to build with these changes.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-22 13:47:15 +10:00
Damien George
ce02d5e348 stm32/boards/NUCLEO_WB55: Add more CPU pins and aliases to SW1/2/3.
Signed-off-by: Damien George <damien@micropython.org>
2020-06-18 10:48:24 +10:00
Damien George
4b5dd012e0 stm32/rfcore: Leave txpower level as default when initialising rfcore.
And provide a convenient API function to change it (currently unused).

Fixes issue #5985.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-17 00:10:29 +10:00
Damien George
289be6b352 stm32/usb: Add support for 2xVCP on L0, L432 and WB MCUs.
There are a maximum of 8 USB endpoints and each has 2 buffer slots
(in/out).  This commit add support for up to 8 endpoints and adds FIFO
configuration for USB profiles with 2xVCP on MCUs that have device-only USB
peripherals.

Tested on NUCLEO_WB55 in 2xVCP, 2xVCP+MSC and 2xVCP+MSC+HID mode.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-17 00:09:42 +10:00
Damien George
da99e0f979 stm32/factoryreset: Provide empty create-FS function when FAT disabled.
Signed-off-by: Damien George <damien@micropython.org>
2020-06-17 00:09:37 +10:00
Damien George
2b9900380a stm32/boards/STM32F769DISC: Use macro instead of const for flash size.
So that the flash size can be changed in just one place.  Also remove the
duplicate cache entry.
2020-06-12 10:28:26 +10:00
stinos
da71f55e23 stm32/Makefile: Quote libgcc path so spaces are not an issue.
Fixes #3116.
2020-06-02 14:11:08 +10:00
Damien George
246f3f640d stm32/boards/xxx_WB55: Enable pyb.ADC and hardware SPI on WB55 boards.
These features are now supported (although machine.ADC is recommended over
pyb.ADC).
2020-06-02 10:48:49 +10:00
Damien George
c8985d52d3 stm32/dma: Add support for DMA on STM32WB, with SPI settings provided. 2020-06-02 10:48:49 +10:00
Damien George
0f7b5cceea stm32/machine_adc: Make setting of ADC1_COMMON->CCR clearer on STM32WB. 2020-06-02 10:48:49 +10:00
Damien George
5210fc51ec stm32/adc: Add support to pyb.ADC for STM32WB MCUs. 2020-06-02 10:48:49 +10:00
Damien George
68d053c66e stm32/modmachine: Allow changing AHB and APB bus frequencies on STM32WB.
For now SYSCLK cannot be changed and must remain at 64MHz.
2020-06-02 10:48:49 +10:00
Damien George
9ae50d22c9 stm32/machine_uart: Allow re-init'ing a static UART object.
Just disallow changing the rxbuf which will be some static RAM (can't free
it and soft-reset would lose any dynamically allocated buffer).
2020-06-01 21:41:54 +10:00
Damien George
88971342b1 stm32/machine_uart: Retain attached-to-repl setting when init'ing UART. 2020-06-01 21:41:50 +10:00
Thomas Roberts
463c0fb2f4 stm32/boards: Add board config for Nucleo-F412ZG development board. 2020-05-15 10:48:48 +10:00
Thomas Roberts
d7399679de stm32: Add support for F412 MCUs. 2020-05-15 10:08:30 +10:00
Thorsten von Eicken
f385b7bfa8 stm32/README: Reorg DFU flashing instructions with addition for PYBD. 2020-05-11 21:23:41 +10:00
Damien George
e2def200bf stm32/boards/PYBD_SF2: Put BTstack library in external QSPI XIP flash.
In the same way the nimble stack is put there.
2020-05-05 20:21:15 +10:00
Jim Mussared
710426024a all: Factor gchelper code to one place and use it for unix & ARM ports.
No functionality change is intended with this commit, it just consolidates
the separate implementations of GC helper code to the lib/utils/ directory
as a general set of helper functions useful for any port.  This reduces
duplication of code, and makes it easier for future ports or embedders to
get the GC implementation correct.

Ports should now link against gchelper_native.c and either gchelper_m0.s or
gchelper_m3.s (currently only Cortex-M is supported but other architectures
can follow), or use the fallback gchelper_generic.c which will work on
x86/x64/ARM.

The gc_helper_get_sp function from gchelper_m3.s is not really GC related
and was only used by cc3200, so it has been moved to that port and renamed
to cortex_m3_get_sp.
2020-04-29 23:45:19 +10:00
Jim Mussared
50e44f477b stm32/main: Peform a clean shutdown of btstack on soft reset.
Not just NimBLE.
2020-04-29 16:45:46 +10:00
Jim Mussared
8119ec0765 extmod/modbluetooth: Don't hold atomic section during mp_sched_schedule.
Because, for example, on unix the atomic section isn't re-entrant, and
mp_sched_schedule() will try to re-acquire the atomic section.
2020-04-29 16:45:40 +10:00
Jim Mussared
0da47ecc93 stm32/Makefile: Rename SRC_LIB to LIB_SRC_C to match other ports. 2020-04-29 16:38:18 +10:00
stijn
84fa3312cf all: Format code to add space after C++-style comment start.
Note: the uncrustify configuration is explicitly set to 'add' instead of
'force' in order not to alter the comments which use extra spaces after //
as a means of indenting text for clarity.
2020-04-23 11:24:25 +10:00
Andrew Leech
8ee2e1fdbc stm32/mboot: Expose custom DFU USB VID/PID values at makefile level.
In mboot, the ability to override the USB vendor/product id's was added
back in 5688c9ba09.  However, when the main
firmware is turned into a DFU file the default VID/PID are used there.
pydfu.py doesn't care about this but dfu-util does and prevents its use
when the VID/PID don't match.

This commit exposes BOOTLOADER_DFU_USB_VID/PID as make variables, for use
on either command line or mpconfigboard.mk, to set VID/PID in both mboot
and DFU files.
2020-04-18 23:02:00 +10:00
stijn
30840ebc99 all: Enable extra conversion warnings where applicable.
Add -Wdouble-promotion and -Wfloat-conversion for most ports to ban out
implicit floating point conversions, and add extra Travis builds using
MICROPY_FLOAT_IMPL_FLOAT to uncover warnings which weren't found
previously.  For the unix port -Wsign-comparison is added as well but only
there since only clang supports this but gcc doesn't.
2020-04-18 22:42:28 +10:00
stijn
70affd9ba2 all: Fix implicit floating point to integer conversions.
These are found when building with -Wfloat-conversion.
2020-04-18 22:42:24 +10:00
stijn
bcf01d1686 all: Fix implicit conversion from double to float.
These are found when building with -Wfloat-conversion.
2020-04-18 22:42:24 +10:00
Martin Fischer
28833690bb stm32/mboot/README: Clarify that mboot can access FAT formatted FS only. 2020-04-16 16:28:07 +10:00
Martin Fischer
7942d0b688 stm32/storage: Fix start address of second, internal block device. 2020-04-16 16:25:20 +10:00
Damien George
8e048d2548 all: Clean up error strings to use lowercase and change cannot to can't.
Now that error string compression is supported it's more important to have
consistent error string formatting (eg all lowercase English words,
consistent contractions).  This commit cleans up some of the strings to
make them more consistent.
2020-04-13 22:19:37 +10:00
Jim Mussared
073b9a5eb8 ports: Enable error text compression for various ports, but not all.
Enabled on: bare-arm, minimal, unix coverage/dev/minimal, stm32, esp32,
esp8266, cc3200, teensy, qemu-arm, nrf.  Not enabled on others to be able
to test the code when the feature is disabled (the default case).

Code size change for this commit:

   bare-arm:  -600 -0.906%
minimal x86:  -308 -0.208%
   unix x64:    +0 +0.000%
unix nanbox:    +0 +0.000%
      stm32: -3368 -0.869% PYBV10
     cc3200: -1024 -0.558%
    esp8266: -2512 -0.368% GENERIC
      esp32: -2876 -0.205% GENERIC[incl -3168(data)]
        nrf: -1708 -1.173% pca10040
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
2020-04-05 15:02:06 +10:00
Jim Mussared
def76fe4d9 all: Use MP_ERROR_TEXT for all error messages. 2020-04-05 15:02:06 +10:00
Jim Mussared
994c1dd57a stm32/Makefile: Add missing ordering dependency on generated headers. 2020-04-05 14:12:59 +10:00
Damien George
1a3e386c67 all: Remove spaces inside and around parenthesis.
Using new options enabled in the uncrustify configuration.
2020-03-28 23:36:44 +11:00
Damien George
83461e37d4 stm32/boards: Disable pend_throw, uheapq, utimeq on small-flash boards.
These are mainly used by the previous version of uasyncio which is now
replaced by a newer version, with built-in C module _uasyncio.  Saves about
1300 bytes of flash.
2020-03-28 13:55:59 +11:00
Damien George
09154f585f stm32/mpconfigport.h: Make most extended modules configurable by board. 2020-03-28 13:46:35 +11:00
Damien George
dbba6b05dc stm32/mpconfigport.h: Remove unused root pointer for BTstack bindings.
This was a cut-and-paste error from the NimBLE bindings.
2020-03-27 00:30:37 +11:00
Damien George
35e2dd0979 stm32: Enable and freeze uasyncio. 2020-03-26 01:25:45 +11:00
Damien George
f05ae416ff stm32/softtimer: Initialise pairing-heap node before pushing to heap. 2020-03-26 01:21:04 +11:00
Zoltán Vörös
c5cc64175b ports: Add lib/libm/roundf.c to bare-metal Makefile's.
This function is not used by the core but having it as part of the build
allows it to be used by user C modules, or board extensions.  The linker
won't include it in the final firmware if it remains unused.
2020-03-25 01:22:00 +11:00
Damien George
feb2577585 all: Remove spaces between nested paren and inside function arg paren.
Using new options enabled in the uncrustify configuration.
2020-03-25 00:39:46 +11:00
Damien George
40255aff23 stm32/mboot: Remove unnecessary test for led being 1 in led_state.
The "led" argument is always a pointer to the GPIO port, or'd with the pin
that the LED is on, so testing that it is "1" is unnecessary.  The type of
"led" is also changed to uint32_t so it can properly hold a 32-bit pointer.
2020-03-25 00:10:32 +11:00
Andrew Leech
9dd470b768 stm32/mboot: Update LED0 state from systick handler.
Updating the LED0 state from systick handler ensures LED0 is always
consistent with its flash rate regardless of other processing going on in
either interrupts or main.  This improves the visible stability of the
bootloader, rather than LED0 flashing somewhat randomly at times.

This commit also changes the LED0 flash rate depending on the current state
of DFU, giving slightly more visual feedback on what the device is doing.
2020-03-25 00:08:32 +11:00
Andrew Leech
f7130a99b6 stm32/mboot: Protect against invalid address flash writes.
And provide a DFU error message for invalid erases and writes.
2020-03-22 15:23:49 +11:00
Andrew Leech
b41d08cf15 stm32/mboot: Update dfu state/status flags to better match standard. 2020-03-22 14:11:16 +11:00
Andrew Leech
03b1ed80e7 stm32/mboot: Allow overriding led_init and led_state in board folder.
Allows for custom functions/logic to display mboot state.
2020-03-22 13:48:45 +11:00
Damien George
eae495a714 stm32/main: Fix bug mounting 3rd SD partition.
Fixes issue #5753.
2020-03-12 12:34:31 +11:00
Damien George
ed848553b4 extmod/vfs: Factor out vfs mount-and-chdir helper from stm32. 2020-03-11 14:24:26 +11:00
Damien George
e965363b6b stm32: Refactor Bluetooth HCI RX to be independent of transport layer.
Now all HCI specific code (eg UART vs WB55 internal messaging) is confined
to modbluetooth_hci.c.
2020-03-10 01:53:42 +11:00
Damien George
0674917bc5 extmod/btstack: Implement advertising.
Work done in collaboration with Jim Mussared aka @jimmo.
2020-03-10 01:53:42 +11:00
Damien George
51f8591097 stm32/boards/PYBD: Allow building with BTstack (via make command line).
Work done in collaboration with Jim Mussared aka @jimmo.
2020-03-10 01:53:42 +11:00
Damien George
0e95815bfb stm32: Add bindings for BTstack implementation.
Work done in collaboration with Jim Mussared aka @jimmo.
2020-03-10 01:53:42 +11:00
Damien George
894c550c86 stm32: Refactor bluetooth stack/hci/driver bindings.
This makes a cleaner separation between the: driver, HCI UART and BT stack.
Also updated the naming to be more consistent (mp_bluetooth_hci_*).

Work done in collaboration with Jim Mussared aka @jimmo.
2020-03-10 01:53:42 +11:00
Damien George
c44d52f33e extmod/modbluetooth_nimble: Move nimble specific code, factor nimble.mk.
Move extmod/modbluetooth_nimble.* to extmod/nimble.  And move common
Makefile lines to extmod/nimble/nimble.mk (which was previously only used
by stm32).  This allows (upcoming) btstack to follow a similar structure.

Work done in collaboration with Jim Mussared aka @jimmo.
2020-03-06 12:35:20 +11:00
Damien George
44aa5b2200 stm32/modnetwork: Remove redundant call to nimble_poll in lwip poll.
The bluetooth stack has its own dedicated polling function, see
mod_bluetooth_nimble_poll_wrapper().
2020-03-06 12:35:20 +11:00
Damien George
69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Damien George
3f39d18c2b all: Add *FORMAT-OFF* in various places.
This string is recognised by uncrustify, to disable formatting in the
region marked by these comments.  This is necessary in the qstrdef*.h files
to prevent modification of the strings within the Q(...).  In other places
it is used to prevent excessive reformatting that would make the code less
readable.
2020-02-28 10:31:07 +11:00
hahmadi
b169904254 stm32/mpconfigport.h: Add option to have custom help text.
Define MICROPY_PY_BUILTINS_HELP_TEXT in <yourboard>/mpconfigboard.h for a
custom help text.
2020-02-21 15:02:19 +11:00
Andrew Leech
3fe83e4318 stm32/sdram: Fix compile issue from unused sdram startup test flag. 2020-02-18 14:22:03 +11:00
Damien George
ad7213d3c3 py: Add mp_raise_msg_varg helper and use it where appropriate.
This commit adds mp_raise_msg_varg(type, fmt, ...) as a helper for
nlr_raise(mp_obj_new_exception_msg_varg(type, fmt, ...)).  It makes the
C-level API for raising exceptions more consistent, and reduces code size
on most ports:

   bare-arm:   +28 +0.042%
minimal x86:  +100 +0.067%
   unix x64:   -56 -0.011%
unix nanbox:  -300 -0.068%
      stm32:  -204 -0.054% PYBV10
     cc3200:    +0 +0.000%
    esp8266:   -64 -0.010% GENERIC
      esp32:  -104 -0.007% GENERIC
        nrf:  -136 -0.094% pca10040
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
2020-02-13 11:52:40 +11:00
Damien George
97eca38c4f py: Add mp_raise_type helper macro and use it where appropriate.
This provides a more consistent C-level API to raise exceptions, ie moving
away from nlr_raise towards mp_raise_XXX.  It also reduces code size by a
small amount on some ports.
2020-02-13 11:03:37 +11:00
Damien George
ce40abcf21 stm32/usbd_cdc_interface: Remove "interrupt_char != -1" check.
It's not needed.  The C integer implicit promotion rules mean that the
uint8_t of the incoming character is promoted to a (signed) int, matching
the type of interrupt_char.  Thus the uint8_t incoming character can never
be equal to -1 (the value of interrupt_char that indicate that interruption
is disabled).
2020-02-07 16:08:37 +11:00
Damien George
98a3911c43 py/scheduler: Add "raise_exc" argument to mp_handle_pending.
Previous behaviour is when this argument is set to "true", in which case
the function will raise any pending exception.  Setting it to "false" will
cancel any pending exception.
2020-02-07 16:08:20 +11:00
Damien George
d6a1e45caa stm32/usbd_conf: Allow boards to configure USB HS ULPI NXT/DIR pins. 2020-02-04 23:15:55 +11:00
Andrew Leech
ff9a61b5a8 stm32/sdram: Expose the result of sdram startup test in stm32_main.
This means boards can choose to only use it for gc heap if the test passes.
2020-02-04 18:18:41 +11:00
Damien George
af88e70414 stm32/powerctrl: Reenable PLL3 on H7 MCUs when waking from stop mode.
So that USB can work.
2020-01-31 23:25:18 +11:00
Damien George
2c8c2b935e stm32/powerctrl: Improve support for changing system freq on H7 MCUs.
This commit improves pllvalues.py to generate PLL values for H7 MCUs that
are valid (VCO in and out are in range) and extend for the entire range of
SYSCLK values up to 400MHz (up to 480MHz is currently unsupported).
2020-01-31 23:25:18 +11:00
Damien George
03b73ce329 stm32/stm32_it: Don't call __HAL_USB_HS_EXTI_CLEAR_FLAG on H7 MCUs.
It doesn't exist on these MCUs.
2020-01-31 23:25:18 +11:00
Damien George
257b17ec10 stm32/sdio: Add support for H7 MCUs.
The cyw43 driver on stm32 will now work with H7 MCUs.
2020-01-31 23:25:18 +11:00
Damien George
31ba06ce84 stm32/boards/stm32f746_af.csv: Add ADC alt functions to correct pins. 2020-01-30 16:31:11 +11:00
Damien George
68db7e01d8 stm32/powerctrl: Enable overdrive on F7 when waking from stop mode.
Because if the SYSCLK is set to 180MHz or higher it will require this to be
on already.
2020-01-30 16:30:03 +11:00
Damien George
29b84ea798 stm32/powerctrl: Disable HSI if not needed to save a bit of power. 2020-01-30 16:29:45 +11:00
Damien George
96a4435be1 stm32/boards/STM32F769DISC: Add config to use external SPI as filesys.
This board now has the following 3 build configurations:
- mboot + external QSPI in XIP mode + internal filesystem
- mboot + external QSPI with filesystem (the default)
- no mboot + external QSPI with filesystem
2020-01-30 14:40:38 +11:00
Damien George
7bb2bf965e stm32/Makefile: Allow a board's .mk file to add things to CFLAGS. 2020-01-30 14:39:46 +11:00
Andrew Leech
30501d3f54 drivers, stm32: Support SPI/QSPI flash chips over 16MB.
With a SPI flash that has more than 16MB, 32-bit addressing is required
rather than the standard 24-bit.  This commit adds support for 32-bit
addressing so that the SPI flash commands (read/write/erase) are selected
automatically depending on the size of the address being used at each
operation.
2020-01-30 13:18:38 +11:00
David Lechner
b72cb0ca1b py/mpthread.h: Use strong type for mp_thread_set_state() argument.
This modifies the signature of mp_thread_set_state() to use
mp_state_thread_t* instead of void*.  This matches the return type of
mp_thread_get_state(), which returns the same value.

`struct _mp_state_thread_t;` had to be moved before
`#include <mpthreadport.h>` since the stm32 port uses it in its
mpthreadport.h file.
2020-01-29 17:10:32 +11:00
Damien George
a542c6d7e0 stm32/powerctrl: For F7, allow PLLM!=HSE when setting PLLSAI to 48MHz.
PLLM is shared among all PLL blocks on F7 MCUs, and this calculation to
configure PLLSAI to have 48MHz on the P output previously assumed that PLLM
is equal to HSE (eg PLLM=25 for HSE=25MHz).  This commit relaxes this
assumption to allow other values of PLLM.
2020-01-29 16:49:13 +11:00
Damien George
f70373c7b2 stm32/softtimer: Change linear linked list to a pairing heap. 2020-01-22 17:31:18 +11:00
Memiks
4ab4bf3ec6 ports: Modify mp_hal_pin_write macro so it can be used as a function.
Even though it doesn't return anything it could still be used like a
function.  Addresses issue #5501.
2020-01-14 23:48:42 +11:00
Damien George
bfbd94401d py: Make mp_obj_get_type() return a const ptr to mp_obj_type_t.
Most types are in rodata/ROM, and mp_obj_base_t.type is a constant pointer,
so enforce this const-ness throughout the code base.  If a type ever needs
to be modified (eg a user type) then a simple cast can be used.
2020-01-09 11:25:26 +11:00
Damien George
e3187b052f stm32/boards/PYBD: Change RTC asynch prediv from 1 to 4.
This change has the following effects:
- Reduces the resolution of the RTC sub-second counter from 30.52us to
  122.07us.
- Allows RTC.calibration() to now support positive values (as well as
  negative values).
- Reduces VBAT current consumption in standby mode by a small amount.

For general purpose use 122us resolution of the sub-second counter is
good enough, and the benefits of full range calibration and minor reduction
in VBAT consumption are worth the change.
2020-01-07 23:59:29 +11:00
Nicko van Someren
4c93955b7b py/objslice: Add support for indices() method on slice objects.
Instances of the slice class are passed to __getitem__() on objects when
the user indexes them with a slice.  In practice the majority of the time
(other than passing it on untouched) is to work out what the slice means in
the context of an array dimension of a particular length.  Since Python 2.3
there has been a method on the slice class, indices(), that takes a
dimension length and returns the real start, stop and step, accounting for
missing or negative values in the slice spec.  This commit implements such
a indices() method on the slice class.

It is configurable at compile-time via MICROPY_PY_BUILTINS_SLICE_INDICES,
disabled by default, enabled on unix, stm32 and esp32 ports.

This commit also adds new tests for slice indices and for slicing unicode
strings.
2019-12-28 23:55:15 +11:00
Yonatan Goldschmidt
61d2b40ad5 lib/utils/pyexec: Introduce MICROPY_REPL_INFO, wrap debug prints in it.
For the 3 ports that already make use of this feature (stm32, nrf and
teensy) this doesn't make any difference, it just allows to disable it from
now on.

For other ports that use pyexec, this decreases code size because the debug
printing code is dead (it can't be enabled) but the compiler can't deduce
that, so code is still emitted.
2019-12-28 00:05:39 +11:00
David Lechner
e79424d672 ports: Allow overriding CROSS_COMPILE in a custom makefile.
Many ports already allow overriding CROSS_COMPILE.  This modifies the
remaining ports to allow it as well.
2019-12-27 23:53:16 +11:00