Compare commits

...

3 Commits

4 changed files with 58 additions and 42 deletions

22
flake.lock generated
View File

@ -18,16 +18,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1709237383,
"narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=",
"lastModified": 1719838683,
"narHash": "sha256-Zw9rQjHz1ilNIimEXFeVa1ERNRBF8DoXDhLAZq5B4pE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8",
"rev": "d032c1a6dfad4eedec7e35e91986becc699d7d69",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
@ -64,11 +64,11 @@
"src-migen": {
"flake": false,
"locked": {
"lastModified": 1702942348,
"narHash": "sha256-gKIfHZxsv+jcgDFRW9mPqmwqbZXuRvXefkZcSFjOGHw=",
"lastModified": 1715484909,
"narHash": "sha256-4DCHBUBfc/VA+7NW2Hr0+JP4NnKPru2uVJyZjCCk0Ws=",
"owner": "m-labs",
"repo": "migen",
"rev": "50934ad10a87ade47219b796535978b9bdf24023",
"rev": "4790bb577681a8c3a8d226bc196a4e5deb39e4df",
"type": "github"
},
"original": {
@ -80,11 +80,11 @@
"src-misoc": {
"flake": false,
"locked": {
"lastModified": 1699352904,
"narHash": "sha256-SglyTmXOPv8jJOjwAjJrj/WhAkItQfUbvKfUqrynwRg=",
"lastModified": 1715647536,
"narHash": "sha256-q+USDcaKHABwW56Jzq8u94iGPWlyLXMyVt0j/Gyg+IE=",
"ref": "refs/heads/master",
"rev": "a53859f2167c31ab5225b6c09f30cf05527b94f4",
"revCount": 2452,
"rev": "fea9de558c730bc394a5936094ae95bb9d6fa726",
"revCount": 2455,
"submodules": true,
"type": "git",
"url": "https://github.com/m-labs/misoc.git"

View File

@ -1,7 +1,7 @@
{
description = "Firmware for Sinara Fast-Servo based on Not-OS and Linien";
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-24.05;
inputs.not-os.url = github:cleverca22/not-os;
inputs.not-os.inputs.nixpkgs.follows = "nixpkgs";

View File

@ -1,5 +1,5 @@
diff --git a/base.nix b/base.nix
index 7eaee32..3a2a0a9 100644
index 7eaee32..3ade454 100644
--- a/base.nix
+++ b/base.nix
@@ -27,6 +27,11 @@ with lib;
@ -14,9 +14,12 @@ index 7eaee32..3a2a0a9 100644
not-os.simpleStaticIp = mkOption {
type = types.bool;
default = false;
@@ -86,15 +91,25 @@ with lib;
@@ -84,17 +89,27 @@ with lib;
};
environment.etc = {
"nix/nix.conf".source = pkgs.runCommand "nix.conf" {} ''
extraPaths=$(for i in $(cat ${pkgs.writeReferencesToFile pkgs.runtimeShell}); do if test -d $i; then echo $i; fi; done)
- extraPaths=$(for i in $(cat ${pkgs.writeReferencesToFile pkgs.runtimeShell}); do if test -d $i; then echo $i; fi; done)
+ extraPaths=$(for i in $(cat ${pkgs.writeClosure [ pkgs.bash ]}); do if test -d $i; then echo $i; fi; done)
cat > $out << EOF
- build-use-sandbox = true
+ auto-optimise-store = true
@ -151,7 +154,7 @@ index c61f9d6..fbdf0fd 100644
};
}
diff --git a/zynq_image.nix b/zynq_image.nix
index 3fa23ab..9d1621e 100644
index 3fa23ab..d5c5eda 100644
--- a/zynq_image.nix
+++ b/zynq_image.nix
@@ -1,66 +1,89 @@
@ -163,7 +166,7 @@ index 3fa23ab..9d1621e 100644
- # dont use overlays for the qemu, it causes a lot of wasted time on recompiles
- x86pkgs = import pkgs.path { system = "x86_64-linux"; };
- customKernel = pkgs.linux.override {
+ customKernel = (pkgs.linux.override {
+ customKernel = (pkgs.linux_6_6.override {
extraConfig = ''
OVERLAY_FS y
+ MEDIA_SUPPORT n

View File

@ -394,10 +394,10 @@ index 0000000..53c5349
\ No newline at end of file
diff --git a/xilinx-fpga-manager.patch b/xilinx-fpga-manager.patch
new file mode 100644
index 0000000..59aa585
index 0000000..33daffe
--- /dev/null
+++ b/xilinx-fpga-manager.patch
@@ -0,0 +1,663 @@
@@ -0,0 +1,676 @@
+# Enable user-space interface for PL programming via Linux FPGA manager
+# diff cherry-picked from Xilinx/linux-xilinx/tree/xlnx_rebase_v6.6_LTS
+# commit IDs: e61c0a9, 0a38712, dc67651, 89a24e3, 8d224b1, 2a9c05f, 4e94580
@ -425,7 +425,7 @@ index 0000000..59aa585
+ tristate "Altera SOCFPGA FPGA Manager"
+ depends on ARCH_INTEL_SOCFPGA || COMPILE_TEST
+diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
+index 06651389c592..6e8c45974f28 100644
+index 0f4035b089a2..3aa9f5f041f6 100644
+--- a/drivers/fpga/fpga-mgr.c
++++ b/drivers/fpga/fpga-mgr.c
+@@ -8,6 +8,9 @@
@ -673,7 +673,7 @@ index 0000000..59aa585
+ NULL,
+ };
+ ATTRIBUTE_GROUPS(fpga_mgr);
+@@ -732,6 +864,106 @@ void fpga_mgr_put(struct fpga_manager *mgr)
+@@ -739,6 +871,106 @@ void fpga_mgr_put(struct fpga_manager *mgr)
+ }
+ EXPORT_SYMBOL_GPL(fpga_mgr_put);
+
@ -780,8 +780,8 @@ index 0000000..59aa585
+ /**
+ * fpga_mgr_lock - Lock FPGA manager for exclusive use
+ * @mgr: fpga manager
+@@ -779,6 +1011,9 @@ struct fpga_manager *
+ fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info)
+@@ -788,6 +1020,9 @@ __fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *
+ struct module *owner)
+ {
+ const struct fpga_manager_ops *mops = info->mops;
++#ifdef CONFIG_FPGA_MGR_DEBUG_FS
@ -790,7 +790,7 @@ index 0000000..59aa585
+ struct fpga_manager *mgr;
+ int id, ret;
+
+@@ -815,10 +1050,28 @@ fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *in
+@@ -826,10 +1061,28 @@ __fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *
+ mgr->dev.of_node = parent->of_node;
+ mgr->dev.id = id;
+
@ -819,7 +819,7 @@ index 0000000..59aa585
+ /*
+ * Initialize framework state by requesting low level driver read state
+ * from device. FPGA may be in reset mode or may have been programmed
+@@ -832,6 +1085,28 @@ fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *in
+@@ -843,6 +1096,28 @@ __fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *
+ return ERR_PTR(ret);
+ }
+
@ -848,7 +848,7 @@ index 0000000..59aa585
+ return mgr;
+
+ error_device:
+@@ -882,6 +1157,10 @@ void fpga_mgr_unregister(struct fpga_manager *mgr)
+@@ -894,6 +1169,10 @@ void fpga_mgr_unregister(struct fpga_manager *mgr)
+ {
+ dev_info(&mgr->dev, "%s %s\n", __func__, mgr->name);
+
@ -881,10 +881,10 @@ index 0000000..59aa585
+ &firmware_name)) {
+ info->firmware_name = devm_kstrdup(dev, firmware_name,
+diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
+index f3434e2c487b..db923746cac5 100644
+index f3434e2c487b..d2434ed85eff 100644
+--- a/drivers/fpga/zynqmp-fpga.c
++++ b/drivers/fpga/zynqmp-fpga.c
+@@ -43,25 +43,42 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr,
+@@ -43,25 +43,47 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr,
+ struct zynqmp_fpga_priv *priv;
+ dma_addr_t dma_addr;
+ u32 eemi_flags = 0;
@ -915,6 +915,11 @@ index 0000000..59aa585
++
+ wmb(); /* ensure all writes are done before initiate FW call */
+
++ if (priv->flags & FPGA_MGR_DDR_MEM_AUTH_BITSTREAM)
++ eemi_flags |= XILINX_ZYNQMP_PM_FPGA_AUTHENTICATION_DDR;
++ else if (priv->flags & FPGA_MGR_SECURE_MEM_AUTH_BITSTREAM)
++ eemi_flags |= XILINX_ZYNQMP_PM_FPGA_AUTHENTICATION_OCM;
++
+ if (priv->flags & FPGA_MGR_PARTIAL_RECONFIG)
+ eemi_flags |= XILINX_ZYNQMP_PM_FPGA_PARTIAL;
+
@ -931,20 +936,22 @@ index 0000000..59aa585
+ return ret;
+ }
+diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
+index 9dda7d9898ff..edaf77160746 100644
+index e8b12ec8b060..ffd2dfdb6abd 100644
+--- a/include/linux/firmware/xlnx-zynqmp.h
++++ b/include/linux/firmware/xlnx-zynqmp.h
+@@ -70,6 +70,8 @@
+@@ -83,6 +83,10 @@
+ */
+ #define XILINX_ZYNQMP_PM_FPGA_FULL 0x0U
+ #define XILINX_ZYNQMP_PM_FPGA_PARTIAL BIT(0)
++#define XILINX_ZYNQMP_PM_FPGA_AUTHENTICATION_DDR BIT(1)
++#define XILINX_ZYNQMP_PM_FPGA_AUTHENTICATION_OCM BIT(2)
++#define XILINX_ZYNQMP_PM_FPGA_ENCRYPTION_USERKEY BIT(3)
++#define XILINX_ZYNQMP_PM_FPGA_ENCRYPTION_DEVKEY BIT(4)
+
+ /* FPGA Status Reg */
+ #define XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET 7U
+diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
+index 54f63459efd6..c96a4405f909 100644
+index 0d4fe068f3d8..f884d268c974 100644
+--- a/include/linux/fpga/fpga-mgr.h
++++ b/include/linux/fpga/fpga-mgr.h
+@@ -9,8 +9,11 @@
@ -959,7 +966,7 @@ index 0000000..59aa585
+ struct fpga_manager;
+ struct sg_table;
+
+@@ -66,17 +69,25 @@ enum fpga_mgr_states {
+@@ -66,17 +69,29 @@ enum fpga_mgr_states {
+ *
+ * %FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting
+ *
@ -973,6 +980,10 @@ index 0000000..59aa585
++ *
++ * %FPGA_MGR_USERKEY_ENCRYPTED_BITSTREAM: indicates bitstream is encrypted with
++ * user key
++ * %FPGA_MGR_DDR_MEM_AUTH_BITSTREAM: do bitstream authentication using DDR
++ * memory if supported
++ * %FPGA_MGR_SECURE_MEM_AUTH_BITSTREAM: do bitstream authentication using secure
++ * memory if supported
+ */
+ #define FPGA_MGR_PARTIAL_RECONFIG BIT(0)
+ #define FPGA_MGR_EXTERNAL_CONFIG BIT(1)
@ -986,7 +997,7 @@ index 0000000..59aa585
+
+ /**
+ * struct fpga_image_info - information specific to an FPGA image
+@@ -86,6 +97,7 @@ enum fpga_mgr_states {
+@@ -86,6 +101,7 @@ enum fpga_mgr_states {
+ * @config_complete_timeout_us: maximum time for FPGA to switch to operating
+ * status in the write_complete op.
+ * @firmware_name: name of FPGA image firmware file
@ -994,7 +1005,7 @@ index 0000000..59aa585
+ * @sgt: scatter/gather table containing FPGA image
+ * @buf: contiguous buffer containing FPGA image
+ * @count: size of buf
+@@ -102,6 +114,7 @@ struct fpga_image_info {
+@@ -102,6 +118,7 @@ struct fpga_image_info {
+ u32 disable_timeout_us;
+ u32 config_complete_timeout_us;
+ char *firmware_name;
@ -1002,7 +1013,7 @@ index 0000000..59aa585
+ struct sg_table *sgt;
+ const char *buf;
+ size_t count;
+@@ -160,6 +173,7 @@ struct fpga_manager_info {
+@@ -160,6 +177,7 @@ struct fpga_manager_info {
+ * @write: write count bytes of configuration data to the FPGA
+ * @write_sg: write the scatter list of configuration data to the FPGA
+ * @write_complete: set FPGA to operating state after writing is done
@ -1010,7 +1021,7 @@ index 0000000..59aa585
+ * @fpga_remove: optional: Set FPGA into a specific state during driver remove
+ * @groups: optional attribute groups.
+ *
+@@ -182,6 +196,7 @@ struct fpga_manager_ops {
+@@ -182,6 +200,7 @@ struct fpga_manager_ops {
+ int (*write_sg)(struct fpga_manager *mgr, struct sg_table *sgt);
+ int (*write_complete)(struct fpga_manager *mgr,
+ struct fpga_image_info *info);
@ -1018,7 +1029,7 @@ index 0000000..59aa585
+ void (*fpga_remove)(struct fpga_manager *mgr);
+ const struct attribute_group **groups;
+ };
+@@ -196,21 +211,35 @@ struct fpga_manager_ops {
+@@ -196,23 +215,37 @@ struct fpga_manager_ops {
+ /**
+ * struct fpga_manager - fpga manager structure
+ * @name: name of low level fpga manager
@ -1031,6 +1042,7 @@ index 0000000..59aa585
+ * @state: state of fpga manager
+ * @compat_id: FPGA manager id for compatibility check.
+ * @mops: pointer to struct of fpga manager ops
+ * @mops_owner: module containing the mops
+ * @priv: low level driver private date
++ * @err: low level driver error code
++ * @dir: debugfs image directory
@ -1046,6 +1058,7 @@ index 0000000..59aa585
+ enum fpga_mgr_states state;
+ struct fpga_compat_id *compat_id;
+ const struct fpga_manager_ops *mops;
+ struct module *mops_owner;
+ void *priv;
++ int err;
++#ifdef CONFIG_FPGA_MGR_DEBUG_FS
@ -1054,21 +1067,21 @@ index 0000000..59aa585
+ };
+
+ #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev)
+@@ -244,4 +273,6 @@ struct fpga_manager *
+ devm_fpga_mgr_register(struct device *parent, const char *name,
+ const struct fpga_manager_ops *mops, void *priv);
+@@ -258,4 +291,6 @@ __devm_fpga_mgr_register(struct device *parent, const char *name,
+ const struct fpga_manager_ops *mops, void *priv,
+ struct module *owner);
+
++#define FPGA_IOCTL_LOAD_DMA_BUFF _IOWR('R', 1, __u32)
++
+ #endif /*_LINUX_FPGA_MGR_H */
diff --git a/zynq_image.nix b/zynq_image.nix
index 9d1621e..012e50c 100644
index d5c5eda..7ede584 100644
--- a/zynq_image.nix
+++ b/zynq_image.nix
@@ -3,6 +3,16 @@
with lib;
let
customKernel = (pkgs.linux.override {
customKernel = (pkgs.linux_6_6.override {
+ kernelPatches = [
+ ({
+ name = "xilinx-configfs-overlays";