Expose the existing registers through Modbus and service CAN using one GAS provider only in M95M02 builds. Include the EEPROM layout/driver, LOAD protection and calibration, firmware identity and shared CCS build workflow. Add transport/profile and SCI8 validation tests, documentation and the checked M95M02 firmware image.
66 lines
2.3 KiB
Python
66 lines
2.3 KiB
Python
"""Exercise the current board-specific SCI8 gate without TI tools or hardware."""
|
|
from pathlib import Path
|
|
import struct
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
LIMIT = (0x3FFF - (128 + 1)) * 2
|
|
|
|
|
|
def image(size):
|
|
header = struct.pack('<H', 0x08AA) + bytes(16) + struct.pack('<HH', 0, 0x8000)
|
|
blocks = max(1, (size-24+131075)//131076)
|
|
remaining = (size-24-blocks*6)//2
|
|
result = bytearray(header)
|
|
for _ in range(blocks):
|
|
words = min(65535, remaining)
|
|
result += struct.pack('<HHH', words, 0, 0x8000) + bytes(words*2)
|
|
remaining -= words
|
|
return bytes(result)+bytes(2)
|
|
|
|
|
|
class FirmwareGateTest(unittest.TestCase):
|
|
def check_image(self, data, success, profile="AT25256B"):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
source = Path(directory) / 'candidate.bin'
|
|
source.write_bytes(data)
|
|
result = subprocess.run([
|
|
sys.executable, str(ROOT / 'tests/gas167/check_image.py'),
|
|
str(source), '--eeprom', profile,
|
|
], capture_output=True)
|
|
self.assertEqual(result.returncode == 0, success,
|
|
result.stderr.decode(errors='replace'))
|
|
self.assertEqual(source.read_bytes(), data)
|
|
return result.stdout + result.stderr
|
|
|
|
def test_exact_boundary_is_accepted(self):
|
|
self.check_image(image(LIMIT), True)
|
|
|
|
def test_34a95bc5_size_is_rejected(self):
|
|
self.check_image(image(32518), False)
|
|
|
|
def test_missing_boot_terminator_is_rejected(self):
|
|
self.check_image(image(100)[:-2], False)
|
|
|
|
def test_partial_block_is_rejected(self):
|
|
self.check_image(image(100)[:-10], False)
|
|
|
|
def test_m95_capacity_does_not_expand_code_ram(self):
|
|
diagnostic = self.check_image(image(261884), False, "M95M02")
|
|
self.assertIn(b'outside code RAM', diagnostic)
|
|
self.check_image(image(261886), False, "M95M02")
|
|
|
|
def test_m95_image_rejected_for_small_part(self):
|
|
self.check_image(image(32734), True, "M95M02")
|
|
self.check_image(image(32734), False, "AT25256B")
|
|
|
|
def test_wrong_format_is_rejected(self):
|
|
self.check_image(bytes(100), False)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|