add spi flash debug_data_poll
authorkyz <kongyuzhong@google.com>
Tue, 17 Nov 2026 13:14:47 +0000 (21:14 +0800)
committerkyz <kongyuzhong@google.com>
Tue, 17 Nov 2026 13:14:47 +0000 (21:14 +0800)
39 files changed:
APP/BSP/bsp_init.c
APP/BSP/dev_lcd.c
APP/Common Module/FlashDisk.c
APP/IC_Driver/SPI_GD25Q128.c [new file with mode: 0644]
APP/IC_Driver/SPI_GD25Q128.h [new file with mode: 0644]
APP/IC_Driver/lcd_st7789.c
APP/bootloader/bootloader_main.c
APP/bootloader/bootloader_ui.c [new file with mode: 0644]
APP/bootloader/bootloader_ui.h [new file with mode: 0644]
APP/bootloader/font/ugui_font.c [new file with mode: 0644]
APP/bootloader/font/ugui_font_12x20.h [new file with mode: 0644]
APP/bootloader/font/ugui_font_6x8.h [new file with mode: 0644]
APP/bootloader/font/ugui_font_8x12.h [new file with mode: 0644]
APP/bootloader/iap.c [new file with mode: 0644]
APP/bootloader/iap.h [new file with mode: 0644]
APP/bootloader/sflash_test.c [new file with mode: 0644]
APP/bootloader/ugui.c [new file with mode: 0644]
APP/bootloader/ugui.h [new file with mode: 0644]
APP/bootloader/ugui_config.h [new file with mode: 0644]
APP/bootloader/ugui_core.h [new file with mode: 0644]
APP/bootloader/ugui_port.c [new file with mode: 0644]
APP/bootloader/widgets/window.h [new file with mode: 0644]
APP/fs/lfs.c [new file with mode: 0644]
APP/fs/lfs.h [new file with mode: 0644]
APP/fs/lfs_port.c [new file with mode: 0644]
APP/fs/lfs_port.h [new file with mode: 0644]
APP/fs/lfs_util.c [new file with mode: 0644]
APP/fs/lfs_util.h [new file with mode: 0644]
APP/main.c
APP/user_iap.c
APP/version.h
APP/wave_data.c
CSL/CMSIS/DeviceSupport/startup/arm/startup_SWM341.s
Linker_Scatter_File/SWM34S_SDRAM.sct [new file with mode: 0644]
dispboard_app.uvprojx
dispboard_app_sdram.uvprojx [new file with mode: 0644]
dispboard_bootloader.uvprojx
tools/fwpack.py [new file with mode: 0644]
tools/使用方法.md [new file with mode: 0644]

index 3aeed0f6cad9a17fbcdb1fb902f19cdcdc870409..3dfcc8895647245b55b3988ea58ef0218be4846a 100644 (file)
@@ -38,7 +38,11 @@ void bsp_init(void)
     //start.s里面调用SystemInit() 这个是有问题的,
     //他给SystemCoreClock和CyclesPerUs这两个全局变量赋值
     //然后非0的全局变量会__main中被重新赋初值,这里再重新调一下。
+#if CODE_ON_SDRAM
+    SystemCoreClockUpdate();
+#else
     SystemInit(); 
+#endif
 
     gpio_init();
 
index b3ee728183904e3173aaf9b057c97d811114c6cd..311aa10dcdb19a5e35f8b4c3ff9932354ad78631 100644 (file)
@@ -75,7 +75,7 @@ void lcd_init(void)
     /* 背景色 */
     LCD_initStruct.Background = 0xFFFF;
     /* 图层 1 被 lvgl 使用, 此处仅做初始化临时值, 在 disp_flush() 会切换至 lcdbuf_gui/show 帧缓冲区域 */
-    LCD_initStruct.DataSource = (uint32_t)SDRAMM_BASE;
+    LCD_initStruct.DataSource = (uint32_t)SDRAMM_BASE+0x700000;
     
     /* 0-失能传输完成中断, 刷完一帧自动开始刷新下一帧(用户无须参与)
      * 1-使能传输完成中断, 须在中断内软件启动刷新下一帧(开启后可提供接口以测试实际帧率) 
index 8ec2656c768cedc4738fcde8631b58455d376f71..28e4537067259939782bb778948ddfd62dae79a1 100644 (file)
@@ -25,7 +25,7 @@
 /*******************************************************************************************************************************************
  * Private Define
  *******************************************************************************************************************************************/
-#define IO_SPI_ENABLE /**< IO-SPI Ä£¿éʹÄܺê(²ÉÓàIO_SPI ·½Ê½Ð´Èë SPI-Flash) */
+/// #define IO_SPI_ENABLE /**< IO-SPI Ä£¿éʹÄܺê(²ÉÓàIO_SPI ·½Ê½Ð´Èë SPI-Flash) */
 
 /*******************************************************************************************************************************************
  * Private Variable
diff --git a/APP/IC_Driver/SPI_GD25Q128.c b/APP/IC_Driver/SPI_GD25Q128.c
new file mode 100644 (file)
index 0000000..91db161
--- /dev/null
@@ -0,0 +1,288 @@
+#include "SWM341.h"
+
+#include "SPI_GD25Q128.h"
+
+#define SPI_X SPI1
+
+#define GD25Q128_Assert()      GPIO_ClrBit(GPIOA, PIN8)
+#define GD25Q128_Deassert()    GPIO_SetBit(GPIOA, PIN8)
+
+/*******************************************************************************************************************************
+* @brief       init the SPI used to access SPI Flash, and read chip ID to determine whether it is a GD25Q128 chip
+* @param
+* @return      1 = 芯片识别成功, 0 = 未读到 ID (SPI Flash 异常)
+*******************************************************************************************************************************/
+uint32_t GD25Q128_Init(void)
+{
+       uint16_t chip_id;
+       uint8_t manufacture_id, device_id;
+       SPI_InitStructure SPI_initStruct;
+       
+       /* SPI Flash 与 LCD 共用 SPI_X 数据线 (PN0=SCK, PN4=MISO, PN5=MOSI), 片选单独接 PA8 */
+       GPIO_Init(GPIOA, PIN8, 1, 0, 0, 0);
+
+       GD25Q128_Deassert();
+
+       PORT_Init(PORTN, PIN0, PORTN_PIN0_SPI1_SCLK, 0);
+       PORT_Init(PORTN, PIN4, PORTN_PIN4_SPI1_MISO, 1);
+       PORT_Init(PORTN, PIN5, PORTN_PIN5_SPI1_MOSI, 0);
+
+       SPI_initStruct.clkDiv = SPI_CLKDIV_4;
+       SPI_initStruct.FrameFormat = SPI_FORMAT_SPI;
+       SPI_initStruct.SampleEdge = SPI_SECOND_EDGE;
+       SPI_initStruct.IdleLevel = SPI_HIGH_LEVEL;
+       SPI_initStruct.WordSize = 8;
+       SPI_initStruct.Master = 1;
+       SPI_initStruct.RXThreshold = 0;
+       SPI_initStruct.RXThresholdIEn = 0;
+       SPI_initStruct.TXThreshold = 0;
+       SPI_initStruct.TXThresholdIEn = 0;
+       SPI_initStruct.TXCompleteIEn = 0;
+       SPI_Init(SPI_X, &SPI_initStruct);
+
+       SPI_Open(SPI_X);
+       
+       chip_id = GD25Q128_ReadChipID();
+       manufacture_id = chip_id >> 8;
+       device_id = chip_id & 0xFF;
+       
+       if((manufacture_id == GD25Q128_MANUFACTOR_ID) && (device_id == GD25Q128_DEVICE_ID))
+       {
+               printf("GD25Q128 found\r\n");
+               
+               while(GD25Q128_IsBusy()) __NOP();
+               return 1;
+       }
+       else
+       {
+               printf("Manufactor ID: %02X, Device ID: %02X, fail to identify\r\n", manufacture_id, device_id);
+               return 0;
+       }
+}
+
+/*******************************************************************************************************************************
+* @brief       read chip id
+* @param
+* @return      chip id, the high 8 bits are the manufacturer ID and the low 8 bits are the Device ID
+*******************************************************************************************************************************/
+uint16_t GD25Q128_ReadChipID(void)
+{
+       uint8_t manufacture_id, device_id;
+       
+       GD25Q128_Assert();
+       
+       SPI_ReadWrite(SPI_X, GD25Q128_CMD_READ_CHIP_ID);
+       SPI_ReadWrite(SPI_X, 0x00);
+       SPI_ReadWrite(SPI_X, 0x00);
+       SPI_ReadWrite(SPI_X, 0x00);
+       
+       manufacture_id = SPI_ReadWrite(SPI_X, 0xFF);
+       device_id      = SPI_ReadWrite(SPI_X, 0xFF);
+       
+       GD25Q128_Deassert();
+       
+       return (manufacture_id << 8) | device_id;
+}
+
+/*******************************************************************************************************************************
+* @brief       read status register from SPI Flash
+* @param
+* @return      status register value
+*******************************************************************************************************************************/
+uint16_t GD25Q128_ReadStatus(void)
+{
+       uint16_t status;
+       
+       GD25Q128_Assert();
+               
+       SPI_ReadWrite(SPI_X, GD25Q128_CMD_READ_STATUS_L);
+       status = SPI_ReadWrite(SPI_X, 0xFF);
+       
+       GD25Q128_Deassert();
+       
+       GD25Q128_Assert();
+       
+       SPI_ReadWrite(SPI_X, GD25Q128_CMD_READ_STATUS_H);
+       status |= SPI_ReadWrite(SPI_X, 0xFF) << 8;
+       
+       GD25Q128_Deassert();
+               
+       return status;
+}
+
+/*******************************************************************************************************************************
+* @brief       GD25Q128 busy query
+* @param
+* @return      1 busy for internal operation, 0 idle, operation done
+*******************************************************************************************************************************/
+uint32_t GD25Q128_IsBusy(void)
+{
+       return (GD25Q128_ReadStatus() & GD25Q128_STATUS_WIP_Msk) ? 1 : 0;
+}
+
+/*******************************************************************************************************************************
+* @brief       GD25Q128 sector erase, 4KB per sector
+* @param       addr is the address of the sector to erase
+* @return
+*******************************************************************************************************************************/
+void GD25Q128_EraseSector(uint32_t addr)
+{
+       GD25Q128_Assert();
+       
+       SPI_ReadWrite(SPI_X, GD25Q128_CMD_WRITE_ENABLE);
+       
+       GD25Q128_Deassert();
+       
+       GD25Q128_Assert();
+               
+       SPI_ReadWrite(SPI_X, GD25Q128_CMD_ERASE_SECTOR);
+       SPI_ReadWrite(SPI_X, (addr >> 16) & 0xFF);
+       SPI_ReadWrite(SPI_X, (addr >>  8) & 0xFF);
+       SPI_ReadWrite(SPI_X, (addr >>  0) & 0xFF);
+       
+       GD25Q128_Deassert();
+}
+
+/*******************************************************************************************************************************
+* @brief       GD25Q128 data read
+* @param       addr is the address to read from
+* @param       buff is used to save read data
+* @param       cnt is the number of byte to read
+* @return
+*******************************************************************************************************************************/
+void GD25Q128_ReadData(uint32_t addr, uint8_t buff[], uint32_t cnt)
+{
+       uint32_t i;
+       
+       GD25Q128_Assert();
+       
+       SPI_ReadWrite(SPI_X, GD25Q128_CMD_READ_DATA);
+       SPI_ReadWrite(SPI_X, (addr >> 16) & 0xFF);
+       SPI_ReadWrite(SPI_X, (addr >>  8) & 0xFF);
+       SPI_ReadWrite(SPI_X, (addr >>  0) & 0xFF);
+       
+       for(i = 0; i < cnt; i++)
+       {
+               buff[i] = SPI_ReadWrite(SPI_X, 0xFF);
+       }
+       
+       GD25Q128_Deassert();
+}
+
+/*******************************************************************************************************************************
+* @brief       GD25Q128 data write, 256 bytes per page
+* @param       addr is the address to write to
+* @param       data is the data to write
+* @param       cnt is the number of byte to write, all data must be within the address range of the same page
+* @return
+*******************************************************************************************************************************/
+void GD25Q128_WritePage(uint32_t addr, uint8_t data[], uint16_t cnt)
+{
+       uint32_t i;
+       
+       GD25Q128_Assert();
+       
+       SPI_ReadWrite(SPI_X, GD25Q128_CMD_WRITE_ENABLE);
+       
+       GD25Q128_Deassert();
+       
+       GD25Q128_Assert();
+       
+       SPI_ReadWrite(SPI_X, GD25Q128_CMD_WRITE_PAGE);
+       SPI_ReadWrite(SPI_X, (addr >> 16) & 0xFF);
+       SPI_ReadWrite(SPI_X, (addr >>  8) & 0xFF);
+       SPI_ReadWrite(SPI_X, (addr >>  0) & 0xFF);
+       
+       for(i = 0; i < cnt; i++)
+       {
+               SPI_ReadWrite(SPI_X, data[i]);
+       }
+       
+       GD25Q128_Deassert();
+}
+
+
+/**
+ * @brief   向 GD25Q128 指定地址处写入指定个字节数据(写入前须保证待写入区域已被擦空)
+ * @param   addr    : 数据要写入到 GD25Q128 的物理位置
+ * @param   buff    : 数据源
+ * @param   cnt     : 数据字节个数
+ * @retval  /
+ */
+void GD25Q128_WriteBuff(uint32_t addr, uint8_t *buff, uint32_t cnt)
+{
+    uint32_t num_page = 0, page_remain = 0, align_addr = 0, align_count = 0, temp = 0;
+
+    align_addr = addr % GD25Q128_A_PAGE_BYTES;        /* mod 运算求余,若 addr 是 WB25Qxx_A_PAGE_BYTES 整数倍,运算结果值为 0 */
+    align_count = GD25Q128_A_PAGE_BYTES - align_addr; /* 差 count 个数据值,刚好可以对齐到页地址 */
+    num_page = cnt / GD25Q128_A_PAGE_BYTES;           /* 计算出要写多少整数页 */
+    page_remain = cnt % GD25Q128_A_PAGE_BYTES;        /* mod 运算求余,计算出剩余不满一页的字节数 */
+
+    if (align_addr == 0) /* align_addr = 0,则 addr 刚好按页对齐 aligned */
+    {
+        if (num_page == 0) /* 数据量不足一页 */
+        {
+            GD25Q128_WritePage(addr, buff, cnt);
+        }
+        else /* 数据量大于一页 */
+        {
+            /* 先把整数页都写了 */
+            while (num_page--)
+            {
+                GD25Q128_WritePage(addr, buff, GD25Q128_A_PAGE_BYTES);
+                addr += GD25Q128_A_PAGE_BYTES;
+                buff += GD25Q128_A_PAGE_BYTES;
+            }
+            if (page_remain > 0) /* 若有多余的不满一页的数据,把它写完 */
+            {
+                GD25Q128_WritePage  (addr, buff, page_remain);
+            }
+        }
+    }
+    else /* 若地址与 WB25Qxx_A_PAGE_BYTES 不对齐  */
+    {
+        if (num_page == 0) /* 数据量不足一页 */
+        {
+            if (page_remain > align_count) /* 当前页剩余的 count 个位置比 align_count 小,写不完 */
+            {
+                temp = page_remain - align_count;
+
+                /* 先写满当前页 */
+                GD25Q128_WritePage(addr, buff, align_count);
+                addr += align_count;
+                buff += align_count;
+
+                /* 再写剩余的数据 */
+                GD25Q128_WritePage(addr, buff, temp);
+            }
+            else /* 当前页剩余的 count 个位置能写完 align_count 个数据 */
+            {
+                GD25Q128_WritePage(addr, buff, cnt);
+            }
+        }
+        else /* 数据量大于一页 */
+        {
+            /* 地址不对齐多出的 count 分开处理,不加入这个运算 */
+            cnt -= align_count;
+            num_page = cnt / GD25Q128_A_PAGE_BYTES;
+            page_remain = cnt % GD25Q128_A_PAGE_BYTES;
+
+            GD25Q128_WritePage(addr, buff, align_count);
+            addr += align_count;
+            buff += align_count;
+
+            /* 把整数页都写了 */
+            while (num_page--)
+            {
+                GD25Q128_WritePage(addr, buff, GD25Q128_A_PAGE_BYTES);
+                addr += GD25Q128_A_PAGE_BYTES;
+                buff += GD25Q128_A_PAGE_BYTES;
+            }
+            /* 若有多余的不满一页的数据,把它写完 */
+            if (page_remain != 0)
+            {
+                GD25Q128_WritePage(addr, buff, page_remain);
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/APP/IC_Driver/SPI_GD25Q128.h b/APP/IC_Driver/SPI_GD25Q128.h
new file mode 100644 (file)
index 0000000..57ec678
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef __SPI_GD25Q128_H__
+#define __SPI_GD25Q128_H__
+
+#include <stdint.h>
+
+uint32_t GD25Q128_Init(void);
+uint16_t GD25Q128_ReadChipID(void);
+uint16_t GD25Q128_ReadStatus(void);
+
+uint32_t GD25Q128_IsBusy(void);
+
+void GD25Q128_EraseSector(uint32_t addr);
+void GD25Q128_ReadData(uint32_t addr, uint8_t buff[], uint32_t cnt);
+void GD25Q128_WritePage(uint32_t addr, uint8_t data[], uint16_t cnt);
+
+
+#define GD25Q128_STATUS_WIP_Pos                0               // Write In Progress
+#define GD25Q128_STATUS_WIP_Msk                (0x01 << GD25Q128_STATUS_WIP_Pos)
+#define GD25Q128_STATUS_WEL_Pos                1               // Write Enable Latch
+#define GD25Q128_STATUS_WEL_Msk                (0x01 << GD25Q128_STATUS_WEL_Pos)
+#define GD25Q128_STATUS_SBP_Pos                2               // Software Block Protect
+#define GD25Q128_STATUS_SBP_Msk                (0x1F << GD25Q128_STATUS_SBP_Pos)
+#define GD25Q128_STATUS_SRP_Pos                7               // Status Register Protect
+#define GD25Q128_STATUS_SRP_Msk                (0x03 << GD25Q128_STATUS_SRP_Pos)
+#define GD25Q128_STATUS_QE_Pos         9               // Quad Enable
+#define GD25Q128_STATUS_QE_Msk         (0x01 << GD25Q128_STATUS_QE_Pos)
+#define GD25Q128_STATUS_SUS_Pos                15              // SUSPEND STATUS
+#define GD25Q128_STATUS_SUS_Msk                (0x01 << GD25Q128_STATUS_SUS_Pos)
+
+
+#define GD25Q128_MANUFACTOR_ID         0xC8
+#define GD25Q128_DEVICE_ID                     0x17
+
+
+#define GD25Q128_CMD_READ_CHIP_ID      0x90
+#define GD25Q128_CMD_READ_STATUS_L     0x05
+#define GD25Q128_CMD_READ_STATUS_H     0x35
+#define GD25Q128_CMD_WRITE_STATUS      0x01
+#define GD25Q128_CMD_READ_DATA         0x03
+#define GD25Q128_CMD_READ_DATA_4bit    0x6B
+#define GD25Q128_CMD_WRITE_PAGE                0x02
+#define GD25Q128_CMD_ERASE_SECTOR      0x20
+#define GD25Q128_CMD_WRITE_ENABLE      0x06
+#define GD25Q128_CMD_WRITE_DISABLE     0x04
+
+#define GD25Q128_A_PAGE_BYTES          256             // 页大小
+
+
+#endif
\ No newline at end of file
index 80f3126fec6a76f9b38f17bc1c6655639e8a0333..e93cc57955e154663766aa084f7ef93e322120a4 100644 (file)
 #define H_SDA()     GPIO_SetBit( LCD_GPIO_MOSI, LCD_PIN_MOSI )
 #define L_SDA()     GPIO_ClrBit( LCD_GPIO_MOSI, LCD_PIN_MOSI )
 
+#if BOOTLOADER
+static void _delay_ms( uint32_t ms )
+{
+  for( int n = 0; n<ms*10; n++ ){
+    for (unsigned int i = 0; i < CyclesPerUs; ++i) __NOP();
+  }
+}
+#define systick_delay_ms(ms)  _delay_ms(ms)
+#else
+#define systick_delay_ms(ms)  vTaskDelay(ms)
+#endif
+
 /*******************************************************************************************************************************************
  * Private Function
  *******************************************************************************************************************************************/
@@ -215,7 +227,7 @@ static void spi_port_init(void)
  */
 volatile uint32_t lcd_chip_id = 0;
 
-#define systick_delay_ms(ms)  vTaskDelay(ms)
+
 
 void lcd_st7789_spi_init(void)
 {
index 676ea4202252bcbc9eaed69f893be1c97f5335fd..6187f06e3455f1235c982b0eb084c7dbcd79ccec 100644 (file)
+/**
+ *******************************************************************************************************************************************
+ * @file        bootloader_main.c
+ * @brief       bootloader 主程序: 引导 + 固件校验 + 拷贝 + 跳转运行 / 升级
+ * @details     完整流程:
+ *              3.1 读取分区1(主程序), 取版本 + 校验CRC; 若因校验失败则走升级流程
+ *              3.2 读取分区2(待升级), 取版本 + 校验CRC, 判断是否需要升级
+ *              3.3 若不需要升级且主程序有效: 分区1 → SDRAM, 跳转运行
+ *              3.4 若需要升级且有升级固件: 分区2 → 分区1, 擦除分区2, 重启
+ *              3.5 分区2无升级固件: 打开LCD 显示无主程序, 等待插入U盘升级
+ *******************************************************************************************************************************************
+ */
+#include <string.h>
 #include "SWM341.h"
 
-void SerialInit(void);
-void SFC_Config(void);
-void SDRAM_Config(void);
-void JumpToApp(uint32_t addr);
+#include "iap.h"
+#include "bootloader_ui.h"
+#include "bsp_init.h"
+#include "SPI_GD25Q128.h"
+#include "lfs.h"
+#include "lfs_port.h"
 
+#include "usbh_core.h"
+#include "usbh_msc_core.h"
+#include "ff.h"
+
+#include "dev_systick.h"
+
+#define BOOT_VER_MAJOR    4
+#define BOOT_VER_MINOR    3
+#define BOOT_VER_REVISION 2
+#define BOOT_VER_BUILD    1
+
+extern USBH_Class_cb_t USBH_MSC_cb;
+extern USBH_User_cb_t  USBH_USR_cb;
+
+#define USB_FW_PATH      "usb:/app.bin"    /* U盘升级固件默认文件名 */
+
+static FATFS g_usb_fs;                      /* U盘文件系统对象 */
+
+/*************************************************************************************************************
+ * Private Prototype
+ *************************************************************************************************************/
+static void progress_cb(uint32_t done, uint32_t total);
+static void bootloader_wait_upgrade_usb(void);
+static void boot_delay_ms(uint32_t ms);
+static void bootloader_fs_log_update(void);
+static uint16_t boot_upd_crc16(const uint8_t *data, uint32_t len, uint16_t crc);
+static int      boot_upd_fw_valid(FIL *fp, uint32_t file_size, const uint8_t *hdr, uint8_t *buf);
+
+const  BOOT_VER[4] = {BOOT_VER_MAJOR, BOOT_VER_MINOR, BOOT_VER_REVISION, BOOT_VER_BUILD};
+
+/*************************************************************************************************************
+ * Public Function
+ *************************************************************************************************************/
 int main(void)
-{      
-       SystemInit();
-       
-       SerialInit();
-       
-       printf("Running in BootLoader!\r\n");
-       
-       SFC_Read(0, (uint32_t *)SDRAMM_BASE, 0x100000/4);       // 将 SPI Flash 上前 1MB 拷贝到 SDRAM 上
-       
-       printf("Jump to SDRAM_APP!\r\n");
-       
-       JumpToApp(SDRAMM_BASE);
-       
-       while(1==1)
-       {
-       }
+{
+    firmware_info_t info1, info2;
+    int ok1, ok2;
+
+    bsp_init();
+    SysTick_Config(CyclesPerUs * 100);
+
+
+    /* 初始化 SPI Flash: 读取芯片 ID, 若识别异常则不再执行任何读写操作 */
+    if (iap_init() != 0) {
+        /* 打开 LCD 显示界面 */
+        bootloader_ui_init();
+        bootloader_ui_show_status((char*)"SPI Flash abnormal !");
+        while (1) __NOP();
+    }
+
+#if 1
+    /* 芯片 ID 读取成功后执行 SPI Flash 读写擦除自检 */
+    {
+    //    extern void sflash_test( void );
+    //    sflash_test();
+    }
+    /* 3.1 / 3.2 单遍加载: 读文件头校验, 直读正文到 SDRAM 同时计算CRC
+     *       part1 → 0x80000000 (运行镜像)         part2 → 0x80200000 (升级缓冲) */
+    ok1 = iap_part_load(IAP_PART1_OFF, IAP_APP_RUN_ADDR, &info1);   /* 主程序分区   */
+    ok2 = iap_part_load(IAP_PART2_OFF, IAP_PART2_RUN_ADDR, &info2); /* 待升级分区   */
+
+    printf("[bootloader] part1(%d) part2(%d)\r\n", ok1, ok2);
+
+    //如果button 1 和 2 都按下, 则进入升级流程
+    if( is_key_pressed(0) ){ 
+        ok1 = -1;
+        ok2 = -1;
+    }
+    /* 3.3 主程序有效 */
+    if (ok1 == 0) {
+        /* 3.4 有待升级固件且版本更新: 用 SDRAM 缓冲升级后再启动 */
+        if (ok2 == 0 && iap_need_update(&info1, &info2)) {
+            ///bootloader_ui_show_status((char*)"Upgrading firmware ...");
+            iap_sdram_to_part(IAP_PART2_RUN_ADDR, IAP_PART1_OFF,
+                              info2.size + IAP_FW_HDR_LEN);
+            GD25Q128_EraseSector(IAP_PART2_OFF);                /* 只擦除首扇区, 清掉文件头标志 */
+            while (GD25Q128_IsBusy()) __NOP();
+            NVIC_SystemReset();                                 /* 重启再次引导 */
+        }
+
+        /* 无需升级: 主程序已在 SDRAM, 直接跳到正文起始(跳过16字节文件头) */
+        //bootloader_ui_show_status((char*)"Booting ...");
+        iap_jump_app(IAP_APP_RUN_ADDR + IAP_FW_HDR_LEN);
+        /* 跳转后不会返回; 若这里失败则继续走升级/等待流程 */
+        bootloader_ui_show_status((char*)"Load app failed !");
+    }
+    else if (ok2 == 0) {
+        /* 主程序无效, 但存在待升级固件: 用 SDRAM 缓冲直接升级 */
+        //bootloader_ui_show_status((char*)"Main FW invalid, update");
+        iap_sdram_to_part(IAP_PART2_RUN_ADDR, IAP_PART1_OFF,
+                          info2.size + IAP_FW_HDR_LEN);
+        GD25Q128_EraseSector(IAP_PART2_OFF);                    /* 只擦除首扇区 */
+        while (GD25Q128_IsBusy()) __NOP();
+        bootloader_ui_show_status((char*)"Upgrade done, reboot");
+        bootloader_fs_log_update();
+        boot_delay_ms(500);
+        NVIC_SystemReset();
+    }
+#endif
+    bootloader_ui_init();
+
+    if (iap_init() != 0) {
+        /* 打开 LCD 显示界面 */
+        bootloader_ui_init();
+        bootloader_ui_show_status((char*)"SPI Flash abnormal !");
+        while (1) __NOP();
+    }else{
+      /* 3.5 主程序无效且无待升级固件: 等待插入U盘升级 */
+      bootloader_ui_show_status((char*)"No app, insert USB to update");
+      bootloader_wait_upgrade_usb();
+    }
+
+    while (1) __NOP();
+}
+
+/*************************************************************************************************************
+ * Private Function
+ *************************************************************************************************************/
+/**
+ * @brief   升级进度回调 → 写入 UI 进度条
+ */
+static void progress_cb(uint32_t done, uint32_t total)
+{
+    bootloader_ui_show_progress((uint32_t)((uint64_t)done * 100 / total));
 }
 
-void JumpToApp(uint32_t addr)
+/**
+ * @brief   简单忙等延时 (基于 SysTick 的 CyclesPerUs)
+ */
+static void boot_delay_ms(uint32_t ms)
 {
-       uint32_t sp = *((volatile uint32_t *)(addr));
-       uint32_t pc = *((volatile uint32_t *)(addr + 4));
-       
-       typedef void (*Func_void_void)(void);
-       Func_void_void ResetHandler = (Func_void_void)pc;
-       
-       if(((sp > 0x20000000) && (sp < 0x20010000)) &&
-          ((pc > SDRAMM_BASE) && (pc < (SDRAMM_BASE + 0x2000000))))
-       {
-               SCB->VTOR = addr;
-               
-               __set_MSP(sp);
-               
-               ResetHandler();
-       }
-       
-       while(1) __NOP();
+    for (uint32_t i = 0; i < ms * 10; ++i) {
+        for (unsigned int c = 0; c < CyclesPerUs; ++c)
+            __NOP();
+    }
 }
 
-void SerialInit(void)
+/**
+ * @brief   通过 littlefs 记录一次升级事件
+ * @note    只读写片外 Flash 的 8M littlefs 分区 (0x600000), 与固件分区无重叠。
+ *          用于在 bootloader 中接入 littlefs 接口并测量其对代码体积的影响。
+ */
+static void bootloader_fs_log_update(void)
 {
-       UART_InitStructure UART_initStruct;
-       
-       PORT_Init(PORTM, PIN0, PORTM_PIN0_UART0_RX, 1); //GPIOM.0配置为UART0输入引脚
-       PORT_Init(PORTM, PIN1, PORTM_PIN1_UART0_TX, 0); //GPIOM.1配置为UART0输出引脚
-       
-       UART_initStruct.Baudrate = 57600;
-       UART_initStruct.DataBits = UART_DATA_8BIT;
-       UART_initStruct.Parity = UART_PARITY_NONE;
-       UART_initStruct.StopBits = UART_STOP_1BIT;
-       UART_initStruct.RXThreshold = 3;
-       UART_initStruct.RXThresholdIEn = 0;
-       UART_initStruct.TXThreshold = 3;
-       UART_initStruct.TXThresholdIEn = 0;
-       UART_initStruct.TimeoutTime = 10;
-       UART_initStruct.TimeoutIEn = 0;
-       UART_Init(UART0, &UART_initStruct);
-       UART_Open(UART0);
+    lfs_file_t f;
+
+    fs_littlefs_flash_init();
+
+    /* 首次使用若分区未格式化则格式化 */
+    if (fs_littlefs_mount() < 0) {
+        fs_littlefs_format();
+        if (fs_littlefs_mount() < 0)
+            return;
+    }
+
+    if (lfs_file_open(&fs_lfs, &f, "UPD", LFS_O_CREAT | LFS_O_APPEND | LFS_O_WRONLY) == LFS_ERR_OK) {
+        lfs_file_write(&fs_lfs, &f, "B", 1);   /* 每字节标记一次升级 */
+        lfs_file_close(&fs_lfs, &f);
+    }
+
+    fs_littlefs_unmount();
 }
 
-/****************************************************************************************************************************************** 
-* 函数名称: fputc()
-* 功能说明: printf()使用此函数完成实际的串口打印动作
-* 输    入: int ch           要打印的字符
-*                      FILE *f         文件句柄
-* 输    出: 无
-* 注意事项: 无
-******************************************************************************************************************************************/
-int fputc(int ch, FILE *f)
+/**
+ * @brief   CRC-CCITT (poly 0x1021), 与 iap.c 中算法一致
+ */
+static uint16_t boot_upd_crc16(const uint8_t *data, uint32_t len, uint16_t crc)
 {
-       UART_WriteByte(UART0, ch);
-       
-       while(UART_IsTXBusy(UART0));
-       
-       return ch;
+    uint32_t i;
+    int      j;
+
+    for (i = 0; i < len; ++i) {
+        crc ^= (uint16_t)data[i] << 8;
+        for (j = 0; j < 8; ++j) {
+            if (crc & 0x8000)
+                crc = (uint16_t)((crc << 1) ^ IAP_FW_CRC_POLY);
+            else
+                crc = (uint16_t)(crc << 1);
+        }
+    }
+    return crc;
 }
 
+/**
+ * @brief   校验 U 盘固件文件是否有效 (项目名 / 板子ID / 固件长度 / 正文CRC)
+ * @note    需已打开文件并读取完 16 字节文件头 (hdr); file_size 为整个文件大小。
+ * @retval  0 有效 / 非0 无效
+ */
+static int boot_upd_fw_valid(FIL *fp, uint32_t file_size, const uint8_t *hdr, uint8_t *buf)
+{
+    uint32_t fw_size;
+    uint16_t fw_crc;
+    uint16_t crc = 0;
+    uint32_t off;
+    uint32_t n;
+    UINT     rd;
+
+    /* 校验项目名 */
+    if (memcmp(hdr + IAP_FW_HDR_OFF_PROJ, IAP_PROJ_NAME, IAP_PROJ_NAME_LEN) != 0)
+        return -1;
+
+    /* 校验板子ID */
+    if (hdr[IAP_FW_HDR_OFF_BOARD] != IAP_BOARD_LCD)
+        return -1;
+
+    /* 解析固件长度 (Byte11~13 大端), 且长度须等于文件去除16字节头后的体积 */
+    fw_size  = ((uint32_t)hdr[IAP_FW_HDR_OFF_SIZE]     << 16) |
+               ((uint32_t)hdr[IAP_FW_HDR_OFF_SIZE + 1] <<  8) |
+               ((uint32_t)hdr[IAP_FW_HDR_OFF_SIZE + 2]);
+    if (fw_size == 0 || fw_size != (file_size - IAP_FW_HDR_LEN))
+        return -1;
+
+    /* 校验固件正文 CRC (从文件偏移 IAP_FW_HDR_LEN 开始逐块读取) */
+    fw_crc = (uint16_t)(((uint16_t)hdr[IAP_FW_HDR_OFF_CRC] << 8) |
+                         hdr[IAP_FW_HDR_OFF_CRC + 1]);
+
+    f_lseek(fp, IAP_FW_HDR_LEN);
+    off = IAP_FW_HDR_LEN;
+    while (off < file_size) {
+        n = file_size - off;
+        if (n > IAP_FLASH_PAGE)
+            n = IAP_FLASH_PAGE;
+
+        if (f_read(fp, buf, n, &rd) != FR_OK || rd != n)
+            return -1;
+
+        crc = boot_upd_crc16(buf, n, crc);
+        off += n;
+    }
+
+    return (crc == fw_crc) ? 0 : -1;
+}
+
+/**
+ * @brief   等待插入 U 盘升级固件
+ * @note    将 U 盘根目录 app.bin 写入 SPI Flash 分区2, 然后重启,
+ *          重启后 bootloader 会通过 3.4/主程序无效流程 将分区2 → 分区1 并启动。
+ */
+static void bootloader_wait_upgrade_usb(void)
+{
+    FIL     fp;
+    FRESULT res;
+    UINT    rd = 0;
+    uint32_t file_size;
+    uint32_t off = 0;
+    uint32_t n;
+static     uint8_t  hdr[IAP_FW_HDR_LEN];
+static     uint8_t  buf[IAP_FLASH_PAGE];
+
+        GPIO_SetBit(GPIOD, PIN9); //usb power on
+    for (;;) {
+        /* 等待 U 盘挂载成功 (重试挂载) */
+        if (f_mount(&g_usb_fs, "usb:", 1) != FR_OK)
+            continue;   /* 尚未插入/挂载, 继续等待 */
+
+        res = f_open(&fp, USB_FW_PATH, FA_OPEN_EXISTING | FA_READ);
+        if (res != FR_OK) {
+            f_mount(NULL, "usb:", 0);
+            continue;   /* 未找到升级文件, 继续等待 */
+        }
+
+        file_size = (uint32_t)f_size(&fp);
+        if (file_size <= IAP_FW_HDR_LEN || file_size > IAP_PART_SIZE) {
+            f_close(&fp);
+            f_mount(NULL, "usb:", 0);
+            continue;
+        }
+
+        bootloader_ui_show_status((char*)"USB update found");
+        f_read(&fp, hdr, IAP_FW_HDR_LEN, &rd);
+
+        /* 校验固件数据 (项目名/板子ID/长度/正文CRC), 无效则不执行升级 */
+        if (boot_upd_fw_valid(&fp, file_size, hdr, buf) != 0) {
+            printf("[bootloader] USB firmware invalid, skip upgrade\r\n");
+            f_close(&fp);
+            f_mount(NULL, "usb:", 0);
+            continue;
+        }
+        bootloader_ui_show_status((char*)"USB firmware valid");
+
+        /* 先擦除分区2, 再写正文, 最后写文件头(第一页), 防止半途写入残留完整的文件头标志 */
+        iap_erase_part(IAP_PART2_OFF, IAP_PART_SIZE);
+
+        /* 正文从分区偏移一页(256B)开始写, 首页预留的16字节头+240字节正文放到最后写 */
+        f_lseek(&fp, IAP_FLASH_PAGE);
+        off = IAP_FLASH_PAGE;
+
+        /* 先将固件正文写入分区2 */
+        while (off < file_size) {
+            n = file_size - off;
+            if (n > IAP_FLASH_PAGE)
+                n = IAP_FLASH_PAGE;
+
+            if (f_read(&fp, buf, n, &rd) != FR_OK || rd != n)
+                break;
+
+            GD25Q128_WriteBuff(IAP_PART2_OFF + off, buf, n);
+            while (GD25Q128_IsBusy()) __NOP();
+
+            off += n;
+            bootloader_ui_show_progress((uint32_t)((uint64_t)off * 100 / file_size));
+        }
+
+        /* 正文写入完成后补写第一页: 16字节文件头 + 前240字节固件正文 */
+        if (off >= file_size) {
+            memcpy(buf, hdr, IAP_FW_HDR_LEN);
+            f_lseek(&fp, IAP_FW_HDR_LEN);
+            if (f_read(&fp, &buf[IAP_FW_HDR_LEN], IAP_FLASH_PAGE - IAP_FW_HDR_LEN, &rd) == FR_OK) {
+                n = IAP_FLASH_PAGE;
+                GD25Q128_WriteBuff(IAP_PART2_OFF, buf, n);  /* SPI_GD25Q128.h 提供 */
+                while (GD25Q128_IsBusy()) __NOP();
+            }
+        }
+
+        f_close(&fp);
+        f_mount(NULL, "usb:", 0);
+
+        if (off >= file_size) {
+            bootloader_ui_show_status((char*)"Update ready, reboot");
+            boot_delay_ms(300);
+            NVIC_SystemReset();
+        }
+    }
+}
+
+/**
+ * @brief   USB Host 中断处理
+ */
+void SysTick_Handler(void)
+{
+   // USBH_Process();
+}
\ No newline at end of file
diff --git a/APP/bootloader/bootloader_ui.c b/APP/bootloader/bootloader_ui.c
new file mode 100644 (file)
index 0000000..d6f60ad
--- /dev/null
@@ -0,0 +1,101 @@
+/**
+ *******************************************************************************************************************************************
+ * @file        bootloader_ui.c
+ * @brief       bootloader 升级界面 (基于 uGUI)
+ * @details     bootloader 启动后初始化 LCD 与 uGUI, 提供升级界面绘制入口。
+ *              目前仅提供 init 接口, 用于点亮屏幕并显示一行测试字符串,
+ *              后续升级进度条 / 升级完成提示等界面在此文件中扩展。
+ *******************************************************************************************************************************************
+ */
+#include "ugui.h"
+#include "bootloader_ui.h"
+
+#include "dev_sdram.h"   /* SDRAM 显存初始化, 基地址 0x80000000 */
+#include "dev_lcd.h"     /* LCD 初始化, 显存 DataSource 指向 SDRAMM_BASE */
+
+#include "version.h"     /* LCD_HDOT / LCD_VDOT 屏幕分辨率 */
+
+/* ugui 硬件移植层接口 (ugui_port.c) */
+extern void UG_Pixel_Set(UG_S16 x, UG_S16 y, UG_COLOR c);   /* pset 回调        */
+extern void UG_LCD_Fill(UG_U16 color);                       /* 清屏            */
+
+/* uGUI 全局图形上下文 (bootloader 只使用单屏, 无窗口管理)  */
+static UG_GUI bootloader_gui;
+
+/**
+ * @brief   bootloader 显示界面初始化
+ * @note    启动 LCD + uGUI, 并显示一行测试字符串。
+ *          硬件(LCD/SDRAM)仅执行一次初始化, 函数可重复调用。
+ */
+void bootloader_ui_init(void)
+{
+    static uint8_t hw_inited = 0;
+
+    if (0 == hw_inited)
+    {
+        //sdram_init();                  /* 将片内 SDRAM 映射到 0x80000000, 作为 LCD 显存 */
+        lcd_init();                    /* 启动 LCD, DataSource 指向 SDRAMM_BASE        */
+        hw_inited = 1;
+        LCD_Start(LCD);
+    }
+
+    /* 初始化 uGUI, 绑定像素写入回调 (写入 SDRAM 显存) */
+    UG_Init(&bootloader_gui, UG_Pixel_Set, LCD_HDOT, LCD_VDOT);
+    UG_FontSetHSpace(1);
+    UG_FontSetVSpace(1);
+
+    /* 清屏为黑色 */
+    UG_LCD_Fill((UG_U16)C_BLACK);
+return;
+    /* 显示一行测试字符串 */
+    UG_FontSelect(&FONT_12X20);
+    UG_SetForecolor(C_WHITE);
+    UG_SetBackcolor(C_BLACK);
+    UG_PutString(0, 10, (char*)"BOOTLOADER UI OK");
+    UG_PutString(0, 40, (char*)"FW UPDATE LOADER");
+
+    UG_FontSelect(&FONT_8X12);
+    UG_PutString(0, 90, (char*)"ui v1.0 test string");
+    UG_PutString(0, 110, (char*)"wait for update ...");
+}
+
+/**
+ * @brief   屏幕状态区内各界面元素坐标定义
+ * @note    屏幕分辨率 320x240; 底部预留状态区, 中部为进度条
+ */
+#define UI_STATUS_Y     205          /* 状态文本所在行 */
+#define UI_PBAR_X1      20           /* 进度条左边   */
+#define UI_PBAR_Y1      120          /* 进度条顶边   */
+#define UI_PBAR_X2      300          /* 进度条右边   */
+#define UI_PBAR_Y2      140          /* 进度条底边   */
+
+void bootloader_ui_show_status(const char *msg)
+{
+    UG_FontSelect(&FONT_8X12);
+    UG_SetForecolor(C_WHITE);
+    UG_SetBackcolor(C_BLACK);
+
+    /* 先清空状态区, 避免残留旧文本 */
+    UG_FillFrame(0, UI_STATUS_Y - 2, 319, UI_STATUS_Y + 8 + 2, C_BLACK);
+
+    if (msg)
+        UG_PutString(0, UI_STATUS_Y, (char*)msg);
+}
+
+void bootloader_ui_show_progress(uint32_t percent)
+{
+    static const UG_S16 pbar_w = UI_PBAR_X2 - UI_PBAR_X1;
+    UG_S16 fill_w;
+
+    if (percent > 100)
+        percent = 100;
+
+    /* 绘制进度条外框 */
+    UG_DrawFrame(UI_PBAR_X1, UI_PBAR_Y1, UI_PBAR_X2, UI_PBAR_Y2, C_WHITE);
+
+    /* 按百分比填充进度条 */
+    fill_w = (UG_S16)(pbar_w * percent / 100);
+    if (fill_w > 0)
+        UG_FillFrame(UI_PBAR_X1, UI_PBAR_Y1,
+                     UI_PBAR_X1 + fill_w - 1, UI_PBAR_Y2, C_GREEN);
+}
\ No newline at end of file
diff --git a/APP/bootloader/bootloader_ui.h b/APP/bootloader/bootloader_ui.h
new file mode 100644 (file)
index 0000000..0951964
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef __BOOTLOADER_UI_H__
+#define __BOOTLOADER_UI_H__
+
+#include "ugui.h"
+
+/**
+ * @brief   初始化 bootloader 显示界面 (启动 LCD + uGUI), 并显示一行测试字符串
+ * @note    内部会保证硬件(LCD/SDRAM)只被初始化一次, 可安全重复调用
+ */
+void bootloader_ui_init(void);
+
+/**
+ * @brief   在屏幕固定状态区显示一行文本 (不影响其它区域)
+ * @param   msg 要显示的字符串
+ */
+void bootloader_ui_show_status(const char *msg);
+
+/**
+ * @brief   在屏幕固定区域绘制升级进度条
+ * @param   percent 进度百分比 (0~100)
+ * @note    首次调用前可先调用 bootloader_ui_show_progress(0) 绘制外框
+ */
+void bootloader_ui_show_progress(uint32_t percent);
+
+#endif /* __BOOTLOADER_UI_H__ */
\ No newline at end of file
diff --git a/APP/bootloader/font/ugui_font.c b/APP/bootloader/font/ugui_font.c
new file mode 100644 (file)
index 0000000..af37ab8
--- /dev/null
@@ -0,0 +1,117 @@
+/* -------------------------------------------------------------------------------- */
+/* -- uGUI - Generic GUI module (C)Achim D?bler, 2015                            -- */
+/* -------------------------------------------------------------------------------- */
+// uGUI is a generic GUI module for embedded systems.
+// This is a free software that is open for education, research and commercial
+// developments under license policy of following terms.
+//
+//  Copyright (C) 2015, Achim D?bler, all rights reserved.
+//  URL: http://www.embeddedlightning.com/
+//
+// * The uGUI module is a free software and there is NO WARRANTY.
+// * No restriction on use. You can use, modify and redistribute it for
+//   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+// * Redistributions of source code must retain the above copyright notice.
+//
+/* -------------------------------------------------------------------------------- */
+#include "ugui.h"
+
+#ifdef USE_FONT_4X6
+    #include "font/ugui_font_4x6.h"
+    __UG_FONT_DATA UG_FONT FONT_4X6 = {(unsigned char*)font_4x6,FONT_TYPE_1BPP,4,6,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_5X8
+    #include "font/ugui_font_5x8.h"
+    __UG_FONT_DATA UG_FONT FONT_5X8 = {(unsigned char*)font_5x8,FONT_TYPE_1BPP,5,8,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_5X12
+    #include "font/ugui_font_5x12.h"
+    __UG_FONT_DATA UG_FONT FONT_5X12 = {(unsigned char*)font_5x12,FONT_TYPE_1BPP,5,12,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_6X8
+    #include "font/ugui_font_6x8.h"
+    __UG_FONT_DATA UG_FONT FONT_6X8 = {(unsigned char*)font_6x8,FONT_TYPE_1BPP,6,8,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_6X10
+    #include "font/ugui_font_6x10.h"
+    __UG_FONT_DATA UG_FONT FONT_6X10 = {(unsigned char*)font_6x10,FONT_TYPE_1BPP,6,10,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_7X12
+    #include "font/ugui_font_7x12.h"
+    __UG_FONT_DATA UG_FONT FONT_7X12 = {(unsigned char*)font_7x12,FONT_TYPE_1BPP,7,12,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_8X8
+    #include "font/ugui_font_8x8.h"
+    __UG_FONT_DATA UG_FONT FONT_8X8 = {(unsigned char*)font_8x8,FONT_TYPE_1BPP,8,8,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_8X12
+    #include "font/ugui_font_8x12.h"
+    __UG_FONT_DATA UG_FONT FONT_8X12 = {(unsigned char*)font_8x12,FONT_TYPE_1BPP,8,12,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_8X14
+    #include "font/ugui_font_8x14.h"
+    __UG_FONT_DATA UG_FONT FONT_8X14 = {(unsigned char*)font_8x14,FONT_TYPE_1BPP,8,14,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_10X16
+    #include "font/ugui_font_10x16.h"
+    __UG_FONT_DATA UG_FONT FONT_10X16 = {(unsigned char*)font_10x16,FONT_TYPE_1BPP,10,16,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_12X16
+    #include "font/ugui_font_12x16.h"
+    __UG_FONT_DATA UG_FONT FONT_12X16 = {(unsigned char*)font_12x16,FONT_TYPE_1BPP,12,16,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_12X20
+    #include "font/ugui_font_12x20.h"
+    __UG_FONT_DATA UG_FONT FONT_12X20 = {(unsigned char*)font_12x20,FONT_TYPE_1BPP,12,20,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_16X26
+    #include "font/ugui_font_16x26.h"
+    __UG_FONT_DATA UG_FONT FONT_16X26 = {(unsigned char*)font_16x26,FONT_TYPE_1BPP,16,26,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_22X36
+    #include "font/ugui_font_22x36.h"
+    __UG_FONT_DATA UG_FONT FONT_22X36 = {(unsigned char*)font_22x36,FONT_TYPE_1BPP,22,36,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_24X40
+    #include "font/ugui_font_24x40.h"
+    __UG_FONT_DATA UG_FONT FONT_24X40 = {(unsigned char*)font_24x40,FONT_TYPE_1BPP,24,40,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_32X53
+    #include "font/ugui_font_32x53.h"
+    __UG_FONT_DATA UG_FONT FONT_32X53 = {(unsigned char*)font_32x53,FONT_TYPE_1BPP,32,53,0x20,0x7E,NULL,NULL};
+#endif
+
+#ifdef USE_FONT_GB2312_12X12
+    #include "font/ugui_gb2312_12x12.h"
+    __UG_FONT_DATA UG_FONT FONT_GB2312_12X12 = {(unsigned char*)font_gb2312_12x12,FONT_TYPE_1BPP,12,12,0xA1A2,0xF7FE,NULL,\
+                                                {(UG_U16*)font_gb2312_12x12_index,sizeof(font_gb2312_12x12_index)/(sizeof(UG_U16)*2)}};
+#endif
+
+#ifdef USE_FONT_GB2312_20X20
+    #include "font/ugui_gb2312_20x20.h"
+    __UG_FONT_DATA UG_FONT FONT_GB2312_20X20 = {(unsigned char*)font_gb2312_20x20,FONT_TYPE_1BPP,20,20,0xA1A2,0xF7FE,NULL,\
+                                                {(UG_U16*)font_gb2312_20x20_index,sizeof(font_gb2312_20x20_index)/(sizeof(UG_U16)*2)}};
+#endif
+
+#ifdef USE_FONT_GB2312_36X36
+    #include "font/ugui_gb2312_36x36.h"
+    __UG_FONT_DATA UG_FONT FONT_GB2312_36X36 = {(unsigned char*)font_gb2312_36x36,FONT_TYPE_1BPP,36,36,0xA1A2,0xF7FE,NULL,\
+                                                {(UG_U16*)font_gb2312_36x36_index,sizeof(font_gb2312_36x36_index)/(sizeof(UG_U16)*2)}};
+#endif
+
+
diff --git a/APP/bootloader/font/ugui_font_12x20.h b/APP/bootloader/font/ugui_font_12x20.h
new file mode 100644 (file)
index 0000000..2371d05
--- /dev/null
@@ -0,0 +1,120 @@
+/* -------------------------------------------------------------------------------- */
+/* -- uGUI - Generic GUI module (C)Achim D?bler, 2015                            -- */
+/* -------------------------------------------------------------------------------- */
+// uGUI is a generic GUI module for embedded systems.
+// This is a free software that is open for education, research and commercial
+// developments under license policy of following terms.
+//
+//  Copyright (C) 2015, Achim D?bler, all rights reserved.
+//  URL: http://www.embeddedlightning.com/
+//
+// * The uGUI module is a free software and there is NO WARRANTY.
+// * No restriction on use. You can use, modify and redistribute it for
+//   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+// * Redistributions of source code must retain the above copyright notice.
+//
+/* -------------------------------------------------------------------------------- */
+#ifndef __UGUI_FONT_12X20_H
+#define __UGUI_FONT_12X20_H
+
+#include "ugui_config.h"
+
+__UG_FONT_DATA UG_U8 font_12x20[][40]={
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x20
+{0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x21
+{0x00,0x00,0x8C,0x01,0x8C,0x01,0x8C,0x01,0x8C,0x01,0x8C,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x22
+{0x00,0x00,0x00,0x00,0x20,0x02,0x20,0x02,0x10,0x01,0x10,0x01,0x10,0x01,0xFE,0x0F,0x88,0x00,0x88,0x00,0x88,0x00,0xFE,0x07,0x44,0x00,0x44,0x00,0x22,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x23
+{0x00,0x00,0x40,0x00,0xF0,0x01,0xF8,0x03,0x4C,0x02,0x4C,0x00,0x4C,0x00,0x78,0x00,0x70,0x00,0xC0,0x01,0xC0,0x01,0x40,0x03,0x40,0x03,0x44,0x03,0xFC,0x01,0xF8,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x24
+{0x00,0x00,0x00,0x00,0x1E,0x08,0x33,0x04,0x33,0x02,0x33,0x01,0xB3,0x00,0xB3,0x00,0x5E,0x00,0xA0,0x07,0xD0,0x0C,0xD0,0x0C,0xC8,0x0C,0xC4,0x0C,0xC2,0x0C,0x81,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x25
+{0x00,0x00,0x00,0x00,0xF0,0x00,0xF8,0x01,0x98,0x01,0x98,0x01,0xD8,0x00,0x70,0x00,0x3C,0x00,0x66,0x0C,0xE3,0x0C,0xC3,0x0C,0x83,0x07,0x87,0x07,0xFE,0x07,0xFC,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x26
+{0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x27
+{0x00,0x00,0x00,0x03,0xC0,0x03,0xE0,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0xE0,0x00,0xC0,0x03,0x00,0x03,0x00,0x00},  // 0x28
+{0x00,0x00,0x0C,0x00,0x3C,0x00,0x70,0x00,0x60,0x00,0xC0,0x00,0xC0,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xC0,0x00,0xC0,0x00,0x60,0x00,0x70,0x00,0x3C,0x00,0x0C,0x00,0x00,0x00},  // 0x29
+{0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x36,0x03,0xCE,0x03,0x00,0x00,0xD8,0x00,0x9C,0x01,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x2A
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFE,0x07,0xFE,0x07,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x2B
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x00,0x00},  // 0x2C
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x2D
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x2E
+{0x00,0x00,0x00,0x06,0x00,0x03,0x00,0x03,0x80,0x01,0x80,0x01,0x80,0x01,0xC0,0x00,0xC0,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x06,0x00,0x00,0x00},  // 0x2F
+{0x00,0x00,0x00,0x00,0xF0,0x00,0xF8,0x01,0x0C,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0x0C,0x03,0xF8,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x30
+{0x00,0x00,0x00,0x00,0x60,0x00,0x7C,0x00,0x66,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x31
+{0x00,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x84,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x80,0x01,0xC0,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0xFC,0x03,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x32
+{0x00,0x00,0x00,0x00,0xF8,0x00,0xFC,0x03,0x04,0x03,0x00,0x03,0x80,0x01,0xF8,0x00,0xF8,0x00,0x80,0x01,0x00,0x03,0x00,0x03,0x00,0x03,0x84,0x03,0xFC,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x33
+{0x00,0x00,0x00,0x00,0x80,0x01,0xC0,0x01,0xE0,0x01,0xA0,0x01,0x90,0x01,0x98,0x01,0x8C,0x01,0x84,0x01,0xFE,0x07,0xFE,0x07,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x34
+{0x00,0x00,0x00,0x00,0xF8,0x03,0xF8,0x03,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0xF8,0x00,0xF8,0x01,0x80,0x03,0x00,0x03,0x00,0x03,0x80,0x03,0xF8,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x35
+{0x00,0x00,0x00,0x00,0xF0,0x00,0xF8,0x01,0x1C,0x01,0x0C,0x00,0x06,0x00,0xE6,0x00,0xF6,0x01,0x8E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8C,0x03,0xFC,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x36
+{0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x07,0x00,0x06,0x00,0x03,0x00,0x01,0x80,0x01,0xC0,0x00,0x40,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x37
+{0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x01,0x8C,0x01,0x8C,0x01,0x9C,0x01,0xF8,0x00,0x70,0x00,0xEC,0x01,0x86,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x38
+{0x00,0x00,0x00,0x00,0x78,0x00,0xFC,0x01,0x8E,0x01,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0x7C,0x03,0x38,0x03,0x00,0x03,0x80,0x01,0xC4,0x01,0xFC,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x39
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x3A
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x00,0x00},  // 0x3B
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x07,0xC0,0x03,0xE0,0x00,0x38,0x00,0x0E,0x00,0x38,0x00,0xE0,0x00,0xC0,0x03,0x00,0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x3C
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x3D
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x0E,0x00,0x3C,0x00,0x70,0x00,0xC0,0x01,0x00,0x07,0xC0,0x01,0x70,0x00,0x3C,0x00,0x0E,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x3E
+{0x00,0x00,0x00,0x00,0xFE,0x00,0xFE,0x03,0x82,0x03,0x00,0x03,0x00,0x03,0x80,0x01,0xC0,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x3F
+{0x00,0x00,0x00,0x00,0xF0,0x01,0x18,0x03,0x0C,0x06,0xC6,0x07,0x63,0x06,0x33,0x06,0x33,0x06,0x33,0x07,0x33,0x07,0xF3,0x06,0x66,0x0E,0x06,0x00,0x0C,0x00,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x40
+{0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xD0,0x00,0x98,0x01,0x98,0x01,0x8C,0x03,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x41
+{0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0xFE,0x01,0x86,0x01,0x86,0x01,0xC6,0x00,0x7E,0x00,0xFE,0x00,0x86,0x01,0x06,0x03,0x06,0x03,0x06,0x03,0xFE,0x01,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x42
+{0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x07,0x1C,0x04,0x0C,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x3C,0x04,0xF8,0x07,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x43
+{0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0xFE,0x01,0x86,0x03,0x06,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x03,0x86,0x03,0xFE,0x01,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x44
+{0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x07,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x03,0xFC,0x03,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x07,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x45
+{0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x07,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x03,0xFC,0x03,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x46
+{0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x07,0x1C,0x04,0x0C,0x00,0x06,0x00,0x06,0x00,0x86,0x07,0x86,0x07,0x06,0x06,0x0C,0x06,0x1C,0x06,0xF8,0x07,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x47
+{0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0xFE,0x03,0xFE,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x48
+{0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x01,0xFE,0x01,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xFE,0x01,0xFE,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x49
+{0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xF8,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xC0,0x01,0xFC,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x4A
+{0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x86,0x03,0xC6,0x01,0xE6,0x00,0x66,0x00,0x36,0x00,0x3E,0x00,0x76,0x00,0xE6,0x00,0xC6,0x01,0x86,0x03,0x06,0x07,0x06,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x4B
+{0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x07,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x4C
+{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x8F,0x07,0x8B,0x06,0x8B,0x06,0xDB,0x06,0x53,0x06,0x53,0x06,0x73,0x06,0x23,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x4D
+{0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x06,0x0E,0x06,0x1E,0x06,0x1E,0x06,0x36,0x06,0x76,0x06,0x66,0x06,0xE6,0x06,0xC6,0x06,0x86,0x07,0x86,0x07,0x06,0x07,0x06,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x4E
+{0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x8E,0x03,0x07,0x07,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x07,0x07,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x4F
+{0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x01,0xFC,0x03,0x0C,0x07,0x0C,0x06,0x0C,0x06,0x0C,0x07,0xFC,0x03,0xFC,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x50
+{0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x8E,0x03,0x07,0x07,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x06,0x03,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x80,0x03,0x00,0x0F,0x00,0x04,0x00,0x00},  // 0x51
+{0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0xFE,0x01,0x86,0x01,0x86,0x01,0x86,0x01,0xC6,0x01,0xFE,0x00,0x7E,0x00,0xE6,0x00,0xC6,0x01,0x86,0x03,0x06,0x07,0x06,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x52
+{0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x06,0x01,0x06,0x00,0x0E,0x00,0x3C,0x00,0xF8,0x00,0xC0,0x03,0x00,0x03,0x00,0x03,0x86,0x03,0xFE,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x53
+{0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x54
+{0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x55
+{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x0C,0x06,0x06,0x06,0x06,0x0E,0x06,0x0C,0x03,0x0C,0x03,0x1C,0x03,0x98,0x01,0xB8,0x01,0xB0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x56
+{0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x03,0x0C,0x03,0x0C,0x62,0x04,0x62,0x04,0xE2,0x06,0xF6,0x06,0x96,0x06,0x96,0x06,0x96,0x03,0x9C,0x03,0x9C,0x03,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x57
+{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x0E,0x0E,0x06,0x0C,0x03,0x98,0x01,0xF8,0x00,0xF0,0x00,0x60,0x00,0xF0,0x00,0xD8,0x01,0x98,0x01,0x0C,0x03,0x06,0x07,0x03,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x58
+{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x0C,0x06,0x06,0x0C,0x03,0x1C,0x03,0x98,0x01,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x59
+{0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x07,0xFE,0x07,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0x06,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x5A
+{0x00,0x00,0xF0,0x03,0xF0,0x03,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xF0,0x03,0xF0,0x03,0x00,0x00},  // 0x5B
+{0x00,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0x60,0x00,0xC0,0x00,0xC0,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x00},  // 0x5C
+{0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xFC,0x00,0xFC,0x00,0x00,0x00},  // 0x5D
+{0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0xE0,0x00,0xA0,0x00,0xB0,0x00,0xB0,0x01,0x18,0x01,0x18,0x03,0x0C,0x03,0x0C,0x02,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x5E
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00},  // 0x5F
+{0x60,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x60
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x04,0x03,0x00,0x03,0x00,0x03,0xF8,0x03,0x0C,0x03,0x06,0x03,0x86,0x03,0xFE,0x0F,0x7C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x61
+{0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xE6,0x00,0xF6,0x01,0x9E,0x03,0x0E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x01,0xFE,0x01,0xF6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x62
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x01,0xFC,0x03,0x1C,0x02,0x0E,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x0E,0x00,0x1C,0x00,0xFC,0x03,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x63
+{0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x78,0x03,0xFC,0x03,0x8C,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x03,0x38,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x64
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x01,0x8C,0x03,0x06,0x03,0xFE,0x03,0xFE,0x03,0x06,0x00,0x06,0x00,0x0C,0x02,0xFC,0x03,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x65
+{0x00,0x00,0xE0,0x07,0xF0,0x07,0x30,0x00,0x30,0x00,0xFE,0x07,0xFE,0x07,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x66
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x03,0xFC,0x03,0x8C,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x03,0x78,0x03,0x00,0x03,0x84,0x03,0xFC,0x01,0xF8,0x00},  // 0x67
+{0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xE6,0x01,0xF6,0x03,0x1E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x68
+{0x00,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x69
+{0x00,0x00,0x80,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0xF8,0x01,0xF8,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xC0,0x01,0xFC,0x00,0x7C,0x00},  // 0x6A
+{0x00,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x07,0x8C,0x03,0xCC,0x01,0xEC,0x00,0x6C,0x00,0x7C,0x00,0xEC,0x00,0xCC,0x01,0x8C,0x03,0x0C,0x07,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x6B
+{0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x6C
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9B,0x03,0xFF,0x07,0x77,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x6D
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE6,0x01,0xF6,0x03,0x1E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x6E
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x6F
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF6,0x00,0xFE,0x01,0x8E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x01,0xFE,0x01,0xF6,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00},  // 0x70
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x03,0xFC,0x03,0x8C,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0x7C,0x03,0x38,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03},  // 0x71
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC,0x03,0xEC,0x03,0x3C,0x02,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x72
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x01,0x0C,0x00,0x0C,0x00,0x3C,0x00,0xF0,0x01,0x80,0x03,0x00,0x03,0x04,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x73
+{0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0xFE,0x07,0xFE,0x07,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xF0,0x07,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x74
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0xC6,0x03,0x7E,0x03,0x3C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x75
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x0C,0x02,0x0C,0x03,0x0C,0x03,0x18,0x01,0x98,0x01,0x98,0x01,0xB0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x76
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x63,0x0C,0x63,0x0C,0xE2,0x04,0xF6,0x04,0x96,0x04,0x96,0x06,0x96,0x07,0x9C,0x03,0x0C,0x03,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x77
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x07,0x0C,0x03,0x98,0x01,0xB8,0x00,0xF0,0x00,0x60,0x00,0xF0,0x00,0xD8,0x01,0x98,0x01,0x0C,0x03,0x06,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x78
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x0C,0x02,0x0C,0x03,0x1C,0x03,0x98,0x01,0x98,0x01,0xB0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x3C,0x00,0x1C,0x00},  // 0x79
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x03,0xFE,0x03,0x00,0x03,0x80,0x01,0xC0,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0xFE,0x03,0xFE,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  // 0x7A
+{0x00,0x00,0xC0,0x03,0xE0,0x03,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x3C,0x00,0x3C,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xE0,0x03,0xC0,0x03,0x00,0x00},  // 0x7B
+{0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00},  // 0x7C
+{0x00,0x00,0x3C,0x00,0x7C,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xC0,0x03,0xC0,0x03,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7C,0x00,0x3C,0x00,0x00,0x00},  // 0x7D
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x04,0xFE,0x07,0xC2,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}  // 0x7E
+};
+
+#endif
diff --git a/APP/bootloader/font/ugui_font_6x8.h b/APP/bootloader/font/ugui_font_6x8.h
new file mode 100644 (file)
index 0000000..811af3b
--- /dev/null
@@ -0,0 +1,120 @@
+/* -------------------------------------------------------------------------------- */
+/* -- uGUI - Generic GUI module (C)Achim D?bler, 2015                            -- */
+/* -------------------------------------------------------------------------------- */
+// uGUI is a generic GUI module for embedded systems.
+// This is a free software that is open for education, research and commercial
+// developments under license policy of following terms.
+//
+//  Copyright (C) 2015, Achim D?bler, all rights reserved.
+//  URL: http://www.embeddedlightning.com/
+//
+// * The uGUI module is a free software and there is NO WARRANTY.
+// * No restriction on use. You can use, modify and redistribute it for
+//   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+// * Redistributions of source code must retain the above copyright notice.
+//
+/* -------------------------------------------------------------------------------- */
+#ifndef __UGUI_FONT_6X8_H
+#define __UGUI_FONT_6X8_H
+
+#include "ugui_config.h"
+
+__UG_FONT_DATA unsigned char font_6x8[][8]={
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},   // 0x20
+{0x08,0x1C,0x1C,0x08,0x08,0x00,0x08,0x00},   // 0x21
+{0x36,0x36,0x12,0x00,0x00,0x00,0x00,0x00},   // 0x22
+{0x00,0x14,0x3E,0x14,0x14,0x3E,0x14,0x00},   // 0x23
+{0x04,0x1C,0x02,0x0C,0x10,0x0E,0x08,0x00},   // 0x24
+{0x26,0x26,0x10,0x08,0x04,0x32,0x32,0x00},   // 0x25
+{0x04,0x0A,0x0A,0x04,0x2A,0x12,0x2C,0x00},   // 0x26
+{0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00},   // 0x27
+{0x08,0x04,0x04,0x04,0x04,0x04,0x08,0x00},   // 0x28
+{0x04,0x08,0x08,0x08,0x08,0x08,0x04,0x00},   // 0x29
+{0x00,0x14,0x1C,0x3E,0x1C,0x14,0x00,0x00},   // 0x2A
+{0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},   // 0x2B
+{0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x04},   // 0x2C
+{0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x00},   // 0x2D
+{0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00},   // 0x2E
+{0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},   // 0x2F
+{0x1C,0x22,0x32,0x2A,0x26,0x22,0x1C,0x00},   // 0x30
+{0x08,0x0C,0x08,0x08,0x08,0x08,0x1C,0x00},   // 0x31
+{0x1C,0x22,0x20,0x18,0x04,0x02,0x3E,0x00},   // 0x32
+{0x1C,0x22,0x20,0x1C,0x20,0x22,0x1C,0x00},   // 0x33
+{0x10,0x18,0x14,0x12,0x3E,0x10,0x10,0x00},   // 0x34
+{0x3E,0x02,0x02,0x1E,0x20,0x22,0x1C,0x00},   // 0x35
+{0x18,0x04,0x02,0x1E,0x22,0x22,0x1C,0x00},   // 0x36
+{0x3E,0x20,0x10,0x08,0x04,0x04,0x04,0x00},   // 0x37
+{0x1C,0x22,0x22,0x1C,0x22,0x22,0x1C,0x00},   // 0x38
+{0x1C,0x22,0x22,0x3C,0x20,0x10,0x0C,0x00},   // 0x39
+{0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00},   // 0x3A
+{0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x04},   // 0x3B
+{0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x00},   // 0x3C
+{0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00},   // 0x3D
+{0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x00},   // 0x3E
+{0x1C,0x22,0x20,0x18,0x08,0x00,0x08,0x00},   // 0x3F
+{0x1C,0x22,0x3A,0x2A,0x3A,0x02,0x1C,0x00},   // 0x40
+{0x1C,0x22,0x22,0x22,0x3E,0x22,0x22,0x00},   // 0x41
+{0x1E,0x22,0x22,0x1E,0x22,0x22,0x1E,0x00},   // 0x42
+{0x1C,0x22,0x02,0x02,0x02,0x22,0x1C,0x00},   // 0x43
+{0x1E,0x22,0x22,0x22,0x22,0x22,0x1E,0x00},   // 0x44
+{0x3E,0x02,0x02,0x1E,0x02,0x02,0x3E,0x00},   // 0x45
+{0x3E,0x02,0x02,0x1E,0x02,0x02,0x02,0x00},   // 0x46
+{0x1C,0x22,0x02,0x3A,0x22,0x22,0x3C,0x00},   // 0x47
+{0x22,0x22,0x22,0x3E,0x22,0x22,0x22,0x00},   // 0x48
+{0x1C,0x08,0x08,0x08,0x08,0x08,0x1C,0x00},   // 0x49
+{0x20,0x20,0x20,0x20,0x22,0x22,0x1C,0x00},   // 0x4A
+{0x22,0x12,0x0A,0x06,0x0A,0x12,0x22,0x00},   // 0x4B
+{0x02,0x02,0x02,0x02,0x02,0x02,0x3E,0x00},   // 0x4C
+{0x22,0x36,0x2A,0x22,0x22,0x22,0x22,0x00},   // 0x4D
+{0x22,0x26,0x2A,0x32,0x22,0x22,0x22,0x00},   // 0x4E
+{0x1C,0x22,0x22,0x22,0x22,0x22,0x1C,0x00},   // 0x4F
+{0x1E,0x22,0x22,0x1E,0x02,0x02,0x02,0x00},   // 0x50
+{0x1C,0x22,0x22,0x22,0x2A,0x12,0x2C,0x00},   // 0x51
+{0x1E,0x22,0x22,0x1E,0x12,0x22,0x22,0x00},   // 0x52
+{0x1C,0x22,0x02,0x1C,0x20,0x22,0x1C,0x00},   // 0x53
+{0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x00},   // 0x54
+{0x22,0x22,0x22,0x22,0x22,0x22,0x1C,0x00},   // 0x55
+{0x22,0x22,0x22,0x22,0x22,0x14,0x08,0x00},   // 0x56
+{0x22,0x22,0x2A,0x2A,0x2A,0x2A,0x14,0x00},   // 0x57
+{0x22,0x22,0x14,0x08,0x14,0x22,0x22,0x00},   // 0x58
+{0x22,0x22,0x22,0x14,0x08,0x08,0x08,0x00},   // 0x59
+{0x1E,0x10,0x08,0x04,0x02,0x02,0x1E,0x00},   // 0x5A
+{0x1C,0x04,0x04,0x04,0x04,0x04,0x1C,0x00},   // 0x5B
+{0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},   // 0x5C
+{0x1C,0x10,0x10,0x10,0x10,0x10,0x1C,0x00},   // 0x5D
+{0x08,0x14,0x22,0x00,0x00,0x00,0x00,0x00},   // 0x5E
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F},   // 0x5F
+{0x0C,0x0C,0x08,0x00,0x00,0x00,0x00,0x00},   // 0x60
+{0x00,0x00,0x1C,0x20,0x3C,0x22,0x3C,0x00},   // 0x61
+{0x02,0x02,0x1E,0x22,0x22,0x22,0x1E,0x00},   // 0x62
+{0x00,0x00,0x1C,0x22,0x02,0x22,0x1C,0x00},   // 0x63
+{0x20,0x20,0x3C,0x22,0x22,0x22,0x3C,0x00},   // 0x64
+{0x00,0x00,0x1C,0x22,0x1E,0x02,0x1C,0x00},   // 0x65
+{0x18,0x04,0x04,0x1E,0x04,0x04,0x04,0x00},   // 0x66
+{0x00,0x00,0x3C,0x22,0x22,0x3C,0x20,0x1C},   // 0x67
+{0x02,0x02,0x0E,0x12,0x12,0x12,0x12,0x00},   // 0x68
+{0x08,0x00,0x08,0x08,0x08,0x08,0x18,0x00},   // 0x69
+{0x10,0x00,0x18,0x10,0x10,0x10,0x12,0x0C},   // 0x6A
+{0x02,0x02,0x12,0x0A,0x06,0x0A,0x12,0x00},   // 0x6B
+{0x08,0x08,0x08,0x08,0x08,0x08,0x18,0x00},   // 0x6C
+{0x00,0x00,0x16,0x2A,0x2A,0x22,0x22,0x00},   // 0x6D
+{0x00,0x00,0x0E,0x12,0x12,0x12,0x12,0x00},   // 0x6E
+{0x00,0x00,0x1C,0x22,0x22,0x22,0x1C,0x00},   // 0x6F
+{0x00,0x00,0x1E,0x22,0x22,0x22,0x1E,0x02},   // 0x70
+{0x00,0x00,0x3C,0x22,0x22,0x22,0x3C,0x20},   // 0x71
+{0x00,0x00,0x1A,0x24,0x04,0x04,0x0E,0x00},   // 0x72
+{0x00,0x00,0x1C,0x02,0x1C,0x20,0x1C,0x00},   // 0x73
+{0x00,0x04,0x1E,0x04,0x04,0x14,0x08,0x00},   // 0x74
+{0x00,0x00,0x12,0x12,0x12,0x1A,0x14,0x00},   // 0x75
+{0x00,0x00,0x22,0x22,0x22,0x14,0x08,0x00},   // 0x76
+{0x00,0x00,0x22,0x22,0x2A,0x3E,0x14,0x00},   // 0x77
+{0x00,0x00,0x12,0x12,0x0C,0x12,0x12,0x00},   // 0x78
+{0x00,0x00,0x12,0x12,0x12,0x1C,0x08,0x06},   // 0x79
+{0x00,0x00,0x1E,0x10,0x0C,0x02,0x1E,0x00},   // 0x7A
+{0x18,0x04,0x04,0x06,0x04,0x04,0x18,0x00},   // 0x7B
+{0x08,0x08,0x08,0x00,0x08,0x08,0x08,0x00},   // 0x7C
+{0x0C,0x10,0x10,0x30,0x10,0x10,0x0C,0x00},   // 0x7D
+{0x14,0x0A,0x00,0x00,0x00,0x00,0x00,0x00}   // 0x7E
+};
+
+#endif
diff --git a/APP/bootloader/font/ugui_font_8x12.h b/APP/bootloader/font/ugui_font_8x12.h
new file mode 100644 (file)
index 0000000..f66ec18
--- /dev/null
@@ -0,0 +1,120 @@
+/* -------------------------------------------------------------------------------- */
+/* -- uGUI - Generic GUI module (C)Achim D?bler, 2015                            -- */
+/* -------------------------------------------------------------------------------- */
+// uGUI is a generic GUI module for embedded systems.
+// This is a free software that is open for education, research and commercial
+// developments under license policy of following terms.
+//
+//  Copyright (C) 2015, Achim D?bler, all rights reserved.
+//  URL: http://www.embeddedlightning.com/
+//
+// * The uGUI module is a free software and there is NO WARRANTY.
+// * No restriction on use. You can use, modify and redistribute it for
+//   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+// * Redistributions of source code must retain the above copyright notice.
+//
+/* -------------------------------------------------------------------------------- */
+#ifndef __UGUI_FONT_8X12_H
+#define __UGUI_FONT_8X12_H
+
+#include "ugui_config.h"
+
+__UG_FONT_DATA UG_U8 font_8x12[][12]={
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20
+{0x00,0x0C,0x1E,0x1E,0x1E,0x0C,0x0C,0x00,0x0C,0x0C,0x00,0x00}, // 0x21
+{0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x22
+{0x00,0x36,0x36,0x7F,0x36,0x36,0x36,0x7F,0x36,0x36,0x00,0x00}, // 0x23
+{0x0C,0x0C,0x3E,0x03,0x03,0x1E,0x30,0x30,0x1F,0x0C,0x0C,0x00}, // 0x24
+{0x00,0x00,0x00,0x23,0x33,0x18,0x0C,0x06,0x33,0x31,0x00,0x00}, // 0x25
+{0x00,0x0E,0x1B,0x1B,0x0E,0x5F,0x7B,0x33,0x3B,0x6E,0x00,0x00}, // 0x26
+{0x00,0x0C,0x0C,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x27
+{0x00,0x30,0x18,0x0C,0x06,0x06,0x06,0x0C,0x18,0x30,0x00,0x00}, // 0x28
+{0x00,0x06,0x0C,0x18,0x30,0x30,0x30,0x18,0x0C,0x06,0x00,0x00}, // 0x29
+{0x00,0x00,0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,0x00,0x00}, // 0x2A
+{0x00,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,0x00,0x00}, // 0x2B
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x06,0x00}, // 0x2C
+{0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x2D
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00,0x00}, // 0x2E
+{0x00,0x00,0x40,0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00,0x00}, // 0x2F
+{0x00,0x3E,0x63,0x73,0x7B,0x6B,0x6F,0x67,0x63,0x3E,0x00,0x00}, // 0x30
+{0x00,0x08,0x0C,0x0F,0x0C,0x0C,0x0C,0x0C,0x0C,0x3F,0x00,0x00}, // 0x31
+{0x00,0x1E,0x33,0x33,0x30,0x18,0x0C,0x06,0x33,0x3F,0x00,0x00}, // 0x32
+{0x00,0x1E,0x33,0x30,0x30,0x1C,0x30,0x30,0x33,0x1E,0x00,0x00}, // 0x33
+{0x00,0x30,0x38,0x3C,0x36,0x33,0x7F,0x30,0x30,0x78,0x00,0x00}, // 0x34
+{0x00,0x3F,0x03,0x03,0x03,0x1F,0x30,0x30,0x33,0x1E,0x00,0x00}, // 0x35
+{0x00,0x1C,0x06,0x03,0x03,0x1F,0x33,0x33,0x33,0x1E,0x00,0x00}, // 0x36
+{0x00,0x7F,0x63,0x63,0x60,0x30,0x18,0x0C,0x0C,0x0C,0x00,0x00}, // 0x37
+{0x00,0x1E,0x33,0x33,0x33,0x1E,0x33,0x33,0x33,0x1E,0x00,0x00}, // 0x38
+{0x00,0x1E,0x33,0x33,0x33,0x3E,0x18,0x18,0x0C,0x0E,0x00,0x00}, // 0x39
+{0x00,0x00,0x00,0x1C,0x1C,0x00,0x00,0x1C,0x1C,0x00,0x00,0x00}, // 0x3A
+{0x00,0x00,0x00,0x1C,0x1C,0x00,0x00,0x1C,0x1C,0x18,0x0C,0x00}, // 0x3B
+{0x00,0x30,0x18,0x0C,0x06,0x03,0x06,0x0C,0x18,0x30,0x00,0x00}, // 0x3C
+{0x00,0x00,0x00,0x00,0x7E,0x00,0x7E,0x00,0x00,0x00,0x00,0x00}, // 0x3D
+{0x00,0x06,0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x06,0x00,0x00}, // 0x3E
+{0x00,0x1E,0x33,0x30,0x18,0x0C,0x0C,0x00,0x0C,0x0C,0x00,0x00}, // 0x3F
+{0x00,0x3E,0x63,0x63,0x7B,0x7B,0x7B,0x03,0x03,0x3E,0x00,0x00}, // 0x40
+{0x00,0x0C,0x1E,0x33,0x33,0x33,0x3F,0x33,0x33,0x33,0x00,0x00}, // 0x41
+{0x00,0x3F,0x66,0x66,0x66,0x3E,0x66,0x66,0x66,0x3F,0x00,0x00}, // 0x42
+{0x00,0x3C,0x66,0x63,0x03,0x03,0x03,0x63,0x66,0x3C,0x00,0x00}, // 0x43
+{0x00,0x1F,0x36,0x66,0x66,0x66,0x66,0x66,0x36,0x1F,0x00,0x00}, // 0x44
+{0x00,0x7F,0x46,0x06,0x26,0x3E,0x26,0x06,0x46,0x7F,0x00,0x00}, // 0x45
+{0x00,0x7F,0x66,0x46,0x26,0x3E,0x26,0x06,0x06,0x0F,0x00,0x00}, // 0x46
+{0x00,0x3C,0x66,0x63,0x03,0x03,0x73,0x63,0x66,0x7C,0x00,0x00}, // 0x47
+{0x00,0x33,0x33,0x33,0x33,0x3F,0x33,0x33,0x33,0x33,0x00,0x00}, // 0x48
+{0x00,0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00,0x00}, // 0x49
+{0x00,0x78,0x30,0x30,0x30,0x30,0x33,0x33,0x33,0x1E,0x00,0x00}, // 0x4A
+{0x00,0x67,0x66,0x36,0x36,0x1E,0x36,0x36,0x66,0x67,0x00,0x00}, // 0x4B
+{0x00,0x0F,0x06,0x06,0x06,0x06,0x46,0x66,0x66,0x7F,0x00,0x00}, // 0x4C
+{0x00,0x63,0x77,0x7F,0x7F,0x6B,0x63,0x63,0x63,0x63,0x00,0x00}, // 0x4D
+{0x00,0x63,0x63,0x67,0x6F,0x7F,0x7B,0x73,0x63,0x63,0x00,0x00}, // 0x4E
+{0x00,0x1C,0x36,0x63,0x63,0x63,0x63,0x63,0x36,0x1C,0x00,0x00}, // 0x4F
+{0x00,0x3F,0x66,0x66,0x66,0x3E,0x06,0x06,0x06,0x0F,0x00,0x00}, // 0x50
+{0x00,0x1C,0x36,0x63,0x63,0x63,0x73,0x7B,0x3E,0x30,0x78,0x00}, // 0x51
+{0x00,0x3F,0x66,0x66,0x66,0x3E,0x36,0x66,0x66,0x67,0x00,0x00}, // 0x52
+{0x00,0x1E,0x33,0x33,0x03,0x0E,0x18,0x33,0x33,0x1E,0x00,0x00}, // 0x53
+{0x00,0x3F,0x2D,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00,0x00}, // 0x54
+{0x00,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x1E,0x00,0x00}, // 0x55
+{0x00,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x1E,0x0C,0x00,0x00}, // 0x56
+{0x00,0x63,0x63,0x63,0x63,0x6B,0x6B,0x36,0x36,0x36,0x00,0x00}, // 0x57
+{0x00,0x33,0x33,0x33,0x1E,0x0C,0x1E,0x33,0x33,0x33,0x00,0x00}, // 0x58
+{0x00,0x33,0x33,0x33,0x33,0x1E,0x0C,0x0C,0x0C,0x1E,0x00,0x00}, // 0x59
+{0x00,0x7F,0x73,0x19,0x18,0x0C,0x06,0x46,0x63,0x7F,0x00,0x00}, // 0x5A
+{0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00,0x00}, // 0x5B
+{0x00,0x00,0x01,0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00,0x00}, // 0x5C
+{0x00,0x3C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3C,0x00,0x00}, // 0x5D
+{0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x5E
+{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00}, // 0x5F
+{0x0C,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x60
+{0x00,0x00,0x00,0x00,0x1E,0x30,0x3E,0x33,0x33,0x6E,0x00,0x00}, // 0x61
+{0x00,0x07,0x06,0x06,0x3E,0x66,0x66,0x66,0x66,0x3B,0x00,0x00}, // 0x62
+{0x00,0x00,0x00,0x00,0x1E,0x33,0x03,0x03,0x33,0x1E,0x00,0x00}, // 0x63
+{0x00,0x38,0x30,0x30,0x3E,0x33,0x33,0x33,0x33,0x6E,0x00,0x00}, // 0x64
+{0x00,0x00,0x00,0x00,0x1E,0x33,0x3F,0x03,0x33,0x1E,0x00,0x00}, // 0x65
+{0x00,0x1C,0x36,0x06,0x06,0x1F,0x06,0x06,0x06,0x0F,0x00,0x00}, // 0x66
+{0x00,0x00,0x00,0x00,0x6E,0x33,0x33,0x33,0x3E,0x30,0x33,0x1E}, // 0x67
+{0x00,0x07,0x06,0x06,0x36,0x6E,0x66,0x66,0x66,0x67,0x00,0x00}, // 0x68
+{0x00,0x18,0x18,0x00,0x1E,0x18,0x18,0x18,0x18,0x7E,0x00,0x00}, // 0x69
+{0x00,0x30,0x30,0x00,0x3C,0x30,0x30,0x30,0x30,0x33,0x33,0x1E}, // 0x6A
+{0x00,0x07,0x06,0x06,0x66,0x36,0x1E,0x36,0x66,0x67,0x00,0x00}, // 0x6B
+{0x00,0x1E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00}, // 0x6C
+{0x00,0x00,0x00,0x00,0x3F,0x6B,0x6B,0x6B,0x6B,0x63,0x00,0x00}, // 0x6D
+{0x00,0x00,0x00,0x00,0x1F,0x33,0x33,0x33,0x33,0x33,0x00,0x00}, // 0x6E
+{0x00,0x00,0x00,0x00,0x1E,0x33,0x33,0x33,0x33,0x1E,0x00,0x00}, // 0x6F
+{0x00,0x00,0x00,0x00,0x3B,0x66,0x66,0x66,0x66,0x3E,0x06,0x0F}, // 0x70
+{0x00,0x00,0x00,0x00,0x6E,0x33,0x33,0x33,0x33,0x3E,0x30,0x78}, // 0x71
+{0x00,0x00,0x00,0x00,0x37,0x76,0x6E,0x06,0x06,0x0F,0x00,0x00}, // 0x72
+{0x00,0x00,0x00,0x00,0x1E,0x33,0x06,0x18,0x33,0x1E,0x00,0x00}, // 0x73
+{0x00,0x00,0x04,0x06,0x3F,0x06,0x06,0x06,0x36,0x1C,0x00,0x00}, // 0x74
+{0x00,0x00,0x00,0x00,0x33,0x33,0x33,0x33,0x33,0x6E,0x00,0x00}, // 0x75
+{0x00,0x00,0x00,0x00,0x33,0x33,0x33,0x33,0x1E,0x0C,0x00,0x00}, // 0x76
+{0x00,0x00,0x00,0x00,0x63,0x63,0x6B,0x6B,0x36,0x36,0x00,0x00}, // 0x77
+{0x00,0x00,0x00,0x00,0x63,0x36,0x1C,0x1C,0x36,0x63,0x00,0x00}, // 0x78
+{0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x3C,0x30,0x18,0x0F}, // 0x79
+{0x00,0x00,0x00,0x00,0x3F,0x31,0x18,0x06,0x23,0x3F,0x00,0x00}, // 0x7A
+{0x00,0x38,0x0C,0x0C,0x06,0x03,0x06,0x0C,0x0C,0x38,0x00,0x00}, // 0x7B
+{0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00}, // 0x7C
+{0x00,0x07,0x0C,0x0C,0x18,0x30,0x18,0x0C,0x0C,0x07,0x00,0x00}, // 0x7D
+{0x00,0xCE,0x5B,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 0x7E
+};
+
+#endif
diff --git a/APP/bootloader/iap.c b/APP/bootloader/iap.c
new file mode 100644 (file)
index 0000000..61b1381
--- /dev/null
@@ -0,0 +1,387 @@
+/**
+ *******************************************************************************************************************************************
+ * @file        iap.c
+ * @brief       bootloader 升级固件逻辑 (基于 SPI Flash GD25Q128E)
+ * @details     实现主程序/待升级程序分区的读取、CRC 校验、拷贝、以及跳转运行。
+ * *****************************************************************************************************************************************
+ *  SPIFlash 分区与固件头格式参见 iap.h 及 user_iap.h。
+ *
+ *  固件文件头 (16 字节):
+ *     Byte0~5  : 项目名 "BDM120"
+ *     Byte6    : 板子ID (0 保护板 / 1 液晶板 / 2 增强板)
+ *     Byte7~10 : 版本号 (Vx.x.x.x, 4 字节)
+ *     Byte11~13: 固件长度 (3 字节大端, 不含16字节头)
+ *     Byte14~15: 固件 CRC-CCITT (多项式 0x1021, 对固件正文计算)
+ *******************************************************************************************************************************************
+ */
+#include <string.h>
+#include "SWM341.h"
+#include "SPI_GD25Q128.h"
+#include "iap.h"
+
+/*************************************************************************************************************
+ * Private Prototype
+ *************************************************************************************************************/
+static uint16_t iap_crc16_block(const uint8_t *data, uint32_t len, uint16_t crc);
+static uint16_t iap_crc16_flash(uint32_t addr, uint32_t len);
+static uint16_t rd_be16(const uint8_t *p);
+
+/*************************************************************************************************************
+ * Public Function
+ *************************************************************************************************************/
+/**
+ * @brief   初始化 SPI Flash
+ * @return  0 = 芯片识别成功; 非0 = SPI Flash 异常
+ */
+int iap_init(void)
+{
+    return GD25Q128_Init() ? 0 : -1;
+}
+
+/**
+ * @brief   读取并校验某分区的固件
+ */
+int iap_part_valid(uint32_t part, firmware_info_t *out)
+{
+    uint8_t  hdr[IAP_FW_HDR_LEN];
+    uint32_t fw_size;
+    uint16_t fw_crc;
+    int      i;
+
+    /* 读取 16 字节固件头 */
+    GD25Q128_ReadData(part, hdr, IAP_FW_HDR_LEN);
+
+    /* 校验项目名 */
+    if (memcmp(hdr + IAP_FW_HDR_OFF_PROJ, IAP_PROJ_NAME, IAP_PROJ_NAME_LEN) != 0)
+        return -1;
+
+    /* 校验板子ID */
+    if (hdr[IAP_FW_HDR_OFF_BOARD] != IAP_BOARD_LCD )
+        return -1;
+
+    /* 解析固件长度 (Byte11~13 大端), 并校验不超出分区 */
+    fw_size  = ((uint32_t)hdr[IAP_FW_HDR_OFF_SIZE]     << 16) |
+               ((uint32_t)hdr[IAP_FW_HDR_OFF_SIZE + 1] <<  8) |
+               ((uint32_t)hdr[IAP_FW_HDR_OFF_SIZE + 2]);
+    if (fw_size == 0 || fw_size > (IAP_PART_SIZE - IAP_FW_HDR_LEN))
+        return -1;
+
+    /* 校验固件正文 CRC */
+    fw_crc = rd_be16(hdr + IAP_FW_HDR_OFF_CRC);
+    if (iap_crc16_flash(part+IAP_FW_HDR_LEN,fw_size) != fw_crc)
+        return -1;
+
+    if (out) {
+        memset(out, 0, sizeof(*out));
+        out->board_id = hdr[IAP_FW_HDR_OFF_BOARD];
+        for (i = 0; i < IAP_FW_HDR_VER_LEN; ++i)
+            out->version[i] = hdr[IAP_FW_HDR_OFF_VER + i];
+        out->size = fw_size;
+        out->crc  = fw_crc;
+    }
+    return 0;
+}
+
+/**
+ * @brief   判断 new 版本是否高于 old 版本
+ */
+int iap_need_update(const firmware_info_t *old, const firmware_info_t *new)
+{
+    int i;
+
+    if (!old || !new)
+        return 1;
+    for (i = 0; i < IAP_FW_HDR_VER_LEN; ++i) {
+        if (new->version[i] > old->version[i])
+            return 1;
+        if (new->version[i] < old->version[i])
+            return 0;
+    }
+    return 0;   /* 版本相同: 不升级 */
+}
+
+/**
+ * @brief   擦除分区内 [part, part+size) 区域 (按 4K 扇区)
+ */
+void iap_erase_part(uint32_t part, uint32_t size)
+{
+    uint32_t addr;
+    for (addr = part; addr < part + size; addr += IAP_FLASH_SECTOR){
+        GD25Q128_EraseSector(addr);
+        while (GD25Q128_IsBusy()) __NOP();   /* 等待擦除完成 */
+    }
+}
+
+/**
+ * @brief   将固件 (含16字节头) 从 src 分区整体拷贝到 dst 分区
+ */
+int iap_part_to_part(uint32_t src, uint32_t dst, uint32_t length,
+                     void (*progress)(uint32_t done, uint32_t total))
+{
+    uint8_t  buf[IAP_FLASH_PAGE];
+    uint32_t remain = length;
+    uint32_t offset = 0;
+    uint32_t n;
+
+    if (length == 0)
+        return -1;
+
+    /* 先擦除目标区域 (按扇区, 不足一扇区补足一扇区) */
+    iap_erase_part(dst, ((length + IAP_FLASH_SECTOR - 1) / IAP_FLASH_SECTOR) * IAP_FLASH_SECTOR);
+
+    /* 分页拷贝 */
+    while (remain) {
+        n = (remain > IAP_FLASH_PAGE) ? IAP_FLASH_PAGE : remain;
+
+        GD25Q128_ReadData(src + offset, buf, n);
+        GD25Q128_WriteBuff(dst + offset, buf, n);
+        while (GD25Q128_IsBusy()) __NOP();
+
+        offset += n;
+        remain -= n;
+
+//        if (progress)
+//            progress(offset, length);
+    }
+    return 0;
+}
+
+/**
+ * @brief   将分区固件体(跳过16字节头)拷贝到 SDRAM 指定地址
+ */
+int iap_part_to_sdram(uint32_t part, uint32_t size)
+{
+    uint8_t  buf[IAP_FLASH_PAGE];
+    uint32_t remain = size;
+    uint32_t offset = 0;
+    uint32_t n;
+    uint8_t *dst = (uint8_t *)IAP_APP_RUN_ADDR;
+
+    if (size == 0 || size > IAP_APP_RUN_SIZE)
+        return -1;
+
+    while (remain) {
+        n = (remain > IAP_FLASH_PAGE) ? IAP_FLASH_PAGE : remain;
+
+        GD25Q128_ReadData(part + IAP_FW_HDR_LEN + offset, buf, n);
+        memcpy(dst + offset, buf, n);
+
+        offset += n;
+        remain -= n;
+    }
+    return 0;
+}
+
+/**
+ * @brief   单遍加载分区固件到 SDRAM (读头校验 + 读正文 + 同步CRC), 只读一遍闪存
+ */
+int iap_part_load(uint32_t part, uint32_t dst, firmware_info_t *out)
+{
+    uint8_t       hdr[IAP_FW_HDR_LEN];
+    static uint8_t buf[IAP_FLASH_PAGE];
+    uint8_t      *d = (uint8_t *)dst;
+    uint32_t      fw_size;
+    uint16_t      fw_crc;
+    uint16_t      crc = 0;
+    uint32_t      off, n, i;
+
+    /* 读取并校验 16 字节文件头 */
+    GD25Q128_ReadData(part, hdr, IAP_FW_HDR_LEN);
+    memcpy(d, hdr, IAP_FW_HDR_LEN);               /* 头也保存到 SDRAM 缓冲 */
+
+    if (memcmp(hdr + IAP_FW_HDR_OFF_PROJ, IAP_PROJ_NAME, IAP_PROJ_NAME_LEN) != 0)
+        return -1;
+    if (hdr[IAP_FW_HDR_OFF_BOARD] != IAP_BOARD_LCD)
+        return -1;
+
+    fw_size  = ((uint32_t)hdr[IAP_FW_HDR_OFF_SIZE]     << 16) |
+               ((uint32_t)hdr[IAP_FW_HDR_OFF_SIZE + 1] <<  8) |
+               ((uint32_t)hdr[IAP_FW_HDR_OFF_SIZE + 2]);
+    if (fw_size == 0 || fw_size > (IAP_APP_RUN_SIZE - IAP_FW_HDR_LEN))
+        return -1;
+
+    fw_crc = rd_be16(hdr + IAP_FW_HDR_OFF_CRC);
+
+    /* 直读正文到 SDRAM, 同时流式计算 CRC (只读一遍闪存) */
+    off = 0;
+    while (off < fw_size) {
+        n = (fw_size - off) > IAP_FLASH_PAGE ? IAP_FLASH_PAGE : (fw_size - off);
+
+        GD25Q128_ReadData(part + IAP_FW_HDR_LEN + off, buf, n);
+        crc = iap_crc16_block(buf, n, crc);
+        memcpy(d + IAP_FW_HDR_LEN + off, buf, n);
+
+        off += n;
+    }
+
+    if (crc != fw_crc)
+        return -1;
+
+    if (out) {
+        memset(out, 0, sizeof(*out));
+        out->board_id = hdr[IAP_FW_HDR_OFF_BOARD];
+        for (i = 0; i < IAP_FW_HDR_VER_LEN; ++i)
+            out->version[i] = hdr[IAP_FW_HDR_OFF_VER + i];
+        out->size = fw_size;
+        out->crc  = fw_crc;
+    }
+    return 0;
+}
+
+/**
+ * @brief   将 SDRAM 缓冲(含16字节文件头)写入分区 (part2缓冲 → 分区1 升级)
+ */
+int iap_sdram_to_part(uint32_t src, uint32_t dst, uint32_t length)
+{
+    const uint8_t *s = (const uint8_t *)src;
+          uint8_t  buf[IAP_FLASH_PAGE];
+    uint32_t offset = 0;
+    uint32_t n;
+
+    if (length == 0)
+        return -1;
+
+    /* 先擦除目标区域 */
+    iap_erase_part(dst, ((length + IAP_FLASH_SECTOR - 1) / IAP_FLASH_SECTOR) * IAP_FLASH_SECTOR);
+
+    while (offset < length) {
+        n = (length - offset) > IAP_FLASH_PAGE ? IAP_FLASH_PAGE : (length - offset);
+
+        memcpy(buf, s + offset, n);
+        GD25Q128_WriteBuff(dst + offset, buf, n);
+        while (GD25Q128_IsBusy()) __NOP();
+
+        offset += n;
+    }
+    return 0;
+}
+
+/**
+ * @brief   跳转到 SDRAM 中的 App
+ */
+void iap_jump_app(uint32_t addr)
+{
+    uint32_t sp = *((volatile uint32_t *)(addr));          /* 初始 MSP */
+    uint32_t pc = *((volatile uint32_t *)(addr + 4));      /* 复位 PC */
+    static void (*jump)(void);      //这里使用static,不放在栈里面
+    jump = (void (*)(void))pc;
+
+    /* 关闭全局中断并清中断使能 */
+    __disable_irq();
+    __set_PRIMASK(1);
+
+    /* Disable SysTick IRQ and SysTick Timer */
+    SysTick->CTRL &= ~(SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk);
+
+    /* 重定位中断向量表到 App */
+    SCB->VTOR = addr;
+
+    __set_MSP(sp);
+    jump();  //jump使用static变量,如果是在栈里面的,前一个语句可能会导致其改变。
+
+    while (1) __NOP();
+}
+
+/*************************************************************************************************************
+ * Private Function
+ *************************************************************************************************************/
+/**
+ * @brief   CRC-CCITT (poly 0x1021), 与 user_iap.c 中算法一致
+ */
+static uint16_t iap_crc16_block(const uint8_t *data, uint32_t len, uint16_t crc)
+{
+    uint32_t i;
+    int      j;
+
+    for (i = 0; i < len; ++i) {
+        crc ^= (uint16_t)data[i] << 8;
+        for (j = 0; j < 8; ++j) {
+            if (crc & 0x8000)
+                crc = (uint16_t)((crc << 1) ^ IAP_FW_CRC_POLY);
+            else
+                crc = (uint16_t)(crc << 1);
+        }
+    }
+    return crc;
+}
+
+/**
+ * @brief   对 SPI Flash 上一段数据流式计算 CRC (分页读取)
+ */
+static uint16_t iap_crc16_flash(uint32_t addr, uint32_t len)
+{
+    static uint8_t  buf[IAP_FLASH_PAGE];
+    uint16_t crc = 0;
+    uint32_t n;
+
+  
+    if( addr%IAP_FLASH_PAGE){
+        n = IAP_FLASH_PAGE - (addr%IAP_FLASH_PAGE);
+        if( n > len )
+            n = len;
+        GD25Q128_ReadData(addr, buf, n);
+        crc = iap_crc16_block(buf, n, crc);
+        addr += n;
+        len  -= n;
+    }
+
+    while (len) {
+        n = (len > IAP_FLASH_PAGE) ? IAP_FLASH_PAGE : len;
+        GD25Q128_ReadData(addr, buf, n);
+        crc = iap_crc16_block(buf, n, crc);
+
+        addr += n;
+        len  -= n;
+    }
+    return crc;
+}
+
+/**
+ * @brief   大端读取 16 位
+ */
+static uint16_t rd_be16(const uint8_t *p)
+{
+    return (uint16_t)(((uint16_t)p[0] << 8) | p[1]);
+}
+
+
+
+/*
+ iap.c  用于bootloader 升级固件
+
+ 1  SPIFlash 空间管理
+ SPIFlash 使用 GD25Q128E,  一共16M空间,每个扇区4K,写入按每个页256字节
+ 分区1  2M  用于存储 主程序
+ 分区2  2M  用于存储 待升级程序
+ 分区3  2M  用于存储 汉字字库HZK16
+ 分区4  8M  littlefs  用于存储 资源
+
+ 2 SDRAM 空间 8M  0x80000000 到 0x80800000-1
+  0到2M  用于存储 主程序, bootloader验证固件后将其复制到SDRAM运行。固件前面有个16字节的文件头,编译好后,会自动添加一个文件头。
+ 用python写一个简单工具,加入到在keil的编译后用户指令中,用于将编译好的固件文件前面添加16字节的文件头。 版本号从源代码中提取
+
+ 3  bootloader 功能描述
+ 3.1  读取spiflash 分区1,获取版本号,校验crc,如果失败,进入升级步骤 3.x
+ 3.2  读取spiflash 分区2,获取待升级程序的版本号,校验crc,判断如果需要升级,进入升级步骤 3.x
+ 3.3  如果不需要升级,当前主程序有效, 从分区1 拷贝主程序到sdram, 跳转运行
+ 3.4  如果需要升级,如果有升级固件,从分区2 拷贝待升级程序到分区1,擦除分区2,重启bootloader,
+ 3.5  如果分区2 没有升级固件,打开LCD,显示无主程序,等待插入U盘升级升级固件。
+
+
+4 固件头定义
+前面16个字节:
+Byte0~Byte5:项目名,BDM120,这个不用管
+Byte6:板子ID(0:保护板;1:液晶板;2:增强板)  当前工程是液晶板(1)
+Byte7~Byte10:版本号(图中示例为V1.0.0.0)
+Byte11~Byte13:程序固件长度,单位:字节。(不包含前面的16个字节,是固件是实际大小)
+Byte14~Byte15:固件的CRC校验码(多项式0x1021)
+
+
+ 按以上步骤,实现bootloader, 
+ 1. 第一步,先移植 uGUI到bootloader中, 用于显示升级界面,升级进度条,升级完成提示等。 只保留英文显示,减少bootloader的代码量。
+ 2. uGUI已经从github下载,  代码在web-git目录下,这个目录仅供参考,
+ 3. 将ugui的需要的代码文件复制到app/bootloader目录下。
+ 4. 增加一个bootloader_ui.c 有init接口,调用后启动lcd,显示一行测试字符串。
+ 5. 下一步等待指令
+
+*/
\ No newline at end of file
diff --git a/APP/bootloader/iap.h b/APP/bootloader/iap.h
new file mode 100644 (file)
index 0000000..8b05b05
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef __IAP_H__
+#define __IAP_H__
+
+#include <stdint.h>
+#include "user_iap.h"   /* 复用 firmware_info_t 固件信息结构体 */
+
+/*************************************************************************************************************
+ * SPIFlash (GD25Q128E, 16M) 分区规划
+ *   分区1 : 0x000000 ~ 0x1FFFFF   2M   主程序
+ *   分区2 : 0x200000 ~ 0x3FFFFF   2M   待升级程序
+ *   分区3 : 0x400000 ~ 0x5FFFFF   2M   汉字字库 HZK16
+ *   分区4 : 0x600000 ~ 0xFFFFFF   8M   littlefs 资源
+ *************************************************************************************************************/
+#define IAP_PART_SIZE       0x200000u   /* 主程序/升级程序/字库分区各自大小 2M */
+
+#define IAP_PART1_OFF       0x000000u   /* 主程序分区   */
+#define IAP_PART2_OFF       0x200000u   /* 待升级分区   */
+#define IAP_PART3_OFF       0x400000u   /* HZK16 分区   */
+#define IAP_PART4_OFF       0x600000u   /* littlefs 分区 */
+
+#define IAP_FLASH_SECTOR    4096u       /* SPI Flash 扇区 4K */
+#define IAP_FLASH_PAGE      256u        /* SPI Flash 页    256B */
+
+/* SDRAM (0x80000000 ~ 0x807FFFFF, 8M): 0~2M 存放主程序运行镜像, 2~4M 存放待升级程序缓冲 */
+#define IAP_APP_RUN_ADDR    0x80000000u /* 主程序运行地址    */
+#define IAP_APP_RUN_SIZE    0x200000u   /* 主程序占用 2M     */
+#define IAP_PART2_RUN_ADDR  0x80200000u /* part2 待升级程序缓冲地址 */
+#define IAP_PART2_RUN_SIZE  0x200000u   /* part2 缓冲占用 2M  */
+
+/* 固件头项目名 (Byte0~5) */
+#define IAP_PROJ_NAME       "BDM120"
+#define IAP_PROJ_NAME_LEN   6
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief   初始化 SPI Flash (适配后的 GD25Q128 驱动), 仅调用一次
+ * @return  0 = 芯片识别成功 (可进行后续读写); 非0 = SPI Flash 异常
+ */
+int iap_init(void);
+
+/**
+ * @brief   读取并校验某分区的固件 (头 + 全文 CRC)
+ * @param   part  分区起始地址 (见 IAP_PART*_OFF)
+ * @param   out   输出固件信息 (可为 NULL)
+ * @retval  0 固件有效 / 非 0 无固件或校验失败
+ */
+int iap_part_valid(uint32_t part, firmware_info_t *out);
+
+/**
+ * @brief   比较两固件版本, 判断 new 是否比 old 新
+ * @retval  1 需要升级 / 0 不需要
+ */
+int iap_need_update(const firmware_info_t *old, const firmware_info_t *new);
+
+/**
+ * @brief   擦除分区内 [part, part+size) 区域 (按 4K 扇区)
+ */
+void iap_erase_part(uint32_t part, uint32_t size);
+
+/**
+ * @brief   将固件 (含16字节头) 从 src 分区整体拷贝到 dst 分区
+ * @note    拷贝前会擦除 dst 目标区域; progress 为逐扇区进度回调(可为 NULL)
+ * @retval  0 成功 / 非 0 失败
+ */
+int iap_part_to_part(uint32_t src, uint32_t dst, uint32_t length,
+                     void (*progress)(uint32_t done, uint32_t total));
+
+/**
+ * @brief   将图标分区固件体(跳过16字节头)拷贝到 SDRAM 指定地址
+ * @param   part 源分区地址
+ * @param   size 固件体字节数 (不含16字头)
+ * @retval  0 成功 / 非 0 失败
+ */
+int iap_part_to_sdram(uint32_t part, uint32_t size);
+
+/**
+ * @brief   单遍加载分区固件到 SDRAM: 读文件头校验, 随后直读正文到 SDRAM 并同步计算CRC
+ * @note    加载到 SDRAM 的缓冲包含 16 字节文件头 (头在 dst, 正文从 dst+16 起连续)。
+ *          相比 iap_part_valid + iap_part_to_sdram 两遍读, 只读一遍闪存, 缩短开机时间。
+ * @param   part 源分区地址
+ * @param   dst  SDRAM 目标地址
+ * @param   out  输出固件信息 (可为 NULL)
+ * @retval  0 有效 / 非0 头无效或CRC校验失败
+ */
+int iap_part_load(uint32_t part, uint32_t dst, firmware_info_t *out);
+
+/**
+ * @brief   将 SDRAM 缓冲(含16字节文件头)直接写入分区 (升级: part2缓冲 → 分区1)
+ * @param   src    SDRAM 内存地址 (内容含 16 字节头 + 正文)
+ * @param   dst    目标分区地址
+ * @param   length 总字节数 (含文件头)
+ * @retval  0 成功 / 非0 失败
+ */
+int iap_sdram_to_part(uint32_t src, uint32_t dst, uint32_t length);
+
+/**
+ * @brief   跳转到 SDRAM 中的 App 运行 (设置 SP/PC, 重定位向量表)
+ * @param   addr App 起始地址 (通常为 IAP_APP_RUN_ADDR)
+ */
+void iap_jump_app(uint32_t addr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __IAP_H__ */
\ No newline at end of file
diff --git a/APP/bootloader/sflash_test.c b/APP/bootloader/sflash_test.c
new file mode 100644 (file)
index 0000000..1f02b4b
--- /dev/null
@@ -0,0 +1,59 @@
+#include <string.h>
+#include "SWM341.h"
+
+#include "SPI_GD25Q128.h"
+
+#define SFLASH_TEST_ADDR   0x00FFF000u   /* 末尾扇区(16M-4K), 不占用固件/字库/littlefs 分区 */
+#define SFLASH_TEST_LEN    256u          /* 单页大小, 测试数据 = 一页 */
+
+/*******************************************************************************************************************************
+* @brief   SPI Flash (GD25Q128E) 读写擦除测试: 读取芯片ID → 擦除扇区 → 校验擦除 → 逐页写入 → 回读校验
+* @note    在 bootloader 读取到 SPI Flash ID 成功后调用
+*******************************************************************************************************************************/
+void sflash_test( void )
+{
+    uint16_t chip_id;
+    uint8_t  wbuf[SFLASH_TEST_LEN];
+    uint8_t  rbuf[SFLASH_TEST_LEN];
+    uint32_t i;
+
+    chip_id = GD25Q128_ReadChipID();
+    printf("[sflash] Chip ID = 0x%04X, start R/W/E test ...\r\n", chip_id);
+
+    /* 构造测试数据 */
+    for(i = 0; i < SFLASH_TEST_LEN; i++)
+        wbuf[i] = (uint8_t)(i * 7u + 1u);
+
+    /* 1. 擦除测试扇区 (4K) */
+    GD25Q128_EraseSector(SFLASH_TEST_ADDR);
+    while(GD25Q128_IsBusy()) __NOP();
+
+    /* 2. 校验擦除后扇区内容为 0xFF */
+    GD25Q128_ReadData(SFLASH_TEST_ADDR, rbuf, SFLASH_TEST_LEN);
+    for(i = 0; i < SFLASH_TEST_LEN; i++)
+        if(rbuf[i] != 0xFF) break;
+    if(i < SFLASH_TEST_LEN)
+    {
+        printf("[sflash] ERASE test FAIL @ 0x%X (got 0x%02X, expect 0xFF)\r\n", i, rbuf[i]);
+        return;
+    }
+    printf("[sflash] ERASE test PASS\r\n");
+
+    /* 3. 写入一页测试数据 */
+    GD25Q128_WritePage(SFLASH_TEST_ADDR, wbuf, SFLASH_TEST_LEN);
+    while(GD25Q128_IsBusy()) __NOP();
+
+    /* 4. 回读并逐一对比 */
+    GD25Q128_ReadData(SFLASH_TEST_ADDR, rbuf, SFLASH_TEST_LEN);
+    for(i = 0; i < SFLASH_TEST_LEN; i++)
+        if(wbuf[i] != rbuf[i]) break;
+    if(i < SFLASH_TEST_LEN)
+    {
+        printf("[sflash] WRITE/READ test FAIL @ 0x%X (want 0x%02X, got 0x%02X)\r\n",
+               i, wbuf[i], rbuf[i]);
+        return;
+    }
+    printf("[sflash] WRITE/READ test PASS\r\n");
+
+    printf("[sflash] R/W/E test ALL PASS\r\n");
+}
\ No newline at end of file
diff --git a/APP/bootloader/ugui.c b/APP/bootloader/ugui.c
new file mode 100644 (file)
index 0000000..dde4851
--- /dev/null
@@ -0,0 +1,1246 @@
+/* -------------------------------------------------------------------------------- */
+/* -- uGUI - Generic GUI module (C)Achim Döbler, 2015                            -- */
+/* -------------------------------------------------------------------------------- */
+// µGUI is a generic GUI module for embedded systems.
+// This is a free software that is open for education, research and commercial
+// developments under license policy of following terms.
+//
+//  Copyright (C) 2015, Achim Döbler, all rights reserved.
+//  URL: http://www.embeddedlightning.com/
+//
+// * The µGUI module is a free software and there is NO WARRANTY.
+// * No restriction on use. You can use, modify and redistribute it for
+//   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+// * Redistributions of source code must retain the above copyright notice.
+//
+/* -------------------------------------------------------------------------------- */
+/* -- REVISION HISTORY                                                           -- */
+/* -------------------------------------------------------------------------------- */
+//  Oct 11, 2019  V0.31 Checkbox component with all funtions added.
+//                      RGB565 color schema added.
+//  Mar 18, 2015  V0.3  Driver support added.
+//                      Window and object support added.
+//                      Touch support added.
+//                      Fixed some minor bugs.
+//
+//  Oct 20, 2014  V0.2  Function UG_DrawRoundFrame() added.
+//                      Function UG_FillRoundFrame() added.
+//                      Function UG_DrawArc() added.
+//                      Fixed some minor bugs.
+//
+//  Oct 11, 2014  V0.1  First release.
+/* -------------------------------------------------------------------------------- */
+#include "ugui.h"
+#include "widgets/window.h"
+
+/* Static functions */
+static void _UG_PutChar( UG_U16 chr, UG_S16 x, UG_S16 y, UG_COLOR fc, UG_COLOR bc, __UG_FONT_DATA UG_FONT* font);
+static UG_U16 _UG_Is_Point_In(int vertexcount, PolygonVertex *vertexs, uint16_t testx, uint16_t testy);
+
+ /* Pointer to the pGUI */
+UG_GUI* pGUI;
+
+UG_S16 UG_Init( UG_GUI* g, void (*p)(UG_S16,UG_S16,UG_COLOR), UG_S16 width, UG_S16 height )
+{
+   UG_U8 i;
+
+   g->pset = (void(*)(UG_S16,UG_S16,UG_COLOR))p;
+   g->x_dim = width;
+   g->y_dim = height;
+   g->console.x_start = 4;
+   g->console.y_start = 4;
+   g->console.x_end = g->x_dim - g->console.x_start-1;
+   g->console.y_end = g->y_dim - g->console.x_start-1;
+   g->console.x_pos = g->console.x_end;
+   g->console.y_pos = g->console.y_end;
+   g->char_h_space = 1;
+   g->char_v_space = 1;
+   g->font.p = NULL;
+   g->font.char_height = 0;
+   g->font.char_width = 0;
+   g->font.start_char = 0;
+   g->font.end_char = 0;
+   g->font.widths = NULL;
+   #ifdef USE_COLOR_RGB888
+   g->desktop_color = 0x5E8BEf;
+   #endif
+   #ifdef USE_COLOR_RGB565
+   g->desktop_color = 0x5C5D;
+   #endif
+   g->fore_color = C_WHITE;
+   g->back_color = C_BLACK;
+   g->next_window = NULL;
+   g->active_window = NULL;
+   g->last_window = NULL;
+
+   /* Clear drivers */
+   for(i=0;i<NUMBER_OF_DRIVERS;i++)
+   {
+      g->driver[i].driver = NULL;
+      g->driver[i].state = 0;
+   }
+
+   pGUI = g;
+   return 1;
+}
+
+UG_S16 UG_SelectGUI( UG_GUI* g )
+{
+   pGUI = g;
+   return 1;
+}
+
+void UG_FontSelect( __UG_FONT_DATA UG_FONT* font )
+{
+   pGUI->font = *font;
+}
+
+void UG_FillScreen( UG_COLOR c )
+{
+   UG_FillFrame(0,0,pGUI->x_dim-1,pGUI->y_dim-1,c);
+}
+
+void UG_FillFrame( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c )
+{
+   UG_S16 n,m;
+
+   if ( x2 < x1 )
+   {
+      n = x2;
+      x2 = x1;
+      x1 = n;
+   }
+   if ( y2 < y1 )
+   {
+      n = y2;
+      y2 = y1;
+      y1 = n;
+   }
+
+   /* Is hardware acceleration available? */
+   if ( pGUI->driver[DRIVER_FILL_FRAME].state & DRIVER_ENABLED )
+   {
+      if( ((UG_RESULT(*)(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c))pGUI->driver[DRIVER_FILL_FRAME].driver)(x1,y1,x2,y2,c) == UG_RESULT_OK ) return;
+   }
+
+   for( m=y1; m<=y2; m++ )
+   {
+      for( n=x1; n<=x2; n++ )
+      {
+         pGUI->pset(n,m,c);
+      }
+   }
+}
+
+void UG_FillRoundFrame( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_S16 r, UG_COLOR c )
+{
+   UG_S16  x,y,xd;
+
+   if ( x2 < x1 )
+   {
+      x = x2;
+      x2 = x1;
+      x1 = x;
+   }
+   if ( y2 < y1 )
+   {
+      y = y2;
+      y2 = y1;
+      y1 = y;
+   }
+
+   if ( r<=0 ) return;
+
+   xd = 3 - (r << 1);
+   x = 0;
+   y = r;
+
+   UG_FillFrame(x1 + r, y1, x2 - r, y2, c);
+
+   while ( x <= y )
+   {
+     if( y > 0 )
+     {
+        UG_DrawLine(x2 + x - r, y1 - y + r, x2+ x - r, y + y2 - r, c);
+        UG_DrawLine(x1 - x + r, y1 - y + r, x1- x + r, y + y2 - r, c);
+     }
+     if( x > 0 )
+     {
+        UG_DrawLine(x1 - y + r, y1 - x + r, x1 - y + r, x + y2 - r, c);
+        UG_DrawLine(x2 + y - r, y1 - x + r, x2 + y - r, x + y2 - r, c);
+     }
+     if ( xd < 0 )
+     {
+        xd += (x << 2) + 6;
+     }
+     else
+     {
+        xd += ((x - y) << 2) + 10;
+        y--;
+     }
+     x++;
+   }
+}
+
+void UG_DrawMesh( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c )
+{
+   UG_S16 n,m;
+
+   if ( x2 < x1 )
+   {
+      n = x2;
+      x2 = x1;
+      x1 = n;
+   }
+   if ( y2 < y1 )
+   {
+      n = y2;
+      y2 = y1;
+      y1 = n;
+   }
+
+   for( m=y1; m<=y2; m+=2 )
+   {
+      for( n=x1; n<=x2; n+=2 )
+      {
+         pGUI->pset(n,m,c);
+      }
+   }
+}
+
+void UG_DrawFrame( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c )
+{
+   UG_DrawLine(x1,y1,x2,y1,c);
+   UG_DrawLine(x1,y2,x2,y2,c);
+   UG_DrawLine(x1,y1,x1,y2,c);
+   UG_DrawLine(x2,y1,x2,y2,c);
+}
+
+void UG_DrawRoundFrame( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_S16 r, UG_COLOR c )
+{
+   UG_S16 n;
+   if ( x2 < x1 )
+   {
+      n = x2;
+      x2 = x1;
+      x1 = n;
+   }
+   if ( y2 < y1 )
+   {
+      n = y2;
+      y2 = y1;
+      y1 = n;
+   }
+
+   if ( r > x2 ) return;
+   if ( r > y2 ) return;
+
+   UG_DrawLine(x1+r, y1, x2-r, y1, c);
+   UG_DrawLine(x1+r, y2, x2-r, y2, c);
+   UG_DrawLine(x1, y1+r, x1, y2-r, c);
+   UG_DrawLine(x2, y1+r, x2, y2-r, c);
+   UG_DrawArc(x1+r, y1+r, r, 0x0C, c);
+   UG_DrawArc(x2-r, y1+r, r, 0x03, c);
+   UG_DrawArc(x1+r, y2-r, r, 0x30, c);
+   UG_DrawArc(x2-r, y2-r, r, 0xC0, c);
+}
+
+void UG_DrawPixel( UG_S16 x0, UG_S16 y0, UG_COLOR c )
+{
+   pGUI->pset(x0,y0,c);
+}
+
+void UG_DrawCircle( UG_S16 x0, UG_S16 y0, UG_S16 r, UG_COLOR c )
+{
+   UG_S16 x,y,xd,yd,e;
+
+   if ( x0<0 ) return;
+   if ( y0<0 ) return;
+   if ( r<=0 ) return;
+
+   xd = 1 - (r << 1);
+   yd = 0;
+   e = 0;
+   x = r;
+   y = 0;
+
+   while ( x >= y )
+   {
+      pGUI->pset(x0 - x, y0 + y, c);
+      pGUI->pset(x0 - x, y0 - y, c);
+      pGUI->pset(x0 + x, y0 + y, c);
+      pGUI->pset(x0 + x, y0 - y, c);
+      pGUI->pset(x0 - y, y0 + x, c);
+      pGUI->pset(x0 - y, y0 - x, c);
+      pGUI->pset(x0 + y, y0 + x, c);
+      pGUI->pset(x0 + y, y0 - x, c);
+
+      y++;
+      e += yd;
+      yd += 2;
+      if ( ((e << 1) + xd) > 0 )
+      {
+         x--;
+         e += xd;
+         xd += 2;
+      }
+   }
+}
+
+void UG_FillCircle( UG_S16 x0, UG_S16 y0, UG_S16 r, UG_COLOR c )
+{
+   UG_S16  x,y,xd;
+
+   if ( x0<0 ) return;
+   if ( y0<0 ) return;
+   if ( r<=0 ) return;
+
+   xd = 3 - (r << 1);
+   x = 0;
+   y = r;
+
+   while ( x <= y )
+   {
+     if( y > 0 )
+     {
+        UG_DrawLine(x0 - x, y0 - y,x0 - x, y0 + y, c);
+        UG_DrawLine(x0 + x, y0 - y,x0 + x, y0 + y, c);
+     }
+     if( x > 0 )
+     {
+        UG_DrawLine(x0 - y, y0 - x,x0 - y, y0 + x, c);
+        UG_DrawLine(x0 + y, y0 - x,x0 + y, y0 + x, c);
+     }
+     if ( xd < 0 )
+     {
+        xd += (x << 2) + 6;
+     }
+     else
+     {
+        xd += ((x - y) << 2) + 10;
+        y--;
+     }
+     x++;
+   }
+   UG_DrawCircle(x0, y0, r,c);
+}
+
+void UG_FillPolygon(UG_U8 vertexcount, PolygonVertex *vertexs, UG_COLOR c )
+{
+    UG_U32 temp_max,temp_min;
+    UG_U16 max_x, max_y, min_x, min_y;// ¶à±ßÐζ¥µã×ø±êµÄ×î´ó/×îСֵ
+    UG_U16 i,j;
+    
+    temp_max = 0;
+    temp_min = 0;
+    for (i = 0; i < vertexcount; i++) 
+    {
+        temp_max += vertexs[i].x;
+        temp_min += vertexs[i].y;
+    }
+    max_x = min_x = temp_max / vertexcount; //¼ÆËãÆ½¾ùXÖµ
+    max_y = min_y = temp_min / vertexcount; //¼ÆËãÆ½¾ùYÖµ
+
+    for (i = 0; i < vertexcount; i++)
+    {
+        if (vertexs[i].x >= max_x){max_x = vertexs[i].x;}//ÕÒX×î´óÖµ
+        if (vertexs[i].x < min_x){min_x = vertexs[i].x;}//ÕÒx×îСֵ
+        if (vertexs[i].y >= max_y){max_y = vertexs[i].y;}//ÕÒx×î´óÖµ
+        if (vertexs[i].y < min_y){min_y = vertexs[i].y;}//ÕÒx×îСֵ
+    }
+
+    for (i = min_y+1; i < max_y; i++)
+    {
+        for (j = min_x+1; j < max_x; j++)
+        {
+            if ((_UG_Is_Point_In(vertexcount, vertexs, j, i) % 2) == 1)
+            {
+                pGUI->pset(j, i, c);
+            }
+        }
+    }
+}
+
+void UG_DrawArc( UG_S16 x0, UG_S16 y0, UG_S16 r, UG_U8 s, UG_COLOR c )
+{
+   UG_S16 x,y,xd,yd,e;
+
+   if ( x0<0 ) return;
+   if ( y0<0 ) return;
+   if ( r<=0 ) return;
+
+   xd = 1 - (r << 1);
+   yd = 0;
+   e = 0;
+   x = r;
+   y = 0;
+
+   while ( x >= y )
+   {
+      // Q1
+      if ( s & 0x01 ) pGUI->pset(x0 + x, y0 - y, c);
+      if ( s & 0x02 ) pGUI->pset(x0 + y, y0 - x, c);
+
+      // Q2
+      if ( s & 0x04 ) pGUI->pset(x0 - y, y0 - x, c);
+      if ( s & 0x08 ) pGUI->pset(x0 - x, y0 - y, c);
+
+      // Q3
+      if ( s & 0x10 ) pGUI->pset(x0 - x, y0 + y, c);
+      if ( s & 0x20 ) pGUI->pset(x0 - y, y0 + x, c);
+
+      // Q4
+      if ( s & 0x40 ) pGUI->pset(x0 + y, y0 + x, c);
+      if ( s & 0x80 ) pGUI->pset(x0 + x, y0 + y, c);
+
+      y++;
+      e += yd;
+      yd += 2;
+      if ( ((e << 1) + xd) > 0 )
+      {
+         x--;
+         e += xd;
+         xd += 2;
+      }
+   }
+}
+
+void UG_DrawLine( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c )
+{
+   UG_S16 n, dx, dy, sgndx, sgndy, dxabs, dyabs, x, y, drawx, drawy;
+
+   /* Is hardware acceleration available? */
+   if ( pGUI->driver[DRIVER_DRAW_LINE].state & DRIVER_ENABLED )
+   {
+      if( ((UG_RESULT(*)(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c))pGUI->driver[DRIVER_DRAW_LINE].driver)(x1,y1,x2,y2,c) == UG_RESULT_OK ) return;
+   }
+
+   dx = x2 - x1;
+   dy = y2 - y1;
+   dxabs = (dx>0)?dx:-dx;
+   dyabs = (dy>0)?dy:-dy;
+   sgndx = (dx>0)?1:-1;
+   sgndy = (dy>0)?1:-1;
+   x = dyabs >> 1;
+   y = dxabs >> 1;
+   drawx = x1;
+   drawy = y1;
+
+   pGUI->pset(drawx, drawy,c);
+
+   if( dxabs >= dyabs )
+   {
+      for( n=0; n<dxabs; n++ )
+      {
+         y += dyabs;
+         if( y >= dxabs )
+         {
+            y -= dxabs;
+            drawy += sgndy;
+         }
+         drawx += sgndx;
+         pGUI->pset(drawx, drawy,c);
+      }
+   }
+   else
+   {
+      for( n=0; n<dyabs; n++ )
+      {
+         x += dxabs;
+         if( x >= dyabs )
+         {
+            x -= dyabs;
+            drawx += sgndx;
+         }
+         drawy += sgndy;
+         pGUI->pset(drawx, drawy,c);
+      }
+   }  
+}
+
+void UG_PutString( UG_S16 x, UG_S16 y, char* str )
+{
+   UG_S16 xp,yp;
+   UG_U8 cw;
+   UG_U16 chr;
+
+   xp=x;
+   yp=y;
+
+   while ( *str != 0 )
+   {
+      chr = *str++;
+      if ( chr == '\n' )
+      {
+         xp = pGUI->x_dim;
+         continue;
+      }
+      if (chr > 0x7F)// ÖÐÎÄ
+      {
+          chr = (chr << 8) | *str++;
+      }
+      if (chr < pGUI->font.start_char || chr > pGUI->font.end_char) continue;
+      cw = pGUI->font.widths ? pGUI->font.widths[chr - pGUI->font.start_char] : pGUI->font.char_width;
+
+      if ( xp + cw > pGUI->x_dim - 1 )
+      {
+         xp = x;
+         yp += pGUI->font.char_height + pGUI->char_v_space;
+      }
+
+      _UG_PutChar(chr, xp, yp, pGUI->fore_color, pGUI->back_color,&pGUI->font);
+
+      xp += cw + pGUI->char_h_space;
+   }
+}
+
+void UG_PutChar( UG_U16 chr, UG_S16 x, UG_S16 y, UG_COLOR fc, UG_COLOR bc )
+{
+    _UG_PutChar(chr,x,y,fc,bc,&pGUI->font);
+}
+
+void UG_ConsolePutString( char* str )
+{
+   char chr;
+   UG_U8 cw;
+
+   while ( *str != 0 )
+   {
+      chr = *str;
+      if ( chr == '\n' )
+      {
+         pGUI->console.x_pos = pGUI->x_dim;
+         str++;
+         continue;
+      }
+      
+      cw = pGUI->font.widths ? pGUI->font.widths[chr - pGUI->font.start_char] : pGUI->font.char_width;
+      pGUI->console.x_pos += cw+pGUI->char_h_space;
+
+      if ( pGUI->console.x_pos+cw > pGUI->console.x_end )
+      {
+         pGUI->console.x_pos = pGUI->console.x_start;
+         pGUI->console.y_pos += pGUI->font.char_height+pGUI->char_v_space;
+      }
+      if ( pGUI->console.y_pos+pGUI->font.char_height > pGUI->console.y_end )
+      {
+         pGUI->console.x_pos = pGUI->console.x_start;
+         pGUI->console.y_pos = pGUI->console.y_start;
+         UG_FillFrame(pGUI->console.x_start,pGUI->console.y_start,pGUI->console.x_end,pGUI->console.y_end,pGUI->console.back_color);
+      }
+
+      UG_PutChar(chr, pGUI->console.x_pos, pGUI->console.y_pos, pGUI->console.fore_color, pGUI->console.back_color);
+      str++;
+   }
+}
+
+void UG_ConsoleSetArea( UG_S16 xs, UG_S16 ys, UG_S16 xe, UG_S16 ye )
+{
+   pGUI->console.x_start = xs;
+   pGUI->console.y_start = ys;
+   pGUI->console.x_end = xe;
+   pGUI->console.y_end = ye;
+}
+
+void UG_ConsoleSetForecolor( UG_COLOR c )
+{
+   pGUI->console.fore_color = c;
+}
+
+void UG_ConsoleSetBackcolor( UG_COLOR c )
+{
+   pGUI->console.back_color = c;
+}
+
+void UG_SetForecolor( UG_COLOR c )
+{
+   pGUI->fore_color = c;
+}
+
+void UG_SetBackcolor( UG_COLOR c )
+{
+   pGUI->back_color = c;
+}
+
+UG_S16 UG_GetXDim( void )
+{
+   return pGUI->x_dim;
+}
+
+UG_S16 UG_GetYDim( void )
+{
+   return pGUI->y_dim;
+}
+
+void UG_FontSetHSpace( UG_U16 s )
+{
+   pGUI->char_h_space = s;
+}
+
+void UG_FontSetVSpace( UG_U16 s )
+{
+   pGUI->char_v_space = s;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef USE_COLOR_RGB888
+const UG_COLOR pal_window[] =
+{
+   /* Frame 0 */
+   0x646464,
+   0x646464,
+   0x646464,
+   0x646464,
+   /* Frame 1 */
+   0xFFFFFF,
+   0xFFFFFF,
+   0x696969,
+   0x696969,
+   /* Frame 2 */
+   0xE3E3E3,
+   0xE3E3E3,
+   0xA0A0A0,
+   0xA0A0A0,
+};
+
+const UG_COLOR pal_button_pressed[] =
+{
+   /* Frame 0 */
+   0x646464,
+   0x646464,
+   0x646464,
+   0x646464,
+   /* Frame 1 */
+   0xA0A0A0,
+   0xA0A0A0,
+   0xA0A0A0,
+   0xA0A0A0,
+   /* Frame 2 */
+   0xF0F0F0,
+   0xF0F0F0,
+   0xF0F0F0,
+   0xF0F0F0,
+};
+
+const UG_COLOR pal_button_released[] =
+{
+   /* Frame 0 */
+   0x646464,
+   0x646464,
+   0x646464,
+   0x646464,
+   /* Frame 1 */
+   0xFFFFFF,
+   0xFFFFFF,
+   0x696969,
+   0x696969,
+   /* Frame 2 */
+   0xE3E3E3,
+   0xE3E3E3,
+   0xA0A0A0,
+   0xA0A0A0,
+};
+
+const UG_COLOR pal_checkbox_pressed[] =
+{
+   /* Frame 0 */
+   0x646464,
+   0x646464,
+   0x646464,
+   0x646464,
+   /* Frame 1 */
+   0xA0A0A0,
+   0xA0A0A0,
+   0xA0A0A0,
+   0xA0A0A0,
+   /* Frame 2 */
+   0xF0F0F0,
+   0xF0F0F0,
+   0xF0F0F0,
+   0xF0F0F0,
+};
+
+const UG_COLOR pal_checkbox_released[] =
+{
+   /* Frame 0 */
+   0x646464,
+   0x646464,
+   0x646464,
+   0x646464,
+   /* Frame 1 */
+   0xFFFFFF,
+   0xFFFFFF,
+   0x696969,
+   0x696969,
+   /* Frame 2 */
+   0xE3E3E3,
+   0xE3E3E3,
+   0xA0A0A0,
+   0xA0A0A0,
+};
+#endif
+
+#ifdef USE_COLOR_RGB565
+const UG_COLOR pal_window[] =
+{
+   0x632C,
+   0x632C,
+   0x632C,
+   0x632C,
+
+   0xFFFF,
+   0xFFFF,
+   0x6B4D,
+   0x6B4D,
+
+   0xE71C,
+   0xE71C,
+   0x9D13,
+   0x9D13,
+};
+
+const UG_COLOR pal_button_pressed[] =
+{
+    0x632C,
+    0x632C,
+    0x632C,
+    0x632C,
+
+    0x9D13,
+    0x9D13,
+    0x9D13,
+    0x9D13,
+
+    0xEF7D,
+    0xEF7D,
+    0xEF7D,
+    0xEF7D,
+};
+
+const UG_COLOR pal_button_released[] =
+{
+    0x632C,
+    0x632C,
+    0x632C,
+    0x632C,
+
+    0xFFFF,
+    0xFFFF,
+    0x6B4D,
+    0x6B4D,
+
+    0xE71C,
+    0xE71C,
+    0x9D13,
+    0x9D13,
+};
+
+const UG_COLOR pal_checkbox_pressed[] =
+{
+    0x632C,
+    0x632C,
+    0x632C,
+    0x632C,
+
+    0x9D13,
+    0x9D13,
+    0x9D13,
+    0x9D13,
+
+    0xEF7D,
+    0xEF7D,
+    0xEF7D,
+    0xEF7D,
+};
+
+const UG_COLOR pal_checkbox_released[] =
+{
+    0x632C,
+    0x632C,
+    0x632C,
+    0x632C,
+
+    0xFFFF,
+    0xFFFF,
+    0x6B4D,
+    0x6B4D,
+
+    0xE71C,
+    0xE71C,
+    0x9D13,
+    0x9D13,
+};
+#endif
+
+
+
+/* -------------------------------------------------------------------------------- */
+/* -- INTERNAL FUNCTIONS                                                         -- */
+/* -------------------------------------------------------------------------------- */
+static void _UG_PutChar( UG_U16 chr, UG_S16 x, UG_S16 y, UG_COLOR fc, UG_COLOR bc, __UG_FONT_DATA UG_FONT* font)
+{
+    UG_U16 i,j,k,xo,yo,c,bn,actual_char_width;
+    UG_U8 b;
+    UG_U16 bt;
+    UG_U32 index,index_gb2312;
+    UG_COLOR color;
+
+    bt = chr;
+    if (bt < font->start_char || bt > font->end_char) return;
+    
+    yo = y;
+    bn = font->char_width;
+    if ( !bn ) return;
+    bn >>= 3;
+    if ( font->char_width % 8 ) bn++;
+    
+    if ( bt > 0xA1A1 )// ÖÐÎÄ
+    {
+        for( i=0;i<font->index.font_num;i++ )
+        {
+            if ( bt == font->index.p[2*i] )
+            {
+                index_gb2312 = font->index.p[2*i+1];
+                break;
+            }
+        }
+        if (i == font->index.font_num)return;//¸ÃÎÄ×ÖС×Ö¿â²»´æÔÚ
+        actual_char_width = (font->widths ? font->widths[index_gb2312] : font->char_width);
+    }
+    else
+    {
+        actual_char_width = (font->widths ? font->widths[bt - font->start_char] : font->char_width);
+    }
+
+    /*Not accelerated output*/
+    if (font->font_type == FONT_TYPE_1BPP)// ±ê×¼µãÕó×ÖÌåÏÔʾ
+    {
+        if ( bt > 0xA1A1 )index = index_gb2312 * font->char_height * bn;
+        else index = (bt - font->start_char) * font->char_height * bn;
+
+        for( j=0;j<font->char_height;j++ )
+        {
+            xo = x;
+            c=actual_char_width;
+            for( i=0;i<bn;i++ )
+            {
+                b = font->p[index++];
+                for( k=0;(k<8) && c;k++ )
+                {
+                    if( b & 0x01 )
+                    {
+                        pGUI->pset(xo,yo,fc);
+                    }
+                    else
+                    {
+                        pGUI->pset(xo,yo,bc);
+                    }
+                    b >>= 1;
+                    xo++;
+                    c--;
+                }
+            }
+            yo++;
+        }
+    }
+    else if (font->font_type == FONT_TYPE_8BPP)// ¿¹¾â³Ý×ÖÌåÏÔʾ
+    {
+        if ( bt > 0xA1A1 ) index = index_gb2312 * font->char_height * font->char_width;
+        else index = (bt - font->start_char) * font->char_height * font->char_width;
+        for( j=0;j<font->char_height;j++ )
+        {
+            xo = x;
+            for( i=0;i<actual_char_width;i++ )
+            {
+                b = font->p[index++];
+                color = ((((fc & 0x0000FF) * b + (bc & 0x0000FF) * (256 - b)) >> 8) & 0x0000FF) |//Blue component
+                        ((((fc & 0x00FF00) * b + (bc & 0x00FF00) * (256 - b)) >> 8) & 0x00FF00) |//Green component
+                        ((((fc & 0xFF0000) * b + (bc & 0xFF0000) * (256 - b)) >> 8) & 0xFF0000); //Red component
+                pGUI->pset(xo,yo,color);
+                xo++;
+            }
+            index += font->char_width - actual_char_width;
+            yo++;
+        }
+    }
+}
+
+void _UG_PutText(UG_TEXT* txt)
+{
+    UG_U16 rc,wl;
+    UG_S16 xp,yp;
+    UG_S16 xs=txt->a.xs;
+    UG_S16 ys=txt->a.ys;
+    UG_S16 xe=txt->a.xe;
+    UG_S16 ye=txt->a.ye;
+    UG_U8  align=txt->align;
+    UG_S16 char_height=txt->font->char_height;// ×Ö¸ßÒÔÖÐÎÄΪ׼
+    UG_S16 char_h_space=txt->h_space;
+    UG_S16 char_v_space=txt->v_space;
+
+    UG_U16 chr;
+
+    char* str = txt->str;
+    char* c = str;
+
+    if ( txt->font->p == NULL ) return;
+    if ( txt->font_gb2312->p == NULL ) return;
+    if ( str == NULL ) return;
+    if ( (ye - ys) < txt->font->char_height ) return;
+    
+    // ¼ÆËãÎı¾ÐÐÊý
+    rc=1;
+    c=str;
+    while ( *c != 0 )
+    {
+        if ( *c == '\n' ) rc++;
+        c++;
+    }
+    
+    // ¼ÆËãÎı¾»æÖƵã y ×ø±ê
+    yp = 0;
+    if ( align & (ALIGN_V_CENTER | ALIGN_V_BOTTOM) )
+    {
+        yp = ye - ys + 1;
+        yp -= char_height*rc;
+        yp -= char_v_space*(rc-1);
+        if ( yp < 0 ) return;
+    }
+    if ( align & ALIGN_V_CENTER ) yp >>= 1;
+    yp += ys;
+
+    while( 1 )
+    {
+        c=str;
+        wl = 0;
+        while( (*c != 0) && (*c != '\n') )
+        {
+            if ( *c < 0x7F )
+            {
+                if (*c < txt->font->start_char || *c > txt->font->end_char) {c++; continue;}
+                wl += (txt->font->widths ? txt->font->widths[*c - txt->font->start_char] : txt->font->char_width) + char_h_space;
+                c++;
+            }
+            else if (( *c > 0xA0) && (*c < 0xF8))
+            {
+                chr = ((UG_U16)*c++ << 8);
+                chr |= *c;
+                if (chr < txt->font_gb2312->start_char || chr > txt->font_gb2312->end_char) {c++; continue;}
+                wl += (txt->font_gb2312->widths ? txt->font_gb2312->widths[*c - txt->font_gb2312->start_char] : txt->font_gb2312->char_width) + char_h_space;
+                c++;
+            }
+        }
+        wl -= char_h_space;
+
+        xp = xe - xs + 1;
+        xp -= wl;
+        if ( xp < 0 ) return;
+
+        if ( align & ALIGN_H_LEFT ) xp = 0;
+        else if ( align & ALIGN_H_CENTER ) xp >>= 1;
+        xp += xs;
+
+        while( (*str != '\n') )
+        {
+            chr = (UG_U16)*str++;
+            if ( chr == 0 ) return;
+            if ( chr < 0x7F)// ASCII×Ö·û
+            {
+                _UG_PutChar(chr,xp,yp,txt->fc,txt->bc,txt->font);
+                xp += (txt->font->widths ? txt->font->widths[chr - txt->font->start_char] : txt->font->char_width) + char_h_space;
+            }
+            else if (( chr > 0xA0) && (chr < 0xF8))// 0xA1A2µ½0xF7FEµÄÊÇGB2312±àÂëÎÄ×Ö
+            {
+                chr = (chr << 8) | *str++;// Ò»¸öGB2312ÖÐÎıàÂëÕ¼ÓÃ2¸ö×Ö½Ú
+                _UG_PutChar(chr,xp,yp,txt->fc,txt->bc,txt->font_gb2312);
+                xp += (txt->font_gb2312->widths ? txt->font_gb2312->widths[chr - txt->font_gb2312->start_char] : txt->font_gb2312->char_width) + char_h_space;
+            }            
+        }
+        str++;
+        yp += char_height + char_v_space;
+    }
+}
+
+UG_OBJECT* _UG_GetFreeObject( UG_WINDOW* wnd )
+{
+   UG_U8 i;
+   UG_OBJECT* obj=(UG_OBJECT*)wnd->objlst;
+
+   for(i=0;i<wnd->objcnt;i++)
+   {
+      obj = (UG_OBJECT*)(&wnd->objlst[i]);
+      if ( (obj->state & OBJ_STATE_FREE) && (obj->state & OBJ_STATE_VALID) )
+      {
+         /* Free object found! */
+         return obj;
+      }
+   }
+   return NULL;
+}
+
+UG_OBJECT* _UG_SearchObject( UG_WINDOW* wnd, UG_U8 type, UG_U8 id )
+{
+   UG_U8 i;
+   UG_OBJECT* obj=(UG_OBJECT*)wnd->objlst;
+
+   for(i=0;i<wnd->objcnt;i++)
+   {
+      obj = (UG_OBJECT*)(&wnd->objlst[i]);
+      if ( !(obj->state & OBJ_STATE_FREE) && (obj->state & OBJ_STATE_VALID) )
+      {
+         if ( (obj->type == type) && (obj->id == id) )
+         {
+            /* Requested object found! */
+            return obj;
+         }
+      }
+   }
+   return NULL;
+}
+
+UG_RESULT _UG_DeleteObject( UG_WINDOW* wnd, UG_U8 type, UG_U8 id )
+{
+   UG_OBJECT* obj=NULL;
+
+   obj = _UG_SearchObject( wnd, type, id );
+
+   /* Object found? */
+   if ( obj != NULL )
+   {
+      /* We dont't want to delete a visible or busy object! */
+      if ( (obj->state & OBJ_STATE_VISIBLE) || (obj->state & OBJ_STATE_UPDATE) ) return UG_RESULT_FAIL;
+      obj->state = OBJ_STATE_INIT;
+      obj->data = NULL;
+      obj->event = 0;
+      obj->id = 0;
+      obj->touch_state = 0;
+      obj->type = 0;
+      obj->update = NULL;
+      return UG_RESULT_OK;
+   }
+   return UG_RESULT_FAIL;
+}
+
+void _UG_ProcessTouchData( UG_WINDOW* wnd )
+{
+   UG_S16 xp,yp;
+   UG_U16 i,objcnt;
+   UG_OBJECT* obj;
+   UG_U8 objstate;
+   UG_U8 objtouch;
+   UG_U8 tchstate;
+
+   xp = pGUI->touch.xp;
+   yp = pGUI->touch.yp;
+   tchstate = pGUI->touch.state;
+
+   objcnt = wnd->objcnt;
+   for(i=0; i<objcnt; i++)
+   {
+      obj = (UG_OBJECT*)&wnd->objlst[i];
+      objstate = obj->state;
+      objtouch = obj->touch_state;
+      if ( !(objstate & OBJ_STATE_FREE) && (objstate & OBJ_STATE_VALID) && (objstate & OBJ_STATE_VISIBLE) && !(objstate & OBJ_STATE_REDRAW))
+      {
+         /* Process touch data */
+         if ( (tchstate) && xp != -1 )
+         {
+            if ( !(objtouch & OBJ_TOUCH_STATE_IS_PRESSED) )
+            {
+               objtouch |= OBJ_TOUCH_STATE_PRESSED_OUTSIDE_OBJECT | OBJ_TOUCH_STATE_CHANGED;
+               objtouch &= ~(OBJ_TOUCH_STATE_RELEASED_ON_OBJECT | OBJ_TOUCH_STATE_RELEASED_OUTSIDE_OBJECT | OBJ_TOUCH_STATE_CLICK_ON_OBJECT);
+            }
+            objtouch &= ~OBJ_TOUCH_STATE_IS_PRESSED_ON_OBJECT;
+            if ( xp >= obj->a_abs.xs )
+            {
+               if ( xp <= obj->a_abs.xe )
+               {
+                  if ( yp >= obj->a_abs.ys )
+                  {
+                     if ( yp <= obj->a_abs.ye )
+                     {
+                        objtouch |= OBJ_TOUCH_STATE_IS_PRESSED_ON_OBJECT;
+                        if ( !(objtouch & OBJ_TOUCH_STATE_IS_PRESSED) )
+                        {
+                           objtouch &= ~OBJ_TOUCH_STATE_PRESSED_OUTSIDE_OBJECT;
+                           objtouch |= OBJ_TOUCH_STATE_PRESSED_ON_OBJECT;
+                        }
+                     }
+                  }
+               }
+            }
+            objtouch |= OBJ_TOUCH_STATE_IS_PRESSED;
+         }
+         else if ( objtouch & OBJ_TOUCH_STATE_IS_PRESSED )
+         {
+            if ( objtouch & OBJ_TOUCH_STATE_IS_PRESSED_ON_OBJECT )
+            {
+               if ( objtouch & OBJ_TOUCH_STATE_PRESSED_ON_OBJECT ) objtouch |= OBJ_TOUCH_STATE_CLICK_ON_OBJECT;
+               objtouch |= OBJ_TOUCH_STATE_RELEASED_ON_OBJECT;
+            }
+            else
+            {
+               objtouch |= OBJ_TOUCH_STATE_RELEASED_OUTSIDE_OBJECT;
+            }
+            if ( objtouch & OBJ_TOUCH_STATE_IS_PRESSED )
+            {
+               objtouch |= OBJ_TOUCH_STATE_CHANGED;
+            }
+            objtouch &= ~(OBJ_TOUCH_STATE_PRESSED_OUTSIDE_OBJECT | OBJ_TOUCH_STATE_PRESSED_ON_OBJECT | OBJ_TOUCH_STATE_IS_PRESSED);
+         }
+      }
+      obj->touch_state = objtouch;
+   }
+}
+
+void _UG_UpdateObjects( UG_WINDOW* wnd )
+{
+   UG_U16 i,objcnt;
+   UG_OBJECT* obj;
+   UG_U8 objstate;
+   UG_U8 objtouch;
+
+   /* Check each object, if it needs to be updated? */
+   objcnt = wnd->objcnt;
+   for(i=0; i<objcnt; i++)
+   {
+      obj = (UG_OBJECT*)&wnd->objlst[i];
+      objstate = obj->state;
+      objtouch = obj->touch_state;
+      if ( !(objstate & OBJ_STATE_FREE) && (objstate & OBJ_STATE_VALID) )
+      {
+         if ( objstate & OBJ_STATE_UPDATE )
+         {
+            obj->update(wnd,obj);
+         }
+         if ( (objstate & OBJ_STATE_VISIBLE) && (objstate & OBJ_STATE_TOUCH_ENABLE) )
+         {
+            if ( (objtouch & (OBJ_TOUCH_STATE_CHANGED | OBJ_TOUCH_STATE_IS_PRESSED)) )
+            {
+               obj->update(wnd,obj);
+            }
+         }
+      }
+   }
+}
+
+void _UG_HandleEvents( UG_WINDOW* wnd )
+{
+   UG_U16 i,objcnt;
+   UG_OBJECT* obj;
+   UG_U8 objstate;
+   static UG_MESSAGE msg;
+   msg.src = NULL;
+
+   /* Handle window-related events */
+   //ToDo
+
+
+   /* Handle object-related events */
+   msg.type = MSG_TYPE_OBJECT;
+   objcnt = wnd->objcnt;
+   for(i=0; i<objcnt; i++)
+   {
+      obj = (UG_OBJECT*)&wnd->objlst[i];
+      objstate = obj->state;
+      if ( !(objstate & OBJ_STATE_FREE) && (objstate & OBJ_STATE_VALID) )
+      {
+         if ( obj->event != OBJ_EVENT_NONE )
+         {
+            msg.src = &obj;
+            msg.id = obj->type;
+            msg.sub_id = obj->id;
+            msg.event = obj->event;
+
+            wnd->cb( &msg );
+
+            obj->event = OBJ_EVENT_NONE;
+         }
+      }
+   }
+}
+
+void _UG_DrawObjectFrame( UG_S16 xs, UG_S16 ys, UG_S16 xe, UG_S16 ye, UG_COLOR* p )
+{
+   // Frame 0
+   UG_DrawLine(xs, ys  , xe-1, ys  , *p++);
+   UG_DrawLine(xs, ys+1, xs  , ye-1, *p++);
+   UG_DrawLine(xs, ye  , xe  , ye  , *p++);
+   UG_DrawLine(xe, ys  , xe  , ye-1, *p++);
+   // Frame 1
+   UG_DrawLine(xs+1, ys+1, xe-2, ys+1, *p++);
+   UG_DrawLine(xs+1, ys+2, xs+1, ye-2, *p++);
+   UG_DrawLine(xs+1, ye-1, xe-1, ye-1, *p++);
+   UG_DrawLine(xe-1, ys+1, xe-1, ye-2, *p++);
+   // Frame 2
+   UG_DrawLine(xs+2, ys+2, xe-3, ys+2, *p++);
+   UG_DrawLine(xs+2, ys+3, xs+2, ye-3, *p++);
+   UG_DrawLine(xs+2, ye-2, xe-2, ye-2, *p++);
+   UG_DrawLine(xe-2, ys+2, xe-2, ye-3, *p);
+}
+
+static UG_U16 _UG_Is_Point_In(int vertexcount, PolygonVertex *vertexs, uint16_t testx, uint16_t testy)
+{
+    UG_U16 i, j, c = 0;
+
+    for (i = 0, j = vertexcount - 1; i < vertexcount; j = i++)
+    {
+        if ( ((testy < vertexs[i].y) != ( testy < vertexs[j].y)) && (testx <= (vertexs[j].x - vertexs[i].x) * (testy - vertexs[i].y) / (vertexs[j].y - vertexs[i].y) + vertexs[i].x) )
+            c = !c;
+    }
+    return c;
+}
+
+/* -------------------------------------------------------------------------------- */
+/* -- DRIVER FUNCTIONS                                                           -- */
+/* -------------------------------------------------------------------------------- */
+void UG_DriverRegister( UG_U8 type, void* driver )
+{
+   if ( type >= NUMBER_OF_DRIVERS ) return;
+
+   pGUI->driver[type].driver = driver;
+   pGUI->driver[type].state = DRIVER_REGISTERED | DRIVER_ENABLED;
+}
+
+void UG_DriverEnable( UG_U8 type )
+{
+   if ( type >= NUMBER_OF_DRIVERS ) return;
+   if ( pGUI->driver[type].state & DRIVER_REGISTERED )
+   {
+      pGUI->driver[type].state |= DRIVER_ENABLED;
+   }
+}
+
+void UG_DriverDisable( UG_U8 type )
+{
+   if ( type >= NUMBER_OF_DRIVERS ) return;
+   if ( pGUI->driver[type].state & DRIVER_REGISTERED )
+   {
+      pGUI->driver[type].state &= ~DRIVER_ENABLED;
+   }
+}
+
+/* -------------------------------------------------------------------------------- */
+/* -- MISCELLANEOUS FUNCTIONS                                                    -- */
+/* -------------------------------------------------------------------------------- */
+void UG_WaitForUpdate( void )
+{
+   pGUI->state |= UG_SATUS_WAIT_FOR_UPDATE;
+   #ifdef USE_MULTITASKING    
+   while ( (volatile UG_U8)pGUI->state & UG_SATUS_WAIT_FOR_UPDATE ){};
+   #endif    
+   #ifndef USE_MULTITASKING    
+   while ( (UG_U8)pGUI->state & UG_SATUS_WAIT_FOR_UPDATE ){};
+   #endif    
+}
+
+void UG_TouchUpdate( UG_S16 xp, UG_S16 yp, UG_U8 state )
+{
+   pGUI->touch.xp = xp;
+   pGUI->touch.yp = yp;
+   pGUI->touch.state = state;
+}
+
+
diff --git a/APP/bootloader/ugui.h b/APP/bootloader/ugui.h
new file mode 100644 (file)
index 0000000..eba3335
--- /dev/null
@@ -0,0 +1,686 @@
+/* -------------------------------------------------------------------------------- */
+/* -- uGUI - Generic GUI module (C)Achim Döbler, 2015                            -- */
+/* -------------------------------------------------------------------------------- */
+// uGUI is a generic GUI module for embedded systems.
+// This is a free software that is open for education, research and commercial
+// developments under license policy of following terms.
+//
+//  Copyright (C) 2015, Achim Döbler, all rights reserved.
+//  URL: http://www.embeddedlightning.com/
+//
+// * The uGUI module is a free software and there is NO WARRANTY.
+// * No restriction on use. You can use, modify and redistribute it for
+//   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+// * Redistributions of source code must retain the above copyright notice.
+//
+/* -------------------------------------------------------------------------------- */
+#ifndef __UGUI_H
+#define __UGUI_H
+
+#include "stdint.h"
+#include "ugui_config.h"
+
+/* -------------------------------------------------------------------------------- */
+/* -- uGUI FONTS                                                                 -- */
+/* -- Source: http://www.mikrocontroller.net/user/show/benedikt                  -- */
+/* -------------------------------------------------------------------------------- */
+typedef enum
+{
+    FONT_TYPE_1BPP,// ±ê×¼µãÕó×ÖÌ壬ÿµã1bit
+    FONT_TYPE_8BPP// ¿¹¾â³Ý×ÖÌ壬ÿµã8bit(ÖÐÎÄÔݲ»Ö§³Ö)
+} FONT_TYPE;
+
+typedef struct
+{
+    UG_U16 *p;
+    UG_U16 font_num;
+}UG_FONT_INDEX;
+
+typedef struct
+{
+    unsigned char* p;
+    FONT_TYPE font_type;
+    UG_S16 char_width;
+    UG_S16 char_height;
+    UG_U16 start_char;
+    UG_U16 end_char;
+    UG_U8  *widths;
+    UG_FONT_INDEX index;
+} UG_FONT;
+
+#ifdef USE_FONT_4X6
+   extern __UG_FONT_DATA UG_FONT FONT_4X6;
+#endif
+#ifdef USE_FONT_5X8
+   extern __UG_FONT_DATA UG_FONT FONT_5X8;
+#endif
+#ifdef USE_FONT_5X12
+   extern __UG_FONT_DATA UG_FONT FONT_5X12;
+#endif
+#ifdef USE_FONT_6X8
+   extern __UG_FONT_DATA UG_FONT FONT_6X8;
+#endif
+#ifdef USE_FONT_6X10
+   extern __UG_FONT_DATA UG_FONT FONT_6X10;
+#endif
+#ifdef USE_FONT_7X12
+   extern __UG_FONT_DATA UG_FONT FONT_7X12;
+#endif
+#ifdef USE_FONT_8X8
+   extern __UG_FONT_DATA UG_FONT FONT_8X8;
+#endif
+#ifdef USE_FONT_8X12
+   extern __UG_FONT_DATA UG_FONT FONT_8X12;
+#endif
+#ifdef USE_FONT_8X14
+   extern __UG_FONT_DATA UG_FONT FONT_8X14;
+#endif
+#ifdef USE_FONT_10X16
+   extern __UG_FONT_DATA UG_FONT FONT_10X16;
+#endif
+#ifdef USE_FONT_12X16
+   extern __UG_FONT_DATA UG_FONT FONT_12X16;
+#endif
+#ifdef USE_FONT_12X20
+   extern __UG_FONT_DATA UG_FONT FONT_12X20;
+#endif
+#ifdef USE_FONT_16X26
+   extern __UG_FONT_DATA UG_FONT FONT_16X26;
+#endif
+#ifdef USE_FONT_22X36
+   extern __UG_FONT_DATA UG_FONT FONT_22X36;
+#endif
+#ifdef USE_FONT_24X40
+   extern __UG_FONT_DATA UG_FONT FONT_24X40;
+#endif
+#ifdef USE_FONT_32X53
+   extern __UG_FONT_DATA UG_FONT FONT_32X53;
+#endif
+#ifdef USE_FONT_GB2312_12X12
+    extern __UG_FONT_DATA UG_FONT FONT_GB2312_12X12;
+#endif
+#ifdef USE_FONT_GB2312_20X20
+    extern __UG_FONT_DATA UG_FONT FONT_GB2312_20X20;
+#endif
+#ifdef USE_FONT_GB2312_36X36
+    extern __UG_FONT_DATA UG_FONT FONT_GB2312_36X36;
+#endif
+/* -------------------------------------------------------------------------------- */
+/* -- TYPEDEFS                                                                   -- */
+/* -------------------------------------------------------------------------------- */
+typedef struct S_OBJECT         UG_OBJECT;
+typedef struct S_WINDOW         UG_WINDOW;
+typedef UG_S8                   UG_RESULT;
+#ifdef USE_COLOR_RGB888
+typedef UG_U32                  UG_COLOR;
+#endif
+#ifdef USE_COLOR_RGB565
+typedef UG_U16                  UG_COLOR;
+#endif
+
+/* -------------------------------------------------------------------------------- */
+/* -- DEFINES                                                                    -- */
+/* -------------------------------------------------------------------------------- */
+#ifndef NULL
+   #define NULL ((void*) 0)
+#endif
+
+/* Alignments */
+#define ALIGN_H_LEFT            (1<<0)
+#define ALIGN_H_CENTER          (1<<1)
+#define ALIGN_H_RIGHT           (1<<2)
+#define ALIGN_V_TOP             (1<<3)
+#define ALIGN_V_CENTER          (1<<4)
+#define ALIGN_V_BOTTOM          (1<<5)
+#define ALIGN_BOTTOM_RIGHT      (ALIGN_V_BOTTOM | ALIGN_H_RIGHT)
+#define ALIGN_BOTTOM_CENTER     (ALIGN_V_BOTTOM | ALIGN_H_CENTER)
+#define ALIGN_BOTTOM_LEFT       (ALIGN_V_BOTTOM | ALIGN_H_LEFT)
+#define ALIGN_CENTER_RIGHT      (ALIGN_V_CENTER | ALIGN_H_RIGHT)
+#define ALIGN_CENTER            (ALIGN_V_CENTER | ALIGN_H_CENTER)
+#define ALIGN_CENTER_LEFT       (ALIGN_V_CENTER | ALIGN_H_LEFT)
+#define ALIGN_TOP_RIGHT         (ALIGN_V_TOP | ALIGN_H_RIGHT)
+#define ALIGN_TOP_CENTER        (ALIGN_V_TOP | ALIGN_H_CENTER)
+#define ALIGN_TOP_LEFT          (ALIGN_V_TOP | ALIGN_H_LEFT)
+
+/* Default IDs */
+#define OBJ_ID_0                0
+#define OBJ_ID_1                1
+#define OBJ_ID_2                2
+#define OBJ_ID_3                3
+#define OBJ_ID_4                4
+#define OBJ_ID_5                5
+#define OBJ_ID_6                6
+#define OBJ_ID_7                7
+#define OBJ_ID_8                8
+#define OBJ_ID_9                9
+#define OBJ_ID_10               10
+#define OBJ_ID_11               11
+#define OBJ_ID_12               12
+#define OBJ_ID_13               13
+#define OBJ_ID_14               14
+#define OBJ_ID_15               15
+#define OBJ_ID_16               16
+#define OBJ_ID_17               17
+#define OBJ_ID_18               18
+#define OBJ_ID_19               19
+
+/* -------------------------------------------------------------------------------- */
+/* -- FUNCTION RESULTS                                                           -- */
+/* -------------------------------------------------------------------------------- */
+#define UG_RESULT_FAIL          -1
+#define UG_RESULT_OK            0
+
+/* -------------------------------------------------------------------------------- */
+/* -- UNIVERSAL STRUCTURES                                                       -- */
+/* -------------------------------------------------------------------------------- */
+/* Area structure */
+typedef struct
+{
+   UG_S16 xs;
+   UG_S16 ys;
+   UG_S16 xe;
+   UG_S16 ye;
+} UG_AREA;
+
+/* Text structure */
+typedef struct
+{
+   char* str;
+   __UG_FONT_DATA UG_FONT* font;
+   __UG_FONT_DATA UG_FONT* font_gb2312;
+   UG_AREA a;
+   UG_COLOR fc;
+   UG_COLOR bc;
+   UG_U8 align;
+   UG_S16 h_space;
+   UG_S16 v_space;
+} UG_TEXT;
+
+/* ¶à±ßÐζ¥µã */
+typedef struct
+{
+    UG_U16 x;
+    UG_U16 y;
+}PolygonVertex;
+/* -------------------------------------------------------------------------------- */
+/* -- MESSAGE                                                                    -- */
+/* -------------------------------------------------------------------------------- */
+/* Message structure */
+typedef struct
+{
+   UG_U8 type;
+   UG_U8 id;
+   UG_U8 sub_id;
+   UG_U8 event;
+   void* src;
+} UG_MESSAGE;
+
+/* Message types */
+#define MSG_TYPE_NONE           0
+#define MSG_TYPE_WINDOW         1
+#define MSG_TYPE_OBJECT         2
+
+/* -------------------------------------------------------------------------------- */
+/* -- TOUCH                                                                      -- */
+/* -------------------------------------------------------------------------------- */
+/* Touch structure */
+typedef struct
+{
+   UG_U8 state;
+   UG_S16 xp;
+   UG_S16 yp;
+} UG_TOUCH;
+
+
+#define TOUCH_STATE_PRESSED     1
+#define TOUCH_STATE_RELEASED    0
+
+/* -------------------------------------------------------------------------------- */
+/* -- OBJECTS                                                                    -- */
+/* -------------------------------------------------------------------------------- */
+/* Object structure */
+struct S_OBJECT
+{
+   UG_U8 state;                              /* object state                               */
+   UG_U8 touch_state;                        /* object touch state                         */
+   void (*update) (UG_WINDOW*,UG_OBJECT*);   /* pointer to object-specific update function */
+   UG_AREA a_abs;                            /* ¶ÔÏóµÄ¾ø¶ÔÇøÓò×ø±ê                         */
+   UG_AREA a_rel;                            /* ¶ÔÏóµÄÏà¶Ô×ø±êÇøÓò                         */
+   UG_U8 type;                               /* object type                                */
+   UG_U8 id;                                 /* object ID                                  */
+   UG_U8 event;                              /* ¶ÔÏóÌØ¶¨Ê¼þ                               */
+   void* data;                               /* pointer to object-specific data            */
+};
+
+/* Currently supported objects */
+#define OBJ_TYPE_NONE           0
+#define OBJ_TYPE_BUTTON         1
+#define OBJ_TYPE_TEXTBOX        2
+#define OBJ_TYPE_IMAGE          3
+#define OBJ_TYPE_CHECKBOX       4
+#define OBJ_TYPE_LED7SEG        5
+
+
+/* Standard object events */
+#define OBJ_EVENT_NONE          0
+#define OBJ_EVENT_CLICKED       1
+
+
+/* Object states */
+#define OBJ_STATE_FREE          (1<<0)
+#define OBJ_STATE_VALID         (1<<1)
+#define OBJ_STATE_BUSY          (1<<2)
+#define OBJ_STATE_VISIBLE       (1<<3)
+#define OBJ_STATE_ENABLE        (1<<4)
+#define OBJ_STATE_UPDATE        (1<<5)
+#define OBJ_STATE_REDRAW        (1<<6)
+#define OBJ_STATE_TOUCH_ENABLE  (1<<7)
+#define OBJ_STATE_INIT          (OBJ_STATE_FREE | OBJ_STATE_VALID)
+
+/* Object touch states */
+#define OBJ_TOUCH_STATE_CHANGED                       (1<<0)
+#define OBJ_TOUCH_STATE_PRESSED_ON_OBJECT             (1<<1)
+#define OBJ_TOUCH_STATE_PRESSED_OUTSIDE_OBJECT        (1<<2)
+#define OBJ_TOUCH_STATE_RELEASED_ON_OBJECT            (1<<3)
+#define OBJ_TOUCH_STATE_RELEASED_OUTSIDE_OBJECT       (1<<4)
+#define OBJ_TOUCH_STATE_IS_PRESSED_ON_OBJECT          (1<<5)
+#define OBJ_TOUCH_STATE_IS_PRESSED                    (1<<6)
+#define OBJ_TOUCH_STATE_CLICK_ON_OBJECT               (1<<7)
+#define OBJ_TOUCH_STATE_INIT                          0
+
+
+/* -------------------------------------------------------------------------------- */
+/* -- µGUI DRIVER                                                                -- */
+/* -------------------------------------------------------------------------------- */
+typedef struct
+{
+  void* driver;
+  UG_U8 state;
+} UG_DRIVER;
+
+#define DRIVER_REGISTERED       (1<<0)
+#define DRIVER_ENABLED          (1<<1)
+
+/* Supported drivers */
+#define NUMBER_OF_DRIVERS       2
+#define DRIVER_DRAW_LINE        0
+#define DRIVER_FILL_FRAME       1
+
+/* -------------------------------------------------------------------------------- */
+/* -- µGUI CORE STRUCTURE                                                        -- */
+/* -------------------------------------------------------------------------------- */
+typedef struct
+{
+   void (*pset)(UG_S16,UG_S16,UG_COLOR);
+   UG_S16 x_dim;// ÏÔʾÆ÷ˮƽ´óС
+   UG_S16 y_dim;// ÏÔʾÆ÷´¹Ö±´óС
+   UG_TOUCH touch;
+   UG_WINDOW* next_window;
+   UG_WINDOW* active_window;
+   UG_WINDOW* last_window;
+   struct
+   {
+      UG_S16 x_pos;
+      UG_S16 y_pos;
+      UG_S16 x_start;
+      UG_S16 y_start;
+      UG_S16 x_end;
+      UG_S16 y_end;
+      UG_COLOR fore_color;
+      UG_COLOR back_color;
+   } console;
+   UG_FONT font;
+   UG_S8 char_h_space;
+   UG_S8 char_v_space;
+   UG_COLOR fore_color;
+   UG_COLOR back_color;
+   UG_COLOR desktop_color;
+   UG_U8 state;
+   UG_DRIVER driver[NUMBER_OF_DRIVERS];
+} UG_GUI;
+
+#define UG_SATUS_WAIT_FOR_UPDATE    (1<<0)
+
+/* -------------------------------------------------------------------------------- */
+/* -- µGUI COLORS                                                                -- */
+/* -- Source: http://www.rapidtables.com/web/color/RGB_Color.htm                 -- */
+/* -------------------------------------------------------------------------------- */
+#ifdef USE_COLOR_RGB565
+#define C_MAROON                0x8000
+#define C_DARK_RED              0x8800
+#define C_BROWN                 0xA145
+#define C_FIREBRICK             0xB104
+#define C_CRIMSON               0xD8A7
+#define C_RED                   0xF800
+#define C_TOMATO                0xFB09
+#define C_CORAL                 0xFBEA
+#define C_INDIAN_RED            0xCAEB
+#define C_LIGHT_CORAL           0xEC10
+#define C_DARK_SALMON           0xE4AF
+#define C_SALMON                0xF40E
+#define C_LIGHT_SALMON          0xFD0F
+#define C_ORANGE_RED            0xFA20
+#define C_DARK_ORANGE           0xFC60
+#define C_ORANGE                0xFD20
+#define C_GOLD                  0xFEA0
+#define C_DARK_GOLDEN_ROD       0xB421
+#define C_GOLDEN_ROD            0xDD24
+#define C_PALE_GOLDEN_ROD       0xEF35
+#define C_DARK_KHAKI            0xBDAD
+#define C_KHAKI                 0xEF31
+#define C_OLIVE                 0x8400
+#define C_YELLOW                0xFFE0
+#define C_YELLOW_GREEN          0x9E66
+#define C_DARK_OLIVE_GREEN      0x5346
+#define C_OLIVE_DRAB            0x6C64
+#define C_LAWN_GREEN            0x7FC0
+#define C_CHART_REUSE           0x7FE0
+#define C_GREEN_YELLOW          0xAFE6
+#define C_DARK_GREEN            0x0320
+#define C_GREEN                 0x07E0
+#define C_FOREST_GREEN          0x2444
+#define C_LIME                  0x07E0
+#define C_LIME_GREEN            0x3666
+#define C_LIGHT_GREEN           0x9772
+#define C_PALE_GREEN            0x97D2
+#define C_DARK_SEA_GREEN        0x8DD1
+#define C_MEDIUM_SPRING_GREEN   0x07D3
+#define C_SPRING_GREEN          0x07EF
+#define C_SEA_GREEN             0x344B
+#define C_MEDIUM_AQUA_MARINE    0x6675
+#define C_MEDIUM_SEA_GREEN      0x3D8E
+#define C_LIGHT_SEA_GREEN       0x2595
+#define C_DARK_SLATE_GRAY       0x328A
+#define C_TEAL                  0x0410
+#define C_DARK_CYAN             0x0451
+#define C_AQUA                  0x07FF
+#define C_CYAN                  0x07FF
+#define C_LIGHT_CYAN            0xDFFF
+#define C_DARK_TURQUOISE        0x0679
+#define C_TURQUOISE             0x46F9
+#define C_MEDIUM_TURQUOISE      0x4E99
+#define C_PALE_TURQUOISE        0xAF7D
+#define C_AQUA_MARINE           0x7FFA
+#define C_POWDER_BLUE           0xAEFC
+#define C_CADET_BLUE            0x64F3
+#define C_STEEL_BLUE            0x4C16
+#define C_CORN_FLOWER_BLUE      0x64BD
+#define C_DEEP_SKY_BLUE         0x05FF
+#define C_DODGER_BLUE           0x249F
+#define C_LIGHT_BLUE            0xAEBC
+#define C_SKY_BLUE              0x867D
+#define C_LIGHT_SKY_BLUE        0x867E
+#define C_MIDNIGHT_BLUE         0x18CE
+#define C_NAVY                  0x0010
+#define C_DARK_BLUE             0x0011
+#define C_MEDIUM_BLUE           0x0019
+#define C_BLUE                  0x001F
+#define C_ROYAL_BLUE            0x435B
+#define C_BLUE_VIOLET           0x897B
+#define C_INDIGO                0x4810
+#define C_DARK_SLATE_BLUE       0x49F1
+#define C_SLATE_BLUE            0x6AD9
+#define C_MEDIUM_SLATE_BLUE     0x7B5D
+#define C_MEDIUM_PURPLE         0x939B
+#define C_DARK_MAGENTA          0x8811
+#define C_DARK_VIOLET           0x901A
+#define C_DARK_ORCHID           0x9999
+#define C_MEDIUM_ORCHID         0xBABA
+#define C_PURPLE                0x8010
+#define C_THISTLE               0xD5FA
+#define C_PLUM                  0xDD1B
+#define C_VIOLET                0xEC1D
+#define C_MAGENTA               0xF81F
+#define C_ORCHID                0xDB9A
+#define C_MEDIUM_VIOLET_RED     0xC0B0
+#define C_PALE_VIOLET_RED       0xDB92
+#define C_DEEP_PINK             0xF8B2
+#define C_HOT_PINK              0xFB56
+#define C_LIGHT_PINK            0xFDB7
+#define C_PINK                  0xFDF9
+#define C_ANTIQUE_WHITE         0xF75A
+#define C_BEIGE                 0xF7BB
+#define C_BISQUE                0xFF18
+#define C_BLANCHED_ALMOND       0xFF59
+#define C_WHEAT                 0xF6F6
+#define C_CORN_SILK             0xFFBB
+#define C_LEMON_CHIFFON         0xFFD9
+#define C_LIGHT_GOLDEN_ROD_YELLOW   0xF7DA
+#define C_LIGHT_YELLOW          0xFFFB
+#define C_SADDLE_BROWN          0x8A22
+#define C_SIENNA                0x9A85
+#define C_CHOCOLATE             0xD344
+#define C_PERU                  0xCC28
+#define C_SANDY_BROWN           0xF52C
+#define C_BURLY_WOOD            0xDDB0
+#define C_TAN                   0xD591
+#define C_ROSY_BROWN            0xBC71
+#define C_MOCCASIN              0xFF16
+#define C_NAVAJO_WHITE          0xFEF5
+#define C_PEACH_PUFF            0xFED6
+#define C_MISTY_ROSE            0xFF1B
+#define C_LAVENDER_BLUSH        0xFF7E
+#define C_LINEN                 0xF77C
+#define C_OLD_LACE              0xFFBC
+#define C_PAPAYA_WHIP           0xFF7A
+#define C_SEA_SHELL             0xFFBD
+#define C_MINT_CREAM            0xF7FE
+#define C_SLATE_GRAY            0x7412
+#define C_LIGHT_SLATE_GRAY      0x7453
+#define C_LIGHT_STEEL_BLUE      0xAE1B
+#define C_LAVENDER              0xE73E
+#define C_FLORAL_WHITE          0xFFDD
+#define C_ALICE_BLUE            0xEFBF
+#define C_GHOST_WHITE           0xF7BF
+#define C_HONEYDEW              0xEFFD
+#define C_IVORY                 0xFFFD
+#define C_AZURE                 0xEFFF
+#define C_SNOW                  0xFFDE
+#define C_BLACK                 0x0000
+#define C_DIM_GRAY              0x6B4D
+#define C_GRAY                  0x8410
+#define C_DARK_GRAY             0xAD55
+#define C_SILVER                0xBDF7
+#define C_LIGHT_GRAY            0xD69A
+#define C_GAINSBORO             0xDEDB
+#define C_WHITE_SMOKE           0xF7BE
+#define C_WHITE                 0xFFFF
+#endif
+
+#ifdef USE_COLOR_RGB888
+#define  C_MAROON               0x800000
+#define  C_DARK_RED             0x8B0000
+#define  C_BROWN                0xA52A2A
+#define  C_FIREBRICK            0xB22222
+#define  C_CRIMSON              0xDC143C
+#define  C_RED                  0xFF0000
+#define  C_TOMATO               0xFF6347
+#define  C_CORAL                0xFF7F50
+#define  C_INDIAN_RED           0xCD5C5C
+#define  C_LIGHT_CORAL          0xF08080
+#define  C_DARK_SALMON          0xE9967A
+#define  C_SALMON               0xFA8072
+#define  C_LIGHT_SALMON         0xFFA07A
+#define  C_ORANGE_RED           0xFF4500
+#define  C_DARK_ORANGE          0xFF8C00
+#define  C_ORANGE               0xFFA500
+#define  C_GOLD                 0xFFD700
+#define  C_DARK_GOLDEN_ROD      0xB8860B
+#define  C_GOLDEN_ROD           0xDAA520
+#define  C_PALE_GOLDEN_ROD      0xEEE8AA
+#define  C_DARK_KHAKI           0xBDB76B
+#define  C_KHAKI                0xF0E68C
+#define  C_OLIVE                0x808000
+#define  C_YELLOW               0xFFFF00
+#define  C_YELLOW_GREEN         0x9ACD32
+#define  C_DARK_OLIVE_GREEN     0x556B2F
+#define  C_OLIVE_DRAB           0x6B8E23
+#define  C_LAWN_GREEN           0x7CFC00
+#define  C_CHART_REUSE          0x7FFF00
+#define  C_GREEN_YELLOW         0xADFF2F
+#define  C_DARK_GREEN           0x006400
+#define  C_GREEN                0x00FF00
+#define  C_FOREST_GREEN         0x228B22
+#define  C_LIME                 0x00FF00
+#define  C_LIME_GREEN           0x32CD32
+#define  C_LIGHT_GREEN          0x90EE90
+#define  C_PALE_GREEN           0x98FB98
+#define  C_DARK_SEA_GREEN       0x8FBC8F
+#define  C_MEDIUM_SPRING_GREEN  0x00FA9A
+#define  C_SPRING_GREEN         0x00FF7F
+#define  C_SEA_GREEN            0x2E8B57
+#define  C_MEDIUM_AQUA_MARINE   0x66CDAA
+#define  C_MEDIUM_SEA_GREEN     0x3CB371
+#define  C_LIGHT_SEA_GREEN      0x20B2AA
+#define  C_DARK_SLATE_GRAY      0x2F4F4F
+#define  C_TEAL                 0x008080
+#define  C_DARK_CYAN            0x008B8B
+#define  C_AQUA                 0x00FFFF
+#define  C_CYAN                 0x00FFFF
+#define  C_LIGHT_CYAN           0xE0FFFF
+#define  C_DARK_TURQUOISE       0x00CED1
+#define  C_TURQUOISE            0x40E0D0
+#define  C_MEDIUM_TURQUOISE     0x48D1CC
+#define  C_PALE_TURQUOISE       0xAFEEEE
+#define  C_AQUA_MARINE          0x7FFFD4
+#define  C_POWDER_BLUE          0xB0E0E6
+#define  C_CADET_BLUE           0x5F9EA0
+#define  C_STEEL_BLUE           0x4682B4
+#define  C_CORN_FLOWER_BLUE     0x6495ED
+#define  C_DEEP_SKY_BLUE        0x00BFFF
+#define  C_DODGER_BLUE          0x1E90FF
+#define  C_LIGHT_BLUE           0xADD8E6
+#define  C_SKY_BLUE             0x87CEEB
+#define  C_LIGHT_SKY_BLUE       0x87CEFA
+#define  C_MIDNIGHT_BLUE        0x191970
+#define  C_NAVY                 0x000080
+#define  C_DARK_BLUE            0x00008B
+#define  C_MEDIUM_BLUE          0x0000CD
+#define  C_BLUE                 0x0000FF
+#define  C_ROYAL_BLUE           0x4169E1
+#define  C_BLUE_VIOLET          0x8A2BE2
+#define  C_INDIGO               0x4B0082
+#define  C_DARK_SLATE_BLUE      0x483D8B
+#define  C_SLATE_BLUE           0x6A5ACD
+#define  C_MEDIUM_SLATE_BLUE    0x7B68EE
+#define  C_MEDIUM_PURPLE        0x9370DB
+#define  C_DARK_MAGENTA         0x8B008B
+#define  C_DARK_VIOLET          0x9400D3
+#define  C_DARK_ORCHID          0x9932CC
+#define  C_MEDIUM_ORCHID        0xBA55D3
+#define  C_PURPLE               0x800080
+#define  C_THISTLE              0xD8BFD8
+#define  C_PLUM                 0xDDA0DD
+#define  C_VIOLET               0xEE82EE
+#define  C_MAGENTA              0xFF00FF
+#define  C_ORCHID               0xDA70D6
+#define  C_MEDIUM_VIOLET_RED    0xC71585
+#define  C_PALE_VIOLET_RED      0xDB7093
+#define  C_DEEP_PINK            0xFF1493
+#define  C_HOT_PINK             0xFF69B4
+#define  C_LIGHT_PINK           0xFFB6C1
+#define  C_PINK                 0xFFC0CB
+#define  C_ANTIQUE_WHITE        0xFAEBD7
+#define  C_BEIGE                0xF5F5DC
+#define  C_BISQUE               0xFFE4C4
+#define  C_BLANCHED_ALMOND      0xFFEBCD
+#define  C_WHEAT                0xF5DEB3
+#define  C_CORN_SILK            0xFFF8DC
+#define  C_LEMON_CHIFFON        0xFFFACD
+#define  C_LIGHT_GOLDEN_ROD_YELLOW    0xFAFAD2
+#define  C_LIGHT_YELLOW         0xFFFFE0
+#define  C_SADDLE_BROWN         0x8B4513
+#define  C_SIENNA               0xA0522D
+#define  C_CHOCOLATE            0xD2691E
+#define  C_PERU                 0xCD853F
+#define  C_SANDY_BROWN          0xF4A460
+#define  C_BURLY_WOOD           0xDEB887
+#define  C_TAN                  0xD2B48C
+#define  C_ROSY_BROWN           0xBC8F8F
+#define  C_MOCCASIN             0xFFE4B5
+#define  C_NAVAJO_WHITE         0xFFDEAD
+#define  C_PEACH_PUFF           0xFFDAB9
+#define  C_MISTY_ROSE           0xFFE4E1
+#define  C_LAVENDER_BLUSH       0xFFF0F5
+#define  C_LINEN                0xFAF0E6
+#define  C_OLD_LACE             0xFDF5E6
+#define  C_PAPAYA_WHIP          0xFFEFD5
+#define  C_SEA_SHELL            0xFFF5EE
+#define  C_MINT_CREAM           0xF5FFFA
+#define  C_SLATE_GRAY           0x708090
+#define  C_LIGHT_SLATE_GRAY     0x778899
+#define  C_LIGHT_STEEL_BLUE     0xB0C4DE
+#define  C_LAVENDER             0xE6E6FA
+#define  C_FLORAL_WHITE         0xFFFAF0
+#define  C_ALICE_BLUE           0xF0F8FF
+#define  C_GHOST_WHITE          0xF8F8FF
+#define  C_HONEYDEW             0xF0FFF0
+#define  C_IVORY                0xFFFFF0
+#define  C_AZURE                0xF0FFFF
+#define  C_SNOW                 0xFFFAFA
+#define  C_BLACK                0x000000
+#define  C_DIM_GRAY             0x696969
+#define  C_GRAY                 0x808080
+#define  C_DARK_GRAY            0xA9A9A9
+#define  C_SILVER               0xC0C0C0
+#define  C_LIGHT_GRAY           0xD3D3D3
+#define  C_GAINSBORO            0xDCDCDC
+#define  C_WHITE_SMOKE          0xF5F5F5
+#define  C_WHITE                0xFFFFFF
+#endif
+
+/* -------------------------------------------------------------------------------- */
+/* -- PROTOTYPES                                                                 -- */
+/* -------------------------------------------------------------------------------- */
+/* Hardware Acceleration */
+/* Hardware accelerator for UG_FillFrame */
+void _HW_DrawPoint(UG_S16 x , UG_S16 y , UG_COLOR c);
+/* Hardware accelerator for UG_DrawLine */
+UG_RESULT _HW_DrawLine(UG_S16 x1 , UG_S16 y1 , UG_S16 x2 , UG_S16 y2 , UG_COLOR c);
+/* Hardware accelerator for UG_FillFrame */
+UG_RESULT _HW_FillFrame(UG_S16 x1 , UG_S16 y1 , UG_S16 x2 , UG_S16 y2 , UG_COLOR c);
+
+/* Classic functions */
+UG_S16 UG_Init( UG_GUI* g, void (*p)(UG_S16,UG_S16,UG_COLOR), UG_S16 width, UG_S16 height );
+UG_S16 UG_SelectGUI( UG_GUI* g );
+void UG_FontSelect( __UG_FONT_DATA UG_FONT* font );
+void UG_FillScreen( UG_COLOR c );
+void UG_FillFrame( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c );
+void UG_FillRoundFrame( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_S16 r, UG_COLOR c );
+void UG_DrawMesh( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c );
+void UG_DrawFrame( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c );
+void UG_DrawRoundFrame( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_S16 r, UG_COLOR c );
+void UG_DrawPixel( UG_S16 x0, UG_S16 y0, UG_COLOR c );
+void UG_DrawCircle( UG_S16 x0, UG_S16 y0, UG_S16 r, UG_COLOR c );
+void UG_FillCircle( UG_S16 x0, UG_S16 y0, UG_S16 r, UG_COLOR c );
+void UG_FillPolygon(UG_U8 vertexcount, PolygonVertex *vertexs, UG_COLOR c );
+void UG_DrawArc( UG_S16 x0, UG_S16 y0, UG_S16 r, UG_U8 s, UG_COLOR c );
+void UG_DrawLine( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c );
+void UG_PutString( UG_S16 x, UG_S16 y, char* str );
+void UG_PutChar( UG_U16 chr, UG_S16 x, UG_S16 y, UG_COLOR fc, UG_COLOR bc );
+void UG_ConsolePutString( char* str );
+void UG_ConsoleSetArea( UG_S16 xs, UG_S16 ys, UG_S16 xe, UG_S16 ye );
+void UG_ConsoleSetForecolor( UG_COLOR c );
+void UG_ConsoleSetBackcolor( UG_COLOR c );
+void UG_SetForecolor( UG_COLOR c );
+void UG_SetBackcolor( UG_COLOR c );
+UG_S16 UG_GetXDim( void );
+UG_S16 UG_GetYDim( void );
+void UG_FontSetHSpace( UG_U16 s );
+void UG_FontSetVSpace( UG_U16 s );
+
+/* Miscellaneous functions */
+void UG_WaitForUpdate( void );
+void UG_TouchUpdate( UG_S16 xp, UG_S16 yp, UG_U8 state );
+
+/* Driver functions */
+void UG_DriverRegister( UG_U8 type, void* driver );
+void UG_DriverEnable( UG_U8 type );
+void UG_DriverDisable( UG_U8 type );
+
+
+
+
+
+
+#endif
diff --git a/APP/bootloader/ugui_config.h b/APP/bootloader/ugui_config.h
new file mode 100644 (file)
index 0000000..59638ea
--- /dev/null
@@ -0,0 +1,53 @@
+/* -------------------------------------------------------------------------------- */
+/* -- µGUI - Generic GUI module (C)Achim Döbler, 2015                            -- */
+/* -------------------------------------------------------------------------------- */
+/* bootloader 专用配置: 仅保留英文显示所需的少量字体, 关闭中文 GB2312 字库,
+ * 以最大程度减小 bootloader 的代码体积。
+ */
+#ifndef __UGUI_CONFIG_H
+#define __UGUI_CONFIG_H
+
+/* -------------------------------------------------------------------------------- */
+/* -- CONFIG SECTION                                                             -- */
+/* -------------------------------------------------------------------------------- */
+
+/* Enable color mode: 本项目 LCD 使用 RGB565 */
+#define USE_COLOR_RGB565   // RGB = 0bRRRRRGGGGGGBBBBB
+
+/* Enable needed fonts here (仅英文, 最小化代码) */
+//#define  USE_FONT_4X6
+//#define  USE_FONT_5X8
+//#define  USE_FONT_5X12
+//#define  USE_FONT_6X8
+#define  USE_FONT_6X8
+#define  USE_FONT_8X12
+//#define  USE_FONT_8X14
+//#define  USE_FONT_10X16
+//#define  USE_FONT_12X16
+#define  USE_FONT_12X20
+//#define  USE_FONT_16X26
+//#define  USE_FONT_22X36
+//#define  USE_FONT_24X40
+//#define  USE_FONT_32X53
+
+/* 中文点阵字库不需要, 关闭以减小代码 */
+//#define USE_FONT_GB2312_12X12
+//#define USE_FONT_GB2312_20X20
+//#define USE_FONT_GB2312_36X36
+
+/* Specify platform-dependent integer types here */
+
+#define __UG_FONT_DATA const
+typedef uint8_t      UG_U8;
+typedef int8_t       UG_S8;
+typedef uint16_t     UG_U16;
+typedef int16_t      UG_S16;
+typedef uint32_t     UG_U32;
+typedef int32_t      UG_S32;
+
+
+/* -------------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------------- */
+
+
+#endif
\ No newline at end of file
diff --git a/APP/bootloader/ugui_core.h b/APP/bootloader/ugui_core.h
new file mode 100644 (file)
index 0000000..11d2169
--- /dev/null
@@ -0,0 +1,41 @@
+/* -------------------------------------------------------------------------------- */
+/* -- µGUI - Generic GUI module (C)Achim Döbler, 2015                            -- */
+/* -------------------------------------------------------------------------------- */
+// µGUI is a generic GUI module for embedded systems.
+// This is a free software that is open for education, research and commercial
+// developments under license policy of following terms.
+//
+//  Copyright (C) 2015, Achim Döbler, all rights reserved.
+//  URL: http://www.embeddedlightning.com/
+//
+// * The µGUI module is a free software and there is NO WARRANTY.
+// * No restriction on use. You can use, modify and redistribute it for
+//   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+// * Redistributions of source code must retain the above copyright notice.
+//
+/* -------------------------------------------------------------------------------- */
+#ifndef __UGUI_CORE_H
+#define __UGUI_CORE_H
+
+extern UG_GUI* pGUI;
+extern const UG_COLOR pal_window[];
+extern const UG_COLOR pal_button_pressed[];
+extern const UG_COLOR pal_button_released[];
+extern const UG_COLOR pal_checkbox_pressed[];
+extern const UG_COLOR pal_checkbox_released[];
+
+/* -------------------------------------------------------------------------------- */
+/* -- PROTOTYPES                                                                 -- */
+/* -------------------------------------------------------------------------------- */
+static void _UG_PutChar( char chr, UG_S16 x, UG_S16 y, UG_COLOR fc, UG_COLOR bc, const UG_FONT* font);
+void _UG_PutText(UG_TEXT* txt);
+extern UG_OBJECT* _UG_GetFreeObject( UG_WINDOW* wnd );
+UG_OBJECT* _UG_SearchObject( UG_WINDOW* wnd, UG_U8 type, UG_U8 id );
+UG_RESULT _UG_DeleteObject( UG_WINDOW* wnd, UG_U8 type, UG_U8 id );
+void _UG_ProcessTouchData( UG_WINDOW* wnd );
+void _UG_UpdateObjects( UG_WINDOW* wnd );
+void _UG_HandleEvents( UG_WINDOW* wnd );
+void _UG_DrawObjectFrame( UG_S16 xs, UG_S16 ys, UG_S16 xe, UG_S16 ye, UG_COLOR* p );
+
+
+#endif
diff --git a/APP/bootloader/ugui_port.c b/APP/bootloader/ugui_port.c
new file mode 100644 (file)
index 0000000..9510c8f
--- /dev/null
@@ -0,0 +1,66 @@
+/* -------------------------------------------------------------------------------- */
+/* -- µGUI - Generic GUI module (C)Achim Döbler, 2015                            -- */
+/* -------------------------------------------------------------------------------- */
+/* bootloader 硬件移植层: 基于本项目 LCD (RGB565, 通过 SDRAM 显存刷新)
+ * LCD 控制器直接从 SDRAMM_BASE 处的一整帧显存循环刷新, 因此只需把像素写入
+ * 该显存对应的 (x, y) 位置即可完成显示。
+ */
+#include "ugui.h"
+
+/* 显存基地址: 与 BSP 中 LCD_Init() 设置的 DataSource 保持一致 */
+#define UG_LCD_FB_BASE      (0x80700000u)   /* SDRAMM_BASE */
+#define UG_LCD_WIDTH        (320u)          /* LCD_HDOT   */
+#define UG_LCD_HEIGHT       (240u)          /* LCD_VDOT   */
+
+#define UG_LCD_PIXELS       (UG_LCD_WIDTH * UG_LCD_HEIGHT)
+
+/* RGB565 颜色宏 (与项目内 xrgb565 存储方式保持一致) */
+#define UG_RGB565(r,g,b) \
+    ((UG_U16)((((r) & 0xF8u) << 8) | (((g) & 0xFCu) << 3) | (((b) & 0xF8u) >> 3)))
+
+/**
+ * @brief  将 RGB565 像素写入 LCD 显存 (用作 uGUI 的 pset 回调)
+ * @param  x / y : 屏幕坐标
+ * @param  c     : RGB565 颜色
+ * @retval 无
+ */
+void UG_Pixel_Set(UG_S16 x, UG_S16 y, UG_COLOR c)
+{
+    if (x < 0 || y < 0 || x >= UG_LCD_WIDTH || y >= UG_LCD_HEIGHT)
+        return;
+
+    volatile UG_U16 *p = (volatile UG_U16 *)(UG_LCD_FB_BASE + (y * UG_LCD_WIDTH + x) * sizeof(UG_U16));
+    *p = c;
+}
+
+/* Hardware accelerator for DrawPoint */
+void _HW_DrawPoint(UG_S16 x, UG_S16 y, UG_COLOR c)
+{
+    UG_Pixel_Set(x, y, c);
+}
+
+/* Hardware accelerator for UG_DrawLine */
+UG_RESULT _HW_DrawLine(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c)
+{
+    (void)x1; (void)y1; (void)x2; (void)y2; (void)c;
+    return UG_RESULT_OK; /* 交由 uGUI 软件绘制 */
+}
+
+/* Hardware accelerator for UG_FillFrame */
+UG_RESULT _HW_FillFrame(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c)
+{
+    (void)x1; (void)y1; (void)x2; (void)y2; (void)c;
+    return UG_RESULT_OK; /* 交由 uGUI 软件绘制 */
+}
+
+/**
+ * @brief  清屏: 将整个显存填充为指定 RGB565 颜色
+ * @param  color : RGB565 颜色
+ */
+void UG_LCD_Fill(UG_U16 color)
+{
+    volatile UG_U16 *p = (volatile UG_U16 *)UG_LCD_FB_BASE;
+    UG_U32 i;
+    for (i = 0; i < UG_LCD_PIXELS; ++i)
+        p[i] = color;
+}
\ No newline at end of file
diff --git a/APP/bootloader/widgets/window.h b/APP/bootloader/widgets/window.h
new file mode 100644 (file)
index 0000000..d9b9796
--- /dev/null
@@ -0,0 +1,127 @@
+/* -------------------------------------------------------------------------------- */
+/* -- µGUI - Generic GUI module (C)Achim Döbler, 2015                            -- */
+/* -------------------------------------------------------------------------------- */
+// µGUI is a generic GUI module for embedded systems.
+// This is a free software that is open for education, research and commercial
+// developments under license policy of following terms.
+//
+//  Copyright (C) 2015, Achim Döbler, all rights reserved.
+//  URL: http://www.embeddedlightning.com/
+//
+// * The µGUI module is a free software and there is NO WARRANTY.
+// * No restriction on use. You can use, modify and redistribute it for
+//   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+// * Redistributions of source code must retain the above copyright notice.
+//
+/* -------------------------------------------------------------------------------- */
+#ifndef __WINDOW_H
+#define __WINDOW_H
+
+#include "stdint.h"
+#include "ugui_config.h"
+
+
+/* -------------------------------------------------------------------------------- */
+/* -- WINDOW                                                                     -- */
+/* -------------------------------------------------------------------------------- */
+/* Title structure */
+typedef struct
+{
+   char* str;
+   const UG_FONT* font;
+   const UG_FONT* font_gb2312;
+   UG_S8 h_space;
+   UG_S8 v_space;
+   UG_U8 align;
+   UG_COLOR fc;
+   UG_COLOR bc;
+   UG_COLOR ifc;
+   UG_COLOR ibc;
+   UG_U8 height;
+} UG_TITLE;
+
+/* Window structure */
+struct S_WINDOW
+{
+   UG_U8 objcnt;
+   UG_OBJECT* objlst;
+   UG_U8 state;
+   UG_COLOR fc;
+   UG_COLOR bc;
+   UG_S16 xs;
+   UG_S16 ys;
+   UG_S16 xe;
+   UG_S16 ye;
+   UG_U8 style;
+   UG_TITLE title;
+   void (*cb)( UG_MESSAGE* );
+};
+
+/* Window states */
+#define WND_STATE_FREE          (1<<0)
+#define WND_STATE_VALID         (1<<1)
+#define WND_STATE_BUSY          (1<<2)
+#define WND_STATE_VISIBLE       (1<<3)
+#define WND_STATE_ENABLE        (1<<4)
+#define WND_STATE_UPDATE        (1<<5)
+#define WND_STATE_REDRAW_TITLE  (1<<6)
+
+/* Window styles */
+#define WND_STYLE_2D            (0<<0)
+#define WND_STYLE_3D            (1<<0)
+#define WND_STYLE_HIDE_TITLE    (0<<1)
+#define WND_STYLE_SHOW_TITLE    (1<<1)
+/* -------------------------------------------------------------------------------- */
+/* -- PROTOTYPES                                                                 -- */
+/* -------------------------------------------------------------------------------- */
+/* Window functions */
+UG_RESULT UG_WindowCreate( UG_WINDOW* wnd, UG_OBJECT* objlst, UG_U8 objcnt, void (*cb)( UG_MESSAGE* ) );
+UG_RESULT UG_WindowDelete( UG_WINDOW* wnd );
+UG_RESULT UG_WindowShow( UG_WINDOW* wnd );
+UG_RESULT UG_WindowHide( UG_WINDOW* wnd );
+UG_RESULT UG_WindowResize( UG_WINDOW* wnd, UG_S16 xs, UG_S16 ys, UG_S16 xe, UG_S16 ye );
+UG_RESULT UG_WindowAlert( UG_WINDOW* wnd );
+UG_RESULT UG_WindowSetForeColor( UG_WINDOW* wnd, UG_COLOR fc );
+UG_RESULT UG_WindowSetBackColor( UG_WINDOW* wnd, UG_COLOR bc );
+UG_RESULT UG_WindowSetTitleTextColor( UG_WINDOW* wnd, UG_COLOR c );
+UG_RESULT UG_WindowSetTitleColor( UG_WINDOW* wnd, UG_COLOR c );
+UG_RESULT UG_WindowSetTitleInactiveTextColor( UG_WINDOW* wnd, UG_COLOR c );
+UG_RESULT UG_WindowSetTitleInactiveColor( UG_WINDOW* wnd, UG_COLOR c );
+UG_RESULT UG_WindowSetTitleText( UG_WINDOW* wnd, char* str );
+UG_RESULT UG_WindowSetTitleTextFont( UG_WINDOW* wnd, const UG_FONT* font );
+UG_RESULT UG_WindowSetTitleTextFont_GB2312( UG_WINDOW* wnd, const UG_FONT* font );
+UG_RESULT UG_WindowSetTitleTextHSpace( UG_WINDOW* wnd, UG_S8 hs );
+UG_RESULT UG_WindowSetTitleTextVSpace( UG_WINDOW* wnd, UG_S8 vs );
+UG_RESULT UG_WindowSetTitleTextAlignment( UG_WINDOW* wnd, UG_U8 align );
+UG_RESULT UG_WindowSetTitleHeight( UG_WINDOW* wnd, UG_U8 height );
+UG_RESULT UG_WindowSetXStart( UG_WINDOW* wnd, UG_S16 xs );
+UG_RESULT UG_WindowSetYStart( UG_WINDOW* wnd, UG_S16 ys );
+UG_RESULT UG_WindowSetXEnd( UG_WINDOW* wnd, UG_S16 xe );
+UG_RESULT UG_WindowSetYEnd( UG_WINDOW* wnd, UG_S16 ye );
+UG_RESULT UG_WindowSetStyle( UG_WINDOW* wnd, UG_U8 style );
+UG_COLOR UG_WindowGetForeColor( UG_WINDOW* wnd );
+UG_COLOR UG_WindowGetBackColor( UG_WINDOW* wnd );
+UG_COLOR UG_WindowGetTitleTextColor( UG_WINDOW* wnd );
+UG_COLOR UG_WindowGetTitleColor( UG_WINDOW* wnd );
+UG_COLOR UG_WindowGetTitleInactiveTextColor( UG_WINDOW* wnd );
+UG_COLOR UG_WindowGetTitleInactiveColor( UG_WINDOW* wnd );
+char* UG_WindowGetTitleText( UG_WINDOW* wnd );
+UG_FONT* UG_WindowGetTitleTextFont( UG_WINDOW* wnd );
+UG_FONT* UG_WindowGetTitleTextFont_GB2312( UG_WINDOW* wnd );
+UG_S8 UG_WindowGetTitleTextHSpace( UG_WINDOW* wnd );
+UG_S8 UG_WindowGetTitleTextVSpace( UG_WINDOW* wnd );
+UG_U8 UG_WindowGetTitleTextAlignment( UG_WINDOW* wnd );
+UG_U8 UG_WindowGetTitleHeight( UG_WINDOW* wnd );
+UG_S16 UG_WindowGetXStart( UG_WINDOW* wnd );
+UG_S16 UG_WindowGetYStart( UG_WINDOW* wnd );
+UG_S16 UG_WindowGetXEnd( UG_WINDOW* wnd );
+UG_S16 UG_WindowGetYEnd( UG_WINDOW* wnd );
+UG_U8 UG_WindowGetStyle( UG_WINDOW* wnd );
+UG_RESULT UG_WindowGetArea( UG_WINDOW* wnd, UG_AREA* a );
+UG_S16 UG_WindowGetInnerWidth( UG_WINDOW* wnd );
+UG_S16 UG_WindowGetOuterWidth( UG_WINDOW* wnd );
+UG_S16 UG_WindowGetInnerHeight( UG_WINDOW* wnd );
+UG_S16 UG_WindowGetOuterHeight( UG_WINDOW* wnd );
+void UG_Update( void );
+
+#endif
diff --git a/APP/fs/lfs.c b/APP/fs/lfs.c
new file mode 100644 (file)
index 0000000..c83c7e0
--- /dev/null
@@ -0,0 +1,6558 @@
+/*
+ * The little filesystem
+ *
+ * Copyright (c) 2022, The littlefs authors.
+ * Copyright (c) 2017, Arm Limited. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include "lfs.h"
+#include "lfs_util.h"
+
+
+// some constants used throughout the code
+#define LFS_BLOCK_NULL ((lfs_block_t)-1)
+#define LFS_BLOCK_INLINE ((lfs_block_t)-2)
+
+enum {
+    LFS_OK_RELOCATED = 1,
+    LFS_OK_DROPPED   = 2,
+    LFS_OK_ORPHANED  = 3,
+};
+
+enum {
+    LFS_CMP_EQ = 0,
+    LFS_CMP_LT = 1,
+    LFS_CMP_GT = 2,
+};
+
+
+/// Caching block device operations ///
+
+static inline void lfs_cache_drop(lfs_t *lfs, lfs_cache_t *rcache) {
+    // do not zero, cheaper if cache is readonly or only going to be
+    // written with identical data (during relocates)
+    (void)lfs;
+    rcache->block = LFS_BLOCK_NULL;
+}
+
+static inline void lfs_cache_zero(lfs_t *lfs, lfs_cache_t *pcache) {
+    // zero to avoid information leak
+    memset(pcache->buffer, 0xff, lfs->cfg->cache_size);
+    pcache->block = LFS_BLOCK_NULL;
+}
+
+static int lfs_bd_read(lfs_t *lfs,
+        const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
+        lfs_block_t block, lfs_off_t off,
+        void *buffer, lfs_size_t size) {
+    uint8_t *data = buffer;
+    if (off+size > lfs->cfg->block_size
+            || (lfs->block_count && block >= lfs->block_count)) {
+        return LFS_ERR_CORRUPT;
+    }
+
+    while (size > 0) {
+        lfs_size_t diff = size;
+
+        if (pcache && block == pcache->block &&
+                off < pcache->off + pcache->size) {
+            if (off >= pcache->off) {
+                // is already in pcache?
+                diff = lfs_min(diff, pcache->size - (off-pcache->off));
+                memcpy(data, &pcache->buffer[off-pcache->off], diff);
+
+                data += diff;
+                off += diff;
+                size -= diff;
+                continue;
+            }
+
+            // pcache takes priority
+            diff = lfs_min(diff, pcache->off-off);
+        }
+
+        if (block == rcache->block &&
+                off < rcache->off + rcache->size) {
+            if (off >= rcache->off) {
+                // is already in rcache?
+                diff = lfs_min(diff, rcache->size - (off-rcache->off));
+                memcpy(data, &rcache->buffer[off-rcache->off], diff);
+
+                data += diff;
+                off += diff;
+                size -= diff;
+                continue;
+            }
+
+            // rcache takes priority
+            diff = lfs_min(diff, rcache->off-off);
+        }
+
+        if (size >= hint && off % lfs->cfg->read_size == 0 &&
+                size >= lfs->cfg->read_size) {
+            // bypass cache?
+            diff = lfs_aligndown(diff, lfs->cfg->read_size);
+            int err = lfs->cfg->read(lfs->cfg, block, off, data, diff);
+            LFS_ASSERT(err <= 0);
+            if (err) {
+                return err;
+            }
+
+            data += diff;
+            off += diff;
+            size -= diff;
+            continue;
+        }
+
+        // load to cache, first condition can no longer fail
+        LFS_ASSERT(!lfs->block_count || block < lfs->block_count);
+        rcache->block = block;
+        rcache->off = lfs_aligndown(off, lfs->cfg->read_size);
+        rcache->size = lfs_min(
+                lfs_min(
+                    lfs_alignup(off+hint, lfs->cfg->read_size),
+                    lfs->cfg->block_size)
+                - rcache->off,
+                lfs->cfg->cache_size);
+        int err = lfs->cfg->read(lfs->cfg, rcache->block,
+                rcache->off, rcache->buffer, rcache->size);
+        LFS_ASSERT(err <= 0);
+        if (err) {
+            return err;
+        }
+    }
+
+    return 0;
+}
+
+static int lfs_bd_cmp(lfs_t *lfs,
+        const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
+        lfs_block_t block, lfs_off_t off,
+        const void *buffer, lfs_size_t size) {
+    const uint8_t *data = buffer;
+    lfs_size_t diff = 0;
+
+    for (lfs_off_t i = 0; i < size; i += diff) {
+        uint8_t dat[8];
+
+        diff = lfs_min(size-i, sizeof(dat));
+        int err = lfs_bd_read(lfs,
+                pcache, rcache, hint-i,
+                block, off+i, &dat, diff);
+        if (err) {
+            return err;
+        }
+
+        int res = memcmp(dat, data + i, diff);
+        if (res) {
+            return res < 0 ? LFS_CMP_LT : LFS_CMP_GT;
+        }
+    }
+
+    return LFS_CMP_EQ;
+}
+
+static int lfs_bd_crc(lfs_t *lfs,
+        const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
+        lfs_block_t block, lfs_off_t off, lfs_size_t size, uint32_t *crc) {
+    lfs_size_t diff = 0;
+
+    for (lfs_off_t i = 0; i < size; i += diff) {
+        uint8_t dat[8];
+        diff = lfs_min(size-i, sizeof(dat));
+        int err = lfs_bd_read(lfs,
+                pcache, rcache, hint-i,
+                block, off+i, &dat, diff);
+        if (err) {
+            return err;
+        }
+
+        *crc = lfs_crc(*crc, &dat, diff);
+    }
+
+    return 0;
+}
+
+#ifndef LFS_READONLY
+static int lfs_bd_flush(lfs_t *lfs,
+        lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate) {
+    if (pcache->block != LFS_BLOCK_NULL && pcache->block != LFS_BLOCK_INLINE) {
+        LFS_ASSERT(pcache->block < lfs->block_count);
+        lfs_size_t diff = lfs_alignup(pcache->size, lfs->cfg->prog_size);
+        int err = lfs->cfg->prog(lfs->cfg, pcache->block,
+                pcache->off, pcache->buffer, diff);
+        LFS_ASSERT(err <= 0);
+        if (err) {
+            return err;
+        }
+
+        if (validate) {
+            // check data on disk
+            lfs_cache_drop(lfs, rcache);
+            int res = lfs_bd_cmp(lfs,
+                    NULL, rcache, diff,
+                    pcache->block, pcache->off, pcache->buffer, diff);
+            if (res < 0) {
+                return res;
+            }
+
+            if (res != LFS_CMP_EQ) {
+                return LFS_ERR_CORRUPT;
+            }
+        }
+
+        lfs_cache_zero(lfs, pcache);
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_bd_sync(lfs_t *lfs,
+        lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate) {
+    lfs_cache_drop(lfs, rcache);
+
+    int err = lfs_bd_flush(lfs, pcache, rcache, validate);
+    if (err) {
+        return err;
+    }
+
+    err = lfs->cfg->sync(lfs->cfg);
+    LFS_ASSERT(err <= 0);
+    return err;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_bd_prog(lfs_t *lfs,
+        lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate,
+        lfs_block_t block, lfs_off_t off,
+        const void *buffer, lfs_size_t size) {
+    const uint8_t *data = buffer;
+    LFS_ASSERT(block == LFS_BLOCK_INLINE || block < lfs->block_count);
+    LFS_ASSERT(off + size <= lfs->cfg->block_size);
+
+    while (size > 0) {
+        if (block == pcache->block &&
+                off >= pcache->off &&
+                off < pcache->off + lfs->cfg->cache_size) {
+            // already fits in pcache?
+            lfs_size_t diff = lfs_min(size,
+                    lfs->cfg->cache_size - (off-pcache->off));
+            memcpy(&pcache->buffer[off-pcache->off], data, diff);
+
+            data += diff;
+            off += diff;
+            size -= diff;
+
+            pcache->size = lfs_max(pcache->size, off - pcache->off);
+            if (pcache->size == lfs->cfg->cache_size) {
+                // eagerly flush out pcache if we fill up
+                int err = lfs_bd_flush(lfs, pcache, rcache, validate);
+                if (err) {
+                    return err;
+                }
+            }
+
+            continue;
+        }
+
+        // pcache must have been flushed, either by programming an
+        // entire block or manually flushing the pcache
+        LFS_ASSERT(pcache->block == LFS_BLOCK_NULL);
+
+        // prepare pcache, first condition can no longer fail
+        pcache->block = block;
+        pcache->off = lfs_aligndown(off, lfs->cfg->prog_size);
+        pcache->size = 0;
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_bd_erase(lfs_t *lfs, lfs_block_t block) {
+    LFS_ASSERT(block < lfs->block_count);
+    int err = lfs->cfg->erase(lfs->cfg, block);
+    LFS_ASSERT(err <= 0);
+    return err;
+}
+#endif
+
+
+/// Small type-level utilities ///
+
+// some operations on paths
+static inline lfs_size_t lfs_path_namelen(const char *path) {
+    return (lfs_size_t)strcspn(path, "/");
+}
+
+static inline bool lfs_path_islast(const char *path) {
+    lfs_size_t namelen = lfs_path_namelen(path);
+    return path[namelen + strspn(path + namelen, "/")] == '\0';
+}
+
+static inline bool lfs_path_isdir(const char *path) {
+    return path[lfs_path_namelen(path)] != '\0';
+}
+
+// operations on block pairs
+static inline void lfs_pair_swap(lfs_block_t pair[2]) {
+    lfs_block_t t = pair[0];
+    pair[0] = pair[1];
+    pair[1] = t;
+}
+
+static inline bool lfs_pair_isnull(const lfs_block_t pair[2]) {
+    return pair[0] == LFS_BLOCK_NULL || pair[1] == LFS_BLOCK_NULL;
+}
+
+static inline int lfs_pair_cmp(
+        const lfs_block_t paira[2],
+        const lfs_block_t pairb[2]) {
+    return !(paira[0] == pairb[0] || paira[1] == pairb[1] ||
+             paira[0] == pairb[1] || paira[1] == pairb[0]);
+}
+
+static inline bool lfs_pair_issync(
+        const lfs_block_t paira[2],
+        const lfs_block_t pairb[2]) {
+    return (paira[0] == pairb[0] && paira[1] == pairb[1]) ||
+           (paira[0] == pairb[1] && paira[1] == pairb[0]);
+}
+
+static inline void lfs_pair_fromle32(lfs_block_t pair[2]) {
+    pair[0] = lfs_fromle32(pair[0]);
+    pair[1] = lfs_fromle32(pair[1]);
+}
+
+#ifndef LFS_READONLY
+static inline void lfs_pair_tole32(lfs_block_t pair[2]) {
+    pair[0] = lfs_tole32(pair[0]);
+    pair[1] = lfs_tole32(pair[1]);
+}
+#endif
+
+// operations on 32-bit entry tags
+typedef uint32_t lfs_tag_t;
+typedef int32_t lfs_stag_t;
+
+#define LFS_MKTAG(type, id, size) \
+    (((lfs_tag_t)(type) << 20) | ((lfs_tag_t)(id) << 10) | (lfs_tag_t)(size))
+
+#define LFS_MKTAG_IF(cond, type, id, size) \
+    ((cond) ? LFS_MKTAG(type, id, size) : LFS_MKTAG(LFS_FROM_NOOP, 0, 0))
+
+#define LFS_MKTAG_IF_ELSE(cond, type1, id1, size1, type2, id2, size2) \
+    ((cond) ? LFS_MKTAG(type1, id1, size1) : LFS_MKTAG(type2, id2, size2))
+
+static inline bool lfs_tag_isvalid(lfs_tag_t tag) {
+    return !(tag & 0x80000000);
+}
+
+static inline bool lfs_tag_isdelete(lfs_tag_t tag) {
+    return ((int32_t)(tag << 22) >> 22) == -1;
+}
+
+static inline uint16_t lfs_tag_type1(lfs_tag_t tag) {
+    return (tag & 0x70000000) >> 20;
+}
+
+static inline uint16_t lfs_tag_type2(lfs_tag_t tag) {
+    return (tag & 0x78000000) >> 20;
+}
+
+static inline uint16_t lfs_tag_type3(lfs_tag_t tag) {
+    return (tag & 0x7ff00000) >> 20;
+}
+
+static inline uint8_t lfs_tag_chunk(lfs_tag_t tag) {
+    return (tag & 0x0ff00000) >> 20;
+}
+
+static inline int8_t lfs_tag_splice(lfs_tag_t tag) {
+    return (int8_t)lfs_tag_chunk(tag);
+}
+
+static inline uint16_t lfs_tag_id(lfs_tag_t tag) {
+    return (tag & 0x000ffc00) >> 10;
+}
+
+static inline lfs_size_t lfs_tag_size(lfs_tag_t tag) {
+    return tag & 0x000003ff;
+}
+
+static inline lfs_size_t lfs_tag_dsize(lfs_tag_t tag) {
+    return sizeof(tag) + lfs_tag_size(tag + lfs_tag_isdelete(tag));
+}
+
+// operations on attributes in attribute lists
+struct lfs_mattr {
+    lfs_tag_t tag;
+    const void *buffer;
+};
+
+struct lfs_diskoff {
+    lfs_block_t block;
+    lfs_off_t off;
+};
+
+#define LFS_MKATTRS(...) \
+    (struct lfs_mattr[]){__VA_ARGS__}, \
+    sizeof((struct lfs_mattr[]){__VA_ARGS__}) / sizeof(struct lfs_mattr)
+
+// operations on global state
+static inline void lfs_gstate_xor(lfs_gstate_t *a, const lfs_gstate_t *b) {
+    a->tag ^= b->tag;
+    a->pair[0] ^= b->pair[0];
+    a->pair[1] ^= b->pair[1];
+}
+
+static inline bool lfs_gstate_iszero(const lfs_gstate_t *a) {
+    return a->tag == 0
+            && a->pair[0] == 0
+            && a->pair[1] == 0;
+}
+
+#ifndef LFS_READONLY
+static inline bool lfs_gstate_hasorphans(const lfs_gstate_t *a) {
+    return lfs_tag_size(a->tag);
+}
+
+static inline uint8_t lfs_gstate_getorphans(const lfs_gstate_t *a) {
+    return lfs_tag_size(a->tag) & 0x1ff;
+}
+
+static inline bool lfs_gstate_hasmove(const lfs_gstate_t *a) {
+    return lfs_tag_type1(a->tag);
+}
+#endif
+
+static inline bool lfs_gstate_needssuperblock(const lfs_gstate_t *a) {
+    return lfs_tag_size(a->tag) >> 9;
+}
+
+static inline bool lfs_gstate_hasmovehere(const lfs_gstate_t *a,
+        const lfs_block_t *pair) {
+    return lfs_tag_type1(a->tag) && lfs_pair_cmp(a->pair, pair) == 0;
+}
+
+static inline void lfs_gstate_fromle32(lfs_gstate_t *a) {
+    a->tag     = lfs_fromle32(a->tag);
+    a->pair[0] = lfs_fromle32(a->pair[0]);
+    a->pair[1] = lfs_fromle32(a->pair[1]);
+}
+
+#ifndef LFS_READONLY
+static inline void lfs_gstate_tole32(lfs_gstate_t *a) {
+    a->tag     = lfs_tole32(a->tag);
+    a->pair[0] = lfs_tole32(a->pair[0]);
+    a->pair[1] = lfs_tole32(a->pair[1]);
+}
+#endif
+
+// operations on forward-CRCs used to track erased state
+struct lfs_fcrc {
+    lfs_size_t size;
+    uint32_t crc;
+};
+
+static void lfs_fcrc_fromle32(struct lfs_fcrc *fcrc) {
+    fcrc->size = lfs_fromle32(fcrc->size);
+    fcrc->crc = lfs_fromle32(fcrc->crc);
+}
+
+#ifndef LFS_READONLY
+static void lfs_fcrc_tole32(struct lfs_fcrc *fcrc) {
+    fcrc->size = lfs_tole32(fcrc->size);
+    fcrc->crc = lfs_tole32(fcrc->crc);
+}
+#endif
+
+// other endianness operations
+static void lfs_ctz_fromle32(struct lfs_ctz *ctz) {
+    ctz->head = lfs_fromle32(ctz->head);
+    ctz->size = lfs_fromle32(ctz->size);
+}
+
+#ifndef LFS_READONLY
+static void lfs_ctz_tole32(struct lfs_ctz *ctz) {
+    ctz->head = lfs_tole32(ctz->head);
+    ctz->size = lfs_tole32(ctz->size);
+}
+#endif
+
+static inline void lfs_superblock_fromle32(lfs_superblock_t *superblock) {
+    superblock->version     = lfs_fromle32(superblock->version);
+    superblock->block_size  = lfs_fromle32(superblock->block_size);
+    superblock->block_count = lfs_fromle32(superblock->block_count);
+    superblock->name_max    = lfs_fromle32(superblock->name_max);
+    superblock->file_max    = lfs_fromle32(superblock->file_max);
+    superblock->attr_max    = lfs_fromle32(superblock->attr_max);
+}
+
+#ifndef LFS_READONLY
+static inline void lfs_superblock_tole32(lfs_superblock_t *superblock) {
+    superblock->version     = lfs_tole32(superblock->version);
+    superblock->block_size  = lfs_tole32(superblock->block_size);
+    superblock->block_count = lfs_tole32(superblock->block_count);
+    superblock->name_max    = lfs_tole32(superblock->name_max);
+    superblock->file_max    = lfs_tole32(superblock->file_max);
+    superblock->attr_max    = lfs_tole32(superblock->attr_max);
+}
+#endif
+
+#ifndef LFS_NO_ASSERT
+static bool lfs_mlist_isopen(struct lfs_mlist *head,
+        struct lfs_mlist *node) {
+    for (struct lfs_mlist **p = &head; *p; p = &(*p)->next) {
+        if (*p == (struct lfs_mlist*)node) {
+            return true;
+        }
+    }
+
+    return false;
+}
+#endif
+
+static void lfs_mlist_remove(lfs_t *lfs, struct lfs_mlist *mlist) {
+    for (struct lfs_mlist **p = &lfs->mlist; *p; p = &(*p)->next) {
+        if (*p == mlist) {
+            *p = (*p)->next;
+            break;
+        }
+    }
+}
+
+static void lfs_mlist_append(lfs_t *lfs, struct lfs_mlist *mlist) {
+    mlist->next = lfs->mlist;
+    lfs->mlist = mlist;
+}
+
+// some other filesystem operations
+static uint32_t lfs_fs_disk_version(lfs_t *lfs) {
+    (void)lfs;
+#ifdef LFS_MULTIVERSION
+    if (lfs->cfg->disk_version) {
+        return lfs->cfg->disk_version;
+    } else
+#endif
+    {
+        return LFS_DISK_VERSION;
+    }
+}
+
+static uint16_t lfs_fs_disk_version_major(lfs_t *lfs) {
+    return 0xffff & (lfs_fs_disk_version(lfs) >> 16);
+
+}
+
+static uint16_t lfs_fs_disk_version_minor(lfs_t *lfs) {
+    return 0xffff & (lfs_fs_disk_version(lfs) >> 0);
+}
+
+
+/// Internal operations predeclared here ///
+#ifndef LFS_READONLY
+static int lfs_dir_commit(lfs_t *lfs, lfs_mdir_t *dir,
+        const struct lfs_mattr *attrs, int attrcount);
+static int lfs_dir_compact(lfs_t *lfs,
+        lfs_mdir_t *dir, const struct lfs_mattr *attrs, int attrcount,
+        lfs_mdir_t *source, uint16_t begin, uint16_t end);
+static lfs_ssize_t lfs_file_flushedwrite(lfs_t *lfs, lfs_file_t *file,
+        const void *buffer, lfs_size_t size);
+static lfs_ssize_t lfs_file_write_(lfs_t *lfs, lfs_file_t *file,
+        const void *buffer, lfs_size_t size);
+static int lfs_file_sync_(lfs_t *lfs, lfs_file_t *file);
+static int lfs_file_outline(lfs_t *lfs, lfs_file_t *file);
+static int lfs_file_flush(lfs_t *lfs, lfs_file_t *file);
+
+static int lfs_fs_deorphan(lfs_t *lfs, bool powerloss);
+static int lfs_fs_preporphans(lfs_t *lfs, int8_t orphans);
+static void lfs_fs_prepmove(lfs_t *lfs,
+        uint16_t id, const lfs_block_t pair[2]);
+static int lfs_fs_pred(lfs_t *lfs, const lfs_block_t dir[2],
+        lfs_mdir_t *pdir);
+static lfs_stag_t lfs_fs_parent(lfs_t *lfs, const lfs_block_t dir[2],
+        lfs_mdir_t *parent);
+static int lfs_fs_forceconsistency(lfs_t *lfs);
+#endif
+
+static void lfs_fs_prepsuperblock(lfs_t *lfs, bool needssuperblock);
+
+#ifdef LFS_MIGRATE
+static int lfs1_traverse(lfs_t *lfs,
+        int (*cb)(void*, lfs_block_t), void *data);
+#endif
+
+static int lfs_dir_rewind_(lfs_t *lfs, lfs_dir_t *dir);
+
+static lfs_ssize_t lfs_file_flushedread(lfs_t *lfs, lfs_file_t *file,
+        void *buffer, lfs_size_t size);
+static lfs_ssize_t lfs_file_read_(lfs_t *lfs, lfs_file_t *file,
+        void *buffer, lfs_size_t size);
+static int lfs_file_close_(lfs_t *lfs, lfs_file_t *file);
+static lfs_soff_t lfs_file_size_(lfs_t *lfs, lfs_file_t *file);
+
+static lfs_ssize_t lfs_fs_size_(lfs_t *lfs);
+static int lfs_fs_traverse_(lfs_t *lfs,
+        int (*cb)(void *data, lfs_block_t block), void *data,
+        bool includeorphans);
+
+static int lfs_deinit(lfs_t *lfs);
+static int lfs_unmount_(lfs_t *lfs);
+
+
+/// Block allocator ///
+
+// allocations should call this when all allocated blocks are committed to
+// the filesystem
+//
+// after a checkpoint, the block allocator may realloc any untracked blocks
+static void lfs_alloc_ckpoint(lfs_t *lfs) {
+    lfs->lookahead.ckpoint = lfs->block_count;
+}
+
+// drop the lookahead buffer, this is done during mounting and failed
+// traversals in order to avoid invalid lookahead state
+static void lfs_alloc_drop(lfs_t *lfs) {
+    lfs->lookahead.size = 0;
+    lfs->lookahead.next = 0;
+    lfs_alloc_ckpoint(lfs);
+}
+
+#ifndef LFS_READONLY
+static int lfs_alloc_lookahead(void *p, lfs_block_t block) {
+    lfs_t *lfs = (lfs_t*)p;
+    lfs_block_t off = ((block - lfs->lookahead.start)
+            + lfs->block_count) % lfs->block_count;
+
+    if (off < lfs->lookahead.size) {
+        lfs->lookahead.buffer[off / 8] |= 1U << (off % 8);
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_alloc_scan(lfs_t *lfs) {
+    // move lookahead buffer to the first unused block
+    //
+    // note we limit the lookahead buffer to at most the amount of blocks
+    // checkpointed, this prevents the math in lfs_alloc from underflowing
+    lfs->lookahead.start = (lfs->lookahead.start + lfs->lookahead.next) 
+            % lfs->block_count;
+    lfs->lookahead.next = 0;
+    lfs->lookahead.size = lfs_min(
+            8*lfs->cfg->lookahead_size,
+            lfs->lookahead.ckpoint);
+
+    // find mask of free blocks from tree
+    memset(lfs->lookahead.buffer, 0, lfs->cfg->lookahead_size);
+    int err = lfs_fs_traverse_(lfs, lfs_alloc_lookahead, lfs, true);
+    if (err) {
+        lfs_alloc_drop(lfs);
+        return err;
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
+    while (true) {
+        // scan our lookahead buffer for free blocks
+        while (lfs->lookahead.next < lfs->lookahead.size) {
+            if (!(lfs->lookahead.buffer[lfs->lookahead.next / 8]
+                    & (1U << (lfs->lookahead.next % 8)))) {
+                // found a free block
+                *block = (lfs->lookahead.start + lfs->lookahead.next)
+                        % lfs->block_count;
+
+                // eagerly find next free block to maximize how many blocks
+                // lfs_alloc_ckpoint makes available for scanning
+                while (true) {
+                    lfs->lookahead.next += 1;
+                    lfs->lookahead.ckpoint -= 1;
+
+                    if (lfs->lookahead.next >= lfs->lookahead.size
+                            || !(lfs->lookahead.buffer[lfs->lookahead.next / 8]
+                                & (1U << (lfs->lookahead.next % 8)))) {
+                        return 0;
+                    }
+                }
+            }
+
+            lfs->lookahead.next += 1;
+            lfs->lookahead.ckpoint -= 1;
+        }
+
+        // In order to keep our block allocator from spinning forever when our
+        // filesystem is full, we mark points where there are no in-flight
+        // allocations with a checkpoint before starting a set of allocations.
+        //
+        // If we've looked at all blocks since the last checkpoint, we report
+        // the filesystem as out of storage.
+        //
+        if (lfs->lookahead.ckpoint <= 0) {
+            LFS_ERROR("No more free space 0x%"PRIx32,
+                    (lfs->lookahead.start + lfs->lookahead.next)
+                        % lfs->block_count);
+            return LFS_ERR_NOSPC;
+        }
+
+        // No blocks in our lookahead buffer, we need to scan the filesystem for
+        // unused blocks in the next lookahead window.
+        int err = lfs_alloc_scan(lfs);
+        if(err) {
+            return err;
+        }
+    }
+}
+#endif
+
+/// Metadata pair and directory operations ///
+static lfs_stag_t lfs_dir_getslice(lfs_t *lfs, const lfs_mdir_t *dir,
+        lfs_tag_t gmask, lfs_tag_t gtag,
+        lfs_off_t goff, void *gbuffer, lfs_size_t gsize) {
+    lfs_off_t off = dir->off;
+    lfs_tag_t ntag = dir->etag;
+    lfs_stag_t gdiff = 0;
+
+    // synthetic moves
+    if (lfs_gstate_hasmovehere(&lfs->gdisk, dir->pair) &&
+            lfs_tag_id(gmask) != 0) {
+        if (lfs_tag_id(lfs->gdisk.tag) == lfs_tag_id(gtag)) {
+            return LFS_ERR_NOENT;
+        } else if (lfs_tag_id(lfs->gdisk.tag) < lfs_tag_id(gtag)) {
+            gdiff -= LFS_MKTAG(0, 1, 0);
+        }
+    }
+
+    // iterate over dir block backwards (for faster lookups)
+    while (off >= sizeof(lfs_tag_t) + lfs_tag_dsize(ntag)) {
+        off -= lfs_tag_dsize(ntag);
+        lfs_tag_t tag = ntag;
+        int err = lfs_bd_read(lfs,
+                NULL, &lfs->rcache, sizeof(ntag),
+                dir->pair[0], off, &ntag, sizeof(ntag));
+        LFS_ASSERT(err <= 0);
+        if (err) {
+            return err;
+        }
+
+        ntag = (lfs_frombe32(ntag) ^ tag) & 0x7fffffff;
+
+        if (lfs_tag_id(gmask) != 0 &&
+                lfs_tag_type1(tag) == LFS_TYPE_SPLICE &&
+                lfs_tag_id(tag) <= lfs_tag_id(gtag - gdiff)) {
+            if (tag == (LFS_MKTAG(LFS_TYPE_CREATE, 0, 0) |
+                    (LFS_MKTAG(0, 0x3ff, 0) & (gtag - gdiff)))) {
+                // found where we were created
+                return LFS_ERR_NOENT;
+            }
+
+            // move around splices
+            gdiff += LFS_MKTAG(0, lfs_tag_splice(tag), 0);
+        }
+
+        if ((gmask & tag) == (gmask & (gtag - gdiff))) {
+            if (lfs_tag_isdelete(tag)) {
+                return LFS_ERR_NOENT;
+            }
+
+            lfs_size_t diff = lfs_min(lfs_tag_size(tag), gsize);
+            err = lfs_bd_read(lfs,
+                    NULL, &lfs->rcache, diff,
+                    dir->pair[0], off+sizeof(tag)+goff, gbuffer, diff);
+            LFS_ASSERT(err <= 0);
+            if (err) {
+                return err;
+            }
+
+            memset((uint8_t*)gbuffer + diff, 0, gsize - diff);
+
+            return tag + gdiff;
+        }
+    }
+
+    return LFS_ERR_NOENT;
+}
+
+static lfs_stag_t lfs_dir_get(lfs_t *lfs, const lfs_mdir_t *dir,
+        lfs_tag_t gmask, lfs_tag_t gtag, void *buffer) {
+    return lfs_dir_getslice(lfs, dir,
+            gmask, gtag,
+            0, buffer, lfs_tag_size(gtag));
+}
+
+static int lfs_dir_getread(lfs_t *lfs, const lfs_mdir_t *dir,
+        const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
+        lfs_tag_t gmask, lfs_tag_t gtag,
+        lfs_off_t off, void *buffer, lfs_size_t size) {
+    uint8_t *data = buffer;
+    if (off+size > lfs->cfg->block_size) {
+        return LFS_ERR_CORRUPT;
+    }
+
+    while (size > 0) {
+        lfs_size_t diff = size;
+
+        if (pcache && pcache->block == LFS_BLOCK_INLINE &&
+                off < pcache->off + pcache->size) {
+            if (off >= pcache->off) {
+                // is already in pcache?
+                diff = lfs_min(diff, pcache->size - (off-pcache->off));
+                memcpy(data, &pcache->buffer[off-pcache->off], diff);
+
+                data += diff;
+                off += diff;
+                size -= diff;
+                continue;
+            }
+
+            // pcache takes priority
+            diff = lfs_min(diff, pcache->off-off);
+        }
+
+        if (rcache->block == LFS_BLOCK_INLINE &&
+                off < rcache->off + rcache->size) {
+            if (off >= rcache->off) {
+                // is already in rcache?
+                diff = lfs_min(diff, rcache->size - (off-rcache->off));
+                memcpy(data, &rcache->buffer[off-rcache->off], diff);
+
+                data += diff;
+                off += diff;
+                size -= diff;
+                continue;
+            }
+        }
+
+        // load to cache, first condition can no longer fail
+        rcache->block = LFS_BLOCK_INLINE;
+        rcache->off = lfs_aligndown(off, lfs->cfg->read_size);
+        rcache->size = lfs_min(lfs_alignup(off+hint, lfs->cfg->read_size),
+                lfs->cfg->cache_size);
+        int err = lfs_dir_getslice(lfs, dir, gmask, gtag,
+                rcache->off, rcache->buffer, rcache->size);
+        if (err < 0) {
+            return err;
+        }
+    }
+
+    return 0;
+}
+
+#ifndef LFS_READONLY
+static int lfs_dir_traverse_filter(void *p,
+        lfs_tag_t tag, const void *buffer) {
+    lfs_tag_t *filtertag = p;
+    (void)buffer;
+
+    // which mask depends on unique bit in tag structure
+    uint32_t mask = (tag & LFS_MKTAG(0x100, 0, 0))
+            ? LFS_MKTAG(0x7ff, 0x3ff, 0)
+            : LFS_MKTAG(0x700, 0x3ff, 0);
+
+    // check for redundancy
+    if ((mask & tag) == (mask & *filtertag) ||
+            lfs_tag_isdelete(*filtertag) ||
+            (LFS_MKTAG(0x7ff, 0x3ff, 0) & tag) == (
+                LFS_MKTAG(LFS_TYPE_DELETE, 0, 0) |
+                    (LFS_MKTAG(0, 0x3ff, 0) & *filtertag))) {
+        *filtertag = LFS_MKTAG(LFS_FROM_NOOP, 0, 0);
+        return true;
+    }
+
+    // check if we need to adjust for created/deleted tags
+    if (lfs_tag_type1(tag) == LFS_TYPE_SPLICE &&
+            lfs_tag_id(tag) <= lfs_tag_id(*filtertag)) {
+        *filtertag += LFS_MKTAG(0, lfs_tag_splice(tag), 0);
+    }
+
+    return false;
+}
+#endif
+
+#ifndef LFS_READONLY
+// maximum recursive depth of lfs_dir_traverse, the deepest call:
+//
+// traverse with commit
+// '-> traverse with move
+//     '-> traverse with filter
+//
+#define LFS_DIR_TRAVERSE_DEPTH 3
+
+struct lfs_dir_traverse {
+    const lfs_mdir_t *dir;
+    lfs_off_t off;
+    lfs_tag_t ptag;
+    const struct lfs_mattr *attrs;
+    int attrcount;
+
+    lfs_tag_t tmask;
+    lfs_tag_t ttag;
+    uint16_t begin;
+    uint16_t end;
+    int16_t diff;
+
+    int (*cb)(void *data, lfs_tag_t tag, const void *buffer);
+    void *data;
+
+    lfs_tag_t tag;
+    const void *buffer;
+    struct lfs_diskoff disk;
+};
+
+static int lfs_dir_traverse(lfs_t *lfs,
+        const lfs_mdir_t *dir, lfs_off_t off, lfs_tag_t ptag,
+        const struct lfs_mattr *attrs, int attrcount,
+        lfs_tag_t tmask, lfs_tag_t ttag,
+        uint16_t begin, uint16_t end, int16_t diff,
+        int (*cb)(void *data, lfs_tag_t tag, const void *buffer), void *data) {
+    // This function in inherently recursive, but bounded. To allow tool-based
+    // analysis without unnecessary code-cost we use an explicit stack
+    struct lfs_dir_traverse stack[LFS_DIR_TRAVERSE_DEPTH-1];
+    unsigned sp = 0;
+    int res;
+
+    // iterate over directory and attrs
+    lfs_tag_t tag;
+    const void *buffer;
+    struct lfs_diskoff disk = {0};
+    while (true) {
+        {
+            if (off+lfs_tag_dsize(ptag) < dir->off) {
+                off += lfs_tag_dsize(ptag);
+                int err = lfs_bd_read(lfs,
+                        NULL, &lfs->rcache, sizeof(tag),
+                        dir->pair[0], off, &tag, sizeof(tag));
+                if (err) {
+                    return err;
+                }
+
+                tag = (lfs_frombe32(tag) ^ ptag) | 0x80000000;
+                disk.block = dir->pair[0];
+                disk.off = off+sizeof(lfs_tag_t);
+                buffer = &disk;
+                ptag = tag;
+            } else if (attrcount > 0) {
+                tag = attrs[0].tag;
+                buffer = attrs[0].buffer;
+                attrs += 1;
+                attrcount -= 1;
+            } else {
+                // finished traversal, pop from stack?
+                res = 0;
+                break;
+            }
+
+            // do we need to filter?
+            lfs_tag_t mask = LFS_MKTAG(0x7ff, 0, 0);
+            if ((mask & tmask & tag) != (mask & tmask & ttag)) {
+                continue;
+            }
+
+            if (lfs_tag_id(tmask) != 0) {
+                LFS_ASSERT(sp < LFS_DIR_TRAVERSE_DEPTH);
+                // recurse, scan for duplicates, and update tag based on
+                // creates/deletes
+                stack[sp] = (struct lfs_dir_traverse){
+                    .dir        = dir,
+                    .off        = off,
+                    .ptag       = ptag,
+                    .attrs      = attrs,
+                    .attrcount  = attrcount,
+                    .tmask      = tmask,
+                    .ttag       = ttag,
+                    .begin      = begin,
+                    .end        = end,
+                    .diff       = diff,
+                    .cb         = cb,
+                    .data       = data,
+                    .tag        = tag,
+                    .buffer     = buffer,
+                    .disk       = disk,
+                };
+                sp += 1;
+
+                tmask = 0;
+                ttag = 0;
+                begin = 0;
+                end = 0;
+                diff = 0;
+                cb = lfs_dir_traverse_filter;
+                data = &stack[sp-1].tag;
+                continue;
+            }
+        }
+
+popped:
+        // in filter range?
+        if (lfs_tag_id(tmask) != 0 &&
+                !(lfs_tag_id(tag) >= begin && lfs_tag_id(tag) < end)) {
+            continue;
+        }
+
+        // handle special cases for mcu-side operations
+        if (lfs_tag_type3(tag) == LFS_FROM_NOOP) {
+            // do nothing
+        } else if (lfs_tag_type3(tag) == LFS_FROM_MOVE) {
+            // Without this condition, lfs_dir_traverse can exhibit an
+            // extremely expensive O(n^3) of nested loops when renaming.
+            // This happens because lfs_dir_traverse tries to filter tags by
+            // the tags in the source directory, triggering a second
+            // lfs_dir_traverse with its own filter operation.
+            //
+            // traverse with commit
+            // '-> traverse with filter
+            //     '-> traverse with move
+            //         '-> traverse with filter
+            //
+            // However we don't actually care about filtering the second set of
+            // tags, since duplicate tags have no effect when filtering.
+            //
+            // This check skips this unnecessary recursive filtering explicitly,
+            // reducing this runtime from O(n^3) to O(n^2).
+            if (cb == lfs_dir_traverse_filter) {
+                continue;
+            }
+
+            // recurse into move
+            stack[sp] = (struct lfs_dir_traverse){
+                .dir        = dir,
+                .off        = off,
+                .ptag       = ptag,
+                .attrs      = attrs,
+                .attrcount  = attrcount,
+                .tmask      = tmask,
+                .ttag       = ttag,
+                .begin      = begin,
+                .end        = end,
+                .diff       = diff,
+                .cb         = cb,
+                .data       = data,
+                .tag        = LFS_MKTAG(LFS_FROM_NOOP, 0, 0),
+            };
+            sp += 1;
+
+            uint16_t fromid = lfs_tag_size(tag);
+            uint16_t toid = lfs_tag_id(tag);
+            dir = buffer;
+            off = 0;
+            ptag = 0xffffffff;
+            attrs = NULL;
+            attrcount = 0;
+            tmask = LFS_MKTAG(0x600, 0x3ff, 0);
+            ttag = LFS_MKTAG(LFS_TYPE_STRUCT, 0, 0);
+            begin = fromid;
+            end = fromid+1;
+            diff = toid-fromid+diff;
+        } else if (lfs_tag_type3(tag) == LFS_FROM_USERATTRS) {
+            for (unsigned i = 0; i < lfs_tag_size(tag); i++) {
+                const struct lfs_attr *a = buffer;
+                res = cb(data, LFS_MKTAG(LFS_TYPE_USERATTR + a[i].type,
+                        lfs_tag_id(tag) + diff, a[i].size), a[i].buffer);
+                if (res < 0) {
+                    return res;
+                }
+
+                if (res) {
+                    break;
+                }
+            }
+        } else {
+            res = cb(data, tag + LFS_MKTAG(0, diff, 0), buffer);
+            if (res < 0) {
+                return res;
+            }
+
+            if (res) {
+                break;
+            }
+        }
+    }
+
+    if (sp > 0) {
+        // pop from the stack and return, fortunately all pops share
+        // a destination
+        dir         = stack[sp-1].dir;
+        off         = stack[sp-1].off;
+        ptag        = stack[sp-1].ptag;
+        attrs       = stack[sp-1].attrs;
+        attrcount   = stack[sp-1].attrcount;
+        tmask       = stack[sp-1].tmask;
+        ttag        = stack[sp-1].ttag;
+        begin       = stack[sp-1].begin;
+        end         = stack[sp-1].end;
+        diff        = stack[sp-1].diff;
+        cb          = stack[sp-1].cb;
+        data        = stack[sp-1].data;
+        tag         = stack[sp-1].tag;
+        buffer      = stack[sp-1].buffer;
+        disk        = stack[sp-1].disk;
+        sp -= 1;
+        goto popped;
+    } else {
+        return res;
+    }
+}
+#endif
+
+static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs,
+        lfs_mdir_t *dir, const lfs_block_t pair[2],
+        lfs_tag_t fmask, lfs_tag_t ftag, uint16_t *id,
+        int (*cb)(void *data, lfs_tag_t tag, const void *buffer), void *data) {
+    // we can find tag very efficiently during a fetch, since we're already
+    // scanning the entire directory
+    lfs_stag_t besttag = -1;
+
+    // if either block address is invalid we return LFS_ERR_CORRUPT here,
+    // otherwise later writes to the pair could fail
+    if (lfs->block_count 
+            && (pair[0] >= lfs->block_count || pair[1] >= lfs->block_count)) {
+        return LFS_ERR_CORRUPT;
+    }
+
+    // find the block with the most recent revision
+    uint32_t revs[2] = {0, 0};
+    int r = 0;
+    for (int i = 0; i < 2; i++) {
+        int err = lfs_bd_read(lfs,
+                NULL, &lfs->rcache, sizeof(revs[i]),
+                pair[i], 0, &revs[i], sizeof(revs[i]));
+        revs[i] = lfs_fromle32(revs[i]);
+        if (err && err != LFS_ERR_CORRUPT) {
+            return err;
+        }
+
+        if (err != LFS_ERR_CORRUPT &&
+                lfs_scmp(revs[i], revs[(i+1)%2]) > 0) {
+            r = i;
+        }
+    }
+
+    dir->pair[0] = pair[(r+0)%2];
+    dir->pair[1] = pair[(r+1)%2];
+    dir->rev = revs[(r+0)%2];
+    dir->off = 0; // nonzero = found some commits
+
+    // now scan tags to fetch the actual dir and find possible match
+    for (int i = 0; i < 2; i++) {
+        lfs_off_t off = 0;
+        lfs_tag_t ptag = 0xffffffff;
+
+        uint16_t tempcount = 0;
+        lfs_block_t temptail[2] = {LFS_BLOCK_NULL, LFS_BLOCK_NULL};
+        bool tempsplit = false;
+        lfs_stag_t tempbesttag = besttag;
+
+        // assume not erased until proven otherwise
+        bool maybeerased = false;
+        bool hasfcrc = false;
+        struct lfs_fcrc fcrc;
+
+        dir->rev = lfs_tole32(dir->rev);
+        uint32_t crc = lfs_crc(0xffffffff, &dir->rev, sizeof(dir->rev));
+        dir->rev = lfs_fromle32(dir->rev);
+
+        while (true) {
+            // extract next tag
+            lfs_tag_t tag;
+            off += lfs_tag_dsize(ptag);
+            int err = lfs_bd_read(lfs,
+                    NULL, &lfs->rcache, lfs->cfg->block_size,
+                    dir->pair[0], off, &tag, sizeof(tag));
+            if (err) {
+                if (err == LFS_ERR_CORRUPT) {
+                    // can't continue?
+                    break;
+                }
+                return err;
+            }
+
+            crc = lfs_crc(crc, &tag, sizeof(tag));
+            tag = lfs_frombe32(tag) ^ ptag;
+
+            // next commit not yet programmed?
+            if (!lfs_tag_isvalid(tag)) {
+                // we only might be erased if the last tag was a crc
+                maybeerased = (lfs_tag_type2(ptag) == LFS_TYPE_CCRC);
+                break;
+            // out of range?
+            } else if (off + lfs_tag_dsize(tag) > lfs->cfg->block_size) {
+                break;
+            }
+
+            ptag = tag;
+
+            if (lfs_tag_type2(tag) == LFS_TYPE_CCRC) {
+                // check the crc attr
+                uint32_t dcrc;
+                err = lfs_bd_read(lfs,
+                        NULL, &lfs->rcache, lfs->cfg->block_size,
+                        dir->pair[0], off+sizeof(tag), &dcrc, sizeof(dcrc));
+                if (err) {
+                    if (err == LFS_ERR_CORRUPT) {
+                        break;
+                    }
+                    return err;
+                }
+                dcrc = lfs_fromle32(dcrc);
+
+                if (crc != dcrc) {
+                    break;
+                }
+
+                // reset the next bit if we need to
+                ptag ^= (lfs_tag_t)(lfs_tag_chunk(tag) & 1U) << 31;
+
+                // toss our crc into the filesystem seed for
+                // pseudorandom numbers, note we use another crc here
+                // as a collection function because it is sufficiently
+                // random and convenient
+                lfs->seed = lfs_crc(lfs->seed, &crc, sizeof(crc));
+
+                // update with what's found so far
+                besttag = tempbesttag;
+                dir->off = off + lfs_tag_dsize(tag);
+                dir->etag = ptag;
+                dir->count = tempcount;
+                dir->tail[0] = temptail[0];
+                dir->tail[1] = temptail[1];
+                dir->split = tempsplit;
+
+                // reset crc, hasfcrc
+                crc = 0xffffffff;
+                continue;
+            }
+
+            // crc the entry first, hopefully leaving it in the cache
+            err = lfs_bd_crc(lfs,
+                    NULL, &lfs->rcache, lfs->cfg->block_size,
+                    dir->pair[0], off+sizeof(tag),
+                    lfs_tag_dsize(tag)-sizeof(tag), &crc);
+            if (err) {
+                if (err == LFS_ERR_CORRUPT) {
+                    break;
+                }
+                return err;
+            }
+
+            // directory modification tags?
+            if (lfs_tag_type1(tag) == LFS_TYPE_NAME) {
+                // increase count of files if necessary
+                if (lfs_tag_id(tag) >= tempcount) {
+                    tempcount = lfs_tag_id(tag) + 1;
+                }
+            } else if (lfs_tag_type1(tag) == LFS_TYPE_SPLICE) {
+                tempcount += lfs_tag_splice(tag);
+
+                if (tag == (LFS_MKTAG(LFS_TYPE_DELETE, 0, 0) |
+                        (LFS_MKTAG(0, 0x3ff, 0) & tempbesttag))) {
+                    tempbesttag |= 0x80000000;
+                } else if (tempbesttag != -1 &&
+                        lfs_tag_id(tag) <= lfs_tag_id(tempbesttag)) {
+                    tempbesttag += LFS_MKTAG(0, lfs_tag_splice(tag), 0);
+                }
+            } else if (lfs_tag_type1(tag) == LFS_TYPE_TAIL) {
+                tempsplit = (lfs_tag_chunk(tag) & 1);
+
+                err = lfs_bd_read(lfs,
+                        NULL, &lfs->rcache, lfs->cfg->block_size,
+                        dir->pair[0], off+sizeof(tag), &temptail, 8);
+                if (err) {
+                    if (err == LFS_ERR_CORRUPT) {
+                        break;
+                    }
+                    return err;
+                }
+                lfs_pair_fromle32(temptail);
+            } else if (lfs_tag_type3(tag) == LFS_TYPE_FCRC) {
+                err = lfs_bd_read(lfs,
+                        NULL, &lfs->rcache, lfs->cfg->block_size,
+                        dir->pair[0], off+sizeof(tag),
+                        &fcrc, sizeof(fcrc));
+                if (err) {
+                    if (err == LFS_ERR_CORRUPT) {
+                        break;
+                    }
+                    return err;
+                }
+
+                lfs_fcrc_fromle32(&fcrc);
+                hasfcrc = true;
+            }
+
+            // found a match for our fetcher?
+            if ((fmask & tag) == (fmask & ftag)) {
+                LFS_ASSERT(cb != NULL);
+                int res = cb(data, tag, &(struct lfs_diskoff){
+                        dir->pair[0], off+sizeof(tag)});
+                if (res < 0) {
+                    if (res == LFS_ERR_CORRUPT) {
+                        break;
+                    }
+                    return res;
+                }
+
+                if (res == LFS_CMP_EQ) {
+                    // found a match
+                    tempbesttag = tag;
+                } else if ((LFS_MKTAG(0x7ff, 0x3ff, 0) & tag) ==
+                        (LFS_MKTAG(0x7ff, 0x3ff, 0) & tempbesttag)) {
+                    // found an identical tag, but contents didn't match
+                    // this must mean that our besttag has been overwritten
+                    tempbesttag = -1;
+                } else if (res == LFS_CMP_GT &&
+                        lfs_tag_id(tag) <= lfs_tag_id(tempbesttag)) {
+                    // found a greater match, keep track to keep things sorted
+                    tempbesttag = tag | 0x80000000;
+                }
+            }
+        }
+
+        // found no valid commits?
+        if (dir->off == 0) {
+            // try the other block?
+            lfs_pair_swap(dir->pair);
+            dir->rev = revs[(r+1)%2];
+            continue;
+        }
+
+        // did we end on a valid commit? we may have an erased block
+        dir->erased = false;
+        if (maybeerased && dir->off % lfs->cfg->prog_size == 0) {
+        #ifdef LFS_MULTIVERSION
+            // note versions < lfs2.1 did not have fcrc tags, if
+            // we're < lfs2.1 treat missing fcrc as erased data
+            //
+            // we don't strictly need to do this, but otherwise writing
+            // to lfs2.0 disks becomes very inefficient
+            if (lfs_fs_disk_version(lfs) < 0x00020001) {
+                dir->erased = true;
+
+            } else
+        #endif
+            if (hasfcrc) {
+                // check for an fcrc matching the next prog's erased state, if
+                // this failed most likely a previous prog was interrupted, we
+                // need a new erase
+                uint32_t fcrc_ = 0xffffffff;
+                int err = lfs_bd_crc(lfs,
+                        NULL, &lfs->rcache, lfs->cfg->block_size,
+                        dir->pair[0], dir->off, fcrc.size, &fcrc_);
+                if (err && err != LFS_ERR_CORRUPT) {
+                    return err;
+                }
+
+                // found beginning of erased part?
+                dir->erased = (fcrc_ == fcrc.crc);
+            }
+        }
+
+        // synthetic move
+        if (lfs_gstate_hasmovehere(&lfs->gdisk, dir->pair)) {
+            if (lfs_tag_id(lfs->gdisk.tag) == lfs_tag_id(besttag)) {
+                besttag |= 0x80000000;
+            } else if (besttag != -1 &&
+                    lfs_tag_id(lfs->gdisk.tag) < lfs_tag_id(besttag)) {
+                besttag -= LFS_MKTAG(0, 1, 0);
+            }
+        }
+
+        // found tag? or found best id?
+        if (id) {
+            *id = lfs_min(lfs_tag_id(besttag), dir->count);
+        }
+
+        if (lfs_tag_isvalid(besttag)) {
+            return besttag;
+        } else if (lfs_tag_id(besttag) < dir->count) {
+            return LFS_ERR_NOENT;
+        } else {
+            return 0;
+        }
+    }
+
+    LFS_ERROR("Corrupted dir pair at {0x%"PRIx32", 0x%"PRIx32"}",
+            dir->pair[0], dir->pair[1]);
+    return LFS_ERR_CORRUPT;
+}
+
+static int lfs_dir_fetch(lfs_t *lfs,
+        lfs_mdir_t *dir, const lfs_block_t pair[2]) {
+    // note, mask=-1, tag=-1 can never match a tag since this
+    // pattern has the invalid bit set
+    return (int)lfs_dir_fetchmatch(lfs, dir, pair,
+            (lfs_tag_t)-1, (lfs_tag_t)-1, NULL, NULL, NULL);
+}
+
+static int lfs_dir_getgstate(lfs_t *lfs, const lfs_mdir_t *dir,
+        lfs_gstate_t *gstate) {
+    lfs_gstate_t temp;
+    lfs_stag_t res = lfs_dir_get(lfs, dir, LFS_MKTAG(0x7ff, 0, 0),
+            LFS_MKTAG(LFS_TYPE_MOVESTATE, 0, sizeof(temp)), &temp);
+    if (res < 0 && res != LFS_ERR_NOENT) {
+        return res;
+    }
+
+    if (res != LFS_ERR_NOENT) {
+        // xor together to find resulting gstate
+        lfs_gstate_fromle32(&temp);
+        lfs_gstate_xor(gstate, &temp);
+    }
+
+    return 0;
+}
+
+static int lfs_dir_getinfo(lfs_t *lfs, lfs_mdir_t *dir,
+        uint16_t id, struct lfs_info *info) {
+    if (id == 0x3ff) {
+        // special case for root
+        strcpy(info->name, "/");
+        info->type = LFS_TYPE_DIR;
+        return 0;
+    }
+
+    lfs_stag_t tag = lfs_dir_get(lfs, dir, LFS_MKTAG(0x780, 0x3ff, 0),
+            LFS_MKTAG(LFS_TYPE_NAME, id, lfs->name_max+1), info->name);
+    if (tag < 0) {
+        return (int)tag;
+    }
+
+    info->type = lfs_tag_type3(tag);
+
+    struct lfs_ctz ctz;
+    tag = lfs_dir_get(lfs, dir, LFS_MKTAG(0x700, 0x3ff, 0),
+            LFS_MKTAG(LFS_TYPE_STRUCT, id, sizeof(ctz)), &ctz);
+    if (tag < 0) {
+        return (int)tag;
+    }
+    lfs_ctz_fromle32(&ctz);
+
+    if (lfs_tag_type3(tag) == LFS_TYPE_CTZSTRUCT) {
+        info->size = ctz.size;
+    } else if (lfs_tag_type3(tag) == LFS_TYPE_INLINESTRUCT) {
+        info->size = lfs_tag_size(tag);
+    }
+
+    return 0;
+}
+
+struct lfs_dir_find_match {
+    lfs_t *lfs;
+    const void *name;
+    lfs_size_t size;
+};
+
+static int lfs_dir_find_match(void *data,
+        lfs_tag_t tag, const void *buffer) {
+    struct lfs_dir_find_match *name = data;
+    lfs_t *lfs = name->lfs;
+    const struct lfs_diskoff *disk = buffer;
+
+    // compare with disk
+    lfs_size_t diff = lfs_min(name->size, lfs_tag_size(tag));
+    int res = lfs_bd_cmp(lfs,
+            NULL, &lfs->rcache, diff,
+            disk->block, disk->off, name->name, diff);
+    if (res != LFS_CMP_EQ) {
+        return res;
+    }
+
+    // only equal if our size is still the same
+    if (name->size != lfs_tag_size(tag)) {
+        return (name->size < lfs_tag_size(tag)) ? LFS_CMP_LT : LFS_CMP_GT;
+    }
+
+    // found a match!
+    return LFS_CMP_EQ;
+}
+
+// lfs_dir_find tries to set path and id even if file is not found
+//
+// returns:
+// - 0                  if file is found
+// - LFS_ERR_NOENT      if file or parent is not found
+// - LFS_ERR_NOTDIR     if parent is not a dir
+static lfs_stag_t lfs_dir_find(lfs_t *lfs, lfs_mdir_t *dir,
+        const char **path, uint16_t *id) {
+    // we reduce path to a single name if we can find it
+    const char *name = *path;
+
+    // default to root dir
+    lfs_stag_t tag = LFS_MKTAG(LFS_TYPE_DIR, 0x3ff, 0);
+    dir->tail[0] = lfs->root[0];
+    dir->tail[1] = lfs->root[1];
+
+    // empty paths are not allowed
+    if (*name == '\0') {
+        return LFS_ERR_INVAL;
+    }
+
+    while (true) {
+nextname:
+        // skip slashes if we're a directory
+        if (lfs_tag_type3(tag) == LFS_TYPE_DIR) {
+            name += strspn(name, "/");
+        }
+        lfs_size_t namelen = (lfs_size_t)strcspn(name, "/");
+
+        // skip '.'
+        if (namelen == 1 && memcmp(name, ".", 1) == 0) {
+            name += namelen;
+            goto nextname;
+        }
+
+        // error on unmatched '..', trying to go above root?
+        if (namelen == 2 && memcmp(name, "..", 2) == 0) {
+            return LFS_ERR_INVAL;
+        }
+
+        // skip if matched by '..' in name
+        const char *suffix = name + namelen;
+        lfs_size_t sufflen;
+        int depth = 1;
+        while (true) {
+            suffix += strspn(suffix, "/");
+            sufflen = (lfs_size_t)strcspn(suffix, "/");
+            if (sufflen == 0) {
+                break;
+            }
+
+            if (sufflen == 1 && memcmp(suffix, ".", 1) == 0) {
+                // noop
+            } else if (sufflen == 2 && memcmp(suffix, "..", 2) == 0) {
+                depth -= 1;
+                if (depth == 0) {
+                    name = suffix + sufflen;
+                    goto nextname;
+                }
+            } else {
+                depth += 1;
+            }
+
+            suffix += sufflen;
+        }
+
+        // found path
+        if (*name == '\0') {
+            return tag;
+        }
+
+        // update what we've found so far
+        *path = name;
+
+        // only continue if we're a directory
+        if (lfs_tag_type3(tag) != LFS_TYPE_DIR) {
+            return LFS_ERR_NOTDIR;
+        }
+
+        // grab the entry data
+        if (lfs_tag_id(tag) != 0x3ff) {
+            lfs_stag_t res = lfs_dir_get(lfs, dir, LFS_MKTAG(0x700, 0x3ff, 0),
+                    LFS_MKTAG(LFS_TYPE_STRUCT, lfs_tag_id(tag), 8), dir->tail);
+            if (res < 0) {
+                return res;
+            }
+            lfs_pair_fromle32(dir->tail);
+        }
+
+        // find entry matching name
+        while (true) {
+            tag = lfs_dir_fetchmatch(lfs, dir, dir->tail,
+                    LFS_MKTAG(0x780, 0, 0),
+                    LFS_MKTAG(LFS_TYPE_NAME, 0, namelen),
+                    id,
+                    lfs_dir_find_match, &(struct lfs_dir_find_match){
+                        lfs, name, namelen});
+            if (tag < 0) {
+                return tag;
+            }
+
+            if (tag) {
+                break;
+            }
+
+            if (!dir->split) {
+                return LFS_ERR_NOENT;
+            }
+        }
+
+        // to next name
+        name += namelen;
+    }
+}
+
+// commit logic
+struct lfs_commit {
+    lfs_block_t block;
+    lfs_off_t off;
+    lfs_tag_t ptag;
+    uint32_t crc;
+
+    lfs_off_t begin;
+    lfs_off_t end;
+};
+
+#ifndef LFS_READONLY
+static int lfs_dir_commitprog(lfs_t *lfs, struct lfs_commit *commit,
+        const void *buffer, lfs_size_t size) {
+    int err = lfs_bd_prog(lfs,
+            &lfs->pcache, &lfs->rcache, false,
+            commit->block, commit->off ,
+            (const uint8_t*)buffer, size);
+    if (err) {
+        return err;
+    }
+
+    commit->crc = lfs_crc(commit->crc, buffer, size);
+    commit->off += size;
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_commitattr(lfs_t *lfs, struct lfs_commit *commit,
+        lfs_tag_t tag, const void *buffer) {
+    // check if we fit
+    lfs_size_t dsize = lfs_tag_dsize(tag);
+    if (commit->off + dsize > commit->end) {
+        return LFS_ERR_NOSPC;
+    }
+
+    // write out tag
+    lfs_tag_t ntag = lfs_tobe32((tag & 0x7fffffff) ^ commit->ptag);
+    int err = lfs_dir_commitprog(lfs, commit, &ntag, sizeof(ntag));
+    if (err) {
+        return err;
+    }
+
+    if (!(tag & 0x80000000)) {
+        // from memory
+        err = lfs_dir_commitprog(lfs, commit, buffer, dsize-sizeof(tag));
+        if (err) {
+            return err;
+        }
+    } else {
+        // from disk
+        const struct lfs_diskoff *disk = buffer;
+        for (lfs_off_t i = 0; i < dsize-sizeof(tag); i++) {
+            // rely on caching to make this efficient
+            uint8_t dat;
+            err = lfs_bd_read(lfs,
+                    NULL, &lfs->rcache, dsize-sizeof(tag)-i,
+                    disk->block, disk->off+i, &dat, 1);
+            if (err) {
+                return err;
+            }
+
+            err = lfs_dir_commitprog(lfs, commit, &dat, 1);
+            if (err) {
+                return err;
+            }
+        }
+    }
+
+    commit->ptag = tag & 0x7fffffff;
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+
+static int lfs_dir_commitcrc(lfs_t *lfs, struct lfs_commit *commit) {
+    // align to program units
+    //
+    // this gets a bit complex as we have two types of crcs:
+    // - 5-word crc with fcrc to check following prog (middle of block)
+    // - 2-word crc with no following prog (end of block)
+    const lfs_off_t end = lfs_alignup(
+            lfs_min(commit->off + 5*sizeof(uint32_t), lfs->cfg->block_size),
+            lfs->cfg->prog_size);
+
+    lfs_off_t off1 = 0;
+    uint32_t crc1 = 0;
+
+    // create crc tags to fill up remainder of commit, note that
+    // padding is not crced, which lets fetches skip padding but
+    // makes committing a bit more complicated
+    while (commit->off < end) {
+        lfs_off_t noff = (
+                lfs_min(end - (commit->off+sizeof(lfs_tag_t)), 0x3fe)
+                + (commit->off+sizeof(lfs_tag_t)));
+        // too large for crc tag? need padding commits
+        if (noff < end) {
+            noff = lfs_min(noff, end - 5*sizeof(uint32_t));
+        }
+
+        // space for fcrc?
+        uint8_t eperturb = (uint8_t)-1;
+        if (noff >= end && noff <= lfs->cfg->block_size - lfs->cfg->prog_size) {
+            // first read the leading byte, this always contains a bit
+            // we can perturb to avoid writes that don't change the fcrc
+            int err = lfs_bd_read(lfs,
+                    NULL, &lfs->rcache, lfs->cfg->prog_size,
+                    commit->block, noff, &eperturb, 1);
+            if (err && err != LFS_ERR_CORRUPT) {
+                return err;
+            }
+
+        #ifdef LFS_MULTIVERSION
+            // unfortunately fcrcs break mdir fetching < lfs2.1, so only write
+            // these if we're a >= lfs2.1 filesystem
+            if (lfs_fs_disk_version(lfs) <= 0x00020000) {
+                // don't write fcrc
+            } else
+        #endif
+            {
+                // find the expected fcrc, don't bother avoiding a reread
+                // of the eperturb, it should still be in our cache
+                struct lfs_fcrc fcrc = {
+                    .size = lfs->cfg->prog_size,
+                    .crc = 0xffffffff
+                };
+                err = lfs_bd_crc(lfs,
+                        NULL, &lfs->rcache, lfs->cfg->prog_size,
+                        commit->block, noff, fcrc.size, &fcrc.crc);
+                if (err && err != LFS_ERR_CORRUPT) {
+                    return err;
+                }
+
+                lfs_fcrc_tole32(&fcrc);
+                err = lfs_dir_commitattr(lfs, commit,
+                        LFS_MKTAG(LFS_TYPE_FCRC, 0x3ff, sizeof(struct lfs_fcrc)),
+                        &fcrc);
+                if (err) {
+                    return err;
+                }
+            }
+        }
+
+        // build commit crc
+        struct {
+            lfs_tag_t tag;
+            uint32_t crc;
+        } ccrc;
+        lfs_tag_t ntag = LFS_MKTAG(
+                LFS_TYPE_CCRC + (((uint8_t)~eperturb) >> 7), 0x3ff,
+                noff - (commit->off+sizeof(lfs_tag_t)));
+        ccrc.tag = lfs_tobe32(ntag ^ commit->ptag);
+        commit->crc = lfs_crc(commit->crc, &ccrc.tag, sizeof(lfs_tag_t));
+        ccrc.crc = lfs_tole32(commit->crc);
+
+        int err = lfs_bd_prog(lfs,
+                &lfs->pcache, &lfs->rcache, false,
+                commit->block, commit->off, &ccrc, sizeof(ccrc));
+        if (err) {
+            return err;
+        }
+
+        // keep track of non-padding checksum to verify
+        if (off1 == 0) {
+            off1 = commit->off + sizeof(lfs_tag_t);
+            crc1 = commit->crc;
+        }
+
+        commit->off = noff;
+        // perturb valid bit?
+        commit->ptag = ntag ^ ((lfs_tag_t)(0x80 & ~eperturb) << 24);
+        // reset crc for next commit
+        commit->crc = 0xffffffff;
+
+        // manually flush here since we don't prog the padding, this confuses
+        // the caching layer
+        if (noff >= end || noff >= lfs->pcache.off + lfs->cfg->cache_size) {
+            // flush buffers
+            int err = lfs_bd_sync(lfs, &lfs->pcache, &lfs->rcache, false);
+            if (err) {
+                return err;
+            }
+        }
+    }
+
+    // successful commit, check checksums to make sure
+    //
+    // note that we don't need to check padding commits, worst
+    // case if they are corrupted we would have had to compact anyways
+    lfs_off_t off = commit->begin;
+    uint32_t crc = 0xffffffff;
+    int err = lfs_bd_crc(lfs,
+            NULL, &lfs->rcache, off1+sizeof(uint32_t),
+            commit->block, off, off1-off, &crc);
+    if (err) {
+        return err;
+    }
+
+    // check non-padding commits against known crc
+    if (crc != crc1) {
+        return LFS_ERR_CORRUPT;
+    }
+
+    // make sure to check crc in case we happen to pick
+    // up an unrelated crc (frozen block?)
+    err = lfs_bd_crc(lfs,
+            NULL, &lfs->rcache, sizeof(uint32_t),
+            commit->block, off1, sizeof(uint32_t), &crc);
+    if (err) {
+        return err;
+    }
+
+    if (crc != 0) {
+        return LFS_ERR_CORRUPT;
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_alloc(lfs_t *lfs, lfs_mdir_t *dir) {
+    // allocate pair of dir blocks (backwards, so we write block 1 first)
+    for (int i = 0; i < 2; i++) {
+        int err = lfs_alloc(lfs, &dir->pair[(i+1)%2]);
+        if (err) {
+            return err;
+        }
+    }
+
+    // zero for reproducibility in case initial block is unreadable
+    dir->rev = 0;
+
+    // rather than clobbering one of the blocks we just pretend
+    // the revision may be valid
+    int err = lfs_bd_read(lfs,
+            NULL, &lfs->rcache, sizeof(dir->rev),
+            dir->pair[0], 0, &dir->rev, sizeof(dir->rev));
+    dir->rev = lfs_fromle32(dir->rev);
+    if (err && err != LFS_ERR_CORRUPT) {
+        return err;
+    }
+
+    // to make sure we don't immediately evict, align the new revision count
+    // to our block_cycles modulus, see lfs_dir_compact for why our modulus
+    // is tweaked this way
+    if (lfs->cfg->block_cycles > 0) {
+        dir->rev = lfs_alignup(dir->rev, ((lfs->cfg->block_cycles+1)|1));
+    }
+
+    // set defaults
+    dir->off = sizeof(dir->rev);
+    dir->etag = 0xffffffff;
+    dir->count = 0;
+    dir->tail[0] = LFS_BLOCK_NULL;
+    dir->tail[1] = LFS_BLOCK_NULL;
+    dir->erased = false;
+    dir->split = false;
+
+    // don't write out yet, let caller take care of that
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_drop(lfs_t *lfs, lfs_mdir_t *dir, lfs_mdir_t *tail) {
+    // steal state
+    int err = lfs_dir_getgstate(lfs, tail, &lfs->gdelta);
+    if (err) {
+        return err;
+    }
+
+    // steal tail
+    lfs_pair_tole32(tail->tail);
+    err = lfs_dir_commit(lfs, dir, LFS_MKATTRS(
+            {LFS_MKTAG(LFS_TYPE_TAIL + tail->split, 0x3ff, 8), tail->tail}));
+    lfs_pair_fromle32(tail->tail);
+    if (err) {
+        return err;
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_split(lfs_t *lfs,
+        lfs_mdir_t *dir, const struct lfs_mattr *attrs, int attrcount,
+        lfs_mdir_t *source, uint16_t split, uint16_t end) {
+    // create tail metadata pair
+    lfs_mdir_t tail;
+    int err = lfs_dir_alloc(lfs, &tail);
+    if (err) {
+        return err;
+    }
+
+    tail.split = dir->split;
+    tail.tail[0] = dir->tail[0];
+    tail.tail[1] = dir->tail[1];
+
+    // note we don't care about LFS_OK_RELOCATED
+    int res = lfs_dir_compact(lfs, &tail, attrs, attrcount, source, split, end);
+    if (res < 0) {
+        return res;
+    }
+
+    dir->tail[0] = tail.pair[0];
+    dir->tail[1] = tail.pair[1];
+    dir->split = true;
+
+    // update root if needed
+    if (lfs_pair_cmp(dir->pair, lfs->root) == 0 && split == 0) {
+        lfs->root[0] = tail.pair[0];
+        lfs->root[1] = tail.pair[1];
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_commit_size(void *p, lfs_tag_t tag, const void *buffer) {
+    lfs_size_t *size = p;
+    (void)buffer;
+
+    *size += lfs_tag_dsize(tag);
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+struct lfs_dir_commit_commit {
+    lfs_t *lfs;
+    struct lfs_commit *commit;
+};
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_commit_commit(void *p, lfs_tag_t tag, const void *buffer) {
+    struct lfs_dir_commit_commit *commit = p;
+    return lfs_dir_commitattr(commit->lfs, commit->commit, tag, buffer);
+}
+#endif
+
+#ifndef LFS_READONLY
+static bool lfs_dir_needsrelocation(lfs_t *lfs, lfs_mdir_t *dir) {
+    // If our revision count == n * block_cycles, we should force a relocation,
+    // this is how littlefs wear-levels at the metadata-pair level. Note that we
+    // actually use (block_cycles+1)|1, this is to avoid two corner cases:
+    // 1. block_cycles = 1, which would prevent relocations from terminating
+    // 2. block_cycles = 2n, which, due to aliasing, would only ever relocate
+    //    one metadata block in the pair, effectively making this useless
+    return (lfs->cfg->block_cycles > 0
+            && ((dir->rev + 1) % ((lfs->cfg->block_cycles+1)|1) == 0));
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_compact(lfs_t *lfs,
+        lfs_mdir_t *dir, const struct lfs_mattr *attrs, int attrcount,
+        lfs_mdir_t *source, uint16_t begin, uint16_t end) {
+    // save some state in case block is bad
+    bool relocated = false;
+    bool tired = lfs_dir_needsrelocation(lfs, dir);
+
+    // increment revision count
+    dir->rev += 1;
+
+    // do not proactively relocate blocks during migrations, this
+    // can cause a number of failure states such: clobbering the
+    // v1 superblock if we relocate root, and invalidating directory
+    // pointers if we relocate the head of a directory. On top of
+    // this, relocations increase the overall complexity of
+    // lfs_migration, which is already a delicate operation.
+#ifdef LFS_MIGRATE
+    if (lfs->lfs1) {
+        tired = false;
+    }
+#endif
+
+    if (tired && lfs_pair_cmp(dir->pair, (const lfs_block_t[2]){0, 1}) != 0) {
+        // we're writing too much, time to relocate
+        goto relocate;
+    }
+
+    // begin loop to commit compaction to blocks until a compact sticks
+    while (true) {
+        {
+            // setup commit state
+            struct lfs_commit commit = {
+                .block = dir->pair[1],
+                .off = 0,
+                .ptag = 0xffffffff,
+                .crc = 0xffffffff,
+
+                .begin = 0,
+                .end = (lfs->cfg->metadata_max ?
+                    lfs->cfg->metadata_max : lfs->cfg->block_size) - 8,
+            };
+
+            // erase block to write to
+            int err = lfs_bd_erase(lfs, dir->pair[1]);
+            if (err) {
+                if (err == LFS_ERR_CORRUPT) {
+                    goto relocate;
+                }
+                return err;
+            }
+
+            // write out header
+            dir->rev = lfs_tole32(dir->rev);
+            err = lfs_dir_commitprog(lfs, &commit,
+                    &dir->rev, sizeof(dir->rev));
+            dir->rev = lfs_fromle32(dir->rev);
+            if (err) {
+                if (err == LFS_ERR_CORRUPT) {
+                    goto relocate;
+                }
+                return err;
+            }
+
+            // traverse the directory, this time writing out all unique tags
+            err = lfs_dir_traverse(lfs,
+                    source, 0, 0xffffffff, attrs, attrcount,
+                    LFS_MKTAG(0x400, 0x3ff, 0),
+                    LFS_MKTAG(LFS_TYPE_NAME, 0, 0),
+                    begin, end, -begin,
+                    lfs_dir_commit_commit, &(struct lfs_dir_commit_commit){
+                        lfs, &commit});
+            if (err) {
+                if (err == LFS_ERR_CORRUPT) {
+                    goto relocate;
+                }
+                return err;
+            }
+
+            // commit tail, which may be new after last size check
+            if (!lfs_pair_isnull(dir->tail)) {
+                lfs_pair_tole32(dir->tail);
+                err = lfs_dir_commitattr(lfs, &commit,
+                        LFS_MKTAG(LFS_TYPE_TAIL + dir->split, 0x3ff, 8),
+                        dir->tail);
+                lfs_pair_fromle32(dir->tail);
+                if (err) {
+                    if (err == LFS_ERR_CORRUPT) {
+                        goto relocate;
+                    }
+                    return err;
+                }
+            }
+
+            // bring over gstate?
+            lfs_gstate_t delta = {0};
+            if (!relocated) {
+                lfs_gstate_xor(&delta, &lfs->gdisk);
+                lfs_gstate_xor(&delta, &lfs->gstate);
+            }
+            lfs_gstate_xor(&delta, &lfs->gdelta);
+            delta.tag &= ~LFS_MKTAG(0, 0, 0x3ff);
+
+            err = lfs_dir_getgstate(lfs, dir, &delta);
+            if (err) {
+                return err;
+            }
+
+            if (!lfs_gstate_iszero(&delta)) {
+                lfs_gstate_tole32(&delta);
+                err = lfs_dir_commitattr(lfs, &commit,
+                        LFS_MKTAG(LFS_TYPE_MOVESTATE, 0x3ff,
+                            sizeof(delta)), &delta);
+                if (err) {
+                    if (err == LFS_ERR_CORRUPT) {
+                        goto relocate;
+                    }
+                    return err;
+                }
+            }
+
+            // complete commit with crc
+            err = lfs_dir_commitcrc(lfs, &commit);
+            if (err) {
+                if (err == LFS_ERR_CORRUPT) {
+                    goto relocate;
+                }
+                return err;
+            }
+
+            // successful compaction, swap dir pair to indicate most recent
+            LFS_ASSERT(commit.off % lfs->cfg->prog_size == 0);
+            lfs_pair_swap(dir->pair);
+            dir->count = end - begin;
+            dir->off = commit.off;
+            dir->etag = commit.ptag;
+            // update gstate
+            lfs->gdelta = (lfs_gstate_t){0};
+            if (!relocated) {
+                lfs->gdisk = lfs->gstate;
+            }
+        }
+        break;
+
+relocate:
+        // commit was corrupted, drop caches and prepare to relocate block
+        relocated = true;
+        lfs_cache_drop(lfs, &lfs->pcache);
+        if (!tired) {
+            LFS_DEBUG("Bad block at 0x%"PRIx32, dir->pair[1]);
+        }
+
+        // can't relocate superblock, filesystem is now frozen
+        if (lfs_pair_cmp(dir->pair, (const lfs_block_t[2]){0, 1}) == 0) {
+            LFS_WARN("Superblock 0x%"PRIx32" has become unwritable",
+                    dir->pair[1]);
+            return LFS_ERR_NOSPC;
+        }
+
+        // relocate half of pair
+        int err = lfs_alloc(lfs, &dir->pair[1]);
+        if (err && (err != LFS_ERR_NOSPC || !tired)) {
+            return err;
+        }
+
+        tired = false;
+        continue;
+    }
+
+    return relocated ? LFS_OK_RELOCATED : 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_splittingcompact(lfs_t *lfs, lfs_mdir_t *dir,
+        const struct lfs_mattr *attrs, int attrcount,
+        lfs_mdir_t *source, uint16_t begin, uint16_t end) {
+    while (true) {
+        // find size of first split, we do this by halving the split until
+        // the metadata is guaranteed to fit
+        //
+        // Note that this isn't a true binary search, we never increase the
+        // split size. This may result in poorly distributed metadata but isn't
+        // worth the extra code size or performance hit to fix.
+        lfs_size_t split = begin;
+        while (end - split > 1) {
+            lfs_size_t size = 0;
+            int err = lfs_dir_traverse(lfs,
+                    source, 0, 0xffffffff, attrs, attrcount,
+                    LFS_MKTAG(0x400, 0x3ff, 0),
+                    LFS_MKTAG(LFS_TYPE_NAME, 0, 0),
+                    split, end, -split,
+                    lfs_dir_commit_size, &size);
+            if (err) {
+                return err;
+            }
+
+            // space is complicated, we need room for:
+            //
+            // - tail:         4+2*4 = 12 bytes
+            // - gstate:       4+3*4 = 16 bytes
+            // - move delete:  4     = 4 bytes
+            // - crc:          4+4   = 8 bytes
+            //                 total = 40 bytes
+            //
+            // And we cap at half a block to avoid degenerate cases with
+            // nearly-full metadata blocks.
+            //
+            lfs_size_t metadata_max = (lfs->cfg->metadata_max)
+                    ? lfs->cfg->metadata_max
+                    : lfs->cfg->block_size;
+            if (end - split < 0xff
+                    && size <= lfs_min(
+                        metadata_max - 40,
+                        lfs_alignup(
+                            metadata_max/2,
+                            lfs->cfg->prog_size))) {
+                break;
+            }
+
+            split = split + ((end - split) / 2);
+        }
+
+        if (split == begin) {
+            // no split needed
+            break;
+        }
+
+        // split into two metadata pairs and continue
+        int err = lfs_dir_split(lfs, dir, attrs, attrcount,
+                source, split, end);
+        if (err && err != LFS_ERR_NOSPC) {
+            return err;
+        }
+
+        if (err) {
+            // we can't allocate a new block, try to compact with degraded
+            // performance
+            LFS_WARN("Unable to split {0x%"PRIx32", 0x%"PRIx32"}",
+                    dir->pair[0], dir->pair[1]);
+            break;
+        } else {
+            end = split;
+        }
+    }
+
+    if (lfs_dir_needsrelocation(lfs, dir)
+            && lfs_pair_cmp(dir->pair, (const lfs_block_t[2]){0, 1}) == 0) {
+        // oh no! we're writing too much to the superblock,
+        // should we expand?
+        lfs_ssize_t size = lfs_fs_size_(lfs);
+        if (size < 0) {
+            return size;
+        }
+
+        // littlefs cannot reclaim expanded superblocks, so expand cautiously
+        //
+        // if our filesystem is more than ~88% full, don't expand, this is
+        // somewhat arbitrary
+        if (lfs->block_count - size > lfs->block_count/8) {
+            LFS_DEBUG("Expanding superblock at rev %"PRIu32, dir->rev);
+            int err = lfs_dir_split(lfs, dir, attrs, attrcount,
+                    source, begin, end);
+            if (err && err != LFS_ERR_NOSPC) {
+                return err;
+            }
+
+            if (err) {
+                // welp, we tried, if we ran out of space there's not much
+                // we can do, we'll error later if we've become frozen
+                LFS_WARN("Unable to expand superblock");
+            } else {
+                // duplicate the superblock entry into the new superblock
+                end = 1;
+            }
+        }
+    }
+
+    return lfs_dir_compact(lfs, dir, attrs, attrcount, source, begin, end);
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_relocatingcommit(lfs_t *lfs, lfs_mdir_t *dir,
+        const lfs_block_t pair[2],
+        const struct lfs_mattr *attrs, int attrcount,
+        lfs_mdir_t *pdir) {
+    int state = 0;
+
+    // calculate changes to the directory
+    bool hasdelete = false;
+    for (int i = 0; i < attrcount; i++) {
+        if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_CREATE) {
+            dir->count += 1;
+        } else if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE) {
+            LFS_ASSERT(dir->count > 0);
+            dir->count -= 1;
+            hasdelete = true;
+        } else if (lfs_tag_type1(attrs[i].tag) == LFS_TYPE_TAIL) {
+            dir->tail[0] = ((lfs_block_t*)attrs[i].buffer)[0];
+            dir->tail[1] = ((lfs_block_t*)attrs[i].buffer)[1];
+            dir->split = (lfs_tag_chunk(attrs[i].tag) & 1);
+            lfs_pair_fromle32(dir->tail);
+        }
+    }
+
+    // should we actually drop the directory block?
+    if (hasdelete && dir->count == 0) {
+        LFS_ASSERT(pdir);
+        int err = lfs_fs_pred(lfs, dir->pair, pdir);
+        if (err && err != LFS_ERR_NOENT) {
+            return err;
+        }
+
+        if (err != LFS_ERR_NOENT && pdir->split) {
+            state = LFS_OK_DROPPED;
+            goto fixmlist;
+        }
+    }
+
+    if (dir->erased && dir->count < 0xff) {
+        // try to commit
+        struct lfs_commit commit = {
+            .block = dir->pair[0],
+            .off = dir->off,
+            .ptag = dir->etag,
+            .crc = 0xffffffff,
+
+            .begin = dir->off,
+            .end = (lfs->cfg->metadata_max ?
+                lfs->cfg->metadata_max : lfs->cfg->block_size) - 8,
+        };
+
+        // traverse attrs that need to be written out
+        lfs_pair_tole32(dir->tail);
+        int err = lfs_dir_traverse(lfs,
+                dir, dir->off, dir->etag, attrs, attrcount,
+                0, 0, 0, 0, 0,
+                lfs_dir_commit_commit, &(struct lfs_dir_commit_commit){
+                    lfs, &commit});
+        lfs_pair_fromle32(dir->tail);
+        if (err) {
+            if (err == LFS_ERR_NOSPC || err == LFS_ERR_CORRUPT) {
+                goto compact;
+            }
+            return err;
+        }
+
+        // commit any global diffs if we have any
+        lfs_gstate_t delta = {0};
+        lfs_gstate_xor(&delta, &lfs->gstate);
+        lfs_gstate_xor(&delta, &lfs->gdisk);
+        lfs_gstate_xor(&delta, &lfs->gdelta);
+        delta.tag &= ~LFS_MKTAG(0, 0, 0x3ff);
+        if (!lfs_gstate_iszero(&delta)) {
+            err = lfs_dir_getgstate(lfs, dir, &delta);
+            if (err) {
+                return err;
+            }
+
+            lfs_gstate_tole32(&delta);
+            err = lfs_dir_commitattr(lfs, &commit,
+                    LFS_MKTAG(LFS_TYPE_MOVESTATE, 0x3ff,
+                        sizeof(delta)), &delta);
+            if (err) {
+                if (err == LFS_ERR_NOSPC || err == LFS_ERR_CORRUPT) {
+                    goto compact;
+                }
+                return err;
+            }
+        }
+
+        // finalize commit with the crc
+        err = lfs_dir_commitcrc(lfs, &commit);
+        if (err) {
+            if (err == LFS_ERR_NOSPC || err == LFS_ERR_CORRUPT) {
+                goto compact;
+            }
+            return err;
+        }
+
+        // successful commit, update dir
+        LFS_ASSERT(commit.off % lfs->cfg->prog_size == 0);
+        dir->off = commit.off;
+        dir->etag = commit.ptag;
+        // and update gstate
+        lfs->gdisk = lfs->gstate;
+        lfs->gdelta = (lfs_gstate_t){0};
+
+        goto fixmlist;
+    }
+
+compact:
+    // fall back to compaction
+    lfs_cache_drop(lfs, &lfs->pcache);
+
+    state = lfs_dir_splittingcompact(lfs, dir, attrs, attrcount,
+            dir, 0, dir->count);
+    if (state < 0) {
+        return state;
+    }
+
+    goto fixmlist;
+
+fixmlist:;
+    // this complicated bit of logic is for fixing up any active
+    // metadata-pairs that we may have affected
+    //
+    // note we have to make two passes since the mdir passed to
+    // lfs_dir_commit could also be in this list, and even then
+    // we need to copy the pair so they don't get clobbered if we refetch
+    // our mdir.
+    lfs_block_t oldpair[2] = {pair[0], pair[1]};
+    for (struct lfs_mlist *d = lfs->mlist; d; d = d->next) {
+        if (lfs_pair_cmp(d->m.pair, oldpair) == 0) {
+            d->m = *dir;
+            if (d->m.pair != pair) {
+                for (int i = 0; i < attrcount; i++) {
+                    if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE &&
+                            d->id == lfs_tag_id(attrs[i].tag) &&
+                            d->type != LFS_TYPE_DIR) {
+                        d->m.pair[0] = LFS_BLOCK_NULL;
+                        d->m.pair[1] = LFS_BLOCK_NULL;
+                    } else if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE &&
+                            d->id > lfs_tag_id(attrs[i].tag)) {
+                        d->id -= 1;
+                        if (d->type == LFS_TYPE_DIR) {
+                            ((lfs_dir_t*)d)->pos -= 1;
+                        }
+                    } else if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_CREATE &&
+                            d->id >= lfs_tag_id(attrs[i].tag)) {
+                        d->id += 1;
+                        if (d->type == LFS_TYPE_DIR) {
+                            ((lfs_dir_t*)d)->pos += 1;
+                        }
+                    }
+                }
+            }
+
+            while (d->id >= d->m.count && d->m.split) {
+                // we split and id is on tail now
+                if (lfs_pair_cmp(d->m.tail, lfs->root) != 0) {
+                    d->id -= d->m.count;
+                }
+                int err = lfs_dir_fetch(lfs, &d->m, d->m.tail);
+                if (err) {
+                    return err;
+                }
+            }
+        }
+    }
+
+    return state;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_orphaningcommit(lfs_t *lfs, lfs_mdir_t *dir,
+        const struct lfs_mattr *attrs, int attrcount) {
+    // check for any inline files that aren't RAM backed and
+    // forcefully evict them, needed for filesystem consistency
+    for (lfs_file_t *f = (lfs_file_t*)lfs->mlist; f; f = f->next) {
+        if (dir != &f->m && lfs_pair_cmp(f->m.pair, dir->pair) == 0 &&
+                f->type == LFS_TYPE_REG && (f->flags & LFS_F_INLINE) &&
+                f->ctz.size > lfs->cfg->cache_size) {
+            int err = lfs_file_outline(lfs, f);
+            if (err) {
+                return err;
+            }
+
+            err = lfs_file_flush(lfs, f);
+            if (err) {
+                return err;
+            }
+        }
+    }
+
+    lfs_block_t lpair[2] = {dir->pair[0], dir->pair[1]};
+    lfs_mdir_t ldir = *dir;
+    lfs_mdir_t pdir;
+    int state = lfs_dir_relocatingcommit(lfs, &ldir, dir->pair,
+            attrs, attrcount, &pdir);
+    if (state < 0) {
+        return state;
+    }
+
+    // update if we're not in mlist, note we may have already been
+    // updated if we are in mlist
+    if (lfs_pair_cmp(dir->pair, lpair) == 0) {
+        *dir = ldir;
+    }
+
+    // commit was successful, but may require other changes in the
+    // filesystem, these would normally be tail recursive, but we have
+    // flattened them here avoid unbounded stack usage
+
+    // need to drop?
+    if (state == LFS_OK_DROPPED) {
+        // steal state
+        int err = lfs_dir_getgstate(lfs, dir, &lfs->gdelta);
+        if (err) {
+            return err;
+        }
+
+        // steal tail, note that this can't create a recursive drop
+        lpair[0] = pdir.pair[0];
+        lpair[1] = pdir.pair[1];
+        lfs_pair_tole32(dir->tail);
+        state = lfs_dir_relocatingcommit(lfs, &pdir, lpair, LFS_MKATTRS(
+                    {LFS_MKTAG(LFS_TYPE_TAIL + dir->split, 0x3ff, 8),
+                        dir->tail}),
+                NULL);
+        lfs_pair_fromle32(dir->tail);
+        if (state < 0) {
+            return state;
+        }
+
+        ldir = pdir;
+    }
+
+    // need to relocate?
+    bool orphans = false;
+    while (state == LFS_OK_RELOCATED) {
+        LFS_DEBUG("Relocating {0x%"PRIx32", 0x%"PRIx32"} "
+                    "-> {0x%"PRIx32", 0x%"PRIx32"}",
+                lpair[0], lpair[1], ldir.pair[0], ldir.pair[1]);
+        state = 0;
+
+        // update internal root
+        if (lfs_pair_cmp(lpair, lfs->root) == 0) {
+            lfs->root[0] = ldir.pair[0];
+            lfs->root[1] = ldir.pair[1];
+        }
+
+        // update internally tracked dirs
+        for (struct lfs_mlist *d = lfs->mlist; d; d = d->next) {
+            if (lfs_pair_cmp(lpair, d->m.pair) == 0) {
+                d->m.pair[0] = ldir.pair[0];
+                d->m.pair[1] = ldir.pair[1];
+            }
+
+            if (d->type == LFS_TYPE_DIR &&
+                    lfs_pair_cmp(lpair, ((lfs_dir_t*)d)->head) == 0) {
+                ((lfs_dir_t*)d)->head[0] = ldir.pair[0];
+                ((lfs_dir_t*)d)->head[1] = ldir.pair[1];
+            }
+        }
+
+        // find parent
+        lfs_stag_t tag = lfs_fs_parent(lfs, lpair, &pdir);
+        if (tag < 0 && tag != LFS_ERR_NOENT) {
+            return tag;
+        }
+
+        bool hasparent = (tag != LFS_ERR_NOENT);
+        if (tag != LFS_ERR_NOENT) {
+            // note that if we have a parent, we must have a pred, so this will
+            // always create an orphan
+            int err = lfs_fs_preporphans(lfs, +1);
+            if (err) {
+                return err;
+            }
+
+            // fix pending move in this pair? this looks like an optimization but
+            // is in fact _required_ since relocating may outdate the move.
+            uint16_t moveid = 0x3ff;
+            if (lfs_gstate_hasmovehere(&lfs->gstate, pdir.pair)) {
+                moveid = lfs_tag_id(lfs->gstate.tag);
+                LFS_DEBUG("Fixing move while relocating "
+                        "{0x%"PRIx32", 0x%"PRIx32"} 0x%"PRIx16"\n",
+                        pdir.pair[0], pdir.pair[1], moveid);
+                lfs_fs_prepmove(lfs, 0x3ff, NULL);
+                if (moveid < lfs_tag_id(tag)) {
+                    tag -= LFS_MKTAG(0, 1, 0);
+                }
+            }
+
+            lfs_block_t ppair[2] = {pdir.pair[0], pdir.pair[1]};
+            lfs_pair_tole32(ldir.pair);
+            state = lfs_dir_relocatingcommit(lfs, &pdir, ppair, LFS_MKATTRS(
+                        {LFS_MKTAG_IF(moveid != 0x3ff,
+                            LFS_TYPE_DELETE, moveid, 0), NULL},
+                        {tag, ldir.pair}),
+                    NULL);
+            lfs_pair_fromle32(ldir.pair);
+            if (state < 0) {
+                return state;
+            }
+
+            if (state == LFS_OK_RELOCATED) {
+                lpair[0] = ppair[0];
+                lpair[1] = ppair[1];
+                ldir = pdir;
+                orphans = true;
+                continue;
+            }
+        }
+
+        // find pred
+        int err = lfs_fs_pred(lfs, lpair, &pdir);
+        if (err && err != LFS_ERR_NOENT) {
+            return err;
+        }
+        LFS_ASSERT(!(hasparent && err == LFS_ERR_NOENT));
+
+        // if we can't find dir, it must be new
+        if (err != LFS_ERR_NOENT) {
+            if (lfs_gstate_hasorphans(&lfs->gstate)) {
+                // next step, clean up orphans
+                err = lfs_fs_preporphans(lfs, -(int8_t)hasparent);
+                if (err) {
+                    return err;
+                }
+            }
+
+            // fix pending move in this pair? this looks like an optimization
+            // but is in fact _required_ since relocating may outdate the move.
+            uint16_t moveid = 0x3ff;
+            if (lfs_gstate_hasmovehere(&lfs->gstate, pdir.pair)) {
+                moveid = lfs_tag_id(lfs->gstate.tag);
+                LFS_DEBUG("Fixing move while relocating "
+                        "{0x%"PRIx32", 0x%"PRIx32"} 0x%"PRIx16"\n",
+                        pdir.pair[0], pdir.pair[1], moveid);
+                lfs_fs_prepmove(lfs, 0x3ff, NULL);
+            }
+
+            // replace bad pair, either we clean up desync, or no desync occured
+            lpair[0] = pdir.pair[0];
+            lpair[1] = pdir.pair[1];
+            lfs_pair_tole32(ldir.pair);
+            state = lfs_dir_relocatingcommit(lfs, &pdir, lpair, LFS_MKATTRS(
+                        {LFS_MKTAG_IF(moveid != 0x3ff,
+                            LFS_TYPE_DELETE, moveid, 0), NULL},
+                        {LFS_MKTAG(LFS_TYPE_TAIL + pdir.split, 0x3ff, 8),
+                            ldir.pair}),
+                    NULL);
+            lfs_pair_fromle32(ldir.pair);
+            if (state < 0) {
+                return state;
+            }
+
+            ldir = pdir;
+        }
+    }
+
+    return orphans ? LFS_OK_ORPHANED : 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_dir_commit(lfs_t *lfs, lfs_mdir_t *dir,
+        const struct lfs_mattr *attrs, int attrcount) {
+    int orphans = lfs_dir_orphaningcommit(lfs, dir, attrs, attrcount);
+    if (orphans < 0) {
+        return orphans;
+    }
+
+    if (orphans) {
+        // make sure we've removed all orphans, this is a noop if there
+        // are none, but if we had nested blocks failures we may have
+        // created some
+        int err = lfs_fs_deorphan(lfs, false);
+        if (err) {
+            return err;
+        }
+    }
+
+    return 0;
+}
+#endif
+
+
+/// Top level directory operations ///
+#ifndef LFS_READONLY
+static int lfs_mkdir_(lfs_t *lfs, const char *path) {
+    // deorphan if we haven't yet, needed at most once after poweron
+    int err = lfs_fs_forceconsistency(lfs);
+    if (err) {
+        return err;
+    }
+
+    struct lfs_mlist cwd;
+    cwd.next = lfs->mlist;
+    uint16_t id;
+    err = lfs_dir_find(lfs, &cwd.m, &path, &id);
+    if (!(err == LFS_ERR_NOENT && lfs_path_islast(path))) {
+        return (err < 0) ? err : LFS_ERR_EXIST;
+    }
+
+    // check that name fits
+    lfs_size_t nlen = lfs_path_namelen(path);
+    if (nlen > lfs->name_max) {
+        return LFS_ERR_NAMETOOLONG;
+    }
+
+    // build up new directory
+    lfs_alloc_ckpoint(lfs);
+    lfs_mdir_t dir;
+    err = lfs_dir_alloc(lfs, &dir);
+    if (err) {
+        return err;
+    }
+
+    // find end of list
+    lfs_mdir_t pred = cwd.m;
+    while (pred.split) {
+        err = lfs_dir_fetch(lfs, &pred, pred.tail);
+        if (err) {
+            return err;
+        }
+    }
+
+    // setup dir
+    lfs_pair_tole32(pred.tail);
+    err = lfs_dir_commit(lfs, &dir, LFS_MKATTRS(
+            {LFS_MKTAG(LFS_TYPE_SOFTTAIL, 0x3ff, 8), pred.tail}));
+    lfs_pair_fromle32(pred.tail);
+    if (err) {
+        return err;
+    }
+
+    // current block not end of list?
+    if (cwd.m.split) {
+        // update tails, this creates a desync
+        err = lfs_fs_preporphans(lfs, +1);
+        if (err) {
+            return err;
+        }
+
+        // it's possible our predecessor has to be relocated, and if
+        // our parent is our predecessor's predecessor, this could have
+        // caused our parent to go out of date, fortunately we can hook
+        // ourselves into littlefs to catch this
+        cwd.type = 0;
+        cwd.id = 0;
+        lfs->mlist = &cwd;
+
+        lfs_pair_tole32(dir.pair);
+        err = lfs_dir_commit(lfs, &pred, LFS_MKATTRS(
+                {LFS_MKTAG(LFS_TYPE_SOFTTAIL, 0x3ff, 8), dir.pair}));
+        lfs_pair_fromle32(dir.pair);
+        if (err) {
+            lfs->mlist = cwd.next;
+            return err;
+        }
+
+        lfs->mlist = cwd.next;
+        err = lfs_fs_preporphans(lfs, -1);
+        if (err) {
+            return err;
+        }
+    }
+
+    // now insert into our parent block
+    lfs_pair_tole32(dir.pair);
+    err = lfs_dir_commit(lfs, &cwd.m, LFS_MKATTRS(
+            {LFS_MKTAG(LFS_TYPE_CREATE, id, 0), NULL},
+            {LFS_MKTAG(LFS_TYPE_DIR, id, nlen), path},
+            {LFS_MKTAG(LFS_TYPE_DIRSTRUCT, id, 8), dir.pair},
+            {LFS_MKTAG_IF(!cwd.m.split,
+                LFS_TYPE_SOFTTAIL, 0x3ff, 8), dir.pair}));
+    lfs_pair_fromle32(dir.pair);
+    if (err) {
+        return err;
+    }
+
+    return 0;
+}
+#endif
+
+static int lfs_dir_open_(lfs_t *lfs, lfs_dir_t *dir, const char *path) {
+    lfs_stag_t tag = lfs_dir_find(lfs, &dir->m, &path, NULL);
+    if (tag < 0) {
+        return tag;
+    }
+
+    if (lfs_tag_type3(tag) != LFS_TYPE_DIR) {
+        return LFS_ERR_NOTDIR;
+    }
+
+    lfs_block_t pair[2];
+    if (lfs_tag_id(tag) == 0x3ff) {
+        // handle root dir separately
+        pair[0] = lfs->root[0];
+        pair[1] = lfs->root[1];
+    } else {
+        // get dir pair from parent
+        lfs_stag_t res = lfs_dir_get(lfs, &dir->m, LFS_MKTAG(0x700, 0x3ff, 0),
+                LFS_MKTAG(LFS_TYPE_STRUCT, lfs_tag_id(tag), 8), pair);
+        if (res < 0) {
+            return res;
+        }
+        lfs_pair_fromle32(pair);
+    }
+
+    // fetch first pair
+    int err = lfs_dir_fetch(lfs, &dir->m, pair);
+    if (err) {
+        return err;
+    }
+
+    // setup entry
+    dir->head[0] = dir->m.pair[0];
+    dir->head[1] = dir->m.pair[1];
+    dir->id = 0;
+    dir->pos = 0;
+
+    // add to list of mdirs
+    dir->type = LFS_TYPE_DIR;
+    lfs_mlist_append(lfs, (struct lfs_mlist *)dir);
+
+    return 0;
+}
+
+static int lfs_dir_close_(lfs_t *lfs, lfs_dir_t *dir) {
+    // remove from list of mdirs
+    lfs_mlist_remove(lfs, (struct lfs_mlist *)dir);
+
+    return 0;
+}
+
+static int lfs_dir_read_(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
+    memset(info, 0, sizeof(*info));
+
+    // special offset for '.' and '..'
+    if (dir->pos == 0) {
+        info->type = LFS_TYPE_DIR;
+        strcpy(info->name, ".");
+        dir->pos += 1;
+        return true;
+    } else if (dir->pos == 1) {
+        info->type = LFS_TYPE_DIR;
+        strcpy(info->name, "..");
+        dir->pos += 1;
+        return true;
+    }
+
+    while (true) {
+        if (dir->id == dir->m.count) {
+            if (!dir->m.split) {
+                return false;
+            }
+
+            int err = lfs_dir_fetch(lfs, &dir->m, dir->m.tail);
+            if (err) {
+                return err;
+            }
+
+            dir->id = 0;
+        }
+
+        int err = lfs_dir_getinfo(lfs, &dir->m, dir->id, info);
+        if (err && err != LFS_ERR_NOENT) {
+            return err;
+        }
+
+        dir->id += 1;
+        if (err != LFS_ERR_NOENT) {
+            break;
+        }
+    }
+
+    dir->pos += 1;
+    return true;
+}
+
+static int lfs_dir_seek_(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
+    // simply walk from head dir
+    int err = lfs_dir_rewind_(lfs, dir);
+    if (err) {
+        return err;
+    }
+
+    // first two for ./..
+    dir->pos = lfs_min(2, off);
+    off -= dir->pos;
+
+    // skip superblock entry
+    dir->id = (off > 0 && lfs_pair_cmp(dir->head, lfs->root) == 0);
+
+    while (off > 0) {
+        if (dir->id == dir->m.count) {
+            if (!dir->m.split) {
+                return LFS_ERR_INVAL;
+            }
+
+            err = lfs_dir_fetch(lfs, &dir->m, dir->m.tail);
+            if (err) {
+                return err;
+            }
+
+            dir->id = 0;
+        }
+
+        int diff = lfs_min(dir->m.count - dir->id, off);
+        dir->id += diff;
+        dir->pos += diff;
+        off -= diff;
+    }
+
+    return 0;
+}
+
+static lfs_soff_t lfs_dir_tell_(lfs_t *lfs, lfs_dir_t *dir) {
+    (void)lfs;
+    return dir->pos;
+}
+
+static int lfs_dir_rewind_(lfs_t *lfs, lfs_dir_t *dir) {
+    // reload the head dir
+    int err = lfs_dir_fetch(lfs, &dir->m, dir->head);
+    if (err) {
+        return err;
+    }
+
+    dir->id = 0;
+    dir->pos = 0;
+    return 0;
+}
+
+
+/// File index list operations ///
+static int lfs_ctz_index(lfs_t *lfs, lfs_off_t *off) {
+    lfs_off_t size = *off;
+    lfs_off_t b = lfs->cfg->block_size - 2*4;
+    lfs_off_t i = size / b;
+    if (i == 0) {
+        return 0;
+    }
+
+    i = (size - 4*(lfs_popc(i-1)+2)) / b;
+    *off = size - b*i - 4*lfs_popc(i);
+    return i;
+}
+
+static int lfs_ctz_find(lfs_t *lfs,
+        const lfs_cache_t *pcache, lfs_cache_t *rcache,
+        lfs_block_t head, lfs_size_t size,
+        lfs_size_t pos, lfs_block_t *block, lfs_off_t *off) {
+    if (size == 0) {
+        *block = LFS_BLOCK_NULL;
+        *off = 0;
+        return 0;
+    }
+
+    lfs_off_t current = lfs_ctz_index(lfs, &(lfs_off_t){size-1});
+    lfs_off_t target = lfs_ctz_index(lfs, &pos);
+
+    while (current > target) {
+        lfs_size_t skip = lfs_min(
+                lfs_npw2(current-target+1) - 1,
+                lfs_ctz(current));
+
+        int err = lfs_bd_read(lfs,
+                pcache, rcache, sizeof(head),
+                head, 4*skip, &head, sizeof(head));
+        head = lfs_fromle32(head);
+        if (err) {
+            return err;
+        }
+
+        current -= 1 << skip;
+    }
+
+    *block = head;
+    *off = pos;
+    return 0;
+}
+
+#ifndef LFS_READONLY
+static int lfs_ctz_extend(lfs_t *lfs,
+        lfs_cache_t *pcache, lfs_cache_t *rcache,
+        lfs_block_t head, lfs_size_t size,
+        lfs_block_t *block, lfs_off_t *off) {
+    while (true) {
+        // go ahead and grab a block
+        lfs_block_t nblock;
+        int err = lfs_alloc(lfs, &nblock);
+        if (err) {
+            return err;
+        }
+
+        {
+            err = lfs_bd_erase(lfs, nblock);
+            if (err) {
+                if (err == LFS_ERR_CORRUPT) {
+                    goto relocate;
+                }
+                return err;
+            }
+
+            if (size == 0) {
+                *block = nblock;
+                *off = 0;
+                return 0;
+            }
+
+            lfs_size_t noff = size - 1;
+            lfs_off_t index = lfs_ctz_index(lfs, &noff);
+            noff = noff + 1;
+
+            // just copy out the last block if it is incomplete
+            if (noff != lfs->cfg->block_size) {
+                for (lfs_off_t i = 0; i < noff; i++) {
+                    uint8_t data;
+                    err = lfs_bd_read(lfs,
+                            NULL, rcache, noff-i,
+                            head, i, &data, 1);
+                    if (err) {
+                        return err;
+                    }
+
+                    err = lfs_bd_prog(lfs,
+                            pcache, rcache, true,
+                            nblock, i, &data, 1);
+                    if (err) {
+                        if (err == LFS_ERR_CORRUPT) {
+                            goto relocate;
+                        }
+                        return err;
+                    }
+                }
+
+                *block = nblock;
+                *off = noff;
+                return 0;
+            }
+
+            // append block
+            index += 1;
+            lfs_size_t skips = lfs_ctz(index) + 1;
+            lfs_block_t nhead = head;
+            for (lfs_off_t i = 0; i < skips; i++) {
+                nhead = lfs_tole32(nhead);
+                err = lfs_bd_prog(lfs, pcache, rcache, true,
+                        nblock, 4*i, &nhead, 4);
+                nhead = lfs_fromle32(nhead);
+                if (err) {
+                    if (err == LFS_ERR_CORRUPT) {
+                        goto relocate;
+                    }
+                    return err;
+                }
+
+                if (i != skips-1) {
+                    err = lfs_bd_read(lfs,
+                            NULL, rcache, sizeof(nhead),
+                            nhead, 4*i, &nhead, sizeof(nhead));
+                    nhead = lfs_fromle32(nhead);
+                    if (err) {
+                        return err;
+                    }
+                }
+            }
+
+            *block = nblock;
+            *off = 4*skips;
+            return 0;
+        }
+
+relocate:
+        LFS_DEBUG("Bad block at 0x%"PRIx32, nblock);
+
+        // just clear cache and try a new block
+        lfs_cache_drop(lfs, pcache);
+    }
+}
+#endif
+
+static int lfs_ctz_traverse(lfs_t *lfs,
+        const lfs_cache_t *pcache, lfs_cache_t *rcache,
+        lfs_block_t head, lfs_size_t size,
+        int (*cb)(void*, lfs_block_t), void *data) {
+    if (size == 0) {
+        return 0;
+    }
+
+    lfs_off_t index = lfs_ctz_index(lfs, &(lfs_off_t){size-1});
+
+    while (true) {
+        int err = cb(data, head);
+        if (err) {
+            return err;
+        }
+
+        if (index == 0) {
+            return 0;
+        }
+
+        lfs_block_t heads[2];
+        int count = 2 - (index & 1);
+        err = lfs_bd_read(lfs,
+                pcache, rcache, count*sizeof(head),
+                head, 0, &heads, count*sizeof(head));
+        heads[0] = lfs_fromle32(heads[0]);
+        heads[1] = lfs_fromle32(heads[1]);
+        if (err) {
+            return err;
+        }
+
+        for (int i = 0; i < count-1; i++) {
+            err = cb(data, heads[i]);
+            if (err) {
+                return err;
+            }
+        }
+
+        head = heads[count-1];
+        index -= count;
+    }
+}
+
+
+/// Top level file operations ///
+static int lfs_file_opencfg_(lfs_t *lfs, lfs_file_t *file,
+        const char *path, int flags,
+        const struct lfs_file_config *cfg) {
+#ifndef LFS_READONLY
+    // deorphan if we haven't yet, needed at most once after poweron
+    if ((flags & LFS_O_WRONLY) == LFS_O_WRONLY) {
+        int err = lfs_fs_forceconsistency(lfs);
+        if (err) {
+            return err;
+        }
+    }
+#else
+    LFS_ASSERT((flags & LFS_O_RDONLY) == LFS_O_RDONLY);
+#endif
+
+    // setup simple file details
+    int err;
+    file->cfg = cfg;
+    file->flags = flags;
+    file->pos = 0;
+    file->off = 0;
+    file->cache.buffer = NULL;
+
+    // allocate entry for file if it doesn't exist
+    lfs_stag_t tag = lfs_dir_find(lfs, &file->m, &path, &file->id);
+    if (tag < 0 && !(tag == LFS_ERR_NOENT && lfs_path_islast(path))) {
+        err = tag;
+        goto cleanup;
+    }
+
+    // get id, add to list of mdirs to catch update changes
+    file->type = LFS_TYPE_REG;
+    lfs_mlist_append(lfs, (struct lfs_mlist *)file);
+
+#ifdef LFS_READONLY
+    if (tag == LFS_ERR_NOENT) {
+        err = LFS_ERR_NOENT;
+        goto cleanup;
+#else
+    if (tag == LFS_ERR_NOENT) {
+        if (!(flags & LFS_O_CREAT)) {
+            err = LFS_ERR_NOENT;
+            goto cleanup;
+        }
+
+        // don't allow trailing slashes
+        if (lfs_path_isdir(path)) {
+            err = LFS_ERR_NOTDIR;
+            goto cleanup;
+        }
+
+        // check that name fits
+        lfs_size_t nlen = lfs_path_namelen(path);
+        if (nlen > lfs->name_max) {
+            err = LFS_ERR_NAMETOOLONG;
+            goto cleanup;
+        }
+
+        // get next slot and create entry to remember name
+        err = lfs_dir_commit(lfs, &file->m, LFS_MKATTRS(
+                {LFS_MKTAG(LFS_TYPE_CREATE, file->id, 0), NULL},
+                {LFS_MKTAG(LFS_TYPE_REG, file->id, nlen), path},
+                {LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0), NULL}));
+
+        // it may happen that the file name doesn't fit in the metadata blocks, e.g., a 256 byte file name will
+        // not fit in a 128 byte block.
+        err = (err == LFS_ERR_NOSPC) ? LFS_ERR_NAMETOOLONG : err;
+        if (err) {
+            goto cleanup;
+        }
+
+        tag = LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, 0);
+    } else if (flags & LFS_O_EXCL) {
+        err = LFS_ERR_EXIST;
+        goto cleanup;
+#endif
+    } else if (lfs_tag_type3(tag) != LFS_TYPE_REG) {
+        err = LFS_ERR_ISDIR;
+        goto cleanup;
+#ifndef LFS_READONLY
+    } else if (flags & LFS_O_TRUNC) {
+        // truncate if requested
+        tag = LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0);
+        file->flags |= LFS_F_DIRTY;
+#endif
+    } else {
+        // try to load what's on disk, if it's inlined we'll fix it later
+        tag = lfs_dir_get(lfs, &file->m, LFS_MKTAG(0x700, 0x3ff, 0),
+                LFS_MKTAG(LFS_TYPE_STRUCT, file->id, 8), &file->ctz);
+        if (tag < 0) {
+            err = tag;
+            goto cleanup;
+        }
+        lfs_ctz_fromle32(&file->ctz);
+    }
+
+    // fetch attrs
+    for (unsigned i = 0; i < file->cfg->attr_count; i++) {
+        // if opened for read / read-write operations
+        if ((file->flags & LFS_O_RDONLY) == LFS_O_RDONLY) {
+            lfs_stag_t res = lfs_dir_get(lfs, &file->m,
+                    LFS_MKTAG(0x7ff, 0x3ff, 0),
+                    LFS_MKTAG(LFS_TYPE_USERATTR + file->cfg->attrs[i].type,
+                        file->id, file->cfg->attrs[i].size),
+                        file->cfg->attrs[i].buffer);
+            if (res < 0 && res != LFS_ERR_NOENT) {
+                err = res;
+                goto cleanup;
+            }
+        }
+
+#ifndef LFS_READONLY
+        // if opened for write / read-write operations
+        if ((file->flags & LFS_O_WRONLY) == LFS_O_WRONLY) {
+            if (file->cfg->attrs[i].size > lfs->attr_max) {
+                err = LFS_ERR_NOSPC;
+                goto cleanup;
+            }
+
+            file->flags |= LFS_F_DIRTY;
+        }
+#endif
+    }
+
+    // allocate buffer if needed
+    if (file->cfg->buffer) {
+        file->cache.buffer = file->cfg->buffer;
+    } else {
+        file->cache.buffer = lfs_malloc(lfs->cfg->cache_size);
+        if (!file->cache.buffer) {
+            err = LFS_ERR_NOMEM;
+            goto cleanup;
+        }
+    }
+
+    // zero to avoid information leak
+    lfs_cache_zero(lfs, &file->cache);
+
+    if (lfs_tag_type3(tag) == LFS_TYPE_INLINESTRUCT) {
+        // load inline files
+        file->ctz.head = LFS_BLOCK_INLINE;
+        file->ctz.size = lfs_tag_size(tag);
+        file->flags |= LFS_F_INLINE;
+        file->cache.block = file->ctz.head;
+        file->cache.off = 0;
+        file->cache.size = lfs->cfg->cache_size;
+
+        // don't always read (may be new/trunc file)
+        if (file->ctz.size > 0) {
+            lfs_stag_t res = lfs_dir_get(lfs, &file->m,
+                    LFS_MKTAG(0x700, 0x3ff, 0),
+                    LFS_MKTAG(LFS_TYPE_STRUCT, file->id,
+                        lfs_min(file->cache.size, 0x3fe)),
+                    file->cache.buffer);
+            if (res < 0) {
+                err = res;
+                goto cleanup;
+            }
+        }
+    }
+
+    return 0;
+
+cleanup:
+    // clean up lingering resources
+#ifndef LFS_READONLY
+    file->flags |= LFS_F_ERRED;
+#endif
+    lfs_file_close_(lfs, file);
+    return err;
+}
+
+#ifndef LFS_NO_MALLOC
+static int lfs_file_open_(lfs_t *lfs, lfs_file_t *file,
+        const char *path, int flags) {
+    static const struct lfs_file_config defaults = {0};
+    int err = lfs_file_opencfg_(lfs, file, path, flags, &defaults);
+    return err;
+}
+#endif
+
+static int lfs_file_close_(lfs_t *lfs, lfs_file_t *file) {
+    int err = 0;
+#ifndef LFS_READONLY
+    // it's not safe to do anything if our file errored
+    if (!(file->flags & LFS_F_ERRED)) {
+        err = lfs_file_sync_(lfs, file);
+    }
+#endif
+
+    // remove from list of mdirs
+    lfs_mlist_remove(lfs, (struct lfs_mlist*)file);
+
+    // clean up memory
+    if (!file->cfg->buffer) {
+        lfs_free(file->cache.buffer);
+    }
+
+    return err;
+}
+
+
+#ifndef LFS_READONLY
+static int lfs_file_relocate(lfs_t *lfs, lfs_file_t *file) {
+    while (true) {
+        // just relocate what exists into new block
+        lfs_block_t nblock;
+        int err = lfs_alloc(lfs, &nblock);
+        if (err) {
+            return err;
+        }
+
+        err = lfs_bd_erase(lfs, nblock);
+        if (err) {
+            if (err == LFS_ERR_CORRUPT) {
+                goto relocate;
+            }
+            return err;
+        }
+
+        // either read from dirty cache or disk
+        for (lfs_off_t i = 0; i < file->off; i++) {
+            uint8_t data;
+            if (file->flags & LFS_F_INLINE) {
+                err = lfs_dir_getread(lfs, &file->m,
+                        // note we evict inline files before they can be dirty
+                        NULL, &file->cache, file->off-i,
+                        LFS_MKTAG(0xfff, 0x1ff, 0),
+                        LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0),
+                        i, &data, 1);
+                if (err) {
+                    return err;
+                }
+            } else {
+                err = lfs_bd_read(lfs,
+                        &file->cache, &lfs->rcache, file->off-i,
+                        file->block, i, &data, 1);
+                if (err) {
+                    return err;
+                }
+            }
+
+            err = lfs_bd_prog(lfs,
+                    &lfs->pcache, &lfs->rcache, true,
+                    nblock, i, &data, 1);
+            if (err) {
+                if (err == LFS_ERR_CORRUPT) {
+                    goto relocate;
+                }
+                return err;
+            }
+        }
+
+        // copy over new state of file
+        memcpy(file->cache.buffer, lfs->pcache.buffer, lfs->cfg->cache_size);
+        file->cache.block = lfs->pcache.block;
+        file->cache.off = lfs->pcache.off;
+        file->cache.size = lfs->pcache.size;
+        lfs_cache_zero(lfs, &lfs->pcache);
+
+        file->block = nblock;
+        file->flags |= LFS_F_WRITING;
+        return 0;
+
+relocate:
+        LFS_DEBUG("Bad block at 0x%"PRIx32, nblock);
+
+        // just clear cache and try a new block
+        lfs_cache_drop(lfs, &lfs->pcache);
+    }
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_file_outline(lfs_t *lfs, lfs_file_t *file) {
+    file->off = file->pos;
+    lfs_alloc_ckpoint(lfs);
+    int err = lfs_file_relocate(lfs, file);
+    if (err) {
+        return err;
+    }
+
+    file->flags &= ~LFS_F_INLINE;
+    return 0;
+}
+#endif
+
+static int lfs_file_flush(lfs_t *lfs, lfs_file_t *file) {
+    if (file->flags & LFS_F_READING) {
+        if (!(file->flags & LFS_F_INLINE)) {
+            lfs_cache_drop(lfs, &file->cache);
+        }
+        file->flags &= ~LFS_F_READING;
+    }
+
+#ifndef LFS_READONLY
+    if (file->flags & LFS_F_WRITING) {
+        lfs_off_t pos = file->pos;
+
+        if (!(file->flags & LFS_F_INLINE)) {
+            // copy over anything after current branch
+            lfs_file_t orig = {
+                .ctz.head = file->ctz.head,
+                .ctz.size = file->ctz.size,
+                .flags = LFS_O_RDONLY,
+                .pos = file->pos,
+                .cache = lfs->rcache,
+            };
+            lfs_cache_drop(lfs, &lfs->rcache);
+
+            while (file->pos < file->ctz.size) {
+                // copy over a byte at a time, leave it up to caching
+                // to make this efficient
+                uint8_t data;
+                lfs_ssize_t res = lfs_file_flushedread(lfs, &orig, &data, 1);
+                if (res < 0) {
+                    return res;
+                }
+
+                res = lfs_file_flushedwrite(lfs, file, &data, 1);
+                if (res < 0) {
+                    return res;
+                }
+
+                // keep our reference to the rcache in sync
+                if (lfs->rcache.block != LFS_BLOCK_NULL) {
+                    lfs_cache_drop(lfs, &orig.cache);
+                    lfs_cache_drop(lfs, &lfs->rcache);
+                }
+            }
+
+            // write out what we have
+            while (true) {
+                int err = lfs_bd_flush(lfs, &file->cache, &lfs->rcache, true);
+                if (err) {
+                    if (err == LFS_ERR_CORRUPT) {
+                        goto relocate;
+                    }
+                    return err;
+                }
+
+                break;
+
+relocate:
+                LFS_DEBUG("Bad block at 0x%"PRIx32, file->block);
+                err = lfs_file_relocate(lfs, file);
+                if (err) {
+                    return err;
+                }
+            }
+        } else {
+            file->pos = lfs_max(file->pos, file->ctz.size);
+        }
+
+        // actual file updates
+        file->ctz.head = file->block;
+        file->ctz.size = file->pos;
+        file->flags &= ~LFS_F_WRITING;
+        file->flags |= LFS_F_DIRTY;
+
+        file->pos = pos;
+    }
+#endif
+
+    return 0;
+}
+
+#ifndef LFS_READONLY
+static int lfs_file_sync_(lfs_t *lfs, lfs_file_t *file) {
+    int err = lfs_file_flush(lfs, file);
+    if (err) {
+        file->flags |= LFS_F_ERRED;
+        return err;
+    }
+
+    if ((file->flags & LFS_F_DIRTY) &&
+            !lfs_pair_isnull(file->m.pair)) {
+        // before we commit metadata, we need sync the disk to make sure
+        // data writes don't complete after metadata writes
+        if (!(file->flags & LFS_F_INLINE)) {
+            err = lfs_bd_sync(lfs, &lfs->pcache, &lfs->rcache, false);
+            if (err) {
+                return err;
+            }
+        }
+
+        // update dir entry
+        uint16_t type;
+        const void *buffer;
+        lfs_size_t size;
+        struct lfs_ctz ctz;
+        if (file->flags & LFS_F_INLINE) {
+            // inline the whole file
+            type = LFS_TYPE_INLINESTRUCT;
+            buffer = file->cache.buffer;
+            size = file->ctz.size;
+        } else {
+            // update the ctz reference
+            type = LFS_TYPE_CTZSTRUCT;
+            // copy ctz so alloc will work during a relocate
+            ctz = file->ctz;
+            lfs_ctz_tole32(&ctz);
+            buffer = &ctz;
+            size = sizeof(ctz);
+        }
+
+        // commit file data and attributes
+        err = lfs_dir_commit(lfs, &file->m, LFS_MKATTRS(
+                {LFS_MKTAG(type, file->id, size), buffer},
+                {LFS_MKTAG(LFS_FROM_USERATTRS, file->id,
+                    file->cfg->attr_count), file->cfg->attrs}));
+        if (err) {
+            file->flags |= LFS_F_ERRED;
+            return err;
+        }
+
+        file->flags &= ~LFS_F_DIRTY;
+    }
+
+    // mark any other file handles as dirty + desync
+    for (lfs_file_t *f = (lfs_file_t*)lfs->mlist; f; f = f->next) {
+        if (file != f
+                && f->type == LFS_TYPE_REG
+                && lfs_pair_cmp(f->m.pair, file->m.pair) == 0
+                && f->id == file->id) {
+            f->flags |= LFS_F_DUSTY;
+        }
+    }
+
+    file->flags &= ~LFS_F_ERRED & ~LFS_F_DUSTY;
+    return 0;
+}
+#endif
+
+static lfs_ssize_t lfs_file_flushedread(lfs_t *lfs, lfs_file_t *file,
+        void *buffer, lfs_size_t size) {
+    uint8_t *data = buffer;
+    lfs_size_t nsize = size;
+
+    if (file->pos >= file->ctz.size) {
+        // eof if past end
+        return 0;
+    }
+
+    size = lfs_min(size, file->ctz.size - file->pos);
+    nsize = size;
+
+    while (nsize > 0) {
+        // check if we need a new block
+        if (!(file->flags & LFS_F_READING) ||
+                file->off == lfs->cfg->block_size) {
+            if (!(file->flags & LFS_F_INLINE)) {
+                int err = lfs_ctz_find(lfs, NULL, &file->cache,
+                        file->ctz.head, file->ctz.size,
+                        file->pos, &file->block, &file->off);
+                if (err) {
+                    return err;
+                }
+            } else {
+                file->block = LFS_BLOCK_INLINE;
+                file->off = file->pos;
+            }
+
+            file->flags |= LFS_F_READING;
+        }
+
+        // read as much as we can in current block
+        lfs_size_t diff = lfs_min(nsize, lfs->cfg->block_size - file->off);
+        if (file->flags & LFS_F_INLINE) {
+            int err = lfs_dir_getread(lfs, &file->m,
+                    NULL, &file->cache, lfs->cfg->block_size,
+                    LFS_MKTAG(0xfff, 0x1ff, 0),
+                    LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0),
+                    file->off, data, diff);
+            if (err) {
+                return err;
+            }
+        } else {
+            int err = lfs_bd_read(lfs,
+                    NULL, &file->cache, lfs->cfg->block_size,
+                    file->block, file->off, data, diff);
+            if (err) {
+                return err;
+            }
+        }
+
+        file->pos += diff;
+        file->off += diff;
+        data += diff;
+        nsize -= diff;
+    }
+
+    return size;
+}
+
+static lfs_ssize_t lfs_file_read_(lfs_t *lfs, lfs_file_t *file,
+        void *buffer, lfs_size_t size) {
+    LFS_ASSERT((file->flags & LFS_O_RDONLY) == LFS_O_RDONLY);
+
+#ifndef LFS_READONLY
+    if (file->flags & LFS_F_WRITING) {
+        // flush out any writes
+        int err = lfs_file_flush(lfs, file);
+        if (err) {
+            return err;
+        }
+    }
+#endif
+
+    return lfs_file_flushedread(lfs, file, buffer, size);
+}
+
+
+#ifndef LFS_READONLY
+static lfs_ssize_t lfs_file_flushedwrite(lfs_t *lfs, lfs_file_t *file,
+        const void *buffer, lfs_size_t size) {
+    const uint8_t *data = buffer;
+    lfs_size_t nsize = size;
+
+    if ((file->flags & LFS_F_INLINE) &&
+            lfs_max(file->pos+nsize, file->ctz.size) > lfs->inline_max) {
+        // inline file doesn't fit anymore
+        int err = lfs_file_outline(lfs, file);
+        if (err) {
+            file->flags |= LFS_F_ERRED;
+            return err;
+        }
+    }
+
+    while (nsize > 0) {
+        // check if we need a new block
+        if (!(file->flags & LFS_F_WRITING) ||
+                file->off == lfs->cfg->block_size) {
+            if (!(file->flags & LFS_F_INLINE)) {
+                if (!(file->flags & LFS_F_WRITING) && file->pos > 0) {
+                    // find out which block we're extending from
+                    int err = lfs_ctz_find(lfs, NULL, &file->cache,
+                            file->ctz.head, file->ctz.size,
+                            file->pos-1, &file->block, &(lfs_off_t){0});
+                    if (err) {
+                        file->flags |= LFS_F_ERRED;
+                        return err;
+                    }
+
+                    // mark cache as dirty since we may have read data into it
+                    lfs_cache_zero(lfs, &file->cache);
+                }
+
+                // extend file with new blocks
+                lfs_alloc_ckpoint(lfs);
+                int err = lfs_ctz_extend(lfs, &file->cache, &lfs->rcache,
+                        file->block, file->pos,
+                        &file->block, &file->off);
+                if (err) {
+                    file->flags |= LFS_F_ERRED;
+                    return err;
+                }
+            } else {
+                file->block = LFS_BLOCK_INLINE;
+                file->off = file->pos;
+            }
+
+            file->flags |= LFS_F_WRITING;
+        }
+
+        // program as much as we can in current block
+        lfs_size_t diff = lfs_min(nsize, lfs->cfg->block_size - file->off);
+        while (true) {
+            int err = lfs_bd_prog(lfs, &file->cache, &lfs->rcache, true,
+                    file->block, file->off, data, diff);
+            if (err) {
+                if (err == LFS_ERR_CORRUPT) {
+                    goto relocate;
+                }
+                file->flags |= LFS_F_ERRED;
+                return err;
+            }
+
+            break;
+relocate:
+            err = lfs_file_relocate(lfs, file);
+            if (err) {
+                file->flags |= LFS_F_ERRED;
+                return err;
+            }
+        }
+
+        file->pos += diff;
+        file->off += diff;
+        data += diff;
+        nsize -= diff;
+
+        lfs_alloc_ckpoint(lfs);
+    }
+
+    return size;
+}
+
+static lfs_ssize_t lfs_file_write_(lfs_t *lfs, lfs_file_t *file,
+        const void *buffer, lfs_size_t size) {
+    LFS_ASSERT((file->flags & LFS_O_WRONLY) == LFS_O_WRONLY);
+
+    if (file->flags & LFS_F_READING) {
+        // drop any reads
+        int err = lfs_file_flush(lfs, file);
+        if (err) {
+            return err;
+        }
+    }
+
+    if ((file->flags & LFS_O_APPEND) && file->pos < file->ctz.size) {
+        file->pos = file->ctz.size;
+    }
+
+    if (file->pos + size > lfs->file_max) {
+        // Larger than file limit?
+        return LFS_ERR_FBIG;
+    }
+
+    if (!(file->flags & LFS_F_WRITING) && file->pos > file->ctz.size) {
+        // fill with zeros
+        lfs_off_t pos = file->pos;
+        file->pos = file->ctz.size;
+
+        while (file->pos < pos) {
+            lfs_ssize_t res = lfs_file_flushedwrite(lfs, file, &(uint8_t){0}, 1);
+            if (res < 0) {
+                return res;
+            }
+        }
+    }
+
+    lfs_ssize_t nsize = lfs_file_flushedwrite(lfs, file, buffer, size);
+    if (nsize < 0) {
+        return nsize;
+    }
+
+    file->flags &= ~LFS_F_ERRED & ~LFS_F_DUSTY;
+    return nsize;
+}
+#endif
+
+static lfs_soff_t lfs_file_seek_(lfs_t *lfs, lfs_file_t *file,
+        lfs_soff_t off, int whence) {
+    // find new pos
+    //
+    // fortunately for us, littlefs is limited to 31-bit file sizes, so we
+    // don't have to worry too much about integer overflow
+    lfs_off_t npos = file->pos;
+    if (whence == LFS_SEEK_SET) {
+        npos = off;
+    } else if (whence == LFS_SEEK_CUR) {
+        npos = file->pos + (lfs_off_t)off;
+    } else if (whence == LFS_SEEK_END) {
+        npos = (lfs_off_t)lfs_file_size_(lfs, file) + (lfs_off_t)off;
+    }
+
+    if (npos > lfs->file_max) {
+        // file position out of range
+        return LFS_ERR_INVAL;
+    }
+
+    if (file->pos == npos) {
+        // noop - position has not changed
+        return npos;
+    }
+
+    // if we're only reading and our new offset is still in the file's cache
+    // we can avoid flushing and needing to reread the data
+    if ((file->flags & LFS_F_READING)
+            && file->off != lfs->cfg->block_size) {
+        int oindex = lfs_ctz_index(lfs, &(lfs_off_t){file->pos});
+        lfs_off_t noff = npos;
+        int nindex = lfs_ctz_index(lfs, &noff);
+        if (oindex == nindex
+                && noff >= file->cache.off
+                && noff < file->cache.off + file->cache.size) {
+            file->pos = npos;
+            file->off = noff;
+            return npos;
+        }
+    }
+
+    // write out everything beforehand, may be noop if rdonly
+    int err = lfs_file_flush(lfs, file);
+    if (err) {
+        return err;
+    }
+
+    // update pos
+    file->pos = npos;
+    return npos;
+}
+
+#ifndef LFS_READONLY
+static int lfs_file_truncate_(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
+    LFS_ASSERT((file->flags & LFS_O_WRONLY) == LFS_O_WRONLY);
+
+    if (size > LFS_FILE_MAX) {
+        return LFS_ERR_INVAL;
+    }
+
+    lfs_off_t pos = file->pos;
+    lfs_off_t oldsize = lfs_file_size_(lfs, file);
+    if (size < oldsize) {
+        // revert to inline file?
+        if (size <= lfs->inline_max) {
+            // flush+seek to head
+            lfs_soff_t res = lfs_file_seek_(lfs, file, 0, LFS_SEEK_SET);
+            if (res < 0) {
+                return (int)res;
+            }
+
+            // read our data into rcache temporarily
+            lfs_cache_drop(lfs, &lfs->rcache);
+            res = lfs_file_flushedread(lfs, file,
+                    lfs->rcache.buffer, size);
+            if (res < 0) {
+                return (int)res;
+            }
+
+            file->ctz.head = LFS_BLOCK_INLINE;
+            file->ctz.size = size;
+            file->flags |= LFS_F_DIRTY | LFS_F_READING | LFS_F_INLINE;
+            file->cache.block = file->ctz.head;
+            file->cache.off = 0;
+            file->cache.size = lfs->cfg->cache_size;
+            memcpy(file->cache.buffer, lfs->rcache.buffer, size);
+
+        } else {
+            // need to flush since directly changing metadata
+            int err = lfs_file_flush(lfs, file);
+            if (err) {
+                return err;
+            }
+
+            // lookup new head in ctz skip list
+            err = lfs_ctz_find(lfs, NULL, &file->cache,
+                    file->ctz.head, file->ctz.size,
+                    size-1, &file->block, &(lfs_off_t){0});
+            if (err) {
+                return err;
+            }
+
+            // need to set pos/block/off consistently so seeking back to
+            // the old position does not get confused
+            file->pos = size;
+            file->ctz.head = file->block;
+            file->ctz.size = size;
+            file->flags |= LFS_F_DIRTY | LFS_F_READING;
+        }
+    } else if (size > oldsize) {
+        // flush+seek if not already at end
+        lfs_soff_t res = lfs_file_seek_(lfs, file, 0, LFS_SEEK_END);
+        if (res < 0) {
+            return (int)res;
+        }
+
+        // fill with zeros
+        while (file->pos < size) {
+            res = lfs_file_write_(lfs, file, &(uint8_t){0}, 1);
+            if (res < 0) {
+                return (int)res;
+            }
+        }
+    }
+
+    // restore pos
+    lfs_soff_t res = lfs_file_seek_(lfs, file, pos, LFS_SEEK_SET);
+    if (res < 0) {
+      return (int)res;
+    }
+
+    return 0;
+}
+#endif
+
+static lfs_soff_t lfs_file_tell_(lfs_t *lfs, lfs_file_t *file) {
+    (void)lfs;
+    return file->pos;
+}
+
+static int lfs_file_rewind_(lfs_t *lfs, lfs_file_t *file) {
+    lfs_soff_t res = lfs_file_seek_(lfs, file, 0, LFS_SEEK_SET);
+    if (res < 0) {
+        return (int)res;
+    }
+
+    return 0;
+}
+
+static lfs_soff_t lfs_file_size_(lfs_t *lfs, lfs_file_t *file) {
+    (void)lfs;
+
+#ifndef LFS_READONLY
+    if (file->flags & LFS_F_WRITING) {
+        return lfs_max(file->pos, file->ctz.size);
+    }
+#endif
+
+    return file->ctz.size;
+}
+
+
+/// General fs operations ///
+static int lfs_stat_(lfs_t *lfs, const char *path, struct lfs_info *info) {
+    lfs_mdir_t cwd;
+    lfs_stag_t tag = lfs_dir_find(lfs, &cwd, &path, NULL);
+    if (tag < 0) {
+        return (int)tag;
+    }
+
+    // only allow trailing slashes on dirs
+    if (strchr(path, '/') != NULL
+            && lfs_tag_type3(tag) != LFS_TYPE_DIR) {
+        return LFS_ERR_NOTDIR;
+    }
+
+    return lfs_dir_getinfo(lfs, &cwd, lfs_tag_id(tag), info);
+}
+
+#ifndef LFS_READONLY
+static int lfs_remove_(lfs_t *lfs, const char *path) {
+    // deorphan if we haven't yet, needed at most once after poweron
+    int err = lfs_fs_forceconsistency(lfs);
+    if (err) {
+        return err;
+    }
+
+    lfs_mdir_t cwd;
+    lfs_stag_t tag = lfs_dir_find(lfs, &cwd, &path, NULL);
+    if (tag < 0 || lfs_tag_id(tag) == 0x3ff) {
+        return (tag < 0) ? (int)tag : LFS_ERR_INVAL;
+    }
+
+    struct lfs_mlist dir;
+    dir.next = lfs->mlist;
+    if (lfs_tag_type3(tag) == LFS_TYPE_DIR) {
+        // must be empty before removal
+        lfs_block_t pair[2];
+        lfs_stag_t res = lfs_dir_get(lfs, &cwd, LFS_MKTAG(0x700, 0x3ff, 0),
+                LFS_MKTAG(LFS_TYPE_STRUCT, lfs_tag_id(tag), 8), pair);
+        if (res < 0) {
+            return (int)res;
+        }
+        lfs_pair_fromle32(pair);
+
+        err = lfs_dir_fetch(lfs, &dir.m, pair);
+        if (err) {
+            return err;
+        }
+
+        if (dir.m.count > 0 || dir.m.split) {
+            return LFS_ERR_NOTEMPTY;
+        }
+
+        // mark fs as orphaned
+        err = lfs_fs_preporphans(lfs, +1);
+        if (err) {
+            return err;
+        }
+
+        // I know it's crazy but yes, dir can be changed by our parent's
+        // commit (if predecessor is child)
+        dir.type = 0;
+        dir.id = 0;
+        lfs->mlist = &dir;
+    }
+
+    // delete the entry
+    err = lfs_dir_commit(lfs, &cwd, LFS_MKATTRS(
+            {LFS_MKTAG(LFS_TYPE_DELETE, lfs_tag_id(tag), 0), NULL}));
+    if (err) {
+        lfs->mlist = dir.next;
+        return err;
+    }
+
+    lfs->mlist = dir.next;
+    if (lfs_gstate_hasorphans(&lfs->gstate)) {
+        LFS_ASSERT(lfs_tag_type3(tag) == LFS_TYPE_DIR);
+
+        // fix orphan
+        err = lfs_fs_preporphans(lfs, -1);
+        if (err) {
+            return err;
+        }
+
+        err = lfs_fs_pred(lfs, dir.m.pair, &cwd);
+        if (err) {
+            return err;
+        }
+
+        err = lfs_dir_drop(lfs, &cwd, &dir.m);
+        if (err) {
+            return err;
+        }
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_rename_(lfs_t *lfs, const char *oldpath, const char *newpath) {
+    // deorphan if we haven't yet, needed at most once after poweron
+    int err = lfs_fs_forceconsistency(lfs);
+    if (err) {
+        return err;
+    }
+
+    // find old entry
+    lfs_mdir_t oldcwd;
+    lfs_stag_t oldtag = lfs_dir_find(lfs, &oldcwd, &oldpath, NULL);
+    if (oldtag < 0 || lfs_tag_id(oldtag) == 0x3ff) {
+        return (oldtag < 0) ? (int)oldtag : LFS_ERR_INVAL;
+    }
+
+    // find new entry
+    lfs_mdir_t newcwd;
+    uint16_t newid;
+    lfs_stag_t prevtag = lfs_dir_find(lfs, &newcwd, &newpath, &newid);
+    if ((prevtag < 0 || lfs_tag_id(prevtag) == 0x3ff) &&
+            !(prevtag == LFS_ERR_NOENT && lfs_path_islast(newpath))) {
+        return (prevtag < 0) ? (int)prevtag : LFS_ERR_INVAL;
+    }
+
+    // if we're in the same pair there's a few special cases...
+    bool samepair = (lfs_pair_cmp(oldcwd.pair, newcwd.pair) == 0);
+    uint16_t newoldid = lfs_tag_id(oldtag);
+
+    struct lfs_mlist prevdir;
+    prevdir.next = lfs->mlist;
+    if (prevtag == LFS_ERR_NOENT) {
+        // if we're a file, don't allow trailing slashes
+        if (lfs_path_isdir(newpath)
+                && lfs_tag_type3(oldtag) != LFS_TYPE_DIR) {
+            return LFS_ERR_NOTDIR;
+        }
+
+        // check that name fits
+        lfs_size_t nlen = lfs_path_namelen(newpath);
+        if (nlen > lfs->name_max) {
+            return LFS_ERR_NAMETOOLONG;
+        }
+
+        // there is a small chance we are being renamed in the same
+        // directory/ to an id less than our old id, the global update
+        // to handle this is a bit messy
+        if (samepair && newid <= newoldid) {
+            newoldid += 1;
+        }
+    } else if (lfs_tag_type3(prevtag) != lfs_tag_type3(oldtag)) {
+        return (lfs_tag_type3(prevtag) == LFS_TYPE_DIR)
+                ? LFS_ERR_ISDIR
+                : LFS_ERR_NOTDIR;
+    } else if (samepair && newid == newoldid) {
+        // we're renaming to ourselves??
+        return 0;
+    } else if (lfs_tag_type3(prevtag) == LFS_TYPE_DIR) {
+        // must be empty before removal
+        lfs_block_t prevpair[2];
+        lfs_stag_t res = lfs_dir_get(lfs, &newcwd, LFS_MKTAG(0x700, 0x3ff, 0),
+                LFS_MKTAG(LFS_TYPE_STRUCT, newid, 8), prevpair);
+        if (res < 0) {
+            return (int)res;
+        }
+        lfs_pair_fromle32(prevpair);
+
+        // must be empty before removal
+        err = lfs_dir_fetch(lfs, &prevdir.m, prevpair);
+        if (err) {
+            return err;
+        }
+
+        if (prevdir.m.count > 0 || prevdir.m.split) {
+            return LFS_ERR_NOTEMPTY;
+        }
+
+        // mark fs as orphaned
+        err = lfs_fs_preporphans(lfs, +1);
+        if (err) {
+            return err;
+        }
+
+        // I know it's crazy but yes, dir can be changed by our parent's
+        // commit (if predecessor is child)
+        prevdir.type = 0;
+        prevdir.id = 0;
+        lfs->mlist = &prevdir;
+    }
+
+    if (!samepair) {
+        lfs_fs_prepmove(lfs, newoldid, oldcwd.pair);
+    }
+
+    // move over all attributes
+    err = lfs_dir_commit(lfs, &newcwd, LFS_MKATTRS(
+            {LFS_MKTAG_IF(prevtag != LFS_ERR_NOENT,
+                LFS_TYPE_DELETE, newid, 0), NULL},
+            {LFS_MKTAG(LFS_TYPE_CREATE, newid, 0), NULL},
+            {LFS_MKTAG(lfs_tag_type3(oldtag),
+                newid, lfs_path_namelen(newpath)), newpath},
+            {LFS_MKTAG(LFS_FROM_MOVE, newid, lfs_tag_id(oldtag)), &oldcwd},
+            {LFS_MKTAG_IF(samepair,
+                LFS_TYPE_DELETE, newoldid, 0), NULL}));
+    if (err) {
+        lfs->mlist = prevdir.next;
+        return err;
+    }
+
+    // let commit clean up after move (if we're different! otherwise move
+    // logic already fixed it for us)
+    if (!samepair && lfs_gstate_hasmove(&lfs->gstate)) {
+        // prep gstate and delete move id
+        lfs_fs_prepmove(lfs, 0x3ff, NULL);
+        err = lfs_dir_commit(lfs, &oldcwd, LFS_MKATTRS(
+                {LFS_MKTAG(LFS_TYPE_DELETE, lfs_tag_id(oldtag), 0), NULL}));
+        if (err) {
+            lfs->mlist = prevdir.next;
+            return err;
+        }
+    }
+
+    lfs->mlist = prevdir.next;
+    if (lfs_gstate_hasorphans(&lfs->gstate)) {
+        LFS_ASSERT(prevtag != LFS_ERR_NOENT
+                && lfs_tag_type3(prevtag) == LFS_TYPE_DIR);
+
+        // fix orphan
+        err = lfs_fs_preporphans(lfs, -1);
+        if (err) {
+            return err;
+        }
+
+        err = lfs_fs_pred(lfs, prevdir.m.pair, &newcwd);
+        if (err) {
+            return err;
+        }
+
+        err = lfs_dir_drop(lfs, &newcwd, &prevdir.m);
+        if (err) {
+            return err;
+        }
+    }
+
+    return 0;
+}
+#endif
+
+static lfs_ssize_t lfs_getattr_(lfs_t *lfs, const char *path,
+        uint8_t type, void *buffer, lfs_size_t size) {
+    lfs_mdir_t cwd;
+    lfs_stag_t tag = lfs_dir_find(lfs, &cwd, &path, NULL);
+    if (tag < 0) {
+        return tag;
+    }
+
+    uint16_t id = lfs_tag_id(tag);
+    if (id == 0x3ff) {
+        // special case for root
+        id = 0;
+        int err = lfs_dir_fetch(lfs, &cwd, lfs->root);
+        if (err) {
+            return err;
+        }
+    }
+
+    tag = lfs_dir_get(lfs, &cwd, LFS_MKTAG(0x7ff, 0x3ff, 0),
+            LFS_MKTAG(LFS_TYPE_USERATTR + type,
+                id, lfs_min(size, lfs->attr_max)),
+            buffer);
+    if (tag < 0) {
+        if (tag == LFS_ERR_NOENT) {
+            return LFS_ERR_NOATTR;
+        }
+
+        return tag;
+    }
+
+    return lfs_tag_size(tag);
+}
+
+#ifndef LFS_READONLY
+static int lfs_commitattr(lfs_t *lfs, const char *path,
+        uint8_t type, const void *buffer, lfs_size_t size) {
+    lfs_mdir_t cwd;
+    lfs_stag_t tag = lfs_dir_find(lfs, &cwd, &path, NULL);
+    if (tag < 0) {
+        return tag;
+    }
+
+    uint16_t id = lfs_tag_id(tag);
+    if (id == 0x3ff) {
+        // special case for root
+        id = 0;
+        int err = lfs_dir_fetch(lfs, &cwd, lfs->root);
+        if (err) {
+            return err;
+        }
+    }
+
+    return lfs_dir_commit(lfs, &cwd, LFS_MKATTRS(
+            {LFS_MKTAG(LFS_TYPE_USERATTR + type, id, size), buffer}));
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_setattr_(lfs_t *lfs, const char *path,
+        uint8_t type, const void *buffer, lfs_size_t size) {
+    if (size > lfs->attr_max) {
+        return LFS_ERR_NOSPC;
+    }
+
+    return lfs_commitattr(lfs, path, type, buffer, size);
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_removeattr_(lfs_t *lfs, const char *path, uint8_t type) {
+    return lfs_commitattr(lfs, path, type, NULL, 0x3ff);
+}
+#endif
+
+
+/// Filesystem operations ///
+
+// compile time checks, see lfs.h for why these limits exist
+#if LFS_NAME_MAX > 1022
+#error "Invalid LFS_NAME_MAX, must be <= 1022"
+#endif
+
+#if LFS_FILE_MAX > 2147483647
+#error "Invalid LFS_FILE_MAX, must be <= 2147483647"
+#endif
+
+#if LFS_ATTR_MAX > 1022
+#error "Invalid LFS_ATTR_MAX, must be <= 1022"
+#endif
+
+// common filesystem initialization
+static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
+    lfs->cfg = cfg;
+    lfs->block_count = cfg->block_count;  // May be 0
+    int err = 0;
+
+#ifdef LFS_MULTIVERSION
+    // this driver only supports minor version < current minor version
+    LFS_ASSERT(!lfs->cfg->disk_version || (
+            (0xffff & (lfs->cfg->disk_version >> 16))
+                    == LFS_DISK_VERSION_MAJOR
+                && (0xffff & (lfs->cfg->disk_version >> 0))
+                    <= LFS_DISK_VERSION_MINOR));
+#endif
+
+    // check that bool is a truthy-preserving type
+    //
+    // note the most common reason for this failure is a before-c99 compiler,
+    // which littlefs currently does not support
+    LFS_ASSERT((bool)0x80000000);
+
+    // check that the required io functions are provided
+    LFS_ASSERT(lfs->cfg->read != NULL);
+#ifndef LFS_READONLY
+    LFS_ASSERT(lfs->cfg->prog != NULL);
+    LFS_ASSERT(lfs->cfg->erase != NULL);
+    LFS_ASSERT(lfs->cfg->sync != NULL);
+#endif
+
+    // validate that the lfs-cfg sizes were initiated properly before
+    // performing any arithmetic logics with them
+    LFS_ASSERT(lfs->cfg->read_size != 0);
+    LFS_ASSERT(lfs->cfg->prog_size != 0);
+    LFS_ASSERT(lfs->cfg->cache_size != 0);
+
+    // check that block size is a multiple of cache size is a multiple
+    // of prog and read sizes
+    LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->read_size == 0);
+    LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->prog_size == 0);
+    LFS_ASSERT(lfs->cfg->block_size % lfs->cfg->cache_size == 0);
+
+    // check that the block size is large enough to fit all ctz pointers
+    LFS_ASSERT(lfs->cfg->block_size >= 128);
+    // this is the exact calculation for all ctz pointers, if this fails
+    // and the simpler assert above does not, math must be broken
+    LFS_ASSERT(4*lfs_npw2(0xffffffff / (lfs->cfg->block_size-2*4))
+            <= lfs->cfg->block_size);
+
+    // block_cycles = 0 is no longer supported.
+    //
+    // block_cycles is the number of erase cycles before littlefs evicts
+    // metadata logs as a part of wear leveling. Suggested values are in the
+    // range of 100-1000, or set block_cycles to -1 to disable block-level
+    // wear-leveling.
+    LFS_ASSERT(lfs->cfg->block_cycles != 0);
+
+    // check that compact_thresh makes sense
+    //
+    // metadata can't be compacted below block_size/2, and metadata can't
+    // exceed a block_size
+    LFS_ASSERT(lfs->cfg->compact_thresh == 0
+            || lfs->cfg->compact_thresh >= lfs->cfg->block_size/2);
+    LFS_ASSERT(lfs->cfg->compact_thresh == (lfs_size_t)-1
+            || lfs->cfg->compact_thresh <= lfs->cfg->block_size);
+
+    // check that metadata_max is a multiple of read_size and prog_size,
+    // and a factor of the block_size
+    LFS_ASSERT(!lfs->cfg->metadata_max
+            || lfs->cfg->metadata_max % lfs->cfg->read_size == 0);
+    LFS_ASSERT(!lfs->cfg->metadata_max
+            || lfs->cfg->metadata_max % lfs->cfg->prog_size == 0);
+    LFS_ASSERT(!lfs->cfg->metadata_max
+            || lfs->cfg->block_size % lfs->cfg->metadata_max == 0);
+
+    // setup read cache
+    if (lfs->cfg->read_buffer) {
+        lfs->rcache.buffer = lfs->cfg->read_buffer;
+    } else {
+        lfs->rcache.buffer = lfs_malloc(lfs->cfg->cache_size);
+        if (!lfs->rcache.buffer) {
+            err = LFS_ERR_NOMEM;
+            goto cleanup;
+        }
+    }
+
+    // setup program cache
+    if (lfs->cfg->prog_buffer) {
+        lfs->pcache.buffer = lfs->cfg->prog_buffer;
+    } else {
+        lfs->pcache.buffer = lfs_malloc(lfs->cfg->cache_size);
+        if (!lfs->pcache.buffer) {
+            err = LFS_ERR_NOMEM;
+            goto cleanup;
+        }
+    }
+
+    // zero to avoid information leaks
+    lfs_cache_zero(lfs, &lfs->rcache);
+    lfs_cache_zero(lfs, &lfs->pcache);
+
+    // setup lookahead buffer, note mount finishes initializing this after
+    // we establish a decent pseudo-random seed
+    LFS_ASSERT(lfs->cfg->lookahead_size > 0);
+    if (lfs->cfg->lookahead_buffer) {
+        lfs->lookahead.buffer = lfs->cfg->lookahead_buffer;
+    } else {
+        lfs->lookahead.buffer = lfs_malloc(lfs->cfg->lookahead_size);
+        if (!lfs->lookahead.buffer) {
+            err = LFS_ERR_NOMEM;
+            goto cleanup;
+        }
+    }
+
+    // check that the size limits are sane
+    LFS_ASSERT(lfs->cfg->name_max <= LFS_NAME_MAX);
+    lfs->name_max = lfs->cfg->name_max;
+    if (!lfs->name_max) {
+        lfs->name_max = LFS_NAME_MAX;
+    }
+
+    LFS_ASSERT(lfs->cfg->file_max <= LFS_FILE_MAX);
+    lfs->file_max = lfs->cfg->file_max;
+    if (!lfs->file_max) {
+        lfs->file_max = LFS_FILE_MAX;
+    }
+
+    LFS_ASSERT(lfs->cfg->attr_max <= LFS_ATTR_MAX);
+    lfs->attr_max = lfs->cfg->attr_max;
+    if (!lfs->attr_max) {
+        lfs->attr_max = LFS_ATTR_MAX;
+    }
+
+    LFS_ASSERT(lfs->cfg->metadata_max <= lfs->cfg->block_size);
+
+    LFS_ASSERT(lfs->cfg->inline_max == (lfs_size_t)-1
+            || lfs->cfg->inline_max <= lfs->cfg->cache_size);
+    LFS_ASSERT(lfs->cfg->inline_max == (lfs_size_t)-1
+            || lfs->cfg->inline_max <= lfs->attr_max);
+    LFS_ASSERT(lfs->cfg->inline_max == (lfs_size_t)-1
+            || lfs->cfg->inline_max <= ((lfs->cfg->metadata_max)
+                ? lfs->cfg->metadata_max
+                : lfs->cfg->block_size)/8);
+    lfs->inline_max = lfs->cfg->inline_max;
+    if (lfs->inline_max == (lfs_size_t)-1) {
+        lfs->inline_max = 0;
+    } else if (lfs->inline_max == 0) {
+        lfs->inline_max = lfs_min(
+                lfs->cfg->cache_size,
+                lfs_min(
+                    lfs->attr_max,
+                    ((lfs->cfg->metadata_max)
+                        ? lfs->cfg->metadata_max
+                        : lfs->cfg->block_size)/8));
+    }
+
+    // setup default state
+    lfs->root[0] = LFS_BLOCK_NULL;
+    lfs->root[1] = LFS_BLOCK_NULL;
+    lfs->mlist = NULL;
+    lfs->seed = 0;
+    lfs->gdisk = (lfs_gstate_t){0};
+    lfs->gstate = (lfs_gstate_t){0};
+    lfs->gdelta = (lfs_gstate_t){0};
+#ifdef LFS_MIGRATE
+    lfs->lfs1 = NULL;
+#endif
+
+    return 0;
+
+cleanup:
+    lfs_deinit(lfs);
+    return err;
+}
+
+static int lfs_deinit(lfs_t *lfs) {
+    // free allocated memory
+    if (!lfs->cfg->read_buffer) {
+        lfs_free(lfs->rcache.buffer);
+    }
+
+    if (!lfs->cfg->prog_buffer) {
+        lfs_free(lfs->pcache.buffer);
+    }
+
+    if (!lfs->cfg->lookahead_buffer) {
+        lfs_free(lfs->lookahead.buffer);
+    }
+
+    return 0;
+}
+
+
+
+#ifndef LFS_READONLY
+static int lfs_format_(lfs_t *lfs, const struct lfs_config *cfg) {
+    int err = 0;
+    {
+        err = lfs_init(lfs, cfg);
+        if (err) {
+            return err;
+        }
+
+        LFS_ASSERT(cfg->block_count != 0);
+
+        // create free lookahead
+        memset(lfs->lookahead.buffer, 0, lfs->cfg->lookahead_size);
+        lfs->lookahead.start = 0;
+        lfs->lookahead.size = lfs_min(8*lfs->cfg->lookahead_size,
+                lfs->block_count);
+        lfs->lookahead.next = 0;
+        lfs_alloc_ckpoint(lfs);
+
+        // create root dir
+        lfs_mdir_t root;
+        err = lfs_dir_alloc(lfs, &root);
+        if (err) {
+            goto cleanup;
+        }
+
+        // write one superblock
+        lfs_superblock_t superblock = {
+            .version     = lfs_fs_disk_version(lfs),
+            .block_size  = lfs->cfg->block_size,
+            .block_count = lfs->block_count,
+            .name_max    = lfs->name_max,
+            .file_max    = lfs->file_max,
+            .attr_max    = lfs->attr_max,
+        };
+
+        lfs_superblock_tole32(&superblock);
+        err = lfs_dir_commit(lfs, &root, LFS_MKATTRS(
+                {LFS_MKTAG(LFS_TYPE_CREATE, 0, 0), NULL},
+                {LFS_MKTAG(LFS_TYPE_SUPERBLOCK, 0, 8), "littlefs"},
+                {LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)),
+                    &superblock}));
+        if (err) {
+            goto cleanup;
+        }
+
+        // force compaction to prevent accidentally mounting any
+        // older version of littlefs that may live on disk
+        root.erased = false;
+        err = lfs_dir_commit(lfs, &root, NULL, 0);
+        if (err) {
+            goto cleanup;
+        }
+
+        // sanity check that fetch works
+        err = lfs_dir_fetch(lfs, &root, (const lfs_block_t[2]){0, 1});
+        if (err) {
+            goto cleanup;
+        }
+    }
+
+cleanup:
+    lfs_deinit(lfs);
+    return err;
+
+}
+#endif
+
+struct lfs_tortoise_t {
+    lfs_block_t pair[2];
+    lfs_size_t i;
+    lfs_size_t period;
+};
+
+static int lfs_tortoise_detectcycles(
+    const lfs_mdir_t *dir, struct lfs_tortoise_t *tortoise) {
+    // detect cycles with Brent's algorithm
+    if (lfs_pair_issync(dir->tail, tortoise->pair)) {
+        LFS_WARN("Cycle detected in tail list");
+        return LFS_ERR_CORRUPT;
+    }
+    if (tortoise->i == tortoise->period) {
+        tortoise->pair[0] = dir->tail[0];
+        tortoise->pair[1] = dir->tail[1];
+        tortoise->i = 0;
+        tortoise->period *= 2;
+    }
+    tortoise->i += 1;
+
+    return LFS_ERR_OK;
+}
+
+static int lfs_mount_(lfs_t *lfs, const struct lfs_config *cfg) {
+    int err = lfs_init(lfs, cfg);
+    if (err) {
+        return err;
+    }
+
+    // scan directory blocks for superblock and any global updates
+    lfs_mdir_t dir = {.tail = {0, 1}};
+    struct lfs_tortoise_t tortoise = {
+        .pair = {LFS_BLOCK_NULL, LFS_BLOCK_NULL},
+        .i = 1,
+        .period = 1,
+    };
+    while (!lfs_pair_isnull(dir.tail)) {
+        err = lfs_tortoise_detectcycles(&dir, &tortoise);
+        if (err < 0) {
+            goto cleanup;
+        }
+
+        // fetch next block in tail list
+        lfs_stag_t tag = lfs_dir_fetchmatch(lfs, &dir, dir.tail,
+                LFS_MKTAG(0x7ff, 0x3ff, 0),
+                LFS_MKTAG(LFS_TYPE_SUPERBLOCK, 0, 8),
+                NULL,
+                lfs_dir_find_match, &(struct lfs_dir_find_match){
+                    lfs, "littlefs", 8});
+        if (tag < 0) {
+            err = tag;
+            goto cleanup;
+        }
+
+        // has superblock?
+        if (tag && !lfs_tag_isdelete(tag)) {
+            // update root
+            lfs->root[0] = dir.pair[0];
+            lfs->root[1] = dir.pair[1];
+
+            // grab superblock
+            lfs_superblock_t superblock;
+            tag = lfs_dir_get(lfs, &dir, LFS_MKTAG(0x7ff, 0x3ff, 0),
+                    LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)),
+                    &superblock);
+            if (tag < 0) {
+                err = tag;
+                goto cleanup;
+            }
+            lfs_superblock_fromle32(&superblock);
+
+            // check version
+            uint16_t major_version = (0xffff & (superblock.version >> 16));
+            uint16_t minor_version = (0xffff & (superblock.version >>  0));
+            if (major_version != lfs_fs_disk_version_major(lfs)
+                    || minor_version > lfs_fs_disk_version_minor(lfs)) {
+                LFS_ERROR("Invalid version "
+                        "v%"PRIu16".%"PRIu16" != v%"PRIu16".%"PRIu16,
+                        major_version,
+                        minor_version,
+                        lfs_fs_disk_version_major(lfs),
+                        lfs_fs_disk_version_minor(lfs));
+                err = LFS_ERR_INVAL;
+                goto cleanup;
+            }
+
+            // found older minor version? set an in-device only bit in the
+            // gstate so we know we need to rewrite the superblock before
+            // the first write
+            bool needssuperblock = false;
+            if (minor_version < lfs_fs_disk_version_minor(lfs)) {
+                LFS_DEBUG("Found older minor version "
+                        "v%"PRIu16".%"PRIu16" < v%"PRIu16".%"PRIu16,
+                        major_version,
+                        minor_version,
+                        lfs_fs_disk_version_major(lfs),
+                        lfs_fs_disk_version_minor(lfs));
+                needssuperblock = true;
+            }
+            // note this bit is reserved on disk, so fetching more gstate
+            // will not interfere here
+            lfs_fs_prepsuperblock(lfs, needssuperblock);
+
+            // check superblock configuration
+            if (superblock.name_max) {
+                if (superblock.name_max > lfs->name_max) {
+                    LFS_ERROR("Unsupported name_max (%"PRIu32" > %"PRIu32")",
+                            superblock.name_max, lfs->name_max);
+                    err = LFS_ERR_INVAL;
+                    goto cleanup;
+                }
+
+                lfs->name_max = superblock.name_max;
+            }
+
+            if (superblock.file_max) {
+                if (superblock.file_max > lfs->file_max) {
+                    LFS_ERROR("Unsupported file_max (%"PRIu32" > %"PRIu32")",
+                            superblock.file_max, lfs->file_max);
+                    err = LFS_ERR_INVAL;
+                    goto cleanup;
+                }
+
+                lfs->file_max = superblock.file_max;
+            }
+
+            if (superblock.attr_max) {
+                if (superblock.attr_max > lfs->attr_max) {
+                    LFS_ERROR("Unsupported attr_max (%"PRIu32" > %"PRIu32")",
+                            superblock.attr_max, lfs->attr_max);
+                    err = LFS_ERR_INVAL;
+                    goto cleanup;
+                }
+
+                lfs->attr_max = superblock.attr_max;
+
+                // we also need to update inline_max in case attr_max changed
+                lfs->inline_max = lfs_min(lfs->inline_max, lfs->attr_max);
+            }
+
+            // this is where we get the block_count from disk if block_count=0
+            if (lfs->cfg->block_count
+                    && superblock.block_count != lfs->cfg->block_count) {
+                LFS_ERROR("Invalid block count (%"PRIu32" != %"PRIu32")",
+                        superblock.block_count, lfs->cfg->block_count);
+                err = LFS_ERR_INVAL;
+                goto cleanup;
+            }
+
+            lfs->block_count = superblock.block_count;
+
+            if (superblock.block_size != lfs->cfg->block_size) {
+                LFS_ERROR("Invalid block size (%"PRIu32" != %"PRIu32")",
+                        superblock.block_size, lfs->cfg->block_size);
+                err = LFS_ERR_INVAL;
+                goto cleanup;
+            }
+        }
+
+        // has gstate?
+        err = lfs_dir_getgstate(lfs, &dir, &lfs->gstate);
+        if (err) {
+            goto cleanup;
+        }
+    }
+
+    // update littlefs with gstate
+    if (!lfs_gstate_iszero(&lfs->gstate)) {
+        LFS_DEBUG("Found pending gstate 0x%08"PRIx32"%08"PRIx32"%08"PRIx32,
+                lfs->gstate.tag,
+                lfs->gstate.pair[0],
+                lfs->gstate.pair[1]);
+    }
+    lfs->gstate.tag += !lfs_tag_isvalid(lfs->gstate.tag);
+    lfs->gdisk = lfs->gstate;
+
+    // setup free lookahead, to distribute allocations uniformly across
+    // boots, we start the allocator at a random location
+    lfs->lookahead.start = lfs->seed % lfs->block_count;
+    lfs_alloc_drop(lfs);
+
+    return 0;
+
+cleanup:
+    lfs_unmount_(lfs);
+    return err;
+}
+
+static int lfs_unmount_(lfs_t *lfs) {
+    return lfs_deinit(lfs);
+}
+
+
+/// Filesystem filesystem operations ///
+static int lfs_fs_stat_(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
+    // if the superblock is up-to-date, we must be on the most recent
+    // minor version of littlefs
+    if (!lfs_gstate_needssuperblock(&lfs->gstate)) {
+        fsinfo->disk_version = lfs_fs_disk_version(lfs);
+
+    // otherwise we need to read the minor version on disk
+    } else {
+        // fetch the superblock
+        lfs_mdir_t dir;
+        int err = lfs_dir_fetch(lfs, &dir, lfs->root);
+        if (err) {
+            return err;
+        }
+
+        lfs_superblock_t superblock;
+        lfs_stag_t tag = lfs_dir_get(lfs, &dir, LFS_MKTAG(0x7ff, 0x3ff, 0),
+                LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)),
+                &superblock);
+        if (tag < 0) {
+            return tag;
+        }
+        lfs_superblock_fromle32(&superblock);
+
+        // read the on-disk version
+        fsinfo->disk_version = superblock.version;
+    }
+
+    // filesystem geometry
+    fsinfo->block_size = lfs->cfg->block_size;
+    fsinfo->block_count = lfs->block_count;
+
+    // other on-disk configuration, we cache all of these for internal use
+    fsinfo->name_max = lfs->name_max;
+    fsinfo->file_max = lfs->file_max;
+    fsinfo->attr_max = lfs->attr_max;
+
+    return 0;
+}
+
+int lfs_fs_traverse_(lfs_t *lfs,
+        int (*cb)(void *data, lfs_block_t block), void *data,
+        bool includeorphans) {
+    // iterate over metadata pairs
+    lfs_mdir_t dir = {.tail = {0, 1}};
+
+#ifdef LFS_MIGRATE
+    // also consider v1 blocks during migration
+    if (lfs->lfs1) {
+        int err = lfs1_traverse(lfs, cb, data);
+        if (err) {
+            return err;
+        }
+
+        dir.tail[0] = lfs->root[0];
+        dir.tail[1] = lfs->root[1];
+    }
+#endif
+
+    struct lfs_tortoise_t tortoise = {
+        .pair = {LFS_BLOCK_NULL, LFS_BLOCK_NULL},
+        .i = 1,
+        .period = 1,
+    };
+    int err = LFS_ERR_OK;
+    while (!lfs_pair_isnull(dir.tail)) {
+        err = lfs_tortoise_detectcycles(&dir, &tortoise);
+        if (err < 0) {
+            return LFS_ERR_CORRUPT;
+        }
+
+        for (int i = 0; i < 2; i++) {
+            int err = cb(data, dir.tail[i]);
+            if (err) {
+                return err;
+            }
+        }
+
+        // iterate through ids in directory
+        int err = lfs_dir_fetch(lfs, &dir, dir.tail);
+        if (err) {
+            return err;
+        }
+
+        for (uint16_t id = 0; id < dir.count; id++) {
+            struct lfs_ctz ctz;
+            lfs_stag_t tag = lfs_dir_get(lfs, &dir, LFS_MKTAG(0x700, 0x3ff, 0),
+                    LFS_MKTAG(LFS_TYPE_STRUCT, id, sizeof(ctz)), &ctz);
+            if (tag < 0) {
+                if (tag == LFS_ERR_NOENT) {
+                    continue;
+                }
+                return tag;
+            }
+            lfs_ctz_fromle32(&ctz);
+
+            if (lfs_tag_type3(tag) == LFS_TYPE_CTZSTRUCT) {
+                err = lfs_ctz_traverse(lfs, NULL, &lfs->rcache,
+                        ctz.head, ctz.size, cb, data);
+                if (err) {
+                    return err;
+                }
+            } else if (includeorphans &&
+                    lfs_tag_type3(tag) == LFS_TYPE_DIRSTRUCT) {
+                for (int i = 0; i < 2; i++) {
+                    err = cb(data, (&ctz.head)[i]);
+                    if (err) {
+                        return err;
+                    }
+                }
+            }
+        }
+    }
+
+#ifndef LFS_READONLY
+    // iterate over any open files
+    for (lfs_file_t *f = (lfs_file_t*)lfs->mlist; f; f = f->next) {
+        if (f->type != LFS_TYPE_REG) {
+            continue;
+        }
+
+        if (((f->flags & LFS_F_DIRTY) || (f->flags & LFS_F_DUSTY))
+                && !(f->flags & LFS_F_INLINE)) {
+            int err = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache,
+                    f->ctz.head, f->ctz.size, cb, data);
+            if (err) {
+                return err;
+            }
+        }
+
+        if ((f->flags & LFS_F_WRITING) && !(f->flags & LFS_F_INLINE)) {
+            int err = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache,
+                    f->block, f->pos, cb, data);
+            if (err) {
+                return err;
+            }
+        }
+    }
+#endif
+
+    return 0;
+}
+
+#ifndef LFS_READONLY
+static int lfs_fs_pred(lfs_t *lfs,
+        const lfs_block_t pair[2], lfs_mdir_t *pdir) {
+    // iterate over all directory directory entries
+    pdir->tail[0] = 0;
+    pdir->tail[1] = 1;
+    struct lfs_tortoise_t tortoise = {
+        .pair = {LFS_BLOCK_NULL, LFS_BLOCK_NULL},
+        .i = 1,
+        .period = 1,
+    };
+    int err = LFS_ERR_OK;
+    while (!lfs_pair_isnull(pdir->tail)) {
+        err = lfs_tortoise_detectcycles(pdir, &tortoise);
+        if (err < 0) {
+            return LFS_ERR_CORRUPT;
+        }
+
+        if (lfs_pair_cmp(pdir->tail, pair) == 0) {
+            return 0;
+        }
+
+        int err = lfs_dir_fetch(lfs, pdir, pdir->tail);
+        if (err) {
+            return err;
+        }
+    }
+
+    return LFS_ERR_NOENT;
+}
+#endif
+
+#ifndef LFS_READONLY
+struct lfs_fs_parent_match {
+    lfs_t *lfs;
+    const lfs_block_t pair[2];
+};
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_fs_parent_match(void *data,
+        lfs_tag_t tag, const void *buffer) {
+    struct lfs_fs_parent_match *find = data;
+    lfs_t *lfs = find->lfs;
+    const struct lfs_diskoff *disk = buffer;
+    (void)tag;
+
+    lfs_block_t child[2];
+    int err = lfs_bd_read(lfs,
+            &lfs->pcache, &lfs->rcache, lfs->cfg->block_size,
+            disk->block, disk->off, &child, sizeof(child));
+    if (err) {
+        return err;
+    }
+
+    lfs_pair_fromle32(child);
+    return (lfs_pair_cmp(child, find->pair) == 0) ? LFS_CMP_EQ : LFS_CMP_LT;
+}
+#endif
+
+#ifndef LFS_READONLY
+static lfs_stag_t lfs_fs_parent(lfs_t *lfs, const lfs_block_t pair[2],
+        lfs_mdir_t *parent) {
+    // use fetchmatch with callback to find pairs
+    parent->tail[0] = 0;
+    parent->tail[1] = 1;
+    struct lfs_tortoise_t tortoise = {
+        .pair = {LFS_BLOCK_NULL, LFS_BLOCK_NULL},
+        .i = 1,
+        .period = 1,
+    };
+    int err = LFS_ERR_OK;
+    while (!lfs_pair_isnull(parent->tail)) {
+        err = lfs_tortoise_detectcycles(parent, &tortoise);
+        if (err < 0) {
+            return err;
+        }
+
+        lfs_stag_t tag = lfs_dir_fetchmatch(lfs, parent, parent->tail,
+                LFS_MKTAG(0x7ff, 0, 0x3ff),
+                LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 0, 8),
+                NULL,
+                lfs_fs_parent_match, &(struct lfs_fs_parent_match){
+                    lfs, {pair[0], pair[1]}});
+        if (tag && tag != LFS_ERR_NOENT) {
+            return tag;
+        }
+    }
+
+    return LFS_ERR_NOENT;
+}
+#endif
+
+static void lfs_fs_prepsuperblock(lfs_t *lfs, bool needssuperblock) {
+    lfs->gstate.tag = (lfs->gstate.tag & ~LFS_MKTAG(0, 0, 0x200))
+            | (uint32_t)needssuperblock << 9;
+}
+
+#ifndef LFS_READONLY
+static int lfs_fs_preporphans(lfs_t *lfs, int8_t orphans) {
+    LFS_ASSERT(lfs_tag_size(lfs->gstate.tag) > 0x000 || orphans >= 0);
+    LFS_ASSERT(lfs_tag_size(lfs->gstate.tag) < 0x1ff || orphans <= 0);
+    lfs->gstate.tag += orphans;
+    lfs->gstate.tag = ((lfs->gstate.tag & ~LFS_MKTAG(0x800, 0, 0)) |
+            ((uint32_t)lfs_gstate_hasorphans(&lfs->gstate) << 31));
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static void lfs_fs_prepmove(lfs_t *lfs,
+        uint16_t id, const lfs_block_t pair[2]) {
+    lfs->gstate.tag = ((lfs->gstate.tag & ~LFS_MKTAG(0x7ff, 0x3ff, 0)) |
+            ((id != 0x3ff) ? LFS_MKTAG(LFS_TYPE_DELETE, id, 0) : 0));
+    lfs->gstate.pair[0] = (id != 0x3ff) ? pair[0] : 0;
+    lfs->gstate.pair[1] = (id != 0x3ff) ? pair[1] : 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_fs_desuperblock(lfs_t *lfs) {
+    if (!lfs_gstate_needssuperblock(&lfs->gstate)) {
+        return 0;
+    }
+
+    LFS_DEBUG("Rewriting superblock {0x%"PRIx32", 0x%"PRIx32"}",
+            lfs->root[0],
+            lfs->root[1]);
+
+    lfs_mdir_t root;
+    int err = lfs_dir_fetch(lfs, &root, lfs->root);
+    if (err) {
+        return err;
+    }
+
+    // write a new superblock
+    lfs_superblock_t superblock = {
+        .version     = lfs_fs_disk_version(lfs),
+        .block_size  = lfs->cfg->block_size,
+        .block_count = lfs->block_count,
+        .name_max    = lfs->name_max,
+        .file_max    = lfs->file_max,
+        .attr_max    = lfs->attr_max,
+    };
+
+    lfs_superblock_tole32(&superblock);
+    err = lfs_dir_commit(lfs, &root, LFS_MKATTRS(
+            {LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)),
+                &superblock}));
+    if (err) {
+        return err;
+    }
+
+    lfs_fs_prepsuperblock(lfs, false);
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_fs_demove(lfs_t *lfs) {
+    if (!lfs_gstate_hasmove(&lfs->gdisk)) {
+        return 0;
+    }
+
+    // Fix bad moves
+    LFS_DEBUG("Fixing move {0x%"PRIx32", 0x%"PRIx32"} 0x%"PRIx16,
+            lfs->gdisk.pair[0],
+            lfs->gdisk.pair[1],
+            lfs_tag_id(lfs->gdisk.tag));
+
+    // no other gstate is supported at this time, so if we found something else
+    // something most likely went wrong in gstate calculation
+    LFS_ASSERT(lfs_tag_type3(lfs->gdisk.tag) == LFS_TYPE_DELETE);
+
+    // fetch and delete the moved entry
+    lfs_mdir_t movedir;
+    int err = lfs_dir_fetch(lfs, &movedir, lfs->gdisk.pair);
+    if (err) {
+        return err;
+    }
+
+    // prep gstate and delete move id
+    uint16_t moveid = lfs_tag_id(lfs->gdisk.tag);
+    lfs_fs_prepmove(lfs, 0x3ff, NULL);
+    err = lfs_dir_commit(lfs, &movedir, LFS_MKATTRS(
+            {LFS_MKTAG(LFS_TYPE_DELETE, moveid, 0), NULL}));
+    if (err) {
+        return err;
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_fs_deorphan(lfs_t *lfs, bool powerloss) {
+    if (!lfs_gstate_hasorphans(&lfs->gstate)) {
+        return 0;
+    }
+
+    // Check for orphans in two separate passes:
+    // - 1 for half-orphans (relocations)
+    // - 2 for full-orphans (removes/renames)
+    //
+    // Two separate passes are needed as half-orphans can contain outdated
+    // references to full-orphans, effectively hiding them from the deorphan
+    // search.
+    //
+    int pass = 0;
+    while (pass < 2) {
+        // Fix any orphans
+        lfs_mdir_t pdir = {.split = true, .tail = {0, 1}};
+        lfs_mdir_t dir;
+        bool moreorphans = false;
+
+        // iterate over all directory directory entries
+        while (!lfs_pair_isnull(pdir.tail)) {
+            int err = lfs_dir_fetch(lfs, &dir, pdir.tail);
+            if (err) {
+                return err;
+            }
+
+            // check head blocks for orphans
+            if (!pdir.split) {
+                // check if we have a parent
+                lfs_mdir_t parent;
+                lfs_stag_t tag = lfs_fs_parent(lfs, pdir.tail, &parent);
+                if (tag < 0 && tag != LFS_ERR_NOENT) {
+                    return tag;
+                }
+
+                if (pass == 0 && tag != LFS_ERR_NOENT) {
+                    lfs_block_t pair[2];
+                    lfs_stag_t state = lfs_dir_get(lfs, &parent,
+                            LFS_MKTAG(0x7ff, 0x3ff, 0), tag, pair);
+                    if (state < 0) {
+                        return state;
+                    }
+                    lfs_pair_fromle32(pair);
+
+                    if (!lfs_pair_issync(pair, pdir.tail)) {
+                        // we have desynced
+                        LFS_DEBUG("Fixing half-orphan "
+                                "{0x%"PRIx32", 0x%"PRIx32"} "
+                                "-> {0x%"PRIx32", 0x%"PRIx32"}",
+                                pdir.tail[0], pdir.tail[1], pair[0], pair[1]);
+
+                        // fix pending move in this pair? this looks like an
+                        // optimization but is in fact _required_ since
+                        // relocating may outdate the move.
+                        uint16_t moveid = 0x3ff;
+                        if (lfs_gstate_hasmovehere(&lfs->gstate, pdir.pair)) {
+                            moveid = lfs_tag_id(lfs->gstate.tag);
+                            LFS_DEBUG("Fixing move while fixing orphans "
+                                    "{0x%"PRIx32", 0x%"PRIx32"} 0x%"PRIx16"\n",
+                                    pdir.pair[0], pdir.pair[1], moveid);
+                            lfs_fs_prepmove(lfs, 0x3ff, NULL);
+                        }
+
+                        lfs_pair_tole32(pair);
+                        state = lfs_dir_orphaningcommit(lfs, &pdir, LFS_MKATTRS(
+                                {LFS_MKTAG_IF(moveid != 0x3ff,
+                                    LFS_TYPE_DELETE, moveid, 0), NULL},
+                                {LFS_MKTAG(LFS_TYPE_SOFTTAIL, 0x3ff, 8),
+                                    pair}));
+                        lfs_pair_fromle32(pair);
+                        if (state < 0) {
+                            return state;
+                        }
+
+                        // did our commit create more orphans?
+                        if (state == LFS_OK_ORPHANED) {
+                            moreorphans = true;
+                        }
+
+                        // refetch tail
+                        continue;
+                    }
+                }
+
+                // note we only check for full orphans if we may have had a
+                // power-loss, otherwise orphans are created intentionally
+                // during operations such as lfs_mkdir
+                if (pass == 1 && tag == LFS_ERR_NOENT && powerloss) {
+                    // we are an orphan
+                    LFS_DEBUG("Fixing orphan {0x%"PRIx32", 0x%"PRIx32"}",
+                            pdir.tail[0], pdir.tail[1]);
+
+                    // steal state
+                    err = lfs_dir_getgstate(lfs, &dir, &lfs->gdelta);
+                    if (err) {
+                        return err;
+                    }
+
+                    // steal tail
+                    lfs_pair_tole32(dir.tail);
+                    int state = lfs_dir_orphaningcommit(lfs, &pdir, LFS_MKATTRS(
+                            {LFS_MKTAG(LFS_TYPE_TAIL + dir.split, 0x3ff, 8),
+                                dir.tail}));
+                    lfs_pair_fromle32(dir.tail);
+                    if (state < 0) {
+                        return state;
+                    }
+
+                    // did our commit create more orphans?
+                    if (state == LFS_OK_ORPHANED) {
+                        moreorphans = true;
+                    }
+
+                    // refetch tail
+                    continue;
+                }
+            }
+
+            pdir = dir;
+        }
+
+        pass = moreorphans ? 0 : pass+1;
+    }
+
+    // mark orphans as fixed
+    return lfs_fs_preporphans(lfs, -lfs_gstate_getorphans(&lfs->gstate));
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_fs_forceconsistency(lfs_t *lfs) {
+    int err = lfs_fs_desuperblock(lfs);
+    if (err) {
+        return err;
+    }
+
+    err = lfs_fs_demove(lfs);
+    if (err) {
+        return err;
+    }
+
+    err = lfs_fs_deorphan(lfs, true);
+    if (err) {
+        return err;
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+static int lfs_fs_mkconsistent_(lfs_t *lfs) {
+    // lfs_fs_forceconsistency does most of the work here
+    int err = lfs_fs_forceconsistency(lfs);
+    if (err) {
+        return err;
+    }
+
+    // do we have any pending gstate?
+    lfs_gstate_t delta = {0};
+    lfs_gstate_xor(&delta, &lfs->gdisk);
+    lfs_gstate_xor(&delta, &lfs->gstate);
+    if (!lfs_gstate_iszero(&delta)) {
+        // lfs_dir_commit will implicitly write out any pending gstate
+        lfs_mdir_t root;
+        err = lfs_dir_fetch(lfs, &root, lfs->root);
+        if (err) {
+            return err;
+        }
+
+        err = lfs_dir_commit(lfs, &root, NULL, 0);
+        if (err) {
+            return err;
+        }
+    }
+
+    return 0;
+}
+#endif
+
+static int lfs_fs_size_count(void *p, lfs_block_t block) {
+    (void)block;
+    lfs_size_t *size = p;
+    *size += 1;
+    return 0;
+}
+
+static lfs_ssize_t lfs_fs_size_(lfs_t *lfs) {
+    lfs_size_t size = 0;
+    int err = lfs_fs_traverse_(lfs, lfs_fs_size_count, &size, false);
+    if (err) {
+        return err;
+    }
+
+    return size;
+}
+
+// explicit garbage collection
+#ifndef LFS_READONLY
+static int lfs_fs_gc_(lfs_t *lfs) {
+    // force consistency, even if we're not necessarily going to write,
+    // because this function is supposed to take care of janitorial work
+    // isn't it?
+    int err = lfs_fs_forceconsistency(lfs);
+    if (err) {
+        return err;
+    }
+
+    // try to compact metadata pairs, note we can't really accomplish
+    // anything if compact_thresh doesn't at least leave a prog_size
+    // available
+    if (lfs->cfg->compact_thresh
+            < lfs->cfg->block_size - lfs->cfg->prog_size) {
+        // iterate over all mdirs
+        lfs_mdir_t mdir = {.tail = {0, 1}};
+        while (!lfs_pair_isnull(mdir.tail)) {
+            err = lfs_dir_fetch(lfs, &mdir, mdir.tail);
+            if (err) {
+                return err;
+            }
+
+            // not erased? exceeds our compaction threshold?
+            if (!mdir.erased || ((lfs->cfg->compact_thresh == 0)
+                    ? mdir.off > lfs->cfg->block_size - lfs->cfg->block_size/8
+                    : mdir.off > lfs->cfg->compact_thresh)) {
+                // the easiest way to trigger a compaction is to mark
+                // the mdir as unerased and add an empty commit
+                mdir.erased = false;
+                err = lfs_dir_commit(lfs, &mdir, NULL, 0);
+                if (err) {
+                    return err;
+                }
+            }
+        }
+    }
+
+    // try to populate the lookahead buffer, unless it's already full
+    if (lfs->lookahead.size < lfs_min(
+            8 * lfs->cfg->lookahead_size,
+            lfs->block_count)) {
+        err = lfs_alloc_scan(lfs);
+        if (err) {
+            return err;
+        }
+    }
+
+    return 0;
+}
+#endif
+
+#ifndef LFS_READONLY
+#ifdef LFS_SHRINKNONRELOCATING
+static int lfs_shrink_checkblock(void *data, lfs_block_t block) {
+    lfs_size_t threshold = *((lfs_size_t*)data);
+    if (block >= threshold) {
+        return LFS_ERR_NOTEMPTY;
+    }
+    return 0;
+}
+#endif
+
+static int lfs_fs_grow_(lfs_t *lfs, lfs_size_t block_count) {
+    int err;
+
+    if (block_count == lfs->block_count) {
+        return 0;
+    }
+
+    
+#ifndef LFS_SHRINKNONRELOCATING
+    // shrinking is not supported
+    LFS_ASSERT(block_count >= lfs->block_count);
+#endif
+#ifdef LFS_SHRINKNONRELOCATING
+    if (block_count < lfs->block_count) {
+        err = lfs_fs_traverse_(lfs, lfs_shrink_checkblock, &block_count, true);
+        if (err) {
+            return err;
+        }
+    }
+#endif
+
+    lfs->block_count = block_count;
+
+    // fetch the root
+    lfs_mdir_t root;
+    err = lfs_dir_fetch(lfs, &root, lfs->root);
+    if (err) {
+        return err;
+    }
+
+    // update the superblock
+    lfs_superblock_t superblock;
+    lfs_stag_t tag = lfs_dir_get(lfs, &root, LFS_MKTAG(0x7ff, 0x3ff, 0),
+            LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)),
+            &superblock);
+    if (tag < 0) {
+        return tag;
+    }
+    lfs_superblock_fromle32(&superblock);
+
+    superblock.block_count = lfs->block_count;
+
+    lfs_superblock_tole32(&superblock);
+    err = lfs_dir_commit(lfs, &root, LFS_MKATTRS(
+            {tag, &superblock}));
+    if (err) {
+        return err;
+    }
+    return 0;
+}
+#endif
+
+#ifdef LFS_MIGRATE
+////// Migration from littelfs v1 below this //////
+
+/// Version info ///
+
+// Software library version
+// Major (top-nibble), incremented on backwards incompatible changes
+// Minor (bottom-nibble), incremented on feature additions
+#define LFS1_VERSION 0x00010007
+#define LFS1_VERSION_MAJOR (0xffff & (LFS1_VERSION >> 16))
+#define LFS1_VERSION_MINOR (0xffff & (LFS1_VERSION >>  0))
+
+// Version of On-disk data structures
+// Major (top-nibble), incremented on backwards incompatible changes
+// Minor (bottom-nibble), incremented on feature additions
+#define LFS1_DISK_VERSION 0x00010001
+#define LFS1_DISK_VERSION_MAJOR (0xffff & (LFS1_DISK_VERSION >> 16))
+#define LFS1_DISK_VERSION_MINOR (0xffff & (LFS1_DISK_VERSION >>  0))
+
+
+/// v1 Definitions ///
+
+// File types
+enum lfs1_type {
+    LFS1_TYPE_REG        = 0x11,
+    LFS1_TYPE_DIR        = 0x22,
+    LFS1_TYPE_SUPERBLOCK = 0x2e,
+};
+
+typedef struct lfs1 {
+    lfs_block_t root[2];
+} lfs1_t;
+
+typedef struct lfs1_entry {
+    lfs_off_t off;
+
+    struct lfs1_disk_entry {
+        uint8_t type;
+        uint8_t elen;
+        uint8_t alen;
+        uint8_t nlen;
+        union {
+            struct {
+                lfs_block_t head;
+                lfs_size_t size;
+            } file;
+            lfs_block_t dir[2];
+        } u;
+    } d;
+} lfs1_entry_t;
+
+typedef struct lfs1_dir {
+    struct lfs1_dir *next;
+    lfs_block_t pair[2];
+    lfs_off_t off;
+
+    lfs_block_t head[2];
+    lfs_off_t pos;
+
+    struct lfs1_disk_dir {
+        uint32_t rev;
+        lfs_size_t size;
+        lfs_block_t tail[2];
+    } d;
+} lfs1_dir_t;
+
+typedef struct lfs1_superblock {
+    lfs_off_t off;
+
+    struct lfs1_disk_superblock {
+        uint8_t type;
+        uint8_t elen;
+        uint8_t alen;
+        uint8_t nlen;
+        lfs_block_t root[2];
+        uint32_t block_size;
+        uint32_t block_count;
+        uint32_t version;
+        char magic[8];
+    } d;
+} lfs1_superblock_t;
+
+
+/// Low-level wrappers v1->v2 ///
+static void lfs1_crc(uint32_t *crc, const void *buffer, size_t size) {
+    *crc = lfs_crc(*crc, buffer, size);
+}
+
+static int lfs1_bd_read(lfs_t *lfs, lfs_block_t block,
+        lfs_off_t off, void *buffer, lfs_size_t size) {
+    // if we ever do more than writes to alternating pairs,
+    // this may need to consider pcache
+    return lfs_bd_read(lfs, &lfs->pcache, &lfs->rcache, size,
+            block, off, buffer, size);
+}
+
+static int lfs1_bd_crc(lfs_t *lfs, lfs_block_t block,
+        lfs_off_t off, lfs_size_t size, uint32_t *crc) {
+    for (lfs_off_t i = 0; i < size; i++) {
+        uint8_t c;
+        int err = lfs1_bd_read(lfs, block, off+i, &c, 1);
+        if (err) {
+            return err;
+        }
+
+        lfs1_crc(crc, &c, 1);
+    }
+
+    return 0;
+}
+
+
+/// Endian swapping functions ///
+static void lfs1_dir_fromle32(struct lfs1_disk_dir *d) {
+    d->rev     = lfs_fromle32(d->rev);
+    d->size    = lfs_fromle32(d->size);
+    d->tail[0] = lfs_fromle32(d->tail[0]);
+    d->tail[1] = lfs_fromle32(d->tail[1]);
+}
+
+static void lfs1_dir_tole32(struct lfs1_disk_dir *d) {
+    d->rev     = lfs_tole32(d->rev);
+    d->size    = lfs_tole32(d->size);
+    d->tail[0] = lfs_tole32(d->tail[0]);
+    d->tail[1] = lfs_tole32(d->tail[1]);
+}
+
+static void lfs1_entry_fromle32(struct lfs1_disk_entry *d) {
+    d->u.dir[0] = lfs_fromle32(d->u.dir[0]);
+    d->u.dir[1] = lfs_fromle32(d->u.dir[1]);
+}
+
+static void lfs1_entry_tole32(struct lfs1_disk_entry *d) {
+    d->u.dir[0] = lfs_tole32(d->u.dir[0]);
+    d->u.dir[1] = lfs_tole32(d->u.dir[1]);
+}
+
+static void lfs1_superblock_fromle32(struct lfs1_disk_superblock *d) {
+    d->root[0]     = lfs_fromle32(d->root[0]);
+    d->root[1]     = lfs_fromle32(d->root[1]);
+    d->block_size  = lfs_fromle32(d->block_size);
+    d->block_count = lfs_fromle32(d->block_count);
+    d->version     = lfs_fromle32(d->version);
+}
+
+
+///// Metadata pair and directory operations ///
+static inline lfs_size_t lfs1_entry_size(const lfs1_entry_t *entry) {
+    return 4 + entry->d.elen + entry->d.alen + entry->d.nlen;
+}
+
+static int lfs1_dir_fetch(lfs_t *lfs,
+        lfs1_dir_t *dir, const lfs_block_t pair[2]) {
+    // copy out pair, otherwise may be aliasing dir
+    const lfs_block_t tpair[2] = {pair[0], pair[1]};
+    bool valid = false;
+
+    // check both blocks for the most recent revision
+    for (int i = 0; i < 2; i++) {
+        struct lfs1_disk_dir test;
+        int err = lfs1_bd_read(lfs, tpair[i], 0, &test, sizeof(test));
+        lfs1_dir_fromle32(&test);
+        if (err) {
+            if (err == LFS_ERR_CORRUPT) {
+                continue;
+            }
+            return err;
+        }
+
+        if (valid && lfs_scmp(test.rev, dir->d.rev) < 0) {
+            continue;
+        }
+
+        if ((0x7fffffff & test.size) < sizeof(test)+4 ||
+            (0x7fffffff & test.size) > lfs->cfg->block_size) {
+            continue;
+        }
+
+        uint32_t crc = 0xffffffff;
+        lfs1_dir_tole32(&test);
+        lfs1_crc(&crc, &test, sizeof(test));
+        lfs1_dir_fromle32(&test);
+        err = lfs1_bd_crc(lfs, tpair[i], sizeof(test),
+                (0x7fffffff & test.size) - sizeof(test), &crc);
+        if (err) {
+            if (err == LFS_ERR_CORRUPT) {
+                continue;
+            }
+            return err;
+        }
+
+        if (crc != 0) {
+            continue;
+        }
+
+        valid = true;
+
+        // setup dir in case it's valid
+        dir->pair[0] = tpair[(i+0) % 2];
+        dir->pair[1] = tpair[(i+1) % 2];
+        dir->off = sizeof(dir->d);
+        dir->d = test;
+    }
+
+    if (!valid) {
+        LFS_ERROR("Corrupted dir pair at {0x%"PRIx32", 0x%"PRIx32"}",
+                tpair[0], tpair[1]);
+        return LFS_ERR_CORRUPT;
+    }
+
+    return 0;
+}
+
+static int lfs1_dir_next(lfs_t *lfs, lfs1_dir_t *dir, lfs1_entry_t *entry) {
+    while (dir->off + sizeof(entry->d) > (0x7fffffff & dir->d.size)-4) {
+        if (!(0x80000000 & dir->d.size)) {
+            entry->off = dir->off;
+            return LFS_ERR_NOENT;
+        }
+
+        int err = lfs1_dir_fetch(lfs, dir, dir->d.tail);
+        if (err) {
+            return err;
+        }
+
+        dir->off = sizeof(dir->d);
+        dir->pos += sizeof(dir->d) + 4;
+    }
+
+    int err = lfs1_bd_read(lfs, dir->pair[0], dir->off,
+            &entry->d, sizeof(entry->d));
+    lfs1_entry_fromle32(&entry->d);
+    if (err) {
+        return err;
+    }
+
+    entry->off = dir->off;
+    dir->off += lfs1_entry_size(entry);
+    dir->pos += lfs1_entry_size(entry);
+    return 0;
+}
+
+/// littlefs v1 specific operations ///
+int lfs1_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data) {
+    if (lfs_pair_isnull(lfs->lfs1->root)) {
+        return 0;
+    }
+
+    // iterate over metadata pairs
+    lfs1_dir_t dir;
+    lfs1_entry_t entry;
+    lfs_block_t cwd[2] = {0, 1};
+
+    while (true) {
+        for (int i = 0; i < 2; i++) {
+            int err = cb(data, cwd[i]);
+            if (err) {
+                return err;
+            }
+        }
+
+        int err = lfs1_dir_fetch(lfs, &dir, cwd);
+        if (err) {
+            return err;
+        }
+
+        // iterate over contents
+        while (dir.off + sizeof(entry.d) <= (0x7fffffff & dir.d.size)-4) {
+            err = lfs1_bd_read(lfs, dir.pair[0], dir.off,
+                    &entry.d, sizeof(entry.d));
+            lfs1_entry_fromle32(&entry.d);
+            if (err) {
+                return err;
+            }
+
+            dir.off += lfs1_entry_size(&entry);
+            if ((0x70 & entry.d.type) == (0x70 & LFS1_TYPE_REG)) {
+                err = lfs_ctz_traverse(lfs, NULL, &lfs->rcache,
+                        entry.d.u.file.head, entry.d.u.file.size, cb, data);
+                if (err) {
+                    return err;
+                }
+            }
+        }
+
+        // we also need to check if we contain a threaded v2 directory
+        lfs_mdir_t dir2 = {.split=true, .tail={cwd[0], cwd[1]}};
+        while (dir2.split) {
+            err = lfs_dir_fetch(lfs, &dir2, dir2.tail);
+            if (err) {
+                break;
+            }
+
+            for (int i = 0; i < 2; i++) {
+                err = cb(data, dir2.pair[i]);
+                if (err) {
+                    return err;
+                }
+            }
+        }
+
+        cwd[0] = dir.d.tail[0];
+        cwd[1] = dir.d.tail[1];
+
+        if (lfs_pair_isnull(cwd)) {
+            break;
+        }
+    }
+
+    return 0;
+}
+
+static int lfs1_moved(lfs_t *lfs, const void *e) {
+    if (lfs_pair_isnull(lfs->lfs1->root)) {
+        return 0;
+    }
+
+    // skip superblock
+    lfs1_dir_t cwd;
+    int err = lfs1_dir_fetch(lfs, &cwd, (const lfs_block_t[2]){0, 1});
+    if (err) {
+        return err;
+    }
+
+    // iterate over all directory directory entries
+    lfs1_entry_t entry;
+    while (!lfs_pair_isnull(cwd.d.tail)) {
+        err = lfs1_dir_fetch(lfs, &cwd, cwd.d.tail);
+        if (err) {
+            return err;
+        }
+
+        while (true) {
+            err = lfs1_dir_next(lfs, &cwd, &entry);
+            if (err && err != LFS_ERR_NOENT) {
+                return err;
+            }
+
+            if (err == LFS_ERR_NOENT) {
+                break;
+            }
+
+            if (!(0x80 & entry.d.type) &&
+                 memcmp(&entry.d.u, e, sizeof(entry.d.u)) == 0) {
+                return true;
+            }
+        }
+    }
+
+    return false;
+}
+
+/// Filesystem operations ///
+static int lfs1_mount(lfs_t *lfs, struct lfs1 *lfs1,
+        const struct lfs_config *cfg) {
+    int err = 0;
+    {
+        err = lfs_init(lfs, cfg);
+        if (err) {
+            return err;
+        }
+
+        lfs->lfs1 = lfs1;
+        lfs->lfs1->root[0] = LFS_BLOCK_NULL;
+        lfs->lfs1->root[1] = LFS_BLOCK_NULL;
+
+        // setup free lookahead
+        lfs->lookahead.start = 0;
+        lfs->lookahead.size = 0;
+        lfs->lookahead.next = 0;
+        lfs_alloc_ckpoint(lfs);
+
+        // load superblock
+        lfs1_dir_t dir;
+        lfs1_superblock_t superblock;
+        err = lfs1_dir_fetch(lfs, &dir, (const lfs_block_t[2]){0, 1});
+        if (err && err != LFS_ERR_CORRUPT) {
+            goto cleanup;
+        }
+
+        if (!err) {
+            err = lfs1_bd_read(lfs, dir.pair[0], sizeof(dir.d),
+                    &superblock.d, sizeof(superblock.d));
+            lfs1_superblock_fromle32(&superblock.d);
+            if (err) {
+                goto cleanup;
+            }
+
+            lfs->lfs1->root[0] = superblock.d.root[0];
+            lfs->lfs1->root[1] = superblock.d.root[1];
+        }
+
+        if (err || memcmp(superblock.d.magic, "littlefs", 8) != 0) {
+            LFS_ERROR("Invalid superblock at {0x%"PRIx32", 0x%"PRIx32"}",
+                    0, 1);
+            err = LFS_ERR_CORRUPT;
+            goto cleanup;
+        }
+
+        uint16_t major_version = (0xffff & (superblock.d.version >> 16));
+        uint16_t minor_version = (0xffff & (superblock.d.version >>  0));
+        if ((major_version != LFS1_DISK_VERSION_MAJOR ||
+             minor_version > LFS1_DISK_VERSION_MINOR)) {
+            LFS_ERROR("Invalid version v%d.%d", major_version, minor_version);
+            err = LFS_ERR_INVAL;
+            goto cleanup;
+        }
+
+        return 0;
+    }
+
+cleanup:
+    lfs_deinit(lfs);
+    return err;
+}
+
+static int lfs1_unmount(lfs_t *lfs) {
+    return lfs_deinit(lfs);
+}
+
+/// v1 migration ///
+static int lfs_migrate_(lfs_t *lfs, const struct lfs_config *cfg) {
+    struct lfs1 lfs1;
+
+    // Indeterminate filesystem size not allowed for migration.
+    LFS_ASSERT(cfg->block_count != 0);
+
+    int err = lfs1_mount(lfs, &lfs1, cfg);
+    if (err) {
+        return err;
+    }
+
+    {
+        // iterate through each directory, copying over entries
+        // into new directory
+        lfs1_dir_t dir1;
+        lfs_mdir_t dir2;
+        dir1.d.tail[0] = lfs->lfs1->root[0];
+        dir1.d.tail[1] = lfs->lfs1->root[1];
+        while (!lfs_pair_isnull(dir1.d.tail)) {
+            // iterate old dir
+            err = lfs1_dir_fetch(lfs, &dir1, dir1.d.tail);
+            if (err) {
+                goto cleanup;
+            }
+
+            // create new dir and bind as temporary pretend root
+            err = lfs_dir_alloc(lfs, &dir2);
+            if (err) {
+                goto cleanup;
+            }
+
+            dir2.rev = dir1.d.rev;
+            dir1.head[0] = dir1.pair[0];
+            dir1.head[1] = dir1.pair[1];
+            lfs->root[0] = dir2.pair[0];
+            lfs->root[1] = dir2.pair[1];
+
+            err = lfs_dir_commit(lfs, &dir2, NULL, 0);
+            if (err) {
+                goto cleanup;
+            }
+
+            while (true) {
+                lfs1_entry_t entry1;
+                err = lfs1_dir_next(lfs, &dir1, &entry1);
+                if (err && err != LFS_ERR_NOENT) {
+                    goto cleanup;
+                }
+
+                if (err == LFS_ERR_NOENT) {
+                    break;
+                }
+
+                // check that entry has not been moved
+                if (entry1.d.type & 0x80) {
+                    int moved = lfs1_moved(lfs, &entry1.d.u);
+                    if (moved < 0) {
+                        err = moved;
+                        goto cleanup;
+                    }
+
+                    if (moved) {
+                        continue;
+                    }
+
+                    entry1.d.type &= ~0x80;
+                }
+
+                // also fetch name
+                char name[LFS_NAME_MAX+1];
+                memset(name, 0, sizeof(name));
+                err = lfs1_bd_read(lfs, dir1.pair[0],
+                        entry1.off + 4+entry1.d.elen+entry1.d.alen,
+                        name, entry1.d.nlen);
+                if (err) {
+                    goto cleanup;
+                }
+
+                bool isdir = (entry1.d.type == LFS1_TYPE_DIR);
+
+                // create entry in new dir
+                err = lfs_dir_fetch(lfs, &dir2, lfs->root);
+                if (err) {
+                    goto cleanup;
+                }
+
+                uint16_t id;
+                err = lfs_dir_find(lfs, &dir2, &(const char*){name}, &id);
+                if (!(err == LFS_ERR_NOENT && id != 0x3ff)) {
+                    err = (err < 0) ? err : LFS_ERR_EXIST;
+                    goto cleanup;
+                }
+
+                lfs1_entry_tole32(&entry1.d);
+                err = lfs_dir_commit(lfs, &dir2, LFS_MKATTRS(
+                        {LFS_MKTAG(LFS_TYPE_CREATE, id, 0), NULL},
+                        {LFS_MKTAG_IF_ELSE(isdir,
+                            LFS_TYPE_DIR, id, entry1.d.nlen,
+                            LFS_TYPE_REG, id, entry1.d.nlen),
+                                name},
+                        {LFS_MKTAG_IF_ELSE(isdir,
+                            LFS_TYPE_DIRSTRUCT, id, sizeof(entry1.d.u),
+                            LFS_TYPE_CTZSTRUCT, id, sizeof(entry1.d.u)),
+                                &entry1.d.u}));
+                lfs1_entry_fromle32(&entry1.d);
+                if (err) {
+                    goto cleanup;
+                }
+            }
+
+            if (!lfs_pair_isnull(dir1.d.tail)) {
+                // find last block and update tail to thread into fs
+                err = lfs_dir_fetch(lfs, &dir2, lfs->root);
+                if (err) {
+                    goto cleanup;
+                }
+
+                while (dir2.split) {
+                    err = lfs_dir_fetch(lfs, &dir2, dir2.tail);
+                    if (err) {
+                        goto cleanup;
+                    }
+                }
+
+                lfs_pair_tole32(dir2.pair);
+                err = lfs_dir_commit(lfs, &dir2, LFS_MKATTRS(
+                        {LFS_MKTAG(LFS_TYPE_SOFTTAIL, 0x3ff, 8), dir1.d.tail}));
+                lfs_pair_fromle32(dir2.pair);
+                if (err) {
+                    goto cleanup;
+                }
+            }
+
+            // Copy over first block to thread into fs. Unfortunately
+            // if this fails there is not much we can do.
+            LFS_DEBUG("Migrating {0x%"PRIx32", 0x%"PRIx32"} "
+                        "-> {0x%"PRIx32", 0x%"PRIx32"}",
+                    lfs->root[0], lfs->root[1], dir1.head[0], dir1.head[1]);
+
+            err = lfs_bd_erase(lfs, dir1.head[1]);
+            if (err) {
+                goto cleanup;
+            }
+
+            err = lfs_dir_fetch(lfs, &dir2, lfs->root);
+            if (err) {
+                goto cleanup;
+            }
+
+            for (lfs_off_t i = 0; i < dir2.off; i++) {
+                uint8_t dat;
+                err = lfs_bd_read(lfs,
+                        NULL, &lfs->rcache, dir2.off,
+                        dir2.pair[0], i, &dat, 1);
+                if (err) {
+                    goto cleanup;
+                }
+
+                err = lfs_bd_prog(lfs,
+                        &lfs->pcache, &lfs->rcache, true,
+                        dir1.head[1], i, &dat, 1);
+                if (err) {
+                    goto cleanup;
+                }
+            }
+
+            err = lfs_bd_flush(lfs, &lfs->pcache, &lfs->rcache, true);
+            if (err) {
+                goto cleanup;
+            }
+        }
+
+        // Create new superblock. This marks a successful migration!
+        err = lfs1_dir_fetch(lfs, &dir1, (const lfs_block_t[2]){0, 1});
+        if (err) {
+            goto cleanup;
+        }
+
+        dir2.pair[0] = dir1.pair[0];
+        dir2.pair[1] = dir1.pair[1];
+        dir2.rev = dir1.d.rev;
+        dir2.off = sizeof(dir2.rev);
+        dir2.etag = 0xffffffff;
+        dir2.count = 0;
+        dir2.tail[0] = lfs->lfs1->root[0];
+        dir2.tail[1] = lfs->lfs1->root[1];
+        dir2.erased = false;
+        dir2.split = true;
+
+        lfs_superblock_t superblock = {
+            .version     = LFS_DISK_VERSION,
+            .block_size  = lfs->cfg->block_size,
+            .block_count = lfs->cfg->block_count,
+            .name_max    = lfs->name_max,
+            .file_max    = lfs->file_max,
+            .attr_max    = lfs->attr_max,
+        };
+
+        lfs_superblock_tole32(&superblock);
+        err = lfs_dir_commit(lfs, &dir2, LFS_MKATTRS(
+                {LFS_MKTAG(LFS_TYPE_CREATE, 0, 0), NULL},
+                {LFS_MKTAG(LFS_TYPE_SUPERBLOCK, 0, 8), "littlefs"},
+                {LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)),
+                    &superblock}));
+        if (err) {
+            goto cleanup;
+        }
+
+        // sanity check that fetch works
+        err = lfs_dir_fetch(lfs, &dir2, (const lfs_block_t[2]){0, 1});
+        if (err) {
+            goto cleanup;
+        }
+
+        // force compaction to prevent accidentally mounting v1
+        dir2.erased = false;
+        err = lfs_dir_commit(lfs, &dir2, NULL, 0);
+        if (err) {
+            goto cleanup;
+        }
+    }
+
+cleanup:
+    lfs1_unmount(lfs);
+    return err;
+}
+
+#endif
+
+
+/// Public API wrappers ///
+
+// Here we can add tracing/thread safety easily
+
+// Thread-safe wrappers if enabled
+#ifdef LFS_THREADSAFE
+#define LFS_LOCK(cfg)   cfg->lock(cfg)
+#define LFS_UNLOCK(cfg) cfg->unlock(cfg)
+#else
+#define LFS_LOCK(cfg)   ((void)cfg, 0)
+#define LFS_UNLOCK(cfg) ((void)cfg)
+#endif
+
+// Public API
+#ifndef LFS_READONLY
+int lfs_format(lfs_t *lfs, const struct lfs_config *cfg) {
+    int err = LFS_LOCK(cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_format(%p, %p {.context=%p, "
+                ".read=%p, .prog=%p, .erase=%p, .sync=%p, "
+                ".read_size=%"PRIu32", .prog_size=%"PRIu32", "
+                ".block_size=%"PRIu32", .block_count=%"PRIu32", "
+                ".block_cycles=%"PRId32", .cache_size=%"PRIu32", "
+                ".lookahead_size=%"PRIu32", .read_buffer=%p, "
+                ".prog_buffer=%p, .lookahead_buffer=%p, "
+                ".name_max=%"PRIu32", .file_max=%"PRIu32", "
+                ".attr_max=%"PRIu32"})",
+            (void*)lfs, (void*)cfg, cfg->context,
+            (void*)(uintptr_t)cfg->read, (void*)(uintptr_t)cfg->prog,
+            (void*)(uintptr_t)cfg->erase, (void*)(uintptr_t)cfg->sync,
+            cfg->read_size, cfg->prog_size, cfg->block_size, cfg->block_count,
+            cfg->block_cycles, cfg->cache_size, cfg->lookahead_size,
+            cfg->read_buffer, cfg->prog_buffer, cfg->lookahead_buffer,
+            cfg->name_max, cfg->file_max, cfg->attr_max);
+
+    err = lfs_format_(lfs, cfg);
+
+    LFS_TRACE("lfs_format -> %d", err);
+    LFS_UNLOCK(cfg);
+    return err;
+}
+#endif
+
+int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {
+    int err = LFS_LOCK(cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_mount(%p, %p {.context=%p, "
+                ".read=%p, .prog=%p, .erase=%p, .sync=%p, "
+                ".read_size=%"PRIu32", .prog_size=%"PRIu32", "
+                ".block_size=%"PRIu32", .block_count=%"PRIu32", "
+                ".block_cycles=%"PRId32", .cache_size=%"PRIu32", "
+                ".lookahead_size=%"PRIu32", .read_buffer=%p, "
+                ".prog_buffer=%p, .lookahead_buffer=%p, "
+                ".name_max=%"PRIu32", .file_max=%"PRIu32", "
+                ".attr_max=%"PRIu32"})",
+            (void*)lfs, (void*)cfg, cfg->context,
+            (void*)(uintptr_t)cfg->read, (void*)(uintptr_t)cfg->prog,
+            (void*)(uintptr_t)cfg->erase, (void*)(uintptr_t)cfg->sync,
+            cfg->read_size, cfg->prog_size, cfg->block_size, cfg->block_count,
+            cfg->block_cycles, cfg->cache_size, cfg->lookahead_size,
+            cfg->read_buffer, cfg->prog_buffer, cfg->lookahead_buffer,
+            cfg->name_max, cfg->file_max, cfg->attr_max);
+
+    err = lfs_mount_(lfs, cfg);
+
+    LFS_TRACE("lfs_mount -> %d", err);
+    LFS_UNLOCK(cfg);
+    return err;
+}
+
+int lfs_unmount(lfs_t *lfs) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_unmount(%p)", (void*)lfs);
+
+    err = lfs_unmount_(lfs);
+
+    LFS_TRACE("lfs_unmount -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+#ifndef LFS_READONLY
+int lfs_remove(lfs_t *lfs, const char *path) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_remove(%p, \"%s\")", (void*)lfs, path);
+
+    err = lfs_remove_(lfs, path);
+
+    LFS_TRACE("lfs_remove -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+#ifndef LFS_READONLY
+int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_rename(%p, \"%s\", \"%s\")", (void*)lfs, oldpath, newpath);
+
+    err = lfs_rename_(lfs, oldpath, newpath);
+
+    LFS_TRACE("lfs_rename -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_stat(%p, \"%s\", %p)", (void*)lfs, path, (void*)info);
+
+    err = lfs_stat_(lfs, path, info);
+
+    LFS_TRACE("lfs_stat -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+lfs_ssize_t lfs_getattr(lfs_t *lfs, const char *path,
+        uint8_t type, void *buffer, lfs_size_t size) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_getattr(%p, \"%s\", %"PRIu8", %p, %"PRIu32")",
+            (void*)lfs, path, type, buffer, size);
+
+    lfs_ssize_t res = lfs_getattr_(lfs, path, type, buffer, size);
+
+    LFS_TRACE("lfs_getattr -> %"PRId32, res);
+    LFS_UNLOCK(lfs->cfg);
+    return res;
+}
+
+#ifndef LFS_READONLY
+int lfs_setattr(lfs_t *lfs, const char *path,
+        uint8_t type, const void *buffer, lfs_size_t size) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_setattr(%p, \"%s\", %"PRIu8", %p, %"PRIu32")",
+            (void*)lfs, path, type, buffer, size);
+
+    err = lfs_setattr_(lfs, path, type, buffer, size);
+
+    LFS_TRACE("lfs_setattr -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+#ifndef LFS_READONLY
+int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_removeattr(%p, \"%s\", %"PRIu8")", (void*)lfs, path, type);
+
+    err = lfs_removeattr_(lfs, path, type);
+
+    LFS_TRACE("lfs_removeattr -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+#ifndef LFS_NO_MALLOC
+int lfs_file_open(lfs_t *lfs, lfs_file_t *file, const char *path, int flags) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_open(%p, %p, \"%s\", %x)",
+            (void*)lfs, (void*)file, path, (unsigned)flags);
+    LFS_ASSERT(!lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
+
+    err = lfs_file_open_(lfs, file, path, flags);
+
+    LFS_TRACE("lfs_file_open -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file,
+        const char *path, int flags,
+        const struct lfs_file_config *cfg) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_opencfg(%p, %p, \"%s\", %x, %p {"
+                 ".buffer=%p, .attrs=%p, .attr_count=%"PRIu32"})",
+            (void*)lfs, (void*)file, path, (unsigned)flags,
+            (void*)cfg, cfg->buffer, (void*)cfg->attrs, cfg->attr_count);
+    LFS_ASSERT(!lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
+
+    err = lfs_file_opencfg_(lfs, file, path, flags, cfg);
+
+    LFS_TRACE("lfs_file_opencfg -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+int lfs_file_close(lfs_t *lfs, lfs_file_t *file) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_close(%p, %p)", (void*)lfs, (void*)file);
+    LFS_ASSERT(lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
+
+    err = lfs_file_close_(lfs, file);
+
+    LFS_TRACE("lfs_file_close -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+#ifndef LFS_READONLY
+int lfs_file_sync(lfs_t *lfs, lfs_file_t *file) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_sync(%p, %p)", (void*)lfs, (void*)file);
+    LFS_ASSERT(lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
+
+    err = lfs_file_sync_(lfs, file);
+
+    LFS_TRACE("lfs_file_sync -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file,
+        void *buffer, lfs_size_t size) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_read(%p, %p, %p, %"PRIu32")",
+            (void*)lfs, (void*)file, buffer, size);
+    LFS_ASSERT(lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
+
+    lfs_ssize_t res = lfs_file_read_(lfs, file, buffer, size);
+
+    LFS_TRACE("lfs_file_read -> %"PRId32, res);
+    LFS_UNLOCK(lfs->cfg);
+    return res;
+}
+
+#ifndef LFS_READONLY
+lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file,
+        const void *buffer, lfs_size_t size) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_write(%p, %p, %p, %"PRIu32")",
+            (void*)lfs, (void*)file, buffer, size);
+    LFS_ASSERT(lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
+
+    lfs_ssize_t res = lfs_file_write_(lfs, file, buffer, size);
+
+    LFS_TRACE("lfs_file_write -> %"PRId32, res);
+    LFS_UNLOCK(lfs->cfg);
+    return res;
+}
+#endif
+
+lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file,
+        lfs_soff_t off, int whence) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_seek(%p, %p, %"PRId32", %d)",
+            (void*)lfs, (void*)file, off, whence);
+    LFS_ASSERT(lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
+
+    lfs_soff_t res = lfs_file_seek_(lfs, file, off, whence);
+
+    LFS_TRACE("lfs_file_seek -> %"PRId32, res);
+    LFS_UNLOCK(lfs->cfg);
+    return res;
+}
+
+#ifndef LFS_READONLY
+int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_truncate(%p, %p, %"PRIu32")",
+            (void*)lfs, (void*)file, size);
+    LFS_ASSERT(lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
+
+    err = lfs_file_truncate_(lfs, file, size);
+
+    LFS_TRACE("lfs_file_truncate -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+lfs_soff_t lfs_file_tell(lfs_t *lfs, lfs_file_t *file) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_tell(%p, %p)", (void*)lfs, (void*)file);
+    LFS_ASSERT(lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
+
+    lfs_soff_t res = lfs_file_tell_(lfs, file);
+
+    LFS_TRACE("lfs_file_tell -> %"PRId32, res);
+    LFS_UNLOCK(lfs->cfg);
+    return res;
+}
+
+int lfs_file_rewind(lfs_t *lfs, lfs_file_t *file) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_rewind(%p, %p)", (void*)lfs, (void*)file);
+
+    err = lfs_file_rewind_(lfs, file);
+
+    LFS_TRACE("lfs_file_rewind -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_file_size(%p, %p)", (void*)lfs, (void*)file);
+    LFS_ASSERT(lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
+
+    lfs_soff_t res = lfs_file_size_(lfs, file);
+
+    LFS_TRACE("lfs_file_size -> %"PRIu32, res);
+    LFS_UNLOCK(lfs->cfg);
+    return res;
+}
+
+#ifndef LFS_READONLY
+int lfs_mkdir(lfs_t *lfs, const char *path) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_mkdir(%p, \"%s\")", (void*)lfs, path);
+
+    err = lfs_mkdir_(lfs, path);
+
+    LFS_TRACE("lfs_mkdir -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+int lfs_dir_open(lfs_t *lfs, lfs_dir_t *dir, const char *path) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_dir_open(%p, %p, \"%s\")", (void*)lfs, (void*)dir, path);
+    LFS_ASSERT(!lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)dir));
+
+    err = lfs_dir_open_(lfs, dir, path);
+
+    LFS_TRACE("lfs_dir_open -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+int lfs_dir_close(lfs_t *lfs, lfs_dir_t *dir) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_dir_close(%p, %p)", (void*)lfs, (void*)dir);
+
+    err = lfs_dir_close_(lfs, dir);
+
+    LFS_TRACE("lfs_dir_close -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_dir_read(%p, %p, %p)",
+            (void*)lfs, (void*)dir, (void*)info);
+
+    err = lfs_dir_read_(lfs, dir, info);
+
+    LFS_TRACE("lfs_dir_read -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_dir_seek(%p, %p, %"PRIu32")",
+            (void*)lfs, (void*)dir, off);
+
+    err = lfs_dir_seek_(lfs, dir, off);
+
+    LFS_TRACE("lfs_dir_seek -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+lfs_soff_t lfs_dir_tell(lfs_t *lfs, lfs_dir_t *dir) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_dir_tell(%p, %p)", (void*)lfs, (void*)dir);
+
+    lfs_soff_t res = lfs_dir_tell_(lfs, dir);
+
+    LFS_TRACE("lfs_dir_tell -> %"PRId32, res);
+    LFS_UNLOCK(lfs->cfg);
+    return res;
+}
+
+int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_dir_rewind(%p, %p)", (void*)lfs, (void*)dir);
+
+    err = lfs_dir_rewind_(lfs, dir);
+
+    LFS_TRACE("lfs_dir_rewind -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+int lfs_fs_stat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_fs_stat(%p, %p)", (void*)lfs, (void*)fsinfo);
+
+    err = lfs_fs_stat_(lfs, fsinfo);
+
+    LFS_TRACE("lfs_fs_stat -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+lfs_ssize_t lfs_fs_size(lfs_t *lfs) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_fs_size(%p)", (void*)lfs);
+
+    lfs_ssize_t res = lfs_fs_size_(lfs);
+
+    LFS_TRACE("lfs_fs_size -> %"PRId32, res);
+    LFS_UNLOCK(lfs->cfg);
+    return res;
+}
+
+int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void *, lfs_block_t), void *data) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_fs_traverse(%p, %p, %p)",
+            (void*)lfs, (void*)(uintptr_t)cb, data);
+
+    err = lfs_fs_traverse_(lfs, cb, data, true);
+
+    LFS_TRACE("lfs_fs_traverse -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+
+#ifndef LFS_READONLY
+int lfs_fs_mkconsistent(lfs_t *lfs) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_fs_mkconsistent(%p)", (void*)lfs);
+
+    err = lfs_fs_mkconsistent_(lfs);
+
+    LFS_TRACE("lfs_fs_mkconsistent -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+#ifndef LFS_READONLY
+int lfs_fs_gc(lfs_t *lfs) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_fs_gc(%p)", (void*)lfs);
+
+    err = lfs_fs_gc_(lfs);
+
+    LFS_TRACE("lfs_fs_gc -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+#ifndef LFS_READONLY
+int lfs_fs_grow(lfs_t *lfs, lfs_size_t block_count) {
+    int err = LFS_LOCK(lfs->cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_fs_grow(%p, %"PRIu32")", (void*)lfs, block_count);
+
+    err = lfs_fs_grow_(lfs, block_count);
+
+    LFS_TRACE("lfs_fs_grow -> %d", err);
+    LFS_UNLOCK(lfs->cfg);
+    return err;
+}
+#endif
+
+#ifdef LFS_MIGRATE
+int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg) {
+    int err = LFS_LOCK(cfg);
+    if (err) {
+        return err;
+    }
+    LFS_TRACE("lfs_migrate(%p, %p {.context=%p, "
+                ".read=%p, .prog=%p, .erase=%p, .sync=%p, "
+                ".read_size=%"PRIu32", .prog_size=%"PRIu32", "
+                ".block_size=%"PRIu32", .block_count=%"PRIu32", "
+                ".block_cycles=%"PRId32", .cache_size=%"PRIu32", "
+                ".lookahead_size=%"PRIu32", .read_buffer=%p, "
+                ".prog_buffer=%p, .lookahead_buffer=%p, "
+                ".name_max=%"PRIu32", .file_max=%"PRIu32", "
+                ".attr_max=%"PRIu32"})",
+            (void*)lfs, (void*)cfg, cfg->context,
+            (void*)(uintptr_t)cfg->read, (void*)(uintptr_t)cfg->prog,
+            (void*)(uintptr_t)cfg->erase, (void*)(uintptr_t)cfg->sync,
+            cfg->read_size, cfg->prog_size, cfg->block_size, cfg->block_count,
+            cfg->block_cycles, cfg->cache_size, cfg->lookahead_size,
+            cfg->read_buffer, cfg->prog_buffer, cfg->lookahead_buffer,
+            cfg->name_max, cfg->file_max, cfg->attr_max);
+
+    err = lfs_migrate_(lfs, cfg);
+
+    LFS_TRACE("lfs_migrate -> %d", err);
+    LFS_UNLOCK(cfg);
+    return err;
+}
+#endif
+
diff --git a/APP/fs/lfs.h b/APP/fs/lfs.h
new file mode 100644 (file)
index 0000000..8fbd5b4
--- /dev/null
@@ -0,0 +1,802 @@
+/*
+ * The little filesystem
+ *
+ * Copyright (c) 2022, The littlefs authors.
+ * Copyright (c) 2017, Arm Limited. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#ifndef LFS_H
+#define LFS_H
+
+#include "lfs_util.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/// Version info ///
+
+// Software library version
+// Major (top-nibble), incremented on backwards incompatible changes
+// Minor (bottom-nibble), incremented on feature additions
+#define LFS_VERSION 0x0002000b
+#define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16))
+#define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >>  0))
+
+// Version of On-disk data structures
+// Major (top-nibble), incremented on backwards incompatible changes
+// Minor (bottom-nibble), incremented on feature additions
+#define LFS_DISK_VERSION 0x00020001
+#define LFS_DISK_VERSION_MAJOR (0xffff & (LFS_DISK_VERSION >> 16))
+#define LFS_DISK_VERSION_MINOR (0xffff & (LFS_DISK_VERSION >>  0))
+
+
+/// Definitions ///
+
+// Type definitions
+typedef uint32_t lfs_size_t;
+typedef uint32_t lfs_off_t;
+
+typedef int32_t  lfs_ssize_t;
+typedef int32_t  lfs_soff_t;
+
+typedef uint32_t lfs_block_t;
+
+// Maximum name size in bytes, may be redefined to reduce the size of the
+// info struct. Limited to <= 1022. Stored in superblock and must be
+// respected by other littlefs drivers.
+#ifndef LFS_NAME_MAX
+#define LFS_NAME_MAX 255
+#endif
+
+// Maximum size of a file in bytes, may be redefined to limit to support other
+// drivers. Limited on disk to <= 2147483647. Stored in superblock and must be
+// respected by other littlefs drivers.
+#ifndef LFS_FILE_MAX
+#define LFS_FILE_MAX 2147483647
+#endif
+
+// Maximum size of custom attributes in bytes, may be redefined, but there is
+// no real benefit to using a smaller LFS_ATTR_MAX. Limited to <= 1022. Stored
+// in superblock and must be respected by other littlefs drivers.
+#ifndef LFS_ATTR_MAX
+#define LFS_ATTR_MAX 1022
+#endif
+
+// Possible error codes, these are negative to allow
+// valid positive return values
+enum lfs_error {
+    LFS_ERR_OK          = 0,    // No error
+    LFS_ERR_IO          = -5,   // Error during device operation
+    LFS_ERR_CORRUPT     = -84,  // Corrupted
+    LFS_ERR_NOENT       = -2,   // No directory entry
+    LFS_ERR_EXIST       = -17,  // Entry already exists
+    LFS_ERR_NOTDIR      = -20,  // Entry is not a dir
+    LFS_ERR_ISDIR       = -21,  // Entry is a dir
+    LFS_ERR_NOTEMPTY    = -39,  // Dir is not empty
+    LFS_ERR_BADF        = -9,   // Bad file number
+    LFS_ERR_FBIG        = -27,  // File too large
+    LFS_ERR_INVAL       = -22,  // Invalid parameter
+    LFS_ERR_NOSPC       = -28,  // No space left on device
+    LFS_ERR_NOMEM       = -12,  // No more memory available
+    LFS_ERR_NOATTR      = -61,  // No data/attr available
+    LFS_ERR_NAMETOOLONG = -36,  // File name too long
+};
+
+// File types
+enum lfs_type {
+    // file types
+    LFS_TYPE_REG            = 0x001,
+    LFS_TYPE_DIR            = 0x002,
+
+    // internally used types
+    LFS_TYPE_SPLICE         = 0x400,
+    LFS_TYPE_NAME           = 0x000,
+    LFS_TYPE_STRUCT         = 0x200,
+    LFS_TYPE_USERATTR       = 0x300,
+    LFS_TYPE_FROM           = 0x100,
+    LFS_TYPE_TAIL           = 0x600,
+    LFS_TYPE_GLOBALS        = 0x700,
+    LFS_TYPE_CRC            = 0x500,
+
+    // internally used type specializations
+    LFS_TYPE_CREATE         = 0x401,
+    LFS_TYPE_DELETE         = 0x4ff,
+    LFS_TYPE_SUPERBLOCK     = 0x0ff,
+    LFS_TYPE_DIRSTRUCT      = 0x200,
+    LFS_TYPE_CTZSTRUCT      = 0x202,
+    LFS_TYPE_INLINESTRUCT   = 0x201,
+    LFS_TYPE_SOFTTAIL       = 0x600,
+    LFS_TYPE_HARDTAIL       = 0x601,
+    LFS_TYPE_MOVESTATE      = 0x7ff,
+    LFS_TYPE_CCRC           = 0x500,
+    LFS_TYPE_FCRC           = 0x5ff,
+
+    // internal chip sources
+    LFS_FROM_NOOP           = 0x000,
+    LFS_FROM_MOVE           = 0x101,
+    LFS_FROM_USERATTRS      = 0x102,
+};
+
+// File open flags
+enum lfs_open_flags {
+    // open flags
+    LFS_O_RDONLY = 1,         // Open a file as read only
+#ifndef LFS_READONLY
+    LFS_O_WRONLY = 2,         // Open a file as write only
+    LFS_O_RDWR   = 3,         // Open a file as read and write
+    LFS_O_CREAT  = 0x0100,    // Create a file if it does not exist
+    LFS_O_EXCL   = 0x0200,    // Fail if a file already exists
+    LFS_O_TRUNC  = 0x0400,    // Truncate the existing file to zero size
+    LFS_O_APPEND = 0x0800,    // Move to end of file on every write
+#endif
+
+    // internally used flags
+#ifndef LFS_READONLY
+    LFS_F_DIRTY   = 0x00010000, // File does not match storage due to write
+    LFS_F_DUSTY   = 0x00020000, // File does not match storage due to desync
+    LFS_F_WRITING = 0x00040000, // File has been written since last flush
+#endif
+    LFS_F_READING = 0x00080000, // File has been read since last flush
+#ifndef LFS_READONLY
+    LFS_F_ERRED   = 0x00100000, // An error occurred during write
+#endif
+    LFS_F_INLINE  = 0x01000000, // Currently inlined in directory entry
+};
+
+// File seek flags
+enum lfs_whence_flags {
+    LFS_SEEK_SET = 0,   // Seek relative to an absolute position
+    LFS_SEEK_CUR = 1,   // Seek relative to the current file position
+    LFS_SEEK_END = 2,   // Seek relative to the end of the file
+};
+
+
+// Configuration provided during initialization of the littlefs
+struct lfs_config {
+    // Opaque user provided context that can be used to pass
+    // information to the block device operations
+    void *context;
+
+    // Read a region in a block. Negative error codes are propagated
+    // to the user.
+    int (*read)(const struct lfs_config *c, lfs_block_t block,
+            lfs_off_t off, void *buffer, lfs_size_t size);
+
+    // Program a region in a block. The block must have previously
+    // been erased. Negative error codes are propagated to the user.
+    // May return LFS_ERR_CORRUPT if the block should be considered bad.
+    int (*prog)(const struct lfs_config *c, lfs_block_t block,
+            lfs_off_t off, const void *buffer, lfs_size_t size);
+
+    // Erase a block. A block must be erased before being programmed.
+    // The state of an erased block is undefined. Negative error codes
+    // are propagated to the user.
+    // May return LFS_ERR_CORRUPT if the block should be considered bad.
+    int (*erase)(const struct lfs_config *c, lfs_block_t block);
+
+    // Sync the state of the underlying block device. Negative error codes
+    // are propagated to the user.
+    int (*sync)(const struct lfs_config *c);
+
+#ifdef LFS_THREADSAFE
+    // Lock the underlying block device. Negative error codes
+    // are propagated to the user.
+    int (*lock)(const struct lfs_config *c);
+
+    // Unlock the underlying block device. Negative error codes
+    // are propagated to the user.
+    int (*unlock)(const struct lfs_config *c);
+#endif
+
+    // Minimum size of a block read in bytes. All read operations will be a
+    // multiple of this value.
+    lfs_size_t read_size;
+
+    // Minimum size of a block program in bytes. All program operations will be
+    // a multiple of this value.
+    lfs_size_t prog_size;
+
+    // Size of an erasable block in bytes. This does not impact ram consumption
+    // and may be larger than the physical erase size. However, non-inlined
+    // files take up at minimum one block. Must be a multiple of the read and
+    // program sizes.
+    lfs_size_t block_size;
+
+    // Number of erasable blocks on the device. Defaults to block_count stored
+    // on disk when zero.
+    lfs_size_t block_count;
+
+    // Number of erase cycles before littlefs evicts metadata logs and moves
+    // the metadata to another block. Suggested values are in the
+    // range 100-1000, with large values having better performance at the cost
+    // of less consistent wear distribution.
+    //
+    // Set to -1 to disable block-level wear-leveling.
+    int32_t block_cycles;
+
+    // Size of block caches in bytes. Each cache buffers a portion of a block in
+    // RAM. The littlefs needs a read cache, a program cache, and one additional
+    // cache per file. Larger caches can improve performance by storing more
+    // data and reducing the number of disk accesses. Must be a multiple of the
+    // read and program sizes, and a factor of the block size.
+    lfs_size_t cache_size;
+
+    // Size of the lookahead buffer in bytes. A larger lookahead buffer
+    // increases the number of blocks found during an allocation pass. The
+    // lookahead buffer is stored as a compact bitmap, so each byte of RAM
+    // can track 8 blocks.
+    lfs_size_t lookahead_size;
+
+    // Threshold for metadata compaction during lfs_fs_gc in bytes. Metadata
+    // pairs that exceed this threshold will be compacted during lfs_fs_gc.
+    // Defaults to ~88% block_size when zero, though the default may change
+    // in the future.
+    //
+    // Note this only affects lfs_fs_gc. Normal compactions still only occur
+    // when full.
+    //
+    // Set to -1 to disable metadata compaction during lfs_fs_gc.
+    lfs_size_t compact_thresh;
+
+    // Optional statically allocated read buffer. Must be cache_size.
+    // By default lfs_malloc is used to allocate this buffer.
+    void *read_buffer;
+
+    // Optional statically allocated program buffer. Must be cache_size.
+    // By default lfs_malloc is used to allocate this buffer.
+    void *prog_buffer;
+
+    // Optional statically allocated lookahead buffer. Must be lookahead_size.
+    // By default lfs_malloc is used to allocate this buffer.
+    void *lookahead_buffer;
+
+    // Optional upper limit on length of file names in bytes. No downside for
+    // larger names except the size of the info struct which is controlled by
+    // the LFS_NAME_MAX define. Defaults to LFS_NAME_MAX or name_max stored on
+    // disk when zero.
+    lfs_size_t name_max;
+
+    // Optional upper limit on files in bytes. No downside for larger files
+    // but must be <= LFS_FILE_MAX. Defaults to LFS_FILE_MAX or file_max stored
+    // on disk when zero.
+    lfs_size_t file_max;
+
+    // Optional upper limit on custom attributes in bytes. No downside for
+    // larger attributes size but must be <= LFS_ATTR_MAX. Defaults to
+    // LFS_ATTR_MAX or attr_max stored on disk when zero.
+    lfs_size_t attr_max;
+
+    // Optional upper limit on total space given to metadata pairs in bytes. On
+    // devices with large blocks (e.g. 128kB) setting this to a low size (2-8kB)
+    // can help bound the metadata compaction time. Must be <= block_size.
+    // Defaults to block_size when zero.
+    lfs_size_t metadata_max;
+
+    // Optional upper limit on inlined files in bytes. Inlined files live in
+    // metadata and decrease storage requirements, but may be limited to
+    // improve metadata-related performance. Must be <= cache_size, <=
+    // attr_max, and <= block_size/8. Defaults to the largest possible
+    // inline_max when zero.
+    //
+    // Set to -1 to disable inlined files.
+    lfs_size_t inline_max;
+
+#ifdef LFS_MULTIVERSION
+    // On-disk version to use when writing in the form of 16-bit major version
+    // + 16-bit minor version. This limiting metadata to what is supported by
+    // older minor versions. Note that some features will be lost. Defaults to 
+    // to the most recent minor version when zero.
+    uint32_t disk_version;
+#endif
+};
+
+// File info structure
+struct lfs_info {
+    // Type of the file, either LFS_TYPE_REG or LFS_TYPE_DIR
+    uint8_t type;
+
+    // Size of the file, only valid for REG files. Limited to 32-bits.
+    lfs_size_t size;
+
+    // Name of the file stored as a null-terminated string. Limited to
+    // LFS_NAME_MAX+1, which can be changed by redefining LFS_NAME_MAX to
+    // reduce RAM. LFS_NAME_MAX is stored in superblock and must be
+    // respected by other littlefs drivers.
+    char name[LFS_NAME_MAX+1];
+};
+
+// Filesystem info structure
+struct lfs_fsinfo {
+    // On-disk version.
+    uint32_t disk_version;
+
+    // Size of a logical block in bytes.
+    lfs_size_t block_size;
+
+    // Number of logical blocks in filesystem.
+    lfs_size_t block_count;
+
+    // Upper limit on the length of file names in bytes.
+    lfs_size_t name_max;
+
+    // Upper limit on the size of files in bytes.
+    lfs_size_t file_max;
+
+    // Upper limit on the size of custom attributes in bytes.
+    lfs_size_t attr_max;
+};
+
+// Custom attribute structure, used to describe custom attributes
+// committed atomically during file writes.
+struct lfs_attr {
+    // 8-bit type of attribute, provided by user and used to
+    // identify the attribute
+    uint8_t type;
+
+    // Pointer to buffer containing the attribute
+    void *buffer;
+
+    // Size of attribute in bytes, limited to LFS_ATTR_MAX
+    lfs_size_t size;
+};
+
+// Optional configuration provided during lfs_file_opencfg
+struct lfs_file_config {
+    // Optional statically allocated file buffer. Must be cache_size.
+    // By default lfs_malloc is used to allocate this buffer.
+    void *buffer;
+
+    // Optional list of custom attributes related to the file. If the file
+    // is opened with read access, these attributes will be read from disk
+    // during the open call. If the file is opened with write access, the
+    // attributes will be written to disk every file sync or close. This
+    // write occurs atomically with update to the file's contents.
+    //
+    // Custom attributes are uniquely identified by an 8-bit type and limited
+    // to LFS_ATTR_MAX bytes. When read, if the stored attribute is smaller
+    // than the buffer, it will be padded with zeros. If the stored attribute
+    // is larger, then it will be silently truncated. If the attribute is not
+    // found, it will be created implicitly.
+    struct lfs_attr *attrs;
+
+    // Number of custom attributes in the list
+    lfs_size_t attr_count;
+};
+
+
+/// internal littlefs data structures ///
+typedef struct lfs_cache {
+    lfs_block_t block;
+    lfs_off_t off;
+    lfs_size_t size;
+    uint8_t *buffer;
+} lfs_cache_t;
+
+typedef struct lfs_mdir {
+    lfs_block_t pair[2];
+    uint32_t rev;
+    lfs_off_t off;
+    uint32_t etag;
+    uint16_t count;
+    bool erased;
+    bool split;
+    lfs_block_t tail[2];
+} lfs_mdir_t;
+
+// littlefs directory type
+typedef struct lfs_dir {
+    struct lfs_dir *next;
+    uint16_t id;
+    uint8_t type;
+    lfs_mdir_t m;
+
+    lfs_off_t pos;
+    lfs_block_t head[2];
+} lfs_dir_t;
+
+// littlefs file type
+typedef struct lfs_file {
+    struct lfs_file *next;
+    uint16_t id;
+    uint8_t type;
+    lfs_mdir_t m;
+
+    struct lfs_ctz {
+        lfs_block_t head;
+        lfs_size_t size;
+    } ctz;
+
+    uint32_t flags;
+    lfs_off_t pos;
+    lfs_block_t block;
+    lfs_off_t off;
+    lfs_cache_t cache;
+
+    const struct lfs_file_config *cfg;
+} lfs_file_t;
+
+typedef struct lfs_superblock {
+    uint32_t version;
+    lfs_size_t block_size;
+    lfs_size_t block_count;
+    lfs_size_t name_max;
+    lfs_size_t file_max;
+    lfs_size_t attr_max;
+} lfs_superblock_t;
+
+typedef struct lfs_gstate {
+    uint32_t tag;
+    lfs_block_t pair[2];
+} lfs_gstate_t;
+
+// The littlefs filesystem type
+typedef struct lfs {
+    lfs_cache_t rcache;
+    lfs_cache_t pcache;
+
+    lfs_block_t root[2];
+    struct lfs_mlist {
+        struct lfs_mlist *next;
+        uint16_t id;
+        uint8_t type;
+        lfs_mdir_t m;
+    } *mlist;
+    uint32_t seed;
+
+    lfs_gstate_t gstate;
+    lfs_gstate_t gdisk;
+    lfs_gstate_t gdelta;
+
+    struct lfs_lookahead {
+        lfs_block_t start;
+        lfs_block_t size;
+        lfs_block_t next;
+        lfs_block_t ckpoint;
+        uint8_t *buffer;
+    } lookahead;
+
+    const struct lfs_config *cfg;
+    lfs_size_t block_count;
+    lfs_size_t name_max;
+    lfs_size_t file_max;
+    lfs_size_t attr_max;
+    lfs_size_t inline_max;
+
+#ifdef LFS_MIGRATE
+    struct lfs1 *lfs1;
+#endif
+} lfs_t;
+
+
+/// Filesystem functions ///
+
+#ifndef LFS_READONLY
+// Format a block device with the littlefs
+//
+// Requires a littlefs object and config struct. This clobbers the littlefs
+// object, and does not leave the filesystem mounted. The config struct must
+// be zeroed for defaults and backwards compatibility.
+//
+// Returns a negative error code on failure.
+int lfs_format(lfs_t *lfs, const struct lfs_config *config);
+#endif
+
+// Mounts a littlefs
+//
+// Requires a littlefs object and config struct. Multiple filesystems
+// may be mounted simultaneously with multiple littlefs objects. Both
+// lfs and config must be allocated while mounted. The config struct must
+// be zeroed for defaults and backwards compatibility.
+//
+// Returns a negative error code on failure.
+int lfs_mount(lfs_t *lfs, const struct lfs_config *config);
+
+// Unmounts a littlefs
+//
+// Does nothing besides releasing any allocated resources.
+// Returns a negative error code on failure.
+int lfs_unmount(lfs_t *lfs);
+
+/// General operations ///
+
+#ifndef LFS_READONLY
+// Removes a file or directory
+//
+// If removing a directory, the directory must be empty.
+// Returns a negative error code on failure.
+int lfs_remove(lfs_t *lfs, const char *path);
+#endif
+
+#ifndef LFS_READONLY
+// Rename or move a file or directory
+//
+// If the destination exists, it must match the source in type.
+// If the destination is a directory, the directory must be empty.
+//
+// Returns a negative error code on failure.
+int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath);
+#endif
+
+// Find info about a file or directory
+//
+// Fills out the info structure, based on the specified file or directory.
+// Returns a negative error code on failure.
+int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info);
+
+// Get a custom attribute
+//
+// Custom attributes are uniquely identified by an 8-bit type and limited
+// to LFS_ATTR_MAX bytes. When read, if the stored attribute is smaller than
+// the buffer, it will be padded with zeros. If the stored attribute is larger,
+// then it will be silently truncated. If no attribute is found, the error
+// LFS_ERR_NOATTR is returned and the buffer is filled with zeros.
+//
+// Returns the size of the attribute, or a negative error code on failure.
+// Note, the returned size is the size of the attribute on disk, irrespective
+// of the size of the buffer. This can be used to dynamically allocate a buffer
+// or check for existence.
+lfs_ssize_t lfs_getattr(lfs_t *lfs, const char *path,
+        uint8_t type, void *buffer, lfs_size_t size);
+
+#ifndef LFS_READONLY
+// Set custom attributes
+//
+// Custom attributes are uniquely identified by an 8-bit type and limited
+// to LFS_ATTR_MAX bytes. If an attribute is not found, it will be
+// implicitly created.
+//
+// Returns a negative error code on failure.
+int lfs_setattr(lfs_t *lfs, const char *path,
+        uint8_t type, const void *buffer, lfs_size_t size);
+#endif
+
+#ifndef LFS_READONLY
+// Removes a custom attribute
+//
+// If an attribute is not found, nothing happens.
+//
+// Returns a negative error code on failure.
+int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type);
+#endif
+
+
+/// File operations ///
+
+#ifndef LFS_NO_MALLOC
+// Open a file
+//
+// The mode that the file is opened in is determined by the flags, which
+// are values from the enum lfs_open_flags that are bitwise-ored together.
+//
+// Returns a negative error code on failure.
+int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
+        const char *path, int flags);
+
+// if LFS_NO_MALLOC is defined, lfs_file_open() will fail with LFS_ERR_NOMEM
+// thus use lfs_file_opencfg() with config.buffer set.
+#endif
+
+// Open a file with extra configuration
+//
+// The mode that the file is opened in is determined by the flags, which
+// are values from the enum lfs_open_flags that are bitwise-ored together.
+//
+// The config struct provides additional config options per file as described
+// above. The config struct must remain allocated while the file is open, and
+// the config struct must be zeroed for defaults and backwards compatibility.
+//
+// Returns a negative error code on failure.
+int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file,
+        const char *path, int flags,
+        const struct lfs_file_config *config);
+
+// Close a file
+//
+// Any pending writes are written out to storage as though
+// sync had been called and releases any allocated resources.
+//
+// Returns a negative error code on failure.
+int lfs_file_close(lfs_t *lfs, lfs_file_t *file);
+
+// Synchronize a file on storage
+//
+// Any pending writes are written out to storage.
+// Returns a negative error code on failure.
+int lfs_file_sync(lfs_t *lfs, lfs_file_t *file);
+
+// Read data from file
+//
+// Takes a buffer and size indicating where to store the read data.
+// Returns the number of bytes read, or a negative error code on failure.
+lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file,
+        void *buffer, lfs_size_t size);
+
+#ifndef LFS_READONLY
+// Write data to file
+//
+// Takes a buffer and size indicating the data to write. The file will not
+// actually be updated on the storage until either sync or close is called.
+//
+// Returns the number of bytes written, or a negative error code on failure.
+lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file,
+        const void *buffer, lfs_size_t size);
+#endif
+
+// Change the position of the file
+//
+// The change in position is determined by the offset and whence flag.
+// Returns the new position of the file, or a negative error code on failure.
+lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file,
+        lfs_soff_t off, int whence);
+
+#ifndef LFS_READONLY
+// Truncates the size of the file to the specified size
+//
+// Returns a negative error code on failure.
+int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size);
+#endif
+
+// Return the position of the file
+//
+// Equivalent to lfs_file_seek(lfs, file, 0, LFS_SEEK_CUR)
+// Returns the position of the file, or a negative error code on failure.
+lfs_soff_t lfs_file_tell(lfs_t *lfs, lfs_file_t *file);
+
+// Change the position of the file to the beginning of the file
+//
+// Equivalent to lfs_file_seek(lfs, file, 0, LFS_SEEK_SET)
+// Returns a negative error code on failure.
+int lfs_file_rewind(lfs_t *lfs, lfs_file_t *file);
+
+// Return the size of the file
+//
+// Similar to lfs_file_seek(lfs, file, 0, LFS_SEEK_END)
+// Returns the size of the file, or a negative error code on failure.
+lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file);
+
+
+/// Directory operations ///
+
+#ifndef LFS_READONLY
+// Create a directory
+//
+// Returns a negative error code on failure.
+int lfs_mkdir(lfs_t *lfs, const char *path);
+#endif
+
+// Open a directory
+//
+// Once open a directory can be used with read to iterate over files.
+// Returns a negative error code on failure.
+int lfs_dir_open(lfs_t *lfs, lfs_dir_t *dir, const char *path);
+
+// Close a directory
+//
+// Releases any allocated resources.
+// Returns a negative error code on failure.
+int lfs_dir_close(lfs_t *lfs, lfs_dir_t *dir);
+
+// Read an entry in the directory
+//
+// Fills out the info structure, based on the specified file or directory.
+// Returns a positive value on success, 0 at the end of directory,
+// or a negative error code on failure.
+int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info);
+
+// Change the position of the directory
+//
+// The new off must be a value previous returned from tell and specifies
+// an absolute offset in the directory seek.
+//
+// Returns a negative error code on failure.
+int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off);
+
+// Return the position of the directory
+//
+// The returned offset is only meant to be consumed by seek and may not make
+// sense, but does indicate the current position in the directory iteration.
+//
+// Returns the position of the directory, or a negative error code on failure.
+lfs_soff_t lfs_dir_tell(lfs_t *lfs, lfs_dir_t *dir);
+
+// Change the position of the directory to the beginning of the directory
+//
+// Returns a negative error code on failure.
+int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir);
+
+
+/// Filesystem-level filesystem operations
+
+// Find on-disk info about the filesystem
+//
+// Fills out the fsinfo structure based on the filesystem found on-disk.
+// Returns a negative error code on failure.
+int lfs_fs_stat(lfs_t *lfs, struct lfs_fsinfo *fsinfo);
+
+// Finds the current size of the filesystem
+//
+// Note: Result is best effort. If files share COW structures, the returned
+// size may be larger than the filesystem actually is.
+//
+// Returns the number of allocated blocks, or a negative error code on failure.
+lfs_ssize_t lfs_fs_size(lfs_t *lfs);
+
+// Traverse through all blocks in use by the filesystem
+//
+// The provided callback will be called with each block address that is
+// currently in use by the filesystem. This can be used to determine which
+// blocks are in use or how much of the storage is available.
+//
+// Returns a negative error code on failure.
+int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data);
+
+#ifndef LFS_READONLY
+// Attempt to make the filesystem consistent and ready for writing
+//
+// Calling this function is not required, consistency will be implicitly
+// enforced on the first operation that writes to the filesystem, but this
+// function allows the work to be performed earlier and without other
+// filesystem changes.
+//
+// Returns a negative error code on failure.
+int lfs_fs_mkconsistent(lfs_t *lfs);
+#endif
+
+#ifndef LFS_READONLY
+// Attempt any janitorial work
+//
+// This currently:
+// 1. Calls mkconsistent if not already consistent
+// 2. Compacts metadata > compact_thresh
+// 3. Populates the block allocator
+//
+// Though additional janitorial work may be added in the future.
+//
+// Calling this function is not required, but may allow the offloading of
+// expensive janitorial work to a less time-critical code path.
+//
+// Returns a negative error code on failure. Accomplishing nothing is not
+// an error.
+int lfs_fs_gc(lfs_t *lfs);
+#endif
+
+#ifndef LFS_READONLY
+// Grows the filesystem to a new size, updating the superblock with the new
+// block count.
+//
+// If LFS_SHRINKNONRELOCATING is defined, this function will also accept
+// block_counts smaller than the current configuration, after checking
+// that none of the blocks that are being removed are in use.
+// Note that littlefs's pseudorandom block allocation means that
+// this is very unlikely to work in the general case.
+//
+// Returns a negative error code on failure.
+int lfs_fs_grow(lfs_t *lfs, lfs_size_t block_count);
+#endif
+
+#ifndef LFS_READONLY
+#ifdef LFS_MIGRATE
+// Attempts to migrate a previous version of littlefs
+//
+// Behaves similarly to the lfs_format function. Attempts to mount
+// the previous version of littlefs and update the filesystem so it can be
+// mounted with the current version of littlefs.
+//
+// Requires a littlefs object and config struct. This clobbers the littlefs
+// object, and does not leave the filesystem mounted. The config struct must
+// be zeroed for defaults and backwards compatibility.
+//
+// Returns a negative error code on failure.
+int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg);
+#endif
+#endif
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
diff --git a/APP/fs/lfs_port.c b/APP/fs/lfs_port.c
new file mode 100644 (file)
index 0000000..15bd31b
--- /dev/null
@@ -0,0 +1,123 @@
+/**
+ *******************************************************************************************************************************************
+ * @file        lfs_port.c
+ * @brief       littlefs 移植层: 将块设备读写映射到片外 SPI Flash GD25Q128E 最后一个 8M 分区
+ * @details     物理布局: 分区4 位于片外 Flash 偏移 0x600000, 大小 8M。
+ *              块设备参数:
+ *                - 读/写最小粒度 256B (一页 / prog_size)
+ *                - 块大小     4K  (一个扇区 / 擦除单位)
+ *                - 总块数     2048
+ *******************************************************************************************************************************************
+ */
+#include <string.h>
+#include "SWM341.h"
+#include "lfs.h"
+#include "lfs_port.h"
+#include "SPI_GD25Q128.h"
+
+/* 静态缓存: 避免依赖动态内存 (读缓存/写缓存/前瞻缓存) */
+__attribute__((aligned(4))) static uint8_t s_read_buf[FS_CACHE_SIZE];
+__attribute__((aligned(4))) static uint8_t s_prog_buf[FS_CACHE_SIZE];
+__attribute__((aligned(4))) static uint8_t s_lookahead_buf[FS_BLOCK_COUNT / 8];
+
+/* littlefs 全局实例 */
+lfs_t fs_lfs;
+
+/*************************************************************************************************************
+ * Block Device Callbacks
+ *************************************************************************************************************/
+static int lfs_flash_read(const struct lfs_config *c,
+                          lfs_block_t block, lfs_off_t off,
+                          void *buffer, lfs_size_t size)
+{
+    uint32_t addr = FS_PART4_OFF + (uint32_t)block * FS_BLOCK_SIZE + off;
+
+    (void)c;
+    GD25Q128_ReadData(addr, buffer, size);
+    return LFS_ERR_OK;
+}
+
+static int lfs_flash_prog(const struct lfs_config *c,
+                          lfs_block_t block, lfs_off_t off,
+                          const void *buffer, lfs_size_t size)
+{
+    uint32_t addr = FS_PART4_OFF + (uint32_t)block * FS_BLOCK_SIZE + off;
+
+    (void)c;
+    GD25Q128_WritePage(addr, (uint8_t *)buffer, size);
+    while (GD25Q128_IsBusy()) { __NOP(); }   /* 等待页编程完成 */
+    return LFS_ERR_OK;
+}
+
+static int lfs_flash_erase(const struct lfs_config *c, lfs_block_t block)
+{
+    uint32_t addr = FS_PART4_OFF + (uint32_t)block * FS_BLOCK_SIZE;
+
+    (void)c;
+    GD25Q128_EraseSector(addr);
+    while (GD25Q128_IsBusy()) { __NOP(); }   /* 等待扇区擦除完成 */
+    return LFS_ERR_OK;
+}
+
+static int lfs_flash_sync(const struct lfs_config *c)
+{
+    (void)c;
+    return LFS_ERR_OK;
+}
+
+/*************************************************************************************************************
+ * littlefs 配置: 绑定底层回调与静态缓存 (编译期完成)
+ *************************************************************************************************************/
+struct lfs_config fs_cfg = {
+    .context        = NULL,
+
+    .read           = lfs_flash_read,
+    .prog           = lfs_flash_prog,
+    .erase          = lfs_flash_erase,
+    .sync           = lfs_flash_sync,
+
+    .read_size      = FS_READ_PROG_SIZE,
+    .prog_size      = FS_READ_PROG_SIZE,
+    .block_size     = FS_BLOCK_SIZE,
+    .block_count    = FS_BLOCK_COUNT,
+    .block_cycles   = 500,
+    .cache_size     = FS_CACHE_SIZE,
+    .lookahead_size = FS_BLOCK_COUNT / 8,
+
+    .read_buffer        = s_read_buf,
+    .prog_buffer        = s_prog_buf,
+    .lookahead_buffer   = s_lookahead_buf,
+
+    .name_max       = 0,
+    .file_max       = 0,
+    .attr_max       = 0,
+};
+
+/*************************************************************************************************************
+ * Public API
+ *************************************************************************************************************/
+void fs_littlefs_flash_init(void)
+{
+    static uint8_t inited = 0;
+
+    if (inited)
+        return;
+
+    GD25Q128_Init();
+    inited = 1;
+}
+
+int fs_littlefs_format(void)
+{
+    return lfs_format(&fs_lfs, &fs_cfg);
+}
+
+int fs_littlefs_mount(void)
+{
+    return lfs_mount(&fs_lfs, &fs_cfg);
+}
+
+void fs_littlefs_unmount(void)
+{
+    lfs_unmount(&fs_lfs);
+}
\ No newline at end of file
diff --git a/APP/fs/lfs_port.h b/APP/fs/lfs_port.h
new file mode 100644 (file)
index 0000000..7b5206d
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ *******************************************************************************************************************************************
+ * @file        lfs_port.h
+ * @brief       littlefs 移植层对外接口 (片外 SPI Flash GD25Q128E, 最后一个 8M 分区)
+ * @details     littlefs 核心放在 APP/fs 目录, 底层读写/擦除映射到 GD25Q128E 的
+ *              最后一个 8M 分区 (偏移 IAP_PART4_OFF=0x600000)。
+ *              移植层提供全局 lfs_t / lfs_config, APP 可直接调用 littlefs 全功能 API。
+ *******************************************************************************************************************************************
+ */
+#ifndef __LFS_PORT_H__
+#define __LFS_PORT_H__
+
+#include "lfs.h"
+
+/* littlefs 实例与底层配置 (供 APP 直接使用 lfs_xxx API) */
+extern lfs_t               fs_lfs;
+extern struct lfs_config   fs_cfg;
+
+/* 分区地址/容量配置 */
+#define FS_PART4_OFF        0x600000u          /* SPI Flash 偏移: 最后一个 8M 分区 */
+#define FS_FLASH_SIZE       0x800000u          /* littlefs 分区大小  8M             */
+#define FS_BLOCK_SIZE       4096u              /* 一个块 = 一个 4K 扇区              */
+#define FS_BLOCK_COUNT      (FS_FLASH_SIZE / FS_BLOCK_SIZE)   /* 2048 块             */
+#define FS_READ_PROG_SIZE   256u               /* 读写最小粒度 = 一页                 */
+#define FS_CACHE_SIZE       512u               /* 块缓存                              */
+
+void fs_littlefs_flash_init(void);             /* 初始化 SPI Flash (勿重复调用)      */
+int  fs_littlefs_mount(void);                  /* 挂载, 若未格式化返回 LFS_ERR_NOATTR */
+int  fs_littlefs_format(void);                 /* 格式化整个分区                      */
+void fs_littlefs_unmount(void);                /* 卸载                                */
+
+#endif /* __LFS_PORT_H__ */
\ No newline at end of file
diff --git a/APP/fs/lfs_util.c b/APP/fs/lfs_util.c
new file mode 100644 (file)
index 0000000..dac72ab
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * lfs util functions
+ *
+ * Copyright (c) 2022, The littlefs authors.
+ * Copyright (c) 2017, Arm Limited. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include "lfs_util.h"
+
+// Only compile if user does not provide custom config
+#ifndef LFS_CONFIG
+
+
+// If user provides their own CRC impl we don't need this
+#ifndef LFS_CRC
+// Software CRC implementation with small lookup table
+uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
+    static const uint32_t rtable[16] = {
+        0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
+        0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
+        0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
+        0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c,
+    };
+
+    const uint8_t *data = buffer;
+
+    for (size_t i = 0; i < size; i++) {
+        crc = (crc >> 4) ^ rtable[(crc ^ (data[i] >> 0)) & 0xf];
+        crc = (crc >> 4) ^ rtable[(crc ^ (data[i] >> 4)) & 0xf];
+    }
+
+    return crc;
+}
+#endif
+
+
+#endif
diff --git a/APP/fs/lfs_util.h b/APP/fs/lfs_util.h
new file mode 100644 (file)
index 0000000..0ef31ef
--- /dev/null
@@ -0,0 +1,281 @@
+/*
+ * lfs utility functions
+ *
+ * Copyright (c) 2022, The littlefs authors.
+ * Copyright (c) 2017, Arm Limited. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#ifndef LFS_UTIL_H
+#define LFS_UTIL_H
+
+/* ---- Bootloader/APP 精简配置: 关闭断言与所有日志输出以减小代码体积 ---- */
+#define LFS_NO_ASSERT
+#define LFS_NO_DEBUG
+#define LFS_NO_WARN
+#define LFS_NO_ERROR
+#define LFS_NO_TRACE
+/* ---------------------------------------------------------------------- */
+
+#define LFS_STRINGIZE(x) LFS_STRINGIZE2(x)
+#define LFS_STRINGIZE2(x) #x
+
+// Users can override lfs_util.h with their own configuration by defining
+// LFS_CONFIG as a header file to include (-DLFS_CONFIG=lfs_config.h).
+//
+// If LFS_CONFIG is used, none of the default utils will be emitted and must be
+// provided by the config file. To start, I would suggest copying lfs_util.h
+// and modifying as needed.
+#ifdef LFS_CONFIG
+#include LFS_STRINGIZE(LFS_CONFIG)
+#else
+
+// Alternatively, users can provide a header file which defines
+// macros and other things consumed by littlefs.
+//
+// For example, provide my_defines.h, which contains
+// something like:
+//
+// #include <stddef.h>
+// extern void *my_malloc(size_t sz);
+// #define LFS_MALLOC(sz) my_malloc(sz)
+//
+// And build littlefs with the header by defining LFS_DEFINES.
+// (-DLFS_DEFINES=my_defines.h)
+
+#ifdef LFS_DEFINES
+#include LFS_STRINGIZE(LFS_DEFINES)
+#endif
+
+// System includes
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+#include <inttypes.h>
+
+#ifndef LFS_NO_MALLOC
+#include <stdlib.h>
+#endif
+#ifndef LFS_NO_ASSERT
+#include <assert.h>
+#endif
+#if !defined(LFS_NO_DEBUG) || \
+        !defined(LFS_NO_WARN) || \
+        !defined(LFS_NO_ERROR) || \
+        defined(LFS_YES_TRACE)
+#include <stdio.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+// Macros, may be replaced by system specific wrappers. Arguments to these
+// macros must not have side-effects as the macros can be removed for a smaller
+// code footprint
+
+// Logging functions
+#ifndef LFS_TRACE
+#ifdef LFS_YES_TRACE
+#define LFS_TRACE_(fmt, ...) \
+    printf("%s:%d:trace: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__)
+#define LFS_TRACE(...) LFS_TRACE_(__VA_ARGS__, "")
+#else
+#define LFS_TRACE(...)
+#endif
+#endif
+
+#ifndef LFS_DEBUG
+#ifndef LFS_NO_DEBUG
+#define LFS_DEBUG_(fmt, ...) \
+    printf("%s:%d:debug: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__)
+#define LFS_DEBUG(...) LFS_DEBUG_(__VA_ARGS__, "")
+#else
+#define LFS_DEBUG(...)
+#endif
+#endif
+
+#ifndef LFS_WARN
+#ifndef LFS_NO_WARN
+#define LFS_WARN_(fmt, ...) \
+    printf("%s:%d:warn: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__)
+#define LFS_WARN(...) LFS_WARN_(__VA_ARGS__, "")
+#else
+#define LFS_WARN(...)
+#endif
+#endif
+
+#ifndef LFS_ERROR
+#ifndef LFS_NO_ERROR
+#define LFS_ERROR_(fmt, ...) \
+    printf("%s:%d:error: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__)
+#define LFS_ERROR(...) LFS_ERROR_(__VA_ARGS__, "")
+#else
+#define LFS_ERROR(...)
+#endif
+#endif
+
+// Runtime assertions
+#ifndef LFS_ASSERT
+#ifndef LFS_NO_ASSERT
+#define LFS_ASSERT(test) assert(test)
+#else
+#define LFS_ASSERT(test)
+#endif
+#endif
+
+
+// Builtin functions, these may be replaced by more efficient
+// toolchain-specific implementations. LFS_NO_INTRINSICS falls back to a more
+// expensive basic C implementation for debugging purposes
+
+// Min/max functions for unsigned 32-bit numbers
+static inline uint32_t lfs_max(uint32_t a, uint32_t b) {
+    return (a > b) ? a : b;
+}
+
+static inline uint32_t lfs_min(uint32_t a, uint32_t b) {
+    return (a < b) ? a : b;
+}
+
+// Align to nearest multiple of a size
+static inline uint32_t lfs_aligndown(uint32_t a, uint32_t alignment) {
+    return a - (a % alignment);
+}
+
+static inline uint32_t lfs_alignup(uint32_t a, uint32_t alignment) {
+    return lfs_aligndown(a + alignment-1, alignment);
+}
+
+// Find the smallest power of 2 greater than or equal to a
+static inline uint32_t lfs_npw2(uint32_t a) {
+#if !defined(LFS_NO_INTRINSICS) && (defined(__GNUC__) || defined(__CC_ARM))
+    return 32 - __builtin_clz(a-1);
+#else
+    uint32_t r = 0;
+    uint32_t s;
+    a -= 1;
+    s = (a > 0xffff) << 4; a >>= s; r |= s;
+    s = (a > 0xff  ) << 3; a >>= s; r |= s;
+    s = (a > 0xf   ) << 2; a >>= s; r |= s;
+    s = (a > 0x3   ) << 1; a >>= s; r |= s;
+    return (r | (a >> 1)) + 1;
+#endif
+}
+
+// Count the number of trailing binary zeros in a
+// lfs_ctz(0) may be undefined
+static inline uint32_t lfs_ctz(uint32_t a) {
+#if !defined(LFS_NO_INTRINSICS) && defined(__GNUC__)
+    return __builtin_ctz(a);
+#else
+    return lfs_npw2((a & -a) + 1) - 1;
+#endif
+}
+
+// Count the number of binary ones in a
+static inline uint32_t lfs_popc(uint32_t a) {
+#if !defined(LFS_NO_INTRINSICS) && (defined(__GNUC__) || defined(__CC_ARM))
+    return __builtin_popcount(a);
+#else
+    a = a - ((a >> 1) & 0x55555555);
+    a = (a & 0x33333333) + ((a >> 2) & 0x33333333);
+    return (((a + (a >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24;
+#endif
+}
+
+// Find the sequence comparison of a and b, this is the distance
+// between a and b ignoring overflow
+static inline int lfs_scmp(uint32_t a, uint32_t b) {
+    return (int)(unsigned)(a - b);
+}
+
+// Convert between 32-bit little-endian and native order
+static inline uint32_t lfs_fromle32(uint32_t a) {
+#if (defined(  BYTE_ORDER  ) && defined(  ORDER_LITTLE_ENDIAN  ) &&   BYTE_ORDER   ==   ORDER_LITTLE_ENDIAN  ) || \
+    (defined(__BYTE_ORDER  ) && defined(__ORDER_LITTLE_ENDIAN  ) && __BYTE_ORDER   == __ORDER_LITTLE_ENDIAN  ) || \
+    (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+    return a;
+#elif !defined(LFS_NO_INTRINSICS) && ( \
+    (defined(  BYTE_ORDER  ) && defined(  ORDER_BIG_ENDIAN  ) &&   BYTE_ORDER   ==   ORDER_BIG_ENDIAN  ) || \
+    (defined(__BYTE_ORDER  ) && defined(__ORDER_BIG_ENDIAN  ) && __BYTE_ORDER   == __ORDER_BIG_ENDIAN  ) || \
+    (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
+    return __builtin_bswap32(a);
+#else
+    return ((uint32_t)((uint8_t*)&a)[0] <<  0) |
+           ((uint32_t)((uint8_t*)&a)[1] <<  8) |
+           ((uint32_t)((uint8_t*)&a)[2] << 16) |
+           ((uint32_t)((uint8_t*)&a)[3] << 24);
+#endif
+}
+
+static inline uint32_t lfs_tole32(uint32_t a) {
+    return lfs_fromle32(a);
+}
+
+// Convert between 32-bit big-endian and native order
+static inline uint32_t lfs_frombe32(uint32_t a) {
+#if !defined(LFS_NO_INTRINSICS) && ( \
+    (defined(  BYTE_ORDER  ) && defined(  ORDER_LITTLE_ENDIAN  ) &&   BYTE_ORDER   ==   ORDER_LITTLE_ENDIAN  ) || \
+    (defined(__BYTE_ORDER  ) && defined(__ORDER_LITTLE_ENDIAN  ) && __BYTE_ORDER   == __ORDER_LITTLE_ENDIAN  ) || \
+    (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
+    return __builtin_bswap32(a);
+#elif (defined(  BYTE_ORDER  ) && defined(  ORDER_BIG_ENDIAN  ) &&   BYTE_ORDER   ==   ORDER_BIG_ENDIAN  ) || \
+    (defined(__BYTE_ORDER  ) && defined(__ORDER_BIG_ENDIAN  ) && __BYTE_ORDER   == __ORDER_BIG_ENDIAN  ) || \
+    (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+    return a;
+#else
+    return ((uint32_t)((uint8_t*)&a)[0] << 24) |
+           ((uint32_t)((uint8_t*)&a)[1] << 16) |
+           ((uint32_t)((uint8_t*)&a)[2] <<  8) |
+           ((uint32_t)((uint8_t*)&a)[3] <<  0);
+#endif
+}
+
+static inline uint32_t lfs_tobe32(uint32_t a) {
+    return lfs_frombe32(a);
+}
+
+// Calculate CRC-32 with polynomial = 0x04c11db7
+#ifdef LFS_CRC
+static inline uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
+    return LFS_CRC(crc, buffer, size);
+}
+#else
+uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size);
+#endif
+
+// Allocate memory, only used if buffers are not provided to littlefs
+//
+// littlefs current has no alignment requirements, as it only allocates
+// byte-level buffers.
+static inline void *lfs_malloc(size_t size) {
+#if defined(LFS_MALLOC)
+    return LFS_MALLOC(size);
+#elif !defined(LFS_NO_MALLOC)
+    return malloc(size);
+#else
+    (void)size;
+    return NULL;
+#endif
+}
+
+// Deallocate memory, only used if buffers are not provided to littlefs
+static inline void lfs_free(void *p) {
+#if defined(LFS_FREE)
+    LFS_FREE(p);
+#elif !defined(LFS_NO_MALLOC)
+    free(p);
+#else
+    (void)p;
+#endif
+}
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
+#endif
\ No newline at end of file
index 520aca075f94c3f132a0df615b131a7e11947059..e2fc2b16448d763004e60d64ce889affc43308f9 100644 (file)
@@ -42,6 +42,8 @@
 #include "task.h"
 #include "dispboard.h"
 
+const uint8_t FW_VER[4] = {FW_VER_MAJOR, FW_VER_MINOR, FW_VER_REVISION, FW_VER_BUILD};
+
 void user_app( void );
 int main(void)
 {
index 4169fbedd61ba2638d469c7a723c5a6a65544d9c..804383c38cbc368ee461f2ba1100eda5e71e511a 100644 (file)
@@ -339,7 +339,7 @@ int iap_send_pkt( uint32_t offset, uint8_t *pdata, int len )
     return rc;
 }
 
-FIL s_iap_fp;
+FIL s_iap_fp  __attribute__((section(".SDRAM1"), aligned(4)));
 int iap_open_fw( void )
 {
     FRESULT fres;
index 1ec0e16013b0b68da3a5a97cdd32cc4981a27fe6..1135ffec2fb6f4de4727b1c05f6bb0af826c162b 100644 (file)
-/**
- *******************************************************************************************************************************************
- * @file        version.h
- * @brief       版本/目标控制
- * @details     /
- * @since       Change Logs:
- * Date         Author       Notes
- * 2022-12-08   lzh          the first version
- * 2023-05-10   lzh          add configurable options( LCD_TYPE / TP_TYPE )
- * @note        若用户使用的 TFT-LCD 模组不在原厂已调试过的型号范围内, 需要自行编写/更改对应 TFT-LCD 显示/触摸 的驱动程序.
- * 请知悉 : 没有任何一个程序可以兼容市面各式各样、不同参数的屏幕.
- *
- * @remark      本例程综合了 SWM34S 系列不同脚位封装( CE-48 / RE-64 / VE-100 )的 DEMO 板驱动不同的 TFT-LCD 屏(RGB接口) 的应用
- * 用户首先要点击魔术棒左边的 Target 下拉进行目标选择, 再调整 "version.h" 的宏定义以进行 <__平台适配__> , 最后编译下载查看效果.
- *
- * <__平台适配__> :
- * 可自定义 : Demo 板 PCB 丝印 / TFT-LCD 模组型号(捆绑分辨率 + TP型号, 也支持自定义)
- *
- * 其他配置项则与下拉目标绑定, 无需修改, 用户只需要点击选取下拉列表项即可.
- *
- * enum : 编译目标选择 < 请勿更改 __TARGET_CONST__ 预设值 >
- *
- * ****************************************** RGB565 ******************************************
- *
- * 0 => LVGL 官方示例, 其 UI 布局自适应分辨率, 具体的示例通过在 lv_ex_conf.h 中配置开关宏进行选择,
- * 特别对于 lv_music 示例, 由于其图片素材超多, 片内Flash存不下, 故需要在 Flash Download 中添加片外 SPI Flash的下载算法,
- * 使用 SFC 配合 Scatter File 设定将图片素材随程序一并下载, 即在 MDK 下一键下载 程序 + 素材.
- *
- * 1 => Lib \ SimplLCD_RGB 例程在 LVGL 下实现 - 不依赖于任何 UI 素材, 单纯显示颜色测试
- *
- * 2 => SYNWIT 应用例程 - 480 * 272 分辨率 UI 素材
- *
- * 3 => SYNWIT 应用例程 - 480 * 480 分辨率 UI 素材
- *
- * 4 => SYNWIT 应用例程 - 800 * 480 分辨率 UI 素材
- *
- * 5 => SYNWIT 应用例程 - 1024 * 600 分辨率 UI 素材
- *
- * ****************************************** ARGB888 ******************************************
- *
- * 6 => LVGL 官方示例, 其 UI 布局自适应分辨率, 具体的示例通过在 lv_ex_conf.h 中配置开关宏进行选择,
- * 特别对于 lv_music 示例, 由于其图片素材超多, 片内Flash存不下, 故需要在 Flash Download 中添加片外 SPI Flash的下载算法,
- * 使用 SFC 配合 Scatter File 设定将图片素材随程序一并下载, 即在 MDK 下一键下载 程序 + 素材.
- *
- * 7 => Lib \ SimplLCD_RGB 例程在 LVGL 下实现 - 不依赖于任何 UI 素材, 单纯显示颜色测试
- *
- * 8 => SYNWIT 应用例程 - 480 * 272 分辨率 UI 素材
- *
- * 9 => SYNWIT 应用例程 - 480 * 480 分辨率 UI 素材
- *
- * 10 => SYNWIT 应用例程 - 800 * 480 分辨率 UI 素材
- *
- * 11 => SYNWIT 应用例程 - 1024 * 600 分辨率 UI 素材
- *
- * ****************************************** UserBoot ******************************************
- *
- * 0xFF => UserBoot 功能应用, 适用于上述所有目标的固件(请注意: 使用前必须先打开查看 userboot.c 文件内的说明, 不看说明直接下载是不行的)
- *
- * @warning     本文件中 __TARGET_CONST__ 已按预期下拉 Target 设定赋值,
- *
- * 应用本工程时 < 请勿更改 >< 请勿更改 >< 请勿更改 > __TARGET_CONST__ 预设值,
- *
- * (__TARGET_CONST__ 在 Keil Option for Target => C/C++(AC6) => Preprocessor Symbols => Define 设置)
- *
- * @test        实测在 1024*600-RGB888 下应用 lvgl, 8 MB SDRAM 空间捉襟见肘, 效果不佳(待后续推出大容量 SDRAM)
- *******************************************************************************************************************************************
- * @attention
- *
- * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION
- * REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, SYNWIT SHALL NOT BE HELD LIABLE
- * FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
- * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONN-
- * -ECTION WITH THEIR PRODUCTS.
- *
- * @copyright   2012 Synwit Technology
- *******************************************************************************************************************************************
- */
 #ifndef __VERSION_H__
 #define __VERSION_H__
-/*******************************************************************************************************************************************
- * Public Define Config (以下配置项需用户根据实际硬件环境情况配置)
- *******************************************************************************************************************************************/
 
 #define LCD_HDOT        (320)
 #define LCD_VDOT        (240)
 #define TP_TYPE         0
 
 
-/*******************************************************************************************************************************************
- * Public Define Constant
- *******************************************************************************************************************************************/
 #define LCD_RGB565              (2) /**< RGB565 = 16 Bit */
 #define LCD_ARGB888             (4) /**< RGB888 + Alpha = 32 Bit */
-/**
- * enum : LCD 显示格式(LCD_FORMAT)
- * 其值为一个像素点所占用的字节数, 可使用该值结合分辨率计算一帧显示缓存的大小
- *
- * 2 => RGB565 (Support RGB or MPU/MCU Interface)
- *
- * 4 => ARGB888 (Only Support RGB Interface)
- */
 #define LCD_FMT                 LCD_RGB565
-
-#define SIZE_32MB               (0x02000000)
-#define SIZE_16MB               (0x01000000)
 #define SIZE_8MB                (0x00800000)
-#define SIZE_2MB                (0x00200000)
 
 #define SDRAMM_SIZE             SIZE_8MB /**< SDRAM 大小 = 8 MB */
 
+
+#define FW_VER_MAJOR    3
+#define FW_VER_MINOR    4
+#define FW_VER_REVISION 5
+#define FW_VER_BUILD    7
+
 #endif //__VERSION_H__
index 98e3e3050032d1f8bc5c30df3bd64de1a2cda570..a0c518e15931b24cf333cf0ddd97f9ddcae838b6 100644 (file)
@@ -781,7 +781,7 @@ int user_wave_export_files(void)
     return (exported > 0) ? ERR_OK : ERR_NO_DATA;
 }
 
-static FIL wave_raw_file;
+static FIL wave_raw_file  __attribute__((section(".SDRAM1"), aligned(4)));
 
 int wave_raw_create( void )
 {
index 2ae9c0c2371d1d5bfb69a8637926dc5c0dac5a7a..9335f2190b51f15e6ee7b5a40de6929dedec9d1a 100644 (file)
 ;   <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
 ; </h>
 
+
+
+  IF :DEF:BOOTLOADER
 Stack_Size      EQU     0x00004000
+  ELSE
+Stack_Size      EQU     0x00001000
+  ENDIF
+  
 
                 AREA    STACK, NOINIT, READWRITE, ALIGN=3
 Stack_Mem       SPACE   Stack_Size
@@ -166,7 +173,27 @@ __Vectors_End
 
 __Vectors_Size  EQU  __Vectors_End - __Vectors
 
-
+;------------------------------------------------------------
+; 增加一些固件信息,方便外部工具对其校验和解析使用  kyz
+                               IMPORT |Region$$Table$$Limit|
+                               IMPORT |Region$$Table$$Base|
+                               ;ALIGN  0x400
+                               SPACE  0x400 - __Vectors_Size
+FW_INFO_ADDR
+                               IF  :DEF:BOOTLOADER
+          IMPORT       BOOT_VER
+                                       DCD 0x544F4F42  ; 'BOOT'
+          DCD BOOT_VER
+                               ELSE
+                               IMPORT  FW_VER
+                                       DCD 0x00505041  ; 'APP\0'
+          DCD FW_VER
+                               ENDIF
+                               DCD     |Region$$Table$$Base|
+                               DCD     |Region$$Table$$Limit|
+                               DCD  __Vectors
+                               SPACE 44
+;------------------------------------------------------------
 
                 AREA    |.text|, CODE, READONLY
 
@@ -180,19 +207,23 @@ Reset_Handler    PROC
                                 IMPORT sdram_init  
                                 LDR     R0, =FPU_Enable
                                 BLX     R0
-                                
-                                ;初始化系统时钟(可配置)
-                                LDR     R0, =SystemInit
-                                BLX     R0
 
-                                ;初始化总线上外挂的SPI-Flash, 将其映射至MCU内部(可选外设)
-                                LDR     R0, =sfc_init
-                                BLX     R0
+                                IF  :DEF:CODE_ON_SDRAM
+          
+                                ELSE
+            ;初始化系统时钟(可配置)
+            LDR     R0, =SystemInit
+            BLX     R0
+
+            ;初始化总线上外挂的SPI-Flash, 将其映射至MCU内部(可选外设)
+            LDR     R0, =sfc_init
+            BLX     R0
+
+            ;初始化总线上外挂的SDRAM<芯片内置>, 将其映射至MCU内部(可选外设)
+            LDR     R0, =sdram_init 
+            BLX     R0
+                                ENDIF
 
-                                ;初始化总线上外挂的SDRAM<芯片内置>, 将其映射至MCU内部(可选外设)
-                                LDR     R0, =sdram_init 
-                                BLX     R0
-                                
                  LDR     R0, =__main
                  BX      R0
                  ENDP
diff --git a/Linker_Scatter_File/SWM34S_SDRAM.sct b/Linker_Scatter_File/SWM34S_SDRAM.sct
new file mode 100644 (file)
index 0000000..d3289f2
--- /dev/null
@@ -0,0 +1,33 @@
+; *************************************************************
+; *** Scatter-Loading Description File generated by uVision ***
+; *************************************************************
+
+
+;UseBoot-APP
+;LR_IROM1 0x00010000 0x00070000  {    ; load region size_region
+;  ER_IROM1 0x00010000 0x00070000  {  ; load address = execution address
+
+;General-APP
+LR_IROM1 0x80000000 0x00200000  {    ; load region size_region
+  ER_IROM1 0x80000000 0x00200000  {  ; load address = execution address
+
+   *.o (RESET, +First)
+   *(InRoot$$Sections)
+   .ANY (+RO)
+   .ANY (+XO)
+  }
+  FSymTab +0 { *(FSymTab) }  ; CherrySH 命令符号表
+  VSymTab +0 { *(VSymTab) }  ; CherrySH 变量符号表
+  RW_IRAM1 0x20000000 0x00010000  {  ; RW data
+   .ANY (+RW +ZI)
+   ;*(.SRAM)
+  }
+  RW_SDRAM1 0x80200000 UNINIT 0x00400000  { ; RW data
+    *(.SDRAM1)
+     *(.SDRAM1.bss)
+  }
+;  0x00200000
+ ; RW_SDRAM2 0x80600000 0x00200000  { ; RW data
+;    *(.SDRAM2)
+;  }
+}
index 78d9575958e306d12c6132459b561af5e4fe3543..d0152fa0682d4e0a61bd35ed9e50cf3fd70a0195 100644 (file)
             <InvalidFlash>1</InvalidFlash>
           </TargetStatus>
           <OutputDirectory>.\out\dispboard_app\</OutputDirectory>
-          <OutputName>dispboard</OutputName>
+          <OutputName>dispboard_app</OutputName>
           <CreateExecutable>1</CreateExecutable>
           <CreateLib>0</CreateLib>
-          <CreateHexFile>0</CreateHexFile>
+          <CreateHexFile>1</CreateHexFile>
           <DebugInformation>1</DebugInformation>
           <BrowseInformation>1</BrowseInformation>
           <ListingPath>.\out\dispboard_app\</ListingPath>
@@ -81,9 +81,9 @@
           </BeforeMake>
           <AfterMake>
             <RunUserProg1>1</RunUserProg1>
-            <RunUserProg2>0</RunUserProg2>
-            <UserProg1Name>fromelf --i32combined -o "$L@L.hex" "#L"</UserProg1Name>
-            <UserProg2Name>fromelf --text -a -c -o "$L@L.asm" "#L"</UserProg2Name>
+            <RunUserProg2>1</RunUserProg2>
+            <UserProg1Name>fromelf --bin -o "$L@L.bin" "#L"</UserProg1Name>
+            <UserProg2Name>"$Ptools\fwpack.exe" --in "$L@L.bin" --out "$L@L_fw.bin" --hex "$L@L_fw.hex" --base 0xA0000000</UserProg2Name>
             <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
             <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
             <nStopA1X>0</nStopA1X>
diff --git a/dispboard_app_sdram.uvprojx b/dispboard_app_sdram.uvprojx
new file mode 100644 (file)
index 0000000..f80626b
--- /dev/null
@@ -0,0 +1,5465 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
+
+  <SchemaVersion>2.1</SchemaVersion>
+
+  <Header>### uVision Project, (C) Keil Software</Header>
+
+  <Targets>
+    <Target>
+      <TargetName>dispboard_app_sdram</TargetName>
+      <ToolsetNumber>0x4</ToolsetNumber>
+      <ToolsetName>ARM-ADS</ToolsetName>
+      <pCCUsed>6160000::V6.16::ARMCLANG</pCCUsed>
+      <uAC6>1</uAC6>
+      <TargetOption>
+        <TargetCommonOption>
+          <Device>SWM341xE</Device>
+          <Vendor>Synwit</Vendor>
+          <PackID>Synwit.SWM32_DFP.2.1.4</PackID>
+          <PackURL>http://www.synwit.com/pack</PackURL>
+          <Cpu>IRAM(0x20000000,0x10000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M33") FPU3(SFPU) DSP CLOCK(12000000) ELITTLE</Cpu>
+          <FlashUtilSpec></FlashUtilSpec>
+          <StartupFile></StartupFile>
+          <FlashDriverDll>UL2V8M(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0SWM341xE -FS00 -FL080000 -FP0($$Device:SWM341xE$Flash\SWM341xE.FLM))</FlashDriverDll>
+          <DeviceId>0</DeviceId>
+          <RegisterFile>$$Device:SWM341xE$CSL\SWM341\CMSIS\DeviceSupport\SWM341.h</RegisterFile>
+          <MemoryEnv></MemoryEnv>
+          <Cmp></Cmp>
+          <Asm></Asm>
+          <Linker></Linker>
+          <OHString></OHString>
+          <InfinionOptionDll></InfinionOptionDll>
+          <SLE66CMisc></SLE66CMisc>
+          <SLE66AMisc></SLE66AMisc>
+          <SLE66LinkerMisc></SLE66LinkerMisc>
+          <SFDFile>$$Device:SWM341xE$SVD\SWM341.svd</SFDFile>
+          <bCustSvd>0</bCustSvd>
+          <UseEnv>0</UseEnv>
+          <BinPath></BinPath>
+          <IncludePath></IncludePath>
+          <LibPath></LibPath>
+          <RegisterFilePath></RegisterFilePath>
+          <DBRegisterFilePath></DBRegisterFilePath>
+          <TargetStatus>
+            <Error>0</Error>
+            <ExitCodeStop>0</ExitCodeStop>
+            <ButtonStop>0</ButtonStop>
+            <NotGenerated>0</NotGenerated>
+            <InvalidFlash>1</InvalidFlash>
+          </TargetStatus>
+          <OutputDirectory>.\out\dispboard_app_sdram\</OutputDirectory>
+          <OutputName>dispboard_app_sdram</OutputName>
+          <CreateExecutable>1</CreateExecutable>
+          <CreateLib>0</CreateLib>
+          <CreateHexFile>1</CreateHexFile>
+          <DebugInformation>1</DebugInformation>
+          <BrowseInformation>1</BrowseInformation>
+          <ListingPath>.\out\dispboard_app_sdram\</ListingPath>
+          <HexFormatSelection>1</HexFormatSelection>
+          <Merge32K>0</Merge32K>
+          <CreateBatchFile>0</CreateBatchFile>
+          <BeforeCompile>
+            <RunUserProg1>0</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name></UserProg1Name>
+            <UserProg2Name></UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopU1X>0</nStopU1X>
+            <nStopU2X>0</nStopU2X>
+          </BeforeCompile>
+          <BeforeMake>
+            <RunUserProg1>0</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name></UserProg1Name>
+            <UserProg2Name></UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopB1X>0</nStopB1X>
+            <nStopB2X>0</nStopB2X>
+          </BeforeMake>
+          <AfterMake>
+            <RunUserProg1>1</RunUserProg1>
+            <RunUserProg2>1</RunUserProg2>
+            <UserProg1Name>fromelf --bin -o "$L@L.bin" "#L"</UserProg1Name>
+            <UserProg2Name>"$Ptools\fwpack.exe" --in "$L@L.bin" --out "$L@L_fw.bin" --hex "$L@L_fw.hex" --base 0xA0000000</UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopA1X>0</nStopA1X>
+            <nStopA2X>0</nStopA2X>
+          </AfterMake>
+          <SelectedForBatchBuild>0</SelectedForBatchBuild>
+          <SVCSIdString></SVCSIdString>
+        </TargetCommonOption>
+        <CommonProperty>
+          <UseCPPCompiler>0</UseCPPCompiler>
+          <RVCTCodeConst>0</RVCTCodeConst>
+          <RVCTZI>0</RVCTZI>
+          <RVCTOtherData>0</RVCTOtherData>
+          <ModuleSelection>0</ModuleSelection>
+          <IncludeInBuild>1</IncludeInBuild>
+          <AlwaysBuild>0</AlwaysBuild>
+          <GenerateAssemblyFile>0</GenerateAssemblyFile>
+          <AssembleAssemblyFile>0</AssembleAssemblyFile>
+          <PublicsOnly>0</PublicsOnly>
+          <StopOnExitCode>3</StopOnExitCode>
+          <CustomArgument></CustomArgument>
+          <IncludeLibraryModules></IncludeLibraryModules>
+          <ComprImg>1</ComprImg>
+        </CommonProperty>
+        <DllOption>
+          <SimDllName></SimDllName>
+          <SimDllArguments></SimDllArguments>
+          <SimDlgDll></SimDlgDll>
+          <SimDlgDllArguments></SimDlgDllArguments>
+          <TargetDllName>SARMV8M.DLL</TargetDllName>
+          <TargetDllArguments></TargetDllArguments>
+          <TargetDlgDll>TCM.DLL</TargetDlgDll>
+          <TargetDlgDllArguments>-pCM33</TargetDlgDllArguments>
+        </DllOption>
+        <DebugOption>
+          <OPTHX>
+            <HexSelection>1</HexSelection>
+            <HexRangeLowAddress>0</HexRangeLowAddress>
+            <HexRangeHighAddress>0</HexRangeHighAddress>
+            <HexOffset>0</HexOffset>
+            <Oh166RecLen>16</Oh166RecLen>
+          </OPTHX>
+        </DebugOption>
+        <Utilities>
+          <Flash1>
+            <UseTargetDll>1</UseTargetDll>
+            <UseExternalTool>0</UseExternalTool>
+            <RunIndependent>0</RunIndependent>
+            <UpdateFlashBeforeDebugging>0</UpdateFlashBeforeDebugging>
+            <Capability>1</Capability>
+            <DriverSelection>4102</DriverSelection>
+          </Flash1>
+          <bUseTDR>1</bUseTDR>
+          <Flash2>BIN\UL2V8M.DLL</Flash2>
+          <Flash3>"" ()</Flash3>
+          <Flash4>.\DebugInSDRAM.ini</Flash4>
+          <pFcarmOut></pFcarmOut>
+          <pFcarmGrp></pFcarmGrp>
+          <pFcArmRoot></pFcArmRoot>
+          <FcArmLst>0</FcArmLst>
+        </Utilities>
+        <TargetArmAds>
+          <ArmAdsMisc>
+            <GenerateListings>0</GenerateListings>
+            <asHll>1</asHll>
+            <asAsm>1</asAsm>
+            <asMacX>1</asMacX>
+            <asSyms>1</asSyms>
+            <asFals>1</asFals>
+            <asDbgD>1</asDbgD>
+            <asForm>1</asForm>
+            <ldLst>0</ldLst>
+            <ldmm>1</ldmm>
+            <ldXref>1</ldXref>
+            <BigEnd>0</BigEnd>
+            <AdsALst>1</AdsALst>
+            <AdsACrf>1</AdsACrf>
+            <AdsANop>0</AdsANop>
+            <AdsANot>0</AdsANot>
+            <AdsLLst>1</AdsLLst>
+            <AdsLmap>1</AdsLmap>
+            <AdsLcgr>1</AdsLcgr>
+            <AdsLsym>1</AdsLsym>
+            <AdsLszi>1</AdsLszi>
+            <AdsLtoi>1</AdsLtoi>
+            <AdsLsun>1</AdsLsun>
+            <AdsLven>1</AdsLven>
+            <AdsLsxf>1</AdsLsxf>
+            <RvctClst>0</RvctClst>
+            <GenPPlst>0</GenPPlst>
+            <AdsCpuType>"Cortex-M33"</AdsCpuType>
+            <RvctDeviceName></RvctDeviceName>
+            <mOS>0</mOS>
+            <uocRom>0</uocRom>
+            <uocRam>0</uocRam>
+            <hadIROM>1</hadIROM>
+            <hadIRAM>1</hadIRAM>
+            <hadXRAM>0</hadXRAM>
+            <uocXRam>0</uocXRam>
+            <RvdsVP>2</RvdsVP>
+            <RvdsMve>0</RvdsMve>
+            <RvdsCdeCp>0</RvdsCdeCp>
+            <nBranchProt>0</nBranchProt>
+            <hadIRAM2>0</hadIRAM2>
+            <hadIROM2>0</hadIROM2>
+            <StupSel>8</StupSel>
+            <useUlib>1</useUlib>
+            <EndSel>0</EndSel>
+            <uLtcg>0</uLtcg>
+            <nSecure>0</nSecure>
+            <RoSelD>3</RoSelD>
+            <RwSelD>3</RwSelD>
+            <CodeSel>0</CodeSel>
+            <OptFeed>0</OptFeed>
+            <NoZi1>0</NoZi1>
+            <NoZi2>0</NoZi2>
+            <NoZi3>0</NoZi3>
+            <NoZi4>0</NoZi4>
+            <NoZi5>0</NoZi5>
+            <Ro1Chk>0</Ro1Chk>
+            <Ro2Chk>0</Ro2Chk>
+            <Ro3Chk>0</Ro3Chk>
+            <Ir1Chk>1</Ir1Chk>
+            <Ir2Chk>0</Ir2Chk>
+            <Ra1Chk>0</Ra1Chk>
+            <Ra2Chk>0</Ra2Chk>
+            <Ra3Chk>0</Ra3Chk>
+            <Im1Chk>1</Im1Chk>
+            <Im2Chk>0</Im2Chk>
+            <OnChipMemories>
+              <Ocm1>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm1>
+              <Ocm2>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm2>
+              <Ocm3>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm3>
+              <Ocm4>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm4>
+              <Ocm5>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm5>
+              <Ocm6>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm6>
+              <IRAM>
+                <Type>0</Type>
+                <StartAddress>0x20000000</StartAddress>
+                <Size>0x10000</Size>
+              </IRAM>
+              <IROM>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x80000</Size>
+              </IROM>
+              <XRAM>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </XRAM>
+              <OCR_RVCT1>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT1>
+              <OCR_RVCT2>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT2>
+              <OCR_RVCT3>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT3>
+              <OCR_RVCT4>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x80000</Size>
+              </OCR_RVCT4>
+              <OCR_RVCT5>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT5>
+              <OCR_RVCT6>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT6>
+              <OCR_RVCT7>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT7>
+              <OCR_RVCT8>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT8>
+              <OCR_RVCT9>
+                <Type>0</Type>
+                <StartAddress>0x20000000</StartAddress>
+                <Size>0x10000</Size>
+              </OCR_RVCT9>
+              <OCR_RVCT10>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT10>
+            </OnChipMemories>
+            <RvctStartVector></RvctStartVector>
+          </ArmAdsMisc>
+          <Cads>
+            <interw>1</interw>
+            <Optim>1</Optim>
+            <oTime>0</oTime>
+            <SplitLS>0</SplitLS>
+            <OneElfS>1</OneElfS>
+            <Strict>0</Strict>
+            <EnumInt>0</EnumInt>
+            <PlainCh>0</PlainCh>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <wLevel>3</wLevel>
+            <uThumb>0</uThumb>
+            <uSurpInc>0</uSurpInc>
+            <uC99>0</uC99>
+            <uGnu>0</uGnu>
+            <useXO>0</useXO>
+            <v6Lang>3</v6Lang>
+            <v6LangP>3</v6LangP>
+            <vShortEn>1</vShortEn>
+            <vShortWch>1</vShortWch>
+            <v6Lto>0</v6Lto>
+            <v6WtE>0</v6WtE>
+            <v6Rtti>0</v6Rtti>
+            <VariousControls>
+              <MiscControls>-Wno-invalid-source-encoding</MiscControls>
+              <Define>CODE_ON_SDRAM,__TARGET_CONST__=0</Define>
+              <Undefine></Undefine>
+              <IncludePath>.\CSL\CMSIS\CoreSupport;.\CSL\CMSIS\DeviceSupport;.\CSL\SWM341_StdPeriph_Driver;.\CSL\SWM341_UsbHost_Lib;.\CSL\SWM341_UsbHost_Lib\CDC;.\CSL\SWM341_UsbHost_Lib\HID;.\CSL\SWM341_UsbHost_Lib\MSC;.\CSL\SWM341_UsbHost_Lib\MTP;.\Middleware\FatFs\source;.\Middleware\lvgl;.\Middleware\lvgl\lvgl;.\Middleware\lvgl\lvgl\src;.\Middleware\lvgl\lvgl\src\lv_core;.\Middleware\lvgl\lvgl\src\lv_draw;.\Middleware\lvgl\lvgl\src\lv_font;.\Middleware\lvgl\lvgl\src\lv_gpu;.\Middleware\lvgl\lvgl\src\lv_hal;.\Middleware\lvgl\lvgl\src\lv_misc;.\Middleware\lvgl\lvgl\src\lv_themes;.\Middleware\lvgl\lvgl\src\lv_widgets;.\Middleware\lvgl\lvgl\examples\porting;.\Middleware\lvgl\lv_examples;.\Middleware\lvgl\lv_examples\src;.\Middleware\lvgl\lv_examples\src\lv_demo_widgets;.\Middleware\lvgl\lv_examples\src\lv_demo_benchmark;.\Middleware\lvgl\lv_examples\src\lv_demo_stress;.\Middleware\lvgl\lv_examples\src\lv_demo_music;.\APP;.\APP\can_comm;.\APP\BSP;.\APP\IC_Driver;.\APP\Common Module;.\APP\Software_Parser;.\APP\USB\Device;.\APP\USB\Host;.\APP\UI;.\APP\UI\Resource;.\APP\UI\Page;.\Middleware\FreeRTOS-Kernel;.\Middleware\FreeRTOS-Kernel\include;.\Middleware\FreeRTOS-Kernel\portable\GCC\ARM_CM33_NTZ\non_secure;.\Middleware\FreeRTOS-Kernel\portable\MemMang;.\APP\can_comm;.\APP\mb;.\APP\shell;.\APP\shell\cherryrl</IncludePath>
+            </VariousControls>
+          </Cads>
+          <Aads>
+            <interw>1</interw>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <thumb>0</thumb>
+            <SplitLS>0</SplitLS>
+            <SwStkChk>0</SwStkChk>
+            <NoWarn>0</NoWarn>
+            <uSurpInc>0</uSurpInc>
+            <useXO>0</useXO>
+            <ClangAsOpt>1</ClangAsOpt>
+            <VariousControls>
+              <MiscControls></MiscControls>
+              <Define>CODE_ON_SDRAM</Define>
+              <Undefine></Undefine>
+              <IncludePath></IncludePath>
+            </VariousControls>
+          </Aads>
+          <LDads>
+            <umfTarg>0</umfTarg>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <noStLib>0</noStLib>
+            <RepFail>1</RepFail>
+            <useFile>0</useFile>
+            <TextAddressRange>0x00000000</TextAddressRange>
+            <DataAddressRange>0x00000000</DataAddressRange>
+            <pXoBase></pXoBase>
+            <ScatterFile>.\Linker_Scatter_File\SWM34S_SDRAM.sct</ScatterFile>
+            <IncludeLibs></IncludeLibs>
+            <IncludeLibsPath></IncludeLibsPath>
+            <Misc></Misc>
+            <LinkerInputFile></LinkerInputFile>
+            <DisabledWarnings></DisabledWarnings>
+          </LDads>
+        </TargetArmAds>
+      </TargetOption>
+      <Groups>
+        <Group>
+          <GroupName>Readme</GroupName>
+          <Files>
+            <File>
+              <FileName>readme.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\readme.txt</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Config(必看)</GroupName>
+          <Files>
+            <File>
+              <FileName>version.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\version.h</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>APP</GroupName>
+          <Files>
+            <File>
+              <FileName>main.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\app\main.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_app.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_app.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_ui.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_ui.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_usb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_usb.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_mb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_mb.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_iap.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_iap.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_mb_data.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_mb_data.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_export.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_export.c</FilePath>
+            </File>
+            <File>
+              <FileName>wave_data.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\wave_data.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>BSP</GroupName>
+          <Files>
+            <File>
+              <FileName>irq_handler.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\irq_handler.c</FilePath>
+            </File>
+            <File>
+              <FileName>bsp_init.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\bsp_init.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_systick.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_systick.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_bod.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_bod.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_crc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_crc.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_jpeg.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_jpeg.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_uart.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sfc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_sfc.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sdram.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_sdram.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sdio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_sdio.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_dac.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_dac.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_lcd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_lcd.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_touch.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_touch.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>dev_sleep_stop.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_sleep_stop.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_io.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Bsp\dev_io.h</FilePath>
+            </File>
+            <File>
+              <FileName>dev_io_spi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_io_spi.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_io_i2c.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_io_i2c.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_can.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\BSP\dev_can.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>IC_Driver</GroupName>
+          <Files>
+            <File>
+              <FileName>documents.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\IC_Driver\documents.txt</FilePath>
+            </File>
+            <File>
+              <FileName>SPI_WB25Qxx.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\SPI_WB25Qxx.c</FilePath>
+            </File>
+            <File>
+              <FileName>LCD_TL021WVC02.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\LCD_TL021WVC02.c</FilePath>
+            </File>
+            <File>
+              <FileName>LCD_TL040WVS03.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\LCD_TL040WVS03.c</FilePath>
+            </File>
+            <File>
+              <FileName>LCD_JLT35002A.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\LCD_JLT35002A.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_CST826.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_CST826.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_CST328.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_CST328.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_FT5206.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_FT5206.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_FT6336.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_FT6336.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_GT911.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_GT911.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_Tango_C32.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_Tango_C32.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_ILI2117A.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_ILI2117A.c</FilePath>
+            </File>
+            <File>
+              <FileName>lcd_st7789.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\lcd_st7789.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Common Module</GroupName>
+          <Files>
+            <File>
+              <FileName>documents.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Common Module\documents.txt</FilePath>
+            </File>
+            <File>
+              <FileName>file_table.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\file_table.c</FilePath>
+            </File>
+            <File>
+              <FileName>load_file.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\load_file.c</FilePath>
+            </File>
+            <File>
+              <FileName>load_mv.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\load_mv.c</FilePath>
+            </File>
+            <File>
+              <FileName>mem_sdram.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\mem_sdram.c</FilePath>
+            </File>
+            <File>
+              <FileName>FlashDisk.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\FlashDisk.c</FilePath>
+            </File>
+            <File>
+              <FileName>userboot.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\userboot.c</FilePath>
+            </File>
+            <File>
+              <FileName>pthread_lock.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Common Module\pthread_lock.h</FilePath>
+            </File>
+            <File>
+              <FileName>posix_fsm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\posix_fsm.c</FilePath>
+            </File>
+            <File>
+              <FileName>log.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\log.c</FilePath>
+            </File>
+            <File>
+              <FileName>board_test.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\board_test.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>UI</GroupName>
+          <Files>
+            <File>
+              <FileName>documents.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\UI\documents.txt</FilePath>
+            </File>
+            <File>
+              <FileName>simple_lcd_rgb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\simple_lcd_rgb.c</FilePath>
+            </File>
+            <File>
+              <FileName>ui.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\UI\ui.h</FilePath>
+            </File>
+            <File>
+              <FileName>ui.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\ui.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>ui_boot.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\ui_boot.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>ui_update.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\ui_update.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>ui_test_button.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\ui_test_button.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>UI\Resource</GroupName>
+          <GroupOption>
+            <CommonProperty>
+              <UseCPPCompiler>0</UseCPPCompiler>
+              <RVCTCodeConst>0</RVCTCodeConst>
+              <RVCTZI>0</RVCTZI>
+              <RVCTOtherData>0</RVCTOtherData>
+              <ModuleSelection>0</ModuleSelection>
+              <IncludeInBuild>0</IncludeInBuild>
+              <AlwaysBuild>2</AlwaysBuild>
+              <GenerateAssemblyFile>2</GenerateAssemblyFile>
+              <AssembleAssemblyFile>2</AssembleAssemblyFile>
+              <PublicsOnly>2</PublicsOnly>
+              <StopOnExitCode>11</StopOnExitCode>
+              <CustomArgument></CustomArgument>
+              <IncludeLibraryModules></IncludeLibraryModules>
+              <ComprImg>1</ComprImg>
+            </CommonProperty>
+            <GroupArmAds>
+              <Cads>
+                <interw>2</interw>
+                <Optim>0</Optim>
+                <oTime>2</oTime>
+                <SplitLS>2</SplitLS>
+                <OneElfS>2</OneElfS>
+                <Strict>2</Strict>
+                <EnumInt>2</EnumInt>
+                <PlainCh>2</PlainCh>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <wLevel>0</wLevel>
+                <uThumb>2</uThumb>
+                <uSurpInc>2</uSurpInc>
+                <uC99>2</uC99>
+                <uGnu>2</uGnu>
+                <useXO>2</useXO>
+                <v6Lang>0</v6Lang>
+                <v6LangP>0</v6LangP>
+                <vShortEn>2</vShortEn>
+                <vShortWch>2</vShortWch>
+                <v6Lto>2</v6Lto>
+                <v6WtE>2</v6WtE>
+                <v6Rtti>2</v6Rtti>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Cads>
+              <Aads>
+                <interw>2</interw>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <thumb>2</thumb>
+                <SplitLS>2</SplitLS>
+                <SwStkChk>2</SwStkChk>
+                <NoWarn>2</NoWarn>
+                <uSurpInc>2</uSurpInc>
+                <useXO>2</useXO>
+                <ClangAsOpt>0</ClangAsOpt>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Aads>
+            </GroupArmAds>
+          </GroupOption>
+          <Files>
+            <File>
+              <FileName>image_source.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Resource\image_source.c</FilePath>
+            </File>
+            <File>
+              <FileName>yahei11_font.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Resource\yahei11_font.c</FilePath>
+            </File>
+            <File>
+              <FileName>demo_font.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Resource\demo_font.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>UI\Page</GroupName>
+          <GroupOption>
+            <CommonProperty>
+              <UseCPPCompiler>0</UseCPPCompiler>
+              <RVCTCodeConst>0</RVCTCodeConst>
+              <RVCTZI>0</RVCTZI>
+              <RVCTOtherData>0</RVCTOtherData>
+              <ModuleSelection>0</ModuleSelection>
+              <IncludeInBuild>0</IncludeInBuild>
+              <AlwaysBuild>2</AlwaysBuild>
+              <GenerateAssemblyFile>2</GenerateAssemblyFile>
+              <AssembleAssemblyFile>2</AssembleAssemblyFile>
+              <PublicsOnly>2</PublicsOnly>
+              <StopOnExitCode>11</StopOnExitCode>
+              <CustomArgument></CustomArgument>
+              <IncludeLibraryModules></IncludeLibraryModules>
+              <ComprImg>1</ComprImg>
+            </CommonProperty>
+            <GroupArmAds>
+              <Cads>
+                <interw>2</interw>
+                <Optim>0</Optim>
+                <oTime>2</oTime>
+                <SplitLS>2</SplitLS>
+                <OneElfS>2</OneElfS>
+                <Strict>2</Strict>
+                <EnumInt>2</EnumInt>
+                <PlainCh>2</PlainCh>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <wLevel>0</wLevel>
+                <uThumb>2</uThumb>
+                <uSurpInc>2</uSurpInc>
+                <uC99>2</uC99>
+                <uGnu>2</uGnu>
+                <useXO>2</useXO>
+                <v6Lang>0</v6Lang>
+                <v6LangP>0</v6LangP>
+                <vShortEn>2</vShortEn>
+                <vShortWch>2</vShortWch>
+                <v6Lto>2</v6Lto>
+                <v6WtE>2</v6WtE>
+                <v6Rtti>2</v6Rtti>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Cads>
+              <Aads>
+                <interw>2</interw>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <thumb>2</thumb>
+                <SplitLS>2</SplitLS>
+                <SwStkChk>2</SwStkChk>
+                <NoWarn>2</NoWarn>
+                <uSurpInc>2</uSurpInc>
+                <useXO>2</useXO>
+                <ClangAsOpt>0</ClangAsOpt>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Aads>
+            </GroupArmAds>
+          </GroupOption>
+          <Files>
+            <File>
+              <FileName>ui_event.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\ui_event.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_scr_home.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_scr_home.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_home_page_home.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_home_page_home.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_home_page_m0.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_home_page_m0.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_home_page_m4.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_home_page_m4.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_home_page_pd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_home_page_pd.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_home_page_pp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_home_page_pp.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_scr_m0_m4.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_scr_m0_m4.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Software_Parser</GroupName>
+          <Files>
+            <File>
+              <FileName>jfif_parser.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Software_Parser\jfif_parser.c</FilePath>
+            </File>
+            <File>
+              <FileName>avi_parser.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Software_Parser\avi_parser.c</FilePath>
+            </File>
+            <File>
+              <FileName>wav_parser.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Software_Parser\wav_parser.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>USBH\User</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_user.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\USB\Host\usbh_user.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_cdc_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_cdc_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_hid_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_hid_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_msc_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_mtp_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_mtp_conf.h</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>=====芯片支持库=====</GroupName>
+        </Group>
+        <Group>
+          <GroupName>CSL\CMSIS</GroupName>
+          <Files>
+            <File>
+              <FileName>system_SWM341.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\CMSIS\DeviceSupport\system_SWM341.c</FilePath>
+            </File>
+            <File>
+              <FileName>startup_SWM341.s</FileName>
+              <FileType>2</FileType>
+              <FilePath>.\CSL\CMSIS\DeviceSupport\startup\arm\startup_SWM341.s</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\StdPD</GroupName>
+          <Files>
+            <File>
+              <FileName>SWM341_adc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_adc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_can.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_can.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_cordic.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_cordic.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_crc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_crc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dac.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dac.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_div.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_div.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dma.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dma.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_exti.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_exti.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_flash.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_flash.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_gpio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_gpio.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_i2c.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_i2c.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_jpeg.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_jpeg.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_lcd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_lcd.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_port.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_port.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_pwm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_pwm.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sdio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sdio.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sdram.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sdram.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sfc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sfc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sleep.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sleep.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_spi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_spi.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_timr.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_timr.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_uart.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_usbd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_usbd.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_usbh.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_usbh.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_wdt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_wdt.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dma2d.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dma2d.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_qei.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_qei.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_iofilt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_iofilt.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\USBH</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\usbh_core.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_stdreq.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\usbh_stdreq.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\USBH\MSC</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_msc_bot.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_bot.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_core.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_scsi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_scsi.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>======中间件=======</GroupName>
+        </Group>
+        <Group>
+          <GroupName>FATFS</GroupName>
+          <Files>
+            <File>
+              <FileName>00readme.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\FatFs\source\00readme.txt</FilePath>
+            </File>
+            <File>
+              <FileName>diskio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\diskio.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffconf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffconf.h</FilePath>
+            </File>
+            <File>
+              <FileName>ff.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ff.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffsystem.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffsystem.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffunicode.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffunicode.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_porting</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\lv_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>lv_port_disp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_disp.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_port_indev.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_indev.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_port_fs.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_fs.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>lv_port_disp1.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_disp1.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>lv_port_disp2_1.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_disp2_1.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>lv_port_disp2_2.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_disp2_2.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>lv_port_disp3.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_disp3.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_gpu</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_gpu_swm341_dma2d.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_gpu\lv_gpu_swm341_dma2d.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_core</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_disp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_disp.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_group.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_group.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_indev.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_indev.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_obj.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_obj.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_refr.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_refr.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_style.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_style.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_draw</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_draw_arc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_arc.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_blend.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_blend.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_img.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_img.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_label.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_label.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_line.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_line.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_mask.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_mask.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_rect.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_rect.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_triangle.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_triangle.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_img_buf.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_img_buf.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_img_cache.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_img_cache.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_img_decoder.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_img_decoder.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_font</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_font.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_dejavu_16_persian_hebrew.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_dejavu_16_persian_hebrew.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_fmt_txt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_fmt_txt.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_loader.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_loader.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_8.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_8.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_10.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_10.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_12.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_12.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_12_subpx.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_12_subpx.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_14.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_14.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_16.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_16.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_18.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_18.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_20.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_20.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_22.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_22.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_24.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_24.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_26.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_26.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_28.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_28.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_28_compressed.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_28_compressed.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_30.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_30.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_32.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_32.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_34.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_34.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_36.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_36.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_38.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_38.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_40.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_40.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_42.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_42.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_44.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_44.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_46.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_46.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_48.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_48.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_simsun_16_cjk.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_simsun_16_cjk.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_unscii_8.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_unscii_8.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_unscii_16.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_unscii_16.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_hal</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_hal_disp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_hal\lv_hal_disp.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_hal_indev.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_hal\lv_hal_indev.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_hal_tick.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_hal\lv_hal_tick.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_misc</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_anim.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_anim.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_area.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_area.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_async.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_async.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_bidi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_bidi.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_color.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_color.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_debug.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_debug.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_fs.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_fs.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_gc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_gc.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_ll.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_ll.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_log.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_log.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_math.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_math.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_mem.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_mem.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_printf.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_printf.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_task.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_task.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_templ.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_templ.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_txt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_txt.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_txt_ap.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_txt_ap.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_utils.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_utils.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_themes</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_theme.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_themes\lv_theme.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_theme_empty.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_themes\lv_theme_empty.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_theme_material.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_themes\lv_theme_material.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_theme_mono.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_themes\lv_theme_mono.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_theme_template.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_themes\lv_theme_template.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_widgets</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_arc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_arc.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_bar.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_bar.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_btn.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_btn.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_btnmatrix.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_btnmatrix.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_calendar.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_calendar.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_canvas.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_canvas.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_chart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_chart.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_checkbox.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_checkbox.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_cont.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_cont.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_cpicker.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_cpicker.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_dropdown.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_dropdown.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_gauge.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_gauge.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_img.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_img.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_imgbtn.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_imgbtn.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_keyboard.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_keyboard.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_label.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_label.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_led.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_led.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_line.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_line.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_linemeter.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_linemeter.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_list.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_list.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_msgbox.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_msgbox.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_objmask.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_objmask.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_objx_templ.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_objx_templ.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_page.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_page.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_roller.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_roller.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_slider.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_slider.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_spinbox.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_spinbox.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_spinner.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_spinner.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_switch.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_switch.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_table.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_table.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_tabview.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_tabview.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_textarea.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_textarea.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_tileview.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_tileview.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_win.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_win.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_example</GroupName>
+          <GroupOption>
+            <CommonProperty>
+              <UseCPPCompiler>0</UseCPPCompiler>
+              <RVCTCodeConst>0</RVCTCodeConst>
+              <RVCTZI>0</RVCTZI>
+              <RVCTOtherData>0</RVCTOtherData>
+              <ModuleSelection>0</ModuleSelection>
+              <IncludeInBuild>1</IncludeInBuild>
+              <AlwaysBuild>2</AlwaysBuild>
+              <GenerateAssemblyFile>2</GenerateAssemblyFile>
+              <AssembleAssemblyFile>2</AssembleAssemblyFile>
+              <PublicsOnly>2</PublicsOnly>
+              <StopOnExitCode>11</StopOnExitCode>
+              <CustomArgument></CustomArgument>
+              <IncludeLibraryModules></IncludeLibraryModules>
+              <ComprImg>1</ComprImg>
+            </CommonProperty>
+            <GroupArmAds>
+              <Cads>
+                <interw>2</interw>
+                <Optim>0</Optim>
+                <oTime>2</oTime>
+                <SplitLS>2</SplitLS>
+                <OneElfS>2</OneElfS>
+                <Strict>2</Strict>
+                <EnumInt>2</EnumInt>
+                <PlainCh>2</PlainCh>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <wLevel>0</wLevel>
+                <uThumb>2</uThumb>
+                <uSurpInc>2</uSurpInc>
+                <uC99>2</uC99>
+                <uGnu>2</uGnu>
+                <useXO>2</useXO>
+                <v6Lang>0</v6Lang>
+                <v6LangP>0</v6LangP>
+                <vShortEn>2</vShortEn>
+                <vShortWch>2</vShortWch>
+                <v6Lto>2</v6Lto>
+                <v6WtE>2</v6WtE>
+                <v6Rtti>2</v6Rtti>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Cads>
+              <Aads>
+                <interw>2</interw>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <thumb>2</thumb>
+                <SplitLS>2</SplitLS>
+                <SwStkChk>2</SwStkChk>
+                <NoWarn>2</NoWarn>
+                <uSurpInc>2</uSurpInc>
+                <useXO>2</useXO>
+                <ClangAsOpt>0</ClangAsOpt>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Aads>
+            </GroupArmAds>
+          </GroupOption>
+          <Files>
+            <File>
+              <FileName>lv_ex_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\lv_ex_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_widgets.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_widgets\lv_demo_widgets.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>lv_demo_benchmark.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_benchmark\lv_demo_benchmark.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_stress.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_stress\lv_demo_stress.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_cogwheel_alpha16.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_cogwheel_alpha16.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_cogwheel_argb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_cogwheel_argb.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_cogwheel_chroma_keyed.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_cogwheel_chroma_keyed.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_cogwheel_indexed16.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_cogwheel_indexed16.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_cogwheel_rgb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_cogwheel_rgb.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_hand.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_hand.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_12_compr_az.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\lv_font_montserrat_12_compr_az.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_16_compr_az.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\lv_font_montserrat_16_compr_az.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_28_compr_az.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\lv_font_montserrat_28_compr_az.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_music.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\lv_demo_music.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_music_list.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\lv_demo_music_list.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_music_main.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\lv_demo_music_main.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_list_pause.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_list_pause.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_list_play.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_list_play.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_loop.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_loop.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_next.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_next.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_pause.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_pause.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_play.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_play.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_prev.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_prev.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_rnd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_rnd.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_corner_left.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_corner_left.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_corner_right.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_corner_right.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_cover_1.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_cover_1.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_cover_2.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_cover_2.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_cover_3.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_cover_3.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_icon_1.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_icon_1.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_icon_2.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_icon_2.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_icon_3.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_icon_3.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_icon_4.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_icon_4.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_list_border.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_list_border.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_logo.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_logo.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_slider_knob.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_slider_knob.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_wave_bottom.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_wave_bottom.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_wave_top.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_wave_top.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_music_font_16_bold.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\lv_demo_music_font_16_bold.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>FreeRTOS-kernel</GroupName>
+          <Files>
+            <File>
+              <FileName>croutine.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\croutine.c</FilePath>
+            </File>
+            <File>
+              <FileName>event_groups.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\event_groups.c</FilePath>
+            </File>
+            <File>
+              <FileName>list.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\list.c</FilePath>
+            </File>
+            <File>
+              <FileName>queue.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\queue.c</FilePath>
+            </File>
+            <File>
+              <FileName>stream_buffer.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\stream_buffer.c</FilePath>
+            </File>
+            <File>
+              <FileName>tasks.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\tasks.c</FilePath>
+            </File>
+            <File>
+              <FileName>timers.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\timers.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>FreeRTOS-port</GroupName>
+          <Files>
+            <File>
+              <FileName>port.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\portable\GCC\ARM_CM33_NTZ\non_secure\port.c</FilePath>
+            </File>
+            <File>
+              <FileName>portasm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\portable\GCC\ARM_CM33_NTZ\non_secure\portasm.c</FilePath>
+            </File>
+            <File>
+              <FileName>heap_4.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\portable\MemMang\heap_4.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>mb</GroupName>
+          <Files>
+            <File>
+              <FileName>mb_api.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_api.c</FilePath>
+            </File>
+            <File>
+              <FileName>mb_phy_uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_phy_uart.c</FilePath>
+            </File>
+            <File>
+              <FileName>mb_task.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_task.c</FilePath>
+            </File>
+            <File>
+              <FileName>mb_test.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_test.c</FilePath>
+            </File>
+            <File>
+              <FileName>mb_proto.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_proto.c</FilePath>
+            </File>
+            <File>
+              <FileName>mb_phy_can.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_phy_can.c</FilePath>
+            </File>
+            <File>
+              <FileName>device_model.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\device_model.c</FilePath>
+            </File>
+            <File>
+              <FileName>reg_cache.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\reg_cache.c</FilePath>
+            </File>
+            <File>
+              <FileName>event.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\event.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>shell</GroupName>
+          <Files>
+            <File>
+              <FileName>shell.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\shell.c</FilePath>
+            </File>
+            <File>
+              <FileName>chry_shell.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\chry_shell.c</FilePath>
+            </File>
+            <File>
+              <FileName>chry_readline.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\cherryrl\chry_readline.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+      </Groups>
+    </Target>
+    <Target>
+      <TargetName>UserBoot</TargetName>
+      <ToolsetNumber>0x4</ToolsetNumber>
+      <ToolsetName>ARM-ADS</ToolsetName>
+      <pCCUsed>6150000::V6.15::ARMCLANG</pCCUsed>
+      <uAC6>1</uAC6>
+      <TargetOption>
+        <TargetCommonOption>
+          <Device>SWM341xE</Device>
+          <Vendor>Synwit</Vendor>
+          <PackID>Synwit.SWM32_DFP.2.1.4</PackID>
+          <PackURL>http://www.synwit.com/pack</PackURL>
+          <Cpu>IRAM(0x20000000,0x10000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M33") FPU3(SFPU) DSP CLOCK(12000000) ELITTLE</Cpu>
+          <FlashUtilSpec></FlashUtilSpec>
+          <StartupFile></StartupFile>
+          <FlashDriverDll>UL2V8M(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0SWM341xE -FS00 -FL080000 -FP0($$Device:SWM341xE$Flash\SWM341xE.FLM))</FlashDriverDll>
+          <DeviceId>0</DeviceId>
+          <RegisterFile>$$Device:SWM341xE$CSL\SWM341\CMSIS\DeviceSupport\SWM341.h</RegisterFile>
+          <MemoryEnv></MemoryEnv>
+          <Cmp></Cmp>
+          <Asm></Asm>
+          <Linker></Linker>
+          <OHString></OHString>
+          <InfinionOptionDll></InfinionOptionDll>
+          <SLE66CMisc></SLE66CMisc>
+          <SLE66AMisc></SLE66AMisc>
+          <SLE66LinkerMisc></SLE66LinkerMisc>
+          <SFDFile>$$Device:SWM341xE$SVD\SWM341.svd</SFDFile>
+          <bCustSvd>0</bCustSvd>
+          <UseEnv>0</UseEnv>
+          <BinPath></BinPath>
+          <IncludePath></IncludePath>
+          <LibPath></LibPath>
+          <RegisterFilePath></RegisterFilePath>
+          <DBRegisterFilePath></DBRegisterFilePath>
+          <TargetStatus>
+            <Error>0</Error>
+            <ExitCodeStop>0</ExitCodeStop>
+            <ButtonStop>0</ButtonStop>
+            <NotGenerated>0</NotGenerated>
+            <InvalidFlash>1</InvalidFlash>
+          </TargetStatus>
+          <OutputDirectory>.\out\UserBoot\</OutputDirectory>
+          <OutputName>UserBoot</OutputName>
+          <CreateExecutable>1</CreateExecutable>
+          <CreateLib>0</CreateLib>
+          <CreateHexFile>0</CreateHexFile>
+          <DebugInformation>1</DebugInformation>
+          <BrowseInformation>1</BrowseInformation>
+          <ListingPath>.\out\</ListingPath>
+          <HexFormatSelection>1</HexFormatSelection>
+          <Merge32K>0</Merge32K>
+          <CreateBatchFile>0</CreateBatchFile>
+          <BeforeCompile>
+            <RunUserProg1>0</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name></UserProg1Name>
+            <UserProg2Name></UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopU1X>0</nStopU1X>
+            <nStopU2X>0</nStopU2X>
+          </BeforeCompile>
+          <BeforeMake>
+            <RunUserProg1>0</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name></UserProg1Name>
+            <UserProg2Name></UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopB1X>0</nStopB1X>
+            <nStopB2X>0</nStopB2X>
+          </BeforeMake>
+          <AfterMake>
+            <RunUserProg1>1</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name>fromelf --bin -o "$L@L.bin" "#L"</UserProg1Name>
+            <UserProg2Name>fromelf --text -a -c -o "$L@L.asm" "#L"</UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopA1X>0</nStopA1X>
+            <nStopA2X>0</nStopA2X>
+          </AfterMake>
+          <SelectedForBatchBuild>0</SelectedForBatchBuild>
+          <SVCSIdString></SVCSIdString>
+        </TargetCommonOption>
+        <CommonProperty>
+          <UseCPPCompiler>0</UseCPPCompiler>
+          <RVCTCodeConst>0</RVCTCodeConst>
+          <RVCTZI>0</RVCTZI>
+          <RVCTOtherData>0</RVCTOtherData>
+          <ModuleSelection>0</ModuleSelection>
+          <IncludeInBuild>1</IncludeInBuild>
+          <AlwaysBuild>0</AlwaysBuild>
+          <GenerateAssemblyFile>0</GenerateAssemblyFile>
+          <AssembleAssemblyFile>0</AssembleAssemblyFile>
+          <PublicsOnly>0</PublicsOnly>
+          <StopOnExitCode>3</StopOnExitCode>
+          <CustomArgument></CustomArgument>
+          <IncludeLibraryModules></IncludeLibraryModules>
+          <ComprImg>1</ComprImg>
+        </CommonProperty>
+        <DllOption>
+          <SimDllName></SimDllName>
+          <SimDllArguments></SimDllArguments>
+          <SimDlgDll></SimDlgDll>
+          <SimDlgDllArguments></SimDlgDllArguments>
+          <TargetDllName>SARMV8M.DLL</TargetDllName>
+          <TargetDllArguments></TargetDllArguments>
+          <TargetDlgDll>TCM.DLL</TargetDlgDll>
+          <TargetDlgDllArguments>-pCM33</TargetDlgDllArguments>
+        </DllOption>
+        <DebugOption>
+          <OPTHX>
+            <HexSelection>1</HexSelection>
+            <HexRangeLowAddress>0</HexRangeLowAddress>
+            <HexRangeHighAddress>0</HexRangeHighAddress>
+            <HexOffset>0</HexOffset>
+            <Oh166RecLen>16</Oh166RecLen>
+          </OPTHX>
+        </DebugOption>
+        <Utilities>
+          <Flash1>
+            <UseTargetDll>1</UseTargetDll>
+            <UseExternalTool>0</UseExternalTool>
+            <RunIndependent>0</RunIndependent>
+            <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
+            <Capability>1</Capability>
+            <DriverSelection>4102</DriverSelection>
+          </Flash1>
+          <bUseTDR>1</bUseTDR>
+          <Flash2>BIN\UL2V8M.DLL</Flash2>
+          <Flash3>"" ()</Flash3>
+          <Flash4></Flash4>
+          <pFcarmOut></pFcarmOut>
+          <pFcarmGrp></pFcarmGrp>
+          <pFcArmRoot></pFcArmRoot>
+          <FcArmLst>0</FcArmLst>
+        </Utilities>
+        <TargetArmAds>
+          <ArmAdsMisc>
+            <GenerateListings>0</GenerateListings>
+            <asHll>1</asHll>
+            <asAsm>1</asAsm>
+            <asMacX>1</asMacX>
+            <asSyms>1</asSyms>
+            <asFals>1</asFals>
+            <asDbgD>1</asDbgD>
+            <asForm>1</asForm>
+            <ldLst>0</ldLst>
+            <ldmm>1</ldmm>
+            <ldXref>1</ldXref>
+            <BigEnd>0</BigEnd>
+            <AdsALst>1</AdsALst>
+            <AdsACrf>1</AdsACrf>
+            <AdsANop>0</AdsANop>
+            <AdsANot>0</AdsANot>
+            <AdsLLst>1</AdsLLst>
+            <AdsLmap>1</AdsLmap>
+            <AdsLcgr>1</AdsLcgr>
+            <AdsLsym>1</AdsLsym>
+            <AdsLszi>1</AdsLszi>
+            <AdsLtoi>1</AdsLtoi>
+            <AdsLsun>1</AdsLsun>
+            <AdsLven>1</AdsLven>
+            <AdsLsxf>1</AdsLsxf>
+            <RvctClst>0</RvctClst>
+            <GenPPlst>0</GenPPlst>
+            <AdsCpuType>"Cortex-M33"</AdsCpuType>
+            <RvctDeviceName></RvctDeviceName>
+            <mOS>0</mOS>
+            <uocRom>0</uocRom>
+            <uocRam>0</uocRam>
+            <hadIROM>1</hadIROM>
+            <hadIRAM>1</hadIRAM>
+            <hadXRAM>0</hadXRAM>
+            <uocXRam>0</uocXRam>
+            <RvdsVP>2</RvdsVP>
+            <RvdsMve>0</RvdsMve>
+            <RvdsCdeCp>0</RvdsCdeCp>
+            <nBranchProt>0</nBranchProt>
+            <hadIRAM2>0</hadIRAM2>
+            <hadIROM2>0</hadIROM2>
+            <StupSel>8</StupSel>
+            <useUlib>0</useUlib>
+            <EndSel>0</EndSel>
+            <uLtcg>0</uLtcg>
+            <nSecure>0</nSecure>
+            <RoSelD>3</RoSelD>
+            <RwSelD>3</RwSelD>
+            <CodeSel>0</CodeSel>
+            <OptFeed>0</OptFeed>
+            <NoZi1>0</NoZi1>
+            <NoZi2>0</NoZi2>
+            <NoZi3>0</NoZi3>
+            <NoZi4>0</NoZi4>
+            <NoZi5>0</NoZi5>
+            <Ro1Chk>0</Ro1Chk>
+            <Ro2Chk>0</Ro2Chk>
+            <Ro3Chk>0</Ro3Chk>
+            <Ir1Chk>1</Ir1Chk>
+            <Ir2Chk>0</Ir2Chk>
+            <Ra1Chk>0</Ra1Chk>
+            <Ra2Chk>0</Ra2Chk>
+            <Ra3Chk>0</Ra3Chk>
+            <Im1Chk>1</Im1Chk>
+            <Im2Chk>0</Im2Chk>
+            <OnChipMemories>
+              <Ocm1>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm1>
+              <Ocm2>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm2>
+              <Ocm3>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm3>
+              <Ocm4>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm4>
+              <Ocm5>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm5>
+              <Ocm6>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm6>
+              <IRAM>
+                <Type>0</Type>
+                <StartAddress>0x20000000</StartAddress>
+                <Size>0x10000</Size>
+              </IRAM>
+              <IROM>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x80000</Size>
+              </IROM>
+              <XRAM>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </XRAM>
+              <OCR_RVCT1>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT1>
+              <OCR_RVCT2>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT2>
+              <OCR_RVCT3>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT3>
+              <OCR_RVCT4>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x10000</Size>
+              </OCR_RVCT4>
+              <OCR_RVCT5>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT5>
+              <OCR_RVCT6>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT6>
+              <OCR_RVCT7>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT7>
+              <OCR_RVCT8>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT8>
+              <OCR_RVCT9>
+                <Type>0</Type>
+                <StartAddress>0x20000000</StartAddress>
+                <Size>0x10000</Size>
+              </OCR_RVCT9>
+              <OCR_RVCT10>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT10>
+            </OnChipMemories>
+            <RvctStartVector></RvctStartVector>
+          </ArmAdsMisc>
+          <Cads>
+            <interw>1</interw>
+            <Optim>2</Optim>
+            <oTime>0</oTime>
+            <SplitLS>0</SplitLS>
+            <OneElfS>1</OneElfS>
+            <Strict>0</Strict>
+            <EnumInt>0</EnumInt>
+            <PlainCh>0</PlainCh>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <wLevel>3</wLevel>
+            <uThumb>0</uThumb>
+            <uSurpInc>0</uSurpInc>
+            <uC99>0</uC99>
+            <uGnu>0</uGnu>
+            <useXO>0</useXO>
+            <v6Lang>3</v6Lang>
+            <v6LangP>3</v6LangP>
+            <vShortEn>1</vShortEn>
+            <vShortWch>1</vShortWch>
+            <v6Lto>0</v6Lto>
+            <v6WtE>0</v6WtE>
+            <v6Rtti>0</v6Rtti>
+            <VariousControls>
+              <MiscControls>-Wno-invalid-source-encoding</MiscControls>
+              <Define>__TARGET_CONST__=0xFF,</Define>
+              <Undefine></Undefine>
+              <IncludePath>.\CSL\CMSIS\CoreSupport;.\CSL\CMSIS\DeviceSupport;.\CSL\SWM341_StdPeriph_Driver;.\CSL\SWM341_UsbHost_Lib;.\CSL\SWM341_UsbHost_Lib\CDC;.\CSL\SWM341_UsbHost_Lib\HID;.\CSL\SWM341_UsbHost_Lib\MSC;.\CSL\SWM341_UsbHost_Lib\MTP;.\Middleware\FatFs\source;.\Middleware\lvgl;.\Middleware\lvgl\lvgl;.\Middleware\lvgl\lvgl\src;.\Middleware\lvgl\lvgl\src\lv_core;.\Middleware\lvgl\lvgl\src\lv_draw;.\Middleware\lvgl\lvgl\src\lv_font;.\Middleware\lvgl\lvgl\src\lv_gpu;.\Middleware\lvgl\lvgl\src\lv_hal;.\Middleware\lvgl\lvgl\src\lv_misc;.\Middleware\lvgl\lvgl\src\lv_themes;.\Middleware\lvgl\lvgl\src\lv_widgets;.\Middleware\lvgl\lvgl\examples\porting;.\Middleware\lvgl\lv_examples;.\Middleware\lvgl\lv_examples\src;.\Middleware\lvgl\lv_examples\src\lv_demo_widgets;.\Middleware\lvgl\lv_examples\src\lv_demo_benchmark;.\Middleware\lvgl\lv_examples\src\lv_demo_stress;.\Middleware\lvgl\lv_examples\src\lv_demo_music;.\APP;.\APP\can_comm;.\APP\BSP;.\APP\IC_Driver;.\APP\Common Module;.\APP\Software_Parser;.\APP\USB\Device;.\APP\USB\Host;.\APP\UI;.\APP\UI\Resource;.\APP\UI\Page</IncludePath>
+            </VariousControls>
+          </Cads>
+          <Aads>
+            <interw>1</interw>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <thumb>0</thumb>
+            <SplitLS>0</SplitLS>
+            <SwStkChk>0</SwStkChk>
+            <NoWarn>0</NoWarn>
+            <uSurpInc>0</uSurpInc>
+            <useXO>0</useXO>
+            <ClangAsOpt>1</ClangAsOpt>
+            <VariousControls>
+              <MiscControls></MiscControls>
+              <Define></Define>
+              <Undefine></Undefine>
+              <IncludePath></IncludePath>
+            </VariousControls>
+          </Aads>
+          <LDads>
+            <umfTarg>1</umfTarg>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <noStLib>0</noStLib>
+            <RepFail>1</RepFail>
+            <useFile>0</useFile>
+            <TextAddressRange>0x00000000</TextAddressRange>
+            <DataAddressRange>0x00000000</DataAddressRange>
+            <pXoBase></pXoBase>
+            <ScatterFile>.\Linker Scatter File\SWM34S_Nonuse_SFC.sct</ScatterFile>
+            <IncludeLibs></IncludeLibs>
+            <IncludeLibsPath></IncludeLibsPath>
+            <Misc></Misc>
+            <LinkerInputFile></LinkerInputFile>
+            <DisabledWarnings></DisabledWarnings>
+          </LDads>
+        </TargetArmAds>
+      </TargetOption>
+      <Groups>
+        <Group>
+          <GroupName>Readme</GroupName>
+          <Files>
+            <File>
+              <FileName>readme.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\readme.txt</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Config(必看)</GroupName>
+          <Files>
+            <File>
+              <FileName>version.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\version.h</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>APP</GroupName>
+          <Files>
+            <File>
+              <FileName>main.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\app\main.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_app.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_app.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_ui.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_ui.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_usb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_usb.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_mb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_mb.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_iap.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_iap.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_mb_data.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_mb_data.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_export.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_export.c</FilePath>
+            </File>
+            <File>
+              <FileName>wave_data.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\wave_data.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>BSP</GroupName>
+          <Files>
+            <File>
+              <FileName>irq_handler.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\irq_handler.c</FilePath>
+            </File>
+            <File>
+              <FileName>bsp_init.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\bsp_init.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_systick.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_systick.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_bod.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_bod.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_crc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_crc.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_jpeg.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_jpeg.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_uart.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sfc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_sfc.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sdram.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_sdram.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sdio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_sdio.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_dac.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_dac.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_lcd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_lcd.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_touch.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_touch.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sleep_stop.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_sleep_stop.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_io.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Bsp\dev_io.h</FilePath>
+            </File>
+            <File>
+              <FileName>dev_io_spi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_io_spi.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_io_i2c.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_io_i2c.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_can.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\BSP\dev_can.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>IC_Driver</GroupName>
+          <Files>
+            <File>
+              <FileName>documents.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\IC_Driver\documents.txt</FilePath>
+            </File>
+            <File>
+              <FileName>SPI_WB25Qxx.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\SPI_WB25Qxx.c</FilePath>
+            </File>
+            <File>
+              <FileName>LCD_TL021WVC02.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\LCD_TL021WVC02.c</FilePath>
+            </File>
+            <File>
+              <FileName>LCD_TL040WVS03.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\LCD_TL040WVS03.c</FilePath>
+            </File>
+            <File>
+              <FileName>LCD_JLT35002A.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\LCD_JLT35002A.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_CST826.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_CST826.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_CST328.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_CST328.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_FT5206.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_FT5206.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_FT6336.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_FT6336.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_GT911.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_GT911.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_Tango_C32.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_Tango_C32.c</FilePath>
+            </File>
+            <File>
+              <FileName>TP_ILI2117A.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\TP_ILI2117A.c</FilePath>
+            </File>
+            <File>
+              <FileName>lcd_st7789.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\lcd_st7789.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Common Module</GroupName>
+          <Files>
+            <File>
+              <FileName>documents.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Common Module\documents.txt</FilePath>
+            </File>
+            <File>
+              <FileName>file_table.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\file_table.c</FilePath>
+            </File>
+            <File>
+              <FileName>load_file.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\load_file.c</FilePath>
+            </File>
+            <File>
+              <FileName>load_mv.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\load_mv.c</FilePath>
+            </File>
+            <File>
+              <FileName>mem_sdram.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\mem_sdram.c</FilePath>
+            </File>
+            <File>
+              <FileName>FlashDisk.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\FlashDisk.c</FilePath>
+            </File>
+            <File>
+              <FileName>userboot.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\userboot.c</FilePath>
+            </File>
+            <File>
+              <FileName>pthread_lock.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Common Module\pthread_lock.h</FilePath>
+            </File>
+            <File>
+              <FileName>posix_fsm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\posix_fsm.c</FilePath>
+            </File>
+            <File>
+              <FileName>log.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\log.c</FilePath>
+            </File>
+            <File>
+              <FileName>board_test.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\board_test.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>UI</GroupName>
+          <Files>
+            <File>
+              <FileName>documents.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\UI\documents.txt</FilePath>
+            </File>
+            <File>
+              <FileName>simple_lcd_rgb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\simple_lcd_rgb.c</FilePath>
+            </File>
+            <File>
+              <FileName>ui.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\UI\ui.h</FilePath>
+            </File>
+            <File>
+              <FileName>ui.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\ui.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>ui_boot.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\ui_boot.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>ui_update.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\ui_update.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>ui_test_button.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\ui_test_button.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>UI\Resource</GroupName>
+          <GroupOption>
+            <CommonProperty>
+              <UseCPPCompiler>0</UseCPPCompiler>
+              <RVCTCodeConst>0</RVCTCodeConst>
+              <RVCTZI>0</RVCTZI>
+              <RVCTOtherData>0</RVCTOtherData>
+              <ModuleSelection>0</ModuleSelection>
+              <IncludeInBuild>0</IncludeInBuild>
+              <AlwaysBuild>2</AlwaysBuild>
+              <GenerateAssemblyFile>2</GenerateAssemblyFile>
+              <AssembleAssemblyFile>2</AssembleAssemblyFile>
+              <PublicsOnly>2</PublicsOnly>
+              <StopOnExitCode>11</StopOnExitCode>
+              <CustomArgument></CustomArgument>
+              <IncludeLibraryModules></IncludeLibraryModules>
+              <ComprImg>1</ComprImg>
+            </CommonProperty>
+            <GroupArmAds>
+              <Cads>
+                <interw>2</interw>
+                <Optim>0</Optim>
+                <oTime>2</oTime>
+                <SplitLS>2</SplitLS>
+                <OneElfS>2</OneElfS>
+                <Strict>2</Strict>
+                <EnumInt>2</EnumInt>
+                <PlainCh>2</PlainCh>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <wLevel>0</wLevel>
+                <uThumb>2</uThumb>
+                <uSurpInc>2</uSurpInc>
+                <uC99>2</uC99>
+                <uGnu>2</uGnu>
+                <useXO>2</useXO>
+                <v6Lang>0</v6Lang>
+                <v6LangP>0</v6LangP>
+                <vShortEn>2</vShortEn>
+                <vShortWch>2</vShortWch>
+                <v6Lto>2</v6Lto>
+                <v6WtE>2</v6WtE>
+                <v6Rtti>2</v6Rtti>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Cads>
+              <Aads>
+                <interw>2</interw>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <thumb>2</thumb>
+                <SplitLS>2</SplitLS>
+                <SwStkChk>2</SwStkChk>
+                <NoWarn>2</NoWarn>
+                <uSurpInc>2</uSurpInc>
+                <useXO>2</useXO>
+                <ClangAsOpt>0</ClangAsOpt>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Aads>
+            </GroupArmAds>
+          </GroupOption>
+          <Files>
+            <File>
+              <FileName>image_source.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Resource\image_source.c</FilePath>
+            </File>
+            <File>
+              <FileName>yahei11_font.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Resource\yahei11_font.c</FilePath>
+            </File>
+            <File>
+              <FileName>demo_font.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Resource\demo_font.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>UI\Page</GroupName>
+          <GroupOption>
+            <CommonProperty>
+              <UseCPPCompiler>0</UseCPPCompiler>
+              <RVCTCodeConst>0</RVCTCodeConst>
+              <RVCTZI>0</RVCTZI>
+              <RVCTOtherData>0</RVCTOtherData>
+              <ModuleSelection>0</ModuleSelection>
+              <IncludeInBuild>0</IncludeInBuild>
+              <AlwaysBuild>2</AlwaysBuild>
+              <GenerateAssemblyFile>2</GenerateAssemblyFile>
+              <AssembleAssemblyFile>2</AssembleAssemblyFile>
+              <PublicsOnly>2</PublicsOnly>
+              <StopOnExitCode>11</StopOnExitCode>
+              <CustomArgument></CustomArgument>
+              <IncludeLibraryModules></IncludeLibraryModules>
+              <ComprImg>1</ComprImg>
+            </CommonProperty>
+            <GroupArmAds>
+              <Cads>
+                <interw>2</interw>
+                <Optim>0</Optim>
+                <oTime>2</oTime>
+                <SplitLS>2</SplitLS>
+                <OneElfS>2</OneElfS>
+                <Strict>2</Strict>
+                <EnumInt>2</EnumInt>
+                <PlainCh>2</PlainCh>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <wLevel>0</wLevel>
+                <uThumb>2</uThumb>
+                <uSurpInc>2</uSurpInc>
+                <uC99>2</uC99>
+                <uGnu>2</uGnu>
+                <useXO>2</useXO>
+                <v6Lang>0</v6Lang>
+                <v6LangP>0</v6LangP>
+                <vShortEn>2</vShortEn>
+                <vShortWch>2</vShortWch>
+                <v6Lto>2</v6Lto>
+                <v6WtE>2</v6WtE>
+                <v6Rtti>2</v6Rtti>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Cads>
+              <Aads>
+                <interw>2</interw>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <thumb>2</thumb>
+                <SplitLS>2</SplitLS>
+                <SwStkChk>2</SwStkChk>
+                <NoWarn>2</NoWarn>
+                <uSurpInc>2</uSurpInc>
+                <useXO>2</useXO>
+                <ClangAsOpt>0</ClangAsOpt>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Aads>
+            </GroupArmAds>
+          </GroupOption>
+          <Files>
+            <File>
+              <FileName>ui_event.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\ui_event.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_scr_home.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_scr_home.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_home_page_home.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_home_page_home.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_home_page_m0.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_home_page_m0.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_home_page_m4.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_home_page_m4.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_home_page_pd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_home_page_pd.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_home_page_pp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_home_page_pp.c</FilePath>
+            </File>
+            <File>
+              <FileName>setup_scr_m0_m4.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\UI\Page\setup_scr_m0_m4.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Software_Parser</GroupName>
+          <Files>
+            <File>
+              <FileName>jfif_parser.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Software_Parser\jfif_parser.c</FilePath>
+            </File>
+            <File>
+              <FileName>avi_parser.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Software_Parser\avi_parser.c</FilePath>
+            </File>
+            <File>
+              <FileName>wav_parser.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Software_Parser\wav_parser.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>USBH\User</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_user.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\USB\Host\usbh_user.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_cdc_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_cdc_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_hid_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_hid_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_msc_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_mtp_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_mtp_conf.h</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>=====芯片支持库=====</GroupName>
+        </Group>
+        <Group>
+          <GroupName>CSL\CMSIS</GroupName>
+          <Files>
+            <File>
+              <FileName>system_SWM341.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\CMSIS\DeviceSupport\system_SWM341.c</FilePath>
+            </File>
+            <File>
+              <FileName>startup_SWM341.s</FileName>
+              <FileType>2</FileType>
+              <FilePath>.\CSL\CMSIS\DeviceSupport\startup\arm\startup_SWM341.s</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\StdPD</GroupName>
+          <Files>
+            <File>
+              <FileName>SWM341_adc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_adc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_can.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_can.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_cordic.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_cordic.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_crc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_crc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dac.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dac.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_div.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_div.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dma.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dma.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_exti.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_exti.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_flash.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_flash.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_gpio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_gpio.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_i2c.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_i2c.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_jpeg.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_jpeg.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_lcd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_lcd.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_port.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_port.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_pwm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_pwm.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sdio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sdio.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sdram.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sdram.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sfc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sfc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sleep.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sleep.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_spi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_spi.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_timr.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_timr.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_uart.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_usbd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_usbd.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_usbh.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_usbh.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_wdt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_wdt.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dma2d.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dma2d.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_qei.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_qei.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_iofilt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_iofilt.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\USBH</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\usbh_core.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_stdreq.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\usbh_stdreq.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\USBH\MSC</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_msc_bot.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_bot.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_core.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_scsi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_scsi.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>======中间件=======</GroupName>
+        </Group>
+        <Group>
+          <GroupName>FATFS</GroupName>
+          <Files>
+            <File>
+              <FileName>00readme.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\FatFs\source\00readme.txt</FilePath>
+            </File>
+            <File>
+              <FileName>diskio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\diskio.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffconf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffconf.h</FilePath>
+            </File>
+            <File>
+              <FileName>ff.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ff.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffsystem.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffsystem.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffunicode.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffunicode.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_porting</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\lv_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>lv_port_disp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_disp.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_port_indev.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_indev.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_port_fs.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_fs.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>lv_port_disp1.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_disp1.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>lv_port_disp2_1.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_disp2_1.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>lv_port_disp2_2.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_disp2_2.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>lv_port_disp3.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\examples\porting\lv_port_disp3.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_gpu</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_gpu_swm341_dma2d.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_gpu\lv_gpu_swm341_dma2d.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_core</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_disp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_disp.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_group.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_group.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_indev.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_indev.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_obj.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_obj.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_refr.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_refr.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_style.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_core\lv_style.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_draw</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_draw_arc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_arc.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_blend.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_blend.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_img.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_img.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_label.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_label.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_line.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_line.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_mask.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_mask.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_rect.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_rect.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_draw_triangle.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_draw_triangle.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_img_buf.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_img_buf.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_img_cache.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_img_cache.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_img_decoder.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_draw\lv_img_decoder.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_font</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_font.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_dejavu_16_persian_hebrew.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_dejavu_16_persian_hebrew.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_fmt_txt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_fmt_txt.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_loader.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_loader.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_8.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_8.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_10.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_10.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_12.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_12.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_12_subpx.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_12_subpx.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_14.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_14.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_16.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_16.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_18.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_18.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_20.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_20.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_22.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_22.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_24.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_24.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_26.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_26.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_28.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_28.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_28_compressed.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_28_compressed.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_30.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_30.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_32.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_32.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_34.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_34.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_36.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_36.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_38.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_38.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_40.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_40.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_42.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_42.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_44.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_44.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_46.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_46.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_48.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_montserrat_48.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_simsun_16_cjk.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_simsun_16_cjk.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_unscii_8.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_unscii_8.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_unscii_16.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_font\lv_font_unscii_16.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_hal</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_hal_disp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_hal\lv_hal_disp.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_hal_indev.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_hal\lv_hal_indev.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_hal_tick.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_hal\lv_hal_tick.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_misc</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_anim.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_anim.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_area.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_area.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_async.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_async.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_bidi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_bidi.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_color.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_color.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_debug.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_debug.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_fs.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_fs.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_gc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_gc.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_ll.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_ll.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_log.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_log.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_math.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_math.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_mem.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_mem.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_printf.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_printf.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_task.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_task.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_templ.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_templ.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_txt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_txt.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_txt_ap.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_txt_ap.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_utils.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_misc\lv_utils.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_themes</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_theme.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_themes\lv_theme.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_theme_empty.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_themes\lv_theme_empty.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_theme_material.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_themes\lv_theme_material.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_theme_mono.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_themes\lv_theme_mono.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_theme_template.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_themes\lv_theme_template.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_widgets</GroupName>
+          <Files>
+            <File>
+              <FileName>lv_arc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_arc.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_bar.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_bar.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_btn.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_btn.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_btnmatrix.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_btnmatrix.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_calendar.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_calendar.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_canvas.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_canvas.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_chart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_chart.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_checkbox.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_checkbox.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_cont.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_cont.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_cpicker.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_cpicker.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_dropdown.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_dropdown.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_gauge.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_gauge.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_img.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_img.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_imgbtn.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_imgbtn.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_keyboard.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_keyboard.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_label.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_label.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_led.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_led.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_line.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_line.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_linemeter.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_linemeter.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_list.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_list.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_msgbox.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_msgbox.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_objmask.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_objmask.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_objx_templ.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_objx_templ.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_page.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_page.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_roller.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_roller.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_slider.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_slider.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_spinbox.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_spinbox.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_spinner.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_spinner.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_switch.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_switch.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_table.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_table.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_tabview.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_tabview.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_textarea.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_textarea.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_tileview.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_tileview.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_win.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lvgl\src\lv_widgets\lv_win.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>lv_example</GroupName>
+          <GroupOption>
+            <CommonProperty>
+              <UseCPPCompiler>0</UseCPPCompiler>
+              <RVCTCodeConst>0</RVCTCodeConst>
+              <RVCTZI>0</RVCTZI>
+              <RVCTOtherData>0</RVCTOtherData>
+              <ModuleSelection>0</ModuleSelection>
+              <IncludeInBuild>0</IncludeInBuild>
+              <AlwaysBuild>2</AlwaysBuild>
+              <GenerateAssemblyFile>2</GenerateAssemblyFile>
+              <AssembleAssemblyFile>2</AssembleAssemblyFile>
+              <PublicsOnly>2</PublicsOnly>
+              <StopOnExitCode>11</StopOnExitCode>
+              <CustomArgument></CustomArgument>
+              <IncludeLibraryModules></IncludeLibraryModules>
+              <ComprImg>1</ComprImg>
+            </CommonProperty>
+            <GroupArmAds>
+              <Cads>
+                <interw>2</interw>
+                <Optim>0</Optim>
+                <oTime>2</oTime>
+                <SplitLS>2</SplitLS>
+                <OneElfS>2</OneElfS>
+                <Strict>2</Strict>
+                <EnumInt>2</EnumInt>
+                <PlainCh>2</PlainCh>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <wLevel>0</wLevel>
+                <uThumb>2</uThumb>
+                <uSurpInc>2</uSurpInc>
+                <uC99>2</uC99>
+                <uGnu>2</uGnu>
+                <useXO>2</useXO>
+                <v6Lang>0</v6Lang>
+                <v6LangP>0</v6LangP>
+                <vShortEn>2</vShortEn>
+                <vShortWch>2</vShortWch>
+                <v6Lto>2</v6Lto>
+                <v6WtE>2</v6WtE>
+                <v6Rtti>2</v6Rtti>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Cads>
+              <Aads>
+                <interw>2</interw>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <thumb>2</thumb>
+                <SplitLS>2</SplitLS>
+                <SwStkChk>2</SwStkChk>
+                <NoWarn>2</NoWarn>
+                <uSurpInc>2</uSurpInc>
+                <useXO>2</useXO>
+                <ClangAsOpt>0</ClangAsOpt>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Aads>
+            </GroupArmAds>
+          </GroupOption>
+          <Files>
+            <File>
+              <FileName>lv_ex_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\lv_ex_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_widgets.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_widgets\lv_demo_widgets.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_benchmark.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_benchmark\lv_demo_benchmark.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_stress.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_stress\lv_demo_stress.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_cogwheel_alpha16.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_cogwheel_alpha16.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_cogwheel_argb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_cogwheel_argb.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_cogwheel_chroma_keyed.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_cogwheel_chroma_keyed.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_cogwheel_indexed16.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_cogwheel_indexed16.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_cogwheel_rgb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_cogwheel_rgb.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_hand.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\img_hand.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_12_compr_az.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\lv_font_montserrat_12_compr_az.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_16_compr_az.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\lv_font_montserrat_16_compr_az.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_font_montserrat_28_compr_az.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\assets\lv_font_montserrat_28_compr_az.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_music.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\lv_demo_music.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_music_list.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\lv_demo_music_list.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_music_main.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\lv_demo_music_main.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_list_pause.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_list_pause.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_list_play.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_list_play.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_loop.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_loop.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_next.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_next.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_pause.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_pause.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_play.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_play.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_prev.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_prev.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_btn_rnd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_btn_rnd.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_corner_left.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_corner_left.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_corner_right.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_corner_right.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_cover_1.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_cover_1.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_cover_2.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_cover_2.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_cover_3.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_cover_3.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_icon_1.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_icon_1.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_icon_2.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_icon_2.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_icon_3.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_icon_3.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_icon_4.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_icon_4.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_list_border.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_list_border.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_logo.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_logo.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_slider_knob.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_slider_knob.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_wave_bottom.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_wave_bottom.c</FilePath>
+            </File>
+            <File>
+              <FileName>img_lv_demo_music_wave_top.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\img_lv_demo_music_wave_top.c</FilePath>
+            </File>
+            <File>
+              <FileName>lv_demo_music_font_16_bold.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\lvgl\lv_examples\src\lv_demo_music\assets\lv_demo_music_font_16_bold.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>FreeRTOS-kernel</GroupName>
+          <Files>
+            <File>
+              <FileName>croutine.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\croutine.c</FilePath>
+            </File>
+            <File>
+              <FileName>event_groups.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\event_groups.c</FilePath>
+            </File>
+            <File>
+              <FileName>list.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\list.c</FilePath>
+            </File>
+            <File>
+              <FileName>queue.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\queue.c</FilePath>
+            </File>
+            <File>
+              <FileName>stream_buffer.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\stream_buffer.c</FilePath>
+            </File>
+            <File>
+              <FileName>tasks.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\tasks.c</FilePath>
+            </File>
+            <File>
+              <FileName>timers.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\timers.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>FreeRTOS-port</GroupName>
+          <Files>
+            <File>
+              <FileName>port.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\portable\GCC\ARM_CM33_NTZ\non_secure\port.c</FilePath>
+            </File>
+            <File>
+              <FileName>portasm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\portable\GCC\ARM_CM33_NTZ\non_secure\portasm.c</FilePath>
+            </File>
+            <File>
+              <FileName>heap_4.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FreeRTOS-Kernel\portable\MemMang\heap_4.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>mb</GroupName>
+          <Files>
+            <File>
+              <FileName>mb_api.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_api.c</FilePath>
+            </File>
+            <File>
+              <FileName>mb_phy_uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_phy_uart.c</FilePath>
+            </File>
+            <File>
+              <FileName>mb_task.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_task.c</FilePath>
+            </File>
+            <File>
+              <FileName>mb_test.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_test.c</FilePath>
+            </File>
+            <File>
+              <FileName>mb_proto.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_proto.c</FilePath>
+            </File>
+            <File>
+              <FileName>mb_phy_can.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\mb_phy_can.c</FilePath>
+            </File>
+            <File>
+              <FileName>device_model.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\device_model.c</FilePath>
+            </File>
+            <File>
+              <FileName>reg_cache.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\reg_cache.c</FilePath>
+            </File>
+            <File>
+              <FileName>event.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\mb\event.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>shell</GroupName>
+          <Files>
+            <File>
+              <FileName>shell.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\shell.c</FilePath>
+            </File>
+            <File>
+              <FileName>chry_shell.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\chry_shell.c</FilePath>
+            </File>
+            <File>
+              <FileName>chry_readline.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\cherryrl\chry_readline.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+      </Groups>
+    </Target>
+  </Targets>
+
+  <RTE>
+    <apis/>
+    <components/>
+    <files>
+      <file attr="config" category="header" name="Config\EventRecorderConf.h" version="1.1.0">
+        <instance index="0" removed="1">RTE\Compiler\EventRecorderConf.h</instance>
+        <component Cbundle="ARM Compiler" Cclass="Compiler" Cgroup="Event Recorder" Cvariant="DAP" Cvendor="Keil" Cversion="1.4.0" condition="Cortex-M Device"/>
+        <package name="ARM_Compiler" schemaVersion="1.6.3" url="http://www.keil.com/pack/" vendor="Keil" version="1.6.3"/>
+        <targetInfos/>
+      </file>
+      <file attr="config" category="source" condition="Compiler ARM" name="CSL\SWM341\CMSIS\DeviceSupport\startup\arm\startup_SWM341.s" version="1.6.0">
+        <instance index="0" removed="1">RTE\Device\SWM341xE\startup_SWM341.s</instance>
+        <component Cclass="Device" Cgroup="Startup" Cvendor="Synwit" Cversion="1.6.0" condition="SWM341 Series"/>
+        <package name="SWM32_DFP" schemaVersion="1.2" url="http://www.synwit.com/pack" vendor="Synwit" version="1.21.0"/>
+        <targetInfos/>
+      </file>
+      <file attr="config" category="source" name="CSL\SWM341\CMSIS\DeviceSupport\system_SWM341.c" version="1.6.0">
+        <instance index="0" removed="1">RTE\Device\SWM341xE\system_SWM341.c</instance>
+        <component Cclass="Device" Cgroup="Startup" Cvendor="Synwit" Cversion="1.6.0" condition="SWM341 Series"/>
+        <package name="SWM32_DFP" schemaVersion="1.2" url="http://www.synwit.com/pack" vendor="Synwit" version="1.21.0"/>
+        <targetInfos/>
+      </file>
+      <file attr="config" category="header" name="RTE\configs\mbedTLS_config.h" version="2.28.0">
+        <instance index="0" removed="1">RTE\Security\mbedTLS_config.h</instance>
+        <component Cclass="Security" Cgroup="mbed TLS" Cvendor="ARM" Cversion="3.1.0"/>
+        <package name="mbedTLS" schemaVersion="1.6.3" url="https://www.keil.com/pack/" vendor="ARM" version="3.1.0"/>
+        <targetInfos/>
+      </file>
+      <file attr="config" category="header" name="RTE\configs\mbedTLS_crypto_config.h" version="2.28.0">
+        <instance index="0" removed="1">RTE\Security\mbedTLS_crypto_config.h</instance>
+        <component Cclass="Security" Cgroup="mbed TLS" Cvendor="ARM" Cversion="3.1.0"/>
+        <package name="mbedTLS" schemaVersion="1.6.3" url="https://www.keil.com/pack/" vendor="ARM" version="3.1.0"/>
+        <targetInfos/>
+      </file>
+    </files>
+  </RTE>
+
+  <LayerInfo>
+    <Layers>
+      <Layer>
+        <LayName>SWM341_StdPeriph_Driver</LayName>
+        <LayPrjMark>1</LayPrjMark>
+      </Layer>
+    </Layers>
+  </LayerInfo>
+
+</Project>
index 30f3e7d573822066f789ef042f5848513a59e0a1..ed6b0f140cfd550c106c6e669c3d4a4e81e91dc6 100644 (file)
           <Vendor>Synwit</Vendor>
           <PackID>Synwit.SWM32_DFP.2.1.4</PackID>
           <PackURL>http://www.synwit.com/pack</PackURL>
-          <Cpu>CPUTYPE("Cortex-M33") FPU3(SFPU) DSP CLOCK(12000000) ESEL ELITTLE</Cpu>
+          <Cpu>IRAM(0x20000000,0x10000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M33") FPU3(SFPU) DSP CLOCK(12000000) ELITTLE</Cpu>
           <FlashUtilSpec></FlashUtilSpec>
           <StartupFile></StartupFile>
-          <FlashDriverDll></FlashDriverDll>
-          <DeviceId>5125</DeviceId>
-          <RegisterFile></RegisterFile>
+          <FlashDriverDll>UL2V8M(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0SWM341xE -FS00 -FL080000 -FP0($$Device:SWM341xE$Flash\SWM341xE.FLM))</FlashDriverDll>
+          <DeviceId>0</DeviceId>
+          <RegisterFile>$$Device:SWM341xE$CSL\SWM341\CMSIS\DeviceSupport\SWM341.h</RegisterFile>
           <MemoryEnv></MemoryEnv>
           <Cmp></Cmp>
           <Asm></Asm>
@@ -33,7 +33,7 @@
           <SLE66CMisc></SLE66CMisc>
           <SLE66AMisc></SLE66AMisc>
           <SLE66LinkerMisc></SLE66LinkerMisc>
-          <SFDFile>C:\Keil\ARM\SFD\SWM341.SFR</SFDFile>
+          <SFDFile>$$Device:SWM341xE$SVD\SWM341.svd</SFDFile>
           <bCustSvd>0</bCustSvd>
           <UseEnv>0</UseEnv>
           <BinPath></BinPath>
@@ -49,7 +49,7 @@
             <InvalidFlash>1</InvalidFlash>
           </TargetStatus>
           <OutputDirectory>.\out\dispboard_bootloader\</OutputDirectory>
-          <OutputName>dispboard_bootloader</OutputName>
+          <OutputName>dispboard</OutputName>
           <CreateExecutable>1</CreateExecutable>
           <CreateLib>0</CreateLib>
           <CreateHexFile>0</CreateHexFile>
@@ -82,7 +82,7 @@
           <AfterMake>
             <RunUserProg1>1</RunUserProg1>
             <RunUserProg2>0</RunUserProg2>
-            <UserProg1Name>fromelf --bin -o "$L@L.bin" "#L"</UserProg1Name>
+            <UserProg1Name>fromelf --i32combined -o "$L@L.hex" "#L"</UserProg1Name>
             <UserProg2Name>fromelf --text -a -c -o "$L@L.asm" "#L"</UserProg2Name>
             <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
             <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
           <ComprImg>1</ComprImg>
         </CommonProperty>
         <DllOption>
-          <SimDllName>SARMCM3.DLL</SimDllName>
+          <SimDllName></SimDllName>
           <SimDllArguments></SimDllArguments>
-          <SimDlgDll>DCM.DLL</SimDlgDll>
-          <SimDlgDllArguments>-pCM4</SimDlgDllArguments>
-          <TargetDllName>SARMCM3.DLL</TargetDllName>
+          <SimDlgDll></SimDlgDll>
+          <SimDlgDllArguments></SimDlgDllArguments>
+          <TargetDllName>SARMV8M.DLL</TargetDllName>
           <TargetDllArguments></TargetDllArguments>
           <TargetDlgDll>TCM.DLL</TargetDlgDll>
-          <TargetDlgDllArguments>-pCM4</TargetDlgDllArguments>
+          <TargetDlgDllArguments>-pCM33</TargetDlgDllArguments>
         </DllOption>
         <DebugOption>
           <OPTHX>
             <RunIndependent>0</RunIndependent>
             <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
             <Capability>1</Capability>
-            <DriverSelection>4099</DriverSelection>
+            <DriverSelection>4102</DriverSelection>
           </Flash1>
           <bUseTDR>1</bUseTDR>
           <Flash2>BIN\UL2V8M.DLL</Flash2>
             <mOS>0</mOS>
             <uocRom>0</uocRom>
             <uocRam>0</uocRam>
-            <hadIROM>0</hadIROM>
-            <hadIRAM>0</hadIRAM>
+            <hadIROM>1</hadIROM>
+            <hadIRAM>1</hadIRAM>
             <hadXRAM>0</hadXRAM>
             <uocXRam>0</uocXRam>
-            <RvdsVP>1</RvdsVP>
+            <RvdsVP>2</RvdsVP>
             <RvdsMve>0</RvdsMve>
             <RvdsCdeCp>0</RvdsCdeCp>
             <nBranchProt>0</nBranchProt>
             <hadIROM2>0</hadIROM2>
             <StupSel>8</StupSel>
             <useUlib>1</useUlib>
-            <EndSel>1</EndSel>
+            <EndSel>0</EndSel>
             <uLtcg>0</uLtcg>
             <nSecure>0</nSecure>
             <RoSelD>3</RoSelD>
-            <RwSelD>5</RwSelD>
+            <RwSelD>3</RwSelD>
             <CodeSel>0</CodeSel>
             <OptFeed>0</OptFeed>
             <NoZi1>0</NoZi1>
               </Ocm6>
               <IRAM>
                 <Type>0</Type>
-                <StartAddress>0x0</StartAddress>
-                <Size>0x0</Size>
+                <StartAddress>0x20000000</StartAddress>
+                <Size>0x10000</Size>
               </IRAM>
               <IROM>
-                <Type>0</Type>
+                <Type>1</Type>
                 <StartAddress>0x0</StartAddress>
-                <Size>0x0</Size>
+                <Size>0x80000</Size>
               </IROM>
               <XRAM>
                 <Type>0</Type>
               <OCR_RVCT4>
                 <Type>1</Type>
                 <StartAddress>0x0</StartAddress>
-                <Size>0x10000</Size>
+                <Size>0x20000</Size>
               </OCR_RVCT4>
               <OCR_RVCT5>
                 <Type>1</Type>
-                <StartAddress>0x80000000</StartAddress>
-                <Size>0x800000</Size>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
               </OCR_RVCT5>
               <OCR_RVCT6>
                 <Type>0</Type>
           </ArmAdsMisc>
           <Cads>
             <interw>1</interw>
-            <Optim>2</Optim>
+            <Optim>1</Optim>
             <oTime>0</oTime>
             <SplitLS>0</SplitLS>
-            <OneElfS>0</OneElfS>
+            <OneElfS>1</OneElfS>
             <Strict>0</Strict>
             <EnumInt>0</EnumInt>
             <PlainCh>0</PlainCh>
             <uGnu>0</uGnu>
             <useXO>0</useXO>
             <v6Lang>3</v6Lang>
-            <v6LangP>1</v6LangP>
+            <v6LangP>3</v6LangP>
             <vShortEn>1</vShortEn>
             <vShortWch>1</vShortWch>
             <v6Lto>0</v6Lto>
             <v6WtE>0</v6WtE>
             <v6Rtti>0</v6Rtti>
             <VariousControls>
-              <MiscControls></MiscControls>
-              <Define></Define>
+              <MiscControls>-Wno-invalid-source-encoding</MiscControls>
+              <Define>__TARGET_CONST__=0, BOOTLOADER</Define>
               <Undefine></Undefine>
-              <IncludePath>.\CSL\CMSIS\CoreSupport;.\CSL\CMSIS\DeviceSupport;.\CSL\SWM341_StdPeriph_Driver;.\APP</IncludePath>
+              <IncludePath>.\CSL\CMSIS\CoreSupport;.\CSL\CMSIS\DeviceSupport;.\CSL\SWM341_StdPeriph_Driver;.\CSL\SWM341_UsbHost_Lib;.\CSL\SWM341_UsbHost_Lib\CDC;.\CSL\SWM341_UsbHost_Lib\HID;.\CSL\SWM341_UsbHost_Lib\MSC;.\CSL\SWM341_UsbHost_Lib\MTP;.\Middleware\FatFs\source;.\Middleware\lvgl;.\Middleware\lvgl\lvgl;.\Middleware\lvgl\lvgl\src;.\Middleware\lvgl\lvgl\src\lv_core;.\Middleware\lvgl\lvgl\src\lv_draw;.\Middleware\lvgl\lvgl\src\lv_font;.\Middleware\lvgl\lvgl\src\lv_gpu;.\Middleware\lvgl\lvgl\src\lv_hal;.\Middleware\lvgl\lvgl\src\lv_misc;.\Middleware\lvgl\lvgl\src\lv_themes;.\Middleware\lvgl\lvgl\src\lv_widgets;.\Middleware\lvgl\lvgl\examples\porting;.\Middleware\lvgl\lv_examples;.\Middleware\lvgl\lv_examples\src;.\Middleware\lvgl\lv_examples\src\lv_demo_widgets;.\Middleware\lvgl\lv_examples\src\lv_demo_benchmark;.\Middleware\lvgl\lv_examples\src\lv_demo_stress;.\Middleware\lvgl\lv_examples\src\lv_demo_music;.\APP;.\APP\can_comm;.\APP\BSP;.\APP\IC_Driver;.\APP\Common Module;.\APP\Software_Parser;.\APP\USB\Device;.\APP\USB\Host;.\APP\UI;.\APP\UI\Resource;.\APP\UI\Page;.\Middleware\FreeRTOS-Kernel;.\Middleware\FreeRTOS-Kernel\include;.\Middleware\FreeRTOS-Kernel\portable\GCC\ARM_CM33_NTZ\non_secure;.\Middleware\FreeRTOS-Kernel\portable\MemMang;.\APP\can_comm;.\APP\mb;.\APP\shell;.\APP\shell\cherryrl;.\APP\bootloader;.\APP\bootloader\font;.\APP\fs</IncludePath>
             </VariousControls>
           </Cads>
           <Aads>
             <ClangAsOpt>1</ClangAsOpt>
             <VariousControls>
               <MiscControls></MiscControls>
-              <Define></Define>
+              <Define>BOOTLOADER</Define>
               <Undefine></Undefine>
               <IncludePath></IncludePath>
             </VariousControls>
           </Aads>
           <LDads>
             <umfTarg>1</umfTarg>
-            <Ropi>0</Ropi>
-            <Rwpi>0</Rwpi>
+            <Ropi>1</Ropi>
+            <Rwpi>1</Rwpi>
             <noStLib>0</noStLib>
             <RepFail>1</RepFail>
             <useFile>0</useFile>
             <TextAddressRange>0x00000000</TextAddressRange>
             <DataAddressRange>0x00000000</DataAddressRange>
             <pXoBase></pXoBase>
-            <ScatterFile></ScatterFile>
+            <ScatterFile>.\Linker_Scatter_File\SWM34S_NoLink_SPI_Flash.sct</ScatterFile>
             <IncludeLibs></IncludeLibs>
             <IncludeLibsPath></IncludeLibsPath>
             <Misc></Misc>
         </TargetArmAds>
       </TargetOption>
       <Groups>
+        <Group>
+          <GroupName>Readme</GroupName>
+          <Files>
+            <File>
+              <FileName>readme.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\readme.txt</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Config(必看)</GroupName>
+          <Files>
+            <File>
+              <FileName>version.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\version.h</FilePath>
+            </File>
+          </Files>
+        </Group>
         <Group>
           <GroupName>APP</GroupName>
           <Files>
             <File>
-              <FileName>bootloader_main.c</FileName>
+              <FileName>main.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\APP\bootloader\bootloader_main.c</FilePath>
+              <FilePath>.\app\main.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>user_app.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_app.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>user_usb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_usb.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+            <File>
+              <FileName>user_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_rtc.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>CSL\StdPD</GroupName>
+          <GroupName>BSP</GroupName>
           <Files>
             <File>
-              <FileName>SWM341_port.c</FileName>
+              <FileName>irq_handler.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_port.c</FilePath>
+              <FilePath>.\APP\bsp\irq_handler.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_gpio.c</FileName>
+              <FileName>bsp_init.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_gpio.c</FilePath>
+              <FilePath>.\APP\bsp\bsp_init.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_exti.c</FileName>
+              <FileName>dev_systick.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_exti.c</FilePath>
+              <FilePath>.\APP\bsp\dev_systick.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_timr.c</FileName>
+              <FileName>dev_bod.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_timr.c</FilePath>
+              <FilePath>.\APP\bsp\dev_bod.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_uart.c</FileName>
+              <FileName>dev_rtc.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_uart.c</FilePath>
+              <FilePath>.\APP\bsp\dev_rtc.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_adc.c</FileName>
+              <FileName>dev_crc.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_adc.c</FilePath>
+              <FilePath>.\APP\Bsp\dev_crc.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_dma.c</FileName>
+              <FileName>dev_uart.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dma.c</FilePath>
+              <FilePath>.\APP\bsp\dev_uart.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_i2c.c</FileName>
+              <FileName>dev_sfc.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_i2c.c</FilePath>
+              <FilePath>.\APP\bsp\dev_sfc.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_pwm.c</FileName>
+              <FileName>dev_sdram.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_pwm.c</FilePath>
+              <FilePath>.\APP\bsp\dev_sdram.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_can.c</FileName>
+              <FileName>dev_sdio.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_can.c</FilePath>
+              <FilePath>.\APP\bsp\dev_sdio.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_spi.c</FileName>
+              <FileName>dev_dac.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_spi.c</FilePath>
+              <FilePath>.\APP\bsp\dev_dac.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_lcd.c</FileName>
+              <FileName>dev_lcd.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_lcd.c</FilePath>
+              <FilePath>.\APP\bsp\dev_lcd.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_flash.c</FileName>
+              <FileName>dev_sleep_stop.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_flash.c</FilePath>
+              <FilePath>.\APP\Bsp\dev_sleep_stop.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_crc.c</FileName>
+              <FileName>dev_io.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Bsp\dev_io.h</FilePath>
+            </File>
+            <File>
+              <FileName>dev_io_spi.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_crc.c</FilePath>
+              <FilePath>.\APP\Bsp\dev_io_spi.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_rtc.c</FileName>
+              <FileName>dev_io_i2c.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_rtc.c</FilePath>
+              <FilePath>.\APP\Bsp\dev_io_i2c.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_wdt.c</FileName>
+              <FileName>dev_can.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_wdt.c</FilePath>
+              <FilePath>.\APP\BSP\dev_can.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>IC_Driver</GroupName>
+          <Files>
+            <File>
+              <FileName>documents.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\IC_Driver\documents.txt</FilePath>
             </File>
             <File>
-              <FileName>SWM341_cordic.c</FileName>
+              <FileName>SPI_WB25Qxx.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_cordic.c</FilePath>
+              <FilePath>.\APP\IC_Driver\SPI_WB25Qxx.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
             </File>
             <File>
-              <FileName>SWM341_sleep.c</FileName>
+              <FileName>lcd_st7789.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sleep.c</FilePath>
+              <FilePath>.\APP\IC_Driver\lcd_st7789.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_usbd.c</FileName>
+              <FileName>SPI_GD25Q128.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_usbd.c</FilePath>
+              <FilePath>.\APP\IC_Driver\SPI_GD25Q128.c</FilePath>
             </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Common Module</GroupName>
+          <GroupOption>
+            <CommonProperty>
+              <UseCPPCompiler>0</UseCPPCompiler>
+              <RVCTCodeConst>0</RVCTCodeConst>
+              <RVCTZI>0</RVCTZI>
+              <RVCTOtherData>0</RVCTOtherData>
+              <ModuleSelection>0</ModuleSelection>
+              <IncludeInBuild>0</IncludeInBuild>
+              <AlwaysBuild>2</AlwaysBuild>
+              <GenerateAssemblyFile>2</GenerateAssemblyFile>
+              <AssembleAssemblyFile>2</AssembleAssemblyFile>
+              <PublicsOnly>2</PublicsOnly>
+              <StopOnExitCode>11</StopOnExitCode>
+              <CustomArgument></CustomArgument>
+              <IncludeLibraryModules></IncludeLibraryModules>
+              <ComprImg>1</ComprImg>
+            </CommonProperty>
+            <GroupArmAds>
+              <Cads>
+                <interw>2</interw>
+                <Optim>0</Optim>
+                <oTime>2</oTime>
+                <SplitLS>2</SplitLS>
+                <OneElfS>2</OneElfS>
+                <Strict>2</Strict>
+                <EnumInt>2</EnumInt>
+                <PlainCh>2</PlainCh>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <wLevel>0</wLevel>
+                <uThumb>2</uThumb>
+                <uSurpInc>2</uSurpInc>
+                <uC99>2</uC99>
+                <uGnu>2</uGnu>
+                <useXO>2</useXO>
+                <v6Lang>0</v6Lang>
+                <v6LangP>0</v6LangP>
+                <vShortEn>2</vShortEn>
+                <vShortWch>2</vShortWch>
+                <v6Lto>2</v6Lto>
+                <v6WtE>2</v6WtE>
+                <v6Rtti>2</v6Rtti>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Cads>
+              <Aads>
+                <interw>2</interw>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <thumb>2</thumb>
+                <SplitLS>2</SplitLS>
+                <SwStkChk>2</SwStkChk>
+                <NoWarn>2</NoWarn>
+                <uSurpInc>2</uSurpInc>
+                <useXO>2</useXO>
+                <ClangAsOpt>0</ClangAsOpt>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Aads>
+            </GroupArmAds>
+          </GroupOption>
+          <Files>
             <File>
-              <FileName>SWM341_div.c</FileName>
+              <FileName>documents.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Common Module\documents.txt</FilePath>
+            </File>
+            <File>
+              <FileName>file_table.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_div.c</FilePath>
+              <FilePath>.\APP\Common Module\file_table.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_sdio.c</FileName>
+              <FileName>load_file.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sdio.c</FilePath>
+              <FilePath>.\APP\Common Module\load_file.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_sdram.c</FileName>
+              <FileName>load_mv.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sdram.c</FilePath>
+              <FilePath>.\APP\Common Module\load_mv.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_dac.c</FileName>
+              <FileName>mem_sdram.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dac.c</FilePath>
+              <FilePath>.\APP\Common Module\mem_sdram.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_jpeg.c</FileName>
+              <FileName>FlashDisk.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_jpeg.c</FilePath>
+              <FilePath>.\APP\Common Module\FlashDisk.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>1</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
             </File>
             <File>
-              <FileName>SWM341_dma2d.c</FileName>
+              <FileName>userboot.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dma2d.c</FilePath>
+              <FilePath>.\APP\Common Module\userboot.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_sfc.c</FileName>
+              <FileName>pthread_lock.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Common Module\pthread_lock.h</FilePath>
+            </File>
+            <File>
+              <FileName>posix_fsm.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sfc.c</FilePath>
+              <FilePath>.\APP\Common Module\posix_fsm.c</FilePath>
             </File>
             <File>
-              <FileName>SWM341_usbh.c</FileName>
+              <FileName>log.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_usbh.c</FilePath>
+              <FilePath>.\APP\Common Module\log.c</FilePath>
+            </File>
+            <File>
+              <FileName>board_test.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\board_test.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>USBH\User</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_user.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\USB\Host\usbh_user.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_cdc_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_cdc_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_hid_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_hid_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_msc_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_mtp_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_mtp_conf.h</FilePath>
             </File>
           </Files>
         </Group>
+        <Group>
+          <GroupName>=====芯片支持库=====</GroupName>
+        </Group>
         <Group>
           <GroupName>CSL\CMSIS</GroupName>
           <Files>
           </Files>
         </Group>
         <Group>
-          <GroupName>BSP</GroupName>
+          <GroupName>CSL\StdPD</GroupName>
           <Files>
             <File>
-              <FileName>dev_sdram.c</FileName>
+              <FileName>SWM341_adc.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\APP\BSP\dev_sdram.c</FilePath>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_adc.c</FilePath>
             </File>
             <File>
-              <FileName>dev_sfc.c</FileName>
+              <FileName>SWM341_can.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_can.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_cordic.c</FileName>
               <FileType>1</FileType>
-              <FilePath>.\APP\BSP\dev_sfc.c</FilePath>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_cordic.c</FilePath>
             </File>
-          </Files>
-        </Group>
-      </Groups>
-    </Target>
-  </Targets>
-
-  <RTE>
-    <apis/>
-    <components/>
-    <files/>
-  </RTE>
+            <File>
+              <FileName>SWM341_crc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_crc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dac.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dac.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_div.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_div.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dma.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dma.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_exti.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_exti.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_flash.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_flash.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_gpio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_gpio.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_i2c.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_i2c.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_jpeg.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_jpeg.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_lcd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_lcd.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_port.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_port.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_pwm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_pwm.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sdio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sdio.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sdram.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sdram.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sfc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sfc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sleep.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sleep.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_spi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_spi.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_timr.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_timr.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_uart.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_usbd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_usbd.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_usbh.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_usbh.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_wdt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_wdt.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dma2d.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dma2d.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_qei.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_qei.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_iofilt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_iofilt.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\USBH</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\usbh_core.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_stdreq.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\usbh_stdreq.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\USBH\MSC</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_msc_bot.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_bot.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_core.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_scsi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_scsi.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>======中间件=======</GroupName>
+        </Group>
+        <Group>
+          <GroupName>FATFS</GroupName>
+          <Files>
+            <File>
+              <FileName>00readme.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\FatFs\source\00readme.txt</FilePath>
+            </File>
+            <File>
+              <FileName>diskio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\diskio.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffconf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffconf.h</FilePath>
+            </File>
+            <File>
+              <FileName>ff.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ff.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffsystem.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffsystem.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffunicode.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffunicode.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>shell</GroupName>
+          <GroupOption>
+            <CommonProperty>
+              <UseCPPCompiler>0</UseCPPCompiler>
+              <RVCTCodeConst>0</RVCTCodeConst>
+              <RVCTZI>0</RVCTZI>
+              <RVCTOtherData>0</RVCTOtherData>
+              <ModuleSelection>0</ModuleSelection>
+              <IncludeInBuild>0</IncludeInBuild>
+              <AlwaysBuild>2</AlwaysBuild>
+              <GenerateAssemblyFile>2</GenerateAssemblyFile>
+              <AssembleAssemblyFile>2</AssembleAssemblyFile>
+              <PublicsOnly>2</PublicsOnly>
+              <StopOnExitCode>11</StopOnExitCode>
+              <CustomArgument></CustomArgument>
+              <IncludeLibraryModules></IncludeLibraryModules>
+              <ComprImg>1</ComprImg>
+            </CommonProperty>
+            <GroupArmAds>
+              <Cads>
+                <interw>2</interw>
+                <Optim>0</Optim>
+                <oTime>2</oTime>
+                <SplitLS>2</SplitLS>
+                <OneElfS>2</OneElfS>
+                <Strict>2</Strict>
+                <EnumInt>2</EnumInt>
+                <PlainCh>2</PlainCh>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <wLevel>0</wLevel>
+                <uThumb>2</uThumb>
+                <uSurpInc>2</uSurpInc>
+                <uC99>2</uC99>
+                <uGnu>2</uGnu>
+                <useXO>2</useXO>
+                <v6Lang>0</v6Lang>
+                <v6LangP>0</v6LangP>
+                <vShortEn>2</vShortEn>
+                <vShortWch>2</vShortWch>
+                <v6Lto>2</v6Lto>
+                <v6WtE>2</v6WtE>
+                <v6Rtti>2</v6Rtti>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Cads>
+              <Aads>
+                <interw>2</interw>
+                <Ropi>2</Ropi>
+                <Rwpi>2</Rwpi>
+                <thumb>2</thumb>
+                <SplitLS>2</SplitLS>
+                <SwStkChk>2</SwStkChk>
+                <NoWarn>2</NoWarn>
+                <uSurpInc>2</uSurpInc>
+                <useXO>2</useXO>
+                <ClangAsOpt>0</ClangAsOpt>
+                <VariousControls>
+                  <MiscControls></MiscControls>
+                  <Define></Define>
+                  <Undefine></Undefine>
+                  <IncludePath></IncludePath>
+                </VariousControls>
+              </Aads>
+            </GroupArmAds>
+          </GroupOption>
+          <Files>
+            <File>
+              <FileName>shell.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\shell.c</FilePath>
+            </File>
+            <File>
+              <FileName>chry_shell.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\chry_shell.c</FilePath>
+            </File>
+            <File>
+              <FileName>chry_readline.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\cherryrl\chry_readline.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>bootloader</GroupName>
+          <Files>
+            <File>
+              <FileName>bootloader_ui.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\bootloader_ui.c</FilePath>
+            </File>
+            <File>
+              <FileName>iap.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\iap.c</FilePath>
+            </File>
+            <File>
+              <FileName>ugui.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\ugui.c</FilePath>
+            </File>
+            <File>
+              <FileName>ugui_port.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\ugui_port.c</FilePath>
+            </File>
+            <File>
+              <FileName>ugui_font.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\font\ugui_font.c</FilePath>
+            </File>
+            <File>
+              <FileName>bootloader_main.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\bootloader_main.c</FilePath>
+            </File>
+            <File>
+              <FileName>sflash_test.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\sflash_test.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>littlefs</GroupName>
+          <Files>
+            <File>
+              <FileName>lfs.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\fs\lfs.c</FilePath>
+            </File>
+            <File>
+              <FileName>lfs_port.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\fs\lfs_port.c</FilePath>
+            </File>
+            <File>
+              <FileName>lfs_util.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\fs\lfs_util.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+      </Groups>
+    </Target>
+    <Target>
+      <TargetName>UserBoot</TargetName>
+      <ToolsetNumber>0x4</ToolsetNumber>
+      <ToolsetName>ARM-ADS</ToolsetName>
+      <pCCUsed>6150000::V6.15::ARMCLANG</pCCUsed>
+      <uAC6>1</uAC6>
+      <TargetOption>
+        <TargetCommonOption>
+          <Device>SWM341xE</Device>
+          <Vendor>Synwit</Vendor>
+          <PackID>Synwit.SWM32_DFP.2.1.4</PackID>
+          <PackURL>http://www.synwit.com/pack</PackURL>
+          <Cpu>IRAM(0x20000000,0x10000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M33") FPU3(SFPU) DSP CLOCK(12000000) ELITTLE</Cpu>
+          <FlashUtilSpec></FlashUtilSpec>
+          <StartupFile></StartupFile>
+          <FlashDriverDll>UL2V8M(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0SWM341xE -FS00 -FL080000 -FP0($$Device:SWM341xE$Flash\SWM341xE.FLM))</FlashDriverDll>
+          <DeviceId>0</DeviceId>
+          <RegisterFile>$$Device:SWM341xE$CSL\SWM341\CMSIS\DeviceSupport\SWM341.h</RegisterFile>
+          <MemoryEnv></MemoryEnv>
+          <Cmp></Cmp>
+          <Asm></Asm>
+          <Linker></Linker>
+          <OHString></OHString>
+          <InfinionOptionDll></InfinionOptionDll>
+          <SLE66CMisc></SLE66CMisc>
+          <SLE66AMisc></SLE66AMisc>
+          <SLE66LinkerMisc></SLE66LinkerMisc>
+          <SFDFile>$$Device:SWM341xE$SVD\SWM341.svd</SFDFile>
+          <bCustSvd>0</bCustSvd>
+          <UseEnv>0</UseEnv>
+          <BinPath></BinPath>
+          <IncludePath></IncludePath>
+          <LibPath></LibPath>
+          <RegisterFilePath></RegisterFilePath>
+          <DBRegisterFilePath></DBRegisterFilePath>
+          <TargetStatus>
+            <Error>0</Error>
+            <ExitCodeStop>0</ExitCodeStop>
+            <ButtonStop>0</ButtonStop>
+            <NotGenerated>0</NotGenerated>
+            <InvalidFlash>1</InvalidFlash>
+          </TargetStatus>
+          <OutputDirectory>.\out\UserBoot\</OutputDirectory>
+          <OutputName>UserBoot</OutputName>
+          <CreateExecutable>1</CreateExecutable>
+          <CreateLib>0</CreateLib>
+          <CreateHexFile>0</CreateHexFile>
+          <DebugInformation>1</DebugInformation>
+          <BrowseInformation>1</BrowseInformation>
+          <ListingPath>.\out\</ListingPath>
+          <HexFormatSelection>1</HexFormatSelection>
+          <Merge32K>0</Merge32K>
+          <CreateBatchFile>0</CreateBatchFile>
+          <BeforeCompile>
+            <RunUserProg1>0</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name></UserProg1Name>
+            <UserProg2Name></UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopU1X>0</nStopU1X>
+            <nStopU2X>0</nStopU2X>
+          </BeforeCompile>
+          <BeforeMake>
+            <RunUserProg1>0</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name></UserProg1Name>
+            <UserProg2Name></UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopB1X>0</nStopB1X>
+            <nStopB2X>0</nStopB2X>
+          </BeforeMake>
+          <AfterMake>
+            <RunUserProg1>1</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name>fromelf --bin -o "$L@L.bin" "#L"</UserProg1Name>
+            <UserProg2Name>fromelf --text -a -c -o "$L@L.asm" "#L"</UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopA1X>0</nStopA1X>
+            <nStopA2X>0</nStopA2X>
+          </AfterMake>
+          <SelectedForBatchBuild>0</SelectedForBatchBuild>
+          <SVCSIdString></SVCSIdString>
+        </TargetCommonOption>
+        <CommonProperty>
+          <UseCPPCompiler>0</UseCPPCompiler>
+          <RVCTCodeConst>0</RVCTCodeConst>
+          <RVCTZI>0</RVCTZI>
+          <RVCTOtherData>0</RVCTOtherData>
+          <ModuleSelection>0</ModuleSelection>
+          <IncludeInBuild>1</IncludeInBuild>
+          <AlwaysBuild>0</AlwaysBuild>
+          <GenerateAssemblyFile>0</GenerateAssemblyFile>
+          <AssembleAssemblyFile>0</AssembleAssemblyFile>
+          <PublicsOnly>0</PublicsOnly>
+          <StopOnExitCode>3</StopOnExitCode>
+          <CustomArgument></CustomArgument>
+          <IncludeLibraryModules></IncludeLibraryModules>
+          <ComprImg>1</ComprImg>
+        </CommonProperty>
+        <DllOption>
+          <SimDllName></SimDllName>
+          <SimDllArguments></SimDllArguments>
+          <SimDlgDll></SimDlgDll>
+          <SimDlgDllArguments></SimDlgDllArguments>
+          <TargetDllName>SARMV8M.DLL</TargetDllName>
+          <TargetDllArguments></TargetDllArguments>
+          <TargetDlgDll>TCM.DLL</TargetDlgDll>
+          <TargetDlgDllArguments>-pCM33</TargetDlgDllArguments>
+        </DllOption>
+        <DebugOption>
+          <OPTHX>
+            <HexSelection>1</HexSelection>
+            <HexRangeLowAddress>0</HexRangeLowAddress>
+            <HexRangeHighAddress>0</HexRangeHighAddress>
+            <HexOffset>0</HexOffset>
+            <Oh166RecLen>16</Oh166RecLen>
+          </OPTHX>
+        </DebugOption>
+        <Utilities>
+          <Flash1>
+            <UseTargetDll>1</UseTargetDll>
+            <UseExternalTool>0</UseExternalTool>
+            <RunIndependent>0</RunIndependent>
+            <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
+            <Capability>1</Capability>
+            <DriverSelection>4102</DriverSelection>
+          </Flash1>
+          <bUseTDR>1</bUseTDR>
+          <Flash2>BIN\UL2V8M.DLL</Flash2>
+          <Flash3>"" ()</Flash3>
+          <Flash4></Flash4>
+          <pFcarmOut></pFcarmOut>
+          <pFcarmGrp></pFcarmGrp>
+          <pFcArmRoot></pFcArmRoot>
+          <FcArmLst>0</FcArmLst>
+        </Utilities>
+        <TargetArmAds>
+          <ArmAdsMisc>
+            <GenerateListings>0</GenerateListings>
+            <asHll>1</asHll>
+            <asAsm>1</asAsm>
+            <asMacX>1</asMacX>
+            <asSyms>1</asSyms>
+            <asFals>1</asFals>
+            <asDbgD>1</asDbgD>
+            <asForm>1</asForm>
+            <ldLst>0</ldLst>
+            <ldmm>1</ldmm>
+            <ldXref>1</ldXref>
+            <BigEnd>0</BigEnd>
+            <AdsALst>1</AdsALst>
+            <AdsACrf>1</AdsACrf>
+            <AdsANop>0</AdsANop>
+            <AdsANot>0</AdsANot>
+            <AdsLLst>1</AdsLLst>
+            <AdsLmap>1</AdsLmap>
+            <AdsLcgr>1</AdsLcgr>
+            <AdsLsym>1</AdsLsym>
+            <AdsLszi>1</AdsLszi>
+            <AdsLtoi>1</AdsLtoi>
+            <AdsLsun>1</AdsLsun>
+            <AdsLven>1</AdsLven>
+            <AdsLsxf>1</AdsLsxf>
+            <RvctClst>0</RvctClst>
+            <GenPPlst>0</GenPPlst>
+            <AdsCpuType>"Cortex-M33"</AdsCpuType>
+            <RvctDeviceName></RvctDeviceName>
+            <mOS>0</mOS>
+            <uocRom>0</uocRom>
+            <uocRam>0</uocRam>
+            <hadIROM>1</hadIROM>
+            <hadIRAM>1</hadIRAM>
+            <hadXRAM>0</hadXRAM>
+            <uocXRam>0</uocXRam>
+            <RvdsVP>2</RvdsVP>
+            <RvdsMve>0</RvdsMve>
+            <RvdsCdeCp>0</RvdsCdeCp>
+            <nBranchProt>0</nBranchProt>
+            <hadIRAM2>0</hadIRAM2>
+            <hadIROM2>0</hadIROM2>
+            <StupSel>8</StupSel>
+            <useUlib>0</useUlib>
+            <EndSel>0</EndSel>
+            <uLtcg>0</uLtcg>
+            <nSecure>0</nSecure>
+            <RoSelD>3</RoSelD>
+            <RwSelD>3</RwSelD>
+            <CodeSel>0</CodeSel>
+            <OptFeed>0</OptFeed>
+            <NoZi1>0</NoZi1>
+            <NoZi2>0</NoZi2>
+            <NoZi3>0</NoZi3>
+            <NoZi4>0</NoZi4>
+            <NoZi5>0</NoZi5>
+            <Ro1Chk>0</Ro1Chk>
+            <Ro2Chk>0</Ro2Chk>
+            <Ro3Chk>0</Ro3Chk>
+            <Ir1Chk>1</Ir1Chk>
+            <Ir2Chk>0</Ir2Chk>
+            <Ra1Chk>0</Ra1Chk>
+            <Ra2Chk>0</Ra2Chk>
+            <Ra3Chk>0</Ra3Chk>
+            <Im1Chk>1</Im1Chk>
+            <Im2Chk>0</Im2Chk>
+            <OnChipMemories>
+              <Ocm1>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm1>
+              <Ocm2>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm2>
+              <Ocm3>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm3>
+              <Ocm4>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm4>
+              <Ocm5>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm5>
+              <Ocm6>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm6>
+              <IRAM>
+                <Type>0</Type>
+                <StartAddress>0x20000000</StartAddress>
+                <Size>0x10000</Size>
+              </IRAM>
+              <IROM>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x80000</Size>
+              </IROM>
+              <XRAM>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </XRAM>
+              <OCR_RVCT1>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT1>
+              <OCR_RVCT2>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT2>
+              <OCR_RVCT3>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT3>
+              <OCR_RVCT4>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x10000</Size>
+              </OCR_RVCT4>
+              <OCR_RVCT5>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT5>
+              <OCR_RVCT6>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT6>
+              <OCR_RVCT7>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT7>
+              <OCR_RVCT8>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT8>
+              <OCR_RVCT9>
+                <Type>0</Type>
+                <StartAddress>0x20000000</StartAddress>
+                <Size>0x10000</Size>
+              </OCR_RVCT9>
+              <OCR_RVCT10>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT10>
+            </OnChipMemories>
+            <RvctStartVector></RvctStartVector>
+          </ArmAdsMisc>
+          <Cads>
+            <interw>1</interw>
+            <Optim>2</Optim>
+            <oTime>0</oTime>
+            <SplitLS>0</SplitLS>
+            <OneElfS>1</OneElfS>
+            <Strict>0</Strict>
+            <EnumInt>0</EnumInt>
+            <PlainCh>0</PlainCh>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <wLevel>3</wLevel>
+            <uThumb>0</uThumb>
+            <uSurpInc>0</uSurpInc>
+            <uC99>0</uC99>
+            <uGnu>0</uGnu>
+            <useXO>0</useXO>
+            <v6Lang>3</v6Lang>
+            <v6LangP>3</v6LangP>
+            <vShortEn>1</vShortEn>
+            <vShortWch>1</vShortWch>
+            <v6Lto>0</v6Lto>
+            <v6WtE>0</v6WtE>
+            <v6Rtti>0</v6Rtti>
+            <VariousControls>
+              <MiscControls>-Wno-invalid-source-encoding</MiscControls>
+              <Define>__TARGET_CONST__=0xFF,</Define>
+              <Undefine></Undefine>
+              <IncludePath>.\CSL\CMSIS\CoreSupport;.\CSL\CMSIS\DeviceSupport;.\CSL\SWM341_StdPeriph_Driver;.\CSL\SWM341_UsbHost_Lib;.\CSL\SWM341_UsbHost_Lib\CDC;.\CSL\SWM341_UsbHost_Lib\HID;.\CSL\SWM341_UsbHost_Lib\MSC;.\CSL\SWM341_UsbHost_Lib\MTP;.\Middleware\FatFs\source;.\Middleware\lvgl;.\Middleware\lvgl\lvgl;.\Middleware\lvgl\lvgl\src;.\Middleware\lvgl\lvgl\src\lv_core;.\Middleware\lvgl\lvgl\src\lv_draw;.\Middleware\lvgl\lvgl\src\lv_font;.\Middleware\lvgl\lvgl\src\lv_gpu;.\Middleware\lvgl\lvgl\src\lv_hal;.\Middleware\lvgl\lvgl\src\lv_misc;.\Middleware\lvgl\lvgl\src\lv_themes;.\Middleware\lvgl\lvgl\src\lv_widgets;.\Middleware\lvgl\lvgl\examples\porting;.\Middleware\lvgl\lv_examples;.\Middleware\lvgl\lv_examples\src;.\Middleware\lvgl\lv_examples\src\lv_demo_widgets;.\Middleware\lvgl\lv_examples\src\lv_demo_benchmark;.\Middleware\lvgl\lv_examples\src\lv_demo_stress;.\Middleware\lvgl\lv_examples\src\lv_demo_music;.\APP;.\APP\can_comm;.\APP\BSP;.\APP\IC_Driver;.\APP\Common Module;.\APP\Software_Parser;.\APP\USB\Device;.\APP\USB\Host;.\APP\UI;.\APP\UI\Resource;.\APP\UI\Page</IncludePath>
+            </VariousControls>
+          </Cads>
+          <Aads>
+            <interw>1</interw>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <thumb>0</thumb>
+            <SplitLS>0</SplitLS>
+            <SwStkChk>0</SwStkChk>
+            <NoWarn>0</NoWarn>
+            <uSurpInc>0</uSurpInc>
+            <useXO>0</useXO>
+            <ClangAsOpt>1</ClangAsOpt>
+            <VariousControls>
+              <MiscControls></MiscControls>
+              <Define></Define>
+              <Undefine></Undefine>
+              <IncludePath></IncludePath>
+            </VariousControls>
+          </Aads>
+          <LDads>
+            <umfTarg>1</umfTarg>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <noStLib>0</noStLib>
+            <RepFail>1</RepFail>
+            <useFile>0</useFile>
+            <TextAddressRange>0x00000000</TextAddressRange>
+            <DataAddressRange>0x00000000</DataAddressRange>
+            <pXoBase></pXoBase>
+            <ScatterFile>.\Linker Scatter File\SWM34S_Nonuse_SFC.sct</ScatterFile>
+            <IncludeLibs></IncludeLibs>
+            <IncludeLibsPath></IncludeLibsPath>
+            <Misc></Misc>
+            <LinkerInputFile></LinkerInputFile>
+            <DisabledWarnings></DisabledWarnings>
+          </LDads>
+        </TargetArmAds>
+      </TargetOption>
+      <Groups>
+        <Group>
+          <GroupName>Readme</GroupName>
+          <Files>
+            <File>
+              <FileName>readme.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\readme.txt</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Config(必看)</GroupName>
+          <Files>
+            <File>
+              <FileName>version.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\version.h</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>APP</GroupName>
+          <Files>
+            <File>
+              <FileName>main.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\app\main.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_app.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_app.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_usb.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_usb.c</FilePath>
+            </File>
+            <File>
+              <FileName>user_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\user_rtc.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>BSP</GroupName>
+          <Files>
+            <File>
+              <FileName>irq_handler.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\irq_handler.c</FilePath>
+            </File>
+            <File>
+              <FileName>bsp_init.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\bsp_init.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_systick.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_systick.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_bod.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_bod.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_crc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_crc.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_uart.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sfc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_sfc.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sdram.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_sdram.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sdio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_sdio.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_dac.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_dac.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_lcd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bsp\dev_lcd.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_sleep_stop.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_sleep_stop.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_io.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Bsp\dev_io.h</FilePath>
+            </File>
+            <File>
+              <FileName>dev_io_spi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_io_spi.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_io_i2c.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Bsp\dev_io_i2c.c</FilePath>
+            </File>
+            <File>
+              <FileName>dev_can.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\BSP\dev_can.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>IC_Driver</GroupName>
+          <Files>
+            <File>
+              <FileName>documents.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\IC_Driver\documents.txt</FilePath>
+            </File>
+            <File>
+              <FileName>SPI_WB25Qxx.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\SPI_WB25Qxx.c</FilePath>
+            </File>
+            <File>
+              <FileName>lcd_st7789.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\lcd_st7789.c</FilePath>
+            </File>
+            <File>
+              <FileName>SPI_GD25Q128.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\IC_Driver\SPI_GD25Q128.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Common Module</GroupName>
+          <Files>
+            <File>
+              <FileName>documents.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Common Module\documents.txt</FilePath>
+            </File>
+            <File>
+              <FileName>file_table.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\file_table.c</FilePath>
+            </File>
+            <File>
+              <FileName>load_file.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\load_file.c</FilePath>
+            </File>
+            <File>
+              <FileName>load_mv.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\load_mv.c</FilePath>
+            </File>
+            <File>
+              <FileName>mem_sdram.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\mem_sdram.c</FilePath>
+            </File>
+            <File>
+              <FileName>FlashDisk.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\FlashDisk.c</FilePath>
+            </File>
+            <File>
+              <FileName>userboot.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\userboot.c</FilePath>
+            </File>
+            <File>
+              <FileName>pthread_lock.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\Common Module\pthread_lock.h</FilePath>
+            </File>
+            <File>
+              <FileName>posix_fsm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\posix_fsm.c</FilePath>
+            </File>
+            <File>
+              <FileName>log.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\log.c</FilePath>
+            </File>
+            <File>
+              <FileName>board_test.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\Common Module\board_test.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>USBH\User</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_user.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\USB\Host\usbh_user.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_cdc_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_cdc_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_hid_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_hid_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_msc_conf.h</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_mtp_conf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\APP\USB\Host\usbh_mtp_conf.h</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>=====芯片支持库=====</GroupName>
+        </Group>
+        <Group>
+          <GroupName>CSL\CMSIS</GroupName>
+          <Files>
+            <File>
+              <FileName>system_SWM341.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\CMSIS\DeviceSupport\system_SWM341.c</FilePath>
+            </File>
+            <File>
+              <FileName>startup_SWM341.s</FileName>
+              <FileType>2</FileType>
+              <FilePath>.\CSL\CMSIS\DeviceSupport\startup\arm\startup_SWM341.s</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\StdPD</GroupName>
+          <Files>
+            <File>
+              <FileName>SWM341_adc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_adc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_can.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_can.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_cordic.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_cordic.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_crc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_crc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dac.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dac.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_div.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_div.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dma.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dma.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_exti.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_exti.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_flash.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_flash.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_gpio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_gpio.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_i2c.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_i2c.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_jpeg.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_jpeg.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_lcd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_lcd.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_port.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_port.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_pwm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_pwm.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sdio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sdio.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sdram.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sdram.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sfc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sfc.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_sleep.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_sleep.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_spi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_spi.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_timr.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_timr.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_uart.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_usbd.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_usbd.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_usbh.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_usbh.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_wdt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_wdt.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_dma2d.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_dma2d.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_qei.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_qei.c</FilePath>
+            </File>
+            <File>
+              <FileName>SWM341_iofilt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_StdPeriph_Driver\SWM341_iofilt.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\USBH</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\usbh_core.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_stdreq.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\usbh_stdreq.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>CSL\USBH\MSC</GroupName>
+          <Files>
+            <File>
+              <FileName>usbh_msc_bot.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_bot.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_core.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbh_msc_scsi.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\CSL\SWM341_UsbHost_Lib\MSC\usbh_msc_scsi.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>======中间件=======</GroupName>
+        </Group>
+        <Group>
+          <GroupName>FATFS</GroupName>
+          <Files>
+            <File>
+              <FileName>00readme.txt</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\FatFs\source\00readme.txt</FilePath>
+            </File>
+            <File>
+              <FileName>diskio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\diskio.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffconf.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffconf.h</FilePath>
+            </File>
+            <File>
+              <FileName>ff.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ff.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffsystem.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffsystem.c</FilePath>
+            </File>
+            <File>
+              <FileName>ffunicode.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\Middleware\FatFs\source\ffunicode.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>shell</GroupName>
+          <Files>
+            <File>
+              <FileName>shell.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\shell.c</FilePath>
+            </File>
+            <File>
+              <FileName>chry_shell.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\chry_shell.c</FilePath>
+            </File>
+            <File>
+              <FileName>chry_readline.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\shell\cherryrl\chry_readline.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>bootloader</GroupName>
+          <Files>
+            <File>
+              <FileName>bootloader_ui.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\bootloader_ui.c</FilePath>
+            </File>
+            <File>
+              <FileName>iap.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\iap.c</FilePath>
+            </File>
+            <File>
+              <FileName>ugui.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\ugui.c</FilePath>
+            </File>
+            <File>
+              <FileName>ugui_port.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\ugui_port.c</FilePath>
+            </File>
+            <File>
+              <FileName>ugui_font.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\font\ugui_font.c</FilePath>
+            </File>
+            <File>
+              <FileName>bootloader_main.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\bootloader_main.c</FilePath>
+            </File>
+            <File>
+              <FileName>sflash_test.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\bootloader\sflash_test.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>littlefs</GroupName>
+          <Files>
+            <File>
+              <FileName>lfs.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\fs\lfs.c</FilePath>
+            </File>
+            <File>
+              <FileName>lfs_port.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\fs\lfs_port.c</FilePath>
+            </File>
+            <File>
+              <FileName>lfs_util.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>.\APP\fs\lfs_util.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+      </Groups>
+    </Target>
+  </Targets>
+
+  <RTE>
+    <apis/>
+    <components/>
+    <files>
+      <file attr="config" category="header" name="Config\EventRecorderConf.h" version="1.1.0">
+        <instance index="0" removed="1">RTE\Compiler\EventRecorderConf.h</instance>
+        <component Cbundle="ARM Compiler" Cclass="Compiler" Cgroup="Event Recorder" Cvariant="DAP" Cvendor="Keil" Cversion="1.4.0" condition="Cortex-M Device"/>
+        <package name="ARM_Compiler" schemaVersion="1.6.3" url="http://www.keil.com/pack/" vendor="Keil" version="1.6.3"/>
+        <targetInfos/>
+      </file>
+      <file attr="config" category="source" condition="Compiler ARM" name="CSL\SWM341\CMSIS\DeviceSupport\startup\arm\startup_SWM341.s" version="1.6.0">
+        <instance index="0" removed="1">RTE\Device\SWM341xE\startup_SWM341.s</instance>
+        <component Cclass="Device" Cgroup="Startup" Cvendor="Synwit" Cversion="1.6.0" condition="SWM341 Series"/>
+        <package name="SWM32_DFP" schemaVersion="1.2" url="http://www.synwit.com/pack" vendor="Synwit" version="1.21.0"/>
+        <targetInfos/>
+      </file>
+      <file attr="config" category="source" name="CSL\SWM341\CMSIS\DeviceSupport\system_SWM341.c" version="1.6.0">
+        <instance index="0" removed="1">RTE\Device\SWM341xE\system_SWM341.c</instance>
+        <component Cclass="Device" Cgroup="Startup" Cvendor="Synwit" Cversion="1.6.0" condition="SWM341 Series"/>
+        <package name="SWM32_DFP" schemaVersion="1.2" url="http://www.synwit.com/pack" vendor="Synwit" version="1.21.0"/>
+        <targetInfos/>
+      </file>
+      <file attr="config" category="header" name="RTE\configs\mbedTLS_config.h" version="2.28.0">
+        <instance index="0" removed="1">RTE\Security\mbedTLS_config.h</instance>
+        <component Cclass="Security" Cgroup="mbed TLS" Cvendor="ARM" Cversion="3.1.0"/>
+        <package name="mbedTLS" schemaVersion="1.6.3" url="https://www.keil.com/pack/" vendor="ARM" version="3.1.0"/>
+        <targetInfos/>
+      </file>
+      <file attr="config" category="header" name="RTE\configs\mbedTLS_crypto_config.h" version="2.28.0">
+        <instance index="0" removed="1">RTE\Security\mbedTLS_crypto_config.h</instance>
+        <component Cclass="Security" Cgroup="mbed TLS" Cvendor="ARM" Cversion="3.1.0"/>
+        <package name="mbedTLS" schemaVersion="1.6.3" url="https://www.keil.com/pack/" vendor="ARM" version="3.1.0"/>
+        <targetInfos/>
+      </file>
+    </files>
+  </RTE>
+
+  <LayerInfo>
+    <Layers>
+      <Layer>
+        <LayName>SWM341_StdPeriph_Driver</LayName>
+        <LayPrjMark>1</LayPrjMark>
+      </Layer>
+    </Layers>
+  </LayerInfo>
 
 </Project>
diff --git a/tools/fwpack.py b/tools/fwpack.py
new file mode 100644 (file)
index 0000000..4bf84ac
--- /dev/null
@@ -0,0 +1,185 @@
+#!/usr/bin/env python3
+"""
+fwpack.py - 固件打包工具 (bootloader 升级固件生成)
+
+功能:
+ 1) 读取 Keil 编译生成的 APP bin (默认 out\\dispboard_app\\dispboard.bin),
+    得到原始固件字节;
+ 2) 从 bin 内向量表后 0x400 偏移的 FW_INFO 区解析版本号 (FW_VER[4] = 主/次/修订/构建);
+ 3) 在原始固件前拼接 16 字节固件头 (格式与 IAP 升级解析代码一致),生成下载升级用固件 bin;
+ 4) 将合并后的固件 bin 转换为 Intel HEX,起始地址 0xA0000000 (用于 Keil 写外置
+    SPI Flash 的编程算法地址映射)。
+
+固件头 16 字节定义 (参考 APP/user_iap.h 与 APP/bootloader/iap.c):
+   Byte0~5  : 项目名    'BDM120'
+   Byte6    : 板子ID    当前工程为液晶板 = 1
+   Byte7~10 : 版本号    V<ver0>.<ver1>.<ver2>.<ver3>
+   Byte11~13: 固件长度  单位字节,大端 (不含 16 字节头)
+   Byte14~15: 固件CRC   多项式 0x1021 (CCITT),大端
+
+用法示例:
+   fwpack.exe --in out\\dispboard_app\\dispboard.bin \\
+              --out out\\dispboard_app\\dispboard_fw.bin \\
+              --hex  out\\dispboard_app\\dispboard_fw.hex \\
+              --base 0xA0000000
+
+PyInstaller 打包 exe (仅用标准库,可 -F 单文件):
+   pyinstaller -F -n fwpack fwpack.py
+"""
+
+import os
+import sys
+import argparse
+import struct
+
+
+PROJ_NAME = b"BDM120"      # 项目名 6 字节
+BOARD_LCD = 1              # 板子ID: 液晶板
+HDR_LEN = 16               # 固件头长度
+PCRC_POLY = 0x1021         # CRC-CCITT 多项式
+
+FW_INFO_OFF = 0x400        # 固件信息区在镜像内偏移
+MAGIC_APP = 0x00505041     # 'APP\0'
+MAGIC_BOOT = 0x544F4F42    # 'BOOT'
+
+
+def crc16_ccitt(data):
+    """CRC-16/CCITT: poly 0x1021, init 0, MSB 先行, 无最终异或 (与 iap 一致)"""
+    crc = 0
+    for b in data:
+        crc ^= b << 8
+        for _ in range(8):
+            if crc & 0x8000:
+                crc = ((crc << 1) ^ PCRC_POLY) & 0xFFFF
+            else:
+                crc = (crc << 1) & 0xFFFF
+    return crc
+
+
+def u32(buf, off):
+    return struct.unpack_from("<I", buf, off)[0]
+
+
+def read_version(app):
+    """依 startup 的 FW_INFO 布局解析版本号。
+
+    读取 bin 内偏移 0x400 的 FW_INFO:
+      +0x0C : magic ('APP\\0' / 'BOOT')
+      +0x04 : DCD FW_VER     -> FW_VER 数组的加载地址
+      +0x08 : Region Table Base
+      +0x0C : Region Table Limit
+      +0x10 : DCD __Vectors  -> 向量表地址(镜像基址)
+    版本偏移 = FW_VER加载地址 - __Vectors 地址。
+    返回 (tag, ver, raw), raw=(fw_ptr, vectors, off, img_len)。
+    """
+    ver = None
+    raw = (None, None, None, len(app))
+    if len(app) >= FW_INFO_OFF + 20:
+        magic = u32(app, FW_INFO_OFF)
+        if magic == MAGIC_APP:
+            tag = "APP"
+        elif magic == MAGIC_BOOT:
+            tag = "BOOT"
+        else:
+            tag = "NONE"
+        fw_ptr = u32(app, FW_INFO_OFF + 4)
+        vectors = u32(app, FW_INFO_OFF + 0x10)
+        off = fw_ptr - vectors
+        raw = (fw_ptr, vectors, off, len(app))
+        if 0 <= off and off + 4 <= len(app):
+            ver = list(app[off:off + 4])
+    else:
+        tag = "NONE"
+    return tag, ver, raw
+
+
+def make_header(proj, board, version, size, crc):
+    h = bytearray(HDR_LEN)
+    h[0:6] = proj[:6]
+    h[6] = board & 0xFF
+    h[7:11] = bytes(version[:4])
+    h[11:14] = size.to_bytes(3, "big")
+    h[14:16] = crc.to_bytes(2, "big")
+    return bytes(h)
+
+
+def hex_line(rec_type, addr, data):
+    n = len(data)
+    rec = struct.pack(">BHB", n, addr & 0xFFFF, rec_type) + bytes(data)
+    csum = sum(rec) & 0xFF
+    rec += struct.pack(">B", (~csum + 1) & 0xFF)
+    return ":" + rec.hex().upper()
+
+
+def bin_to_hex(data, base):
+    """data 以 base 为起始地址转换为 Intel HEX (含 LA=04 记录跨 64K 边界)"""
+    lines = []
+    i = 0
+    cur_la = None
+    n = len(data)
+    while i < n:
+        addr = base + i
+        la = (addr >> 16) & 0xFFFF
+        if la != cur_la:
+            lines.append(hex_line(0x04, 0, [(la >> 8) & 0xFF, la & 0xFF]))
+            cur_la = la
+        space = 0x10000 - (addr & 0xFFFF)
+        cnt = min(16, space, n - i)
+        lines.append(hex_line(0x00, addr & 0xFFFF, data[i:i + cnt]))
+        i += cnt
+    lines.append(":00000001FF")
+    return "\r\n".join(lines) + "\r\n"
+
+
+def main(argv=None):
+    ap = argparse.ArgumentParser(description="Bootloader 升级固件打包工具")
+    ap.add_argument("--in", dest="inp", default=r"out\dispboard_app\dispboard.bin")
+    ap.add_argument("--out", dest="outp", default=r"out\dispboard_app\dispboard_fw.bin")
+    ap.add_argument("--hex", dest="hexp", default=r"out\dispboard_app\dispboard_fw.hex")
+    ap.add_argument("--base", default="0xA0000000", help="HEX 起始地址")
+    ap.add_argument("--proj", default=PROJ_NAME.decode(), help="项目名(6字节)")
+    ap.add_argument("--board", type=int, default=BOARD_LCD, help="板子ID")
+    args = ap.parse_args(argv)
+
+    base = int(args.base, 0)
+    in_path = os.path.abspath(args.inp)
+
+    if not os.path.isfile(in_path):
+        print(f"[fwpack] ERROR: 输入 bin 不存在: {in_path}")
+        return 1
+
+    with open(in_path, "rb") as f:
+        app = f.read()
+
+    tag, ver, raw = read_version(app)
+    if ver is None:
+        ver = [0, 0, 0, 0]
+        fw_ptr, vectors, off, img = raw
+        print(f"[fwpack] WARNING: 未能从 bin 解析版本号 (magic={tag})")
+        if fw_ptr is not None:
+            print(f"[fwpack]   fw_ptr=0x{fw_ptr:08X} vectors=0x{vectors:08X} offset=0x{off:X} 镜像长度=0x{img:X}")
+    else:
+        print(f"[fwpack] 解析到 {tag} 版本 V{ver[0]}.{ver[1]}.{ver[2]}.{ver[3]}")
+
+    fw_size = len(app)
+    fw_crc = crc16_ccitt(app)
+    header = make_header(args.proj.encode(), args.board, ver, fw_size, fw_crc)
+
+    ota = header + app
+    if len(ota) > 0xFFFFFF + HDR_LEN:
+        print("[fwpack] ERROR: 固件长度超过 16MB, 超出 3 字节长度字段")
+        return 1
+
+    with open(os.path.abspath(args.outp), "wb") as f:
+        f.write(ota)
+    with open(os.path.abspath(args.hexp), "w") as f:
+        f.write(bin_to_hex(ota, base))
+
+    print(f"[fwpack] 原始固件:    {len(app)} 字节  CRC={fw_crc:04X}")
+    print(f"[fwpack] 升级固件 bin: {os.path.abspath(args.outp)} ({len(ota)} 字节)")
+    print(f"[fwpack] HEX (base=0x{base:08X}): {os.path.abspath(args.hexp)}")
+    return 0
+
+
+if __name__ == "__main__":
+    sys.exit(main())
\ No newline at end of file
diff --git a/tools/使用方法.md b/tools/使用方法.md
new file mode 100644 (file)
index 0000000..2ead24c
--- /dev/null
@@ -0,0 +1,80 @@
+# fwpack 固件打包工具——使用方法
+
+## 1. 工具说明
+
+脚本位于 `tools/fwpack.py`,纯标准库实现(无需第三方依赖),通过 PyInstaller 打包为 exe 后被 Keil 编译后流程调用。
+
+它在 Keil 编译完成后自动完成:
+
+- 解析 `out/` 目录编译出的 bin(默认 `out\dispboard_app\dispboard.bin`)
+- 生成 16 字节固件头
+- 合并到原固件前,生成下载升级用固件 bin(`dispboard_fw.bin`)
+- 再把合并后的固件转成 Intel HEX,起始地址 `0xA0000000`(用于 Keil 写外置 SPI Flash 的编程算法地址映射)
+
+## 2. 命令行用法
+
+```text
+fwpack.exe --in out\dispboard_app\dispboard.bin --out dispboard_fw.bin --hex dispboard_fw.hex --base 0xA0000000
+```
+
+参数说明:
+
+| 参数 | 默认值 | 说明 |
+| --- | --- | --- |
+| `--in` | `out\dispboard_app\dispboard.bin` | 输入 APP bin |
+| `--out` | 同目录 `dispboard_fw.bin` | 输出升级固件 bin(带 16 字节头) |
+| `--hex` | 同目录 `dispboard_fw.hex` | 输出 HEX(base=0xA0000000) |
+| `--base` | `0xA0000000` | HEX 起始地址 |
+| `--proj` | `BDM120` | 项目名(6 字节) |
+| `--board` | `1` | 板子ID(0保护 / 1液晶 / 2增强) |
+
+## 3. Keil 编译后调用(已配置)
+
+已修改 `dispboard_app.uvprojx` 的 AfterMake UserProg1,在原有 fromelf 转 hex 之后追加一行调用 exe:
+
+```text
+fromelf --i32combined -o "$L@L.hex" "#L"
+"$Ptools\fwpack.exe" --in "$L@L.bin" --out "$L@L_fw.bin" --hex "$L@L_fw.hex" --base 0xA0000000
+```
+
+- `$P` = 工程目录
+- `$L@L.bin` = 输出 bin(`out\dispboard_app\dispboard.bin`)
+
+编译完成后即自动生成:
+
+- `out\dispboard_app\dispboard_fw.bin`:下载升级用固件 bin
+- `out\dispboard_app\dispboard_fw.hex`:起始地址 0xA0000000 的 hex
+
+## 4. 打包成 exe
+
+在 `tools\` 目录下执行:
+
+```text
+pyinstaller -F -n fwpack fwpack.py
+```
+
+生成 `dist\fwpack.exe`,拷贝到 `tools\` 即可被 Keil 调用。
+
+## 5. 固件头 16 字节格式
+
+参考 `APP/user_iap.h` 与 `APP/bootloader/iap.c`:
+
+- Byte0~5:项目名 `BDM120`
+- Byte6:板子ID = 1(液晶板)
+- Byte7~10:版本号 V主.次.修订.构建
+- Byte11~13:固件长度,单位字节,大端(不含 16 字节头)
+- Byte14~15:固件 CRC,多项式 0x1021(CCITT),大端
+
+## 6. 版本号解析
+
+版本号从 bin 的 FW_INFO 区解析(参考 `CSL/.../startup_SWM341.s` 中 `FW_INFO_ADDR` 布局,位于镜像偏移 0x400):
+
+- 偏移 +0:magic `0x00505041`('APP\0'),用于判断是 APP
+- 偏移 +4:`FW_VER` 地址指针
+- 偏移 +0x10:`__Vectors` 地址
+- 换算 `offset = FW_VER - __Vectors` 得到版本号在文件中的位置,读取 [主,次,修订,构建] 4 字节
+
+## 7. 注意事项
+
+- 当前终端环境无法实际执行命令(Runner 被 IDE 扩展日志干扰),未能在本机用真实 `dispboard.bin` 跑通;脚本逻辑已与 `iap.c` 的解析/CRC 及 startup 固件信息布局核对,`GetDiagnostics` 无语法错误。首次在 Keil 编译后即可验证,若结果不符请把生成的文件头/日志反馈。
+- bin 尚未生成时工具会打印 `ERROR: 输入 bin 不存在` 并返回非 0,仅提示,不影响主固件 hex 生成。
\ No newline at end of file