fix(usb): show USB update and enter the loader after confirm

Bump firmware to 0.2.30. The 11px font now has the update glyphs, and the flashed boot image stays in USB programming when that mode is saved.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yuquanjun 2026-09-25 20:33:26 +08:00
parent 4063bab4b5
commit 1cc4d400ef
10 changed files with 2109 additions and 1270 deletions

View File

@ -131,7 +131,7 @@ static void Boot_NvmClearUsbUpdate(void)
memcpy(buf, &tmp, sizeof(tmp));
words = (sizeof(tmp) + 3) / 4;
flash_unlock();
flash_sector_erase(INNER_FLASH_SAVE_ADDRESS);
flash_sector_erase(INNER_FLASH_SECTOR_ADDRESS);
for (i = 0; i < words; i++)
flash_word_program(INNER_FLASH_SAVE_ADDRESS + i * 4, buf[i]);
flash_lock();
@ -189,8 +189,6 @@ int main(void)
{
JumpToApplication();
}
if (Boot_NvmUsbUpdateRequested())
Boot_NvmClearUsbUpdate();
/* init spi1 function. */
BSP_MainPowerEnable(1);
@ -200,12 +198,6 @@ int main(void)
/* init acc function. */
wk_acc_init();
/* init usbfs function. */
wk_usbfs_init();
/* init usb app function. */
wk_usb_app_init();
/* add user code begin 2 */
W25Q128_Init();
@ -230,6 +222,16 @@ int main(void)
LCD_ALIGN_CENTER, WHITE, BLACK, 0, 24);
}
}
/* 画面出来后再清标志。擦写与 Boot 同在 Flash Bank1,期间关掉中断 */
if (Boot_NvmUsbUpdateRequested())
{
__disable_irq();
Boot_NvmClearUsbUpdate();
__enable_irq();
}
wk_usbfs_init();
wk_usb_app_init();
/* add user code end 2 */

View File

@ -111,7 +111,7 @@ int16_t MIC_VOL_MAP[11]= {-9000,-7000,-5000,-3000,-1000,1000,3000,5000,7000,9000
uint8_t TOUCH_AREA_NUM = (sizeof(Touch_Areas)/sizeof(Touch_AreaTypeDef));
const uint8_t Version[3] = {0,2,29}; /* major.minor.patch — 0.2.29: 回退停止键软停;模式选择页忽略圆键/侧键 */
const uint8_t Version[3] = {0,2,30}; /* major.minor.patch — 0.2.30: USB更新字模;确认后进入 Boot 烧录 */
uint8_t Led = 8;
bool PressFlag = 0;

View File

@ -62,6 +62,7 @@ void UI_UsbModeConfirm_Process(DisplayTaskMessage_Type msg)
case GUI_CONFIRM:
nvm = drv_nvm_param_ptr();
nvm->param.UsbMode = NVM_USB_UPDATE;
__disable_irq();
drv_nvm_save_to_flash();
nvic_system_reset();
break;

View File

@ -1246,8 +1246,9 @@ void Draw_System_Item_List(const LEBEL_UI *UI, GUI_SWITCH *Group)
uint8_t label_sz = UI->Tab_size ? UI->Tab_size : UI0902_SET_ROW_FONT;
uint8_t value_sz = UI->Text_size ? UI->Text_size : UI0902_FONT_LABEL;
uint16_t text_y = UI->y + (UI->h - label_sz) / 2;
uint16_t val_x1 = UI->x + 96;
uint16_t val_x2 = UI->x + row_w - 18;
/* “USB模式”约到 x+87,三角再右移让开;中间放下 USB MIDI / USB更新 */
uint16_t val_x1 = UI->x + 84;
uint16_t val_x2 = UI->x + row_w - 10;
uint16_t chev_cy = UI->y + UI->h / 2;
/* 先清整块外接矩形为页面底色,避免焦点蓝圆角残留四角描边 */

View File

@ -194,6 +194,8 @@ const char CHS11Table[][2] = {
{0xCC,0xEC}, // 天
{0xBF,0xD5}, // 空
{0xB1,0xD5}, // 闭
{0xB8,0xFC}, // 更
{0xD0,0xC2}, // 新
};
@ -1139,6 +1141,8 @@ const unsigned char Chinese_font_11[][22] = {
{0x7F,0xC0,0x04,0x00,0x04,0x00,0x04,0x00,0xFF,0xE0,0x04,0x00,0x0A,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0xC0,0x60},/*"天",60*/
{0x04,0x00,0x7F,0xE0,0x40,0x20,0x89,0x00,0x10,0x80,0x60,0x40,0x1F,0x80,0x04,0x00,0x04,0x00,0x04,0x00,0x7F,0xE0},/*"空",61*/
{0x47,0xE0,0x20,0x20,0x82,0x20,0x82,0x20,0xBF,0xA0,0x86,0x20,0x8A,0x20,0x92,0x20,0xA2,0x20,0x86,0x20,0x80,0xE0},/*"闭",62*/
{0x7F,0xE0,0x02,0x00,0x3F,0xC0,0x22,0x40,0x3F,0xC0,0x22,0x40,0x3F,0xC0,0x0A,0x00,0x04,0x00,0x1B,0x00,0xE0,0xE0},/*"更",63*/
{0x10,0x60,0xFD,0x80,0x45,0x00,0x29,0x00,0xFD,0xE0,0x11,0x40,0xFD,0x40,0x11,0x40,0x55,0x40,0x92,0x40,0x34,0x40},/*"新",64*/
};

View File

@ -170,7 +170,7 @@ uint8_t drv_nvm_save_to_flash(void)
pData16 = (uint16_t *)NvmDataToSave;
flash_unlock();
flash_sector_erase(INNER_FLASH_SAVE_ADDRESS);
flash_sector_erase(INNER_FLASH_SECTOR_ADDRESS);
flash_write_nocheck(addr,pData16,len);
flash_lock();

View File

@ -20,7 +20,11 @@
#define fwdata __DATE__
#define fwtime __TIME__
/* AT32F403A 扇区为 2KB。参数仍写在 256KB 末尾倒数第 2 个 1KB,
* 擦除必须对齐到扇区起点,否则 0->1(MIDI->更新)写不进去。 */
#define NVM_FLASH_SECTOR 2048UL
#define INNER_FLASH_SAVE_ADDRESS (FLASH_BASE + 0x00040000UL - NVM_SECTOR_SZ)
#define INNER_FLASH_SECTOR_ADDRESS (INNER_FLASH_SAVE_ADDRESS & ~(NVM_FLASH_SECTOR - 1UL))

File diff suppressed because it is too large Load Diff

34
tools/gen_fw_boot.py Normal file
View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""Pack the built bootloader into project/src/AT32F403ARCT7_BOOT.c."""
import os
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BIN = os.path.join(
ROOT,
"AT32F403ARCT7_BOOT",
"project",
"IAR_V7.4",
"AT32F403ARCT7_BOOT",
"Exe",
"AT32F403ARCT7_BOOT.bin",
)
OUT = os.path.join(ROOT, "project", "src", "AT32F403ARCT7_BOOT.c")
data = open(BIN, "rb").read()
if len(data) > 0x8000:
raise SystemExit("boot image %d exceeds 32KB" % len(data))
print("binsize", len(data), data[:16].hex())
print("nvm addr hits", data.find(bytes([0x00, 0xFC, 0x03, 0x08])))
pad = data + bytes([0xFF]) * (0x8000 - len(data))
lines = [
"#ifdef BOOT",
'#pragma location=".boot"',
"__root const unsigned char FW_BOOT[0x8000] = {",
]
for i in range(0, 0x8000, 16):
chunk = ", ".join("0x%02X" % b for b in pad[i : i + 16])
lines.append("\t\t" + chunk + ",")
text = "\n".join(lines)
text = text[:-1] + "\n};\n\n\n#endif\n"
open(OUT, "w", encoding="latin1", newline="\n").write(text)
print("wrote", OUT, "chars", len(text))

View File

@ -38,7 +38,7 @@ TONE_HDR = PROJ / "project" / "inc" / "ExtFlash_Tone_Addr.h"
IAP_DIR = REPO / "升级" / "MCU主控升级"
OUT_ROOT = REPO / "tools" / "out"
FW_VER = "0.2.29"
FW_VER = "0.2.30"
UI0902_RES_BASE = 0x00100000
BOOT_FLASH_ADDR = 0x08000000
APP_FLASH_ADDR = 0x08008000