====== Testing the Linux Kernel driver for the Lattice iCE40 FPGA ====== Demonstration and testing of the new Linux Kernel driver for the Lattice iCE40 FPGA with sigrok, including an introduction to device-tree and driver development. * [[https://odysee.com/@OpenTechLab:f/otl-002-ice40-linux-kernel-driver:5|odysee]] * [[https://www.youtube.com/watch?v=nIEB1VAGUcs|YouTube]] * [[https://peertube.social/videos/watch/80e5c173-093d-4e5a-981b-1bc0b98f4f2a|peertube.social]] ===== IceStorm FPGA Synthesis Tool-Chain ===== [[http://www.clifford.at/icestorm/]] ===== Patches ===== - [[https://patchwork.kernel.org/patch/9479207/|of: Add vendor prefix for Lattice Semiconductor]] - [[https://patchwork.kernel.org/patch/9479209/|Documentation: Add binding document for Lattice iCE40 FPGA manager]] - [[https://patchwork.kernel.org/patch/9479211/|fpga: Add support for Lattice iCE40 FPGAs]] ===== Device Tree ===== [[https://github.com/raspberrypi/linux/blob/rpi-4.4.y/arch/arm/boot/dts/bcm2708-rpi-b.dts|Raspberry Pi Device Tree]] ==== Overlay ==== /dts-v1/; /plugin/; / { compatible="brcm,bcm2708"; fragment@0 { target = <&spi0>; __overlay__ { status = "okay"; spidev@0 { status = "disabled"; }; spidev@1 { status = "disabled"; }; }; }; fragment@1 { target = <&spi0>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; ice40: ice40@0 { compatible = "lattice,ice40-fpga-mgr"; reg = <0>; spi-max-frequency = <10000000>; cdone-gpios = <&gpio 24 0>; reset-gpios = <&gpio 22 1>; }; }; }; }; ==== Test Firmware ==== === Makefile === outdir=_out/ src= synthesize: $(outdir)counter.bin $(outdir)counter.bin: counter.v counter.pcf $(src) mkdir -p $(outdir) yosys -q -p "synth_ice40 -blif $(outdir)counter.blif" counter.v $(src) arachne-pnr -d 8k -p counter.pcf $(outdir)counter.blif -o $(outdir)counter.txt icepack $(outdir)counter.txt $(outdir)counter.bin .PHONY: synthesize === counter.v === module top(input ref_12mhz, output test1, output test2, output [7:0] leds); reg [23:0] counter = 0; always @(posedge ref_12mhz) counter <= counter + 1; assign leds[0:7] = counter[16:23]; assign test1 = counter[4]; assign test2 = !counter[4]; endmodule === counter.pcf === set_io ref_12mhz J3 set_io test1 M1 set_io test2 M2 set_io leds[0] B5 set_io leds[1] B4 set_io leds[2] A2 set_io leds[3] A1 set_io leds[4] C5 set_io leds[5] C4 set_io leds[6] B3 set_io leds[7] C3 ===== Credits ===== * Intro Music: [[http://freemusicarchive.org/music/Logan_Takahashi/Live_at_WFMU_on_Champ_Sound_with_DJ_Guy_4282016/|Logan Takashi - Orb-O]] (CC-BY-NC-ND). ===== Around the Web ===== * [[https://hackaday.com/2017/04/13/lattice-ice40-fpga-configured-by-linux-kernel/|HackADay Article]]