Commit Graph

122 Commits

Author SHA1 Message Date
Philip Potter c777b6950e stmhal: Update boot.py files to use VCP instead of CDC. 2016-08-29 15:17:34 +10:00
Tobias Badertscher 7441ba7749 stmhal: L4: Make CCM/DTCM RAM start-up conditional on MCU type. 2016-05-05 15:19:33 +01:00
Dave Hylands 4b2938a4b0 stmhal: Some NETDUINO_PLUS_2 cleanup
- Put the I2C bus on the corect pins
- Add the appropriate board_init to power the shield
2016-02-15 10:07:27 +00:00
Damien George b33a770596 extmod/fsusermount: Support mounting of multiple block devices.
This patch adds support to fsusermount for multiple block devices
(instead of just one).  The maximum allowed is fixed at compile time by
the size of the fs_user_mount array accessed via MP_STATE_PORT, which
in turn is set by MICROPY_FATFS_VOLUMES.

With this patch, stmhal (which is still tightly coupled to fsusermount)
is also modified to support mounting multiple devices   And the flash and
SD card are now just two block devices that are mounted at start up if
they exist (and they have special native code to make them more
efficient).
2016-02-10 23:40:10 +00:00
Damien George ea89b80ff4 stmhal: Make TIM3 available for use by the user.
TIM3 is no longer used by USB CDC for triggering outgoing data, so we
can now make it available to the user.

PWM fading on LED(4) is now gone, but will be reinstated in a new way.
2016-01-29 22:31:56 +00:00
Paul Sokolovsky d3b1f0b627 py/runtime: mp_stack_ctrl_init() should be called immediately on startup.
Calling it from mp_init() is too late for some ports (like Unix), and leads
to incomplete stack frame being captured, with following GC issues. So, now
each port should call mp_stack_ctrl_init() on its own, ASAP after startup,
and taking special precautions so it really was called before stack variables
get allocated (because if such variable with a pointer is missed, it may lead
to over-collecting (typical symptom is segfaulting)).
2016-01-29 02:13:42 +02:00
Dave Hylands f380904bd9 stmhal: Print exception information in nlr_jump_failed
Currently nlr_jump_fail prints that there was an uncaught exception
but nothing about the exception.
This patch causes nlr_jump_failed to try to print the exception.
Given that printf was called on the line above, I think that
the call to mp_obj_print_exception has about as much likelyhood
of succeeding as the printf does.
2015-12-07 17:21:51 +00:00
Dave Hylands acc208418b stmhal: Execute boot.py and main.py when formatting the file system.
When you use the USER button to perform a filesystem reset
at boot time then it wipes out the filesystem and creates
a new boot.py and main.py.  With this patch these files are
executed after formatting, ensuring that pyb and machine modules
get imported.
2015-12-07 15:11:42 +00:00
Damien George 66b96822fb stmhal: Add option to free up TIM3 from USB VCP polling.
This is a hack to free up TIM3 so that it can be used by the user.
Instead we use the PVD irq to call the USB VCP polling function, and
trigger it from SysTick (so SysTick itself does not do any processing).

The feature is enabled for pyboard lite only, since it lacks timers.
2015-12-04 14:07:15 +00:00
Damien George f7697ff393 stmhal: Add rtc.init() method to force RTC to re-initialise. 2015-12-04 12:05:05 +00:00
T S 86aa16bea6 stmhal: Implement delayed RTC initialization with LSI fallback.
If RTC is already running at boot then it's left alone.  Otherwise, RTC is
started at boot but startup function returns straight away.  RTC startup
is then finished the first time it is used.  Fallback to LSI if LSE fails
to start in a certain time.

Also included:
 MICROPY_HW_CLK_LAST_FREQ
        hold pyb.freq() parameters in RTC backup reg
 MICROPY_HW_RTC_USE_US
        option to present datetime sub-seconds in microseconds
 MICROPY_HW_RTC_USE_CALOUT
        option to enable RTC calibration output

CLK_LAST_FREQ and RTC_USE_CALOUT are enabled for PYBv1.0.
2015-11-23 23:23:07 +00:00
Damien George 40274fec9c lib/pyexec: Move header pyexec.h from stmhal directory. 2015-11-09 13:13:09 +00:00
Damien George 731f359292 all: Add py/mphal.h and use it in all ports.
py/mphal.h contains declarations for generic mp_hal_XXX functions, such
as stdio and delay/ticks, which ports should provide definitions for.  A
port will also provide mphalport.h with further HAL declarations.
2015-10-31 19:14:30 +03:00
Dave Hylands 504420c51d stmhal: Early version of machine module for stmhal. 2015-10-19 21:12:42 +01:00
Damien George 0334058fa4 Rename "Micro Python" to "MicroPython" in REPL, help, readme's and misc. 2015-10-12 00:06:25 +01:00
Tom Soulanille 7731edf2f5 stmhal: Add "opt" arg to pyb.main, to set mp_optimise_value.
Use this to set the global optimisation value when executing the main
script (and all scripts it imports).
2015-09-12 22:53:54 +01:00
Dave Hylands 5e11d2b349 stmhal: Enable SPI support for F7 MCUs. 2015-08-05 23:38:49 +01:00
Dave Hylands 34fe5a30c6 stmhal: Enable I2C support for F7 MCUs. 2015-08-05 23:38:24 +01:00
Damien George 6f1c00869c stmhal: Factor out USRSW boot-up code and support boards with 1 LED.
Thanks to Dave Hylands for the patch.
2015-08-03 00:14:44 +01:00
Dave Hylands 92d4b51ad5 stmhal: Add STM32F7DISC and associated changes. 2015-07-30 00:38:32 +01:00
Dave Hylands ff987ccf11 stmhal: Move debug UART repl to after uart_init0 call. 2015-05-06 22:16:49 +01:00
Damien George 4f94d90d4d stmhal: Include fatfs headers using lib/fatfs prefix.
This helps make files reusable across other ports.
2015-03-04 20:35:41 +00:00
Henrik Sölver f80f1a7077 stmhal: Add support for CAN rx callbacks. 2015-02-15 03:10:53 +00:00
Damien George 0b32e50365 stmhal: Make pybstdio usable by other ports, and use it.
Now all ports can use pybstdio.c to provide sys.stdin/stdout/stderr, so
long as they implement mp_hal_stdin_* and mp_hal_stdout_* functions.
2015-02-13 15:04:53 +00:00
Damien George 55d6218b9a stmhal: Properly define pyb.usb_mode() semantics. 2015-02-13 14:02:51 +00:00
Damien George 39ce2db181 stmhal: Add "CDC" option to pyb.usb_mode, for CDC device only. 2015-02-13 14:02:51 +00:00
Damien George d39c7aa517 stmhal: Add Python-configurable USB HID mode.
Different HID modes can be configured in Python.  You can either use
predefined mouse or keyboard, or write your own report descriptor.
2015-02-13 14:02:51 +00:00
Damien George f5465b9eb0 stmhal: Reclaim 72 bytes of stack by factoring out flash init code. 2015-01-09 20:38:23 +00:00
Damien George 3b51b3e90f stmhal: Collect all root pointers together in 1 place.
A GC in stmhal port now only scans true root pointers, not entire BSS.
This reduces base GC time from 1700ms to 900ms.
2015-01-07 23:38:50 +00:00
Damien George 2cf6dfa280 stmhal: Prefix includes with py/; remove need for -I../py. 2015-01-01 21:06:20 +00:00
Damien George 8204db6831 stmhal: Change fresh boot.py and main.py to use \r\n newlines.
This is so it's compatible with Windows.
2014-10-25 01:14:39 +01:00
Dave Hylands 8d62bbd46a Add pyb.hard_reset, and make sys.exit() or raise SystemExit do a soft reset. 2014-10-22 19:14:20 +01:00
Damien George 481d714bd5 stmhal: Overhaul UART class to use read/write, and improve it.
UART object now uses a stream-like interface: read, readall, readline,
readinto, readchar, write, writechar.

Timeouts are configured when the UART object is initialised, using
timeout and timeout_char keyword args.

The object includes optional read buffering, using interrupts.  You can set
the buffer size dynamically using read_buf_len keyword arg.  A size of 0
disables buffering.
2014-10-21 22:15:20 +01:00
Damien George fec70ad369 stmhal: Remove long-obsolete pybwlan.[ch] files from old CC3k driver. 2014-10-06 15:40:25 +00:00
Damien George 3a1c4c5bc6 stmhal: Add network and usocket module.
As per issue #876, the network module is used to configure NICs
(hardware modules) and configure routing.  The usocket module is
supposed to implement the normal Python socket module and selects the
underlying NIC using routing logic.

Right now the routing logic is brain dead: first-initialised,
first-used.  And the routing table is just a list of registered NICs.

cc3k and wiznet5k work, but not at the same time due to C name clashes
(to be fixed).

Note that the usocket module has alias socket, so that one can import
socket and it works as normal.  But you can also override socket with
your own module, using usocket at the backend.
2014-09-30 22:36:47 +01:00
Damien George 3a2795e200 stmhal: Add label to internal flash drive on creation. 2014-09-29 15:26:11 +01:00
Damien George eaaebf3291 stmhal: Initialise stack pointer correctly.
Stack is full descending and must be 8-byte aligned.  It must start off
pointing to just above the last byte of RAM.

Previously, stack started pointed to last byte of RAM (eg 0x2001ffff)
and so was not 8-byte aligned.  This caused a bug in combination with
alloca.

This patch also updates some debug printing code.

Addresses issue #872 (among many other undiscovered issues).
2014-09-23 10:59:05 +01:00
Damien George b92cbe6129 py: Move definition of mp_sys_exit to core.
sys.exit always raises SystemExit so doesn't need a special
implementation for each port.  If C exit() is really needed, use the
standard os._exit function.

Also initialise mp_sys_path and mp_sys_argv in teensy port.
2014-09-15 15:53:09 +01:00
Dave Hylands 9480138f0c Add save/restore_irq
Factored irq functions into a separate file.
2014-08-25 12:22:11 +01:00
Damien George b63be37be1 stmhal: In safe mode, still mount SD card and present as MSD over USB.
It's still "safe" because no scripts are run.  Remove the SD card if you
want to access the internal flash filesystem.  Addresses issue #616.

Also: remove obsolete pyb.source_dir setting, and reset pyb.main and
pyb.usb_mode settings on soft-reset.
2014-08-16 14:23:22 +01:00
Damien George 30dd23aa7f doc: Document gc, sys, math, cmath. 2014-08-10 17:50:28 +01:00
Damien George ccacdf44b6 stmhal: Clean up reset/soft-reset code; fix bug init'ing VCP exc.
Make a clearer distinction between init functions that must be done
before any scripts can run (xxx_init0) and those that can be safely
deferred (xxx_init).

Fix bug initialising USB VCP exception.  Addresses issue #788.

Re-order some init function to improve reliability of
reset/soft-reset.
2014-08-04 11:09:51 +01:00
Damien George 8dbbbbc793 Put call to qstr_init and mp_init_emergency_exc_buf in mp_init.
qstr_init is always called exactly before mp_init, so makes sense to
just have mp_init call it.  Similarly with
mp_init_emergency_exception_buf.  Doing this makes the ports simpler and
less error prone (ie they can no longer forget to call these).
2014-08-04 10:05:16 +01:00
Damien George 65dd7bc13d stmhal: Change 0:/ and 1:/ to /flash and /sd; add CWD support.
Some important changes to the way the file system is structured on the
pyboard:

1. 0: and 1: drive names are now replaced with POSIX inspired
directories, namely /flash and /sd.

2. Filesystem now supports the notion of a current working directory.
Supports the standard Python way of manipulating it: os.chdir and
os.getcwd.

3. On boot up, current directory is /flash if no SD inserted, else /sd
if SD inserted.  Then runs boot.py and main.py from the current dir.
This is the same as the old behaviour, but is much more consistent and
flexible (eg you can os.chdir in boot.py to change where main.py is run
from).

4. sys.path (for import) is now set to '' (current dir), plus /flash
and /flash/lib, and then /sd and /sd/lib if SD inserted.  This, along
with CWD, means that import now works properly.  You can import a file
from the current directory.

5. os.listdir is fixed to return just the basename, not the full path.

See issue #537 for background and discussion.
2014-07-31 23:44:04 +01:00
Dave Hylands 5b7fd20fea Add support for storing args during an exception raised by an irq.
The user code should call micropython.alloc_emergency_exception_buf(size)
where size is the size of the buffer used to print the argument
passed to the exception.

With the test code from #732, and a call to
micropython.alloc_emergenncy_exception_buf(100) the following error is
now printed:
```python
>>> import heartbeat_irq
Uncaught exception in Timer(4) interrupt handler
Traceback (most recent call last):
  File "0://heartbeat_irq.py", line 14, in heartbeat_cb
NameError: name 'led' is not defined
```
2014-07-25 14:00:06 -07:00
Damien George 951ed9d02f stmhal: Fix REPL printing by cooking output sent to stdout_obj.
Recent changes to builtin print meant that print was printing to the
mp_sys_stdout_obj, which was sending data raw to the USB CDC device.
The data should be cooked so that \n turns into \r\n.
2014-07-20 13:57:43 +01:00
Damien George e70b5dbe58 stmhal: Some reordering of code/functions. 2014-07-02 14:09:44 +01:00
Damien George 92a47b4dae Merge branch 'add-timer-deinit' of github.com:dhylands/micropython into dhylands-add-timer-deinit 2014-07-02 14:06:28 +01:00
Paul Sokolovsky caa7334141 stackctrl: Add "mp_" prefix. 2014-07-01 02:14:08 +03:00
Dave Hylands 0d81c133b3 Add timer_deinit and call it just before doing a soft-restart
This fixes #733.
2014-06-30 08:07:38 -07:00