Skip to content

Commit 187babe

Browse files
committed
fix: skip data flash usage scan in status command
Data flash reads undefined values after erase (not 0xFF) per Renesas RA4M2 manual section 44.16.2 ?!. So usage cannot be reliably determined. Display "usage unknown" instead of misleading percentages. Signed-off-by: Vincent Jardin <vjardin@free.fr>
1 parent 53357f1 commit 187babe

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

src/radfu.c

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3166,7 +3166,7 @@ ra_status(ra_device_t *dev) {
31663166

31673167
/* Calculate memory sizes and usage */
31683168
uint32_t code_size = 0, code_used = 0;
3169-
uint32_t data_size = 0, data_used = 0;
3169+
uint32_t data_size = 0;
31703170
uint32_t config_size = 0;
31713171
uint32_t code_sad = 0, code_ead = 0;
31723172
uint32_t data_sad = 0, data_ead = 0;
@@ -3212,17 +3212,9 @@ ra_status(ra_device_t *dev) {
32123212
}
32133213
}
32143214

3215-
if (data_size > 0 && dev->chip_layout[1].rau != 0) {
3216-
fprintf(stderr, "Scanning data flash usage...\n");
3217-
for (int i = 0; i < MAX_AREAS; i++) {
3218-
ra_area_t *area = &dev->chip_layout[i];
3219-
if (area->koa == KOA_TYPE_DATA && area->ead != 0 && area->rau != 0) {
3220-
int64_t used = status_scan_flash_usage(dev, area->sad, area->ead, area->rau);
3221-
if (used >= 0)
3222-
data_used += (uint32_t)used;
3223-
}
3224-
}
3225-
}
3215+
/* NOTE: Data flash usage scanning is skipped because erased data flash
3216+
* reads undefined values (not 0xFF) per Renesas RA hardware spec.
3217+
* The bootloader protocol does not expose a reliable blank-check method. */
32263218

32273219
/* Print status display */
32283220
printf("\n");
@@ -3372,18 +3364,12 @@ ra_status(ra_device_t *dev) {
33723364
status_print_line(line, STATUS_WIDTH);
33733365
}
33743366

3375-
/* Data Flash - usage bar */
3376-
pct = (data_size > 0) ? (int)((uint64_t)data_used * 100 / data_size) : 0;
3377-
int df_filled = (data_size > 0) ? (int)((uint64_t)data_used * 40 / data_size) : 0;
3378-
if (df_filled > 40)
3379-
df_filled = 40;
3380-
bar_buf[0] = '\0';
3381-
strcat(bar_buf, " ");
3382-
for (int i = 0; i < df_filled; i++)
3383-
strcat(bar_buf, BAR_FULL);
3384-
for (int i = df_filled; i < 40; i++)
3385-
strcat(bar_buf, BAR_EMPTY);
3386-
snprintf(content, sizeof(content), "%s %3d%% used", bar_buf, pct);
3367+
/* Data Flash - usage cannot be determined (hardware limitation)
3368+
* Per RA4M2 manual 44.16.2: "Values read from data flash memory that has
3369+
* been erased but not yet been programming again are undefined."
3370+
* The bootloader protocol does not expose the hardware blank check. */
3371+
snprintf(
3372+
content, sizeof(content), " (usage unknown - erased data reads undefined per HW spec)");
33873373
status_format_inner(line, sizeof(line), content, INNER_WIDTH);
33883374
status_print_line(line, STATUS_WIDTH);
33893375
}

0 commit comments

Comments
 (0)