From 92e97f4311758ea6d332fec63800cb46d6fe1518 Mon Sep 17 00:00:00 2001 From: elect-gombe <13552050+elect-gombe@users.noreply.github.com> Date: Wed, 18 Sep 2019 18:20:47 +0900 Subject: [PATCH 1/7] [Add] Support MaixPy (main.c) - fix epc bug in the function. - update sbi_call function to support all needed machine register - add usermode variable for accessing machine register. --- projects/mmu_code/main/src/main.c | 214 +++++++++++++++++++----------- 1 file changed, 138 insertions(+), 76 deletions(-) diff --git a/projects/mmu_code/main/src/main.c b/projects/mmu_code/main/src/main.c index d90b6d13d..efda8a794 100644 --- a/projects/mmu_code/main/src/main.c +++ b/projects/mmu_code/main/src/main.c @@ -10,17 +10,18 @@ #include "stdlib.h" #include "fpioa.h" #include "dump.h" +#include "dmac.h" #include "w25qxx.h" #include "printf.h" #include "sysctl.h" -#define print printk2 //no core lock - +int usermode=0; +int printk2(const char *format, ...); +#define print printk2 //no core lock #define INSERT_FIELD(val, which, fieldval) (((val) & ~(which)) | ((fieldval) * ((which) & ~((which)-1)))) - #define CE_TEXT_FLASH __attribute__((section(".text_flash"))) #define CE_RODATA_FLASH __attribute__((section(".rodata_flash"))) @@ -37,7 +38,7 @@ #define CE_CACHE_VA_SPACE_SIZE_IN_PAGES (CE_CACHE_VA_SPACE_SIZE_IN_BLOCKS * CE_BLOCK_SIZE_IN_PAGES) #define CE_CACHE_VA_SPACE_SIZE (CE_CACHE_VA_SPACE_SIZE_IN_PAGES * CE_PAGE_SIZE) -#define CE_CACHE_SIZE_IN_BLOCKS ((3072 / 4) / CE_BLOCK_SIZE_IN_PAGES) +#define CE_CACHE_SIZE_IN_BLOCKS ((128 / 4) / CE_BLOCK_SIZE_IN_PAGES) #define CE_CACHE_SIZE_IN_PAGES (CE_CACHE_SIZE_IN_BLOCKS * CE_BLOCK_SIZE_IN_PAGES) uint64_t volatile __attribute__((aligned(CE_PAGE_SIZE))) ceLv1PageTable[(CE_PAGE_SIZE / 8) * (1)]; @@ -85,15 +86,17 @@ void CE_TEXT_FLASH test2() aaa = bbb; // print(ccc); uarths_putchar('a'); - // uarths_putchar('a'); - // uarths_putchar('a'); - // uarths_putchar('a'); - // uarths_putchar('\r'); - // uarths_putchar('\n'); + uarths_putchar('a'); + uarths_putchar('a'); + uarths_putchar('a'); + uarths_putchar('\r'); + uarths_putchar('\n'); } void ceSetupMMU() { + asm volatile ("la t0,mretdist"); + asm volatile ("csrw mepc,t0"); CE_DEBUG_PRINT("setup mmu...\r\n"); //0 - 3GiB -> mirror to phys @@ -115,11 +118,12 @@ void ceSetupMMU() { msValue |= ((uint64_t)VM_SV39 << 24);// M S U mode, SV39 msValue = INSERT_FIELD(msValue, MSTATUS_MPRV, 1); msValue = INSERT_FIELD(msValue, MSTATUS_MPP, PRV_U); - printk("set mstatus:%x\r\n", msValue); + // print("set mstatus:%x\r\n", msValue); write_csr(mstatus, msValue); ceResetCacheState(); asm volatile ("mret"); + asm volatile ("mretdist:"); } static inline uint32_t ceVAddrToVBlockId(uintptr_t vaddr) { @@ -243,25 +247,6 @@ static inline int supports_extension(char ext) return read_csr(misa) & (1 << (ext - 'A')); } -#define SBI_GET_HARTID 0x01 -#define SBI_GET_CYCLE 0x02 - -#define SBI_CALL(which, arg0, arg1, arg2) ({ \ - register uintptr_t a0 asm ("a0") = (uintptr_t)(arg0); \ - register uintptr_t a1 asm ("a1") = (uintptr_t)(arg1); \ - register uintptr_t a2 asm ("a2") = (uintptr_t)(arg2); \ - register uintptr_t a7 asm ("a7") = (uintptr_t)(which); \ - asm volatile ("ecall" \ - : "+r" (a0) \ - : "r" (a1), "r" (a2), "r" (a7) \ - : "memory"); \ - a0; \ -}) - -/* Lazy implementations until SBI is finalized */ -#define SBI_CALL_0(which) SBI_CALL(which, 0, 0, 0) -#define SBI_CALL_1(which, arg0) SBI_CALL(which, arg0, 0, 0) -#define SBI_CALL_2(which, arg0, arg1) SBI_CALL(which, arg0, arg1, 0) uint64_t sbi_ticks_us(void) { @@ -269,40 +254,25 @@ uint64_t sbi_ticks_us(void) } - +int mpymain() ; int main() { fpioa_set_function(4, FUNC_UARTHS_RX); - fpioa_set_function(5, FUNC_UARTHS_TX); + fpioa_set_function(5, FUNC_UARTHS_TX); uarths_init(); - uarths_config(115200, 1); + uarths_config(115200, 1); + print("m:%p\n",malloc(10)); //fix me. bug exist + ceSetupMMU(); + usermode = 1; + uint8_t manuf_id, device_id; w25qxx_init_dma(3, 0); - w25qxx_enable_quad_mode_dma(); - w25qxx_read_id_dma(&manuf_id, &device_id); + w25qxx_enable_quad_mode_dma(); + w25qxx_read_id_dma(&manuf_id, &device_id); print("flash id:%x %x\r\n",manuf_id, device_id); - - - int status = read_csr(mstatus); - print("status:0x%x\r\n", status); - int e = supports_extension('D'); - int f = supports_extension('F'); - int s = supports_extension('S'); - print("e:%d %d %d\r\n", e, f, s); - - ceSetupMMU(); int a = 5; - - uarths_putchar('1'); - uarths_putchar('1'); - uarths_putchar('1'); - uarths_putchar('1'); - uarths_putchar('\r'); - uarths_putchar('\n'); - - { print("%p\r\n", &a); print("--%p\r\n", test); @@ -313,6 +283,7 @@ int main() print("--putchar time:%d\r\n", sbi_ticks_us() - t); bbb = (int)sbi_ticks_us(); t = sbi_ticks_us(); + test(); test2(); print("--time: %dus %dus %d\r\n", flash_read_time, sbi_ticks_us() - t, aaa); print("%d %d %d %d\r\n", test_data[0], test_data[1], test_data[2], test_data[3]); @@ -320,20 +291,38 @@ int main() } print("test end\r\n"); print("test2\r\n"); - // int core = read_csr(mstatus); // U mode, can not read mstatus - int core = SBI_CALL_0(SBI_GET_HARTID); + // int core = read_csr(mstatus); // U mode, can not read mstatus + int core = get_hartid(); print("sbi ret:%x\r\n", core); print("test2 end\r\n"); - + mpymain(); while(1){} } +unsigned long long sbi_call(unsigned long long which,unsigned long long arg0,unsigned long long arg1,unsigned long long arg2,const char *func,int line){ + unsigned long long res=0; + // printk2("[%20s]:%4d which:%2x(%x)==>",func,line,which,arg0); + + if(usermode){ + // printk2("[u]"); + res = SBI_CALL(which,arg0,arg1,arg2); + }else{ + // printk2("[m]"); + res = handlecsr(which,arg0); + } + // printk2("%x\n",res); + return res; +} + uintptr_t handle_fault_load(uintptr_t cause, uintptr_t epc, uintptr_t regs[32], uintptr_t fregs[32]) { print("fault load\r\n"); + int pu = usermode;//save previous mode + usermode = 0; uintptr_t badAddr = read_csr(mbadaddr); if ((badAddr >= ceVABase) && (badAddr < (ceVABase + CE_CACHE_VA_SPACE_SIZE))) { if (ceHandlePageFault(badAddr, 0) == 0) { - return epc; + usermode = pu; + return epc; } } sys_exit(1337); @@ -343,11 +332,14 @@ uintptr_t handle_fault_load(uintptr_t cause, uintptr_t epc, uintptr_t regs[32], uintptr_t handle_fault_fetch(uintptr_t cause, uintptr_t epc, uintptr_t regs[32], uintptr_t fregs[32]) // uintptr_t handle_illegal_instruction(uintptr_t cause, uintptr_t epc, uintptr_t regs[32], uintptr_t fregs[32]) { + int pu = usermode; print("fault fetch\r\n"); + usermode = 0; // uintptr_t badAddr = read_csr(mbadaddr); if ((epc >= ceVABase) && (epc < (ceVABase + CE_CACHE_VA_SPACE_SIZE))) { if (ceHandlePageFault(epc, 0) == 0) { - return epc; + usermode = pu; + return epc; } } dump_core("illegal instruction", cause, epc, regs, fregs); @@ -355,30 +347,100 @@ uintptr_t handle_fault_fetch(uintptr_t cause, uintptr_t epc, uintptr_t regs[32], return epc; } +unsigned long long handlecsr(unsigned long long cmd,unsigned long long arg0){ + switch (cmd) + { + case SBI_GET_HARTID: + { + int core = read_csr(mhartid); + arg0 = core;//a0=coreid + break; + } + case SBI_GET_CYCLE: + { + int cycle = read_csr(mcycle); + arg0 = cycle;//a0=cycle + break; + } + case SBI_GET_MIE: + { + int ie = read_csr(mie); + arg0 = ie;//a0=cycle + break; + } + case SBI_SET_MIE: + { + set_csr(mie,arg0); + break; + } + case SBI_CLR_MIE: + { + clear_csr(mie,arg0); + break; + } + case SBI_WRI_MIE: + { + write_csr(mie,arg0); + break; + } + case SBI_GET_STATUS: + { + int status = read_csr(mstatus); + arg0 = status;//a0=cycle + break; + } + case SBI_SET_STATUS: + { + set_csr(mstatus,arg0); + break; + } + case SBI_CLR_STATUS: + { + clear_csr(mstatus,arg0); + break; + } + case SBI_GET_MIP: + { + int ip = read_csr(mip); + arg0 = ip;//a0=ip + break; + } + case SBI_SET_MIP: + { + set_csr(mip,arg0); + break; + } + case SBI_CLR_MIP: + { + clear_csr(mip,arg0); + break; + } + case SBI_GET_INSTRET: + { + int instret = read_csr(minstret); + arg0 = instret;//a0=minstret + break; + } + default: + break; + } + return arg0; +} + uintptr_t handle_ecall_u(uintptr_t cause, uintptr_t epc, uintptr_t regs[32], uintptr_t fregs[32]) { register uintptr_t cmd asm ("a7");//get cmd from a7 - switch (cmd) - { - case SBI_GET_HARTID: - { - int core = read_csr(mhartid); - regs[10] = core;//a0=coreid - break; - } - case SBI_GET_CYCLE: - { - int cycle = read_csr(mcycle); - regs[10] = cycle;//a0=cycle - break; - } - default: - break; - } + + regs[10] = handlecsr(cmd,regs[10]); //regs[0]->$a0 return epc+4; } +#include "maixpy.h" - +int mpymain() +{ + maixpy_main(); + return 0; +} From 715f0e475aefe3c5ba685e75dd07ec6376d8961e Mon Sep 17 00:00:00 2001 From: elect-gombe <13552050+elect-gombe@users.noreply.github.com> Date: Wed, 18 Sep 2019 18:23:29 +0900 Subject: [PATCH 2/7] Use python3 for Ubuntu users --- projects/mmu_code/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 projects/mmu_code/project.py diff --git a/projects/mmu_code/project.py b/projects/mmu_code/project.py old mode 100644 new mode 100755 index 2396fec20..2d7184231 --- a/projects/mmu_code/project.py +++ b/projects/mmu_code/project.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 #-*- coding = utf-8 -*- import sys, os From 5ce007b1f1c36ae59e6a23d072c640ef4c35cb3f Mon Sep 17 00:00:00 2001 From: elect-gombe <13552050+elect-gombe@users.noreply.github.com> Date: Wed, 18 Sep 2019 18:24:35 +0900 Subject: [PATCH 3/7] Add micropython to this CMake project --- projects/mmu_code/compile/priority.conf | 1 + projects/mmu_code/main/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/mmu_code/compile/priority.conf b/projects/mmu_code/compile/priority.conf index 74b996db2..43e5a3c0c 100644 --- a/projects/mmu_code/compile/priority.conf +++ b/projects/mmu_code/compile/priority.conf @@ -5,6 +5,7 @@ kendryte_sdk drivers spiffs boards +micropython main diff --git a/projects/mmu_code/main/CMakeLists.txt b/projects/mmu_code/main/CMakeLists.txt index 39d2ba825..0cbc6536f 100644 --- a/projects/mmu_code/main/CMakeLists.txt +++ b/projects/mmu_code/main/CMakeLists.txt @@ -12,7 +12,7 @@ list(APPEND ADD_SRCS "src/main.c" ############################################### ###### Add required/dependent components ###### -list(APPEND ADD_REQUIREMENTS kendryte_sdk drivers boards) +list(APPEND ADD_REQUIREMENTS kendryte_sdk drivers boards micropython) ############################################### ############ Add static libs ################## From f6d02f4156ca9774542526bdde58004586214cf8 Mon Sep 17 00:00:00 2001 From: elect-gombe <13552050+elect-gombe@users.noreply.github.com> Date: Wed, 18 Sep 2019 18:26:35 +0900 Subject: [PATCH 4/7] Update compile flags - Add extra debug information for better disassembly - Add -Wl,--no-relax to suppress compile error --- projects/mmu_code/compile/compile_flags.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/mmu_code/compile/compile_flags.cmake b/projects/mmu_code/compile/compile_flags.cmake index 7f0014733..eb7c6540f 100644 --- a/projects/mmu_code/compile/compile_flags.cmake +++ b/projects/mmu_code/compile/compile_flags.cmake @@ -38,6 +38,8 @@ set(CMAKE_C_FLAGS -mcmodel=medany -Wno-error=restrict -Wno-error=sequence-point -Wno-int-to-pointer-cast + -Wl,--no-relax + -g3 ) ################################ @@ -75,6 +77,8 @@ set(CMAKE_CXX_FLAGS -mcmodel=medany -Wno-error=restrict -Wno-error=sequence-point -Wno-int-to-pointer-cast + -Wl,--no-relax + -g3 ) ################################ @@ -83,6 +87,7 @@ set(LINK_FLAGS ${LINK_FLAGS} -Wl,-static -nostartfiles -Wl,--gc-sections + -Wl,--no-relax -Wl,-EL -T ${PROJECT_SOURCE_DIR}/compile/kendryte.ld -Wl,--start-group From 5ddfa783fd37cbf4c3ee5e840aa5fb923d00f6ca Mon Sep 17 00:00:00 2001 From: elect-gombe <13552050+elect-gombe@users.noreply.github.com> Date: Fri, 27 Sep 2019 21:55:06 +0900 Subject: [PATCH 5/7] Support usermode csrr access functions --- .gitmodules | 6 +++--- components/kendryte_sdk/kendryte-standalone-sdk | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index ab8503e6b..5fc4f1c64 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "tools/kconfig/Kconfiglib"] path = tools/kconfig/Kconfiglib url = https://github.com/ulfalizer/Kconfiglib.git -[submodule "components/kendryte_sdk/kendryte-standalone-sdk"] - path = components/kendryte_sdk/kendryte-standalone-sdk - url = https://github.com/sipeed/kendryte-standalone-sdk [submodule "tools/flash/kflash_py"] path = tools/flash/kflash_py url = https://github.com/sipeed/kflash.py.git @@ -20,3 +17,6 @@ [submodule "tools/spiffs/mkspiffs"] path = tools/spiffs/mkspiffs url = https://github.com/igrr/mkspiffs.git +[submodule "components/kendryte_sdk/kendryte-standalone-sdk"] + path = components/kendryte_sdk/kendryte-standalone-sdk + url = https://github.com/elect-gombe/kendryte-standalone-sdk.git diff --git a/components/kendryte_sdk/kendryte-standalone-sdk b/components/kendryte_sdk/kendryte-standalone-sdk index e4741de52..63e8badac 160000 --- a/components/kendryte_sdk/kendryte-standalone-sdk +++ b/components/kendryte_sdk/kendryte-standalone-sdk @@ -1 +1 @@ -Subproject commit e4741de522408d712f659e01fdc2b6d3efdf7e91 +Subproject commit 63e8badac1933edaec2b98da0ba9998e762bd6af From 8069ed517e8bc54310cb2b1097323460eb5e3373 Mon Sep 17 00:00:00 2001 From: elect-gombe <13552050+elect-gombe@users.noreply.github.com> Date: Fri, 27 Sep 2019 22:01:16 +0900 Subject: [PATCH 6/7] Use new csr access functions for usermode. --- components/kendryte_sdk/src/sipeed_i2c.c | 2 +- .../micropython/port/include/mphalport.h | 2 ++ components/micropython/port/src/maixpy_main.c | 18 +++++++++--------- .../src/modules/ultrasonic/src/ultrasonic.c | 2 +- components/micropython/port/src/mphalport.c | 6 +++--- .../micropython/port/src/video/video_hal.c | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/components/kendryte_sdk/src/sipeed_i2c.c b/components/kendryte_sdk/src/sipeed_i2c.c index cca8ab09b..8e9fcb681 100644 --- a/components/kendryte_sdk/src/sipeed_i2c.c +++ b/components/kendryte_sdk/src/sipeed_i2c.c @@ -89,7 +89,7 @@ void maix_i2c_init_as_slave(i2c_device_number_t i2c_num, uint32_t slave_address, is_master_mode[i2c_num] = false; } -#define time_ms() (unsigned long)(read_csr(mcycle)/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000)) +#define time_ms() (unsigned long)(get_cycle()/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000)) /** * diff --git a/components/micropython/port/include/mphalport.h b/components/micropython/port/include/mphalport.h index e1cad48ce..f671a7678 100644 --- a/components/micropython/port/include/mphalport.h +++ b/components/micropython/port/include/mphalport.h @@ -14,6 +14,8 @@ extern ringbuf_t stdin_ringbuf; extern TaskHandle_t mp_main_task_handle; #endif +#define mp_hal_stdio_poll(poll_flags) (0) + //uint32_t mp_hal_ticks_us(void); //uint32_t mp_hal_ticks_ms(void); //uint32_t mp_hal_ticks_cpu(void); diff --git a/components/micropython/port/src/maixpy_main.c b/components/micropython/port/src/maixpy_main.c index 67c1b6ddf..554738925 100644 --- a/components/micropython/port/src/maixpy_main.c +++ b/components/micropython/port/src/maixpy_main.c @@ -316,14 +316,14 @@ void load_config_from_spiffs(config_data_t* config) SPIFFS_close(&spiffs_user_mount_handle.fs, fd); } -#if MICROPY_ENABLE_COMPILER +#if MICROPY_ENABLE_COMPILER void pyexec_str(vstr_t* str) { nlr_buf_t nlr; if (nlr_push(&nlr) == 0) { mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, str->buf, str->len, 0); qstr source_name = lex->source_name; mp_parse_tree_t parse_tree = mp_parse(lex, MP_PARSE_FILE_INPUT); - mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true); + mp_obj_t module_fun = mp_compile(&parse_tree, source_name, true); mp_call_function_0(module_fun); nlr_pop(); } else { @@ -526,18 +526,17 @@ int maixpy_main() sysctl_clock_enable(SYSCTL_CLOCK_AI); sysctl_set_power_mode(SYSCTL_POWER_BANK6, SYSCTL_POWER_V18); sysctl_set_power_mode(SYSCTL_POWER_BANK7, SYSCTL_POWER_V18); - sysctl_enable_irq(); + sysctl_enable_irq(); rtc_init(); rtc_timer_set(2019,1, 1,0, 0, 0); - flash_init(&manuf_id, &device_id); printk("[MAIXPY]Flash:0x%02x:0x%02x\r\n", manuf_id, device_id); - /* Init SPI IO map and function settings */ - sysctl_set_spi0_dvp_data(1); + /* Init SPI IO map and function settings */ + sysctl_set_spi0_dvp_data(1); /* open core 1 */ printk("open second core...\r\n"); - register_core1(core1_function, 0); + register_core1(core1_function, 0); -#if MICROPY_PY_THREAD +#if MICROPY_PY_THREAD xTaskCreateAtProcessor(0, // processor mp_task, // function entry "mp_task", //task name @@ -552,13 +551,14 @@ int maixpy_main() #endif return 0; } + void do_str(const char *src, mp_parse_input_kind_t input_kind) { nlr_buf_t nlr; if (nlr_push(&nlr) == 0) { mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); qstr source_name = lex->source_name; mp_parse_tree_t parse_tree = mp_parse(lex, input_kind); - mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true); + mp_obj_t module_fun = mp_compile(&parse_tree, source_name, true); mp_call_function_0(module_fun); nlr_pop(); } else { diff --git a/components/micropython/port/src/modules/ultrasonic/src/ultrasonic.c b/components/micropython/port/src/modules/ultrasonic/src/ultrasonic.c index 2cd5b9c67..256239a5c 100644 --- a/components/micropython/port/src/modules/ultrasonic/src/ultrasonic.c +++ b/components/micropython/port/src/modules/ultrasonic/src/ultrasonic.c @@ -6,7 +6,7 @@ #include "sysctl.h" #include "printf.h" -#define time_us() (unsigned long)(read_csr(mcycle)/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000)) +#define time_us() (unsigned long)(get_cycle()/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000)) typedef void (*set_pin_func_t)(uint8_t gpio, gpio_pin_value_t value); typedef gpio_pin_value_t (*get_pin_func_t)(uint8_t gpio); diff --git a/components/micropython/port/src/mphalport.c b/components/micropython/port/src/mphalport.c index 5349ba0a2..ff273181b 100644 --- a/components/micropython/port/src/mphalport.c +++ b/components/micropython/port/src/mphalport.c @@ -67,17 +67,17 @@ void mp_hal_debug_tx_strn_cooked(void *env, const char *str, size_t len) { mp_uint_t inline mp_hal_ticks_cpu(void) { - return (unsigned long)(read_csr(mcycle)); + return (unsigned long)(get_cycle()); } mp_uint_t inline mp_hal_ticks_us(void) { - return (unsigned long)(read_csr(mcycle)/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000)); + return (unsigned long)(get_cycle()/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000)); } mp_uint_t inline mp_hal_ticks_ms(void) { - return (unsigned long)(read_csr(mcycle)/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000)); + return (unsigned long)(get_cycle()/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000)); } void mp_hal_delay_ms(mp_uint_t ms) diff --git a/components/micropython/port/src/video/video_hal.c b/components/micropython/port/src/video/video_hal.c index 305976982..f35e5c60e 100644 --- a/components/micropython/port/src/video/video_hal.c +++ b/components/micropython/port/src/video/video_hal.c @@ -62,7 +62,7 @@ int video_hal_display(image_t* img, video_display_roi_t img_roi) uint64_t inline video_hal_ticks_us(void) { - return (uint64_t)(read_csr(mcycle)/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000)); + return (uint64_t)(get_cycle()/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000)); } From 98b3bc1b899a7957276ee769ec4b94d5b2b8650c Mon Sep 17 00:00:00 2001 From: elect-gombe <13552050+elect-gombe@users.noreply.github.com> Date: Fri, 27 Sep 2019 22:22:08 +0900 Subject: [PATCH 7/7] Fix mp_compile missing parameter caused by submodule version difference. --- components/micropython/port/src/maixpy_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/micropython/port/src/maixpy_main.c b/components/micropython/port/src/maixpy_main.c index 554738925..12f0caad4 100644 --- a/components/micropython/port/src/maixpy_main.c +++ b/components/micropython/port/src/maixpy_main.c @@ -323,7 +323,7 @@ void pyexec_str(vstr_t* str) { mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, str->buf, str->len, 0); qstr source_name = lex->source_name; mp_parse_tree_t parse_tree = mp_parse(lex, MP_PARSE_FILE_INPUT); - mp_obj_t module_fun = mp_compile(&parse_tree, source_name, true); + mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true); mp_call_function_0(module_fun); nlr_pop(); } else { @@ -558,7 +558,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) { mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); qstr source_name = lex->source_name; mp_parse_tree_t parse_tree = mp_parse(lex, input_kind); - mp_obj_t module_fun = mp_compile(&parse_tree, source_name, true); + mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true); mp_call_function_0(module_fun); nlr_pop(); } else {