@h2loop/autosar 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/agents/autosar-integrator.md +45 -2
- package/commands/autosar-trace.md +2 -2
- package/package.json +4 -1
- package/plugins/index.js +55 -23
- package/python/ecuc_engine/__init__.py +1 -1
- package/python/ecuc_engine/add_signal.py +351 -0
- package/python/ecuc_engine/arxml_edit.py +387 -0
- package/python/ecuc_engine/audit.py +352 -50
- package/python/ecuc_engine/cli.py +125 -5
- package/python/ecuc_engine/codegen/__init__.py +233 -0
- package/python/ecuc_engine/codegen/binding.py +305 -0
- package/python/ecuc_engine/codegen/bindings/sip_standin.json +378 -0
- package/python/ecuc_engine/codegen/cdiff.py +395 -0
- package/python/ecuc_engine/codegen/cwriter.py +150 -0
- package/python/ecuc_engine/codegen/emit.py +463 -0
- package/python/ecuc_engine/codegen/handles.py +176 -0
- package/python/ecuc_engine/codegen/mcal/tc4d.json +60 -0
- package/python/ecuc_engine/codegen/model.py +264 -0
- package/python/ecuc_engine/codegen/modules/__init__.py +7 -0
- package/python/ecuc_engine/codegen/modules/com.py +145 -0
- package/python/ecuc_engine/codegen/modules/comstack.py +14 -0
- package/python/ecuc_engine/codegen/modules/dem.py +22 -0
- package/python/ecuc_engine/codegen/modules/mcal.py +170 -0
- package/python/ecuc_engine/codegen/modules/memstack.py +24 -0
- package/python/ecuc_engine/codegen/registry.py +208 -0
- package/python/ecuc_engine/codegen/schm_memmap.py +159 -0
- package/python/ecuc_engine/context.py +481 -0
- package/python/ecuc_engine/csrc.py +189 -0
- package/python/ecuc_engine/defs.py +30 -0
- package/python/ecuc_engine/ecucjson.py +75 -22
- package/python/ecuc_engine/find.py +164 -0
- package/python/ecuc_engine/gen.py +105 -0
- package/python/ecuc_engine/history.py +146 -0
- package/python/ecuc_engine/model.py +4 -1
- package/python/ecuc_engine/probe.py +229 -0
- package/python/ecuc_engine/rte_api.py +935 -0
- package/python/ecuc_engine/rules/__init__.py +5 -3
- package/python/ecuc_engine/rules/mem.py +84 -0
- package/python/ecuc_engine/rules/nvm.py +131 -0
- package/python/ecuc_engine/rules/pdur.py +87 -0
- package/python/ecuc_engine/rules/system.py +162 -0
- package/python/ecuc_engine/specids.py +163 -0
- package/python/ecuc_engine/sysmodel.py +152 -0
- package/python/ecuc_engine/validate.py +15 -2
- package/python/ecuc_engine/values.py +26 -0
- package/python/ecuc_engine/verify_rte.py +445 -0
- package/python/pyproject.toml +1 -1
- package/skills/autosar/SKILL.md +78 -6
- package/skills/autosar/references/codegen.md +58 -0
- package/skills/autosar/references/ecuc-model.md +4 -1
- package/skills/autosar/references/project-layout.md +10 -1
- package/skills/autosar/references/runnable-code.md +50 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Deterministic config code generation (`autosar_codegen`, `autosar_codegen_diff`)
|
|
2
|
+
|
|
3
|
+
Generated C is never written by hand or by the model: run `autosar_codegen`, review with
|
|
4
|
+
`autosar_codegen_diff`, then `autosar_build`. Same ECUC + param defs -> byte-identical files.
|
|
5
|
+
|
|
6
|
+
## What is generated, from where
|
|
7
|
+
| Output | Source |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `<Mip>_Cfg.h` | pre-compile params of singleton containers as `<MIP>_<PARAM>` (booleans STD_ON/STD_OFF), `<MIP>_CFG_AR_RELEASE_*` (from the schema: AUTOSAR_00054 = R4.11.0), every symbolicNameValue param as `<Mip>Conf_<ContainerDef>_<Name>` (TPS_ECUC_02108) |
|
|
10
|
+
| `<Mip>_Cfg.c` / `_Lcfg.c` / `_PBcfg.c` | one const table per multiplicity-n container def, placed by the most dynamic config class of its fields for the module's IMPLEMENTATION-CONFIG-VARIANT |
|
|
11
|
+
| binding tables (e.g. `NvM_BlockDescriptorTable`, `PduR_Config`) | `codegen/bindings/*.json` (or `.hydron/codegen/bindings/`): the static code's struct layout, selected when its `detect` header is in the project |
|
|
12
|
+
| `SchM_<Mip>.h` | exclusive areas the static code uses (`SchM_Enter_<Mip>_<EA>` found in non-generated C) + main functions |
|
|
13
|
+
| `<Mip>_MemMap.h` | SWS_MemMap_00032 keyword file; pragmas from `codegen.memmap.pragmas` |
|
|
14
|
+
|
|
15
|
+
Release macros: `<MIP>_CFG_AR_RELEASE_*` come from the static code's published information (`<MIP>_AR_RELEASE_*` in
|
|
16
|
+
`<Mip>.h`, SWS_BSW_00059), so the generated release check matches the SIP; the ECUC schema release is the fallback.
|
|
17
|
+
|
|
18
|
+
Handle IDs: missing symbolic values are assigned (lowest free >= def MIN, existing values kept, duplicates
|
|
19
|
+
are errors) and written back into the ARXML in place (TPS_ECUC_02107); `write_back=false` keeps them in memory.
|
|
20
|
+
|
|
21
|
+
A binding may declare `handleLayout` (e.g. Com: Tx signals/I-PDUs before Rx, because the static code indexes its
|
|
22
|
+
tables by handle). Values that break it are renumbered and written back, only for withAuto params (ComHandleId,
|
|
23
|
+
ComIPduHandleId); otherwise it is an error. Configuration the static code cannot represent (binding `require` /
|
|
24
|
+
`unsupported`, e.g. BIG_ENDIAN signals or signal groups for the stand-in Com) fails generation; nothing is written.
|
|
25
|
+
Notes list C code that uses a `<Mip>Conf_*` symbol the configuration no longer has (the build would fail on it).
|
|
26
|
+
|
|
27
|
+
Output goes to `.hydron/codegen/out` unless `out_dir` is given (`project` = `codegen.outDir`, default `Output`).
|
|
28
|
+
|
|
29
|
+
## Com
|
|
30
|
+
`Com_Cfg.h`: ComGeneral switches, `COM_DEV_ERROR_DETECT` (ECUC_Com_00141), `ComConf_ComSignal_*`, `ComConf_ComIPdu_*`,
|
|
31
|
+
`ComConf_ComIPduGroup_*` (and signal-group / group-signal) symbols. `Com_PBcfg.c` (binding): I-PDU buffers sized from the
|
|
32
|
+
EcuC Pdu, signal tables (bit position, size, type, init value, transfer property, notification), Tx I-PDU table (PduR
|
|
33
|
+
source handle via the shared EcuC Pdu, Tx mode, cycle = ComTxModeTimePeriod / ComMainTxTimeBase), Rx I-PDU table (deadline
|
|
34
|
+
= smallest non-zero ComFirstTimeout/ComTimeout of its signals without update bit, SWS_Com_00291).
|
|
35
|
+
Notification callouts: R25-11 Com users (ComUserModule -> ComUserModuleCnf, ComUserSignal with the same system signal,
|
|
36
|
+
ComUserCallback of type COM_RX_ACK / COM_TX_ACK; `call:comUserCallback`), or, for a static Com with `void(void)`
|
|
37
|
+
callbacks, the RTE's `Rte_COMCbk_<sn>()` / `Rte_COMCbkTAck_<sn>()` when the RTE's Rte_Cbk.h declares it
|
|
38
|
+
(`call:rteSignalCallback`). Nothing is bound from guesses: no declaration, no callback.
|
|
39
|
+
|
|
40
|
+
## Known differences from the sample/large fixture oracle (all explained)
|
|
41
|
+
| Item | Oracle | Ours | Why |
|
|
42
|
+
|---|---|---|---|
|
|
43
|
+
| `NvM_BlockDescriptorTable[*].RamBlockDataAddress` | `X` | `&X` (as configured) | ECUC_NvM_00482 value is the address expression; kept verbatim, same address for arrays |
|
|
44
|
+
| Rx I-PDU `TimeoutTicks` with mixed signal timeouts | largest ComTimeout | smallest non-zero | SWS_Com_00291 |
|
|
45
|
+
| `<MIP>_CFG_*` version macros, generic ComGeneral/NvMCommon/... switches, Dem/Fee tables | absent | extra | def-driven output the oracle does not emit |
|
|
46
|
+
| SchM main function names | `Com_MainFunctionTx` | same | SWS_Com says `Com_MainFunctionTx_<shortName>`; the instance named like its def keeps the SIP's legacy name |
|
|
47
|
+
|
|
48
|
+
## Reading a diff
|
|
49
|
+
- *missing*: in the reference only (e.g. a symbol whose ECUC container was deleted: stale Output, not a generator bug).
|
|
50
|
+
- *extra*: generated only (generic def-driven macros/tables the reference generator does not emit).
|
|
51
|
+
- *mismatch*: same name, different value. Typical causes: enum encoding (we use the def literal order unless the
|
|
52
|
+
binding maps it), the configured value verbatim (`&Ram` vs `Ram`).
|
|
53
|
+
|
|
54
|
+
## MCAL
|
|
55
|
+
Port/Dio come from the standard R25-11 defs. Register-level output needs a silicon mapping
|
|
56
|
+
(`codegen.mcal.silicon`, e.g. `tc4d`) plus a project pin map (`codegen.mcal.pinMap`). The bundled TC4Dx file
|
|
57
|
+
has public user-manual data only (status `skeleton`); its `needsVendorData` lists what Infineon's VSMD/BSWMD
|
|
58
|
+
and MCAL static code must supply. Never invent register values.
|
|
@@ -15,7 +15,10 @@ its def through `DEFINITION-REF` (an AUTOSAR path); the `DEST` attribute names t
|
|
|
15
15
|
|
|
16
16
|
**ECUC JSON** (what `ecuc_read` returns and `ecuc_edit add` accepts): containers keyed
|
|
17
17
|
`"<DefName>:<ShortName>"` (just `"<Name>"` when equal), params by def short-name, multi-valued
|
|
18
|
-
params as arrays, refs as `"->/path"`, `@path`/`@def`/`@at` metadata.
|
|
18
|
+
params as arrays, refs as `"->/path"`, `@path`/`@def`/`@at` metadata (`@at` = the container's file:line).
|
|
19
|
+
Each value is followed by `"@at:<Param>"` (file:line of its `VALUE`/`VALUE-REF` element — cite this one for a
|
|
20
|
+
value) and integers by `"@hex:<Param>"` (plus `"@dec:<Param>"` when the ARXML text is hex). Keys starting with
|
|
21
|
+
`@` are metadata; `ecuc_edit` ignores them.
|
|
19
22
|
|
|
20
23
|
**Multiplicity.** `LOWER/UPPER-MULTIPLICITY` (or `UPPER-MULTIPLICITY-INFINITE`) on every container,
|
|
21
24
|
param and ref def. Lower ≥ 1 = mandatory. A **choice container** (`ECUC-CHOICE-CONTAINER-DEF`)
|
|
@@ -23,10 +23,19 @@ Optional; pins what the tools load and how to generate/build:
|
|
|
23
23
|
"config": ["Config/**/*.arxml"],
|
|
24
24
|
"input": ["Input/**/*.arxml"],
|
|
25
25
|
"generate": {"command": "<vendor-cli> -p Config/Ecu.dpa --generate {module}", "cwd": ".", "timeoutSec": 3600},
|
|
26
|
-
"build": {"command": "make -C Build -j8 all", "timeoutSec": 3600}
|
|
26
|
+
"build": {"command": "make -C Build -j8 all", "timeoutSec": 3600},
|
|
27
|
+
"probe": {"cc": "tricore-elf-gcc", "flags": ["-I", "SIP/include", "-DCPU=TC4D"]},
|
|
28
|
+
"checkGenerated": false,
|
|
29
|
+
"specDocs": ["~/autosar/R25-11/txt/*.txt"]
|
|
27
30
|
}
|
|
28
31
|
```
|
|
29
32
|
Without it: param defs = every `.arxml` holding `ECUC-MODULE-DEF` (else `$AUTOSAR_PARAMDEFS`, a
|
|
30
33
|
path list), config = every file holding `ECUC-MODULE-CONFIGURATION-VALUES`, input = all other
|
|
31
34
|
`.arxml`. Use the param defs of the release and vendor the project actually targets; the vendor
|
|
32
35
|
BSWMD defs take precedence for vendor-specific parameters.
|
|
36
|
+
|
|
37
|
+
`probe` sets the compiler/flags for the compile-only sizeof probe (H2L-NVM-001; default: the Makefile's CC/CFLAGS,
|
|
38
|
+
else host `cc` with the discovered header dirs). `checkGenerated` turns the stale-Output check (H2L-GEN-001, run in a
|
|
39
|
+
scratch copy) on/off; by default it is on when a `generate` command exists and the configuration is under 5 MB.
|
|
40
|
+
`specDocs` (else `$AUTOSAR_SPEC_DOCS`, a path list) points `autosar_spec_id_check` at your own text exports
|
|
41
|
+
(.txt/.md) of the AUTOSAR specifications; the pack bundles no spec text and no requirement-ID index.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Runnable code: allowed RTE API, verify, context
|
|
2
|
+
|
|
3
|
+
## Three tiers of an RTE API name (AUTOSAR CP R25-11 SWS_RTE 5.6)
|
|
4
|
+
- **allowed** for runnable R: R has the access point the API's *Existence* requirement names. Only these may be
|
|
5
|
+
called from R and the functions it calls (SWS_Rte_CONSTR_09017/09083/...: "may only be used by the runnable that
|
|
6
|
+
contains the corresponding ..."). Shown in `autosar_build_context` section 3.
|
|
7
|
+
- **generated**: some runnable of the SW-C is allowed it, so it is in `Rte_<Swc>.h`. Calling it from another runnable
|
|
8
|
+
compiles but is wrong (NOT-ALLOWED).
|
|
9
|
+
- **derivable**: the port/element/IRV exists, but no runnable has the access point, so the API is not generated yet.
|
|
10
|
+
|
|
11
|
+
| API | Access point (role) | Existence | Signature |
|
|
12
|
+
|---|---|---|---|
|
|
13
|
+
| `Rte_Write_<p>_<o>` / `Rte_Send_<p>_<o>` | dataSendPoint, data / queued element | SWS_Rte_01280 / 01281 | SWS_Rte_01071 / 01072 |
|
|
14
|
+
| `Rte_Read_<p>_<o>` / `Rte_Receive_<p>_<o>` | dataReceivePointByArgument | SWS_Rte_01289 / 01288 | SWS_Rte_01091 / 01092 |
|
|
15
|
+
| `Rte_DRead_<p>_<o>` | dataReceivePointByValue (primitive) | SWS_Rte_07395 | SWS_Rte_07394 |
|
|
16
|
+
| `Rte_IRead[Ref]_<re>_<p>_<o>`, `Rte_IStatus_...` | dataReadAccess | SWS_Rte_01301 / 04578 / 02600 | SWS_Rte_03741 / 04577 / 02599 |
|
|
17
|
+
| `Rte_IWrite[Ref]_<re>_<p>_<o>`, `Rte_IInvalidate_...` | dataWriteAccess | SWS_Rte_01302 / 05510 / 03801 | SWS_Rte_03744 / 05509 / 03800 |
|
|
18
|
+
| `Rte_Call_<p>_<o>` / `Rte_Result_<p>_<o>` | (a)synchronousServerCallPoint / ...ResultPoint | SWS_Rte_01293/01294 / 01296 | SWS_Rte_01102 / 01111 |
|
|
19
|
+
| `Rte_Mode_<p>_<o>` / `Rte_Switch_<p>_<o>` | modeAccessPoint / modeSwitchPoint | SWS_Rte_02629 / 02632 | SWS_Rte_02628 / 02631 |
|
|
20
|
+
| `Rte_Prm_<p>_<o>` / `Rte_CData_<name>` | parameterAccess (port / local) | SWS_Rte_03929 / 01300 | SWS_Rte_03928 / 01252 |
|
|
21
|
+
| `Rte_IrvRead/IrvWrite_<re>_<o>` | read/writtenLocalVariable, explicit IRV | SWS_Rte_01305 / 01306 | SWS_Rte_03560 / 03565 |
|
|
22
|
+
| `Rte_IrvIRead/IrvIWrite[Ref]_<re>_<o>` | read/writtenLocalVariable, implicit IRV | SWS_Rte_01303 / 01304 | SWS_Rte_03550 / 03553 |
|
|
23
|
+
| `Rte_Pim_<name>` | any runnable | SWS_Rte_01299 | SWS_Rte_01118 |
|
|
24
|
+
| `Rte_Enter/Exit_<ea>` | canEnterExclusiveArea | SWS_Rte_01307 / 01308 | SWS_Rte_01120 / 01123 |
|
|
25
|
+
|
|
26
|
+
Parameter passing: IN primitive by value (SWS_Rte_01017), IN struct/union by `const T*` (01018, 07086), IN array as
|
|
27
|
+
pointer to the base type (05107); OUT always by pointer (01019, 07082, 05108); a struct/array return is a const
|
|
28
|
+
pointer (07071, 07072). Multiple instantiation adds `Rte_Instance self` first. `Rte_IsUpdated`, `Rte_Invalidate`,
|
|
29
|
+
`Rte_Feedback`, `Rte_IStatus` exist only with their ComSpec / InvalidationPolicy settings.
|
|
30
|
+
|
|
31
|
+
## autosar_verify_rte
|
|
32
|
+
Each `Rte_*` call is mapped to its enclosing function and to every runnable whose SYMBOL reaches it through the call
|
|
33
|
+
graph (a static helper called from two runnables is checked for both). Statuses:
|
|
34
|
+
- **OK**.
|
|
35
|
+
- **NOT-ALLOWED**: rewrite with an allowed API, or add the access point to the runnable (ops given). For
|
|
36
|
+
`Rte_I*`/`Rte_Irv*` the runnable name is part of the API name: use the caller's.
|
|
37
|
+
- **INVENTED**: no such port/element/runnable, or the wrong API kind for the port's direction or the element's
|
|
38
|
+
data/event semantics (the hint names the right one). When new data is truly needed the ops add the data
|
|
39
|
+
element (to the port's interface — note other users of that interface) or a new port + interface, then the access
|
|
40
|
+
point. New element types default to the type of a same-named element elsewhere, else `uint8` (flagged).
|
|
41
|
+
After applying ops: `autosar_generate`, then verify again; then `autosar_build`. RTE lifecycle calls (`Rte_Start`, ...)
|
|
42
|
+
in integration code are listed as not checked.
|
|
43
|
+
|
|
44
|
+
## autosar_build_context
|
|
45
|
+
Sections, in fixed order: 1 task, 2 SW-C definition, 3 allowed RTE API (exact header text), 4 runnable code,
|
|
46
|
+
5 callees, 6 Com signals / NvM blocks behind its ports and calls, 7 FUZZY similar functions in other SW-Cs, 8 FUZZY
|
|
47
|
+
similar past git changes (ARXML semantic delta + C hunks, ranked by overlap with the task's ports/elements/words and
|
|
48
|
+
recency). Over budget (~4 chars/token): drop 8, drop 7, callees → prototypes, truncate code, truncate config,
|
|
49
|
+
callees → names, code → head, compact 2. Sections 1 and 3 are never reduced. Output is byte-identical for the same
|
|
50
|
+
inputs; the MANIFEST lists every source (file:line, sha1, included mode). Treat 7–8 as hints, never as truth.
|