Add fast-servo linien gateware #37

Merged
sb10q merged 4 commits from fsagbuya/nix-servo:gateware into master 2024-03-01 16:39:57 +08:00
Collaborator

Description

  • Build gateware for linien fast-servo
nix build .#packages.armv7l-linux.fast-servo-gateware -L --show-trace && ls -lhLs
 ./result/
total 3.4M
4.0K dr-xr-xr-x 2 root root 4.0K Jan  1  1970 nix-support
3.4M -r--r--r-- 2 root root 3.4M Jan  1  1970 top.bit
### Description - [x] Build gateware for linien fast-servo ``` nix build .#packages.armv7l-linux.fast-servo-gateware -L --show-trace && ls -lhLs ./result/ total 3.4M 4.0K dr-xr-xr-x 2 root root 4.0K Jan 1 1970 nix-support 3.4M -r--r--r-- 2 root root 3.4M Jan 1 1970 top.bit ```
Owner

firmware.patch is still an awful file name.

firmware.patch is still an awful file name.
sb10q reviewed 2024-02-23 21:18:26 +08:00
flake.nix Outdated
@ -34,0 +79,4 @@
fast-servo-firmware = pkgs.python3Packages.buildPythonPackage {
name = "fast-servo-firmware";
src = pkgs.fetchFromGitHub {
owner = "elhep";
Owner

This is inconsistent. Either use elhep repositories everywhere or (preferred) use upstream linien with patches inside this repos.

This is inconsistent. Either use elhep repositories everywhere or (preferred) use upstream linien with patches inside this repos.
Author
Collaborator

This dependency is also outsourced in the patch here f52548367e/install.sh (L9). However, the option to use elhep repo everywhere only use the linien version 0.8.0 and not the latest 1.0.1. The current linien.patch here is applied to version 1.0.1. Which one should we employ?

This dependency is also outsourced in the patch here https://github.com/elhep/linien/blob/f52548367ed76ebc483c01407f11e54215de4e79/install.sh#L9. However, the option to use elhep repo everywhere only use the linien version `0.8.0` and not the latest `1.0.1`. The current `linien.patch` here is applied to version `1.0.1`. Which one should we employ?
Owner

The main point of using Nix is not to have this kind of non-reproducible installation script. So whatever this script does regarding management of dependencies is not an example to follow.

The main point of using Nix is not to have this kind of non-reproducible installation script. So whatever this script does regarding management of dependencies is not an example to follow.
Owner

As I said, better use upstream linien and apply the changes from elhep in the form of patches.

As I said, better use upstream linien and apply the changes from elhep in the form of patches.
Author
Collaborator

Understood. However running the gateware script of the patched linien from elhep would return an error such as this (since it depends on the other elhep repo):

   > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > no configure script, doing nothing
       > Running phase: buildPhase
       > Traceback (most recent call last):
       >   File "<frozen runpy>", line 198, in _run_module_as_main
       >   File "<frozen runpy>", line 88, in _run_code
       >   File "/build/source/gateware/fpga_image_helper.py", line 81, in <module>
       >     from fast_servo.gateware.fast_servo_platform import Platform
       > ModuleNotFoundError: No module named 'fast_servo'

We can build on top of the elhep patches to add the missing module.

Understood. However running the gateware script of the patched linien from elhep would return an error such as this (since it depends on the other elhep repo): ``` > Running phase: updateAutotoolsGnuConfigScriptsPhase > Running phase: configurePhase > no configure script, doing nothing > Running phase: buildPhase > Traceback (most recent call last): > File "<frozen runpy>", line 198, in _run_module_as_main > File "<frozen runpy>", line 88, in _run_code > File "/build/source/gateware/fpga_image_helper.py", line 81, in <module> > from fast_servo.gateware.fast_servo_platform import Platform > ModuleNotFoundError: No module named 'fast_servo' ``` We can build on top of the elhep patches to add the missing module.
Owner

Obviously you need to apply the elhep patch to the linien repos that it depends on.

Obviously you need to apply the elhep patch to the linien repos that it depends on.
fsagbuya marked this conversation as resolved
sb10q reviewed 2024-02-23 21:19:38 +08:00
flake.nix Outdated
@ -374,6 +456,7 @@
patchShebangs qemu-script
'';
in {
"fast-servo-gateware" = gateware;
Owner

See all my previous comments about this kind of situation.

See all my previous comments about this kind of situation.
fsagbuya marked this conversation as resolved
sb10q reviewed 2024-02-23 21:20:44 +08:00
flake.nix Outdated
@ -34,0 +84,4 @@
rev = "7fae40c0f872a91218be378f8289b98b1e366729";
hash = "sha256-jqMF0fsicdRCq6kwJcZDcVRuHgskTpt7Qo4WkNkE028=";
};
# fix deprecated migen `add_source` error
Owner

If you had named this file properly you would not need this comment.

If you had named this file properly you would not need this comment.
fsagbuya marked this conversation as resolved
Owner

The patch needs traceability information, e.g. "diff between linen-org/linien commit ID XXXXX and elhep/linien commit ID YYYYYY"

The patch needs traceability information, e.g. "diff between linen-org/linien commit ID XXXXX and elhep/linien commit ID YYYYYY"
fsagbuya force-pushed gateware from 38090c9055 to 6cbe558c31 2024-02-26 15:48:36 +08:00 Compare
sb10q reviewed 2024-02-26 15:55:43 +08:00
flake.nix Outdated
@ -374,6 +445,7 @@
patchShebangs qemu-script
'';
in {
"${board}-gateware" = gateware;
Owner

You need to disable this for zc706. There is no linien gateware for this board and probably will never be. Maybe just take the gateware out of board-package-set.

You need to disable this for zc706. There is no linien gateware for this board and probably will never be. Maybe just take the gateware out of board-package-set.
fsagbuya marked this conversation as resolved
fsagbuya force-pushed gateware from 6cbe558c31 to f1b6767e59 2024-02-26 16:18:37 +08:00 Compare
sb10q reviewed 2024-02-26 16:32:33 +08:00
@ -0,0 +1,4395 @@
"diff between linen-org/linien commit ID e3b2dec and elhep/linien commit ID b73eea0"
# https://github.com/elhep/linien/commit/b73eea07889dda8b55f0cf4c2afde96cf4c3efd1
# Added the "fast_servo" module from https://github.com/elhep/Fast-Servo-Firmware
Owner

Again, obviously the commit ID needs to be specified.
Putting both into the same patch sounds like maintainance hassle. And if you are just copying files then the patch format is not the right one.

Again, obviously the commit ID needs to be specified. Putting both into the same patch sounds like maintainance hassle. And if you are just copying files then the patch format is not the right one.
Author
Collaborator

And if you are just copying files then the patch format is not the right one.

May I know what do you mean by this?

> And if you are just copying files then the patch format is not the right one. May I know what do you mean by this?
Owner

Just put files into a directory and copy them.

Just put files into a directory and copy them.
fsagbuya marked this conversation as resolved
sb10q reviewed 2024-02-26 16:33:26 +08:00
flake.nix Outdated
@ -148,0 +204,4 @@
vivado
];
buildPhase = ''
export HOME=$(mktemp -d)
Owner

What needs that?

What needs that?
Author
Collaborator

It is a fix to prevent this error:

PermissionError: [Errno 13] Permission denied: '/homeless-shelter'
It is a fix to prevent this error: ``` PermissionError: [Errno 13] Permission denied: '/homeless-shelter' ```
Owner

I've been using Nix for 6 years and I had already guessed that much.

I've been using Nix for 6 years and I had already guessed that much.
fsagbuya marked this conversation as resolved
sb10q reviewed 2024-02-26 16:33:44 +08:00
flake.nix Outdated
@ -145,6 +190,32 @@
};
};
gateware = pkgs.stdenv.mkDerivation rec {
Owner

fast-servo-gateware = ...

fast-servo-gateware = ...
fsagbuya marked this conversation as resolved
fsagbuya force-pushed gateware from f1b6767e59 to f640be9b8f 2024-02-27 16:35:05 +08:00 Compare
Owner

"gateware-support" is again a poorly chosen name. Should be "linien-gateware" or similar?

"gateware-support" is again a poorly chosen name. Should be "linien-gateware" or similar?
Owner

And why is there a pitaya_ps.py in the fast-servo gateware?
Looks like this could be better handled with a patch against the upstream Linien gateware, instead of all this copying.

And why is there a pitaya_ps.py in the fast-servo gateware? Looks like this could be better handled with a patch against the upstream Linien gateware, instead of all this copying.
Author
Collaborator

And why is there a pitaya_ps.py in the fast-servo gateware?

There are some submodules defined in pitaya_ps that was used by the BaseSOC module of fast-servo (i.e. Axi2Sys, Sys2CSR, SysCDC, SysInterconnect)

Looks like this could be better handled with a patch against the upstream Linien gateware, instead of all this copying.

Will revert back to the patch format, removing pitaya_ps and transferring the required modules inside the fast_servo_soc.py.

> And why is there a pitaya_ps.py in the fast-servo gateware? There are some submodules defined in pitaya_ps that was used by the `BaseSOC` module of fast-servo (i.e. Axi2Sys, Sys2CSR, SysCDC, SysInterconnect) > Looks like this could be better handled with a patch against the upstream Linien gateware, instead of all this copying. Will revert back to the patch format, removing `pitaya_ps` and transferring the required modules inside the fast_servo_soc.py.
Owner

There are some submodules defined in pitaya_ps that was used by the BaseSOC module of fast-servo (i.e. Axi2Sys, Sys2CSR, SysCDC, SysInterconnect)

Well that's silly but looks like an upstream issue which can be addressed later.

Will revert back to the patch format, removing pitaya_ps and transferring the required modules inside the fast_servo_soc.py.

Just stick to upstream for now. Isn't the elhep stuff just minor modifications on top of the original linien gateware?

> There are some submodules defined in pitaya_ps that was used by the BaseSOC module of fast-servo (i.e. Axi2Sys, Sys2CSR, SysCDC, SysInterconnect) Well that's silly but looks like an upstream issue which can be addressed later. > Will revert back to the patch format, removing pitaya_ps and transferring the required modules inside the fast_servo_soc.py. Just stick to upstream for now. Isn't the elhep stuff just minor modifications on top of the original linien gateware?
Author
Collaborator

Just stick to upstream for now. Isn't the elhep stuff just minor modifications on top of the original linien gateware?

Well the elhep patch itself is 1200+ lines of codes already, not to mention that it imports the other module from Fast-Servo-Gateware repo, which makes it longer.

> Just stick to upstream for now. Isn't the elhep stuff just minor modifications on top of the original linien gateware? Well the elhep patch itself is 1200+ lines of codes already, not to mention that it imports the other module from `Fast-Servo-Gateware` repo, which makes it longer.
Owner

What "other module"? I don't find a Fast-Servo-Gateware repos. If you meant Fast-Servo-Firmware it seems to me that it's (1) stuff that we don't need and you can strip (2) minor modifications on top of upstream Linien. In this context 1200 lines counts as minor.

What "other module"? I don't find a Fast-Servo-Gateware repos. If you meant Fast-Servo-Firmware it seems to me that it's (1) stuff that we don't need and you can strip (2) minor modifications on top of upstream Linien. In this context 1200 lines counts as minor.
Author
Collaborator

What "other module"? I don't find a Fast-Servo-Gateware repos. If you meant Fast-Servo-Firmware it seems to me that it's (1) stuff that we don't need and you can strip (2) minor modifications on top of upstream Linien. In this context 1200 lines counts as minor.

Yes, I meant the Fast-Servo-Firmware. I think the primary base board and peripheral definitions are inside the Fast-Servo-Firmware repos, also there are some python scripts there that needs to be run after boot up as per this instruction.

> What "other module"? I don't find a Fast-Servo-Gateware repos. If you meant Fast-Servo-Firmware it seems to me that it's (1) stuff that we don't need and you can strip (2) minor modifications on top of upstream Linien. In this context 1200 lines counts as minor. Yes, I meant the Fast-Servo-Firmware. I think the primary base board and peripheral definitions are inside the Fast-Servo-Firmware repos, also there are some python scripts there that needs to be run after boot up as per [this instruction](https://github.com/elhep/Fast-Servo-Firmware?tab=readme-ov-file#launching).
Owner

Loading the gateware with fpgautil is standard procedure for Zynq and outside the scope of this PR which should be focused solely on building the gateware.

Put the gateware init python scripts into a dedicated folder in this repos (with provenance information). Doesn't seem to be a big deal. But it should not be part of this PR either.

Loading the gateware with fpgautil is standard procedure for Zynq and outside the scope of this PR which should be focused solely on building the gateware. Put the gateware init python scripts into a dedicated folder in this repos (with provenance information). Doesn't seem to be a big deal. But it should not be part of this PR either.
fsagbuya force-pushed gateware from f640be9b8f to f19c3d09a4 2024-02-28 13:03:22 +08:00 Compare
Owner

Again fast-servo-modules.patch is nonsense filename.

Again fast-servo-modules.patch is nonsense filename.
Owner

Seems those patches should be called linien-fast-servo-server.patch and linien-fast-servo-gateware.patch.

Seems those patches should be called linien-fast-servo-server.patch and linien-fast-servo-gateware.patch.
Owner

Why does the server patch have provenance information at its beginning but not the gateware one?

Why does the server patch have provenance information at its beginning but not the gateware one?
Author
Collaborator

Why does the server patch have provenance information at its beginning but not the gateware one?

Will add provenance information as well.

> Why does the server patch have provenance information at its beginning but not the gateware one? Will add provenance information as well.
sb10q reviewed 2024-02-28 13:11:47 +08:00
flake.nix Outdated
@ -148,0 +200,4 @@
name = "fast-servo-gateware";
inherit (pkgs.python3Packages.linien-common) src;
# Apply fast-servo board support
# See: https://github.com/elhep/linien/commit/b73eea07889dda8b55f0cf4c2afde96cf4c3efd1
Owner

To which patch does this commit refer to?

To which patch does this commit refer to?
Owner

How does it relate to the provenance information in the patches?

How does it relate to the provenance information in the patches?
Author
Collaborator

Will clean this up and update to the match the provenance info from patches.

Will clean this up and update to the match the provenance info from patches.
Author
Collaborator

Removed the comment instead, since it will be described from the provenance info.

Removed the comment instead, since it will be described from the provenance info.
fsagbuya marked this conversation as resolved
fsagbuya force-pushed gateware from f19c3d09a4 to dc09533217 2024-02-28 13:26:11 +08:00 Compare
sb10q reviewed 2024-02-28 13:29:45 +08:00
@ -0,0 +1,2359 @@
# Patch containing fast_servo gateware module from:
# https://github.com/elhep/Fast-Servo-Firmware/tree/master/fast_servo/gateware
Owner

What can I say about that?

What can I say about that?
sb10q reviewed 2024-02-28 13:30:46 +08:00
@ -0,0 +1,32 @@
diff --git a/fast_servo/gateware/fast_servo_platform.py b/fast_servo/gateware/fast_servo_platform.py
index 13b4aa3..89a8103 100644
--- a/fast_servo/gateware/fast_servo_platform.py
+++ b/fast_servo/gateware/fast_servo_platform.py
Owner

Why is this not in linien-fast-servo-gateware.patch?

Why is this not in linien-fast-servo-gateware.patch?
fsagbuya marked this conversation as resolved
Owner

The patches still look like a complete mess. Please read again everything that has been said so far and pay attention.

The patches still look like a complete mess. Please read again everything that has been said so far and pay attention.
fsagbuya force-pushed gateware from dc09533217 to 68d0253a8d 2024-02-28 15:29:46 +08:00 Compare
Author
Collaborator

Updates:

  • copy unchanged required files to a dedicated linien-gateware directory, init python scripts excluded and add a README provenance info.
  • clean up the patches, only apply for files that have been modified.

Build log:

3.4M -r--r--r-- 5 root root 3.4M Jan  1  1970 gateware.bin
4.0K dr-xr-xr-x 2 root root 4.0K Jan  1  1970 nix-support
3.4M -r--r--r-- 2 root root 3.4M Jan  1  1970 top.bit
Updates: - copy unchanged [required files ](https://github.com/elhep/linien/commit/b73eea07889dda8b55f0cf4c2afde96cf4c3efd1#diff-fc9f612784d1c62e6f31835025ee8ce21cc1b1820831ea2a2b69e3ece724c505R81)to a dedicated `linien-gateware` directory, init python scripts excluded and add a README provenance info. - clean up the patches, only apply for files that have been modified. Build log: ``` 3.4M -r--r--r-- 5 root root 3.4M Jan 1 1970 gateware.bin 4.0K dr-xr-xr-x 2 root root 4.0K Jan 1 1970 nix-support 3.4M -r--r--r-- 2 root root 3.4M Jan 1 1970 top.bit ```
fsagbuya force-pushed gateware from 68d0253a8d to fe49ff7f57 2024-02-28 17:15:56 +08:00 Compare
sb10q reviewed 2024-02-28 18:07:28 +08:00
@ -0,0 +1,36 @@
# Fix for migen add_source deprecation and removed xilinx bootgen command
# .bin file is being generated by bit2bin.py from Linien repository
Owner

Why do we need the .bin?

Why do we need the .bin?
Author
Collaborator

It seems that is the format supported by the fpga manager when loading gateware inside Linux.

It seems that is the [format supported by the fpga manager](https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841645/Solution+Zynq+PL+Programming+With+FPGA+Manager#SolutionZynqPLProgrammingWithFPGAManager-MissingFeatures,KnownIssuesandLimitations) when loading gateware inside Linux.
Owner

Okay then.

Okay then.
fsagbuya marked this conversation as resolved
sb10q reviewed 2024-02-28 18:08:10 +08:00
sb10q reviewed 2024-02-28 18:10:18 +08:00
flake.nix Outdated
@ -148,0 +214,4 @@
cp gateware/build/top.bit $out
cp linien-server/linien_server/gateware.bin $out
echo file binary-dist $out/top.bit >> $out/nix-support/hydra-build-products
echo file binary-dist $out/gateware.bin >> $out/nix-support/hydra-build-products
Owner

(Assuming we need .bin at all)

(Assuming we need .bin at all)
fsagbuya marked this conversation as resolved
sb10q reviewed 2024-02-28 18:10:25 +08:00
flake.nix Outdated
@ -148,0 +214,4 @@
cp gateware/build/top.bit $out
cp linien-server/linien_server/gateware.bin $out
echo file binary-dist $out/top.bit >> $out/nix-support/hydra-build-products
echo file binary-dist $out/gateware.bin >> $out/nix-support/hydra-build-products
Owner

Why is it top.bit and gateware.bin? Why not top.bin?

Why is it top.bit and gateware.bin? Why not top.bin?
Author
Collaborator

Will rename it as top.bin.

Will rename it as top.bin.
Owner
https://git.m-labs.hk/M-Labs/nix-servo/pulls/37#issuecomment-9150
Author
Collaborator

Okay. Will retain it as is.

Okay. Will retain it as is.
fsagbuya marked this conversation as resolved
sb10q reviewed 2024-02-28 18:11:37 +08:00
flake.nix Outdated
@ -148,0 +212,4 @@
installPhase = ''
mkdir -p $out $out/nix-support
cp gateware/build/top.bit $out
cp linien-server/linien_server/gateware.bin $out
Owner

The directory name inconsistency in these two lines is very suspicious.

The directory name inconsistency in these two lines is very suspicious.
Author
Collaborator

This is linien's default output directory for the bin file. I agree this is suspicious. Will add a patch to use the same directory for the top.bit.

This is [linien's default output directory](https://github.com/elhep/linien/blob/fast_servo_merging/gateware/fpga_image_helper.py#L101-L103) for the bin file. I agree this is suspicious. Will add a patch to use the same directory for the top.bit.
Owner

If this is an upstream issue then fine. Just want to make sure it's understood and not introduced here.

If this is an upstream issue then fine. Just want to make sure it's understood and not introduced here.
fsagbuya marked this conversation as resolved
fsagbuya force-pushed gateware from fe49ff7f57 to bcc12e1007 2024-02-29 12:51:32 +08:00 Compare
sb10q reviewed 2024-02-29 16:14:09 +08:00
flake.nix Outdated
@ -148,0 +193,4 @@
fast-servo-gateware = pkgs.stdenv.mkDerivation rec {
name = "fast-servo-gateware";
inherit (pkgs.python3Packages.linien-common) src;
postUnpack = ''
Owner

Shouldn't this be done in prePatch, not postUnpack?

Shouldn't this be done in prePatch, not postUnpack?
Author
Collaborator

prePatch handles modification on patches attribute. It is selected here since it is only copying the files and not dealing with patches essentially.

prePatch handles modification on `patches` attribute. It is selected here since it is only copying the files and not dealing with patches essentially.
Owner

Where did you get that information from?
https://ryantm.github.io/nixpkgs/stdenv/stdenv/#var-stdenv-prePatch (and IIRC other sources) just say "Hook executed at the start of the patch phase."

Where did you get that information from? https://ryantm.github.io/nixpkgs/stdenv/stdenv/#var-stdenv-prePatch (and IIRC other sources) just say "Hook executed at the start of the patch phase."
Author
Collaborator

Apologies, I maybe pointing to patchPhase not the prePatch. However applying it on prePatch returns a hunk error.

      > --------------------------
       > |diff --git a/fast_servo/gateware/fast_servo_soc.py b/fast_servo/gateware/fast_servo_soc.py
       > |index 02128f5..abfc583 100644
       > |--- a/fast_servo/gateware/fast_servo_soc.py
       > |+++ b/fast_servo/gateware/fast_servo_soc.py
       > --------------------------
       > File to patch:
       > Skip this patch? [y]
       > Skipping patch.
       > 1 out of 1 hunk ignored
Apologies, I maybe pointing to [patchPhase](https://ryantm.github.io/nixpkgs/stdenv/stdenv/#ssec-patch-phase) not the prePatch. However applying it on prePatch returns a hunk error. ``` > -------------------------- > |diff --git a/fast_servo/gateware/fast_servo_soc.py b/fast_servo/gateware/fast_servo_soc.py > |index 02128f5..abfc583 100644 > |--- a/fast_servo/gateware/fast_servo_soc.py > |+++ b/fast_servo/gateware/fast_servo_soc.py > -------------------------- > File to patch: > Skip this patch? [y] > Skipping patch. > 1 out of 1 hunk ignored ```
Owner

Should be fairly easy to debug with ls etc.

Should be fairly easy to debug with ls etc.
Author
Collaborator

Running ls after mkdir -p $sourceRoot/fast_servo/gateware and it does not found the directory:

fast-servo-gateware> source root is source
fast-servo-gateware> Running phase: patchPhase
fast-servo-gateware> CHANGELOG.md  README.md  linien-client     linien-server   source
fast-servo-gateware> CITATION.cff  docs  linien-common  mypy.ini        tests
fast-servo-gateware> LICENSE       gateware      linien-gui     pyproject.toml  version-info.json
Running ls after `mkdir -p $sourceRoot/fast_servo/gateware` and it does not found the directory: ``` fast-servo-gateware> source root is source fast-servo-gateware> Running phase: patchPhase fast-servo-gateware> CHANGELOG.md README.md linien-client linien-server source fast-servo-gateware> CITATION.cff docs linien-common mypy.ini tests fast-servo-gateware> LICENSE gateware linien-gui pyproject.toml version-info.json ```
Owner

As usual please figure out what exactly what is going on and sort it out.

As usual please figure out what exactly what is going on and sort it out.
Author
Collaborator

Converted to prePatch. It does not need the variable sourceRoot now. 👍

Converted to `prePatch`. It does not need the variable `sourceRoot` now. 👍
fsagbuya marked this conversation as resolved
sb10q reviewed 2024-02-29 16:15:01 +08:00
flake.nix Outdated
@ -148,0 +206,4 @@
vivado
];
buildPhase = ''
export HOME=$(mktemp -d)
Owner

You have not answered the question about which part of the build system needs $HOME.

You have not answered the question about which part of the build system needs $HOME.
Author
Collaborator

According to the trace log:

FileNotFoundError: [Errno 2] No such file or directory: '/homeless-shelter/.local/share/linien'

It is found on this part of the build system:
https://github.com/elhep/linien/blob/fast_servo_merging/linien-common/linien_common/config.py#L27

According to the trace log: ``` FileNotFoundError: [Errno 2] No such file or directory: '/homeless-shelter/.local/share/linien' ``` It is found on this part of the build system: https://github.com/elhep/linien/blob/fast_servo_merging/linien-common/linien_common/config.py#L27
Owner

Do we actually need this stuff to build the gateware or can config.py be replaced with an empty/dummy file?

Do we actually need this stuff to build the gateware or can config.py be replaced with an empty/dummy file?
Author
Collaborator

I think it can be replaced with an empty/dummy file, will test and have it added to the patch.

I think it can be replaced with an empty/dummy file, will test and have it added to the patch.
Author
Collaborator

Update: removed the linien-common dependency (which imports config.py) from the gateware build

Update: removed the `linien-common` dependency (which imports `config.py`) from the gateware build
Owner

What exactly did you change?

What exactly did you change?
Author
Collaborator

Added a new commit for the changes. Converted the variables to its actual value in linien_common and config.py, so that we can omit the dependency for this use case.

Added a new commit for the changes. Converted the variables to its actual value in `linien_common` and `config.py`, so that we can omit the dependency for this use case.
Owner

That's much worse than even the one line of code that sets $HOME. I had suggested to edit config.py (and not other files), what is wrong with this approach?

That's much worse than even the one line of code that sets $HOME. I had suggested to edit config.py (and not other files), what is wrong with this approach?
Author
Collaborator

The config.py file that requires modification is part of the linien-common dependency:

nativeBuildInputs = [
          (pkgs.python3.withPackages(ps: [ migen misoc ps.linien-common ]))

To implement the necessary changes, we need to apply an override/overlay for the linien-common package in the upstream. Would this approach be acceptable?

The config.py file that requires modification is part of the linien-common dependency: ``` nativeBuildInputs = [ (pkgs.python3.withPackages(ps: [ migen misoc ps.linien-common ])) ``` To implement the necessary changes, we need to apply an override/overlay for the linien-common package in the upstream. Would this approach be acceptable?
Owner

You can submit a clean patch upstream so building gateware doesn't need config.py/$HOME. And in the meantime something like:

(pkgs.python3.withPackages(ps: [ migen misoc (ps.linien-common.overrideAttrs(oa: {
   # config.py tries to access $HOME, but we do not need it for building gateware
   postPatch = "echo > config.py";  
   doCheck = false;
}))
]))
You can submit a clean patch upstream so building gateware doesn't need config.py/$HOME. And in the meantime something like: ``` (pkgs.python3.withPackages(ps: [ migen misoc (ps.linien-common.overrideAttrs(oa: { # config.py tries to access $HOME, but we do not need it for building gateware postPatch = "echo > config.py"; doCheck = false; })) ])) ```
Author
Collaborator

Updated: Also need to modify the file __init__.py :

    >   File "/nix/store/04nl55kmfkaacbv7vdm18gzhyl586r4r-python3.11-linien-common-1.0.1/lib/python3.11/site-packages/linien_common/__init__.py", line 6, in <module>
       >     from .config import LOG_FILE_PATH
       > ImportError: cannot import name 'LOG_FILE_PATH' from 'linien_common.config'

For this temporary fix, it is also set to an empty file. Other approach is to create a patch that removes related lines to config.py import.

Updated: Also need to modify the [file](https://github.com/linien-org/linien/blob/master/linien-common/linien_common/__init__.py#L6) `__init__.py `: ``` > File "/nix/store/04nl55kmfkaacbv7vdm18gzhyl586r4r-python3.11-linien-common-1.0.1/lib/python3.11/site-packages/linien_common/__init__.py", line 6, in <module> > from .config import LOG_FILE_PATH > ImportError: cannot import name 'LOG_FILE_PATH' from 'linien_common.config' ``` For this temporary fix, it is also set to an empty file. Other approach is to create a patch that removes related lines to config.py import.
Owner

Aaah, the joys of physicist code. Removing the contents of that poorly designed __init__.py sounds fine to me as well.

Aaah, the joys of physicist code. Removing the contents of that poorly designed ``__init__.py`` sounds fine to me as well.
fsagbuya marked this conversation as resolved
sb10q reviewed 2024-02-29 16:18:12 +08:00
@ -0,0 +20,4 @@
new file mode 100644
index 0000000..7c1f7a1
--- /dev/null
+++ b/fast-servo-linien.patch
Owner

?

?
Owner

I don't see a fast-servo-linien.patch in b73eea0788 so this looks like your mistake.

I don't see a fast-servo-linien.patch in https://github.com/elhep/linien/tree/b73eea07889dda8b55f0cf4c2afde96cf4c3efd1 so this looks like your mistake.
Author
Collaborator

It seems I accidentally add that patch during test, apologies. Updated.

It seems I accidentally add that patch during test, apologies. Updated.
fsagbuya marked this conversation as resolved
fsagbuya force-pushed gateware from bcc12e1007 to 9fd509353f 2024-02-29 17:49:48 +08:00 Compare
fsagbuya force-pushed gateware from 9fd509353f to de445b2e65 2024-03-01 11:49:24 +08:00 Compare
sb10q reviewed 2024-03-01 12:04:51 +08:00
flake.nix Outdated
@ -148,0 +195,4 @@
inherit (pkgs.python3Packages.linien-common) src;
prePatch = ''
mkdir -p fast_servo/gateware
cp -r ${./fast-servo/linien-gateware}/. fast_servo/gateware
Owner

/. should be removed I think?

``/.`` should be removed I think?
Author
Collaborator

Removing it will cause it to create a copy of the linien-gateware directory itself and not the contents alone.

ls result:

b535q358y1izxkmd4zfijf51ws9fsrn7-linien-gateware
Removing it will cause it to create a copy of the `linien-gateware` directory itself and not the contents alone. ls result: ``` b535q358y1izxkmd4zfijf51ws9fsrn7-linien-gateware ```
fsagbuya marked this conversation as resolved
fsagbuya force-pushed gateware from de445b2e65 to df6a8233f5 2024-03-01 12:05:36 +08:00 Compare
fsagbuya force-pushed gateware from df6a8233f5 to 71d7fa2271 2024-03-01 12:23:29 +08:00 Compare
fsagbuya force-pushed gateware from 71d7fa2271 to ccdbd67daa 2024-03-01 16:11:59 +08:00 Compare
sb10q reviewed 2024-03-01 16:15:25 +08:00
flake.nix Outdated
@ -148,0 +210,4 @@
'';
doCheck = false;
}))
]))
Owner

Indentation/style. My comment was just a hint, not a textual example.

Indentation/style. My comment was just a hint, not a textual example.
fsagbuya marked this conversation as resolved
fsagbuya force-pushed gateware from ccdbd67daa to ad725ae41b 2024-03-01 16:27:08 +08:00 Compare
sb10q merged commit 007ca18cab into master 2024-03-01 16:39:57 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
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/nix-servo#37
No description provided.