forked from M-Labs/nix-servo
add pyfastservo package and initialize at boot
This commit is contained in:
parent
e08897acce
commit
cc0879fcb0
|
@ -21,7 +21,7 @@ import mmap
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import spidev
|
import spidev
|
||||||
from common import (
|
from pyfastservo.common import (
|
||||||
ADC_AFE_CTRL_ADDR,
|
ADC_AFE_CTRL_ADDR,
|
||||||
ADC_BITSLIP_ADDR,
|
ADC_BITSLIP_ADDR,
|
||||||
ADC_CH0_HIGH_ADDR,
|
ADC_CH0_HIGH_ADDR,
|
||||||
|
|
|
@ -22,8 +22,8 @@ MAP_SIZE = 0x1000
|
||||||
MAP_MASK = 0xFFF
|
MAP_MASK = 0xFFF
|
||||||
PAGESIZE = 0x1000
|
PAGESIZE = 0x1000
|
||||||
|
|
||||||
LINIEN_OFFSET = 0x0
|
# LINIEN_OFFSET = 0x0
|
||||||
# LINIEN_OFFSET = 0x300000
|
LINIEN_OFFSET = 0x300000
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
# FRONT PANEL LEDS REGISTER ADDRESSES
|
# FRONT PANEL LEDS REGISTER ADDRESSES
|
||||||
|
|
|
@ -21,7 +21,7 @@ import mmap
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import spidev
|
import spidev
|
||||||
from common import (
|
from pyfastservo.common import (
|
||||||
CH0_HIGH_WORD_ADDR,
|
CH0_HIGH_WORD_ADDR,
|
||||||
CH0_LOW_WORD_ADDR,
|
CH0_LOW_WORD_ADDR,
|
||||||
CH1_HIGH_WORD_ADDR,
|
CH1_HIGH_WORD_ADDR,
|
||||||
|
|
|
@ -21,7 +21,7 @@ import mmap
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from common import (
|
from pyfastservo.common import (
|
||||||
LED0_BASE_ADDR,
|
LED0_BASE_ADDR,
|
||||||
LED1_BASE_ADDR,
|
LED1_BASE_ADDR,
|
||||||
LED2_BASE_ADDR,
|
LED2_BASE_ADDR,
|
||||||
|
|
|
@ -17,9 +17,7 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import adc
|
from pyfastservo import adc, si5340, dac
|
||||||
import si5340
|
|
||||||
import dac
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
si5340.configure_si5340()
|
si5340.configure_si5340()
|
||||||
|
|
32
flake.nix
32
flake.nix
|
@ -180,6 +180,27 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pyfastservo = pkgs-armv7l.python3Packages.buildPythonPackage rec {
|
||||||
|
name = "pyfastservo";
|
||||||
|
src = ./fast-servo;
|
||||||
|
preBuild = ''
|
||||||
|
cat > setup.py << EOF
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="pyfastservo",
|
||||||
|
packages=["pyfastservo"],
|
||||||
|
install_requires=["spidev", "smbus2"],
|
||||||
|
entry_points = {"console_scripts": ["fp_leds=pyfastservo.fp_leds:main"]},
|
||||||
|
)
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
propagatedBuildInputs = with pkgs-armv7l.python3Packages; [
|
||||||
|
spidev
|
||||||
|
smbus2
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
mkbootimage = pkgs.stdenv.mkDerivation {
|
mkbootimage = pkgs.stdenv.mkDerivation {
|
||||||
pname = "mkbootimage";
|
pname = "mkbootimage";
|
||||||
version = "2.3dev";
|
version = "2.3dev";
|
||||||
|
@ -210,7 +231,10 @@
|
||||||
"${patched-not-os}/zynq_image.nix"
|
"${patched-not-os}/zynq_image.nix"
|
||||||
] ++ pkgs.lib.optionals (board == "fast-servo") [
|
] ++ pkgs.lib.optionals (board == "fast-servo") [
|
||||||
({ config, pkgs, lib, ... }: {
|
({ config, pkgs, lib, ... }: {
|
||||||
environment.systemPackages = [ linien-server ];
|
environment.systemPackages = [
|
||||||
|
linien-server
|
||||||
|
(pkgs.python3.withPackages(ps: [ pyfastservo ]))
|
||||||
|
];
|
||||||
boot.postBootCommands = lib.mkAfter ''
|
boot.postBootCommands = lib.mkAfter ''
|
||||||
|
|
||||||
# Program the FPGA
|
# Program the FPGA
|
||||||
|
@ -220,6 +244,10 @@
|
||||||
mkdir -p /lib/firmware
|
mkdir -p /lib/firmware
|
||||||
cp ${fast-servo-gateware}/gateware.bin /lib/firmware/
|
cp ${fast-servo-gateware}/gateware.bin /lib/firmware/
|
||||||
echo gateware.bin > /sys/class/fpga_manager/fpga0/firmware
|
echo gateware.bin > /sys/class/fpga_manager/fpga0/firmware
|
||||||
|
|
||||||
|
# Run device init scripts
|
||||||
|
echo "Initializing clock generator, ADC, and DAC..."
|
||||||
|
python3 -m pyfastservo.initialize
|
||||||
'';
|
'';
|
||||||
})];
|
})];
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
|
@ -397,7 +425,7 @@
|
||||||
BASE=$(realpath $(dirname $0))
|
BASE=$(realpath $(dirname $0))
|
||||||
|
|
||||||
qemu-img convert -O qcow2 -f raw -o preallocation=metadata $BASE/sd-image.img $IMGDIR/sd-sparse.qcow2
|
qemu-img convert -O qcow2 -f raw -o preallocation=metadata $BASE/sd-image.img $IMGDIR/sd-sparse.qcow2
|
||||||
qemu-img create -F qcow2 -f qcow2 -b $IMGDIR/sd-sparse.qcow2 $IMGDIR/sd-overlay.qcow2 1G
|
qemu-img create -F qcow2 -f qcow2 -b $IMGDIR/sd-sparse.qcow2 $IMGDIR/sd-overlay.qcow2 2G
|
||||||
|
|
||||||
# Some command arguments are based from samples in Xilinx QEMU User Documentation
|
# Some command arguments are based from samples in Xilinx QEMU User Documentation
|
||||||
# See: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/821854273/Running+Bare+Metal+Applications+on+QEMU
|
# See: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/821854273/Running+Bare+Metal+Applications+on+QEMU
|
||||||
|
|
Loading…
Reference in New Issue