Commit Graph

7085 Commits

Author SHA1 Message Date
Damien George
93ee6603b1 py/asm: Fix x86 and ARM assemblers due to recent code refactoring. 2016-12-09 22:54:45 +11:00
Damien George
155fdc74d5 py/asm: Remove need for dummy_data when doing initial assembler passes.
For all but the last pass the assembler only needs to count how much space
is needed for the machine code, it doesn't actually need to emit anything.
The dummy_data just uses unnecessary RAM and without it the code is not
any more complex (and code size does not increase for Thumb and Xtensa
archs).
2016-12-09 22:50:58 +11:00
Damien George
e920bab976 py/emitinline: Move common code for end of final pass to compiler.
This patch moves some common code from the individual inline assemblers to
the compiler, the code that calls the emit-glue to assign the machine code
to the functions scope.
2016-12-09 21:23:17 +11:00
Damien George
dd53b12193 py/emitinline: Move inline-asm align and data methods to compiler.
These are generic methods that don't depend on the architecture and so
can be handled directly by the compiler.
2016-12-09 20:54:54 +11:00
Damien George
a7fd786a1f py/emitinline: Embed entire asm struct instead of a pointer to it.
This reduces fragmentation, and memory use by 1 word.  But more
importantly it means the emit_inline_asm_t struct now "derives" from
mp_asm_base.
2016-12-09 20:35:21 +11:00
Damien George
3a4ebf5768 esp8266: Enable inline Xtensa assembler.
With this patch, @micropython.asm_xtensa can be used on the esp8266 port.
2016-12-09 17:13:00 +11:00
Damien George
f76b1bfa9f py: Add inline Xtensa assembler.
This patch adds the MICROPY_EMIT_INLINE_XTENSA option, which, when
enabled, allows the @micropython.asm_xtensa decorator to be used.

The following opcodes are currently supported (ax is a register, a0-a15):

    ret_n()
    callx0(ax)
    j(label)
    jx(ax)

    beqz(ax, label)
    bnez(ax, label)
    mov(ax, ay)
    movi(ax, imm) # imm can be full 32-bit, uses l32r if needed

    and_(ax, ay, az)
    or_(ax, ay, az)
    xor(ax, ay, az)
    add(ax, ay, az)
    sub(ax, ay, az)
    mull(ax, ay, az)

    l8ui(ax, ay, imm)
    l16ui(ax, ay, imm)
    l32i(ax, ay, imm)
    s8i(ax, ay, imm)
    s16i(ax, ay, imm)
    s32i(ax, ay, imm)
    l16si(ax, ay, imm)
    addi(ax, ay, imm)

    ball(ax, ay, label)
    bany(ax, ay, label)
    bbc(ax, ay, label)
    bbs(ax, ay, label)
    beq(ax, ay, label)
    bge(ax, ay, label)
    bgeu(ax, ay, label)
    blt(ax, ay, label)
    bnall(ax, ay, label)
    bne(ax, ay, label)
    bnone(ax, ay, label)

Upon entry to the assembly function the registers a0, a12, a13, a14 are
pushed to the stack and the stack pointer (a1) decreased by 16.  Upon
exit, these registers and the stack pointer are restored, and ret.n is
executed to return to the caller (caller address is in a0).

Note that the ABI for the Xtensa emitters is non-windowing.
2016-12-09 17:07:38 +11:00
Damien George
ad297a1950 py: Allow inline-assembler emitter to be generic.
This patch refactors some code so that it is easier to integrate new
inline assemblers for different architectures other than ARM Thumb.
2016-12-09 17:06:21 +11:00
Damien George
45a6156dfd esp8266: Enable native emitter for Xtensa arch.
This patch allows esp8266 to use @micropython.native and
@micropython.viper function decorators.  By default the executable machine
code is written to the space at the end of the iram1 region.  The user can
call esp.set_native_code_location() to make the code go to flash instead.
2016-12-09 16:51:49 +11:00
Damien George
8e5aced1fd py: Integrate Xtensa assembler into native emitter.
The config option MICROPY_EMIT_XTENSA can now be enabled to target the
Xtensa architecture with @micropython.native and @micropython.viper
decorators.
2016-12-09 16:51:49 +11:00
Damien George
fcac4b07f1 py/asmxtensa: Add low-level Xtensa assembler. 2016-12-09 16:51:49 +11:00
Damien George
81316fa411 py/asmbase: Add MP_PLAT_COMMIT_EXEC option for handling exec code.
If a port defines MP_PLAT_COMMIT_EXEC then this function is used to turn
RAM data into executable code.  For example a port may want to write the
data to flash for execution.  The function must return a pointer to the
executable data.
2016-12-09 16:51:49 +11:00
Damien George
c8746e1e72 py: Move arch-specific assembler macros from emitnative to asmXXX.h. 2016-12-09 16:51:49 +11:00
Damien George
c2713592bc py/emit.h: Remove long-obsolete declarations for cpython emitter. 2016-12-09 13:28:25 +11:00
Damien George
adf3cb5081 extmod/modframebuf: Store underlying buffer object to prevent GC free. 2016-12-09 12:58:45 +11:00
Damien George
5e393007b9 esp8266/mpconfigport_512k: Disable framebuf module for 512k build.
The 512k build recently overflowed because of the newly-enabled uselect
module.  uselect is arguable more important than framebuf for small
devices so we disable framebuf to keep the 512k build within its limit.
2016-12-08 17:31:21 +11:00
Damien George
898d4c1217 extmod/modframebuf: Make framebuf implement the buffer protocol.
So that one can easily access the underlying data of the frame buffer, eg
to write the data out to a display.
2016-12-08 15:17:47 +11:00
Damien George
ad166857bc esp8266: Refactor to use extmod implementation of software SPI class. 2016-12-08 14:41:58 +11:00
Damien George
1b6d94bccd stmhal: Refactor to use extmod implementation of software SPI class.
This is a pure refactoring (and simplification) of code so that stmhal
uses the software SPI class provided in extmod, for the machine.SPI
implementation.
2016-12-08 13:58:10 +11:00
Damien George
1eb3c66e91 extmod/machine_spi: Provide reusable software SPI class.
So long as a port defines relevant mp_hal_pin_xxx functions (and delay) it
can make use of this software SPI class without the need for additional
code.
2016-12-08 13:47:01 +11:00
Damien George
d9c839742f stmhal/hal: Update HALCOMMITS due to change in f7 hal files. 2016-12-07 17:36:42 +11:00
Rami Ali
db5a4e8f3c stmhal/boards/STM32F7DISC: Define LSE_STARTUP_TIMEOUT.
So it compiles with the latest F7 hal.
2016-12-07 17:31:21 +11:00
Rami Ali
6901649f54 stmhal: Declare and initialise PrescTables for F7 MCUs. 2016-12-07 17:31:09 +11:00
Rami Ali
44cb2ff7ab stmhal: Port of f4 hal commit 1d7fb82 to updated f7 hal. 2016-12-07 17:31:07 +11:00
Rami Ali
821863751f stmhal: Port of f4 hal commit 09de030 to updated f7 hal. 2016-12-07 17:31:05 +11:00
Rami Ali
e1c6ed634f stmhal: Port of f4 hal commit c568a2b to updated f7 hal. 2016-12-07 17:30:44 +11:00
Rami Ali
b9741cd8f8 stmhal/hal: Update ST32CubeF7 HAL files to V1.1.2.
These files originate from the STM32Cube_FW_F7_V1.5.0 software package
from ST.  Newlines are unixified and trailing whitespace is removed.
2016-12-07 17:28:33 +11:00
Rami Ali
d9677f4098 stmhal/cmsis: Update STM32F7 CMSIS device include files to V1.1.2. 2016-12-07 17:27:40 +11:00
Damien George
080a78b15e py/compile: Simplify configuration of native emitter. 2016-12-07 11:17:17 +11:00
Damien George
4c7d799b82 stmhal/uart: Add check that UART id is valid for the given board.
Previous to this patch trying to construct, but not init, a UART that
didn't exist on the target board would actually succeed.  Only when
initialising the UART would it then raise an exception that the UART does
not exist.

This patch adds an explicit check that the constructed UART does in fact
exist for the given board.
2016-12-05 15:31:16 +11:00
Damien George
aaab6a9921 stmhal/uart: Add support for UART7 and UART8 on F7 MCUs. 2016-12-05 15:14:22 +11:00
Rami Ali
27a503f632 stmhal: Refactor UART configuration to use pin objects.
This follows the pattern of other peripherals (I2C, SPI) to specify the
pins using pin objects instead of a pair of GPIO port and pin number.  It
makes it easier to customise the UART pins for a particular board.
2016-12-05 14:26:41 +11:00
puuu
4fc607a1d7 esp8266: Move websocket_helper.py from scripts to modules for frozen BC.
websocket_helper.py is used by webrepl.  If webrepl is enabled and
websocket_helper.py is not frozen bytecode it leads to heap
fragmentation.
2016-12-05 13:01:08 +11:00
Damien George
042d5f24d6 tests/extmod/framebuf1: Add basics tests for hline, vline, rect, line. 2016-12-05 11:55:43 +11:00
Damien George
374ed317c5 extmod/modframebuf: Add hline, vline, rect and line methods.
These are basic drawing primitives.  They work in a generic way on all
framebuf formats by calling the underlying setpixel or fill_rect C-level
primitives.
2016-12-05 11:52:51 +11:00
Damien George
0db3a41f02 travis: Build STM32 F7 and L4 boards under Travis CI.
The STM32 F7 and L4 boards use significantly different code to the F4
boards so it's important to test them with CI.  To keep CI build times
within a reasonable limit the STM32F4DISC board is no longer built, it's
anyway very similar to the standard F4 build for PYBv1.0.
2016-12-05 11:25:37 +11:00
Damien George
fcd10882bd stmhal/adc: Use constants from new HAL version. 2016-12-05 10:51:00 +11:00
Paul Sokolovsky
e44b236ce2 tests/extmod/btree1: Exercise btree.flush(). 2016-12-05 01:55:05 +03:00
Paul Sokolovsky
4463d8a910 extmod/modbtree: Rename "sync" method to "flush" for consistency.
Rename recently introduced "sync" method to "flush" for consistency with
usual files.
2016-12-05 01:50:55 +03:00
Paul Sokolovsky
1779a62085 zephyr: Switch to Zephyr 1.6 unified kernel API.
In 1.6, Zephyr switched to "unified kernel" and new API set. Older kernel
API is supported, but marked as deprecated and leads to warnings.
2016-12-04 00:47:20 +03:00
Peter Hinch
46e59c52af docs/library/pyb.Accel: Add hardware note about pins used by accel. 2016-12-02 17:39:13 +11:00
w4kpm
ec22d1739d extmod/modbtree: Add method to sync the database.
If you have longish operations on the db (such as logging data) it may
be desirable to periodically sync the database to the disk.  The added
btree.sync() method merely exposes the berkley __bt_sync function to the
user.
2016-12-02 17:30:53 +11:00
w4kpm
bd476acd41 extmod/vfs_fat_file: Allow file obj to respond to ioctl flush request. 2016-12-02 17:26:37 +11:00
Damien George
e50cb73b7a esp8266: Enable uselect module.
Select and poll will now work on socket objects.
2016-12-02 16:44:31 +11:00
Damien George
cb53226b0c extmod/modlwip: Add ioctl method to socket, with poll implementation.
Implementation of polling may need further fine tuning, but basic
functionality works (tested on esp8266).
2016-12-02 16:41:51 +11:00
Damien George
2d329c4a56 extmod/moduselect: Use configurable EVENT_POLL_HOOK instead of WFI.
To make moduselect be usable by any port.
2016-12-02 16:40:39 +11:00
Damien George
ebc8d730f1 extmod/moduselect: Use stream helper function instead of ad-hoc code. 2016-12-02 16:39:50 +11:00
Damien George
304cfda8c4 py/stream: Move ad-hoc ioctl constants to stream.h and rename them.
The constants MP_IOCTL_POLL_xxx, which were stmhal-specific, are moved
from stmhal/pybioctl.h (now deleted) to py/stream.h.  And they are renamed
to MP_STREAM_POLL_xxx to be consistent with other such constants.

All uses of these constants have been updated.
2016-12-02 16:37:29 +11:00
Damien George
6194336d81 tests/extmod/vfs_fat_fileio: Add test for constructor of FileIO type. 2016-12-02 15:37:58 +11:00
Damien George
f7545b200e stmhal/moduos: Implement POSIX behaviour of rename, allow to overwrite. 2016-12-02 15:13:29 +11:00