Compare commits

..

7 commits

Author SHA1 Message Date
Artturin f9a6acd4b2 Remove stack.yaml
Seems unneeded

```
trace: haskell-nix.project : both 'stack.yaml' and 'cabal.project' files exist.  Using 'cabal.project'. set 'projectFileName = "stack.yaml";' to override this.'
```
2025-02-22 22:15:33 +02:00
Artturin d8e6e6daa2 Add flake
`haskell.nix` is quite different from normal nix infra but seems to be
working fine here.
2025-02-22 22:13:14 +02:00
Artturin 264438ef3a After make clean and make, this file changes
`make run` works

riscv compiler is gcc 14

`diffoscope old-hello.elf new-hello.elf`

```
--- old-hello.elf
+++ new-hello.elf
├── readelf --wide --file-header {}
│ @@ -6,15 +6,15 @@
│    OS/ABI:                            UNIX - System V
│    ABI Version:                       0
│    Type:                              EXEC (Executable file)
│    Machine:                           RISC-V
│    Version:                           0x1
│    Entry point address:               0x80000000
│    Start of program headers:          64 (bytes into file)
│ -  Start of section headers:          4600 (bytes into file)
│ +  Start of section headers:          4632 (bytes into file)
│    Flags:                             0x1, RVC, soft-float ABI
│    Size of this header:               64 (bytes)
│    Size of program headers:           56 (bytes)
│    Number of program headers:         2
│    Size of section headers:           64 (bytes)
│    Number of section headers:         7
│    Section header string table index: 6
├── readelf --wide --program-header {}
│ @@ -1,14 +1,14 @@
│
│  Elf file type is EXEC (Executable file)
│  Entry point 0x80000000
│  There are 2 program headers, starting at offset 64
│
│  Program Headers:
│    Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
│ -  RISCV_ATTRIBUT 0x00102b 0x0000000000000000 0x0000000000000000 0x000032 0x000000 R   0x1
│ +  RISCV_ATTRIBUT 0x00102b 0x0000000000000000 0x0000000000000000 0x000045 0x000000 R   0x1
│    LOAD           0x001000 0x0000000080000000 0x0000000080000000 0x00002b 0x00002b R E 0x1000
│
│   Section to Segment mapping:
│    Segment Sections...
│     00     .riscv.attributes
│     01     .text .rodata
├── readelf --wide --sections {}
│ @@ -1,16 +1,16 @@
│ -There are 7 section headers, starting at offset 0x11f8:
│ +There are 7 section headers, starting at offset 0x1218:
│
│  Section Headers:
│    [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
│    [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
│    [ 1] .text             PROGBITS        0000000080000000 001000 00001c 00  AX  0   0  2
│    [ 2] .rodata           PROGBITS        000000008000001c 00101c 00000f 00   A  0   0  1
│ -  [ 3] .riscv.attributes RISCV_ATTRIBUTES 0000000000000000 00102b 000032 00      0   0  1
│ -  [ 4] .symtab           SYMTAB          0000000000000000 001060 000108 18      5  10  8
│ -  [ 5] .strtab           STRTAB          0000000000000000 001168 00004f 00      0   0  1
│ -  [ 6] .shstrtab         STRTAB          0000000000000000 0011b7 00003b 00      0   0  1
│ +  [ 3] .riscv.attributes RISCV_ATTRIBUTES 0000000000000000 00102b 000045 00      0   0  1
│ +  [ 4] .symtab           SYMTAB          0000000000000000 001070 000108 18      5  10  8
│ +  [ 5] .strtab           STRTAB          0000000000000000 001178 000062 00      0   0  1
│ +  [ 6] .shstrtab         STRTAB          0000000000000000 0011da 00003b 00      0   0  1
│  Key to Flags:
│    W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
│    L (link order), O (extra OS processing required), G (group), T (TLS),
│    C (compressed), x (unknown), o (OS specific), E (exclude),
│    D (mbind), p (processor specific)
├── readelf --wide --symbols {}
│ @@ -3,12 +3,12 @@
│     Num:    Value          Size Type    Bind   Vis      Ndx Name
│       0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
│       1: 0000000080000000     0 SECTION LOCAL  DEFAULT    1 .text
│       2: 000000008000001c     0 SECTION LOCAL  DEFAULT    2 .rodata
│       3: 0000000000000000     0 SECTION LOCAL  DEFAULT    3 .riscv.attributes
│       4: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS hello.o
│       5: 0000000010000000     0 NOTYPE  LOCAL  DEFAULT  ABS UART_BASE
│ -     6: 0000000080000000     0 NOTYPE  LOCAL  DEFAULT    1 $xrv64i2p1_m2p0_a2p1_c2p0_zmmul1p0
│ +     6: 0000000080000000     0 NOTYPE  LOCAL  DEFAULT    1 $xrv64i2p1_m2p0_a2p1_c2p0_zmmul1p0_zaamo1p0_zalrsc1p0
│       7: 000000008000001c     0 NOTYPE  LOCAL  DEFAULT    2 message
│       8: 0000000080000008     0 NOTYPE  LOCAL  DEFAULT    1 loop
│       9: 000000008000001a     0 NOTYPE  LOCAL  DEFAULT    1 exit
│      10: 0000000080000000     0 NOTYPE  GLOBAL DEFAULT    1 _start
├── strings --all --bytes=8 {}
│ @@ -1,6 +1,6 @@
│  Hello, world!
│ -rv64i2p1_m2p0_a2p1_c2p0_zmmul1p0
│ +rv64i2p1_m2p0_a2p1_c2p0_zmmul1p0_zaamo1p0_zalrsc1p0
│  UART_BASE
│ -$xrv64i2p1_m2p0_a2p1_c2p0_zmmul1p0
│ +$xrv64i2p1_m2p0_a2p1_c2p0_zmmul1p0_zaamo1p0_zalrsc1p0
│  .shstrtab
│  .riscv.attributes
├── readelf --wide --decompress --hex-dump=.riscv.attributes {}
│ @@ -1,7 +1,8 @@
│
│  Hex dump of section '.riscv.attributes':
│ -  0x00000000 41310000 00726973 63760001 27000000 A1...riscv..'...
│ +  0x00000000 41440000 00726973 63760001 3a000000 AD...riscv..:...
│    0x00000010 05727636 34693270 315f6d32 70305f61 .rv64i2p1_m2p0_a
│    0x00000020 3270315f 63327030 5f7a6d6d 756c3170 2p1_c2p0_zmmul1p
│ -  0x00000030 3000                                0.
│ +  0x00000030 305f7a61 616d6f31 70305f7a 616c7273 0_zaamo1p0_zalrs
│ +  0x00000040 63317030 00                         c1p0.
├── readelf --wide --decompress --hex-dump=.strtab {}
│ @@ -1,8 +1,10 @@
│
│  Hex dump of section '.strtab':
│    0x00000000 0068656c 6c6f2e6f 00554152 545f4241 .hello.o.UART_BA
│    0x00000010 53450024 78727636 34693270 315f6d32 SE.$xrv64i2p1_m2
│    0x00000020 70305f61 3270315f 63327030 5f7a6d6d p0_a2p1_c2p0_zmm
│ -  0x00000030 756c3170 30006d65 73736167 65006c6f ul1p0.message.lo
│ -  0x00000040 6f700065 78697400 5f737461 727400   op.exit._start.
│ +  0x00000030 756c3170 305f7a61 616d6f31 70305f7a ul1p0_zaamo1p0_z
│ +  0x00000040 616c7273 63317030 006d6573 73616765 alrsc1p0.message
│ +  0x00000050 006c6f6f 70006578 6974005f 73746172 .loop.exit._star
│ +  0x00000060 7400                                t.
```
2025-02-22 22:02:52 +02:00
Artturin e7cdc3e339 hello_world: Use nixpkgs target prefix
nixpkgs `riscv64-embedded` is `riscv64-none-elf`
2025-02-22 21:45:18 +02:00
Artturin a956a58325 hello_world: Fix stat with coreutils(linux)
the development nix shell has coreutils
2025-02-22 21:44:28 +02:00
Artturin 507afc2c02 Rename rv_formal.cabal to rvFormal
It appears that the convention is to use the package name as the
filename

```
error: path '/nix/store/3bljihq1ighvsr9ghaw5fvflcdapsrff-haskell-project-plan-to-nix-pkgs/.plan.nix/rvFormal.nix' does not exist
```
2025-02-21 23:13:45 +02:00
Artturin eed328e68a Fix shell.nix
```
[nix-shell:~/joyofhardware/RiscV-Formal]$ riscv64-unknown-linux-gnu-gcc
bash: /nix/store/xq4q2vv9ii7z2k2qp82jd180xdb0r4fv-gcc-riscv64-unknown-linux-gnu-14-20241116/bin/riscv64-unknown-linux-gnu-gcc: cannot execute binary file: Exec format error
```

`pkgs.pkgsCross.riscv64` is for running on riscv64
`pkgs.pkgsCross.riscv64.buildPackages` is for running on the build
system and compiling code for riscv64

`nativeBuildInputs` is for packages which run on the build system and
compile code for riscv64

with `__splicedPackages` we can avoid having to specify `buildPackages`
and have the dependency attributes (`nativeBuildInputs`) pick the
`buildHost` version of the package
2025-02-21 17:04:56 +02:00
8 changed files with 650 additions and 19 deletions

View file

@ -1,5 +1,5 @@
packages:
rv_formal.cabal
rvFormal.cabal
packages: .
builddir: build

577
flake.lock Normal file
View file

@ -0,0 +1,577 @@
{
"nodes": {
"HTTP": {
"flake": false,
"locked": {
"lastModified": 1451647621,
"narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=",
"owner": "phadej",
"repo": "HTTP",
"rev": "9bc0996d412fef1787449d841277ef663ad9a915",
"type": "github"
},
"original": {
"owner": "phadej",
"repo": "HTTP",
"type": "github"
}
},
"cabal-32": {
"flake": false,
"locked": {
"lastModified": 1603716527,
"narHash": "sha256-X0TFfdD4KZpwl0Zr6x+PLxUt/VyKQfX7ylXHdmZIL+w=",
"owner": "haskell",
"repo": "cabal",
"rev": "48bf10787e27364730dd37a42b603cee8d6af7ee",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "3.2",
"repo": "cabal",
"type": "github"
}
},
"cabal-34": {
"flake": false,
"locked": {
"lastModified": 1645834128,
"narHash": "sha256-wG3d+dOt14z8+ydz4SL7pwGfe7SiimxcD/LOuPCV6xM=",
"owner": "haskell",
"repo": "cabal",
"rev": "5ff598c67f53f7c4f48e31d722ba37172230c462",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "3.4",
"repo": "cabal",
"type": "github"
}
},
"cabal-36": {
"flake": false,
"locked": {
"lastModified": 1669081697,
"narHash": "sha256-I5or+V7LZvMxfbYgZATU4awzkicBwwok4mVoje+sGmU=",
"owner": "haskell",
"repo": "cabal",
"rev": "8fd619e33d34924a94e691c5fea2c42f0fc7f144",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "3.6",
"repo": "cabal",
"type": "github"
}
},
"cardano-shell": {
"flake": false,
"locked": {
"lastModified": 1608537748,
"narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=",
"owner": "input-output-hk",
"repo": "cardano-shell",
"rev": "9392c75087cb9a3d453998f4230930dea3a95725",
"type": "github"
},
"original": {
"owner": "input-output-hk",
"repo": "cardano-shell",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1672831974,
"narHash": "sha256-z9k3MfslLjWQfnjBtEtJZdq3H7kyi2kQtUThfTgdRk0=",
"owner": "input-output-hk",
"repo": "flake-compat",
"rev": "45f2638735f8cdc40fe302742b79f248d23eb368",
"type": "github"
},
"original": {
"owner": "input-output-hk",
"ref": "hkm/gitlab-fix",
"repo": "flake-compat",
"type": "github"
}
},
"ghc-8.6.5-iohk": {
"flake": false,
"locked": {
"lastModified": 1600920045,
"narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=",
"owner": "input-output-hk",
"repo": "ghc",
"rev": "95713a6ecce4551240da7c96b6176f980af75cae",
"type": "github"
},
"original": {
"owner": "input-output-hk",
"ref": "release/8.6.5-iohk",
"repo": "ghc",
"type": "github"
}
},
"hackage": {
"flake": false,
"locked": {
"lastModified": 1740097423,
"narHash": "sha256-DsGw8i2CJIw+AaMDn01tDS6frU2d80u5LXmGHuW3kUM=",
"owner": "input-output-hk",
"repo": "hackage.nix",
"rev": "83d083a4931b48b5ba555e52b1bbbf4da55f1a24",
"type": "github"
},
"original": {
"owner": "input-output-hk",
"repo": "hackage.nix",
"type": "github"
}
},
"hackage-for-stackage": {
"flake": false,
"locked": {
"lastModified": 1740097413,
"narHash": "sha256-R8387ERJhPpy6Q/BM6EOHNl/AZ7a8KjippJhil2NsUg=",
"owner": "input-output-hk",
"repo": "hackage.nix",
"rev": "e10eff533209542e11345b2930404938d4a9fe8d",
"type": "github"
},
"original": {
"owner": "input-output-hk",
"ref": "for-stackage",
"repo": "hackage.nix",
"type": "github"
}
},
"haskellNix": {
"inputs": {
"HTTP": "HTTP",
"cabal-32": "cabal-32",
"cabal-34": "cabal-34",
"cabal-36": "cabal-36",
"cardano-shell": "cardano-shell",
"flake-compat": "flake-compat",
"ghc-8.6.5-iohk": "ghc-8.6.5-iohk",
"hackage": "hackage",
"hackage-for-stackage": "hackage-for-stackage",
"hls-1.10": "hls-1.10",
"hls-2.0": "hls-2.0",
"hls-2.2": "hls-2.2",
"hls-2.3": "hls-2.3",
"hls-2.4": "hls-2.4",
"hls-2.5": "hls-2.5",
"hls-2.6": "hls-2.6",
"hls-2.7": "hls-2.7",
"hls-2.8": "hls-2.8",
"hls-2.9": "hls-2.9",
"hpc-coveralls": "hpc-coveralls",
"iserv-proxy": "iserv-proxy",
"nixpkgs": [
"haskellNix",
"nixpkgs-unstable"
],
"nixpkgs-2305": "nixpkgs-2305",
"nixpkgs-2311": "nixpkgs-2311",
"nixpkgs-2405": "nixpkgs-2405",
"nixpkgs-2411": "nixpkgs-2411",
"nixpkgs-unstable": "nixpkgs-unstable",
"old-ghc-nix": "old-ghc-nix",
"stackage": "stackage"
},
"locked": {
"lastModified": 1740099110,
"narHash": "sha256-6sEIo/jd7UgbILXNqaiwN/GilAfks8FBaH79uq0nkZw=",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "81eb79ff6065dfd00b7e5ce46d636fc32a1efef4",
"type": "github"
},
"original": {
"owner": "input-output-hk",
"repo": "haskell.nix",
"type": "github"
}
},
"hls-1.10": {
"flake": false,
"locked": {
"lastModified": 1680000865,
"narHash": "sha256-rc7iiUAcrHxwRM/s0ErEsSPxOR3u8t7DvFeWlMycWgo=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "b08691db779f7a35ff322b71e72a12f6e3376fd9",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "1.10.0.0",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.0": {
"flake": false,
"locked": {
"lastModified": 1687698105,
"narHash": "sha256-OHXlgRzs/kuJH8q7Sxh507H+0Rb8b7VOiPAjcY9sM1k=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "783905f211ac63edf982dd1889c671653327e441",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.0.0.1",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.2": {
"flake": false,
"locked": {
"lastModified": 1693064058,
"narHash": "sha256-8DGIyz5GjuCFmohY6Fa79hHA/p1iIqubfJUTGQElbNk=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "b30f4b6cf5822f3112c35d14a0cba51f3fe23b85",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.2.0.0",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.3": {
"flake": false,
"locked": {
"lastModified": 1695910642,
"narHash": "sha256-tR58doOs3DncFehHwCLczJgntyG/zlsSd7DgDgMPOkI=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "458ccdb55c9ea22cd5d13ec3051aaefb295321be",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.3.0.0",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.4": {
"flake": false,
"locked": {
"lastModified": 1699862708,
"narHash": "sha256-YHXSkdz53zd0fYGIYOgLt6HrA0eaRJi9mXVqDgmvrjk=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "54507ef7e85fa8e9d0eb9a669832a3287ffccd57",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.4.0.1",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.5": {
"flake": false,
"locked": {
"lastModified": 1701080174,
"narHash": "sha256-fyiR9TaHGJIIR0UmcCb73Xv9TJq3ht2ioxQ2mT7kVdc=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "27f8c3d3892e38edaef5bea3870161815c4d014c",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.5.0.0",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.6": {
"flake": false,
"locked": {
"lastModified": 1705325287,
"narHash": "sha256-+P87oLdlPyMw8Mgoul7HMWdEvWP/fNlo8jyNtwME8E8=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "6e0b342fa0327e628610f2711f8c3e4eaaa08b1e",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.6.0.0",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.7": {
"flake": false,
"locked": {
"lastModified": 1708965829,
"narHash": "sha256-LfJ+TBcBFq/XKoiNI7pc4VoHg4WmuzsFxYJ3Fu+Jf+M=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "50322b0a4aefb27adc5ec42f5055aaa8f8e38001",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.7.0.0",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.8": {
"flake": false,
"locked": {
"lastModified": 1715153580,
"narHash": "sha256-Vi/iUt2pWyUJlo9VrYgTcbRviWE0cFO6rmGi9rmALw0=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "dd1be1beb16700de59e0d6801957290bcf956a0a",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.8.0.0",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.9": {
"flake": false,
"locked": {
"lastModified": 1720003792,
"narHash": "sha256-qnDx8Pk0UxtoPr7BimEsAZh9g2WuTuMB/kGqnmdryKs=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "0c1817cb2babef0765e4e72dd297c013e8e3d12b",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.9.0.1",
"repo": "haskell-language-server",
"type": "github"
}
},
"hpc-coveralls": {
"flake": false,
"locked": {
"lastModified": 1607498076,
"narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=",
"owner": "sevanspowell",
"repo": "hpc-coveralls",
"rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430",
"type": "github"
},
"original": {
"owner": "sevanspowell",
"repo": "hpc-coveralls",
"type": "github"
}
},
"iserv-proxy": {
"flake": false,
"locked": {
"lastModified": 1717479972,
"narHash": "sha256-7vE3RQycHI1YT9LHJ1/fUaeln2vIpYm6Mmn8FTpYeVo=",
"owner": "stable-haskell",
"repo": "iserv-proxy",
"rev": "2ed34002247213fc435d0062350b91bab920626e",
"type": "github"
},
"original": {
"owner": "stable-haskell",
"ref": "iserv-syms",
"repo": "iserv-proxy",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1735821806,
"narHash": "sha256-cuNapx/uQeCgeuhUhdck3JKbgpsml259sjUQnWM7zW8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d6973081434f88088e5321f83ebafe9a1167c367",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-2305": {
"locked": {
"lastModified": 1705033721,
"narHash": "sha256-K5eJHmL1/kev6WuqyqqbS1cdNnSidIZ3jeqJ7GbrYnQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a1982c92d8980a0114372973cbdfe0a307f1bdea",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-23.05-darwin",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-2311": {
"locked": {
"lastModified": 1719957072,
"narHash": "sha256-gvFhEf5nszouwLAkT9nWsDzocUTqLWHuL++dvNjMp9I=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7144d6241f02d171d25fba3edeaf15e0f2592105",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-23.11-darwin",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-2405": {
"locked": {
"lastModified": 1735564410,
"narHash": "sha256-HB/FA0+1gpSs8+/boEavrGJH+Eq08/R2wWNph1sM1Dg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1e7a8f391f1a490460760065fa0630b5520f9cf8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-24.05-darwin",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-2411": {
"locked": {
"lastModified": 1737255904,
"narHash": "sha256-r3fxHvh+M/mBgCZXOACzRFPsJdix2QSsKazb7VCXXo0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "eacdab35066b0bb1c9413c96898e326b76398a81",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-24.11-darwin",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1737110817,
"narHash": "sha256-DSenga8XjPaUV5KUFW/i3rNkN7jm9XmguW+qQ1ZJTR4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "041c867bad68dfe34b78b2813028a2e2ea70a23c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"old-ghc-nix": {
"flake": false,
"locked": {
"lastModified": 1631092763,
"narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=",
"owner": "angerman",
"repo": "old-ghc-nix",
"rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8",
"type": "github"
},
"original": {
"owner": "angerman",
"ref": "master",
"repo": "old-ghc-nix",
"type": "github"
}
},
"root": {
"inputs": {
"haskellNix": "haskellNix",
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"stackage": {
"flake": false,
"locked": {
"lastModified": 1740096702,
"narHash": "sha256-fwXgQnLUbL3U8091RaskwGeTe0pRLCaAPh8ZkIiaTBc=",
"owner": "input-output-hk",
"repo": "stackage.nix",
"rev": "64d492737ba6c3eecf7f81dc9184dc8c1482fd06",
"type": "github"
},
"original": {
"owner": "input-output-hk",
"repo": "stackage.nix",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

64
flake.nix Normal file
View file

@ -0,0 +1,64 @@
{
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
utils.url = "github:numtide/flake-utils";
haskellNix.url = "github:input-output-hk/haskell.nix";
};
outputs =
inputs:
inputs.utils.lib.eachDefaultSystem (
system:
let
pkgs = import inputs.nixpkgs {
localSystem = system;
overlays = [
inputs.haskellNix.overlay
(_: prev: {
riscv-formal = prev.callPackage (
{
haskell-nix,
qemu,
}:
haskell-nix.hix.project {
src = builtins.path {
path = ./.;
name = "riscv-formal-source";
};
shell =
let
riscv64-linux = prev.pkgsCross.riscv64-embedded.__splicedPackages;
in
{
tools = {
cabal = { };
hlint = { };
haskell-language-server = { };
};
nativeBuildInputs = [
qemu
riscv64-linux.gcc
riscv64-linux.binutils
riscv64-linux.glibc
];
};
}
) { };
})
];
};
flake = pkgs.riscv-formal.flake { };
in
flake
);
nixConfig = {
# https://input-output-hk.github.io/haskell.nix/tutorials/getting-started-flakes.html#setting-up-the-binary-cache
extra-substituters = [ "https://cache.iog.io" ];
extra-trusted-public-keys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
allow-import-from-derivation = true;
};
}

View file

@ -1,8 +1,8 @@
# RISC-V toolchain
CC = riscv64-unknown-elf-gcc
AS = riscv64-unknown-elf-as
LD = riscv64-unknown-elf-ld
OBJCOPY = riscv64-unknown-elf-objcopy
CC = riscv64-none-elf-gcc
AS = riscv64-none-elf-as
LD = riscv64-none-elf-ld
OBJCOPY = riscv64-none-elf-objcopy
QEMU = qemu-system-riscv64
# Compilation flags
@ -27,7 +27,7 @@ $(ELF): $(SRC) $(LDSCRIPT)
$(BIN): $(ELF)
$(OBJCOPY) -O binary $(ELF) $(BIN)
# Pad the binary to a multiple of 4 bytes
size=$$(stat -f%z $(BIN)); \
size=$$(stat -c %s $(BIN)); \
padding=$$(( (4 - (size % 4)) % 4 )); \
[ $$padding -ne 0 ] && dd if=/dev/zero bs=1 count=$$padding >> $(BIN) || true

Binary file not shown.

View file

@ -1,10 +1,10 @@
{ pkgs ? import <nixpkgs> {} }:
let
riscv64-linux = pkgs.pkgsCross.riscv64;
riscv64-linux = pkgs.pkgsCross.riscv64.__splicedPackages;
in
pkgs.mkShell {
buildInputs = [
nativeBuildInputs = [
riscv64-linux.gcc
riscv64-linux.binutils
riscv64-linux.glibc
@ -13,4 +13,4 @@ pkgs.mkShell {
shellHook = ''
echo "RISC-V Linux cross-compilation environment initialized!"
'';
}
}

View file

@ -1,10 +0,0 @@
resolver: lts-21.20
extra-deps:
- GenericPretty-1.2.2
- clash-ghc-1.8.1
- clash-prelude-1.8.1
- clash-lib-1.8.1
- concurrent-supply-0.1.8
- prettyprinter-interp-0.2.0.0
- pretty-show-1.10