Repository navigation
ambarella: report total RAM from the DSP carve-out - #268
Merged
Merged
Conversation
An S3L camera reported 128M with 512 MiB fitted (#266): mem=118M keeps the kernel far below the top of DRAM, and the DSP has the rest. The reporter read the DRAM marking, a 4 Gbit part on a 16-bit bus, and checked that memory above 256 MiB does not alias, so the 256 MiB in the issue was wrong and IAVMEM ending at 512 MiB was right. This replaces the note that said not to trust it. Total is now the top of the carve-out and media is its size, from /proc/device-tree/iavmem/reg, or from the boot log's IAVMEM line where there is no /proc/device-tree, as on Dahua's 3.10.73. That line is printed once, so a ring buffer that dropped it falls back to what the kernel sees. Stock Dahua firmware has no /dev/i2c-*, because its own sensor.ko owns the bus, so no sensor is reported there. CLAUDE.md records that. The parsers are tested with the reporter's log. It has not run on a camera.
PR Summary by QodoReport Ambarella total RAM using the DSP carve-out
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
Review of #268. Overwriting the last byte of the log could shorten the IAVMEM size if the log ended on it, and the parser took the shorter number. The buffer now gets a real terminator, and the line has to end in a newline to count.
DeathCamel58
added a commit
to DeathCamel58/openipc-ipctool
that referenced
this pull request
Nov 6, 2026
rounded_num() counts the halvings it takes to reach zero and returns 1 << that count, so an exact power of two comes back doubled: 512 -> 1024. A kernel MemTotal is never one, which is why it never showed, but since OpenIPC#268 the Ambarella total is the top of the DSP carve-out, and on the S3L camera from OpenIPC#266 that is exactly 512M (0x07800000 + 0x18800000). Both stock and OpenIPC kernels reported `total: 1024M` there. Return n unchanged when it is already a power of two. backup.c rounds its total with the same function and gets the same fix. ambarella_test now covers the 512M case, a 114940 kB MemTotal (112 -> 128), 513 -> 1024 and 1 -> 1; without the fix the 512M and 1 cases fail.
openipc-ai
pushed a commit
that referenced
this pull request
Nov 6, 2026
rounded_num() counts the halvings it takes to reach zero and returns 1 << count, so an exact power of two came back doubled. A kernel MemTotal is never one, so this never showed until #268 made the Ambarella total the top of the DSP carve-out, exactly 512 MiB on the S3L camera in #266. It now returns n unchanged when n is already a power of two. backup.c rounds its total with the same function and gets the same fix. Tested on an Amcrest IP4M-1026E: total 512M and media 392M on both stock Dahua 3.10.73 and OpenIPC 3.10.104.
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.
Refs #266.
The reporter's camera shows
ram: total: 128Mwith 512 MiB fitted, becausemem=118Mkeeps the kernel far below the top of DRAM and the DSP has the rest. With this change it should report:/proc/device-tree/iavmem/reg, or the boot log'sIAVMEMline on kernels with no/proc/device-tree, as on Dahua's 3.10.73.IAVMEMbecause the issue said 256 MiB. The reporter has since corrected that from the DRAM marking and an aliasing check on the running board.CLAUDE.mdis updated to match.Tested:
ambarella_testwith the reporter's log and a device-tree fixture, plus the host and arm32 builds.Not tested:
Sensor reporting is unchanged. Stock firmware has no
/dev/i2c-*, andsensor.koowns the bus, so driving the controller registers directly would race it.