Skip to content

Enable use of DBBT during firmware loading#245

Open
ziemleszcz wants to merge 2 commits intomasterfrom
ziemleszcz/DTR-507
Open

Enable use of DBBT during firmware loading#245
ziemleszcz wants to merge 2 commits intomasterfrom
ziemleszcz/DTR-507

Conversation

@ziemleszcz
Copy link
Contributor

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (imx6ull).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

Fix issues with DBBT creation. DBBT now includes only bad blocks
from kernel partitions. The size is hardcoded to 1 page (5 total),
which is sufficient to hold up to 32 bad block markers for our
kernel partitions.

Enable DBBT usage and disable bad block marker scanning in FCB.

JIRA: DTR-507
@ziemleszcz ziemleszcz self-assigned this Sep 30, 2025
@github-actions
Copy link

Unit Test Results

9 277 tests  +1 076   8 688 ✅ +1 011   57m 9s ⏱️ + 15m 20s
  545 suites +   66     589 💤 +   65 
    1 files   ±    0       0 ❌ ±    0 

Results for commit 521549a. ± Comparison against base commit 728bc94.

This pull request removes 207 and adds 1283 tests. Note that renamed tests count towards both.
phoenix-rtos-tests/libc/math ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/math.math_abs.fabs_special_cond
phoenix-rtos-tests/libc/math ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/math.math_exp.exp_special_cond
phoenix-rtos-tests/libc/math ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/math.math_exp.frexp_special_cond
phoenix-rtos-tests/libc/math ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/math.math_exp.ldexp_special_cond
phoenix-rtos-tests/libc/math ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/math.math_exp.log10_special_cond
phoenix-rtos-tests/libc/math ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/math.math_exp.log2_special_cond
phoenix-rtos-tests/libc/math ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/math.math_exp.log_special_cond
phoenix-rtos-tests/libc/math ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/math.math_frac.ceil_special_cond
phoenix-rtos-tests/libc/math ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/math.math_frac.floor_special_cond
phoenix-rtos-tests/libc/math ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/math.math_frac.fmod_special_cond
…
flash ‑ aarch64a53-zynqmp-qemu:flash
phoenix-rtos-tests/cpp/hello-cpp ‑ aarch64a53-zynqmp-qemu:phoenix-rtos-tests/cpp/hello-cpp
phoenix-rtos-tests/initfini/main ‑ aarch64a53-zynqmp-qemu:phoenix-rtos-tests/initfini/main
phoenix-rtos-tests/ioctl/unit ‑ aarch64a53-zynqmp-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_in
phoenix-rtos-tests/ioctl/unit ‑ aarch64a53-zynqmp-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_in_big
phoenix-rtos-tests/ioctl/unit ‑ aarch64a53-zynqmp-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_inout
phoenix-rtos-tests/ioctl/unit ‑ aarch64a53-zynqmp-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_inout_big
phoenix-rtos-tests/ioctl/unit ‑ aarch64a53-zynqmp-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_out
phoenix-rtos-tests/ioctl/unit ‑ aarch64a53-zynqmp-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_out_big
phoenix-rtos-tests/ioctl/unit ‑ aarch64a53-zynqmp-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.in_val
…

@ziemleszcz ziemleszcz marked this pull request as ready for review September 30, 2025 08:57
@ziemleszcz ziemleszcz requested a review from nalajcie September 30, 2025 08:57
@ziemleszcz ziemleszcz changed the title Ziemleszcz/dtr 507 Enable use of DBBT during firmware loading Nov 13, 2025
Copy link
Member

@nalajcie nalajcie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks + request to make the nandtool implementation more resilient to power cutoff

#define DBBT_START 0x100
#define BCB_CNT 4
#define BCB_FCB_START 0x0
#define BCB_DBBT_START 0x100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is BCB_CNT * info->erasesz? (worth to note it down if we would use NAND with different geometry in the future). Or compute it dynamically from erasesz always

#define BCB_BB_MAX (BCB_DBBT_SIZE * 1024 - 2)
#define BCB_FW1_PART 2
#define BCB_FW2_PART 3
#define BCB_FW1_DEV "/dev/mtd0p2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhh, this should not be hard-coded into generic tool (depends on ptable)


printf("Total blocks checked: %u\n", size / flashmng_common.info.erasesz);
printf("Number of bad blocks: %u\n", bbtn);
printf("Total blocks checked: %u\n", addr / flashmng_common.info.erasesz);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size, now it's invalid if start > 0?



int flashmng_checkRange(oid_t oid, unsigned int start, unsigned int size, dbbt_t **dbbt)
int flashmng_checkRange(oid_t oid, unsigned int start, unsigned int size, unsigned int offs, dbbt_t *dbbt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference between start and offs? (write a comment, maybe rename to partOffs or something along the lines). If start is not used (always 0 passed) than maybe reduce the parameters.

}

/* DBBT includes only bad blocks from firmware partitions */
printf("PSD: Check FW1 bad blocks - start: %u end: %llu.\n", 0, psd_common.partsz / psd_common.flash.erasesz);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be hard-coded, maybe add special command to SDP language to "check current partition and add to the DBBT"?

printf("WARN: %u out of %u DBBT are broken\n", dbbt_failed, BCB_CNT);
}

return (dbbt_failed == BCB_CNT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1

/* DBBT includes only bad blocks from firmware partitions */
err = nandtool_scan(BCB_FW1_DEV, dbbt);
if (err < 0) {
perror("nandtool: failed to flash DBBT");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flash?

return err;
}

err = dbbt_flash(nandtool_common.oid, nandtool_common.fd, dbbt, nandtool_common.info);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should update (erase + write) DBBT ONLY if it differs

}

/* DBBT includes only bad blocks from firmware partitions */
err = nandtool_scan(BCB_FW1_DEV, dbbt);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be great to not have the partitions hard-coded, maybe make device files a parameter to -t?

printf("\t-r - flash raw data\n");
printf("\t-s <block> - start flashing from given block (requires -i)\n");
#ifdef HAS_BCB
printf("\t-f - write FCB\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add (DANGEROUS)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants