refactor(build): 支持A/B分区逻辑
移除sys/flash.h、sys/flash.cpp、sys/initial.h和sys/OTA相关文件的 引用,清理cproject.yml和cbuild.yml中的未使用组件和文件配置。 BREAKING CHANGE: 移除了FlashEEPROM相关功能和接口。
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <cstdio>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "config.h"
|
||||
|
||||
/* retarget the C library printf function to the USART */
|
||||
u8 USART0_init() {
|
||||
@@ -36,6 +37,102 @@ void unused_pin_init() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 扫描APP地址范围内的Flash内容
|
||||
* @param print_content 是否打印Flash内容,默认为true
|
||||
* @param page_count 扫描的页数,默认为0表示扫描整个APP区域
|
||||
* @retval 无
|
||||
*/
|
||||
void scanAppFlashContent(bool print_content = true, u32 page_count = 0) {
|
||||
u32 start_addr = APPLATEST_START_ADDR;
|
||||
u32 total_size = 0xC000;
|
||||
|
||||
// 如果指定了页数,则按页数计算大小
|
||||
if (page_count > 0) {
|
||||
total_size = page_count * FMC_PAGE_SIZE;
|
||||
}
|
||||
|
||||
u32 end_addr = start_addr + total_size;
|
||||
|
||||
#if DEBUG_OTA
|
||||
printf("Scanning Flash from 0x%08X to 0x%08X (%d bytes)\r\n", start_addr,
|
||||
end_addr, total_size);
|
||||
#endif
|
||||
|
||||
u32 page_count_scanned = 0;
|
||||
u32 empty_pages = 0;
|
||||
u32 data_pages = 0;
|
||||
|
||||
for (u32 addr = start_addr; addr < end_addr; addr += FMC_PAGE_SIZE) {
|
||||
bool page_empty = true;
|
||||
|
||||
// 检查当前页是否全为0xFF(空页)
|
||||
for (u32 offset = 0; offset < FMC_PAGE_SIZE; offset += 4) {
|
||||
u32 data = *(u32 *)(addr + offset);
|
||||
|
||||
if (data != 0xFFFFFFFF) {
|
||||
page_empty = false;
|
||||
break; // 找到非空数据,立即退出检查
|
||||
}
|
||||
}
|
||||
|
||||
if (page_empty) {
|
||||
empty_pages++;
|
||||
} else {
|
||||
data_pages++;
|
||||
|
||||
// 只有在非空页面且需要打印时才输出内容
|
||||
if (print_content) {
|
||||
printf("Page 0x%08X: \r\n", addr);
|
||||
|
||||
// 打印所有内容
|
||||
for (u32 offset = 0; offset < FMC_PAGE_SIZE;
|
||||
offset += 16) { // 每行打印16字节
|
||||
// 打印地址偏移
|
||||
printf(" +%03X: ", offset);
|
||||
|
||||
// 打印十六进制数据
|
||||
for (u32 byte_idx = 0; byte_idx < 16; byte_idx++) {
|
||||
if ((offset + byte_idx) < FMC_PAGE_SIZE) {
|
||||
u8 data = *(__IO u8 *)(addr + offset + byte_idx);
|
||||
printf("%02X ", data);
|
||||
} else {
|
||||
printf(" "); // 空白填充
|
||||
}
|
||||
|
||||
// 每8字节加个小空格,便于阅读
|
||||
if (byte_idx == 7) {
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
|
||||
// 打印可打印字符
|
||||
printf("|");
|
||||
for (u32 byte_idx = 0; byte_idx < 16; byte_idx++) {
|
||||
if ((offset + byte_idx) < FMC_PAGE_SIZE) {
|
||||
u8 data = *(__IO u8 *)(addr + offset + byte_idx);
|
||||
if (data >= 32 && data <= 126) { // 可打印字符范围
|
||||
printf("%c", data);
|
||||
} else {
|
||||
printf(".");
|
||||
}
|
||||
} else {
|
||||
printf(" "); // 空白填充
|
||||
}
|
||||
}
|
||||
printf("|\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
page_count_scanned++;
|
||||
}
|
||||
|
||||
#if DEBUG_OTA
|
||||
printf("Scan complete: %d pages scanned, %d empty pages, %d data pages\r\n",
|
||||
page_count_scanned, empty_pages, data_pages);
|
||||
#endif
|
||||
}
|
||||
|
||||
// // 发送单个字节到串口 (用于调试)
|
||||
// void uart_send_byte(uint8_t data) {
|
||||
|
||||
Reference in New Issue
Block a user