examples/psram: BK7258 PSRAM test/heap/memalign commands - #116
Open
yz471686525-eng wants to merge 4 commits into
Open
examples/psram: BK7258 PSRAM test/heap/memalign commands#116yz471686525-eng wants to merge 4 commits into
yz471686525-eng wants to merge 4 commits into
Conversation
Add NSH builtin app for PSRAM testing: - psram id: show chip ID and size - psram probe: init + single-word data path test - psram test [N]: address-in-address test (default 1MB) - psram alias: detect address aliasing - psram width: test 8/16/32-bit access widths Depends on CONFIG_BK7258_PSRAM. Signed-off-by: Zhang Yan <zhangyan68@xiaomi.com>
- psram heap: show PSRAM heap status (arena/used/free/largest) - psram alloc <KB>: allocate from PSRAM heap, verify address in 0x60xxxxxx, quick read/write check - psram freeall: release all alloc'd blocks - Prove malloc() still returns SRAM after PSRAM alloc Signed-off-by: Zhang Yan <zhangyan68@xiaomi.com>
- psram align <A> <KB>: memalign allocation with alignment verification (mod check printed) - psram fbtest: camera framebuffer validation — alloc 614KB at 32 and 64 byte alignment, read/write pattern test, report KB/s bandwidth, verify all freed - Both commands prove malloc() still returns SRAM Signed-off-by: Zhang Yan <zhangyan68@xiaomi.com>
Three fixes to the S4 commands, all found by actually building and running them: 1. clock_systime_ticks() was called without a prototype (implicit int declaration) and is documented as an OS-internal interface that applications should not use. A raw tick delta also bakes in CONFIG_USEC_PER_TICK (10 ms here), which is far too coarse for these measurements. Use clock_gettime(CLOCK_MONOTONIC) and compute microseconds, and print the measured interval next to the throughput so a broken clock can no longer masquerade as slow memory. 2. "psram align <A> <KB>" computed (uintptr_t)ptr % A before checking A, so A=0 divided by zero. Validate that the alignment is a non-zero power of two and that the size is non-zero. 3. Silence -Wshadow on the per-branch "int ret" declarations and print the chip ID with a matching format specifier (uint32_t is unsigned long on this ABI). Measured on BK7258 DevKit after the SysTick fix: psram test 16 -> 11619.8 / 8668.7 KB/s (wr/rd), 16 MB, 0 errors psram fbtest -> 4093.3 / 3611.7 KB/s (wr/rd) for byte-wide access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NSH command used to bring up PSRAM on the BK7258 DevKit:
id / probe / test / alias / width / heap / alloc / align / fbtest / freeall.
Timing uses clock_gettime(CLOCK_MONOTONIC) and prints the measured interval
next to the throughput, so a broken time base cannot masquerade as slow
memory -- which is exactly what happened here before the SysTick fix in the
matching nuttx PR.
Alignment arguments are validated (non-zero power of two) because the mod
checks would otherwise divide by zero.