{"id":18478408,"url":"https://github.com/blitz/nezha-dev-env","last_synced_at":"2025-05-13T18:26:29.327Z","repository":{"id":66575373,"uuid":"401811081","full_name":"blitz/nezha-dev-env","owner":"blitz","description":"A build environment for system software for the Nezha RISC-V board.","archived":false,"fork":false,"pushed_at":"2021-09-02T19:43:12.000Z","size":69,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T20:44:25.412Z","etag":null,"topics":["cross-compilation","nix","risc-v","toolchain"],"latest_commit_sha":null,"homepage":"","language":"Nix","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/blitz.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,"publiccode":null,"codemeta":null}},"created_at":"2021-08-31T18:50:52.000Z","updated_at":"2024-11-29T18:46:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"102ca411-f553-4a11-ad29-9d84f824fea4","html_url":"https://github.com/blitz/nezha-dev-env","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/blitz%2Fnezha-dev-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blitz%2Fnezha-dev-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blitz%2Fnezha-dev-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blitz%2Fnezha-dev-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blitz","download_url":"https://codeload.github.com/blitz/nezha-dev-env/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254002325,"owners_count":21997727,"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":["cross-compilation","nix","risc-v","toolchain"],"created_at":"2024-11-06T12:09:55.467Z","updated_at":"2025-05-13T18:26:29.294Z","avatar_url":"https://github.com/blitz.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Allwinner D1 Nezha Board Development Environment\n\n![Board](./doc/nezha.webp)\n\nThis repository gives you access to an easy to setup chroot\nenvironment that allows compilation of and experimentation with the\nsystem software of the Linux-capable 64-bit RISC-V\n[Nezha](https://liliputing.com/2021/05/nezha-is-a-99-single-board-pc-with-a-risc-v-processor.html)\nboard:\n\n- [OpenSBI](https://github.com/riscv/opensbi),\n- [U-Boot](https://www.denx.de/wiki/U-Boot), and\n- [Linux](https://www.kernel.org/)\n\nwith out the hassle of setting up a RISC-V cross-compilation\nenvironment and keeping it working.\n\nMy intention with documenting this repository is to give an example\nhow to use Nix to easily create and \"preserve\" build environments for\nsoftware that are more flexible and efficient than Docker\nenvironments. I have used a similar approach to [package\nCoreboot](https://github.com/blitz/nix-coreboot).\n\n## Relevant Documentation\n\nThe\n[linux-sunxi](https://linux-sunxi.org/Allwinner_Nezha#Manual_build)\nwiki contains detailed instruction on how to find and build OpenSBI,\nU-Boot, and Linux for the Nezha board. This description largely\napplies.\n\n**Note:** You have to use `CROSS_COMPILE=riscv64-unknown-linux-gnu-`\ninstead of `CROSS_COMPILE=riscv64-linux-gnu-`. But the chroot already\ncomes with this automatically set in the environment.\n\n## Usage\n\nTo use the chroot in this repository, you need to [install\nNix](https://nixos.org/download.html).\n\nThen you can enter the [Nix\nshell](https://ghedam.at/15978/an-introduction-to-nix-shell).\n\n```sh\n$ nix-shell\n```\n\nYou can streamline entering the Nix shell by using\n[direnv](https://direnv.net/), which makes this automatic when you\n`cd` into the directory.\n\nIf you enter this shell the first time, it will be slow, because the\ncross-compilation toolchain is built. Going forward, this toolchain is\ncached. My [Cachix](https://www.cachix.org/) repo may contain prebuilt\ncopies built in this repo via Github Actions. You can do `cachix use\nblitz` to use it.\n\nAfter entering the Nix shell, you have access to three tools:\n\n- `fhs`, which drops you into the Nezha development chroot,\n- `connect-nezha`, which connects to the serial port of the Nezha\n  board (if you [connected a USB serial\n  adapter](https://linux-sunxi.org/Allwinner_Nezha#Adding_a_serial_port)\n  to the debug pins),\n- [niv](https://github.com/nmattia/niv), which is used to update this\n  environment.\n\nAfter you enter the chroot, you can compile system software for the\nNezha board following the linux-sunxi wiki:\n\n```sh\n\nnix-shell $ fhs\n\nfhs-chrootenv $ cd work\nfhs-chrootenv work $ git clone https://github.com/smaeul/opensbi -b d1-wip\n...\n\n# The environment variable is already set for you convenience.\nfhs-chrootenv work $ echo CROSS_COMPILE\nriscv64-unknown-linux-gnu-\n\nfhs-chrootenv work $ PLATFORM=generic FW_PIC=y make -C opensbi\n...\n AS        platform/generic/firmware/fw_payload.o\n ELF       platform/generic/firmware/fw_payload.elf\n OBJCOPY   platform/generic/firmware/fw_payload.bin\n```\n\n🚀🚀🚀 That's it. Happy cross compiling! 🚀🚀🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblitz%2Fnezha-dev-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblitz%2Fnezha-dev-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblitz%2Fnezha-dev-env/lists"}