From 30cfdc29edc7415f7d63be108f3312389c2df202 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 12 Nov 2016 03:24:36 +0300 Subject: tools/tinytest-codegen: Blacklist recently added uheapq_timeq test (qemu-arm). --- tools/tinytest-codegen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/tinytest-codegen.py b/tools/tinytest-codegen.py index 8e505f21a..3436d0f45 100755 --- a/tools/tinytest-codegen.py +++ b/tools/tinytest-codegen.py @@ -50,7 +50,7 @@ test_dirs = ('basics', 'micropython', 'float', 'extmod', 'inlineasm') # 'import' exclude_tests = ( 'float/float2int_doubleprec.py', # requires double precision floating point to work 'inlineasm/asmfpaddsub.py', 'inlineasm/asmfpcmp.py', 'inlineasm/asmfpldrstr.py', 'inlineasm/asmfpmuldiv.py', 'inlineasm/asmfpsqrt.py', - 'extmod/ticks_diff.py', 'extmod/time_ms_us.py', + 'extmod/ticks_diff.py', 'extmod/time_ms_us.py', 'extmod/uheapq_timeq.py', 'extmod/machine_pinbase.py', 'extmod/machine_pulse.py', 'extmod/vfs_fat_ramdisk.py', 'extmod/vfs_fat_fileio.py', 'extmod/vfs_fat_fsusermount.py', 'extmod/vfs_fat_oldproto.py', ) -- cgit v1.2.3 From 29b58796136e3c9133cd268b163db1c53e67ac9b Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 15 Dec 2016 11:29:33 +1100 Subject: tools/pyboard.py: Refactor so target is not reset between scripts/cmd. Previous to this patch pyboard.py would open a new serial connection to the target for each script that was run, and for any command that was run. Apart from being inefficient, this meant that the board was soft-reset between scripts/commands, which precludes scripts from accessing variables set in a previous one. This patch changes the behaviour of pyboard.py so that the connection to the target is created only once, and it's not reset between scripts or any command that is sent with the -c option. --- tools/pyboard.py | 63 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 20 deletions(-) (limited to 'tools') diff --git a/tools/pyboard.py b/tools/pyboard.py index 925e16bc6..d4ce8b788 100755 --- a/tools/pyboard.py +++ b/tools/pyboard.py @@ -285,43 +285,66 @@ def main(): cmd_parser.add_argument('files', nargs='*', help='input files') args = cmd_parser.parse_args() - def execbuffer(buf): + # open the connection to the pyboard + try: + pyb = Pyboard(args.device, args.baudrate, args.user, args.password, args.wait) + except PyboardError as er: + print(er) + sys.exit(1) + + # run any command or file(s) + if args.command is not None or len(args.files): + # we must enter raw-REPL mode to execute commands + # this will do a soft-reset of the board try: - pyb = Pyboard(args.device, args.baudrate, args.user, args.password, args.wait) pyb.enter_raw_repl() - ret, ret_err = pyb.exec_raw(buf, timeout=None, data_consumer=stdout_write_bytes) - pyb.exit_raw_repl() - pyb.close() except PyboardError as er: print(er) sys.exit(1) - except KeyboardInterrupt: - sys.exit(1) - if ret_err: - stdout_write_bytes(ret_err) - sys.exit(1) - - if args.command is not None: - execbuffer(args.command.encode('utf-8')) - - for filename in args.files: - with open(filename, 'rb') as f: - pyfile = f.read() - execbuffer(pyfile) + def execbuffer(buf): + try: + ret, ret_err = pyb.exec_raw(buf, timeout=None, data_consumer=stdout_write_bytes) + except PyboardError as er: + print(er) + sys.exit(1) + except KeyboardInterrupt: + sys.exit(1) + if ret_err: + pyb.exit_raw_repl() + pyb.close() + stdout_write_bytes(ret_err) + sys.exit(1) + + # run the command, if given + if args.command is not None: + execbuffer(args.command.encode('utf-8')) + + # run any files + for filename in args.files: + with open(filename, 'rb') as f: + pyfile = f.read() + execbuffer(pyfile) + + # exiting raw-REPL just drops to friendly-REPL mode + pyb.exit_raw_repl() + + # if asked explicitly, or no files given, then follow the output if args.follow or (args.command is None and len(args.files) == 0): try: - pyb = Pyboard(args.device, args.baudrate, args.user, args.password, args.wait) ret, ret_err = pyb.follow(timeout=None, data_consumer=stdout_write_bytes) - pyb.close() except PyboardError as er: print(er) sys.exit(1) except KeyboardInterrupt: sys.exit(1) if ret_err: + pyb.close() stdout_write_bytes(ret_err) sys.exit(1) + # close the connection to the pyboard + pyb.close() + if __name__ == "__main__": main() -- cgit v1.2.3 From 98458a46ec9c34fa59dbfa7c9189b7e181e5e7a3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 5 Jan 2017 15:52:52 +1100 Subject: tools/mpy-tool.py: Add support for OPT_CACHE_MAP_LOOKUP_IN_BYTECODE. With caching of map lookups in the bytecode, frozen bytecode can still work but must be stored in RAM, not ROM. This patch allows mpy-tool.py to generate code that works with this optimisation, but it's not recommended to use it on embedded targets (because of lack of RAM). --- tools/mpy-tool.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 2bb9fc367..ce373a4f5 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -258,7 +258,10 @@ class RawCode: # generate bytecode data print() print('// frozen bytecode for file %s, scope %s%s' % (self.source_file.str, parent_name, self.simple_name.str)) - print('STATIC const byte bytecode_data_%s[%u] = {' % (self.escaped_name, len(self.bytecode))) + print('STATIC ', end='') + if not config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE: + print('const ', end='') + print('byte bytecode_data_%s[%u] = {' % (self.escaped_name, len(self.bytecode))) print(' ', end='') for i in range(self.ip2): print(' 0x%02x,' % self.bytecode[i], end='') @@ -463,8 +466,8 @@ def freeze_mpy(base_qstrs, raw_codes): print('#include "py/emitglue.h"') print() - print('#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE') - print('#error "MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE not supported with frozen mpy files"') + print('#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE != %u' % config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) + print('#error "incompatible MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE"') print('#endif') print() -- cgit v1.2.3