Skip to content

Add J1939 to RAMN and 'showcase mode'#45

Merged
CamilleTTT merged 7 commits intoToyotaInfoTech:mainfrom
BenGardiner:add-j1939-to-ramn
Apr 10, 2026
Merged

Add J1939 to RAMN and 'showcase mode'#45
CamilleTTT merged 7 commits intoToyotaInfoTech:mainfrom
BenGardiner:add-j1939-to-ramn

Conversation

@BenGardiner
Copy link
Copy Markdown
Contributor

The PR is in 4 parts / commits:

  1. refactor existing RAMN mission-time signals to prepare for adding J1939. There should be no change of functionality
  2. add J1939 mission time signals
  3. add J1939 diagnostics and DTCs
  4. add a 'forced autopilot' that 1Hz randomizes command signals

Also added pytests that use python ctypes to call into firmware .c files recompiled for the host to verify the firmware serialization, diagnostic routing and diagnostic responses.

J1939 Signal Mapping and Refactoring (Commit c0f0999)

Added ENABLE_J1939_MODE to toggle between standard and J1939 modes. In J1939 mode, all existing vehicle control and status
signals were remapped to standard J1939 PGNs using 29-bit identifiers (Extended ID).

  • Key Signal Mappings:
    • TSC1 (PGN 0): Torque/Speed Control (Accelerator Commands).
    • XBR (PGN 1024): External Brake Request (Brake Commands).
    • EEC1/EEC2 (PGN 61444/61443): Engine Speed (RPM) and electronic engine control status.
    • EBC1 (PGN 61441): Electronic Brake Controller status.
    • ETC2 (PGN 61445): Transmission Control status.
    • VDC2 (PGN 61449): Vehicle Dynamic Stability Control (Steering).

J1939 Diagnostic Support (Commit 8d0117d)

  • UDS over J1939: Implemented ISO 14229 (UDS) diagnostics encapsulated within J1939 PDU1 (Physical, PGN 0xDA00) and PDU2 (Functional, PGN 0xDB00) frames.
  • KWP2000 and XCP at PGN 0xEF PropA ; filtering by source address.
  • Active DTCs (DM1): Implemented the J1939 DM1 (Active Diagnostic Trouble Codes) message.
    • Single DTC: Sent as a standard 8-byte message (PGN 65226).
    • Multiple DTCs: Automatically utilizes the J1939 Transport Protocol (TP) with Broadcast Announce Message (BAM) to transmit more than one active trouble code.
  • Network Management: Added support for J1939 Address Claiming (PGN 0xEE00), allowing each ECU to claim a unique source address on the bus (e.g., Headway Control:
    42, Steering: 19, Powertrain: 90, Body: 33).
  • ECU Identification: Implemented PGN 64965 (ECU ID) responses via BAM TP for multi-packet identification strings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 24, 2026

🔨 Build & Macro Coverage Report

Default Builds — Hex File Sizes

ECU Debug (tag 15.0) Release (tag 15.0)
ECUA 530 KiB (543274 bytes) 358 KiB (367050 bytes)
ECUB 339 KiB (347311 bytes) 198 KiB (202935 bytes)
ECUC 319 KiB (327437 bytes) 177 KiB (182054 bytes)
ECUD 329 KiB (337435 bytes) 184 KiB (189194 bytes)

Macro Coverage Build Results

Variant Macros Changed Result Warnings
gsusb +ENABLE_GSUSBENABLE_CDC ✅ Pass 0
gsusb_and_bb +ENABLE_GSUSB +ENABLE_BITBANG ✅ Pass 0
i2c +ENABLE_I2C ✅ Pass 0
j1939 +ENABLE_J1939_MODE ✅ Pass 0
j1939_showcase_mode +ENABLE_J1939_MODE +RAMN_SHOWCASE_MODE ✅ Pass 0
kwp +ENABLE_KWP ✅ Pass 0
no_debug ENABLE_USB_DEBUGENABLE_JOYSTICK_CONTROLSENABLE_SCREENENABLE_CHIP8GENERATE_RUNTIME_STATS ✅ Pass 0
no_dynamic_bitrate ENABLE_DYNAMIC_BITRATE ✅ Pass 0
no_extras ENABLE_J1979ENABLE_MINICTFENABLE_CHIP8ENABLE_SCREENENABLE_SPI ✅ Pass 0
no_uds ENABLE_UDSENABLE_UDS_REPROGRAMMING ✅ Pass 12
uart +ENABLE_UARTENABLE_CDCENABLE_USB ✅ Pass 13
usb_autodetect +ENABLE_USB_AUTODETECT ✅ Pass 0
watchdog +WATCHDOG_ENABLE ✅ Pass 0

Source Code Compile Coverage

  • Total .c source lines: 21260
  • Lines compiled in ≥1 configuration: 19915 (~94%)
  • ENABLE_ macro coverage: 23/23 (100.0%) macros tested in both ON and OFF states
Full ENABLE_ Macro Coverage Table
# Macro Tested ON Tested OFF Covered
1 ENABLE_ADC default (ECUB, ECUC, ECUD) default (ECUA)
2 ENABLE_BITBANG default (ECUA), variant: gsusb_and_bb default (ECUB, ECUC, ECUD)
3 ENABLE_CDC default (ECUA) default (ECUB, ECUC, ECUD), variant: gsusb, variant: uart
4 ENABLE_CHIP8 default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug, variant: no_extras
5 ENABLE_DYNAMIC_BITRATE default (ECUA, ECUB, ECUC, ECUD) variant: no_dynamic_bitrate
6 ENABLE_GSUSB variant: gsusb, variant: gsusb_and_bb default (ECUA, ECUB, ECUC, ECUD)
7 ENABLE_I2C variant: i2c default (ECUA, ECUB, ECUC, ECUD)
8 ENABLE_J1939_MODE variant: j1939, variant: j1939_showcase_mode default (ECUA, ECUB, ECUC, ECUD)
9 ENABLE_J1979 default (ECUA, ECUB, ECUC, ECUD) variant: no_extras
10 ENABLE_JOYSTICK_CONTROLS default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug
11 ENABLE_KWP variant: kwp default (ECUA, ECUB, ECUC, ECUD)
12 ENABLE_MINICTF default (ECUA, ECUD) default (ECUB, ECUC), variant: no_extras
13 ENABLE_SCREEN default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug, variant: no_extras
14 ENABLE_SPI default (ECUA, ECUD) default (ECUB, ECUC), variant: no_extras
15 ENABLE_UART variant: uart default (ECUA, ECUB, ECUC, ECUD)
16 ENABLE_UDS default (ECUA, ECUB, ECUC, ECUD) variant: no_uds
17 ENABLE_UDS_REPROGRAMMING default (ECUA, ECUB, ECUC, ECUD) variant: no_uds
18 ENABLE_USB default (ECUA) default (ECUB, ECUC, ECUD), variant: uart
19 ENABLE_USB_AUTODETECT variant: usb_autodetect default (ECUA, ECUB, ECUC, ECUD)
20 ENABLE_USB_DEBUG default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug
21 ENABLE_XCP default (ECUB, ECUC, ECUD) default (ECUA)
22 GENERATE_RUNTIME_STATS default (ECUA, ECUB, ECUC, ECUD) variant: no_debug
23 WATCHDOG_ENABLE variant: watchdog default (ECUA, ECUB, ECUC, ECUD)

@BenGardiner BenGardiner force-pushed the add-j1939-to-ramn branch 3 times, most recently from e2a2c2a to 02455ed Compare April 8, 2026 03:06
@BenGardiner BenGardiner changed the title Add J1939 to ramn (and forced/fuzzing auto pilot) Add J1939 to RAMN and 'showcase mode' Apr 8, 2026
@BenGardiner
Copy link
Copy Markdown
Contributor Author

@CamilleTTT

  • I have moved the J1939 code to ramn_j1939.c as it should have been instead of ramn_customize.
  • I have renamed the force autopilot stuff to 'showcase mode'

Please merge #47 first, then I will rebase and tweak this one to create j1939 and j1939_showcase variants on top of it

@BenGardiner BenGardiner marked this pull request as draft April 8, 2026 19:11
BenGardiner and others added 7 commits April 9, 2026 10:56
…ripts

- Add RAMN_FORCE_AUTOPILOT macro to ramn_config.h (commented out by default)
- Add forced autopilot code path in ramn_simulator.c that randomizes
  command/control values at 1 Hz using TRNG, bypassing sensor overrides
- Include ramn_trng.h conditionally in ramn_simulator.h
- Add disable_autopilot.py helper script for safe flashing
- Update ProgramECU_BCD.sh and .bat to disable autopilot before flashing
@BenGardiner BenGardiner marked this pull request as ready for review April 9, 2026 20:51
@CamilleTTT CamilleTTT merged commit c001b04 into ToyotaInfoTech:main Apr 10, 2026
18 checks passed
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.

3 participants