Commit Graph

165 Commits

Author SHA1 Message Date
Damien George 7d4a2f773c all: Make use of $(TOP) variable in Makefiles, instead of "..".
$(TOP) is defined in py/mkenv.mk and should be used to refer to the top
level of this repository.
2017-08-11 12:22:19 +10:00
Damien George 05a08506ae stmhal/Makefile: Add CFLAGS_EXTRA to CFLAGS so cmdline can add options. 2017-06-28 15:44:29 +10:00
Damien George 703370ebc5 stmhal/Makefile: Rename FLOAT_IMPL to MICROPY_FLOAT_IMPL to match C name
The name used in py/mpconfig.h is MICROPY_FLOAT_IMPL so rename this
Makefile variable to mirror that.
2017-06-28 15:42:40 +10:00
Damien George 535804a0ed stmhal/Makefile: Use hardware double-prec FP for MCUs that support it. 2017-06-28 15:12:05 +10:00
Damien George ebfdd96cb2 stmhal: Add possibility to build with double-precision floating point.
By default the firmware is built with single-precision floating point.
To build a particular board using double precision instead, put the
following line in the mpconfigboard.mk file:

    FLOAT_IMPL = double
2017-06-28 15:12:04 +10:00
Damien George b19138e82e stmhal: Make available the _onewire module, for low-level bus control. 2017-06-22 16:20:22 +10:00
Damien George 4f9858e86d stmhal: Move pybstdio.c to lib/utils/sys_stdio_mphal.c for common use.
It provides sys.stdin, sys.stdout, sys.stderr for bare-metal targets based
on mp_hal functions.
2017-06-15 18:55:34 +10:00
Damien George 6ff0ecfffc ports: Convert from using stmhal's input() to core provided version. 2017-06-01 16:02:49 +10:00
Damien George b6c7e4b143 all: Use full path name when including mp-readline/timeutils/netutils.
This follows the pattern of how all other headers are now included, and
makes it explicit where the header file comes from.  This patch also
removes -I options from Makefile's that specify the mp-readline/timeutils/
netutils directories, which are no longer needed.
2017-03-31 22:29:39 +11:00
Damien George 125eae1ba3 py/modbuiltins: For round() builtin use nearbyint instead of round.
The C nearbyint function has exactly the semantics that Python's round()
requires, whereas C's round() requires extra steps to handle rounding of
numbers half way between integers.  So using nearbyint reduces code size
and potentially eliminates any source of errors in the handling of half-way
numbers.

Also, bare-metal implementations of nearbyint can be more efficient than
round, so further code size is saved (and efficiency improved).

nearbyint is provided in the C99 standard so it should be available on all
supported platforms.
2017-03-24 11:00:45 +11:00
Krzysztof Blazewicz 75589272ef all/Makefile: Remove -ansi from GCC flags, its ignored anyway.
The -ansi flag is used for C dialect selection and it is equivalent to -std=c90.
Because it goes right before -std=gnu99 it is ignored as for conflicting flags
GCC always uses the last one.
2017-03-23 15:32:12 +11:00
Damien George e5cc681cb1 stmhal: Use generic interrupt char code. 2017-02-15 16:39:30 +11:00
Damien George 7ae9bee790 stmhal/Makefile: Drop use of -mabi=aapcs-linux; link libgcc by default.
The aapcs-linux ABI is not required, instead the default aapcs ABI is
enough.  And using the default ABI means that the provided libgcc will now
link with the firmware without warnings about variable vs fixed enums.

Although the binary size increases by about 1k, RAM usage is slightly
decreased.  And libgcc may prove useful in the future for things like
long-long division.
2017-02-08 11:50:22 +11:00
Damien George 882ec01e42 stmhal: Initial implementation of multithreading, currently disabled.
This patch brings the _thread module to stmhal/pyboard.  There is a very
simple round-robin thread scheduler, which is disabled if there is only
one thread (for efficiency when threading is not used).

The scheduler currently switches threads at a rate of 250Hz using the
systick timer and the pend-SV interrupt.

The GIL is disabled so one must be careful to use lock objects to prevent
concurrent access of objects.

The threading is disabled by default, one can enabled it with the config
option MICROPY_PY_THREAD to test it out.
2017-01-31 18:42:35 +11:00
Damien George 84c614e729 stmhal: Convert to use VFS sub-system and new ooFatFs component.
This patch makes the following configuration changes:
- MICROPY_FSUSERMOUNT is disabled, removing old mounting infrastructure
- MICROPY_VFS is enabled, giving new VFS sub-system
- MICROPY_VFS_FAT is enabled, giving uos.VfsFat type
- MICROPY_FATFS_OO is enabled, to use new ooFatFs lib, R0.12b

User facing API should be almost unchanged.  Most notable changes are
removal of os.mkfs (use os.VfsFat.mkfs instead) and pyb.mount doesn't
allow unmounting by passing None as the device.
2017-01-27 23:22:15 +11:00
Damien George d6a2d00167 stmhal: Add ability to have filesystem stored on external SPI flash.
To use this feature a port should define MICROPY_HW_SPIFLASH_SIZE_BITS
along with x_CS, x_SCK, x_MOSI, x_MISO (x=MICROPY_HW_SPIFLASH).  This will
then use external SPI flash on those pins instead of the internal flash.

The SPI is done using the software implementation.  There is currently only
support for standard SPI (ie not dual or quad mode).
2017-01-24 16:58:50 +11:00
Damien George cffe00d6ab stmhal: Add default frozen-bytecode directory and link lcd160cr driver.
stmhal will now be built by default with frozen bytecode from scripts
stored in the stmhal/modules/ directory.  This can be disabled or
changed to another directory by overridding the make variable
FROZEN_MPY_DIR.
2017-01-23 14:37:49 +11:00
Damien George 8678e3edfd stmhal: Convert to use builtin help function. 2017-01-22 11:56:16 +11:00
Pavol Rusnak b82fc8dcef
stmhal: fix wrong usage of gcc -print-libgcc-file-name 2017-01-12 20:32:43 +01:00
Nicholas Graumann 0d75b0d962 stmhal: Add address parameters to openocd config files.
Also make l4 config the default for STM32L476DISC board.
2016-11-28 15:27:36 +11:00
Damien George 3053748987 stmhal: Add beginnings of port-specific machine.I2C implementation.
This allows one to construct an I2C object using ids that are specific
to the stmhal port, eg machine.I2C('X').  Right now the implementation
of I2C uses software I2C but the idea is to just change the C-level I2C
protocol functions to hardware implementations later on.
2016-11-24 00:20:51 +11:00
Paul Sokolovsky 8f5bc3ffc0 stmhal/moduselect: Move to extmod/ for reuse by other ports. 2016-11-21 00:05:56 +03:00
Damien George e5ef15a9d7 py/lexer: Provide generic mp_lexer_new_from_file based on mp_reader.
If a port defines MICROPY_READER_POSIX or MICROPY_READER_FATFS then
lexer.c now provides an implementation of mp_lexer_new_from_file using
the mp_reader_new_file function.
2016-11-16 18:13:51 +11:00
Damien George bdf33bc136 py: Move frozen bytecode Makefile rules from ports to common mk files.
Now, to use frozen bytecode all a port needs to do is define
FROZEN_MPY_DIR to the directory containing the .py files to freeze, and
define MICROPY_MODULE_FROZEN_MPY and MICROPY_QSTR_EXTRA_POOL.
2016-11-08 14:28:30 +11:00
Damien George cd527bb324 lib/libm: Move Thumb-specific sqrtf function to separate file.
This allows it to be used only when the hardware supports VFP
instructions, preventing compile errors.
2016-11-03 12:26:32 +11:00
Paul Sokolovsky 3967ca7390 stmhal/Makefile: Use standard rules for frozen module generation.
As defined in py/py.mk.
2016-10-21 01:27:17 +03:00
Paul Sokolovsky 799ccdc789 esp8266, stmhal, unix: MAKE_FROZEN is consistently defined in mkenv.mk. 2016-10-16 10:49:36 +03:00
Dave Hylands 7a9c183c20 stmhal: Fix ESPRUINO_PICO by adding ld scripts with correct flash size. 2016-10-05 11:42:50 +11:00
Philip Potter eb239b8398 stmhal/usb: Add support to receive USB HID messages from host. 2016-10-04 15:38:01 +11:00
Dave Hylands 1f433c719b stmhal: Fix linker map for STM32L476 chips.
In particular, this makes the L4 .isr_vector section 16K in size so it's
the same as the F4/F7 MCUs.  The patch also moves the L4 filesystem to
the end of flash, which allows for 512K filesystem on the 1Mb devices
like the STM32L476DISC.
2016-10-04 14:31:19 +11:00
Krzysztof Blazewicz 6aea34ad89 lib/cmsis: move CMSIS headers to lib/
Files in lib/cmsis are generic for all Cortex-M MCU's
files left in stmhal/cmsis are all STM32 specific.
2016-09-30 16:19:03 +10:00
Krzysztof Blazewicz 9310dad15d stmhal: Put common definitions from linker files to common.ld. 2016-09-22 12:03:12 +10:00
Damien George 9526e24234 unix,stmhal,esp8266: When find'ing frozen files follow symbolic links.
It's useful to be able to use symbolic links to add files and directories
to the set of scripts to be frozen.
2016-09-05 12:35:05 +10:00
Delio Brignoli e2ac8bb3f1 py: Add MICROPY_USE_INTERNAL_PRINTF option, defaults to enabled.
This new config option allows to control whether MicroPython uses its own
internal printf or not (if not, an external one should be linked in).
Accompanying this new option is the inclusion of lib/utils/printf.c in the
core list of source files, so that ports no longer need to include it
themselves.
2016-09-05 12:18:53 +10:00
Damien George 76c366df56 stmhal: Add machine.WDT class.
Usage:

    import machine
    wdt = machine.WDT(0, 5000) # 5 second timeout
    wdt.feed()

Thanks to Moritz for the initial implementation.
2016-09-04 00:12:48 +10:00
Damien George 9c04ef2a67 unix,stmhal,esp8266: When find'ing frozen files don't use extra slash.
This extra forward slash for the starting-point directory is unnecessary
and leads to additional slashes on Max OS X which mean that the frozen
files cannot be imported.

Fixes #2374.
2016-08-31 15:12:57 +10:00
Damien George 3e03d1b87e stmhal: Support frozen packages using .mpy files.
See issue #1814.
2016-05-23 13:29:56 +01:00
Colin Hogben 104aa26271 cc3200, stmhal, teensy: Use pyhelp_print_obj function.
Update the help() implementations in the cc3200, stmhal and teensy
ports to use the pyhelp_print_obj function.
2016-04-25 18:54:59 +03:00
Paul Sokolovsky 098f3e2862 stmhal: Update Makefile dependencies. 2016-04-19 11:54:07 +03:00
Tobias Badertscher 69f26c68c9 stmhal: L4: Add line to Makefile for building L4 series. 2016-04-16 22:14:12 +01:00
Damien George 040373e4c4 stmhal: For frozen bytecode generation, add dependency of qstr file. 2016-04-16 13:20:02 +01:00
Jan Čapek d76c65f599 py: Add rules for automated extraction of qstrs from sources.
- add template rule that converts a specified source file into a qstring file

- add special rule for generating a central header that contains all
  extracted/autogenerated strings - defined by QSTR_DEFS_COLLECTED
  variable. Each platform appends a list of sources that may contain
  qstrings into a new build variable: SRC_QSTR. Any autogenerated
  prerequisities are should be appened to SRC_QSTR_AUTO_DEPS variable.

- remove most qstrings from py/qstrdefs, keep only qstrings that
  contain special characters - these cannot be easily detected in the
  sources without additional annotations

- remove most manual qstrdefs, use qstrdef autogen for: py, cc3200,
  stmhal, teensy, unix, windows, pic16bit:

   - remove all micropython generic qstrdefs except for the special strings that contain special characters (e.g. /,+,<,> etc.)
   - remove all port specific qstrdefs except for special strings
   - append sources for qstr generation in platform makefiles (SRC_QSTR)
2016-04-16 13:18:09 +01:00
Damien George 733db525e2 stmhal: Add Makefile option FROZEN_MPY_DIR to support frozen bytecode. 2016-04-13 16:07:47 +01:00
Damien George 0a2e9650f5 py: Add ability to have frozen persistent bytecode from .mpy files.
The config variable MICROPY_MODULE_FROZEN is now made of two separate
parts: MICROPY_MODULE_FROZEN_STR and MICROPY_MODULE_FROZEN_MPY.  This
allows to have none, either or both of frozen strings and frozen mpy
files (aka frozen bytecode).
2016-04-13 16:07:47 +01:00
Christopher Arndt 9b5e05a7c7 stmhal: Add makefile target and configuration to deploy via OpenOCD. 2016-03-09 23:00:17 +00:00
Christopher Arndt 07554486ee stmhal: Add makefile target to deploy stmhal build via ST-LINK. 2016-03-09 13:26:23 +00:00
Damien George 2c72ae5c29 stmhal: Switch from dfu-util to tools/pydfu.py for deflt deploy method.
tools/pydfu.py is now the recommended way of deploying a DFU file.  Old
behaviour of dfu-util can be obtained by passing USE_PYDFU=0 when invoking
make.

The main README.md file has been updated to reflect this change.
2016-03-08 11:58:39 +00:00
Paul Sokolovsky 46a0ac02c5 extmod/vfs_fat_ffconf: Reusable FatFs module, move from stmhal/ffconf.
TODO: Probably merge into vfs_fat_diskio.
2016-02-15 00:19:27 +02:00
Paul Sokolovsky 6b0c88256b extmod/vfs_fat_file: Reusable FatFs module, move from stmhal/file. 2016-02-15 00:16:46 +02:00
Paul Sokolovsky 8cb78e0e53 extmod/vfs_fat_diskio: Reusable FatFs module, move from stmhal/diskio. 2016-02-15 00:08:37 +02:00