Repository navigation
Conversation
PR Summary by QodoSeparate PRU I2S driver library and standardize firmware builds
AI Description
Merge Risk
|
929475c to
ba6662c
Compare
ba6662c to
8d57a17
Compare
8d57a17 to
9e5d826
Compare
de67ca4 to
25b3ade
Compare
25b3ade to
b178148
Compare
b178148 to
26cdfea
Compare
03abdf5 to
086e0fc
Compare
086e0fc to
4bb2203
Compare
pratheesh
left a comment
There was a problem hiding this comment.
Requesting changes on 44ca8db8. The move and the firmware makefiles work, and make all builds for am261x, but one build order bug remains and the description and README don't match the tree.
Please fix before merge
1. make -j8 host fails on a fresh tree. It stops at pru_i2s_diagnostic.c:163 with fatal error: 'pru_i2s_tdm4_pru1_array.h' not found. makefile:77 and makefile:80 make pru and $(DEVICE_NON_PRU) unordered prerequisites of host, so under -j the app can compile before the firmware headers exist. Serial make host and make -j8 all pass. This is the dependency that was marked as fixed in the earlier thread. Having the host recipe call $(MAKE) pru first, then build the host code, would fix it.
2. -v4 and -v3 still disagree. All 8 firmware example.projectspec files still say -v4, while all 8 makefiles set PRU_VERSION := 3. The PR description says "-v4 -> -v3" and README line 226 says -v3. -v3 is the right value for ICSSM: pru_rules.mak documents 3 as PRU-ICSS, and examples/empty uses it for am261x and am263x. The four am263x firmware images came out byte-identical with either flag, so this is an inconsistency and not a firmware bug, but please make the projectspecs -v3. This is also dhavaljk's open question.
3. README doesn't match the tree.
- Lines 172 and 222 say the array headers go to
firmware/i2s/generated/andfirmware/tdm4/generated/, gitignored. Those directories don't exist. The headers land infirmware/i2s/andfirmware/tdm4/, untracked and not ignored, so they can be committed by accident. - Line 209 calls
make"Build only firmware", but it builds firmware, library and app.
Should fix
4. source/i2s depends on the example. source/i2s/makefile:38-39 adds examples/pru_i2s/firmware and examples to the include path, line 45 writes the library to examples/pru_i2s/lib, and pru_i2s_drv.c:39 includes <pru_i2s/firmware/tdm4/icss_pru_i2s_fw.h>. That leaves the library unusable without this example.
5. Dead pru_i2s_app_config copies. source/i2s/ now has near-identical copies of pru_i2s_app/pru_i2s_app_config.c and .h. The app makefile no longer compiles its own copy, so the files in pru_i2s_app/ are dead. Please delete them, or keep the config in the example, since it is example-specific.
6. CCS Debug library name. PROFILE=${ConfigName} builds ...Debug.lib, but the Debug configuration links ...debug.lib (am263x projectspec line 93). Release is consistent at line 106. From reading the files, this should work on Windows and fail on a case-sensitive host. I did not run it.
Minor
make cleancompiles the library before deleting it, becauseclean_lib(makefile:88) depends on$(DEVICE_NON_PRU).- The title "fixes to PR8 185" is hard to read later. Something like "pru_i2s: move driver to source/i2s and use pru_rules.mak" would help.
What checks out
make allfor am261x builds firmware (4 cores), library and app.- All four am263x firmware cores build with
-v3. git grepfinds no leftoverfirmware/I2Sorfirmware/TDM4references.- The
pru_i2s_drv.c,pru_i2s_drv.handpru_i2s_diagnostic.cchanges are include paths only. - It merges cleanly with current main.
Not tested
The am263x library and app (no am263x SDK here), a CCS project import, Linux, and any hardware. To run make on Windows I had to work around the quoted "$(TARGET)" in pru_rules.mak locally. That also fails on an unmodified examples/empty, so it isn't from this PR. dhavaljk's question about building on both Windows and Linux is still open.
|
@a1248924 thanks for the work here, I really appreciate it. Everything that I spot-checked about the build infrastructure looks good, and takes up a lot less repo space. I didn't have time to dig into the driver design, so not sure if Pratheesh's automated review holds up or not about the driver dependency on the example, potential file duplication, etc. My instinct is that a driver that may be reused across multiple examples should be in the source/ directory, but I don't know how the file structure should work. The project-level makefile tentatively looks fine to me. I know we were debugging behavior of -jN builds on windows since it was allowing R5F firmware to get built ahead of the PRU firmware, I thought we might have resolved the behavior but I can't remember now - maybe could find breadcrumbs in the webex chat |
44ca8db to
4d14ec8
Compare
|
Thanks for the review @pratheesh, Will check for build status and new qodo comments regarding this comment : i have fixed the documentation part, but this behavior is also present for other examples, the .h is generated and gets tracked for empty examples also so i followed that here |
|
Thanks @nsaulnier-ti for having a look at the changes, |
pratheesh
left a comment
There was a problem hiding this comment.
Re-checked the six points from my 11-04 review against 4d14ec86 (the branch was rebased, so I rebuilt from a clean tree each time).
Fixed:
make -j8 hostfrom a clean tree now exits 0 and builds the am261x app.- README firmware paths are corrected.
source/i2sno longer reaches intoexamples/:icss_pru_i2s_fw.hnow lives insource/i2s. The old I2S and TDM4 copies differed only in the include-guard comment.- The Debug configuration links the Debug library name.
make cleanno longer builds the library first.
New: the full am263x host build (firmware, library, app) passes with MCU+ SDK am263x 26.01.00.08. I couldn't test this last time.
Still open:
PRU_VERSION := 4/-v4on ICSSM. It is consistent now, but every other am261x/am263x makefile on main uses 3, and 4 is the ICSSG value. I rebuilt all four am263x firmwares withPRU_VERSION=3, and the array headers are identical, so this is only a convention issue. Please use 3 to match the rest of the repo.- Generated
*_array.hheaders are neither tracked nor ignored. After a build they show as??. On main, the only tracked*_array.hfiles are pru_i2s's own (firmware/I2S,firmware/TDM4), and this PR deletes them, so no other example tracks generated headers. Please add them to.gitignore, or say which way you want it. - Qodo's "add i2s to source/makefile". A plain
SUBDIRS += i2swould break the top-level build, becausesource/i2sallbuilds both am261x and am263x against a singleMCU_PLUS_SDK_PATH. If it goes in, it needsDEVICEgating. - Title. "apply changes for issue : fixes to PR8 185" doesn't describe the change.
Minor: pru_i2s_app_config.c is example configuration compiled into the driver library. That works, but it ties the library to this example.
Not run on hardware. CI is green (14/14).
|
Regarding the open items :
fixed the other comments in a new commit, will check the QODO comments |
| host: pre_build_message | ||
| $(MAKE) pru | ||
| $(MAKE) build_lib_$(DEVICE) | ||
| $(MAKE) $(DEVICE_NON_PRU) ARGUMENTS_MCUPLUS=all |
There was a problem hiding this comment.
Ok, we moved the driver code over to source/ directory, which I think is a good call. We also don't build the driver code from the top-level makefile, which I think is fine as long as the project-level makefile enforces the sequence that the library must be built before the R5F code is built (now that you have those on 2 separate lines, the order is enforced, even with -f).
Now I am trying to decide if it makes sense to put the OUTPUTS from the driver library all in the same output directory in source/i2s. Or if we should consider another design because of the potential for conflicts (e.g., top-level make -j triggering multiple projects at once, and then one project deleting the other project's library files between the compile and archive steps in the source/i2s/makefile execution). We wouldn't see any conflicts now since we only build one processor at a time and there is only one i2s project at the moment. I would like to hear yall's thoughts
There was a problem hiding this comment.
Got some suggestions from Claude :
The investigator's findings line up with my race tests, and together they point to the layout the MCU+ SDK uses. I haven't changed anything yet.
What the MCU+ SDK does
For its R5F ti-arm-clang libraries (source/drivers/makefile.am263x.r5f.ti-arm-clang.freertos):
- Objects: each goes in its own directory, obj//ti-arm-clang//... (line 220).
- Archives: they stay in a flat lib/, with device and profile in the name (lines 13 and 219).
- clean: it removes only that device and profile's object directory and archive (lines 246-249).
- scrub: a separate target removes the whole obj/ and lib/ trees.
- Invocation: the SDK builds one DEVICE per make call.
How source/i2s differs
│ │ SDK │ source/i2s today │
│ Object location│ per device and profile directory│ shared lib/, with the device in the file name but not the profile
│ Archive │ flat lib/, device and profile in the name │ same │
│ clean │ only this config's files │ the whole lib/ │
source/rpmsg isn't comparable. It has one device-independent archive, so it can't conflict across devices.
What my tests showed
- Different devices at once: safe, because the object names include the device.
- Same device, debug and release at once: 1 of 5 runs failed. Both builds use pru_i2s_drv_.obj, so one can delete or overwrite the other's object between compile and archive.
- clean during a build: this is the reviewer's scenario. The build exited 0 but lib/ was empty afterward. These are timing-dependent races, so the failure rates aren't a measure of how often they'd happen.
Proposal
Match the SDK. Only source/i2s/makefile changes:
- Objects: compile into source/i2s/obj///. .gitignore already covers obj/ and lib/.
- Archives: keep them in source/i2s/lib/. The two app makefiles and the two projectspecs don't change.
- clean: remove only the current profile's object directories and archives. I'd add a scrub that removes the whole obj/ and lib/. The example's clean_lib would call clean.
- Stale archive members: this also settles the earlier delete-before-build question. Each build can delete its own archive before ar, which only touches that config's file.
That isolates each device and profile pair, so a clean for one can't remove another's files. One limit remains: two builds of the same device and profile at once would still share their object directory. That's unavoidable without a lock, and the SDK has the same limit.
Let me know if this seems ok to implement
There was a problem hiding this comment.
The proposal doesn't actually address the race condition listed, just the clean comment. I'm open to putting the lib output directory somewhere in examples/i2s// like in the original implementation if that's what makes sense. Pushing out to the team to see if anyone else has comments.
There was a problem hiding this comment.
The more I think about it, the more I am leaning towards putting the outputs for a specific project in that project's directory. But let's get input from the rest of the team.
If all build outputs go into the projects instead of source/i2s/lib, then we don't need to clean source/i2s from the top-level make. In that case, we would just add a note to source/makefile that i2s is called and cleaned from individual projects rather than from a top-level make / clean
| make DEVICE=am263x # Build for AM263x | ||
| ``` | ||
|
|
||
| **Build only firmware:** |
There was a problem hiding this comment.
Are there specific reasons to document building only the firmware? Why not just cd examples/pru_i2s and make?
There was a problem hiding this comment.
i think this was in the original PR and not needed,
will remove this
| $(MAKE) pru | ||
| $(MAKE) build_lib_$(DEVICE) | ||
| $(MAKE) $(DEVICE_NON_PRU) ARGUMENTS_MCUPLUS=all | ||
|
|
There was a problem hiding this comment.
The other thing that changed was going from deleting the library outputs every build before re-building the library outputs, to now only deleting library outputs on a clean from the project-level. Was that an intentional decision? Which approach do we want to take?
There was a problem hiding this comment.
hmm, for this i think i found a similar behavior for the libs in the rpmsg examples :
from claude:
The rpmsg library follows the same pattern—no pre-build delete, clean just does RMDIR lib—but builds incrementally with normal make dependencies. I'll check if it shares the same stale-member issue. · summary
Ran 1 shell command
Yes, partly. source/rpmsg is the only other library in the repo, and it behaves like our current version:
- No delete before archiving: it runs arpru r
$(TARGET) $ (OBJECTS), which updates the archive in place. - Clean: make clean is just RMDIR lib.
- Same weakness: if a source file were removed from its object list, its old member would stay in rpmsg.lib too. Nobody has hit that because the library hasn't changed shape.
What differs is that rpmsg is a normal incremental make build. It has object rules and
What that means for the decision
- Matching rpmsg: our current behavior is consistent with the other library in the repo. The reviewer's question is fair, because main's pru_i2s did the opposite.
- The stale-member risk is real but specific to our change: the library lost a member (pru_i2s_app_config) in this PR, so stale archives from earlier builds can exist. That mostly affects people who built the old version in place, and a make clean fixes it.
- Third option: convert source/i2s to proper incremental rules like rpmsg. That is a bigger rewrite for a library with one source file, and I'd not do it for this comment.
the solution looks something like this :
Recommendation
Go back to deleting before building, and keep the clean target too. It's a one-line change per device in source/i2s/makefile: remove only the archive being rebuilt with
Does this sound okay or should we look for some other way?
81874c5 to
08530da
Compare
08530da to
1b53160
Compare
pratheesh
left a comment
There was a problem hiding this comment.
Re-checked against 1b53160c, building from a clean tree each time (MCU+ SDK am261x 11.00.00.29 and am263x 26.01.00.08, clpru 2.3.3, CCS 21 gmake). Not run on hardware.
Fixed since my 11-19 review:
-v3/PRU_VERSION := 3in all 8 firmware makefiles and projectspecs, matching the other ICSSM examples.- App config is out of the driver library.
pru_i2s_app_config.c/.hnow live inpru_i2s_app/, both app makefiles and projectspecs compile them, andPRUI2S_applyAppConfigis gone frompru_i2s_drv.h. - Dead
firmware/includepaths are removed from all makefiles and projectspecs, as @nsaulnier-ti asked. make -j8 hostfrom a clean tree passes for am261x and am263x (firmware, library, app).make cleanleavesexamples/pru_i2sandsource/i2swith no untracked or ignored files.
Qodo's device-switch finding is real, and I reproduced it. Without cleaning in between, I built am261x, then am263x, then am261x again:
- All four
*_array.hfiles underfirmware/i2sandfirmware/tdm4still held the am263x images after the last build. Their hashes matched the am263x build, not the first am261x build. - The log shows why: the four am261x
.outfiles were "up to date", sopru_rules.makskipped the hexpru + copy step. The am261x app then recompiledpru_i2s_diagnostic.cand relinked against the am263x arrays. - This isn't cosmetic.
pru_i2s_interface.hpicks different BCLK/FS/SD pins underSOC_AM261XandSOC_AM263X, so the am261x image would drive am263x pin assignments, and the build gives no error. - Main has the same pattern: the old per-firmware makefiles also copied to one shared path inside the
.outrecipe only. That part I read from the code and did not run, so this predates the PR. But this PR rewrites that path, so it's the cheap place to fix it. Device-specific destinations, for examplefirmware/i2s/<device>/with the app include path selected per device, would fix it and also make the next point simpler.
On the library output location (@nsaulnier-ti's thread on makefile:82): I agree with putting outputs under each project. The obj-per-device/profile proposal fixes clean for one config wiping another, but two projects that share source/i2s/lib can still race on the same archive. That is the case Nick raised, and it grows with every new i2s project. If the library and the firmware arrays are both written under the consuming project's build directory, the cross-project race and the stale-header problem above both go away. source/makefile then doesn't need an i2s entry, just the note Nick suggested. On the delete-before-build question: removing only the current config's archive before ar is fine whichever layout you choose. It stops stale members. For example, ar rc never drops the pru_i2s_app_config_*.obj member that a library built from an earlier head of this PR contains. I reasoned that from ar semantics and didn't test it.
Still open from before:
- The generated
*_array.hheaders are still untracked and not ignored. After a build, all four show as??. The README no longer says "gitignored", but the files themselves haven't changed. Please add them to.gitignore, or have them generated per device as above. - The title is better. The trailing ": fixes to PR8 185" still reads like an internal ticket reference.
CI is green (14/14).
|
for this review comment : The generated *_array.h headers are still untracked and not ignored. After a build, all four show as ??. The README no longer says "gitignored", but the files themselves haven't changed. Please add them to .gitignore, or have them generated per device as above. i think after discussion we decided to keep the .h files tracked and not gitignored (but not pushed to the repo) on the libs output, i will try to move the outputs to the examples directory to avoid the race conditions when multiple examples use the drivers/libs build/delete |
- Move driver (pru_i2s_drv.c/h, pru_i2s_config.h) to source/i2s/ and add source/i2s/makefile with all/clean targets - Rewrite 8 per-core firmware makefiles to use pru_rules.mak (PRU_VERSION=3, outputs in ti-pru-cgt/generated/) - Update example.projectspec files: -v4 -> -v3 - Add firmware/I2S/generated/ and firmware/TDM4/generated/ for array header outputs; update app include paths accordingly - Restructure top-level makefile: guard pru/host inside BUILD_PROJECT check, all: calls - Update README to reflect new directory structure and build flow Signed-off by Ayushman a-ayushman@ti.com
signed-off by Ayushman <a-ayushman@ti.com>
signed-off by Ayushman <a-ayushman@ti.com>
…, Debug lib name)
- makefile: host builds pru firmware, then the driver library, then the R5F
app as ordered recipe steps, so "make -j host" no longer compiles the app
before the firmware array headers exist; all calls host
- makefile: clean_lib no longer depends on the device targets, so "make clean"
does not build the library before removing it
- firmware makefiles (8) and README: PRU_VERSION 3 -> 4 (-v4)
- README: correct array header location, firmware-only build command and
build directory
- remove unused pru_i2s_app/pru_i2s_app_config.{c,h}; the source/i2s copies
are the ones built into the library
- app projectspecs: link ...Debug.lib to match the PROFILE=${ConfigName} name
Signed-off-by: Ayushman <a-ayushman@ti.com>
- move icss_pru_i2s_fw.h to source/i2s/ as the single copy shared by the PRU firmware and the R5F driver (the firmware/i2s and firmware/tdm4 copies were identical apart from a guard comment); the driver now includes it locally - source/i2s/makefile: drop the examples/ include paths and write the library to source/i2s/lib, matching source/rpmsg - firmware makefiles and projectspecs: add source/i2s to the include path and link the header from its new location - app makefiles and projectspecs: link the library from source/i2s/lib - README: update the file tree and library path Signed-off-by: Ayushman <a-ayushman@ti.com>
- move pru_i2s_app_config.{c,h} from source/i2s back into
examples/pru_i2s/pru_i2s_app; it is example configuration, so it is no
longer compiled into the driver library. The app makefiles and projectspecs
now build it
- source/i2s/pru_i2s_drv.h: drop the PRUI2S_applyAppConfig() declaration, the
function is defined by the example and not by the library
- PRU_VERSION 4 -> 3 in the 8 firmware makefiles, -v4 -> -v3 in the 8 firmware
projectspecs and the README note (PRU-ICSS, as in examples/empty)
- README: remove the "gitignored" wording for the generated array headers
- remove the unused examples/pru_i2s/firmware/include path (directory does
not exist) from the 8 firmware makefiles and projectspecs
- README: drop the "Build only firmware" block; no other example documents
`make pru`, and the full build is `make` from examples/pru_i2s
Signed-off-by: Ayushman <a-ayushman@ti.com>
The example no longer builds or cleans the driver library as part of its own build. The library has its own targets, like the MCU+ SDK libraries. - add "libs" and "libs-clean" to examples/pru_i2s/makefile. "clean" no longer removes the library - the library output belongs to the example: examples/pru_i2s/lib. The output directory of source/i2s/makefile is now overridable (GEN_DIR ?=) - the application only links the existing library. If it is missing, the build stops with a message to run "make libs" - remove the library rebuild rule from the application makefiles and the library preBuildStep from the application projectspecs - library names are lowercase (debug/release) like the MCU+ SDK library names, in the makefile and the projectspecs - delete the archive of the profile being built before running ar, so a rebuild cannot keep stale members. The temporary object file name includes the profile, so a debug and a release build do not collide - README: build the library first, rebuild after driver changes, libs-clean Signed-off-by: Ayushman <a-ayushman@ti.com>
Libraries owned by a project are built and cleaned separately from the project, like the MCU+ SDK libraries. Today only pru_i2s has one. - "make libs" builds, "make libs-clean" cleans the libraries of the projects listed in LIBS_SUBDIRS in examples/makefile - "make" (all) builds the libraries first, so a fresh clone and the make CI are unchanged. "make clean" does not remove them - update the help text and the README - ccs_build.yml: the CCS projects only link the library, so build it with "make libs" before the CCS import Signed-off-by: Ayushman <a-ayushman@ti.com>
The PRU firmware headers of am261x and am263x were copied to the same path, firmware/i2s/ and firmware/tdm4/. After building am261x, am263x, then am261x again, the am261x .out files were up to date, so the headers were not generated again and the am261x application was built with the am263x firmware images (different pins, no build error). - copy the headers to firmware/<board>/, am261x-lp or am263x-cc. The I2S and TDM4 header names differ, so one directory per board is enough - the application includes firmware/<board>/ instead of firmware/i2s and firmware/tdm4 - pru_rules.mak creates the destination directory before the copy - README: describe the new location The CCS projects are not affected: the firmware postBuildStep writes the header into the workspace project. Signed-off-by: Ayushman <a-ayushman@ti.com>
1b53160 to
34c5680
Compare
| ifeq ($(BUILD_MCUPLUS),y) | ||
| -$(MKDIR) $(dir $(MCU_HEX_PATH)) | ||
| -$(COPY) $(TARGET_HEX) $(MCU_HEX_PATH) |
There was a problem hiding this comment.
1. Header directory creation errors ignored 📘 Rule violation ≡ Correctness
The new -$(MKDIR) $(dir $(MCU_HEX_PATH)) line in post-build prefixes the command with -, so make ignores its exit status and continues. The following -$(COPY) step is also ignored, so if directory creation fails, the array header is never written to MCU_HEX_PATH and the build still reports success.
Agent Prompt
## Issue description
In `pru_rules.mak`, the post-build step creates the destination directory for the array header with `-$(MKDIR)`, and copies the header with `-$(COPY)`. The leading `-` makes make ignore failures, so a failed directory creation or copy leaves the firmware header missing while the build succeeds.
## Fix Focus Areas
- pru_rules.mak[163-169]
## Recommended Fix
Remove the leading `-` from the `$(MKDIR)` line so a failure stops the build. For the `$(COPY)` line, keep the ignore only if a missing header is acceptable, and otherwise remove the `-` there too. Verify by running a firmware build with the target directory missing and confirming the build reports an error.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
the - on post-build is the existing repo convention, and the new mkdir follows it. A failed copy surfaces as a missing-header compile error in the app. Making the post-build steps strict would change every example, so it should be a separate change -> Claude
@nsaulnier-ti i can follow up on this in a seperate PR, is that ok ?
- remove PRUI2S_pruGpioPadConfig() and PRUICSS_intcSetSysEvtChMap(), they do not exist. The pins are configured by SysConfig - PRUI2S_initPpBufs() is static and called by PRUI2S_open(), do not list it as an API - PRUI2S_open() does not initialize the INTC, the application calls PRUICSS_intcInit() before PRUI2S_init() - say that PRUI2S_applyAppConfig() is part of the example, not of the driver library - directory structure: list pru_i2s_app_config.c/.h, source/i2s and the real names of the generated headers Signed-off-by: Ayushman <a-ayushman@ti.com>
|
based on discussions i have pushed the changes in new commits, @nsaulnier-ti, you can re-review Summary of Issues fixed: Issue: The driver library was built and cleaned as part of the example, its output sat in a shared source/i2s/lib, and concurrent builds could clash.
Issue: The app rebuilt the library itself (a makefile rule and a CCS preBuildStep), and CCS CI relied on that.
Issue: Building am261x, then am263x, then am261x left am263x headers in the am261x app, with different pins and no error.
Issue: Debug and release builds of one device shared an object file, and failed 1 in 5. ar rc also kept stale members.
Issue: The …Debug.lib / …Release.lib names in the projectspecs didn't match the lowercase names in the makefiles. Issue: The README listed functions that don't exist (PRUI2S_pruGpioPadConfig, PRUICSS_intcSetSysEvtChMap), listed a static function as API, and gave the wrong INTC step. Tested: Windows, gmake, am261x and am263x, full clean builds of the rebased tree. rpmsg on am64x is unaffected. |
Signed-off by Ayushman a-ayushman@ti.com