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
Showing only changes of commit ad725ae41b - Show all commits

View File

@ -202,11 +202,20 @@
fast-servo/linien-fast-servo-server.patch
];
fsagbuya marked this conversation as resolved Outdated
Outdated
Review

To which patch does this commit refer to?

To which patch does this commit refer to?
Outdated
Review

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

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

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.

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.
nativeBuildInputs = [
(pkgs.python3.withPackages(ps: [ migen misoc ps.linien-common ]))
(pkgs.python3.withPackages(ps: [
migen misoc
(ps.linien-common.overrideAttrs(oa: {
fsagbuya marked this conversation as resolved Outdated
Outdated
Review

What needs that?

What needs that?

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' ```
Outdated
Review

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.
# config.py tries to access $HOME, but we do not need it for building gateware
postPatch = ''
fsagbuya marked this conversation as resolved Outdated
Outdated
Review

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.

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
Outdated
Review

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?

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.

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
Outdated
Review

What exactly did you change?

What exactly did you change?

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.
Outdated
Review

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?

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?
Outdated
Review

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; })) ])) ```

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.
Outdated
Review

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.
echo > linien_common/config.py
echo > linien_common/__init__.py
'';
doCheck = false;
fsagbuya marked this conversation as resolved Outdated
Outdated
Review

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 Outdated
Outdated
Review

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

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

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.
Outdated
Review

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.
vivado
];
fsagbuya marked this conversation as resolved Outdated
Outdated
Review

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

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

(Assuming we need .bin at all)

(Assuming we need .bin at all)

Will rename it as top.bin.

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

Okay. Will retain it as is.

Okay. Will retain it as is.
buildPhase = ''
export HOME=$(mktemp -d)
python -m gateware.fpga_image_helper -p fastservo
'';
installPhase = ''