{"id":23594252,"url":"https://github.com/pexmor/netmodule","last_synced_at":"2025-11-04T15:30:26.541Z","repository":{"id":248249842,"uuid":"828159424","full_name":"PexMor/NetModule","owner":"PexMor","description":"JS Helper application for HW-584 v2","archived":false,"fork":false,"pushed_at":"2024-08-08T20:42:45.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T09:16:23.465Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pexmor.github.io/NetModule/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PexMor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-13T09:46:21.000Z","updated_at":"2024-08-08T20:42:48.000Z","dependencies_parsed_at":"2024-07-13T12:44:55.379Z","dependency_job_id":"b623469f-5d2e-4153-8b69-8f3946c53691","html_url":"https://github.com/PexMor/NetModule","commit_stats":null,"previous_names":["pexmor/netmodule"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PexMor%2FNetModule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PexMor%2FNetModule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PexMor%2FNetModule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PexMor%2FNetModule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PexMor","download_url":"https://codeload.github.com/PexMor/NetModule/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239435032,"owners_count":19638046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-27T09:16:26.259Z","updated_at":"2025-11-04T15:30:26.479Z","avatar_url":"https://github.com/PexMor.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NetModule\n\nJS Helper application for HW-584 v2\n\n- The Tool itself open \u003chttps://pexmor.github.io/NetModule/\u003e - in-browser \"local\" tool\n- \u003chttps://github.com/nielsonm236/NetMod-ServerApp\u003e - The alternative firmware for the HW-584v2\n\n## Tools used\n\n- [SRecord](https://srecord.sourceforge.net/) - a CLI for manipulating the files\n- [stm8flash](https://github.com/vdudouyt/stm8flash) - a tool used to flash the **STM8** MCUs (SWIM protocol) can use [ST-Link v2](https://www.st.com/en/development-tools/st-link-v2.html)\n- [hexdump](https://manpages.debian.org/unstable/bsdextrautils/hexdump.1.en.html) to check the binary\n- [stlink](https://github.com/stlink-org/stlink) - a suite of tools for **STM32** make use of [ST-Link v2](https://www.st.com/en/development-tools/st-link-v2.html) _(**Note**: not used for HW-584v2)_\n\n### Hints\n\nTo get canonical hexdump (hex + printable ascii) of a file `eeprom.bin`:\n\n```bash\nhexdump -C eeprom.bin\n```\n\nTo show **srecord** file contents:\n\n```bash\nsrec_info NetworkModule-MQTT-Home.srec\n```\n\ngives you this output:\n\n```yaml\nFormat: Motorola S-Record\nHeader: \"NetworkModule.sm8\"\nsrec_info: NetworkModule-MQTT-Home.srec: 1010:\n    warning: data records not in strictly ascending order (expected \u003e= 0xFDD2,\n    got 0x4000)\nExecution Start Address: FFFFFFFF\nData:   000A - 000F\n        4000 - 406D\n        8000 - FDD1\n```\n\nThis original file as the warning and output says is not sorted and contains extra content.\n\nIn order to fix it it has to be tweaked as:\n\n- remove the extra segements `000A - 000F` and `4000 - 406D`\n- fix the record counter\n\nThis can be done manually by:\n\n- removing the records starting with: `S32500004000` up to `S31300004060`\n- as well as line starting with `S30B0000000A`\n- do not forget to remove control line with number of records `S7`\n\nanalysis (based on [Motorola S-Rec wiki page](\u003chttps://en.wikipedia.org/wiki/SREC_(file_format)\u003e)):\n\nCommand `cut -c-2 NetworkModule-MQTT-Home.sx | sort | uniq -c` reveals that it has:\n\n- 1 `S0` (Header) record\n- 1013 `S3` (data 32-bit address) records\n- 1 `S7` (Start address 32-bit) record.\n\nWhere the `S3` data records consists of numerous fields.\n\nFor example (the first code record):\n\n`S3250000800082009E0D820000008200000082000000820000008200000082000000820000009F`\n\nsplits into:\n\n- `S3` type string\n- `25` length in bytes\n- `00008000` address field (not included in length)\n- `82009E0D82000000820000008200000082000000820000008200000082000000` data field\n- `9F` - checksum field\n\nlet's try to parse it with Python see [p01_parse.py](p01_parse.py)\n\nExample file from: \u003chttps://github.com/nielsonm236/NetMod-ServerApp/releases/download/20240612.0226/NetworkModule-MQTT-Home.sx\u003e\n\n```bash\nsrec_cat NetworkModule-MQTT-Home.sx | cut -c-2 | sort | uniq -c\n```\n\nyields (note added `S5` data count record):\n\n```text\nsrec_cat: NetworkModule-MQTT-Home.sx: 1010: warning: data records not in\n    strictly ascending order (expected \u003e= 0xFDD2, got 0x4000)\n      1 S0\n   1012 S1\n      1 S5\n      1 S7\n```\n\nbased on:\n\n```bash\nsrec_info NetworkModule-MQTT-Home.sx\n```\n\n```text\nFormat: Motorola S-Record\nHeader: \"NetworkModule.sm8\"\nsrec_info: NetworkModule-MQTT-Home.sx: 1010: warning: data records not in\n    strictly ascending order (expected \u003e= 0xFDD2, got 0x4000)\nExecution Start Address: FFFFFFFF\nData:   000A - 000F\n        4000 - 406D\n        8000 - FDD1\n```\n\nwe can cut the desired adress range `8000 - FDD1` the code (note: `0xfdd2` which is last address `+1`):\n\n```bash\nsrec_cat NetworkModule-MQTT-Home.sx -crop 0x8000 0xfdd2 | srec_info\n```\n\nwhich can be simplified as:\n\n```bash\nsrec_cat NetworkModule-MQTT-Home.sx -crop 0x8000 | sort | uniq -c\n```\n\nWithout the `data_count`\n\n```bash\nsrec_cat NetworkModule-MQTT-Home.sx -crop 0x8000 -disable=data-count -address‐length=4 | cut -c-2 | sort | uniq -c\n```\n\nwhich gives:\n\n```text\nsrec_cat: NetworkModule-MQTT-Home.sx: 1010: warning: data records not in\n    strictly ascending order (expected \u003e= 0xFDD2, got 0x4000)\n      1 S0\n   1007 S1\n      1 S7\n```\n\n```bash\n# we can omit also the start address but it is not needed\n# srec_cat NetworkModule-MQTT-Home.sx -motorola -crop 0x8000 -address-length=4 -disable=exec-start-address -disable=data-count | tee ~/tmp/final.srec\nsrec_cat NetworkModule-MQTT-Home.sx -motorola -crop 0x8000 -address-length=4 -disable=data-count | tee ~/tmp/final.srec\n```\n\nFinal result gives:\n\n```bash\nsrec_info ~/tmp/final.srec\n```\n\nthen the output turn into:\n\n```yaml\nFormat: Motorola S-Record\nHeader: \"NetworkModule.sm8\"\nExecution Start Address: FFFFFFFF\nData: 8000 - FDD1\n```\n\nready to be flashed, compare that to the original file, which also has the code block split into two parts the first one contains constants (a html, etc.) and the seconds is the actual code.\n\n### Advance srec_cat\n\nExample taken from \u003chttps://mcuoneclipse.com/2015/04/26/crc-checksum-generation-with-srecord-tools-for-gnu-and-eclipse/\u003e to show how the srec_cat can be used.\n\n```bash\n# srec_cat command file to add the CRC and produce application file to be flashed\n# Usage: srec_cat @filename\n\n# first: create CRC checksum\nFRDM-KL25Z_CRC.srec                # input file\n-fill 0xFF 0x0410 0x20000          # fill code area with 0xff\n-crop 0x0410 0x1FFFE               # just keep code area for CRC calculation below (CRC will be at 0x1FFFE..0x1FFFF)\n-CRC16_Big_Endian 0x1FFFE -CCITT   # calculate big endian CCITT CRC16 at given address.\n-crop 0x1FFFE 0x20000              # keep the CRC itself\n\n# second: add application file\nFRDM-KL25Z_CRC.srec                # input file\n-fill 0xFF 0x0410 0x1FFFE          # fill code area with 0xff\n\n# finally, produce the output file\n-Output                            # produce output\nFRDM-KL25Z_CRC_Added.srec\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpexmor%2Fnetmodule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpexmor%2Fnetmodule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpexmor%2Fnetmodule/lists"}