问题描述
代码片段
time_label = lv.label(page_1)
time_label.set_pos(298, -16)
time_label.set_size(204, 82)
time_label.set_text("12:00")
time_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, lv.PART.MAIN | lv.STATE.DEFAULT)
if time_big_font:
time_label.set_style_text_font(time_big_font, lv.PART.MAIN | lv.STATE.DEFAULT)
t2=lv.timer_create(update_time ,30000 , None) # 每30秒更新一次时间显示
def update_time(timer):
label_time = _ui_refs.get('time_label')
label_date = _ui_refs.get('date_label')
time_string1 = "{:02d}:{:02d}".format(rtc.datetime()[4], rtc.datetime()[5])
time_string2 = "{:04d}-{:02d}-{:02d} 星期{}".format(rtc.datetime()[0], rtc.datetime()[1], rtc.datetime()[2], "日一二三四五六"[rtc.datetime()[3]])
label_time.set_text(time_string1)
label_date.set_text(time_string2)
gc.collect()
实际在运行过程中,定时器更新50多次后就会完全卡住,运行过程无报错,其他部分均根据例程编写
硬件板卡
创乐博CanMV K230 V3.0
软件版本
CanMV_K230_V3P0_micropython_v1.5-legacy-0-g413737f_nncase_v2.9.0.img.gz
其他信息
调用
micropython.mem_info()
micropython.qstr_info()
输出的内容基本无问题
stack: 1516 out of 130560
GC: total: 4145664, used: 171008, free: 3974656, max new split: 0
No. of 1-blocks: 805, 2-blocks: 182, max blk sz: 460, max free sz: 121977
qstr pool: n_pool=4, n_qstr=231, n_str_data_bytes=2332, n_total_bytes=5884
串口0
[E/DBG] User Fault, killing thread: preload
[mpy] exit, reset
[mpy] enter repl
[I/WLAN.mgnt] wifi connect success ssid:lwifi
[I/WLAN.lwip] Got IP address : 192.168.137.245
[I/ntp] Get local time from NTP server: Thu Feb 26 17:19:12 2026
[fw_display]: Auto-rotating to 90 deg (Req: 800x480, Phys: 480x800)
panel is rotated, we only need one osd buffer
[Error] (79.242, +79242) freetpye_face_requester: FT_New_Face error(1) (in lv_freetype.c line #241)
[Error] (79.251, +9) freetype_get_glyph_dsc_cb: FTC_Manager_LookupSize error(1) (in lv_freetype.c line #314)
(header_ptr->magic & RT_MEMHEAP_USED) assertion failed at function:rt_memheap_free, line number:516
riscv64-unknown-linux-musl-addr2line -e rtthread.elf -a -f 00000000001c0cea
字体部分调用
def get_font(font_path, font_size):
global _font_cache
if font_path == "montserrat":
size = max(12, min(48, (font_size // 2) * 2))
return getattr(lv, f"font_montserrat_{size}", None)
cache_key = f"{font_path}_{font_size}"
if cache_key in _font_cache:
return _font_cache[cache_key]
try:
font = lv.freetype_font_create(font_path, font_size, 0)
if font:
_font_cache[cache_key] = font
return font
except Exception as e:
print(f"[ERROR] Font load failed: {font_path}, {e}")
return None
info_font = get_font(FONT_PATH, 20)
bind_font = get_font(FONT_PATH, 16)
name_font = get_font(FONT_PATH, 24)
time_big_font = get_font(FONT_PATH, 64)
remind_font = get_font(FONT_PATH, 32)
完整文件
https://wwbcz.lanzoul.com/inr4G3j90wla
补充报错信息
[I/WLAN.mgnt] wifi is connect ssid:leowifi
[I/ntp] Get local time from NTP server: Sat Feb 28 17:14:29 2026
[mpy] exit, reset
[fw_display]: Auto-rotating to 90 deg (Req: 800x480, Phys: 480x800)
panel is rotated, we only need one osd buffer
[DHCP] dhcpd_stop: w0
[I/WLAN.mgnt] wifi connect success ssid:leowifi
[I/WLAN.lwip] Got IP address : 192.168.137.45
[Error] (413.162, +413162) freetpye_face_requester: FT_New_Face error(1) (in lv_freetype.c line #241)
[Error] (413.170, +8) freetype_get_glyph_dsc_cb: FTC_Manager_LookupSize error(1) (in lv_freetype.c line #314)
[E/DBG] [FATAL ERROR] Exception 13:Load Page Fault
[E/DBG] scause:0x000000000000000d,stval:0x000000736e61536e,sepc:0x00000000001f609e
--------------Dump Registers-----------------
Function Registers:
ra(x1) = 0x0000000000220e7c()
user_sp(x2) = 0x0000000000745e38()
gp(x3) = 0x000000000045f5a0()
tp(x4) = 0x000000010042cbd8()
Temporary Registers:
t0(x5) = 0x000000020059d6c2()
t1(x6) = 0x000000000046ef80()
t2(x7) = 0x0000000000746380()
t3(x28) = 0x0000000000000072()
t4(x29) = 0x000000000000001f()
t5(x30) = 0x0000000000000003()
t6(x31) = 0x0000000000000003()
Saved Registers:
s0/fp(x8) = 0x000000000058dcf0()
s1(x9) = 0x000000000076bf60()
s2(x18) = 0x0000000000b1ea40()
s3(x19) = 0x0000000000020000()
s4(x20) = 0x0000000000b1ea40()
s5(x21) = 0x0000000000000030()
s6(x22) = 0x0000000100044020()
s7(x23) = 0x0000000000000032()
s8(x24) = 0x0000000000000000()
s9(x25) = 0x0000000000000001()
s10(x26) = 0x0000000000000001()
s11(x27) = 0x0000000200e63848()
Function Arguments Registers:
a0(x10) = 0x0000000000b1ea40()
a1(x11) = 0x2e4353736e61536e()
a2(x12) = 0x0000000000b1ea5b()
a3(x13) = 0x000000000058dc30()
a4(x14) = 0x000000000058dcf0()
a5(x15) = 0x000000000000002f()
a6(x16) = 0x000000000000002f()
a7(x17) = 0x0000000000202dba()
sstatus = 0x8000000200044720
Supervisor Interrupt Disabled
Last Time Supervisor Interrupt Enabled
Last Privilege is Supervisor Mode
Permit to Access User Page
Not Permit to Read Executable-only Page
satp = 0x800000000001fffb
Current Page Table(Physical) = 0x000000001fffb000
Current ASID = 0x0000000000000000
Mode = Page-based 39-bit Virtual Addressing Mode
-----------------Dump OK---------------------
riscv64-unknown-linux-musl-addr2line -e rtthread.elf -a -f 00000000001f609a
[E/DBG] User Fault, killing thread: preload
补充 字体文件名SourceHanSansSC.ttf