{"id":20041490,"url":"https://github.com/calebccff/rdevmem","last_synced_at":"2025-03-02T06:49:34.000Z","repository":{"id":225906397,"uuid":"767123220","full_name":"calebccff/rdevmem","owner":"calebccff","description":"Like devmem but over sockets","archived":false,"fork":false,"pushed_at":"2024-03-04T22:11:22.000Z","size":325,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T19:26:57.114Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/calebccff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-03-04T18:39:51.000Z","updated_at":"2024-03-05T17:55:09.000Z","dependencies_parsed_at":"2024-03-04T23:29:39.907Z","dependency_job_id":"32c6707a-945f-41c9-819e-cfb3695e32c4","html_url":"https://github.com/calebccff/rdevmem","commit_stats":null,"previous_names":["calebccff/rdevmem"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calebccff%2Frdevmem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calebccff%2Frdevmem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calebccff%2Frdevmem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calebccff%2Frdevmem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/calebccff","download_url":"https://codeload.github.com/calebccff/rdevmem/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241470365,"owners_count":19968041,"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-11-13T10:46:47.160Z","updated_at":"2025-03-02T06:49:33.961Z","avatar_url":"https://github.com/calebccff.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rdevmem\n\nrdevmem is a tool/library for interacting with embedded devices. In short, it\nproxies `/dev/mem` over a UNIX or INET socket, tty, or regular ol' stdio. This\nway, it can be used to build fancy debugging tools (with GUIs!) that run on your\nhost rather than on your target device. It also means your tools don't need to\nbe cross compiled.\n\n\u003e [!NOTE] rdevmem is still very work in progress and needs a lot of polish.\n\u003e However the API is unlikely to change. TTY support is not yet implemented and\n\u003e there are likely many bugs in the protocol still.\n\nThe rdevmem library provides a simple high level API for interacting with\n`/dev/mem`:\n\n```c\n#define GCC_BASE 0x00100000\n#define GCC_USB30_PRIM_MASTER_CLK 0xf00c\n\n/* Initiate a connection via a pre-established socket fd */\nrdevmem_session_t session = rdevmem_init_socket_fd(fd);\n\n/* Connect to the listening rdevmem server on the target */\nint error = rdevmem_hello(session);\nif (error) {\n    fprintf(stderr, \"Failed to send hellow\");\n    return 1;\n}\n\n/* Get a handle to a region of memory on the target */\nint handle = rdevmem_mmap(session, GCC_BASE, 0x1f0000);\nif (handle \u003c 0) {\n    fprintf(stderr, \"Failed to mmap memory\\n\");\n    return 1;\n}\n\nuint32_t value;\nerror = rdevmem_readl(session, handle, GCC_USB30_PRIM_MASTER_CLK, \u0026value);\nif (error) {\n    fprintf(stderr, \"Failed to read\");\n    return 1;\n}\n\nprintf(\"USB30_PRIM_MASTER_CLK: %010x\\n\", value);\n```\n\n## Building\n\nTo make cross compiling as simple as possible, rdevmem should be built as a\nstatic binary, linked against musl. This can be done directly with the tools in\nthis repo.\n\n```sh\n# Set up cross compiler toolchain and libc. We disable CXX support, enable Linux\n# headers, use all CPU cores, and enable pkg-config.\n./mussel/mussel.sh aarch64 -x -p -l -k \n\n# Simple meson wrapper to select a cross compiler config and enable LTO\n# Set up the build environment\n./meson-cross -a aarch64 setup build \n\n# Now compile rdevmem\n./meson-cross compile -C build\n```\n\nThe resulting binary can be deployed to any aarch64 device with any libc and\nprovided that the kernel API is not radically different (e.g. memfd and\n`/dev/mem` are supported) it should just work.\n\n## Not limited to Linux\n\nThe protocol is designed to be fairly minimal, although it could use some work.\nIt should be suitable to write a server implementation for bootloader like\nU-Boot. This would then work with all the same debug tools for interacting with\nclocks or other peripherals.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalebccff%2Frdevmem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalebccff%2Frdevmem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalebccff%2Frdevmem/lists"}