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 spidev
|
||||
from common import (
|
||||
from pyfastservo.common import (
|
||||
ADC_AFE_CTRL_ADDR,
|
||||
ADC_BITSLIP_ADDR,
|
||||
ADC_CH0_HIGH_ADDR,
|
||||
|
|
|
@ -22,8 +22,8 @@ MAP_SIZE = 0x1000
|
|||
MAP_MASK = 0xFFF
|
||||
PAGESIZE = 0x1000
|
||||
|
||||
LINIEN_OFFSET = 0x0
|
||||
# LINIEN_OFFSET = 0x300000
|
||||
# LINIEN_OFFSET = 0x0
|
||||
LINIEN_OFFSET = 0x300000
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# FRONT PANEL LEDS REGISTER ADDRESSES
|
||||
|
|
|
@ -21,7 +21,7 @@ import mmap
|
|||
import os
|
||||
|
||||
import spidev
|
||||
from common import (
|
||||
from pyfastservo.common import (
|
||||
CH0_HIGH_WORD_ADDR,
|
||||
CH0_LOW_WORD_ADDR,
|
||||
CH1_HIGH_WORD_ADDR,
|
||||
|
|
|
@ -21,7 +21,7 @@ import mmap
|
|||
import os
|
||||
import time
|
||||
|
||||
from common import (
|
||||
from pyfastservo.common import (
|
||||
LED0_BASE_ADDR,
|
||||
LED1_BASE_ADDR,
|
||||
LED2_BASE_ADDR,
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import adc
|
||||
import si5340
|
||||
import dac
|
||||
from pyfastservo import adc, si5340, dac
|
||||
|
||||
def main():
|
||||
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 {
|
||||
pname = "mkbootimage";
|
||||
version = "2.3dev";
|
||||
|
@ -210,7 +231,10 @@
|
|||
"${patched-not-os}/zynq_image.nix"
|
||||
] ++ pkgs.lib.optionals (board == "fast-servo") [
|
||||
({ config, pkgs, lib, ... }: {
|
||||
environment.systemPackages = [ linien-server ];
|
||||
environment.systemPackages = [
|
||||
linien-server
|
||||
(pkgs.python3.withPackages(ps: [ pyfastservo ]))
|
||||
];
|
||||
boot.postBootCommands = lib.mkAfter ''
|
||||
|
||||
# Program the FPGA
|
||||
|
@ -220,6 +244,10 @@
|
|||
mkdir -p /lib/firmware
|
||||
cp ${fast-servo-gateware}/gateware.bin /lib/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";
|
||||
|
@ -397,7 +425,7 @@
|
|||
BASE=$(realpath $(dirname $0))
|
||||
|
||||
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
|
||||
# See: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/821854273/Running+Bare+Metal+Applications+on+QEMU
|
||||
|
|
Loading…
Reference in New Issue