{"id":20982016,"url":"https://github.com/lowrisc/epic-c-example","last_synced_at":"2025-05-14T16:31:07.607Z","repository":{"id":48060494,"uuid":"393370796","full_name":"lowRISC/epic-c-example","owner":"lowRISC","description":"ePIC (Embedded PIC) example: kernel and relocatable loadable app ","archived":false,"fork":false,"pushed_at":"2023-10-27T13:12:34.000Z","size":66,"stargazers_count":12,"open_issues_count":2,"forks_count":4,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-02T20:38:25.700Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lowRISC.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}},"created_at":"2021-08-06T12:30:33.000Z","updated_at":"2025-03-15T07:31:50.000Z","dependencies_parsed_at":"2022-09-19T05:40:13.149Z","dependency_job_id":"50e953da-06dd-4535-a93a-1c04f592781c","html_url":"https://github.com/lowRISC/epic-c-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lowRISC%2Fepic-c-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lowRISC%2Fepic-c-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lowRISC%2Fepic-c-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lowRISC%2Fepic-c-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lowRISC","download_url":"https://codeload.github.com/lowRISC/epic-c-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254182823,"owners_count":22028367,"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-19T05:42:16.685Z","updated_at":"2025-05-14T16:31:07.292Z","avatar_url":"https://github.com/lowRISC.png","language":"C","readme":"# RISC-V Embedded PIC Demo\n\n## Overview\n\nlowRISC is working on a [specification](https://github.com/luismarques/epic-spec) and [prototype toolchain implementation](https://github.com/lowRISC/llvm-project/commits/epic) of an Embedded PIC (ePIC) ABI for RISC-V.\n\nThis repository showcases how to use the work-in-progress ePIC toolchain implementation. It contains an example of how to create fully relocatable RISC-V apps that require only a simple runtime loader. To demonstrate the relocatability, the repository also contains a simple kernel that loads and relocates the example app.\n\n- The kernel has its entry point in `kernel.c`.\n- The current example loadable app is CoreMark.\n\nThe example runs in spike (riscv-isa-sim) and simulates a system with both SRAM and Flash memory. The kernel image embeds the ELF files it will load at arbitrary addresses during system execution. The steps to load an app are:\n\n- First the kernel simulates programming the Flash memory with the contents of the app that would be programmed into Flash in an actual embedded system.\n- Then a relocating loader, adapted from libtock-c crt0, loads the app from the simulated Flash into the simulated SRAM and relocates it. The relocation process applies simple relocations (`R_RISCV_32` or `R_RISCV_64`) to the data segment, updating statically initialized pointers, vtables, and similar.\n- The GP register (the PIC base) is set to point to the app's SRAM base address.\n- Control is transferred to the just-loaded app and it starts running.\n\n## Building and Running\n\nBuild requirements:\n\n- spike (riscv-isa-sim)\n- xxd\n- LLVM build dependencies\n\nThe dependencies may be built and installed manually or the provided [Dockerfile](Dockerfile) can be used to set up a container with the dependencies pre-installed.\n\nUse `make` to build and run everything.\n\nThe Clang/LLVM toolchain with ePIC support is automatically built as part of this example.\n\n## Licensing\n\nUnless otherwise noted, everything in this repository is covered by the Apache License, Version 2.0 (see [LICENSE](LICENSE) for full text).\n\nThis repository contains code and linker scripts adapted from the Tock OS project, namely from [libtock-c](https://github.com/tock/libtock-c). Those artifacts are licensed under either of:\n\n- Apache License, Version 2.0\n  ([LICENSE](LICENSE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license\n  (http://opensource.org/licenses/MIT)\n\nThis repository also contains code from the CoreMark benchmark, which is also licensed under the Apache License, Version 2.0 ([LICENSE](LICENSE)).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flowrisc%2Fepic-c-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flowrisc%2Fepic-c-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flowrisc%2Fepic-c-example/lists"}