|
| 1 | +## Build and Test NuttX for QEMU RISC-V 64-bit |
| 2 | + |
| 3 | +name: qemu-riscv-nsh64 |
| 4 | + |
| 5 | +permissions: |
| 6 | + ## Allow publishing of GitHub Release |
| 7 | + contents: write |
| 8 | + |
| 9 | +on: |
| 10 | + |
| 11 | + ## Run every day at 0:00 UTC |
| 12 | + ## schedule: |
| 13 | + ## - cron: '0 0 * * *' |
| 14 | + |
| 15 | + ## Run on every commit to this branch |
| 16 | + push: |
| 17 | + branches: [ main ] |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + |
| 26 | + - name: Checkout Source Files |
| 27 | + run: | |
| 28 | + ## TODO: Paste the GitHub Repo and Branch |
| 29 | + source=https://github.com/apache/nuttx/tree/master |
| 30 | +
|
| 31 | + ## Match `https://github.com/user/repo/tree/branch` |
| 32 | + pattern='\(.*\)\/tree\/\(.*\)' |
| 33 | +
|
| 34 | + ## `url` becomes `https://github.com/user/repo` |
| 35 | + ## `branch` becomes `branch` |
| 36 | + url=`echo $source | sed "s/$pattern/\1/"` |
| 37 | + branch=`echo $source | sed "s/$pattern/\2/"` |
| 38 | +
|
| 39 | + ## Check out the `url` and `branch` |
| 40 | + mkdir nuttx |
| 41 | + cd nuttx |
| 42 | + git clone \ |
| 43 | + $url \ |
| 44 | + --branch $branch \ |
| 45 | + nuttx |
| 46 | + git clone https://github.com/apache/nuttx-apps apps |
| 47 | +
|
| 48 | + - name: Install Build Tools |
| 49 | + run: | |
| 50 | + sudo apt -y update |
| 51 | + sudo apt -y install \ |
| 52 | + bison flex gettext texinfo libncurses5-dev libncursesw5-dev \ |
| 53 | + gperf automake libtool pkg-config build-essential gperf genromfs \ |
| 54 | + libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils-dev libelf-dev \ |
| 55 | + libexpat-dev gcc-multilib g++-multilib u-boot-tools util-linux \ |
| 56 | + kconfig-frontends \ |
| 57 | + wget u-boot-tools |
| 58 | +
|
| 59 | + - name: Install Toolchain |
| 60 | + run: | |
| 61 | + wget --no-check-certificate https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v13.2.0-2/xpack-riscv-none-elf-gcc-13.2.0-2-linux-x64.tar.gz |
| 62 | + tar -xf xpack-riscv-none-elf-gcc-*.tar.gz |
| 63 | +
|
| 64 | + - name: Build |
| 65 | + run: | |
| 66 | + ## Add toolchain to PATH |
| 67 | + export PATH=$PATH:$PWD/xpack-riscv-none-elf-gcc-13.2.0-2/bin |
| 68 | + cd nuttx/nuttx |
| 69 | +
|
| 70 | + ## Dump the git hash |
| 71 | + hash1=`git rev-parse HEAD` |
| 72 | + pushd ../apps |
| 73 | + hash2=`git rev-parse HEAD` |
| 74 | + popd |
| 75 | + echo NuttX Source: https://github.com/apache/nuttx/tree/$hash1 >nuttx.hash |
| 76 | + echo NuttX Apps: https://github.com/apache/nuttx-apps/tree/$hash2 >>nuttx.hash |
| 77 | + cat nuttx.hash |
| 78 | +
|
| 79 | + ## Show the GCC version |
| 80 | + riscv-none-elf-gcc -v |
| 81 | +
|
| 82 | + ## Configure the build |
| 83 | + tools/configure.sh rv-virt:knsh64 |
| 84 | +
|
| 85 | + ## Preserve the build config |
| 86 | + cp .config nuttx.config |
| 87 | +
|
| 88 | + ## Run the build |
| 89 | + make |
| 90 | +
|
| 91 | + ## Build Apps Filesystem |
| 92 | + # make export |
| 93 | + # pushd ../apps |
| 94 | + # ./tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz |
| 95 | + # make import |
| 96 | + # popd |
| 97 | +
|
| 98 | + ## Generate Initial RAM Disk |
| 99 | + # genromfs -f initrd -d ../apps/bin -V "NuttXBootVol" |
| 100 | +
|
| 101 | + ## Prepare a Padding with 64 KB of zeroes |
| 102 | + # head -c 65536 /dev/zero >/tmp/nuttx.pad |
| 103 | + |
| 104 | + ## Append Padding and Initial RAM Disk to NuttX Kernel |
| 105 | + # cat nuttx.bin /tmp/nuttx.pad initrd \ |
| 106 | + # >Image |
| 107 | +
|
| 108 | + ## Show the size |
| 109 | + riscv-none-elf-size nuttx |
| 110 | +
|
| 111 | + ## Dump the disassembly to nuttx.S |
| 112 | + riscv-none-elf-objdump \ |
| 113 | + --syms --source --reloc --demangle --line-numbers --wide \ |
| 114 | + --debugging \ |
| 115 | + nuttx \ |
| 116 | + >nuttx.S \ |
| 117 | + 2>&1 |
| 118 | +
|
| 119 | + ## Dump the init disassembly to init.S |
| 120 | + # riscv-none-elf-objdump \ |
| 121 | + # --syms --source --reloc --demangle --line-numbers --wide \ |
| 122 | + # --debugging \ |
| 123 | + # ../apps/bin/init \ |
| 124 | + # >init.S \ |
| 125 | + # 2>&1 |
| 126 | +
|
| 127 | + ## Dump the hello disassembly to hello.S |
| 128 | + # riscv-none-elf-objdump \ |
| 129 | + # --syms --source --reloc --demangle --line-numbers --wide \ |
| 130 | + # --debugging \ |
| 131 | + # ../apps/bin/hello \ |
| 132 | + # >hello.S \ |
| 133 | + # 2>&1 |
| 134 | +
|
| 135 | + - name: Upload Build Outputs as Artifacts |
| 136 | + uses: actions/upload-artifact@v4 |
| 137 | + with: |
| 138 | + name: nuttx.zip |
| 139 | + path: | |
| 140 | + nuttx/nuttx/nuttx* |
| 141 | + nuttx/nuttx/initrd |
| 142 | + nuttx/nuttx/init.S |
| 143 | + nuttx/nuttx/hello.S |
| 144 | + nuttx/nuttx/Image |
| 145 | + nuttx/nuttx/System.map |
| 146 | +
|
| 147 | + - name: Zip Build Outputs for GitHub Release |
| 148 | + run: | |
| 149 | + cd nuttx/nuttx |
| 150 | + zip nuttx.zip nuttx* initrd init.S hello.S Image System.map |
| 151 | +
|
| 152 | + - name: Get Current Date |
| 153 | + id: date |
| 154 | + run: echo "::set-output name=date::$(date +'%Y-%m-%d-%H-%M-%S')" |
| 155 | + |
| 156 | + - name: Publish the GitHub Release |
| 157 | + uses: softprops/action-gh-release@v1 |
| 158 | + with: |
| 159 | + tag_name: qemu-riscv-nsh64-${{ steps.date.outputs.date }} |
| 160 | + draft: false |
| 161 | + prerelease: false |
| 162 | + generate_release_notes: false |
| 163 | + files: | |
| 164 | + nuttx/nuttx/nuttx.zip |
| 165 | + nuttx/nuttx/nuttx |
| 166 | + nuttx/nuttx/nuttx.S |
| 167 | + nuttx/nuttx/nuttx.bin |
| 168 | + nuttx/nuttx/nuttx.map |
| 169 | + nuttx/nuttx/nuttx.hex |
| 170 | + nuttx/nuttx/nuttx.config |
| 171 | + nuttx/nuttx/nuttx.manifest |
| 172 | + nuttx/nuttx/nuttx.hash |
| 173 | + nuttx/nuttx/nuttx-export* |
| 174 | + nuttx/nuttx/initrd |
| 175 | + nuttx/nuttx/init.S |
| 176 | + nuttx/nuttx/hello.S |
| 177 | + nuttx/nuttx/Image |
| 178 | + nuttx/nuttx/System.map |
| 179 | +
|
| 180 | + - name: Install QEMU Emulator |
| 181 | + run: | |
| 182 | + sudo apt -y update |
| 183 | + sudo apt -y install \ |
| 184 | + expect qemu-system-riscv64 |
| 185 | +
|
| 186 | + - name: Download Test Script |
| 187 | + run: | |
| 188 | + cd nuttx/nuttx |
| 189 | + wget https://raw.githubusercontent.com/lupyuen/nuttx-rust-app/main/nuttx.exp |
| 190 | + chmod +x nuttx.exp |
| 191 | + ls -l |
| 192 | + cat nuttx.hash |
| 193 | +
|
| 194 | + - name: Run Test |
| 195 | + run: | |
| 196 | + cd nuttx/nuttx |
| 197 | + ./nuttx.exp |
0 commit comments