summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-07-28 13:29:47 -0400
committerDan Halbert <halbert@halwitz.org>2018-07-28 13:29:47 -0400
commitf48b70050e3e4122eaae3eee47d35fc30bda2a4c (patch)
tree7d2dacc3c137276e9d0838b571c84c09e78acc42
parentbc760dd34100099c352a0f185ec54ceae23d036d (diff)
merge finished
-rw-r--r--extmod/moduhashlib.c16
-rw-r--r--extmod/vfs_fat.h9
-rw-r--r--extmod/vfs_fat_diskio.c6
-rw-r--r--lib/mp-readline/readline.h2
-rw-r--r--ports/atmel-samd/mpconfigport.h3
-rw-r--r--ports/esp8266/common-hal/neopixel_write/__init__.c2
-rw-r--r--ports/esp8266/esp_mphal.c23
-rw-r--r--ports/esp8266/esp_mphal.h3
-rw-r--r--ports/esp8266/uart.c31
-rw-r--r--ports/nrf/modules/ubluepy/ubluepy_scan_entry.c2
-rw-r--r--ports/nrf/modules/ubluepy/ubluepy_scanner.c2
-rw-r--r--ports/unix/Makefile3
-rw-r--r--ports/unix/coverage.c2
-rw-r--r--py/binary.c4
-rw-r--r--py/frozenmod.c8
-rw-r--r--py/objnamedtuple.h6
-rw-r--r--shared-bindings/bleio/Adapter.c2
-rw-r--r--tests/import/mpy_invalid.py.exp6
-rwxr-xr-xtests/run-tests4
19 files changed, 66 insertions, 68 deletions
diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c
index 6389455c0..5e14fc8d4 100644
--- a/extmod/moduhashlib.c
+++ b/extmod/moduhashlib.c
@@ -29,14 +29,6 @@
#include "py/runtime.h"
-static void check_not_unicode(const mp_obj_t arg) {
-#if MICROPY_CPYTHON_COMPAT
- if (MP_OBJ_IS_STR(arg)) {
- mp_raise_TypeError("a bytes-like object is required");
- }
-#endif
-}
-
#if MICROPY_PY_UHASHLIB
#if MICROPY_PY_UHASHLIB_SHA256
@@ -102,6 +94,14 @@ STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) {
#else
+static void check_not_unicode(const mp_obj_t arg) {
+#if MICROPY_CPYTHON_COMPAT
+ if (MP_OBJ_IS_STR(arg)) {
+ mp_raise_TypeError("a bytes-like object is required");
+ }
+#endif
+}
+
STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 0, 1, false);
mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX));
diff --git a/extmod/vfs_fat.h b/extmod/vfs_fat.h
index ded8bc885..dd5e5ffcb 100644
--- a/extmod/vfs_fat.h
+++ b/extmod/vfs_fat.h
@@ -60,15 +60,6 @@ typedef struct _pyb_file_obj_t {
FIL fp;
} pyb_file_obj_t;
-
-// These should be general types (mpy TOOD says so). In micropython, these are defined in
-// mpconfigport.h.
-////////////#define mp_type_fileio mp_type_vfs_fat_fileio
-////////////#define mp_type_textio mp_type_vfs_fat_textio
-
-////////////extern const mp_obj_type_t mp_type_fileio;
-////////////extern const mp_obj_type_t mp_type_textio;
-
extern const byte fresult_to_errno_table[20];
extern const mp_obj_type_t mp_fat_vfs_type;
extern const mp_obj_type_t mp_type_vfs_fat_fileio;
diff --git a/extmod/vfs_fat_diskio.c b/extmod/vfs_fat_diskio.c
index 3b5c7d888..0e442d8fa 100644
--- a/extmod/vfs_fat_diskio.c
+++ b/extmod/vfs_fat_diskio.c
@@ -75,8 +75,9 @@ DRESULT disk_read (
return RES_ERROR;
}
} else {
+ mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, count * SECSIZE(&vfs->fatfs), buff};
vfs->readblocks[2] = MP_OBJ_NEW_SMALL_INT(sector);
- vfs->readblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), buff);
+ vfs->readblocks[3] = MP_OBJ_FROM_PTR(&ar);
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->readblocks);
@@ -120,8 +121,9 @@ DRESULT disk_write (
return RES_ERROR;
}
} else {
+ mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, count * SECSIZE(&vfs->fatfs), (void*)buff};
vfs->writeblocks[2] = MP_OBJ_NEW_SMALL_INT(sector);
- vfs->writeblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), (void*)buff);
+ vfs->writeblocks[3] = MP_OBJ_FROM_PTR(&ar);
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->writeblocks);
diff --git a/lib/mp-readline/readline.h b/lib/mp-readline/readline.h
index 00aa9622a..17d4ec60e 100644
--- a/lib/mp-readline/readline.h
+++ b/lib/mp-readline/readline.h
@@ -26,6 +26,8 @@
#ifndef MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H
#define MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H
+#include "py/misc.h"
+
#define CHAR_CTRL_A (1)
#define CHAR_CTRL_B (2)
#define CHAR_CTRL_C (3)
diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h
index 6324e7a93..49f71b221 100644
--- a/ports/atmel-samd/mpconfigport.h
+++ b/ports/atmel-samd/mpconfigport.h
@@ -123,6 +123,9 @@ typedef long mp_off_t;
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
+#define mp_type_fileio mp_type_vfs_fat_fileio
+#define mp_type_textio mp_type_vfs_fat_textio
+
#define mp_import_stat mp_vfs_import_stat
#define mp_builtin_open_obj mp_vfs_open_obj
diff --git a/ports/esp8266/common-hal/neopixel_write/__init__.c b/ports/esp8266/common-hal/neopixel_write/__init__.c
index 84a743d11..25fb0dcea 100644
--- a/ports/esp8266/common-hal/neopixel_write/__init__.c
+++ b/ports/esp8266/common-hal/neopixel_write/__init__.c
@@ -29,5 +29,5 @@
#include "espneopixel.h"
void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) {
- esp_neopixel_write(digitalinout->pin->gpio_number, pixels, numBytes);
+ esp_neopixel_write(digitalinout->pin->gpio_number, pixels, numBytes, true /*800 kHz*/);
}
diff --git a/ports/esp8266/esp_mphal.c b/ports/esp8266/esp_mphal.c
index be284c8f3..fe669265e 100644
--- a/ports/esp8266/esp_mphal.c
+++ b/ports/esp8266/esp_mphal.c
@@ -35,18 +35,15 @@
#include "extmod/misc.h"
#include "lib/utils/pyexec.h"
-STATIC byte stdin_ringbuf_array[256];
-ringbuf_t stdin_ringbuf = {stdin_ringbuf_array, sizeof(stdin_ringbuf_array), 0, 0};
+STATIC byte input_buf_array[256];
+ringbuf_t stdin_ringbuf = {input_buf_array, sizeof(input_buf_array)};
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len);
const mp_print_t mp_debug_print = {NULL, mp_hal_debug_tx_strn_cooked};
-int uart_attached_to_dupterm;
-
void mp_hal_init(void) {
//ets_wdt_disable(); // it's a pain while developing
mp_hal_rtc_init();
uart_init(UART_BIT_RATE_115200, UART_BIT_RATE_115200);
- uart_attached_to_dupterm = 0;
}
void mp_hal_delay_us(uint32_t us) {
@@ -87,11 +84,19 @@ void mp_hal_debug_str(const char *str) {
#endif
void mp_hal_stdout_tx_str(const char *str) {
- mp_uos_dupterm_tx_strn(str, strlen(str));
+ const char *last = str;
+ while (*str) {
+ uart_tx_one_char(UART0, *str++);
+ }
+ mp_uos_dupterm_tx_strn(last, str - last);
}
void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
- mp_uos_dupterm_tx_strn(str, len);
+ const char *last = str;
+ while (len--) {
+ uart_tx_one_char(UART0, *str++);
+ }
+ mp_uos_dupterm_tx_strn(last, str - last);
}
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
@@ -101,11 +106,13 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
if (str > last) {
mp_uos_dupterm_tx_strn(last, str - last);
}
+ uart_tx_one_char(UART0, '\r');
+ uart_tx_one_char(UART0, '\n');
mp_uos_dupterm_tx_strn("\r\n", 2);
++str;
last = str;
} else {
- ++str;
+ uart_tx_one_char(UART0, *str++);
}
}
if (str > last) {
diff --git a/ports/esp8266/esp_mphal.h b/ports/esp8266/esp_mphal.h
index 56d9fa35f..5ecd392a6 100644
--- a/ports/esp8266/esp_mphal.h
+++ b/ports/esp8266/esp_mphal.h
@@ -40,9 +40,6 @@ void mp_hal_signal_input(void);
// Call this when data is available in dupterm object
void mp_hal_signal_dupterm_input(void);
-// This variable counts how many times the UART is attached to dupterm
-extern int uart_attached_to_dupterm;
-
void mp_hal_init(void);
void mp_hal_rtc_init(void);
diff --git a/ports/esp8266/uart.c b/ports/esp8266/uart.c
index 52707f981..4a8405337 100644
--- a/ports/esp8266/uart.c
+++ b/ports/esp8266/uart.c
@@ -34,11 +34,6 @@ static int uart_os = UART_OS;
static os_event_t uart_evt_queue[16];
#endif
-// A small, static ring buffer for incoming chars
-// This will only be populated if the UART is not attached to dupterm
-static byte uart_ringbuf_array[16];
-static ringbuf_t uart_ringbuf = {uart_ringbuf_array, sizeof(uart_ringbuf_array), 0, 0};
-
static void uart0_rx_intr_handler(void *para);
void soft_reset(void);
@@ -175,26 +170,18 @@ static void uart0_rx_intr_handler(void *para) {
while (READ_PERI_REG(UART_STATUS(uart_no)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S)) {
uint8 RcvChar = READ_PERI_REG(UART_FIFO(uart_no)) & 0xff;
- // For efficiency, when connected to dupterm we put incoming chars
- // directly on stdin_ringbuf, rather than going via uart_ringbuf
- if (uart_attached_to_dupterm) {
- if (RcvChar == mp_interrupt_char) {
- mp_keyboard_interrupt();
- } else {
- ringbuf_put(&stdin_ringbuf, RcvChar);
- }
+ if (RcvChar == mp_interrupt_char) {
+ mp_keyboard_interrupt();
} else {
- ringbuf_put(&uart_ringbuf, RcvChar);
+ ringbuf_put(&stdin_ringbuf, RcvChar);
}
}
+ mp_hal_signal_input();
+
// Clear pending FIFO interrupts
WRITE_PERI_REG(UART_INT_CLR(UART_REPL), UART_RXFIFO_TOUT_INT_CLR | UART_RXFIFO_FULL_INT_ST);
ETS_UART_INTR_ENABLE();
-
- if (uart_attached_to_dupterm) {
- mp_hal_signal_input();
- }
}
}
@@ -203,7 +190,7 @@ static void uart0_rx_intr_handler(void *para) {
bool uart_rx_wait(uint32_t timeout_us) {
uint32_t start = system_get_time();
for (;;) {
- if (uart_ringbuf.iget != uart_ringbuf.iput) {
+ if (stdin_ringbuf.iget != stdin_ringbuf.iput) {
return true; // have at least 1 char ready for reading
}
if (system_get_time() - start >= timeout_us) {
@@ -214,7 +201,7 @@ bool uart_rx_wait(uint32_t timeout_us) {
}
int uart_rx_any(uint8 uart) {
- if (uart_ringbuf.iget != uart_ringbuf.iput) {
+ if (stdin_ringbuf.iget != stdin_ringbuf.iput) {
return true; // have at least 1 char ready for reading
}
return false;
@@ -230,7 +217,7 @@ int uart_tx_any_room(uint8 uart) {
// Returns char from the input buffer, else -1 if buffer is empty.
int uart_rx_char(void) {
- return ringbuf_get(&uart_ringbuf);
+ return ringbuf_get(&stdin_ringbuf);
}
int uart_rx_one_char(uint8 uart_no) {
@@ -288,7 +275,7 @@ void uart_task_handler(os_event_t *evt) {
}
int c, ret = 0;
- while ((c = ringbuf_get(&input_buf)) >= 0) {
+ while ((c = ringbuf_get(&stdin_ringbuf)) >= 0) {
if (c == mp_interrupt_char) {
mp_keyboard_interrupt();
}
diff --git a/ports/nrf/modules/ubluepy/ubluepy_scan_entry.c b/ports/nrf/modules/ubluepy/ubluepy_scan_entry.c
index 8a936d592..773070b08 100644
--- a/ports/nrf/modules/ubluepy/ubluepy_scan_entry.c
+++ b/ports/nrf/modules/ubluepy/ubluepy_scan_entry.c
@@ -109,7 +109,7 @@ STATIC mp_obj_t scan_entry_get_scan_data(mp_obj_t self_in) {
vstr_t vstr;
vstr_init(&vstr, len);
vstr_printf(&vstr, "%s", text);
- description = mp_obj_new_str(vstr.buf, vstr.len, false);
+ description = mp_obj_new_str(vstr.buf, vstr.len);
vstr_clear(&vstr);
}
}
diff --git a/ports/nrf/modules/ubluepy/ubluepy_scanner.c b/ports/nrf/modules/ubluepy/ubluepy_scanner.c
index c92b7fd87..1cde3d551 100644
--- a/ports/nrf/modules/ubluepy/ubluepy_scanner.c
+++ b/ports/nrf/modules/ubluepy/ubluepy_scanner.c
@@ -49,7 +49,7 @@ STATIC void adv_event_handler(mp_obj_t self_in, uint16_t event_id, ble_drv_adv_d
data->p_peer_addr[5], data->p_peer_addr[4], data->p_peer_addr[3],
data->p_peer_addr[2], data->p_peer_addr[1], data->p_peer_addr[0]);
- item->addr = mp_obj_new_str(vstr.buf, vstr.len, false);
+ item->addr = mp_obj_new_str(vstr.buf, vstr.len);
vstr_clear(&vstr);
diff --git a/ports/unix/Makefile b/ports/unix/Makefile
index 1136c42b6..104ad3e5d 100644
--- a/ports/unix/Makefile
+++ b/ports/unix/Makefile
@@ -261,6 +261,9 @@ coverage_test: coverage
gcov -o build-coverage/py $(TOP)/py/*.c
gcov -o build-coverage/extmod $(TOP)/extmod/*.c
+coverage_clean:
+ $(MAKE) V=2 BUILD=build-coverage PROG=micropython_coverage clean
+
# Value of configure's --host= option (required for cross-compilation).
# Deduce it from CROSS_COMPILE by default, but can be overridden.
ifneq ($(CROSS_COMPILE),)
diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c
index 7820f6d73..841924c58 100644
--- a/ports/unix/coverage.c
+++ b/ports/unix/coverage.c
@@ -173,7 +173,7 @@ STATIC mp_obj_t extra_coverage(void) {
gc_unlock();
// using gc_realloc to resize to 0, which means free the memory
- void *p = gc_alloc(4, false);
+ void *p = gc_alloc(4, false, false);
mp_printf(&mp_plat_print, "%p\n", gc_realloc(p, 0, false));
// calling gc_nbytes with a non-heap pointer
diff --git a/py/binary.c b/py/binary.c
index bb334ed3d..4f02525d7 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -148,7 +148,7 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
#endif
#if MICROPY_PY_BUILTINS_FLOAT
case 'f':
- return mp_obj_new_float((mp_float_t)((float*)p)[index]);
+ return mp_obj_new_float(((float*)p)[index]);
case 'd':
return mp_obj_new_float(((double*)p)[index]);
#endif
@@ -213,7 +213,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) {
#if MICROPY_NONSTANDARD_TYPECODES
} else if (val_type == 'S') {
const char *s_val = (const char*)(uintptr_t)(mp_uint_t)val;
- return mp_obj_new_str(s_val, strlen(s_val), false);
+ return mp_obj_new_str(s_val, strlen(s_val));
#endif
#if MICROPY_PY_BUILTINS_FLOAT
} else if (val_type == 'f') {
diff --git a/py/frozenmod.c b/py/frozenmod.c
index 5464d0af9..a9143b582 100644
--- a/py/frozenmod.c
+++ b/py/frozenmod.c
@@ -43,8 +43,14 @@ extern const char mp_frozen_str_names[];
extern const uint32_t mp_frozen_str_sizes[];
extern const char mp_frozen_str_content[];
-// On input, *len contains size of name, on output - size of content
+// str_len is length of str. *len is set on on output to size of content
const char *mp_find_frozen_str(const char *str, size_t str_len, size_t *len) {
+ // If the frozen module pseudo dir (e.g., ".frozen/") is a prefix of str, remove it.
+ if (strncmp(str, MP_FROZEN_FAKE_DIR_SLASH, MP_FROZEN_FAKE_DIR_SLASH_LENGTH) == 0) {
+ str = str + MP_FROZEN_FAKE_DIR_SLASH_LENGTH;
+ str_len = str_len - MP_FROZEN_FAKE_DIR_SLASH_LENGTH;
+ }
+
const char *name = mp_frozen_str_names;
size_t offset = 0;
diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h
index a36404b8d..deac7107b 100644
--- a/py/objnamedtuple.h
+++ b/py/objnamedtuple.h
@@ -39,7 +39,7 @@
typedef struct _mp_obj_namedtuple_type_t {
mp_obj_type_t base;
- mp_uint_t n_fields;
+ size_t n_fields;
qstr fields[];
} mp_obj_namedtuple_type_t;
@@ -48,9 +48,9 @@ typedef struct _mp_obj_namedtuple_t {
} mp_obj_namedtuple_t;
void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
-
+size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr name);
void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
-
+mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *fields);
mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
#endif // MICROPY_PY_COLLECTIONS
diff --git a/shared-bindings/bleio/Adapter.c b/shared-bindings/bleio/Adapter.c
index 81efea54e..bfe87071d 100644
--- a/shared-bindings/bleio/Adapter.c
+++ b/shared-bindings/bleio/Adapter.c
@@ -86,7 +86,7 @@ STATIC mp_obj_t bleio_adapter_get_address(mp_obj_t self) {
common_hal_bleio_adapter_get_address(&vstr);
- const mp_obj_t mac_str = mp_obj_new_str(vstr.buf, vstr.len, false);
+ const mp_obj_t mac_str = mp_obj_new_str(vstr.buf, vstr.len);
vstr_clear(&vstr);
diff --git a/tests/import/mpy_invalid.py.exp b/tests/import/mpy_invalid.py.exp
index 1727ea1ce..e4f2b13e9 100644
--- a/tests/import/mpy_invalid.py.exp
+++ b/tests/import/mpy_invalid.py.exp
@@ -1,3 +1,3 @@
-mod0 ValueError incompatible .mpy file
-mod1 ValueError incompatible .mpy file
-mod2 ValueError incompatible .mpy file
+mod0 ValueError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.
+mod1 ValueError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.
+mod2 ValueError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.
diff --git a/tests/run-tests b/tests/run-tests
index 3064f6845..94e1591e8 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -396,7 +396,7 @@ def run_tests(pyb, tests, args, base_path=".", num_threads=1):
if pat.search(test_file):
verdict = action
if verdict == "exclude":
- continue
+ return
test_basename = os.path.basename(test_file)
test_name = os.path.splitext(test_basename)[0]
@@ -419,7 +419,7 @@ def run_tests(pyb, tests, args, base_path=".", num_threads=1):
if args.list_tests:
if not skip_it:
print(test_file)
- continue
+ return
if skip_it:
print("skip ", test_file)