Fix kasli_soc-demo compilation error with cfg #250

Merged
sb10q merged 2 commits from morgan/artiq-zynq:bugfix into master 2023-08-30 15:33:45 +08:00
Owner
  • Add cfg(has_virtual_leds) to fix kasli_soc-demo compiling error due to PR #244.

    • Tested with nix build .#kasli_soc-demo-jtag -L and built successfully.
  • Need #252 to add "has_virtual_leds" to rustc-cfg file

#244 kasli_soc-demo compiling error

...
   Compiling io v0.0.0 (/build/src/libio)
   Compiling dwarf v0.0.0 (/build/src/libdwarf)
error[E0433]: failed to resolve: could not find `virtual_leds` in `csr`
   --> libboard_artiq/src/io_expander.rs:156:39
    |
156 |             let level = unsafe { csr::virtual_leds::status_read() >> led & 1 };
    |                                       ^^^^^^^^^^^^ could not find `virtual_leds` in `csr`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
error: could not compile `libboard_artiq`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
make: *** [Makefile:17: ../build/firmware/armv7-none-eabihf/release/runtime] Error 101

- Add `cfg(has_virtual_leds)` to fix `kasli_soc-demo` compiling error due to PR #244. - Tested with `nix build .#kasli_soc-demo-jtag -L` and built successfully. ## Related PR - Need #252 to add "has_virtual_leds" to rustc-cfg file ## #244 kasli_soc-demo compiling error ``` ... Compiling io v0.0.0 (/build/src/libio) Compiling dwarf v0.0.0 (/build/src/libdwarf) error[E0433]: failed to resolve: could not find `virtual_leds` in `csr` --> libboard_artiq/src/io_expander.rs:156:39 | 156 | let level = unsafe { csr::virtual_leds::status_read() >> led & 1 }; | ^^^^^^^^^^^^ could not find `virtual_leds` in `csr` error: aborting due to previous error For more information about this error, try `rustc --explain E0433`. error: could not compile `libboard_artiq` To learn more, run the command again with --verbose. warning: build failed, waiting for other jobs to finish... error: build failed make: *** [Makefile:17: ../build/firmware/armv7-none-eabihf/release/runtime] Error 101 ```
morgan added 1 commit 2023-08-29 11:21:25 +08:00
sb10q reviewed 2023-08-29 11:26:03 +08:00
@ -482,6 +483,7 @@ class GenericSatellite(SoCCore):
self.add_csr_group("grabber", self.grabber_csr_group)
# no RTIO CRG here
self.rustc_cfg["has_virtual_leds"] = None
Owner

IIRC misoc does that by default for all CSR cores and those lines are not necessary?

IIRC misoc does that by default for all CSR cores and those lines are not necessary?
Author
Owner

Running python src/gateware/kasli_soc.py -r build/pl.rs -c build/rustc-cfg -m build/mem.rs kasli-soc-satellite.json with the line omitted, the build/rust-cfg don't have the has_virtual_leds line

build/rust-cfg

has_drtio
has_drtio_routing
has_grabber
has_si5324
has_siphaser
hw_rev="v1.1"
ki_impl="csr"
rtio_frequency="125.0"
si5324_soft_reset
Running `python src/gateware/kasli_soc.py -r build/pl.rs -c build/rustc-cfg -m build/mem.rs kasli-soc-satellite.json` with the line omitted, the `build/rust-cfg` don't have the `has_virtual_leds` line ### build/rust-cfg ``` has_drtio has_drtio_routing has_grabber has_si5324 has_siphaser hw_rev="v1.1" ki_impl="csr" rtio_frequency="125.0" si5324_soft_reset ```
Owner
https://github.com/m-labs/misoc/blob/master/misoc/integration/cpu_interface.py#L305 Please find out what is going on.
Owner

You may want to check migen-axi as well - it might not share this code with misoc.

You may want to check migen-axi as well - it might not share this code with misoc.
Author
Owner

Difference between artiq and artiq-zynq

  • In artiq repo, the rust-cfg is generated by calling f.write(cpu_interface.get_rust_cfg(soc.get_csr_regions(), soc.get_constants())) in the misoc/integration/build.py.

    • get_rust_cfg analyze the content of soc.get_csr_regions() and soc.get_constants() to carefully obtain the useful string and output it to the rust-cfg file
  • While in artiq-zynq, the write_rustc_cfg_file(soc, filename) is called to generated rust-cfg in src/gateware/kasli_soc.py

    • It copies the content of soc.rustc_cfg = dict() directly to rust-cfg file

rust cfg difference if using get_rust_cfg

  • The write_rustc_cfg_file(soc, filename) was modified to follow get_rust_cfg
  • Then run python src/gateware/kasli_soc.py -c build/rustc-cfg kasli-soc-satellite.json

rustc-cfg before modification

has_drtio
has_drtio_routing
has_grabber
has_si5324
has_siphaser
has_virtual_leds
hw_rev="v1.1"
ki_impl="csr"
rtio_frequency="125.0"
si5324_soft_reset

rustc-cfg after modification

has_cri_con
has_drtioaux0
has_drtioaux1
has_drtioaux2
has_drtioaux3
has_drtiorep0
has_drtiorep1
has_drtiorep2
has_drtiosat
has_grabber0
has_gt_drtio
has_identifier
has_routing_table
has_rtio
has_rtio_analyzer
has_rtio_dma
has_rtio_moninj
has_siphaser
has_sys_crg
has_virtual_leds
rtio_log_channel="54"

Relevant code snippet

kasli_soc.py before modification

...
def write_rustc_cfg_file(soc, filename):
    with open(filename, "w") as f:
        for k, v in sorted(soc.rustc_cfg.items(), key=itemgetter(0)):
            if v is None:
                f.write("{}\n".format(k))
            else:
                f.write("{}=\"{}\"\n".format(k, v))
...

kasli_soc.py after modification

...
def write_rustc_cfg_file(soc, filename):
    with open(filename, "w") as f:
        for name, origin, busword, obj in soc.get_csr_regions():
            f.write("{}".format("has_"+name.lower()+"\n"))
        for name, value in soc.get_constants():
            if name.upper().startswith("CONFIG_"):
                if value is None:
                    f.write("{}".format(name.lower()[7:]+"\n"))
                else:
                    f.write("{}".format(name.lower()[7:]+"=\""+str(value)+"\"\n"))
...
## Difference between artiq and artiq-zynq - In artiq repo, the rust-cfg is generated by calling `f.write(cpu_interface.get_rust_cfg(soc.get_csr_regions(), soc.get_constants()))` in the `misoc/integration/build.py`. - `get_rust_cfg` analyze the content of `soc.get_csr_regions()` and `soc.get_constants()` to carefully obtain the useful string and output it to the rust-cfg file - While in artiq-zynq, the `write_rustc_cfg_file(soc, filename)` is called to generated rust-cfg in `src/gateware/kasli_soc.py` - It copies the content of `soc.rustc_cfg = dict()` directly to rust-cfg file ## rust cfg difference if using `get_rust_cfg` - The `write_rustc_cfg_file(soc, filename)` was modified to follow `get_rust_cfg` - Then run `python src/gateware/kasli_soc.py -c build/rustc-cfg kasli-soc-satellite.json` ### rustc-cfg before modification ``` has_drtio has_drtio_routing has_grabber has_si5324 has_siphaser has_virtual_leds hw_rev="v1.1" ki_impl="csr" rtio_frequency="125.0" si5324_soft_reset ``` ### rustc-cfg after modification ``` has_cri_con has_drtioaux0 has_drtioaux1 has_drtioaux2 has_drtioaux3 has_drtiorep0 has_drtiorep1 has_drtiorep2 has_drtiosat has_grabber0 has_gt_drtio has_identifier has_routing_table has_rtio has_rtio_analyzer has_rtio_dma has_rtio_moninj has_siphaser has_sys_crg has_virtual_leds rtio_log_channel="54" ``` ## Relevant code snippet ### kasli_soc.py before modification ``` ... def write_rustc_cfg_file(soc, filename): with open(filename, "w") as f: for k, v in sorted(soc.rustc_cfg.items(), key=itemgetter(0)): if v is None: f.write("{}\n".format(k)) else: f.write("{}=\"{}\"\n".format(k, v)) ... ``` ### kasli_soc.py after modification ``` ... def write_rustc_cfg_file(soc, filename): with open(filename, "w") as f: for name, origin, busword, obj in soc.get_csr_regions(): f.write("{}".format("has_"+name.lower()+"\n")) for name, value in soc.get_constants(): if name.upper().startswith("CONFIG_"): if value is None: f.write("{}".format(name.lower()[7:]+"\n")) else: f.write("{}".format(name.lower()[7:]+"=\""+str(value)+"\"\n")) ... ```
Owner

Yeah we should try to avoid divergence with misoc.

Yeah we should try to avoid divergence with misoc.
morgan added 1 commit 2023-08-30 15:05:06 +08:00
sb10q merged commit 2ac7eedec1 into master 2023-08-30 15:33:45 +08:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/artiq-zynq#250
No description provided.