Add board flash 0x9f SPI command to web config (#1075)
* [ImgBot] Optimize images *Total -- 11,807.83kb -> 10,597.19kb (10.25%) /configs/MavercadeRev2/assets/Rev2_config_pic.jpg -- 1,148.71kb -> 1,001.39kb (12.83%) /configs/MavercadeRev2/assets/Rev2_thumbnail.png -- 4,501.00kb -> 3,984.05kb (11.49%) /configs/ZeroRhythm/Assets/ZeroThythm 2.jpg -- 2,954.52kb -> 2,669.00kb (9.66%) /configs/ZeroRhythm/Assets/ZeroRhythm 1.jpg -- 2,687.40kb -> 2,428.72kb (9.63%) /configs/MavercadeRev1/assets/Rev1_config_pic.png -- 516.19kb -> 514.02kb (0.42%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> * Added actual board flash info to homepage * Missing define * Bump up the TX/RX memory space even more * Last attempt at correctness * Updated system flash size to be a static int32_t only called once at start of web --------- Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
This commit is contained in:
@@ -4,10 +4,12 @@
|
||||
#include <cstdint>
|
||||
|
||||
namespace System {
|
||||
// Returns the size of on-board flash memory in bytes
|
||||
// Returns the size of on-board flash memory reserved by the config
|
||||
uint32_t getTotalFlash();
|
||||
// Returns the amount of on-board flash memory used by the firmware in bytes
|
||||
uint32_t getUsedFlash();
|
||||
// Returns the amount of physical flash memory on the board
|
||||
uint32_t getPhysicalFlash();
|
||||
// Returns the amount of memory used for static allocations in bytes
|
||||
uint32_t getStaticAllocs();
|
||||
// Returns the total size of heap memory in bytes
|
||||
|
||||
@@ -214,7 +214,11 @@ static void __attribute__((noinline)) writeDoc(DynamicJsonDocument& doc, const K
|
||||
|
||||
static int32_t cleanPin(int32_t pin) { return isValidPin(pin) ? pin : -1; }
|
||||
|
||||
static uint32_t systemFlashSize;
|
||||
|
||||
void WebConfig::setup() {
|
||||
// System Flash Size must be called once
|
||||
systemFlashSize = System::getPhysicalFlash();
|
||||
rndis_init();
|
||||
}
|
||||
|
||||
@@ -2106,6 +2110,7 @@ std::string getMemoryReport()
|
||||
DynamicJsonDocument doc(LWIP_HTTPD_POST_MAX_PAYLOAD_LEN);
|
||||
writeDoc(doc, "totalFlash", System::getTotalFlash());
|
||||
writeDoc(doc, "usedFlash", System::getUsedFlash());
|
||||
writeDoc(doc, "physicalFlash", systemFlashSize);
|
||||
writeDoc(doc, "staticAllocs", System::getStaticAllocs());
|
||||
writeDoc(doc, "totalHeap", System::getTotalHeap());
|
||||
writeDoc(doc, "usedHeap", System::getUsedHeap());
|
||||
|
||||
@@ -28,6 +28,22 @@ uint32_t System::getUsedFlash() {
|
||||
return &__flash_binary_end - &__flash_binary_start;
|
||||
}
|
||||
|
||||
#define STORAGE_CMD_TOTAL_BYTES 3
|
||||
|
||||
// Standard Storage instruction: 9f command prefix, Manufacturer ID, Flash Type, Capacity
|
||||
#define FLASH_STORAGE_CMD 0x9f
|
||||
#define FLASH_STORAGE_DATA_BYTES 3
|
||||
#define FLASH_STORAGE_TOTAL_BYTES (1 + FLASH_STORAGE_DATA_BYTES)
|
||||
|
||||
uint32_t System::getPhysicalFlash() {
|
||||
|
||||
uint8_t txbuf[FLASH_STORAGE_TOTAL_BYTES] = {0};
|
||||
uint8_t rxbuf[FLASH_STORAGE_TOTAL_BYTES] = {0};
|
||||
txbuf[0] = FLASH_STORAGE_CMD;
|
||||
flash_do_cmd(txbuf, rxbuf, FLASH_STORAGE_TOTAL_BYTES);
|
||||
return 1 << rxbuf[3];
|
||||
}
|
||||
|
||||
uint32_t System::getStaticAllocs() {
|
||||
const uint32_t inMemorySegmentsSize = reinterpret_cast<uint32_t>(&__bss_end__) - SRAM_BASE;
|
||||
const uint32_t stackSize = &__StackTop - &__StackLimit;
|
||||
|
||||
@@ -761,11 +761,12 @@ app.get('/api/reboot', (req, res) => {
|
||||
|
||||
app.get('/api/getMemoryReport', (req, res) => {
|
||||
return res.send({
|
||||
totalFlash: 2048,
|
||||
usedFlash: 1048,
|
||||
totalFlash: 2048 * 1024,
|
||||
usedFlash: 1048 * 1024,
|
||||
physicalFlash: 2048 * 1024,
|
||||
staticAllocs: 200,
|
||||
totalHeap: 2048,
|
||||
usedHeap: 1048,
|
||||
totalHeap: 2048 * 1024,
|
||||
usedHeap: 1048 * 1024,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ export default {
|
||||
'header-text': 'Welcome to the GP2040-CE Web Configurator!',
|
||||
'latest-text': 'Latest: {{version}}',
|
||||
'memory-flash-text': 'Flash',
|
||||
'memory-board-text': 'Board Flash',
|
||||
'memory-header-text': 'Memory (KB)',
|
||||
'memory-heap-text': 'Heap',
|
||||
'memory-static-allocations-text': 'Static Allocations',
|
||||
|
||||
@@ -55,11 +55,12 @@ export default function HomePage() {
|
||||
|
||||
WebApi.getMemoryReport(setLoading)
|
||||
.then((response) => {
|
||||
const { totalFlash, usedFlash, staticAllocs, totalHeap, usedHeap } =
|
||||
const { totalFlash, usedFlash, physicalFlash, staticAllocs, totalHeap, usedHeap } =
|
||||
response;
|
||||
setMemoryReport({
|
||||
totalFlash: toKB(totalFlash),
|
||||
usedFlash: toKB(usedFlash),
|
||||
physicalFlash: toKB(physicalFlash),
|
||||
staticAllocs: toKB(staticAllocs),
|
||||
totalHeap: toKB(totalHeap),
|
||||
usedHeap: toKB(usedHeap),
|
||||
@@ -111,6 +112,9 @@ export default function HomePage() {
|
||||
{t('HomePage:memory-static-allocations-text')}:{' '}
|
||||
{memoryReport.staticAllocs}
|
||||
</div>
|
||||
<div>
|
||||
{t('HomePage:memory-board-text')}: {memoryReport.physicalFlash}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user