diff options
author | David Lechner <david@pybricks.com> | 2019-06-27 13:36:15 -0500 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-07-03 01:19:41 +1000 |
commit | 62b00dd5d8cd6207147d37222e1c249ef6381841 (patch) | |
tree | 4bbcd49804ae1b0a4dba97db0168354183e93d31 | |
parent | 08075beeb9b45557f8ed6970e4e3e4a00bd26879 (diff) |
py/asmarm: Use __clear_cache on Linux/GCC when creating new asm code.
Comes from https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/caches-and-self-modifying-code
This fixes a crash when running MicroPython using qemu-arm.
-rw-r--r-- | py/asmarm.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/py/asmarm.c b/py/asmarm.c index f2221f8a9..2a84f985b 100644 --- a/py/asmarm.c +++ b/py/asmarm.c @@ -40,7 +40,11 @@ void asm_arm_end_pass(asm_arm_t *as) { if (as->base.pass == MP_ASM_PASS_EMIT) { -#ifdef __arm__ +#if defined(__linux__) && defined(__GNUC__) + char *start = mp_asm_base_get_code(&as->base); + char *end = start + mp_asm_base_get_code_size(&as->base); + __clear_cache(start, end); +#elif defined(__arm__) // flush I- and D-cache asm volatile( "0:" |