├── .github └── autolabeler.yml ├── .gitignore ├── .gitmodules ├── .travis.yml ├── .travis ├── add-local-submodule.sh ├── build.sh ├── copy-files.py ├── download-prebuilt.sh ├── download-xilinx.sh ├── fixup-git.sh ├── generate-prebuilt-list.py ├── package-xilinx-cluefs-filter.py ├── package-xilinx-filter-strace.py ├── package-xilinx-step1-trace.sh ├── package-xilinx-step2-create-tar.sh ├── package-xilinx-step3-upload.sh ├── prevent-condarc.sh ├── run-make-gateware-filter.py ├── run-make-gateware-suppression.regex ├── run.inc.sh ├── setup.sh └── update-prebuilt-list.sh ├── AUTHORS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── doc ├── architecture.dia ├── architecture.png ├── arty_sch.pdf ├── enjoy_digital.png ├── front_panel.jpg ├── litex_oled.bmp ├── netv2_schematic.pdf ├── nexys_video_rm.pdf ├── nexys_video_sch.pdf ├── notes.md ├── numato_opsis_schematic.pdf ├── powered_by_migen.png ├── targets.md └── tofe_low_speed_io.pdf ├── firmware ├── Makefile ├── asm.h ├── bist.c ├── bist.h ├── ci.c ├── ci.h ├── config.c ├── config.h ├── edid.c ├── edid.h ├── encoder.c ├── encoder.h ├── etherbone.c ├── etherbone.h ├── ethernet.c ├── ethernet.h ├── extra-flags.h ├── flash.c ├── flash.h ├── framebuffer.h ├── fx2.c ├── fx2.h ├── fx2_fw_hdmi2usb.c ├── fx2_fw_usbjtag.c ├── hdmi_in.sh ├── hdmi_in0.c ├── hdmi_in0.h ├── hdmi_out0.c ├── hdmi_out0.h ├── hdmi_out1.c ├── hdmi_out1.h ├── heartbeat.c ├── heartbeat.h ├── i2c.c ├── i2c.h ├── isr.c ├── linker-ctr.ld ├── linker-xip.ld ├── main.c ├── mdio.c ├── mdio.h ├── mmcm.c ├── mmcm.h ├── oled.c ├── oled.h ├── opsis_eeprom.c ├── opsis_eeprom.h ├── opsis_i2c.h ├── pattern.c ├── pattern.h ├── pattern.py ├── pll.c ├── pll.h ├── processor.c ├── processor.h ├── reboot.c ├── reboot.h ├── stdio_wrap.c ├── stdio_wrap.h ├── stub │ ├── Makefile │ ├── isr.c │ ├── linker.ld │ └── main.c ├── telnet.c ├── telnet.h ├── tofe_eeprom.c ├── tofe_eeprom.h ├── uip │ ├── Makefile │ ├── Makefile.mk │ ├── clock-arch.c │ ├── clock-arch.h │ ├── contiki-conf.h │ ├── liteethmac-drv.c │ ├── liteethmac-drv.h │ ├── rtimer-arch.c │ └── rtimer-arch.h ├── uptime.c ├── uptime.h ├── version.c ├── version.h ├── version_data.py └── version_data.sh ├── flash.py ├── gateware ├── __init__.py ├── cas.py ├── encoder │ ├── __init__.py │ ├── core.py │ ├── verilog │ │ └── wb_async_reg.v │ └── vhdl │ │ ├── AC_CR_ROM.vhd │ │ ├── AC_ROM.vhd │ │ ├── ByteStuffer.vhd │ │ ├── CtrlSM.vhd │ │ ├── DBUFCTL.vhd │ │ ├── DCT1D.vhd │ │ ├── DCT2D.vhd │ │ ├── DC_CR_ROM.vhd │ │ ├── DC_ROM.vhd │ │ ├── DoubleFifo.vhd │ │ ├── FDCT.vhd │ │ ├── FIFO.vhd │ │ ├── HeaderRAM.v │ │ ├── HostIF.vhd │ │ ├── Huffman.vhd │ │ ├── JFIFGen.vhd │ │ ├── JPEG_PKG.vhd │ │ ├── JpegEnc.vhd │ │ ├── MDCT.vhd │ │ ├── MDCT_PKG.vhd │ │ ├── OutMux.vhd │ │ ├── QUANTIZER.vhd │ │ ├── QUANT_TOP.vhd │ │ ├── RAM.vhd │ │ ├── RAMZ.vhd │ │ ├── RLE.vhd │ │ ├── RLE_TOP.vhd │ │ ├── ROME.vhd │ │ ├── ROMO.vhd │ │ ├── ROMR.vhd │ │ ├── RleDoubleFifo.vhd │ │ ├── SUB_RAMZ.vhd │ │ ├── SingleSM.vhd │ │ ├── ZIGZAG.vhd │ │ ├── ZZ_TOP.vhd │ │ ├── header.hex │ │ └── r_divider.vhd ├── firmware.py ├── freq_measurement.py ├── i2c.py ├── ice40.py ├── info │ ├── __init__.py │ ├── dna.py │ ├── git.py │ ├── platform.py │ └── xadc.py ├── led.py ├── memtest.py ├── oled.py ├── opsis_i2c.py ├── pwm.py ├── rgmii_if.vhd ├── s6rgmii.py ├── shared_uart.py ├── spi_flash.py ├── streamer │ ├── __init__.py │ ├── core.py │ ├── rtp.py │ └── vhdl │ │ └── fx2_jpeg_streamer.vhd └── tofe.py ├── getting-started.md ├── load.py ├── make.py ├── mkimage.py ├── platforms ├── __init__.py ├── arty.py ├── atlys.py ├── basys3.py ├── cmod_a7.py ├── galatea.py ├── ice40_hx8k_b_evn.py ├── ice40_up5k_b_evn.py ├── icebreaker.py ├── mimas_a7.py ├── mimasv2.py ├── minispartan6.py ├── neso.py ├── nexys_video.py ├── opsis.py ├── picoevb.py ├── pipistrello.py ├── saturn.py ├── sim.py ├── tinyfpga_bx.py ├── tofe_axiom.py ├── tofe_lowspeedio.py ├── upduino_v1.py └── waxwing.py ├── scripts ├── README.md ├── bootstrap.sh ├── build-common.sh ├── build-linux.sh ├── build-micropython.sh ├── build-qemu.sh ├── build-renode.sh ├── build-zephyr.sh ├── check-firmware-newlines.sh ├── debian-setup.sh ├── download-env.sh ├── download-prebuilt.sh ├── enter-env.sh ├── makefile-cache.sh ├── reset-usb.sh ├── settings.sh └── view-hdmi2usb.sh ├── software └── pcie │ ├── kernel │ ├── Makefile │ ├── README │ ├── config.h │ ├── flags.h │ ├── init.sh │ ├── litepcie.h │ └── main.c │ └── user │ ├── Makefile │ ├── cutils.h │ ├── litepcie_lib.c │ ├── litepcie_lib.h │ └── litepcie_util.c ├── targets ├── __init__.py ├── arty │ ├── Makefile.mk │ ├── base.py │ └── net.py ├── atlys │ ├── Makefile.mk │ ├── base.py │ ├── hdmi2usb.py │ ├── net.py │ └── video.py ├── basys3 │ ├── Makefile.mk │ └── base.py ├── cmod_a7 │ ├── Makefile.mk │ └── base.py ├── common │ ├── cpu_interface.py │ └── openocd.mk ├── galatea │ ├── Makefile.mk │ └── base.py ├── ice40_hx8k_b_evn │ ├── Makefile.mk │ └── base.py ├── ice40_up5k_b_evn │ ├── Makefile.mk │ ├── base.py │ └── bridge.py ├── icebreaker │ ├── Makefile.mk │ └── base.py ├── mimas_a7 │ ├── Makefile.mk │ ├── base.py │ ├── bridge_net.py │ ├── net.py │ └── video.py ├── mimasv2 │ ├── Makefile.mk │ ├── base.py │ └── scope.py ├── minispartan6 │ ├── Makefile.mk │ └── base.py ├── neso │ ├── Makefile.mk │ └── base.py ├── nexys_video │ ├── Makefile.mk │ ├── base.py │ ├── net.py │ └── video.py ├── opsis │ ├── Makefile.mk │ ├── __init__.py │ ├── axiom.py │ ├── base.py │ ├── encoder.py │ ├── hdmi2usb.py │ ├── net.py │ └── video.py ├── pipistrello │ ├── Makefile.mk │ └── base.py ├── saturn │ ├── Makefile.mk │ └── base.py ├── sim │ ├── Makefile.mk │ ├── __init__.py │ ├── base.py │ ├── memtest.py │ ├── net.py │ └── video.py ├── tinyfpga_bx │ ├── Makefile.mk │ └── base.py ├── upduino_v1 │ ├── Makefile.mk │ └── base.py ├── utils.py └── waxwing │ ├── Makefile.mk │ └── base.py ├── test ├── check_csrs.py ├── common.py ├── edid │ ├── Makefile │ └── edid_test.c ├── edid_debug │ ├── make.py │ ├── test_la.py │ └── test_regs.py ├── hdmi2ethernet │ ├── captures │ │ └── .keep_me │ ├── make.py │ ├── test_capture.py │ ├── test_dump.py │ ├── test_regs.py │ └── test_sdram.py ├── ipython_etherbone.py ├── load_pattern.py ├── test_alignment.py ├── test_analyzer.py ├── test_axiom.py ├── test_ddr3.py ├── test_delays.py ├── test_dump.py ├── test_etherbone.py ├── test_hdmi_out.py ├── test_leds.py ├── test_memtest.py ├── test_sdram.py ├── test_sdram_bist.py └── test_xadc.py └── third_party ├── libuip ├── contiki-default-conf.h ├── contiki-lib.h ├── contiki-net.h ├── contiki-version.h ├── contiki.h ├── dev │ └── radio.h ├── lib │ ├── aes-128.c │ ├── aes-128.h │ ├── assert.c │ ├── assert.h │ ├── crc16.c │ ├── crc16.h │ ├── gcr.c │ ├── gcr.h │ ├── ifft.c │ ├── ifft.h │ ├── list.c │ ├── list.h │ ├── me.c │ ├── me.h │ ├── me_tabs.c │ ├── me_tabs.h │ ├── memb.c │ ├── memb.h │ ├── mmem.c │ ├── mmem.h │ ├── petsciiconv.c │ ├── petsciiconv.h │ ├── print-stats.c │ ├── print-stats.h │ ├── random.c │ ├── random.h │ ├── ringbuf.c │ ├── ringbuf.h │ ├── sensors.c │ ├── sensors.h │ ├── settings.c │ ├── settings.h │ ├── strncasecmp │ │ └── strncasecmp.c │ ├── trickle-timer.c │ └── trickle-timer.h ├── net │ ├── ip │ │ ├── dhcpc.c │ │ ├── dhcpc.h │ │ ├── psock.c │ │ ├── psock.h │ │ ├── resolv.c │ │ ├── resolv.h │ │ ├── simple-udp.c │ │ ├── simple-udp.h │ │ ├── slipdev.c │ │ ├── slipdev.h │ │ ├── tcp-socket.c │ │ ├── tcp-socket.h │ │ ├── tcpip.c │ │ ├── tcpip.h │ │ ├── udp-socket.c │ │ ├── udp-socket.h │ │ ├── uip-debug.c │ │ ├── uip-debug.h │ │ ├── uip-nameserver.c │ │ ├── uip-nameserver.h │ │ ├── uip-packetqueue.c │ │ ├── uip-packetqueue.h │ │ ├── uip-split.c │ │ ├── uip-split.h │ │ ├── uip-udp-packet.c │ │ ├── uip-udp-packet.h │ │ ├── uip.h │ │ ├── uip_arch.h │ │ ├── uiplib.c │ │ ├── uiplib.h │ │ └── uipopt.h │ ├── ip64-addr │ │ ├── README.md │ │ ├── ip64-addr.c │ │ └── ip64-addr.h │ ├── ip64 │ │ ├── README.md │ │ ├── ip64-addrmap.c │ │ ├── ip64-addrmap.h │ │ ├── ip64-arp.c │ │ ├── ip64-arp.h │ │ ├── ip64-conf-example.h │ │ ├── ip64-dhcpc.c │ │ ├── ip64-dhcpc.h │ │ ├── ip64-driver.h │ │ ├── ip64-eth-interface.c │ │ ├── ip64-eth-interface.h │ │ ├── ip64-eth.c │ │ ├── ip64-eth.h │ │ ├── ip64-interface.h │ │ ├── ip64-ipv4-dhcp.c │ │ ├── ip64-ipv4-dhcp.h │ │ ├── ip64-null-driver.c │ │ ├── ip64-null-driver.h │ │ ├── ip64-slip-interface.c │ │ ├── ip64-slip-interface.h │ │ ├── ip64-special-ports.c │ │ ├── ip64-special-ports.h │ │ ├── ip64.c │ │ └── ip64.h │ ├── ipv4 │ │ ├── uaodv-def.h │ │ ├── uaodv-rt.c │ │ ├── uaodv-rt.h │ │ ├── uaodv.c │ │ ├── uaodv.h │ │ ├── uip-fw-drv.c │ │ ├── uip-fw-drv.h │ │ ├── uip-fw.c │ │ ├── uip-fw.h │ │ ├── uip-neighbor.c │ │ ├── uip-neighbor.h │ │ ├── uip-over-mesh.c │ │ ├── uip-over-mesh.h │ │ ├── uip.c │ │ ├── uip_arp.c │ │ └── uip_arp.h │ ├── ipv6 │ │ ├── multicast │ │ │ ├── README.md │ │ │ ├── roll-tm.c │ │ │ ├── roll-tm.h │ │ │ ├── smrf.c │ │ │ ├── smrf.h │ │ │ ├── uip-mcast6-engines.h │ │ │ ├── uip-mcast6-route.c │ │ │ ├── uip-mcast6-route.h │ │ │ ├── uip-mcast6-stats.c │ │ │ ├── uip-mcast6-stats.h │ │ │ └── uip-mcast6.h │ │ ├── sicslowpan.c │ │ ├── sicslowpan.h │ │ ├── uip-ds6-nbr.c │ │ ├── uip-ds6-nbr.h │ │ ├── uip-ds6-route.c │ │ ├── uip-ds6-route.h │ │ ├── uip-ds6.c │ │ ├── uip-ds6.h │ │ ├── uip-icmp6.c │ │ ├── uip-icmp6.h │ │ ├── uip-nd6.c │ │ ├── uip-nd6.h │ │ └── uip6.c │ ├── linkaddr.c │ ├── linkaddr.h │ ├── llsec │ │ ├── anti-replay.c │ │ ├── anti-replay.h │ │ ├── ccm-star.c │ │ ├── ccm-star.h │ │ ├── llsec.h │ │ ├── llsec802154.h │ │ ├── noncoresec │ │ │ ├── noncoresec.c │ │ │ └── noncoresec.h │ │ ├── nullsec.c │ │ └── nullsec.h │ ├── mac │ │ ├── contikimac │ │ │ ├── contikimac-framer.c │ │ │ ├── contikimac-framer.h │ │ │ ├── contikimac.c │ │ │ └── contikimac.h │ │ ├── csma.c │ │ ├── csma.h │ │ ├── cxmac │ │ │ ├── cxmac.c │ │ │ └── cxmac.h │ │ ├── frame802154.c │ │ ├── frame802154.h │ │ ├── framer-802154.c │ │ ├── framer-802154.h │ │ ├── framer-nullmac.c │ │ ├── framer-nullmac.h │ │ ├── framer.c │ │ ├── framer.h │ │ ├── mac-sequence.c │ │ ├── mac-sequence.h │ │ ├── mac.c │ │ ├── mac.h │ │ ├── nullmac.c │ │ ├── nullmac.h │ │ ├── nullrdc-noframer.c │ │ ├── nullrdc-noframer.h │ │ ├── nullrdc.c │ │ ├── nullrdc.h │ │ ├── phase.c │ │ ├── phase.h │ │ ├── rdc.h │ │ └── sicslowmac │ │ │ ├── sicslowmac.c │ │ │ └── sicslowmac.h │ ├── nbr-table.c │ ├── nbr-table.h │ ├── netstack.c │ ├── netstack.h │ ├── packetbuf.c │ ├── packetbuf.h │ ├── queuebuf.c │ ├── queuebuf.h │ ├── rime │ │ ├── abc.c │ │ ├── abc.h │ │ ├── announcement.c │ │ ├── announcement.h │ │ ├── broadcast-announcement.c │ │ ├── broadcast-announcement.h │ │ ├── broadcast.c │ │ ├── broadcast.h │ │ ├── chameleon-bitopt.c │ │ ├── chameleon-bitopt.h │ │ ├── chameleon-raw.c │ │ ├── chameleon-raw.h │ │ ├── chameleon.c │ │ ├── chameleon.h │ │ ├── channel.c │ │ ├── channel.h │ │ ├── collect-link-estimate.c │ │ ├── collect-link-estimate.h │ │ ├── collect-neighbor.c │ │ ├── collect-neighbor.h │ │ ├── collect.c │ │ ├── collect.h │ │ ├── ipolite.c │ │ ├── ipolite.h │ │ ├── mesh.c │ │ ├── mesh.h │ │ ├── multihop.c │ │ ├── multihop.h │ │ ├── neighbor-discovery.c │ │ ├── neighbor-discovery.h │ │ ├── netflood.c │ │ ├── netflood.h │ │ ├── packetqueue.c │ │ ├── packetqueue.h │ │ ├── polite-announcement.c │ │ ├── polite-announcement.h │ │ ├── polite.c │ │ ├── polite.h │ │ ├── rime.c │ │ ├── rime.h │ │ ├── rimestats.c │ │ ├── rimestats.h │ │ ├── rmh.c │ │ ├── rmh.h │ │ ├── route-discovery.c │ │ ├── route-discovery.h │ │ ├── route.c │ │ ├── route.h │ │ ├── rucb.c │ │ ├── rucb.h │ │ ├── rudolph0.c │ │ ├── rudolph0.h │ │ ├── rudolph1.c │ │ ├── rudolph1.h │ │ ├── rudolph2.c │ │ ├── rudolph2.h │ │ ├── runicast.c │ │ ├── runicast.h │ │ ├── stbroadcast.c │ │ ├── stbroadcast.h │ │ ├── stunicast.c │ │ ├── stunicast.h │ │ ├── timesynch.c │ │ ├── timesynch.h │ │ ├── trickle.c │ │ ├── trickle.h │ │ ├── unicast.c │ │ └── unicast.h │ └── rpl │ │ ├── rpl-conf.h │ │ ├── rpl-dag.c │ │ ├── rpl-ext-header.c │ │ ├── rpl-icmp6.c │ │ ├── rpl-mrhof.c │ │ ├── rpl-of0.c │ │ ├── rpl-private.h │ │ ├── rpl-timers.c │ │ ├── rpl.c │ │ └── rpl.h └── sys │ ├── arg.c │ ├── arg.h │ ├── autostart.c │ ├── autostart.h │ ├── cc.h │ ├── clock.h │ ├── compower.c │ ├── compower.h │ ├── ctimer.c │ ├── ctimer.h │ ├── dsc.h │ ├── energest.c │ ├── energest.h │ ├── etimer.c │ ├── etimer.h │ ├── lc-addrlabels.h │ ├── lc-switch.h │ ├── lc.h │ ├── loader.h │ ├── log.h │ ├── mt.c │ ├── mt.h │ ├── node-id.h │ ├── process.c │ ├── process.h │ ├── procinit.c │ ├── procinit.h │ ├── pt-sem.h │ ├── pt.h │ ├── rtimer.c │ ├── rtimer.h │ ├── stimer.c │ ├── stimer.h │ ├── subprocess.h │ ├── timer.c │ └── timer.h └── merge-upstream.sh /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | *.pyc 3 | *.egg-info 4 | *.vcd 5 | firmware/hdmi_in[1-9].[ch] 6 | outgoing 7 | build 8 | *~ 9 | *.png 10 | third_party/qemu-litex 11 | third_party/micropython 12 | third_party/linux 13 | third_party/litex-devicetree 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/litex"] 2 | path = third_party/litex 3 | url = https://github.com/enjoy-digital/litex.git 4 | [submodule "third_party/litedram"] 5 | path = third_party/litedram 6 | url = https://github.com/enjoy-digital/litedram.git 7 | [submodule "third_party/liteeth"] 8 | path = third_party/liteeth 9 | url = https://github.com/enjoy-digital/liteeth.git 10 | [submodule "third_party/litepcie"] 11 | path = third_party/litepcie 12 | url = https://github.com/enjoy-digital/litepcie.git 13 | [submodule "third_party/litesata"] 14 | path = third_party/litesata 15 | url = https://github.com/enjoy-digital/litesata.git 16 | [submodule "third_party/litescope"] 17 | path = third_party/litescope 18 | url = https://github.com/enjoy-digital/litescope.git 19 | [submodule "third_party/liteusb"] 20 | path = third_party/liteusb 21 | url = https://github.com/enjoy-digital/liteusb.git 22 | [submodule "third_party/litevideo"] 23 | path = third_party/litevideo 24 | url = https://github.com/enjoy-digital/litevideo.git 25 | [submodule "third_party/edid-decode"] 26 | path = third_party/edid-decode 27 | url = https://git.linuxtv.org/edid-decode.git/ 28 | [submodule "third_party/flash_proxies"] 29 | path = third_party/flash_proxies 30 | url = https://github.com/jordens/bscan_spi_bitstreams 31 | [submodule "third_party/migen"] 32 | path = third_party/migen 33 | url = https://github.com/m-labs/migen.git 34 | [submodule "third_party/litex-renode"] 35 | path = third_party/litex-renode 36 | url = https://github.com/litex-hub/litex-renode.git 37 | -------------------------------------------------------------------------------- /.travis/copy-files.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os.path 4 | import shutil 5 | import sys 6 | 7 | d = sys.argv[1] 8 | assert d, d 9 | 10 | for l in sys.stdin.readlines(): 11 | src = l.strip() 12 | assert src, src 13 | assert src.startswith('/'), src 14 | out = os.path.join(d, src[1:]) 15 | outdir = os.path.dirname(out) 16 | src = src.replace('/opt/Xilinx/', '/opt/Xilinx.real/') 17 | if not os.path.exists(outdir): 18 | os.makedirs(outdir) 19 | print("New pdir {}".format(outdir)) 20 | 21 | if os.path.isdir(src): 22 | os.makedirs(out, exist_ok=False) 23 | shutil.copystat(src, out) 24 | print("New dir {}".format(out)) 25 | else: 26 | shutil.copy2(src, out, follow_symlinks=False) 27 | print("New file {} -> {}".format(src, out)) 28 | -------------------------------------------------------------------------------- /.travis/package-xilinx-cluefs-filter.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | import os 4 | import csv 5 | import sys 6 | 7 | with open(sys.argv[1]) as csvfile: 8 | # 2017-10-15T09:24:17.147577188Z,2017-10-15T09:24:17.147595641Z,18453,tim,1001,tim,1001,/bin/ls,14308,/opt/Xilinx.real,dir,open,O_RDONLY,0000,4096,4096,1 9 | reader = csv.DictReader( 10 | csvfile, 11 | fieldnames=( 12 | "start_ts", 13 | "end_ts", 14 | "duration_ns", # nanoseconds 15 | "user", 16 | "uid", 17 | "group", 18 | "gid", 19 | "process", 20 | "pid", 21 | "path", 22 | "type"), 23 | ) 24 | 25 | paths = set() 26 | for l in reader: 27 | #print(l) 28 | #if l['type'] != 'file': 29 | # continue 30 | if not l['path'].startswith('/opt/Xilinx'): 31 | continue 32 | if not os.path.exists(l['path']): 33 | continue 34 | #if os.path.isdir(l['path']): 35 | # continue 36 | 37 | src = l['path'] 38 | dst = l['path'].replace('/opt/Xilinx.real/', '/opt/Xilinx/') 39 | 40 | paths.add(dst) 41 | 42 | for p in sorted(paths): 43 | print(p) 44 | -------------------------------------------------------------------------------- /.travis/package-xilinx-step1-trace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | SETUP_SRC=$(realpath ${BASH_SOURCE[0]}) 7 | SETUP_DIR=$(dirname $SETUP_SRC) 8 | TOP_DIR=$(realpath $SETUP_DIR/..) 9 | 10 | BASE=$TOP_DIR/build/package-xilinx 11 | echo $BASE 12 | mkdir -p $BASE 13 | 14 | export PREFIX="/opt/Xilinx/" 15 | 16 | # This is based on https://github.com/m-labs/migen/blob/master/tools/strace_tailor.sh 17 | if [ ! -z "$PLATFORMS" ]; then 18 | echo "\$PLATFORMS is set to '$PLATFORMS', please unset it." 19 | exit 1 20 | fi 21 | if [ ! -z "$TARGETS" ]; then 22 | echo "\$TARGETS is set to '$TARGETS', please unset it." 23 | exit 1 24 | fi 25 | 26 | ( 27 | echo "Deleting previous builds..." 28 | cd build 29 | # Delete all the previous builds 30 | rm -rf *_*_* 31 | ) 32 | 33 | STRACE_LOG=$BASE/strace.log 34 | if [ -f $STRACE_LOG ]; then 35 | echo "Deleting old strace log." 36 | rm -v $STRACE_LOG 37 | fi 38 | 39 | # curl -L https://github.com/airnandez/cluefs/releases/download/v0.5/cluefs-v0.5-linux-x86_64.tar.gz | tar -xz 40 | # https://github.com/airnandez/cluefs 41 | # cluefs --mount=/opt/Xilinx --shadow=/opt/Xilinx.real --out=/tmp/Xilinx.log --ro --csv 42 | 43 | #exec strace -e trace=file,process -E LD_LIBRARY_PATH=/opt/Xilinx/Vivado/2017.3/lib/lnx64.o -f -o ${STRACE_LOG} 44 | bash $SETUP_DIR/build.sh 45 | -------------------------------------------------------------------------------- /.travis/package-xilinx-step2-create-tar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | SETUP_SRC=$(realpath ${BASH_SOURCE[0]}) 7 | SETUP_DIR=$(dirname $SETUP_SRC) 8 | TOP_DIR=$(realpath $SETUP_DIR/..) 9 | 10 | for ARG in XILINX_PASSPHRASE_IN; do 11 | if [ -z "${!ARG}" ]; then 12 | echo "$ARG not set" 13 | exit 1 14 | else 15 | echo "$ARG='${!ARG}'" 16 | fi 17 | done 18 | 19 | BASE=$TOP_DIR/build/package-xilinx 20 | echo $BASE 21 | mkdir -p $BASE 22 | 23 | export PREFIX="/opt/Xilinx/" 24 | 25 | # This is based on https://github.com/m-labs/migen/blob/master/tools/strace_tailor.sh 26 | STRACE_LOG=$BASE/strace.log 27 | if [ ! -f $STRACE_LOG ]; then 28 | echo "No strace log found at $STRACE_LOG" 29 | echo "Please run ./.travis/package-xilinx-step1-trace.sh" 30 | exit 1 31 | fi 32 | 33 | STRACE_FILES=$BASE/strace.files.log 34 | $SETUP_DIR/package-xilinx-cluefs-filter.py $STRACE_LOG > $STRACE_FILES 35 | 36 | XILINX_DIR=$BASE/xilinx-stripped 37 | if [ -d $XILINX_DIR ]; then 38 | rm -rf $XILINX_DIR 39 | fi 40 | 41 | echo "" 42 | echo "Creating directories" 43 | echo "--------------------------------------" 44 | mkdir -p $XILINX_DIR 45 | #cat $STRACE_FILES | xargs -d '\n' \ 46 | # cp -v --parents --no-dereference --preserve=all -t $XILINX_DIR || true 47 | cat $STRACE_FILES | $TOP_DIR/.travis/copy-files.py $XILINX_DIR 48 | echo "--------------------------------------" 49 | 50 | FILENAME="$BASE/xilinx-tools-$(git describe).tar.bz2" 51 | echo $FILENAME 52 | ( 53 | cd $XILINX_DIR 54 | echo "" 55 | echo "Creating tar file" 56 | echo "--------------------------------------" 57 | tar --preserve-permissions -jcvlf $FILENAME opt 58 | echo "--------------------------------------" 59 | ) 60 | echo $XILINX_PASSPHRASE_IN | gpg --passphrase-fd 0 --cipher-algo AES256 -c $FILENAME 61 | -------------------------------------------------------------------------------- /.travis/package-xilinx-step3-upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | SETUP_SRC=$(realpath ${BASH_SOURCE[0]}) 7 | SETUP_DIR=$(dirname $SETUP_SRC) 8 | TOP_DIR=$(realpath $SETUP_DIR/..) 9 | 10 | for ARG in RACKSPACE_USER RACKSPACE_API; do 11 | if [ -z "${!ARG}" ]; then 12 | echo "$ARG not set" 13 | exit 1 14 | else 15 | echo "$ARG='${!ARG}'" 16 | fi 17 | done 18 | 19 | BASE=$TOP_DIR/build/package-xilinx 20 | echo $BASE 21 | mkdir -p $BASE 22 | 23 | ( 24 | cd $BASE 25 | TB_COMMAND="turbolift --verbose --colorized -u $RACKSPACE_USER -a $RACKSPACE_API --os-rax-auth iad upload -c xilinx" 26 | 27 | # Upload the tar bz 28 | $TB_COMMAND -s . --sync --pattern-match ".*\.gpg" 29 | # Upload the index file 30 | md5sum *.gpg | sort -t- -k3,3V -k4,4n > index.txt 31 | cat index.txt 32 | $TB_COMMAND -s . --sync --pattern-match "index.txt" 33 | ) 34 | -------------------------------------------------------------------------------- /.travis/prevent-condarc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p ~/.conda 4 | chmod 0000 ~/.conda 5 | -------------------------------------------------------------------------------- /.travis/run-make-gateware-suppression.regex: -------------------------------------------------------------------------------- 1 | # Line one 2 | Blah.* 3 | -------------------------------------------------------------------------------- /.travis/run.inc.sh: -------------------------------------------------------------------------------- 1 | if [ -z "$PLATFORMS" ]; then 2 | if [ -z "$SKIP_PLATFORMS" ]; then 3 | SKIP_PLATFORMS="sim" 4 | fi 5 | if [ -z "$PLATFORM" ]; then 6 | PLATFORMS=$(ls targets/ | grep -v ".py" | grep -v "common" | grep -v "$SKIP_PLATFORMS" | sed -e"s+targets/++") 7 | else 8 | PLATFORMS="$PLATFORM" 9 | unset PLATFORM 10 | fi 11 | fi 12 | echo "Running with PLATFORMS='$PLATFORMS'" 13 | 14 | if [ -z "$CPUS" ]; then 15 | if [ -z "$CPU" ]; then 16 | CPUS="lm32 mor1kx picorv32 vexriscv" 17 | else 18 | CPUS="$CPU" 19 | unset CPU 20 | fi 21 | fi 22 | 23 | declare -a SUCCESSES 24 | declare -a FAILURES 25 | 26 | START_TARGET="$TARGET" 27 | START_TARGETS="$TARGETS" 28 | for FULL_PLATFORM in $PLATFORMS; do 29 | if [ -z "$START_TARGETS" ]; then 30 | if [ -z "$SKIP_TARGETS" ]; then 31 | SKIP_TARGETS="__" 32 | fi 33 | if [ ! -z "$START_TARGETS" ]; then 34 | TARGETS="$START_TARGETS" 35 | elif [ ! -z "$START_TARGET" ]; then 36 | TARGETS="$START_TARGET" 37 | else 38 | TARGETS=$(ls targets/${FULL_PLATFORM}/*.py | grep -v "__" | grep -v "$SKIP_TARGETS" | sed -e"s+targets/${FULL_PLATFORM}/++" -e"s/.py//") 39 | fi 40 | fi 41 | 42 | echo "" 43 | echo "" 44 | echo "" 45 | echo "Running with TARGETS='$TARGETS'" 46 | for TARGET in $TARGETS; do 47 | echo "Running with CPUS='$CPUS'" 48 | for FULL_CPU in $CPUS; do 49 | $FUNC $FULL_PLATFORM $TARGET $FULL_CPU $FIRMWARE && : 50 | RETURN=$? 51 | if [ "$RETURN" -eq 0 ]; then 52 | SUCCESSES+=("$FULL_PLATFORM+$TARGET+$FULL_CPU+$FIRMWARE") 53 | else 54 | FAILURES+=("$FULL_PLATFORM+$TARGET+$FULL_CPU+$FIRMWARE") 55 | fi 56 | done 57 | done 58 | done 59 | -------------------------------------------------------------------------------- /.travis/update-prebuilt-list.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function prebuilt() { 4 | export FULL_PLATFORM=$1 5 | export TARGET=$2 6 | export FULL_CPU=$3 7 | 8 | if [ x"$4" != x"" ]; then 9 | FIRMWARE=$4 10 | else 11 | unset $FIRMWARE 12 | fi 13 | export FIRMWARE 14 | .travis/generate-prebuilt-list.py || return 1 15 | return 0 16 | } 17 | 18 | if [ x"$TRAVIS_BRANCH" = x"master" ]; then 19 | echo "" 20 | echo "" 21 | echo "" 22 | echo "Updating prebuilt binaries" 23 | echo "=============================================" 24 | for i in 1 2 3 4 5 6 7 8 9 10; do # Try 10 times. 25 | export FUNC=prebuilt 26 | 27 | . .travis/run.inc.sh && : 28 | FAILED=$? 29 | 30 | if [ $FAILED -eq 0 ]; then 31 | echo "Update succeed!" 32 | break 33 | else 34 | echo "Update failed!" 35 | fi 36 | done 37 | echo 38 | echo "Push finished!" 39 | fi 40 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file with this pattern: 2 | # 3 | # For individuals: 4 | # Name 5 | # 6 | # For organizations: 7 | # Organization 8 | # 9 | # See python fnmatch module documentation for more information. 10 | 11 | # People - in alphabetical order 12 | Ajit Mathew 13 | Carl Karsten 14 | Chris Felton 15 | Chris McClelland 16 | Christopher Felton 17 | David Nugent 18 | Florent Kermarrec 19 | Jacinta Richardson 20 | Jahanzeb Ahmad 21 | Joel 'jae' Addison 22 | Joel 'shenki' Stanley 23 | Katie 'katharos' Bell 24 | Kenny Duffus 25 | Matthew Iselin 26 | Michael 'micolous' Farrell 27 | Rohit Kumar Singh 28 | Rohit Kumar Singh 29 | Rohit Kumar Singh 30 | Ryan 'xfxf' Verner 31 | Shashank 'ssk1328' Gangrade 32 | Stefano 'tumbleweed' Rivera 33 | Tim 'mithro' Ansell 34 | Vikram Raigur 35 | William D. Jones 36 | Yann Sionneau 37 | 38 | 39 | # Companies / Groups - in alphabetical order 40 | EnjoyDigital <*@enjoy-digital.com> 41 | Google <*@google.com> 42 | TimVideos.us <*@timvideos.us> 43 | MITHIS <*@mithis.com> 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017 The Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright notice, 9 | this list of conditions and the following disclaimer in the documentation 10 | and/or other materials provided with the distribution. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 13 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 16 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 19 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | -------------------------------------------------------------------------------- /doc/architecture.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/architecture.dia -------------------------------------------------------------------------------- /doc/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/architecture.png -------------------------------------------------------------------------------- /doc/arty_sch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/arty_sch.pdf -------------------------------------------------------------------------------- /doc/enjoy_digital.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/enjoy_digital.png -------------------------------------------------------------------------------- /doc/front_panel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/front_panel.jpg -------------------------------------------------------------------------------- /doc/litex_oled.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/litex_oled.bmp -------------------------------------------------------------------------------- /doc/netv2_schematic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/netv2_schematic.pdf -------------------------------------------------------------------------------- /doc/nexys_video_rm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/nexys_video_rm.pdf -------------------------------------------------------------------------------- /doc/nexys_video_sch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/nexys_video_sch.pdf -------------------------------------------------------------------------------- /doc/notes.md: -------------------------------------------------------------------------------- 1 | 2 | # Setting up the environment 3 | 4 | [This info has moved to the LiteX Build Environment Wiki's Environment page](https://github.com/timvideos/litex-buildenv/wiki/Environment#setting-up-the-environment) 5 | 6 | # Random Comments 7 | 8 | [This info has moved to the LiteX Build Environment Wiki's Glossary page](https://github.com/timvideos/litex-buildenv/wiki/Glossary) 9 | 10 | -------------------------------------------------------------------------------- /doc/numato_opsis_schematic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/numato_opsis_schematic.pdf -------------------------------------------------------------------------------- /doc/powered_by_migen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/powered_by_migen.png -------------------------------------------------------------------------------- /doc/targets.md: -------------------------------------------------------------------------------- 1 | [This page has moved to the LiteX Build Environment Wiki's Targets page](https://github.com/timvideos/litex-buildenv/wiki/Targets) 2 | -------------------------------------------------------------------------------- /doc/tofe_low_speed_io.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/doc/tofe_low_speed_io.pdf -------------------------------------------------------------------------------- /firmware/asm.h: -------------------------------------------------------------------------------- 1 | #ifdef __lm32__ 2 | 3 | #define REBOOT __asm__("call r0") 4 | #define NOP __asm__("nop") 5 | 6 | #elif __or1k__ 7 | 8 | #define REBOOT __asm__("l.j 0") 9 | #define NOP __asm__("l.nop") 10 | 11 | #elif __minerva__ 12 | 13 | #define REBOOT __asm__("jalr x0, 0") 14 | #define NOP __asm__("nop") 15 | 16 | #elif __picorv32__ 17 | 18 | #define REBOOT __asm__("jalr x0, 0") 19 | #define NOP __asm__("nop") 20 | 21 | #elif __vexriscv__ 22 | 23 | #define REBOOT __asm__("jalr x0, 0") 24 | #define NOP __asm__("nop") 25 | 26 | #else 27 | 28 | #error "Unknown ARCH." 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /firmware/bist.h: -------------------------------------------------------------------------------- 1 | #ifndef __BIST_H 2 | #define __BIST_H 3 | 4 | void bist_test(void); 5 | 6 | #endif /* __BIST_H */ 7 | -------------------------------------------------------------------------------- /firmware/ci.h: -------------------------------------------------------------------------------- 1 | #ifndef __CI_H 2 | #define __CI_H 3 | 4 | void ci_prompt(void); 5 | void ci_service(void); 6 | 7 | #ifdef CSR_HDMI_OUT0_BASE 8 | void output0_on(void); 9 | void output0_off(void); 10 | #endif 11 | 12 | #ifdef CSR_HDMI_OUT1_BASE 13 | void output1_on(void); 14 | void output1_off(void); 15 | #endif 16 | 17 | #ifdef CSR_HDMI_IN0_BASE 18 | void input0_on(void); 19 | void input0_off(void); 20 | #endif 21 | 22 | #ifdef CSR_HDMI_IN1_BASE 23 | void input1_on(void); 24 | void input1_off(void); 25 | #endif 26 | 27 | #ifdef ENCODER_BASE 28 | void encoder_on(void); 29 | void encoder_configure_quality(int quality); 30 | void encoder_configure_fps(int fps); 31 | void encoder_off(void); 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /firmware/config.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef LOCALIP1 6 | //#warning "No default IP address" 7 | #define LOCALIP1 0 8 | #define LOCALIP2 0 9 | #define LOCALIP3 0 10 | #define LOCALIP4 0 11 | #endif 12 | 13 | #include "config.h" 14 | #include "processor.h" 15 | 16 | // Order of default; 17 | // HDMI_IN1 (if it exists) 18 | // HDMI_IN0 (if it exists) 19 | // PATTERN 20 | #ifdef CSR_HDMI_IN1_BASE 21 | #define VIDEO_IN_DEFAULT VIDEO_IN_HDMI_IN1 22 | // #warning "Default HDMI In 1" 23 | #else 24 | #ifdef CSR_HDMI_IN0_BASE 25 | #define VIDEO_IN_DEFAULT VIDEO_IN_HDMI_IN0 26 | // #warning "Default HDMI In 0" 27 | #else 28 | #define VIDEO_IN_DEFAULT VIDEO_IN_PATTERN 29 | // #warning "Default Pattern" 30 | #endif 31 | #endif 32 | 33 | 34 | static const unsigned char config_defaults[CONFIG_KEY_COUNT] = { 35 | #if PLATFORM_NETV2 || PLATFORM_NEXYS_VIDEO 36 | PROCESSOR_MODE_1920_1080_60, // Primary 37 | EDID_SECONDARY_MODE_OFF, // Secondary 38 | #else 39 | // EDID Config 40 | PROCESSOR_MODE_720p_50, // Primary 41 | PROCESSOR_MODE_720p_60, // Secondary 42 | #endif 43 | // Input config 44 | false, // Input0 45 | true, // Input1 46 | // Output config 47 | true, VIDEO_IN_DEFAULT, // Output 0 48 | true, VIDEO_IN_PATTERN, // Output 1 49 | // Encoder 50 | true, VIDEO_IN_DEFAULT, 85, 25, true, 51 | // Networking - MAC Address 52 | 0x10, 0xe2, 0xd5, 0x00, 0x00, 0x00, 53 | // Networking - IP Address 54 | LOCALIP1, LOCALIP2, LOCALIP3, LOCALIP4, 55 | // Networking - DHCP 56 | false, 57 | }; 58 | static unsigned char config_values[CONFIG_KEY_COUNT]; 59 | 60 | void config_init(void) 61 | { 62 | memcpy(config_values, config_defaults, CONFIG_KEY_COUNT); 63 | } 64 | 65 | void config_write_all(void) 66 | { 67 | } 68 | 69 | unsigned char config_get(unsigned char key) 70 | { 71 | return config_values[key]; 72 | } 73 | 74 | void config_set(unsigned char key, unsigned char value) 75 | { 76 | } 77 | -------------------------------------------------------------------------------- /firmware/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 / TimVideo.us 3 | * Copyright 2015 / EnjoyDigital 4 | * Copyright 2017 Joel Addison 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | */ 15 | 16 | #ifndef __CONFIG_H 17 | #define __CONFIG_H 18 | 19 | #include "processor.h" 20 | 21 | enum { 22 | CONFIG_KEY_RES_PRIMARY = 0, 23 | CONFIG_KEY_RES_SECONDARY, 24 | // Input config 25 | CONFIG_KEY_INPUT0_ENABLED, 26 | CONFIG_KEY_INPUT1_ENABLED, 27 | // Output 0 config 28 | CONFIG_KEY_OUTPUT0_ENABLED, 29 | CONFIG_KEY_OUTPUT0_SOURCE, 30 | // Output 1 config 31 | CONFIG_KEY_OUTPUT1_ENABLED, 32 | CONFIG_KEY_OUTPUT1_SOURCE, 33 | // Encoder config 34 | CONFIG_KEY_ENCODER_ENABLED, 35 | CONFIG_KEY_ENCODER_SOURCE, 36 | CONFIG_KEY_ENCODER_QUALITY, 37 | CONFIG_KEY_ENCODER_FPS, 38 | CONFIG_KEY_FX2_RESET, 39 | // Networking - MAC Address 40 | CONFIG_KEY_NETWORK_MAC0, 41 | CONFIG_KEY_NETWORK_MAC1, 42 | CONFIG_KEY_NETWORK_MAC2, 43 | CONFIG_KEY_NETWORK_MAC3, 44 | CONFIG_KEY_NETWORK_MAC4, 45 | CONFIG_KEY_NETWORK_MAC5, 46 | // Networking - IP address 47 | CONFIG_KEY_NETWORK_IP0, 48 | CONFIG_KEY_NETWORK_IP1, 49 | CONFIG_KEY_NETWORK_IP2, 50 | CONFIG_KEY_NETWORK_IP3, 51 | // Networking - DHCP enabled? 52 | CONFIG_KEY_NETWORK_DHCP, 53 | 54 | CONFIG_KEY_COUNT 55 | }; 56 | 57 | void config_init(void); 58 | void config_write_all(void); 59 | unsigned char config_get(unsigned char key); 60 | void config_set(unsigned char key, unsigned char value); 61 | 62 | #endif /* __CONFIG_H */ 63 | -------------------------------------------------------------------------------- /firmware/encoder.h: -------------------------------------------------------------------------------- 1 | #ifndef __ENCODER_H 2 | #define __ENCODER_H 3 | 4 | #define ENCODER_START_REG 0x0 5 | #define ENCODER_IMAGE_SIZE_REG 0x4 6 | #define ENCODER_RAM_ACCESS_REG 0x8 7 | #define ENCODER_STS_REG 0xC 8 | #define ENCODER_COD_DATA_ADDR_REG 0x10 9 | #define ENCODER_LENGTH_REG 0x14 10 | 11 | #define ENCODER_QUANTIZER_RAM_LUMA_BASE 0x100 12 | 13 | const char luma_rom_100[64]; 14 | const char luma_rom_85[64]; 15 | const char luma_rom_75[64]; 16 | const char luma_rom_50[64]; 17 | 18 | #define ENCODER_QUANTIZER_RAM_CHROMA_BASE 0x200 19 | 20 | const char chroma_rom_100[64]; 21 | const char chroma_rom_85[64]; 22 | const char chroma_rom_75[64]; 23 | const char chroma_rom_50[64]; 24 | 25 | char encoder_enabled; 26 | int encoder_target_fps; 27 | int encoder_fps; 28 | int encoder_quality; 29 | 30 | void encoder_write_reg(unsigned int adr, unsigned int value); 31 | unsigned int encoder_read_reg(unsigned int adr); 32 | void encoder_init(int encoder_quality); 33 | void encoder_start(short resx, short resy); 34 | int encoder_done(void); 35 | void encoder_enable(char enable); 36 | int encoder_set_quality(int quality); 37 | int encoder_set_fps(int fps); 38 | void encoder_service(void); 39 | 40 | #endif -------------------------------------------------------------------------------- /firmware/etherbone.h: -------------------------------------------------------------------------------- 1 | // This file is Copyright (c) 2015 Florent Kermarrec 2 | // License: BSD 3 | 4 | #ifndef __ETHERBONE_H 5 | #define __ETHERBONE_H 6 | 7 | #include "contiki.h" 8 | #include "contiki-net.h" 9 | 10 | //#define ETHERBONE_DEBUG 11 | 12 | #ifdef ETHERBONE_DEBUG 13 | #define print_debug(...) printf(__VA_ARGS__) 14 | #else 15 | #define print_debug(...) {} 16 | #endif 17 | 18 | #define ETHERBONE_PORT 1234 19 | #define ETHERBONE_BUFFER_SIZE_RX 1512 20 | #define ETHERBONE_BUFFER_SIZE_TX 1512 21 | 22 | #define ETHERBONE_HEADER_LENGTH 12 23 | 24 | struct tcp_socket etherbone_socket; 25 | uint8_t etherbone_rx_buf[ETHERBONE_BUFFER_SIZE_RX]; 26 | uint8_t etherbone_tx_buf[ETHERBONE_BUFFER_SIZE_TX]; 27 | 28 | struct etherbone_record { 29 | union { 30 | uint32_t write_value; 31 | uint32_t read_addr; 32 | }; 33 | } __attribute__((packed)); 34 | 35 | struct etherbone_record_header { 36 | unsigned int bca: 1; 37 | unsigned int rca: 1; 38 | unsigned int rff: 1; 39 | unsigned int reserved: 1; 40 | unsigned int cyc: 1; 41 | unsigned int wca: 1; 42 | unsigned int wff: 1; 43 | unsigned int reserved2: 1; 44 | unsigned char byte_enable; 45 | unsigned char wcount; 46 | unsigned char rcount; 47 | union { 48 | uint32_t base_write_addr; 49 | uint32_t base_ret_addr; 50 | }; 51 | } __attribute__((packed)); 52 | 53 | struct etherbone_packet { 54 | uint16_t magic; 55 | unsigned int version: 4; 56 | unsigned int reserved: 1; 57 | unsigned int nr: 1; 58 | unsigned int pr: 1; 59 | unsigned int pf: 1; 60 | unsigned int addr_size: 4; 61 | unsigned int port_size: 4; 62 | uint32_t padding; 63 | 64 | struct etherbone_record_header record_hdr; 65 | struct etherbone_record record[]; 66 | } __attribute__((packed, aligned(8))); 67 | 68 | void etherbone_init(void); 69 | void etherbone_write(unsigned int addr, unsigned int value); 70 | unsigned int etherbone_read(unsigned int addr); 71 | int etherbone_callback(struct tcp_socket *s, void *ptr, const char *rxbuf, int rxlen); 72 | void etherbone_process(struct tcp_socket *s, unsigned char *rxbuf); 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /firmware/ethernet.c: -------------------------------------------------------------------------------- 1 | // This file is Copyright (c) 2015 Florent Kermarrec 2 | // License: BSD 3 | 4 | #include "ethernet.h" 5 | #include 6 | #include 7 | #include 8 | 9 | static int uip_periodic_event; 10 | static int uip_periodic_period; 11 | 12 | static int uip_arp_event; 13 | static int uip_arp_period; 14 | 15 | void uip_log(char *msg) 16 | { 17 | #ifdef UIP_DEBUG 18 | puts(msg); 19 | #endif 20 | } 21 | 22 | #ifdef ETHMAC_BASE 23 | 24 | void ethernet_init(const unsigned char * mac_addr, const unsigned char *ip_addr) 25 | { 26 | int i; 27 | uip_ipaddr_t ipaddr; 28 | 29 | /* init ethernet mac */ 30 | clock_init(); 31 | liteethmac_init(); 32 | 33 | /* uip periods */ 34 | uip_periodic_period = CONFIG_CLOCK_FREQUENCY/100; /* 10 ms */ 35 | uip_arp_period = CONFIG_CLOCK_FREQUENCY/10; /* 100 ms */ 36 | 37 | /* init uip */ 38 | process_init(); 39 | process_start(&etimer_process, NULL); 40 | uip_init(); 41 | 42 | /* configure mac / ip */ 43 | for (i=0; i<6; i++) uip_lladdr.addr[i] = mac_addr[i]; 44 | uip_ipaddr(&ipaddr, ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3]); 45 | uip_sethostaddr(&ipaddr); 46 | 47 | printf("uIP init done with ip %d.%d.%d.%d\n", ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3]); 48 | } 49 | 50 | void ethernet_service(void) { 51 | int i; 52 | struct uip_eth_hdr *buf = (struct uip_eth_hdr *)&uip_buf[0]; 53 | 54 | etimer_request_poll(); 55 | process_run(); 56 | 57 | uip_len = liteethmac_poll(); 58 | if(uip_len > 0) { 59 | if(buf->type == uip_htons(UIP_ETHTYPE_IP)) { 60 | uip_arp_ipin(); 61 | uip_input(); 62 | if(uip_len > 0) { 63 | uip_arp_out(); 64 | liteethmac_send(); 65 | } 66 | } else if(buf->type == uip_htons(UIP_ETHTYPE_ARP)) { 67 | uip_arp_arpin(); 68 | if(uip_len > 0) 69 | liteethmac_send(); 70 | } 71 | } else if (elapsed(&uip_periodic_event, uip_periodic_period)) { 72 | for(i = 0; i < UIP_CONNS; i++) { 73 | uip_periodic(i); 74 | 75 | if(uip_len > 0) { 76 | uip_arp_out(); 77 | liteethmac_send(); 78 | } 79 | } 80 | } 81 | if (elapsed(&uip_arp_event, uip_arp_period)) { 82 | uip_arp_timer(); 83 | } 84 | } 85 | 86 | #endif -------------------------------------------------------------------------------- /firmware/ethernet.h: -------------------------------------------------------------------------------- 1 | // This file is Copyright (c) 2015 Florent Kermarrec 2 | // License: BSD 3 | 4 | #ifndef __ETHERNET_H 5 | #define __ETHERNET_H 6 | 7 | #include "contiki.h" 8 | #include "contiki-net.h" 9 | #include "liteethmac-drv.h" 10 | 11 | //#define UIP_DEBUG 12 | 13 | #define max(a,b) ((a>b)?a:b) 14 | #define min(a,b) ((a 2 | #ifdef SPIFLASH_PAGE_SIZE 3 | #include "flash.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "ci.h" 11 | 12 | 13 | #define test_size 1024 14 | 15 | 16 | #define NUMBER_OF_BYTES_ON_A_LINE 16 17 | static void dump_bytes(unsigned int *ptr, int count, unsigned addr) 18 | { 19 | char *data = (char *)ptr; 20 | int line_bytes = 0, i = 0; 21 | 22 | putsnonl("Memory dump:"); 23 | while(count > 0){ 24 | line_bytes = 25 | (count > NUMBER_OF_BYTES_ON_A_LINE)? 26 | NUMBER_OF_BYTES_ON_A_LINE : count; 27 | 28 | printf("\n0x%08x ", addr); 29 | for(i=0;i 0x7e)) 39 | printf("."); 40 | else 41 | printf("%c", *(data+i)); 42 | } 43 | 44 | for(;i 2 | #include 3 | #ifdef CSR_OPSIS_I2C_FX2_RESET_OUT_ADDR 4 | 5 | #include 6 | 7 | #include "opsis_i2c.h" 8 | 9 | enum fx2_fw_version { 10 | FX2FW_USBJTAG, 11 | #ifdef ENCODER_BASE 12 | FX2FW_HDMI2USB, 13 | #endif 14 | }; 15 | 16 | void fx2_init(void); 17 | bool fx2_service(bool verbose); 18 | void fx2_reboot(enum fx2_fw_version fw); 19 | void fx2_debug(void); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /firmware/hdmi_in.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "`whoami`" = "root" ] 4 | then 5 | echo "Running the script as root is not permitted" 6 | exit 1 7 | fi 8 | 9 | CALLED=$_ 10 | [[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0 11 | 12 | SCRIPT_SRC=$(realpath ${BASH_SOURCE[0]}) 13 | SCRIPT_DIR=$(dirname $SCRIPT_SRC) 14 | 15 | if [ $SOURCED = 1 ]; then 16 | echo "You must run this script, rather then try to source it." 17 | echo "$SETUP_SRC" 18 | return 19 | fi 20 | 21 | FIRMWARE_DIR=$SCRIPT_DIR 22 | 23 | X=$1 24 | HEXCOLOR=$2 25 | 26 | set -e 27 | 28 | # These must be outside the heredoc below otherwise the script won't error. 29 | TMPFILE_H=$(tempfile -s .h 2>/dev/null || mktemp --suffix=.h) 30 | TMPFILE_C=$(tempfile -s .c 2>/dev/null || mktemp --suffix=.c) 31 | 32 | cat $FIRMWARE_DIR/hdmi_in0.h | sed \ 33 | -e"s/IN0_INDEX\([^0-9]\+\)0/IN${X}_INDEX\1$X/g" \ 34 | -e"s/IN0/IN$X/g" \ 35 | -e"s/in0/in$X/g" \ 36 | -e"s/dvisampler0/dvisampler$X/g" \ 37 | > $TMPFILE_H 38 | 39 | cat $FIRMWARE_DIR/hdmi_in0.c | sed \ 40 | -e"s/IN0/IN$X/g" \ 41 | -e"s/in0/in$X/g" \ 42 | -e"s/dvisampler0/dvisampler$X/g" \ 43 | -e"s/framebuffer\[i\] = 0x.*/framebuffer[i] = ${HEXCOLOR};/g" \ 44 | > $TMPFILE_C 45 | 46 | if ! cmp -s $TMPFILE_H hdmi_in$X.h; then 47 | echo "Updating hdmi_in$X.h" 48 | mv $TMPFILE_H hdmi_in$X.h 49 | fi 50 | 51 | if ! cmp -s $TMPFILE_C hdmi_in$X.c; then 52 | echo "Updating hdmi_in$X.c" 53 | mv $TMPFILE_C hdmi_in$X.c 54 | fi 55 | -------------------------------------------------------------------------------- /firmware/hdmi_in0.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "framebuffer.h" 3 | 4 | #ifndef __HDMI_IN0_H 5 | #define __HDMI_IN0_H 6 | 7 | #ifdef HDMI_IN0_INDEX 8 | #error "HDMI_IN0_INDEX already defined!" 9 | #endif 10 | 11 | #define HDMI_IN0_INDEX 0 12 | #define HDMI_IN0_FRAMEBUFFERS_BASE FRAMEBUFFER_BASE_HDMI_INPUT(HDMI_IN0_INDEX) 13 | 14 | extern int hdmi_in0_debug; 15 | extern int hdmi_in0_fb_index; 16 | 17 | fb_ptrdiff_t hdmi_in0_framebuffer_base(char n); 18 | 19 | void hdmi_in0_isr(void); 20 | void hdmi_in0_init_video(int hres, int vres); 21 | void hdmi_in0_enable(void); 22 | bool hdmi_in0_status(void); 23 | void hdmi_in0_disable(void); 24 | void hdmi_in0_clear_framebuffers(void); 25 | void hdmi_in0_print_status(void); 26 | int hdmi_in0_calibrate_delays(int freq); 27 | int hdmi_in0_adjust_phase(void); 28 | int hdmi_in0_init_phase(void); 29 | int hdmi_in0_phase_startup(int freq); 30 | void hdmi_in0_service(int freq); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /firmware/hdmi_out0.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef CSR_HDMI_OUT0_I2C_W_ADDR 4 | void hdmi_out0_i2c_init(void); 5 | void hdmi_out0_print_edid(void); 6 | #endif 7 | -------------------------------------------------------------------------------- /firmware/hdmi_out1.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef CSR_HDMI_OUT1_I2C_W_ADDR 4 | void hdmi_out1_i2c_init(void); 5 | void hdmi_out1_print_edid(void); 6 | #endif 7 | -------------------------------------------------------------------------------- /firmware/heartbeat.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "hdmi_in0.h" 9 | #include "hdmi_in1.h" 10 | #include "heartbeat.h" 11 | #include "processor.h" 12 | #include "pattern.h" 13 | #include "stdio_wrap.h" 14 | 15 | static bool heartbeat_status = false; 16 | 17 | #define HEARTBEAT_FREQUENCY 1 // In Hertz 18 | #define FILL_RATE 120 // In Hertz, double the standard frame rate 19 | 20 | void hb_status(bool val) 21 | { 22 | heartbeat_status = val; 23 | } 24 | 25 | void hb_service(fb_ptrdiff_t fb_offset) 26 | { 27 | static int last_event; 28 | static int counter; 29 | static bool color_v; 30 | 31 | if (heartbeat_status==1) { 32 | hb_fill(color_v, fb_offset); 33 | if(elapsed(&last_event, CONFIG_CLOCK_FREQUENCY/FILL_RATE)) { 34 | counter = counter + 1; 35 | if(counter > FILL_RATE/(HEARTBEAT_FREQUENCY*2)) { 36 | color_v = !color_v; 37 | counter = 0; 38 | } 39 | } 40 | } 41 | } 42 | 43 | void hb_fill(bool color_v, fb_ptrdiff_t fb_offset) 44 | { 45 | int addr, i, j; 46 | unsigned int color; 47 | 48 | unsigned int *framebuffer = fb_ptrdiff_to_main_ram(fb_offset); 49 | 50 | /* 51 | 8x8 pixel square at right bottom corner 52 | 8 pixel = 4 memory locations in horizoantal 53 | 8 pixel = 8 memory locations in vertical 54 | Toggles between BLUE and RED 55 | */ 56 | 57 | if (color_v == 0) 58 | color = YCBCR422_BLUE; 59 | else 60 | color = YCBCR422_RED; 61 | 62 | addr = 0 + (processor_h_active/2)*(processor_v_active-8) + (processor_h_active/2) - 4; 63 | for (i=0; i<4; i++){ 64 | for (j=0; j<8; j++){ 65 | framebuffer[addr+i+(processor_h_active/2)*j] = color; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /firmware/heartbeat.h: -------------------------------------------------------------------------------- 1 | #ifndef __HEARTBEAT_H 2 | #define __HEARTBEAT_H 3 | 4 | #include 5 | #include "framebuffer.h" 6 | 7 | void hb_status(bool val); 8 | void hb_service(fb_ptrdiff_t fb_offset) ; 9 | void hb_fill(bool color_v, fb_ptrdiff_t fb_offset); 10 | 11 | #endif /* __HEARTBEAT_H */ 12 | -------------------------------------------------------------------------------- /firmware/i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef __I2C_H 2 | #define __I2C_H 3 | 4 | #define I2C_SCL 0x01 5 | #define I2C_SDAOE 0x02 6 | #define I2C_SDAOUT 0x04 7 | 8 | #define I2C_SDAIN 0x01 9 | 10 | #define I2C_READ 0x01 11 | #define I2C_WRITE 0x00 12 | 13 | typedef unsigned char (*i2c_w_read_t)(void); 14 | typedef void (*i2c_w_write_t)(unsigned char value); 15 | typedef unsigned char (*i2c_r_read_t)(void); 16 | 17 | typedef struct { 18 | i2c_w_read_t w_read; 19 | i2c_w_write_t w_write; 20 | i2c_r_read_t r_read; 21 | int started; 22 | } I2C; 23 | 24 | int i2c_init(I2C *i2c); 25 | void i2c_delay(void); 26 | unsigned int i2c_read_bit(I2C *i2c); 27 | void i2c_write_bit(I2C *i2c, unsigned int bit); 28 | void i2c_start_cond(I2C *i2c); 29 | void i2c_stop_cond(I2C *i2c); 30 | unsigned int i2c_write(I2C *i2c, unsigned char byte); 31 | unsigned char i2c_read(I2C *i2c, int ack); 32 | 33 | #endif /* __I2C_H */ 34 | -------------------------------------------------------------------------------- /firmware/isr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "hdmi_in0.h" 6 | #include "hdmi_in1.h" 7 | 8 | void isr(void); 9 | void isr(void) 10 | { 11 | unsigned int irqs; 12 | 13 | irqs = irq_pending() & irq_getmask(); 14 | 15 | if(irqs & (1 << UART_INTERRUPT)) 16 | uart_isr(); 17 | #ifdef CSR_HDMI_IN0_BASE 18 | if(irqs & (1 << HDMI_IN0_INTERRUPT)) 19 | hdmi_in0_isr(); 20 | #endif 21 | #ifdef CSR_HDMI_IN1_BASE 22 | if(irqs & (1 << HDMI_IN1_INTERRUPT)) 23 | hdmi_in1_isr(); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /firmware/linker-ctr.ld: -------------------------------------------------------------------------------- 1 | INCLUDE generated/output_format.ld 2 | ENTRY(_start) 3 | 4 | __DYNAMIC = 0; 5 | 6 | INCLUDE generated/regions.ld 7 | 8 | SECTIONS 9 | { 10 | .text : 11 | { 12 | _ftext = .; 13 | *(.text .stub .text.* .gnu.linkonce.t.*) 14 | _etext = .; 15 | } > main_ram 16 | 17 | .rodata : 18 | { 19 | . = ALIGN(4); 20 | _frodata = .; 21 | *(.rodata .rodata.* .gnu.linkonce.r.*) 22 | *(.rodata1) 23 | _erodata = .; 24 | } > main_ram 25 | 26 | .data : 27 | { 28 | . = ALIGN(4); 29 | _fdata = .; 30 | *(.data .data.* .gnu.linkonce.d.*) 31 | *(.data1) 32 | _gp = ALIGN(16); 33 | *(.sdata .sdata.* .gnu.linkonce.s.*) 34 | _edata = .; 35 | } > main_ram 36 | 37 | .bss : 38 | { 39 | . = ALIGN(4); 40 | _fbss = .; 41 | *(.dynsbss) 42 | *(.sbss .sbss.* .gnu.linkonce.sb.*) 43 | *(.scommon) 44 | *(.dynbss) 45 | *(.bss .bss.* .gnu.linkonce.b.*) 46 | *(COMMON) 47 | . = ALIGN(4); 48 | _ebss = .; 49 | _end = .; 50 | } > sram 51 | } 52 | 53 | PROVIDE(_fstack = ORIGIN(sram) + LENGTH(sram) - 4); 54 | -------------------------------------------------------------------------------- /firmware/linker-xip.ld: -------------------------------------------------------------------------------- 1 | INCLUDE generated/output_format.ld 2 | ENTRY(_start) 3 | 4 | __DYNAMIC = 0; 5 | 6 | INCLUDE generated/regions.ld 7 | 8 | SECTIONS 9 | { 10 | .fbi : 11 | { 12 | . = . + 8; /* Firmware Base Image format (len/crc) data comes first. */ 13 | } > user_flash 14 | 15 | .text : 16 | { 17 | _ftext = .; 18 | *(.text .stub .text.* .gnu.linkonce.t.*) 19 | _etext = .; 20 | } > user_flash 21 | 22 | .rodata : 23 | { 24 | . = ALIGN(4); 25 | _frodata = .; 26 | *(.rodata .rodata.* .gnu.linkonce.r.*) 27 | *(.rodata1) 28 | _erodata = .; 29 | } > user_flash 30 | 31 | .data : AT (ADDR(.rodata) + SIZEOF (.rodata)) 32 | { 33 | . = ALIGN(4); 34 | _fdata = .; 35 | *(.data .data.* .gnu.linkonce.d.*) 36 | *(.data1) 37 | _gp = ALIGN(16); 38 | *(.sdata .sdata.* .gnu.linkonce.s.*) 39 | _edata = ALIGN(16); /* Make sure _edata is >= _gp. */ 40 | } > sram 41 | 42 | .bss : 43 | { 44 | . = ALIGN(4); 45 | _fbss = .; 46 | *(.dynsbss) 47 | *(.sbss .sbss.* .gnu.linkonce.sb.*) 48 | *(.scommon) 49 | *(.dynbss) 50 | *(.bss .bss.* .gnu.linkonce.b.*) 51 | *(COMMON) 52 | . = ALIGN(4); 53 | _ebss = .; 54 | _end = .; 55 | } > sram 56 | } 57 | 58 | PROVIDE(_fstack = ORIGIN(sram) + LENGTH(sram) - 4); 59 | -------------------------------------------------------------------------------- /firmware/mdio.h: -------------------------------------------------------------------------------- 1 | #ifndef __MDIO_H 2 | #define __MDIO_H 3 | 4 | #define MDIO_CLK 0x01 5 | #define MDIO_OE 0x02 6 | #define MDIO_DO 0x04 7 | 8 | #define MDIO_DI 0x01 9 | 10 | void mdio_write(int phyadr, int reg, int val); 11 | int mdio_read(int phyadr, int reg); 12 | void mdio_dump(void); 13 | int mdio_status(void); 14 | 15 | #endif /* __MDIO_H */ 16 | -------------------------------------------------------------------------------- /firmware/mmcm.h: -------------------------------------------------------------------------------- 1 | #ifndef __MMCM_H 2 | #define __MMCM_H 3 | 4 | #include 5 | 6 | typedef void (*mmcm_write_t)(int,int); 7 | typedef int (*mmcm_read_t)(int); 8 | 9 | typedef struct { 10 | mmcm_write_t write; 11 | mmcm_read_t read; 12 | } MMCM; 13 | 14 | void mmcm_config_for_clock(MMCM *mmcm, int freq); 15 | void mmcm_dump(MMCM *mmcm); 16 | void mmcm_dump_all(void); 17 | 18 | #ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR 19 | void hdmi_out0_driver_clocking_mmcm_write(int adr, int data); 20 | int hdmi_out0_driver_clocking_mmcm_read(int adr); 21 | extern MMCM hdmi_out0_driver_clocking_mmcm; 22 | #endif 23 | 24 | #ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR 25 | void hdmi_in0_clocking_mmcm_write(int adr, int data); 26 | int hdmi_in0_clocking_mmcm_read(int adr); 27 | extern MMCM hdmi_in0_clocking_mmcm; 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /firmware/oled.h: -------------------------------------------------------------------------------- 1 | #ifndef __OLED_H 2 | #define __OLED_H 3 | 4 | #define OLED_RESET 0x01 5 | #define OLED_DC 0x02 6 | #define OLED_VBAT 0x04 7 | #define OLED_VDD 0x08 8 | 9 | #define SSD1306_SETCONTRAST 0x81 10 | #define SSD1306_DISPLAYALLON_RESUME 0xa4 11 | #define SSD1306_DISPLAYALLON 0xa5 12 | #define SSD1306_NORMALDISPLAY 0xa6 13 | #define SSD1306_INVERTDISPLAY 0xa7 14 | #define SSD1306_DISPLAYOFF 0xae 15 | #define SSD1306_DISPLAYON 0xaf 16 | #define SSD1306_SETDISPLAYOFFSET 0xd3 17 | #define SSD1306_SETCOMPINS 0xda 18 | #define SSD1306_SETVCOMDETECT 0xdb 19 | #define SSD1306_SETDISPLAYCLOCKDIV 0xd5 20 | #define SSD1306_SETPRECHARGE 0xd9 21 | #define SSD1306_SETMULTIPLEX 0xa8 22 | #define SSD1306_SETLOWCOLUMN 0x00 23 | #define SSD1306_SETHIGHCOLUMN 0x10 24 | #define SSD1306_SETSTARTLINE 0x40 25 | #define SSD1306_MEMORYMODE 0x20 26 | #define SSD1306_COLUMNADDR 0x21 27 | #define SSD1306_PAGEADDR 0x22 28 | #define SSD1306_COMSCANINC 0xc0 29 | #define SSD1306_COMSCANDEC 0xc8 30 | #define SSD1306_SEGREMAP 0xa0 31 | #define SSD1306_CHARGEPUMP 0x8d 32 | #define SSD1306_EXTERNALVCC 0x01 33 | #define SSD1306_SWITCHCAPVCC 0x02 34 | 35 | #define SSD1306_ACTIVATE_SCROLL 0x2f 36 | #define SSD1306_DEACTIVATE_SCROLL 0x2e 37 | #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xa3 38 | #define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 39 | #define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 40 | #define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 41 | #define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2a 42 | 43 | void oled_spi_write(unsigned char value); 44 | void oled_write_command(unsigned char value); 45 | void oled_write_data(unsigned char value); 46 | void oled_init(void); 47 | void oled_refresh(void); 48 | 49 | #endif /* __OLED_H */ 50 | -------------------------------------------------------------------------------- /firmware/opsis_eeprom.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #ifdef CSR_OPSIS_I2C_MASTER_W_ADDR 5 | #include "i2c.h" 6 | #include "opsis_eeprom.h" 7 | #include "stdio_wrap.h" 8 | 9 | I2C opsis_eeprom_i2c; 10 | int opsis_eeprom_debug_enabled = 0; 11 | 12 | void opsis_eeprom_i2c_init(void) { 13 | wprintf("opsis_eeprom: Init..."); 14 | opsis_eeprom_i2c.w_read = opsis_i2c_master_w_read; 15 | opsis_eeprom_i2c.w_write = opsis_i2c_master_w_write; 16 | opsis_eeprom_i2c.r_read = opsis_i2c_master_r_read; 17 | OPSIS_I2C_ACTIVE(OPSIS_I2C_GPIO); 18 | i2c_init(&opsis_eeprom_i2c); 19 | wprintf("finished.\n"); 20 | } 21 | 22 | static void opsis_eeprom_read(uint8_t addr) { 23 | unsigned char b; 24 | 25 | OPSIS_I2C_ACTIVE(OPSIS_I2C_GPIO); 26 | i2c_init(&opsis_eeprom_i2c); 27 | 28 | // Write address to I2C EEPROM 29 | i2c_start_cond(&opsis_eeprom_i2c); 30 | b = i2c_write(&opsis_eeprom_i2c, OPSIS_EEPROM_SLAVE_ADDRESS | I2C_WRITE); 31 | if (!b && opsis_eeprom_debug_enabled) 32 | wprintf("opsis_eeprom: NACK while writing slave address!\n"); 33 | b = i2c_write(&opsis_eeprom_i2c, addr); 34 | if (!b && opsis_eeprom_debug_enabled) 35 | wprintf("opsis_eeprom: NACK while writing opsis_eeprom address!\n"); 36 | 37 | // Read data from I2C EEPROM 38 | i2c_start_cond(&opsis_eeprom_i2c); 39 | b = i2c_write(&opsis_eeprom_i2c, OPSIS_EEPROM_SLAVE_ADDRESS | I2C_READ); 40 | if (!b && opsis_eeprom_debug_enabled) 41 | wprintf("opsis_eeprom: NACK while writing slave address (2)!\n"); 42 | } 43 | 44 | void opsis_eeprom_dump(void) { 45 | opsis_eeprom_read(0); 46 | for (int i = 0 ; i < 256 ; i++) { 47 | unsigned char b = i2c_read(&opsis_eeprom_i2c, 1); 48 | wprintf("%02X ", b); 49 | if(!((i+1) % 16)) 50 | wputchar('\n'); 51 | } 52 | i2c_stop_cond(&opsis_eeprom_i2c); 53 | } 54 | 55 | void opsis_eeprom_mac(unsigned char mac[6]) { 56 | opsis_eeprom_read(OPSIS_EEPROM_MAC); 57 | for (int i = 0 ; i < 6; i++) { 58 | unsigned char b = i2c_read(&opsis_eeprom_i2c, 1); 59 | mac[i] = b; 60 | } 61 | i2c_stop_cond(&opsis_eeprom_i2c); 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /firmware/opsis_eeprom.h: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef CSR_OPSIS_I2C_MASTER_W_ADDR 3 | 4 | #include "opsis_i2c.h" 5 | 6 | #define OPSIS_EEPROM_SLAVE_ADDRESS 0xA0 7 | 8 | #define OPSIS_EEPROM_MAC 0xFA 9 | 10 | void opsis_eeprom_i2c_init(void); 11 | void opsis_eeprom_dump(void); 12 | void opsis_eeprom_mac(unsigned char mac[6]); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /firmware/opsis_i2c.h: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef CSR_OPSIS_I2C_MUX_SEL_ADDR 3 | 4 | #define OPSIS_I2C_GPIO 0 5 | #define OPSIS_I2C_FX2HACK 1 6 | 7 | #define OPSIS_I2C_ACTIVE(x) \ 8 | opsis_i2c_mux_sel_write(x); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /firmware/pattern.h: -------------------------------------------------------------------------------- 1 | #ifndef __PATTERN_H 2 | #define __PATTERN_H 3 | 4 | #include "framebuffer.h" 5 | 6 | /* Colors in YCBCR422 format (see pattern.py) */ 7 | #define YCBCR422_WHITE 0x80ff80ff 8 | #define YCBCR422_YELLOW 0x00e194e1 9 | #define YCBCR422_CYAN 0xabb200b2 10 | #define YCBCR422_GREEN 0x2b951595 11 | #define YCBCR422_PURPLE 0xd469e969 12 | #define YCBCR422_RED 0x544cff4c 13 | #define YCBCR422_BLUE 0xff1d6f1d 14 | #define YCBCR422_BLACK 0x80108010 15 | 16 | /* Colors in RGB format */ 17 | #define RGB_WHITE 0x00ffffff 18 | #define RGB_YELLOW 0x0000ffff 19 | #define RGB_CYAN 0x00ffff00 20 | #define RGB_GREEN 0x0000ff00 21 | #define RGB_PURPLE 0x00ff00ff 22 | #define RGB_RED 0x000000ff 23 | #define RGB_BLUE 0x00ff0000 24 | #define RGB_BLACK 0x00000000 25 | 26 | unsigned int pattern_framebuffer_base(void); 27 | 28 | enum { 29 | PATTERN_COLOR_BARS = 0, 30 | PATTERN_VERTICAL_BLACK_WHITE_LINES = 1, 31 | PATTERN_MAX, 32 | } pattern; 33 | 34 | void pattern_fill_framebuffer(int h_active, int m_active); 35 | void pattern_service(void); 36 | void pattern_next(void); 37 | 38 | #endif /* __PATTERN_H */ 39 | -------------------------------------------------------------------------------- /firmware/pattern.py: -------------------------------------------------------------------------------- 1 | def rgb2ycbcr(r, g, b): 2 | y = int(0.299*r + 0.587*g + 0.114*b) 3 | cb = int(-0.1687*r - 0.3313*g + 0.5*b + 128) 4 | cr = int(0.5*r - 0.4187*g - 0.0813*b + 128) 5 | return y, cb, cr 6 | 7 | def ycbcr_pack(y, cb, cr): 8 | value = y 9 | value |= cr << 8 10 | value |= y << 16 11 | value |= cb << 24 12 | return value 13 | 14 | color_bars_rgb = [ 15 | [255, 255, 255], 16 | [255, 255, 0], 17 | [0, 255, 255], 18 | [0, 255, 0], 19 | [255, 0, 255], 20 | [255, 0, 0], 21 | [0, 0, 255], 22 | [0, 0, 0], 23 | ] 24 | 25 | color_bars_ycbcr = [] 26 | for color_bar_rgb in color_bars_rgb: 27 | r, g, b = color_bar_rgb 28 | y, cb, cr = rgb2ycbcr(r, g, b) 29 | color_bars_ycbcr.append([y, cb, cr]) 30 | 31 | for color_bar_ycbcr in color_bars_ycbcr: 32 | value = ycbcr_pack(*color_bar_ycbcr) 33 | print("%08x" %value) 34 | -------------------------------------------------------------------------------- /firmware/pll.h: -------------------------------------------------------------------------------- 1 | #ifndef __PLL_H 2 | #define __PLL_H 3 | 4 | void pll_config_for_clock(int freq); 5 | void pll_dump(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /firmware/reboot.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "reboot.h" 9 | 10 | #ifndef CONFIG_CPU_RESET_ADDR 11 | #define CONFIG_CPU_RESET_ADDR 0 12 | #warning "CPU reset address was not defined! Using 0." 13 | #endif 14 | 15 | extern void boot_helper(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int addr); 16 | 17 | void reboot(void) 18 | { 19 | boot(0, 0, 0, CONFIG_CPU_RESET_ADDR); 20 | } 21 | 22 | void __attribute__((noreturn)) boot(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int addr) 23 | { 24 | printf("Booting program at 0x%x.\n", addr); 25 | uart_sync(); 26 | irq_setmask(0); 27 | irq_setie(0); 28 | flush_cpu_icache(); 29 | boot_helper(r1, r2, r3, addr); 30 | while(1); 31 | } 32 | -------------------------------------------------------------------------------- /firmware/reboot.h: -------------------------------------------------------------------------------- 1 | #ifndef __REBOOT_H 2 | #define __REBOOT_H 3 | 4 | void reboot(void); 5 | void __attribute__((noreturn)) boot(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int addr); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /firmware/stdio_wrap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include // Needed for ETHMAC_BASE 8 | 9 | #include "telnet.h" 10 | 11 | #include "stdio_wrap.h" 12 | 13 | /* Transform LF -> CRLF in s, putting the result in stdio_write_buffer 14 | */ 15 | char *translate_crlf(const char *s, int trailing_lf) { 16 | assert(tailing_lf == 0 || trailing_lf == 1); 17 | char *out = stdio_write_buffer; 18 | char *end = stdio_write_buffer + STDIO_BUFFER_SIZE - 2 - trailing_lf; 19 | while (*s != '\0' && out < end) { 20 | if (*s == '\n') { 21 | assert(out < end); 22 | *out++ = '\r'; 23 | } 24 | assert(out < end); 25 | *out++ = *s++; 26 | } 27 | if (trailing_lf) { 28 | *out++ = '\r'; 29 | } 30 | *out++ = '\0'; 31 | return stdio_write_buffer; 32 | } 33 | 34 | int wputs(const char *s) 35 | { 36 | char *s_crlf = translate_crlf(s, 1); 37 | #ifdef ETHMAC_BASE 38 | if(telnet_active) 39 | telnet_puts(s_crlf); 40 | else 41 | #endif 42 | puts(s_crlf); 43 | return 0; 44 | } 45 | 46 | int wputchar(int c) 47 | { 48 | #ifdef ETHMAC_BASE 49 | if(telnet_active) { 50 | if(c == '\n') { 51 | telnet_putchar('\r'); 52 | } 53 | telnet_putchar(c); 54 | } else { 55 | #endif 56 | if(c == '\n') { 57 | putchar('\r'); 58 | } 59 | putchar(c); 60 | #ifdef ETHMAC_BASE 61 | } 62 | #endif 63 | return 0; 64 | } 65 | 66 | int wprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); 67 | int wprintf(const char *fmt, ...) 68 | { 69 | int len; 70 | va_list args; 71 | va_start(args, fmt); 72 | 73 | char *fmt_crlf = translate_crlf(fmt, 0); 74 | 75 | #ifdef ETHMAC_BASE 76 | if(telnet_active) 77 | len = telnet_vprintf(fmt_crlf, args); 78 | else 79 | #endif 80 | len = vprintf(fmt_crlf, args); 81 | va_end(args); 82 | return len; 83 | } 84 | 85 | void wputsnonl(const char *s) 86 | { 87 | #ifdef ETHMAC_BASE 88 | if(telnet_active) 89 | telnet_putsnonl(s); 90 | else 91 | #endif 92 | putsnonl(s); 93 | } 94 | -------------------------------------------------------------------------------- /firmware/stdio_wrap.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define STDIO_BUFFER_SIZE 256 4 | char stdio_write_buffer[STDIO_BUFFER_SIZE]; 5 | 6 | char *translate_crlf(const char *s, int trailing_lf); 7 | 8 | int wputs(const char *s); 9 | int wputchar(int c); 10 | int wprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); 11 | void wputsnonl(const char *s); 12 | 13 | int sprintf(char *str, const char *format, ...) __attribute__((format(printf, 2, 3))); 14 | int snprintf(char *str, size_t size, const char *format, ...) __attribute__((format(printf, 3, 4))); 15 | -------------------------------------------------------------------------------- /firmware/stub/Makefile: -------------------------------------------------------------------------------- 1 | include ../include/generated/variables.mak 2 | include $(SOC_DIRECTORY)/software/common.mak 3 | 4 | OBJECTS=\ 5 | main.o \ 6 | isr.o \ 7 | boot-helper-$(CPU).o 8 | 9 | CFLAGS += -I$(STUB_DIRECTORY) \ 10 | -I$(FIRMWARE_DIRECTORY) 11 | 12 | CFLAGS += \ 13 | -Wall \ 14 | -Werror \ 15 | -Wno-error=unused-function \ 16 | -Wno-error=unused-variable 17 | 18 | LDFLAGS += \ 19 | 20 | LINKER_LD=linker.ld 21 | 22 | 23 | all: firmware.bin firmware.fbi 24 | 25 | %.fbi: %.bin 26 | ifeq ($(CPUENDIANNESS), little) 27 | $(PYTHON) -m litex.soc.software.mkmscimg -f --little $< -o $@ 28 | else 29 | $(PYTHON) -m litex.soc.software.mkmscimg -f $< -o $@ 30 | endif 31 | 32 | %.bin: %.elf 33 | $(OBJCOPY) -O binary $< $@ 34 | chmod -x $@ 35 | 36 | firmware.elf: $(STUB_DIRECTORY)/$(LINKER_LD) $(OBJECTS) 37 | 38 | %.elf: ../libbase/crt0-$(CPU)-xip.o ../libbase/libbase-nofloat.a ../libcompiler_rt/libcompiler_rt.a 39 | $(LD) $(LDFLAGS) \ 40 | -T $(STUB_DIRECTORY)/$(LINKER_LD) \ 41 | -N -o $@ \ 42 | ../libbase/crt0-$(CPU)-xip.o \ 43 | $(OBJECTS) \ 44 | -L../libbase \ 45 | -lbase-nofloat \ 46 | -L../libcompiler_rt \ 47 | -lcompiler_rt 48 | chmod -x $@ 49 | 50 | 51 | # pull in dependency info for *existing* .o files 52 | -include $(OBJECTS:.o=.d) 53 | 54 | boot-helper-$(CPU).S: $(BIOS_DIRECTORY)/boot-helper-$(CPU).S 55 | cp $< $@ 56 | 57 | boot-helper-$(CPU).o: boot-helper-$(CPU).S 58 | $(assemble) 59 | 60 | %.o: $(STUB_DIRECTORY)/%.c 61 | $(compile) 62 | 63 | %.o: $(STUB_DIRECTORY)/%.S 64 | $(assemble) 65 | 66 | clean: 67 | $(RM) $(OBJECTS) $(OBJECTS:.o=.d) firmware.elf firmware.bin .*~ *~ 68 | -------------------------------------------------------------------------------- /firmware/stub/isr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern void periodic_isr(void); 6 | 7 | void isr(void); 8 | void isr(void) 9 | { 10 | unsigned int irqs; 11 | 12 | irqs = irq_pending() & irq_getmask(); 13 | 14 | if(irqs & (1 << UART_INTERRUPT)) 15 | uart_isr(); 16 | } 17 | -------------------------------------------------------------------------------- /firmware/stub/linker.ld: -------------------------------------------------------------------------------- 1 | INCLUDE generated/output_format.ld 2 | ENTRY(_start) 3 | 4 | __DYNAMIC = 0; 5 | 6 | INCLUDE generated/regions.ld 7 | 8 | SECTIONS 9 | { 10 | .fbi : 11 | { 12 | . = . + 8; /* Firmware Base Image format (len/crc) data comes first. */ 13 | } > user_flash 14 | 15 | .text : 16 | { 17 | _ftext = .; 18 | *(.text .stub .text.* .gnu.linkonce.t.*) 19 | _etext = .; 20 | } > user_flash 21 | 22 | .rodata : 23 | { 24 | . = ALIGN(4); 25 | _frodata = .; 26 | *(.rodata .rodata.* .gnu.linkonce.r.*) 27 | *(.rodata1) 28 | _erodata = .; 29 | } > user_flash 30 | 31 | .data : AT (ADDR(.rodata) + SIZEOF (.rodata)) 32 | { 33 | . = ALIGN(4); 34 | _fdata = .; 35 | *(.data .data.* .gnu.linkonce.d.*) 36 | *(.data1) 37 | _gp = ALIGN(16); 38 | *(.sdata .sdata.* .gnu.linkonce.s.*) 39 | _edata = ALIGN(16); /* Make sure _edata is >= _gp. */ 40 | } > sram 41 | 42 | .bss : 43 | { 44 | . = ALIGN(4); 45 | _fbss = .; 46 | *(.dynsbss) 47 | *(.sbss .sbss.* .gnu.linkonce.sb.*) 48 | *(.scommon) 49 | *(.dynbss) 50 | *(.bss .bss.* .gnu.linkonce.b.*) 51 | *(COMMON) 52 | . = ALIGN(4); 53 | _ebss = .; 54 | _end = .; 55 | } > sram 56 | } 57 | 58 | PROVIDE(_fstack = ORIGIN(sram) + LENGTH(sram) - 4); 59 | -------------------------------------------------------------------------------- /firmware/telnet.h: -------------------------------------------------------------------------------- 1 | // This file is Copyright (c) 2015 Florent Kermarrec 2 | // License: BSD 3 | 4 | #ifndef __TELNET_H 5 | #define __TELNET_H 6 | 7 | #include 8 | 9 | #include "contiki.h" 10 | #include "contiki-net.h" 11 | 12 | //#define TELNET_DEBUG 13 | 14 | #ifdef TELNET_DEBUG 15 | #define print_debug(...) printf(__VA_ARGS__) 16 | #else 17 | #define print_debug(...) {} 18 | #endif 19 | 20 | #define TELNET_PORT 23 21 | #define TELNET_BUFFER_SIZE_RX 4096 22 | #define TELNET_BUFFER_SIZE_TX 4096 23 | 24 | int telnet_active; 25 | 26 | struct tcp_socket telnet_socket; 27 | uint8_t telnet_rx_buffer[TELNET_BUFFER_SIZE_RX]; 28 | uint8_t telnet_tx_buffer[TELNET_BUFFER_SIZE_TX]; 29 | 30 | void telnet_init(void); 31 | int telnet_event_callback(struct tcp_socket *s, void *ptr, tcp_socket_event_t event); 32 | int telnet_data_callback(struct tcp_socket *s, void *ptr, const char *rxbuf, int rxlen); 33 | 34 | char telnet_readchar(void); 35 | int telnet_readchar_nonblock(void); 36 | 37 | int telnet_putchar(char c); 38 | int telnet_puts(const char *s); 39 | void telnet_putsnonl(const char *s); 40 | 41 | int telnet_vprintf(const char *fmt, va_list argp); 42 | int telnet_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /firmware/tofe_eeprom.c: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef CSR_TOFE_I2C_W_ADDR 3 | #include "i2c.h" 4 | #include "tofe_eeprom.h" 5 | #include "stdio_wrap.h" 6 | 7 | I2C tofe_eeprom_i2c; 8 | int tofe_eeprom_debug_enabled = 0; 9 | 10 | void tofe_eeprom_i2c_init(void) { 11 | wprintf("tofe_eeprom: Init..."); 12 | tofe_eeprom_i2c.w_read = tofe_i2c_w_read; 13 | tofe_eeprom_i2c.w_write = tofe_i2c_w_write; 14 | tofe_eeprom_i2c.r_read = tofe_i2c_r_read; 15 | i2c_init(&tofe_eeprom_i2c); 16 | wprintf("finished.\n"); 17 | } 18 | 19 | void tofe_eeprom_dump(void) { 20 | int tofe_eeprom_addr = 0; 21 | unsigned char b; 22 | 23 | i2c_start_cond(&tofe_eeprom_i2c); 24 | b = i2c_write(&tofe_eeprom_i2c, 0xa0); 25 | if (!b && tofe_eeprom_debug_enabled) 26 | wprintf("tofe_eeprom: NACK while writing slave address!\n"); 27 | b = i2c_write(&tofe_eeprom_i2c, 0x00); 28 | if (!b && tofe_eeprom_debug_enabled) 29 | wprintf("tofe_eeprom: NACK while writing tofe_eeprom address!\n"); 30 | 31 | i2c_start_cond(&tofe_eeprom_i2c); 32 | b = i2c_write(&tofe_eeprom_i2c, 0xa1); 33 | if (!b && tofe_eeprom_debug_enabled) 34 | wprintf("tofe_eeprom: NACK while writing slave address (2)!\n"); 35 | 36 | for (tofe_eeprom_addr = 0 ; tofe_eeprom_addr < 256 ; tofe_eeprom_addr++) { 37 | b = i2c_read(&tofe_eeprom_i2c, 1); 38 | wprintf("%02X ", b); 39 | if(!((tofe_eeprom_addr+1) % 16)) 40 | wputchar('\n'); 41 | } 42 | i2c_stop_cond(&tofe_eeprom_i2c); 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /firmware/tofe_eeprom.h: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef CSR_TOFE_I2C_W_ADDR 3 | 4 | void tofe_eeprom_i2c_init(void); 5 | void tofe_eeprom_dump(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /firmware/uip/Makefile: -------------------------------------------------------------------------------- 1 | include ../include/generated/variables.mak 2 | include $(SOC_DIRECTORY)/software/common.mak 3 | 4 | VPATH=$(UIP_DIRECTORY) 5 | 6 | include $(UIP_DIRECTORY)/Makefile.mk 7 | 8 | #See here for-fno-strict-aliasing -fpack-struct: 9 | #http://sourceforge.net/p/contiki/mailman/message/28002063/ 10 | 11 | CCDEP=$(CC) 12 | 13 | UIPCOREOBJS=$(LIBUIPDIR)/net/ip/dhcpc.o \ 14 | $(LIBUIPDIR)/net/ip/psock.o \ 15 | $(LIBUIPDIR)/net/ip/resolv.o \ 16 | $(LIBUIPDIR)/net/ip/simple-udp.o \ 17 | $(LIBUIPDIR)/net/ip/slipdev.o \ 18 | $(LIBUIPDIR)/net/ip/tcpip.o \ 19 | $(LIBUIPDIR)/net/ip/tcp-socket.o \ 20 | $(LIBUIPDIR)/net/ip/udp-socket.o \ 21 | $(LIBUIPDIR)/net/ip/uip-debug.o \ 22 | $(LIBUIPDIR)/net/ip/uiplib.o \ 23 | $(LIBUIPDIR)/net/ip/uip-packetqueue.o \ 24 | $(LIBUIPDIR)/net/ip/uip-split.o \ 25 | $(LIBUIPDIR)/net/ip/uip-udp-packet.o \ 26 | $(LIBUIPDIR)/net/ipv4/uaodv.o \ 27 | $(LIBUIPDIR)/net/ipv4/uaodv-rt.o \ 28 | $(LIBUIPDIR)/net/ipv4/uip.o \ 29 | $(LIBUIPDIR)/net/ipv4/uip_arp.o \ 30 | $(LIBUIPDIR)/net/ipv4/uip-fw.o \ 31 | $(LIBUIPDIR)/net/ipv4/uip-fw-drv.o \ 32 | $(LIBUIPDIR)/net/ipv4/uip-neighbor.o \ 33 | $(LIBUIPDIR)/net/ipv4/uip-over-mesh.o \ 34 | $(LIBUIPDIR)/net/linkaddr.o \ 35 | $(LIBUIPDIR)/net/nbr-table.o \ 36 | $(LIBUIPDIR)/net/netstack.o \ 37 | $(LIBUIPDIR)/net/packetbuf.o \ 38 | $(LIBUIPDIR)/net/queuebuf.o \ 39 | $(LIBUIPDIR)/sys/process.o \ 40 | $(LIBUIPDIR)/sys/etimer.o \ 41 | $(LIBUIPDIR)/sys/timer.o \ 42 | $(LIBUIPDIR)/lib/list.o 43 | 44 | UIPARCHOBJS=\ 45 | $(UIPDIR)/clock-arch.o \ 46 | $(UIPDIR)/rtimer-arch.o \ 47 | $(UIPDIR)/liteethmac-drv.o 48 | 49 | UIPOBJS=$(UIPCOREOBJS) $(UIPARCHOBJS) 50 | OBJS_LIB+=$(UIPOBJS) 51 | 52 | UIPLIB=libuip.a 53 | 54 | all: $(UIPLIB) 55 | 56 | .PHONY: all compile clean 57 | 58 | # pull in dependency info for *existing* .o files 59 | -include $(UIPOBJS:.o=.d) 60 | 61 | %.o: %.c 62 | @mkdir -p $(@D) 63 | $(compile) 64 | 65 | %.o: %.S 66 | @mkdir -p $(@D) 67 | $(assemble) 68 | 69 | clean: 70 | rm -f $(UIPOBJS) $(UIPOBJS:.o=.d) libuip.a 71 | 72 | libuip.a: $(UIPOBJS) 73 | $(AR) clr libuip.a $(UIPOBJS) 74 | -------------------------------------------------------------------------------- /firmware/uip/Makefile.mk: -------------------------------------------------------------------------------- 1 | LIBUIPDIR=../../third_party/libuip 2 | UIPDIR=. 3 | 4 | CFLAGS += \ 5 | -I$(UIP_DIRECTORY)/$(UIPDIR) \ 6 | -I$(UIP_DIRECTORY)/$(LIBUIPDIR) \ 7 | -I$(UIP_DIRECTORY)/$(LIBUIPDIR)/net \ 8 | -Wno-char-subscripts \ 9 | -fno-strict-aliasing -fpack-struct 10 | -------------------------------------------------------------------------------- /firmware/uip/clock-arch.c: -------------------------------------------------------------------------------- 1 | // This file is Copyright (c) 2015 Florent Kermarrec 2 | // License: BSD 3 | 4 | #include "contiki-conf.h" 5 | #include "clock-arch.h" 6 | #include 7 | 8 | /*-----------------------------------------------------------------------------------*/ 9 | void clock_init(void) 10 | { 11 | timer0_en_write(0); 12 | timer0_load_write(0xffffffff); 13 | timer0_reload_write(0xffffffff); 14 | timer0_en_write(1); 15 | } 16 | 17 | /*---------------------------------------------------------------------------*/ 18 | clock_time_t clock_time(void) 19 | { 20 | unsigned int freq; 21 | unsigned int prescaler; 22 | clock_time_t ticks; 23 | 24 | freq = CONFIG_CLOCK_FREQUENCY; 25 | prescaler = freq/CLOCK_CONF_SECOND; 26 | timer0_update_value_write(1); 27 | ticks = (0xffffffff - timer0_value_read())/prescaler; 28 | return ticks; 29 | } 30 | -------------------------------------------------------------------------------- /firmware/uip/clock-arch.h: -------------------------------------------------------------------------------- 1 | // This file is Copyright (c) 2015 Florent Kermarrec 2 | // License: BSD 3 | 4 | #ifndef __CLOCK_ARCH_H__ 5 | #define __CLOCK_ARCH_H__ 6 | 7 | void clock_init(void); 8 | clock_time_t clock_time(void); 9 | 10 | #endif /* __CLOCK_ARCH_H__ */ 11 | -------------------------------------------------------------------------------- /firmware/uip/contiki-conf.h: -------------------------------------------------------------------------------- 1 | #ifndef CONTIKI_CONF_H__ 2 | #define CONTIKI_CONF_H__ 3 | 4 | #include 5 | #include 6 | 7 | #define CCIF 8 | #define CLIF 9 | 10 | #define NETSTACK_CONF_WITH_IPV4 1 11 | #define WITH_ASCII 1 12 | 13 | #define CLOCK_CONF_SECOND 128 14 | 15 | typedef unsigned char u8_t; 16 | typedef unsigned short u16_t; 17 | typedef unsigned int u32_t; 18 | typedef char s8_t; 19 | typedef short s16_t; 20 | typedef int s32_t; 21 | 22 | typedef unsigned int clock_time_t; 23 | typedef unsigned int uip_stats_t; 24 | 25 | #ifndef BV 26 | #define BV(x) (1<<(x)) 27 | #endif 28 | 29 | /* uIP configuration */ 30 | #if defined(__lm32__) || defined(__or1k__) 31 | #define UIP_CONF_BYTE_ORDER UIP_BIG_ENDIAN 32 | #else 33 | #define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN 34 | #endif 35 | 36 | #define UIP_CONF_LLH_LEN 14 37 | #define UIP_CONF_BROADCAST 1 38 | #define UIP_CONF_LOGGING 1 39 | #define UIP_CONF_BUFFER_SIZE 256 40 | 41 | #define UIP_CONF_TCP_FORWARD 1 42 | 43 | #endif /* CONTIKI_CONF_H__ */ 44 | -------------------------------------------------------------------------------- /firmware/uip/liteethmac-drv.h: -------------------------------------------------------------------------------- 1 | // This file is Copyright (c) 2015 Florent Kermarrec 2 | // License: BSD 3 | #ifndef __LITEETHMAC_H__ 4 | #define __LITEETHMAC_H__ 5 | 6 | void liteethmac_init(void); 7 | uint16_t liteethmac_poll(void); 8 | void liteethmac_send(void); 9 | void liteethmac_exit(void); 10 | 11 | #endif /* __LITEETHMAC_H__ */ 12 | -------------------------------------------------------------------------------- /firmware/uip/rtimer-arch.c: -------------------------------------------------------------------------------- 1 | #include "contiki.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #define RTIMER_DEBUG 9 | 10 | void rtimer_callback(void) 11 | { 12 | #ifdef RTIMER_DEBUG 13 | printf("XXX rtimer_callback"); 14 | #endif 15 | rtimer_run_next(); 16 | } 17 | 18 | void rtimer_arch_init(void) 19 | { 20 | #ifdef RTIMER_DEBUG 21 | printf("XXX rtimer_arch_init"); 22 | #endif 23 | } 24 | 25 | rtimer_clock_t rtimer_arch_now(void) 26 | { 27 | #ifdef RTIMER_DEBUG 28 | printf("XXX rtimer_arch_now"); 29 | #endif 30 | return 0; 31 | } 32 | 33 | void rtimer_arch_schedule(rtimer_clock_t t) 34 | { 35 | #ifdef RTIMER_DEBUG 36 | printf("XXX rtimer_arch_schedule"); 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /firmware/uip/rtimer-arch.h: -------------------------------------------------------------------------------- 1 | #ifndef RTIMER_ARCH_H_ 2 | #define RTIMER_ARCH_H_ 3 | 4 | #include "contiki-conf.h" 5 | 6 | #include 7 | 8 | void rtimer_callback(void); 9 | void rtimer_arch_init(void); 10 | rtimer_clock_t rtimer_arch_now(void); 11 | void rtimer_arch_schedule(rtimer_clock_t t); 12 | #define RTIMER_ARCH_SECOND 312500 13 | 14 | #endif 15 | 16 | /** @} */ 17 | -------------------------------------------------------------------------------- /firmware/uptime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include "uptime.h" 8 | 9 | #include "stdio_wrap.h" 10 | 11 | static int uptime_seconds = 0; 12 | void uptime_service(void) 13 | { 14 | static int last_event; 15 | 16 | if(elapsed(&last_event, CONFIG_CLOCK_FREQUENCY)) { 17 | uptime_seconds++; 18 | } 19 | } 20 | 21 | int uptime(void) 22 | { 23 | return uptime_seconds; 24 | } 25 | 26 | void uptime_print(void) 27 | { 28 | wprintf("uptime: %s\n", uptime_str()); 29 | } 30 | 31 | const char* uptime_str(void) 32 | { 33 | static char buffer[9]; 34 | sprintf(buffer, "%02d:%02d:%02d", 35 | (uptime_seconds/3600)%24, 36 | (uptime_seconds/60)%60, 37 | uptime_seconds%60); 38 | return buffer; 39 | } 40 | -------------------------------------------------------------------------------- /firmware/uptime.h: -------------------------------------------------------------------------------- 1 | #ifndef __UPTIME_H 2 | #define __UPTIME_H 3 | 4 | void uptime_service(void); 5 | int uptime(void); 6 | 7 | void uptime_print(void); 8 | const char* uptime_str(void); 9 | 10 | #endif /* __CONFIG_H */ 11 | -------------------------------------------------------------------------------- /firmware/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __VERSION_H 2 | #define __VERSION_H 3 | 4 | void print_board_dna(void); 5 | void print_board_mac(void); 6 | void print_version(void); 7 | 8 | #endif // __VERSION_H 9 | -------------------------------------------------------------------------------- /firmware/version_data.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # These must be outside the heredoc below otherwise the script won't error. 6 | COMMIT="$(git log --format="%H" -n 1)" 7 | BRANCH="$(git symbolic-ref --short HEAD)" 8 | DESCRIBE="$(git describe --dirty)" 9 | 10 | TMPFILE_H=$(tempfile -s .h 2>/dev/null || mktemp --suffix=.h) 11 | TMPFILE_C=$(tempfile -s .c 2>/dev/null || mktemp --suffix=.c) 12 | 13 | UPLATFORM="$(echo $PLATFORM | tr '[:lower:]' '[:upper:]')" 14 | UTARGET="$(echo $TARGET | tr '[:lower:]' '[:upper:]')" 15 | 16 | cat > $TMPFILE_H < $TMPFILE_C <I", w)[0]) 25 | data_size = len(data)*4 26 | assert data_size > 0 27 | assert data_size < size, ( 28 | "Firmware is too big! {} bytes > {} bytes".format( 29 | data_size, size)) 30 | print("Firmware {} bytes ({} bytes left)".format( 31 | data_size, size-data_size)) 32 | wishbone.SRAM.__init__(self, size, init=data) 33 | else: 34 | print("No firmware found! ({}) Won't compile.".format( 35 | filename)) 36 | wishbone.SRAM.__init__(self, size) 37 | 38 | self.mem.__class__ = MemoryMustHaveContents 39 | self.mem.filename = filename 40 | -------------------------------------------------------------------------------- /gateware/info/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Module for info embedded in the gateware / board. 3 | """ 4 | 5 | from litex.build.generic_platform import ConstraintError 6 | from migen import * 7 | from litex.soc.interconnect.csr import * 8 | 9 | from gateware.info import git 10 | from gateware.info import dna 11 | from gateware.info import xadc 12 | from gateware.info import platform as platform_info 13 | 14 | 15 | class Info(Module, AutoCSR): 16 | def __init__(self, platform, target_name): 17 | self.submodules.dna = dna.DNA() 18 | self.submodules.git = git.GitInfo() 19 | target = target_name.lower()[:-3] 20 | self.submodules.platform = platform_info.PlatformInfo(platform.name, target) 21 | 22 | if "xc7" in platform.device: 23 | self.submodules.xadc = xadc.XADC() 24 | 25 | -------------------------------------------------------------------------------- /gateware/info/dna.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014-2015 Robert Jordens 2 | 3 | from migen import * 4 | from litex.soc.interconnect.csr import * 5 | 6 | 7 | class DNA(Module, AutoCSR): 8 | def __init__(self): 9 | n = 57 10 | self._id = CSRStatus(n) 11 | 12 | # # # 13 | 14 | do = Signal() 15 | cnt = Signal(max=2*n + 1) 16 | 17 | self.specials += Instance("DNA_PORT", 18 | i_DIN=self._id.status[-1], o_DOUT=do, 19 | i_CLK=cnt[0], i_READ=cnt < 2, i_SHIFT=1) 20 | 21 | self.sync += \ 22 | If(cnt < 2*n, 23 | cnt.eq(cnt + 1), 24 | If(cnt[0], 25 | self._id.status.eq(Cat(do, self._id.status)) 26 | ) 27 | ) 28 | -------------------------------------------------------------------------------- /gateware/info/platform.py: -------------------------------------------------------------------------------- 1 | from migen.fhdl import * 2 | from litex.soc.interconnect.csr import * 3 | 4 | 5 | def binify(s, size): 6 | assert size % 8 == 0 7 | blen = int(size / 8) 8 | assert len(s) <= blen, "{} <= {}".format(len(s), blen) 9 | s = s+'\0'*(blen-len(s)) 10 | return sum(ord(c) << i * 8 for i, c in enumerate(reversed(s))) 11 | 12 | 13 | class PlatformInfo(Module, AutoCSR): 14 | def __init__(self, platform, target): 15 | self.platform = CSRStatus(64) 16 | self.target = CSRStatus(64) 17 | 18 | self.comb += [ 19 | self.platform.status.eq(binify(platform[:8], 64)), 20 | self.target.status.eq(binify(target[:8], 64)), 21 | ] 22 | -------------------------------------------------------------------------------- /gateware/led.py: -------------------------------------------------------------------------------- 1 | from migen import * 2 | 3 | from litex.soc.interconnect.csr import * 4 | from litex.soc.cores import gpio 5 | 6 | from gateware.pwm import PWM 7 | 8 | 9 | class ClassicLed(gpio.GPIOOut): 10 | def __init__(self, pads): 11 | gpio.GPIOOut.__init__(self, pads) 12 | 13 | 14 | class RGBLed(Module, AutoCSR): 15 | def __init__(self, pads): 16 | nleds = len(pads.r) 17 | 18 | # # # 19 | 20 | for n in range(nleds): 21 | for c in "rgb": 22 | setattr(self.submodules, c+str(n), PWM(getattr(pads, c)[n])) 23 | -------------------------------------------------------------------------------- /gateware/memtest.py: -------------------------------------------------------------------------------- 1 | """Built In Self Test (BIST) modules for testing liteDRAM functionality.""" 2 | 3 | from migen import * 4 | 5 | 6 | class LiteDRAMBISTCheckerScope(Module): 7 | """Easy scope access to important signals of LiteDRAMBISTChecker.""" 8 | 9 | def __init__(self, checker): 10 | core = checker.core 11 | self.data_error = Signal() 12 | self.data_address = Signal(core.data_counter.nbits) 13 | self.data_expected = Signal(core.dma.source.data.nbits) 14 | self.data_actual = Signal(core.dma.source.data.nbits) 15 | 16 | self.comb += [ 17 | self.data_error.eq(core.dma.source.valid & 18 | (self.data_actual != self.data_expected)), 19 | self.data_address.eq(core.base + core.data_counter), 20 | self.data_actual.eq(core.dma.source.data), 21 | self.data_expected.eq(core.gen.o), 22 | ] 23 | 24 | def signals(self): 25 | return [ 26 | self.data_error, 27 | self.data_address, 28 | self.data_expected, 29 | self.data_actual, 30 | ] 31 | -------------------------------------------------------------------------------- /gateware/pwm.py: -------------------------------------------------------------------------------- 1 | from migen import * 2 | 3 | from litex.soc.interconnect.csr import * 4 | 5 | 6 | class PWM(Module, AutoCSR): 7 | def __init__(self, pwm): 8 | self._enable = CSRStorage() 9 | self._width = CSRStorage(32) 10 | self._period = CSRStorage(32) 11 | 12 | # # # 13 | 14 | cnt = Signal(32) 15 | 16 | enable = self._enable.storage 17 | width = self._width.storage 18 | period = self._period.storage 19 | 20 | self.sync += \ 21 | If(enable, 22 | If(cnt < width, 23 | pwm.eq(1) 24 | ).Else( 25 | pwm.eq(0) 26 | ), 27 | If(cnt == period-1, 28 | cnt.eq(0) 29 | ).Else( 30 | cnt.eq(cnt+1) 31 | ) 32 | ).Else( 33 | cnt.eq(0), 34 | pwm.eq(0) 35 | ) 36 | -------------------------------------------------------------------------------- /gateware/shared_uart.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | UART which is connected to multiple sets of pins. 4 | """ 5 | 6 | import operator 7 | 8 | from migen import * 9 | 10 | from litex.soc.cores import uart 11 | 12 | 13 | class UARTVirtualPhy(Module): 14 | def __init__(self): 15 | self.sink = Endpoint([("data", 8)]) 16 | self.source = Endpoint([("data", 8)]) 17 | 18 | 19 | class SharedUART(Module): 20 | 21 | def __init__(self, clk_freq, baud_rate): 22 | self.tx = Signal() 23 | self.rx = Signal() 24 | self.tx_signals = [] 25 | self.rx_signals = [] 26 | 27 | self.submodules.phy = uart.RS232PHY(self, clk_freq, baud_rate) 28 | self.submodules.uart = uart.UART(self.phy) 29 | 30 | def add_uart_pads(self, new_pads): 31 | self.tx_signals.append(new_pads.tx) 32 | self.rx_signals.append(new_pads.rx) 33 | 34 | def do_finalize(self): 35 | if self.tx_signals: 36 | for tx_sig in self.tx_signals: 37 | self.comb += [ 38 | # TX 39 | tx_sig.eq(self.tx), 40 | ] 41 | 42 | if self.rx_signals: 43 | self.comb += [ 44 | # RX 45 | self.rx.eq(reduce(operator.__and__, self.rx_signals)) 46 | ] 47 | 48 | 49 | # FIXME: Add a test for the shared UART 50 | -------------------------------------------------------------------------------- /gateware/streamer/__init__.py: -------------------------------------------------------------------------------- 1 | from gateware.streamer.core import USBStreamer 2 | -------------------------------------------------------------------------------- /gateware/streamer/core.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from migen import * 4 | from migen.genlib.resetsync import AsyncResetSynchronizer 5 | from litex.soc.interconnect import stream 6 | 7 | class USBStreamer(Module): 8 | def __init__(self, platform, pads): 9 | self.sink = sink = stream.Endpoint([("data", 8)]) 10 | 11 | # # # 12 | 13 | self.clock_domains.cd_usb = ClockDomain() 14 | self.specials += [ 15 | Instance("IBUFG", i_I=pads.ifclk, o_O=self.cd_usb.clk), 16 | ] 17 | 18 | self.specials += AsyncResetSynchronizer(self.cd_usb, ResetSignal()) 19 | 20 | fifo = stream.AsyncFIFO([("data", 8)], 4) 21 | fifo = ClockDomainsRenamer({"write": "encoder", "read": "usb"})(fifo) 22 | self.submodules.fifo = fifo 23 | self.comb += Record.connect(sink, fifo.sink) 24 | 25 | self.specials += Instance("fx2_jpeg_streamer", 26 | # clk, rst 27 | i_rst=ResetSignal("usb"), 28 | i_clk=ClockSignal("usb"), 29 | 30 | # jpeg encoder interface 31 | i_sink_stb=fifo.source.valid, 32 | i_sink_data=fifo.source.data, 33 | o_sink_ack=fifo.source.ready, 34 | 35 | # cypress fx2 slave fifo interface 36 | io_fx2_data=pads.data, 37 | i_fx2_full_n=pads.flagb, 38 | i_fx2_empty_n=pads.flagc, 39 | o_fx2_addr=pads.addr, 40 | o_fx2_cs_n=pads.cs_n, 41 | o_fx2_wr_n=pads.wr_n, 42 | o_fx2_rd_n=pads.rd_n, 43 | o_fx2_oe_n=pads.oe_n, 44 | o_fx2_pktend_n=pads.pktend_n 45 | ) 46 | 47 | # add vhdl sources 48 | platform.add_source_dir(os.path.join("gateware", "streamer", "vhdl")) 49 | -------------------------------------------------------------------------------- /getting-started.md: -------------------------------------------------------------------------------- 1 | For project description and information see the project [README.md](/) file. 2 | 3 | The [getting started document now lives in the LiteX Build Environment Wiki](https://github.com/timvideos/litex-buildenv/wiki/Getting-Started). 4 | -------------------------------------------------------------------------------- /load.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import os 5 | 6 | cmd, prog = sys.argv[:2] 7 | if len(sys.argv) == 3: 8 | fname = sys.argv[2] 9 | else: 10 | p = os.environ['PLATFORM'] 11 | t = os.environ['TARGET'] 12 | c = os.environ['CPU'] 13 | 14 | fname = "build/{p}_{t}_{c}/gateware/top.bit".format( 15 | p=p, t=t, c=c) 16 | 17 | if prog == 'ise': 18 | from litex.build.xilinx import iMPACT 19 | prog = iMPACT() 20 | elif prog == 'vivado': 21 | from litex.build.xilinx import VivadoProgrammer 22 | prog = VivadoProgrammer() 23 | else: 24 | raise SystemError('Unknown programmer {}'.format(prog)) 25 | 26 | if not os.path.exists(fname): 27 | raise SystemError('File {} not found'.format(fname)) 28 | 29 | if not fname.endswith('.bit'): 30 | raise SystemError('Use the .bit file') 31 | 32 | prog.load_bitstream(fname) 33 | -------------------------------------------------------------------------------- /platforms/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/platforms/__init__.py -------------------------------------------------------------------------------- /platforms/sim.py: -------------------------------------------------------------------------------- 1 | from litex.boards.platforms import sim 2 | from litex.boards.platforms.sim import * 3 | __all__ = ['SimPins', 'Platform'] 4 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | Documentation for using these scripts can be found in the 2 | [getting-started.md](/getting-started.md) file. 3 | 4 | Description of what these scripts do can be found in 5 | [docs/notes.md](docs/notes.md) file. 6 | -------------------------------------------------------------------------------- /scripts/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "`whoami`" = "root" ] 4 | then 5 | echo "Running the script as root is not permitted" 6 | exit 1 7 | fi 8 | 9 | if [ -z "$GITHUB_USER" ]; then 10 | GITHUB_USER=timvideos 11 | fi 12 | if [ -z "$GITHUB_REPO" ]; then 13 | GITHUB_REPO=litex-buildenv 14 | fi 15 | 16 | GIT_REPO=https://github.com/$GITHUB_USER/$GITHUB_REPO.git 17 | if [ -z "$GIT_BRANCH" ]; then 18 | GIT_BRANCH=master 19 | fi 20 | 21 | TMOUT=5 22 | 23 | if ! realpath --help > /dev/null 2>&1; then 24 | echo "realpath not found - aborting.." 25 | exit 1 26 | fi 27 | 28 | if ! git help > /dev/null 2>&1; then 29 | echo "git not found - aborting.." 30 | exit 1 31 | fi 32 | 33 | if [ -e $GITHUB_REPO ]; then 34 | cd $GITHUB_REPO || exit 1 35 | else 36 | git clone --recurse-submodules $GIT_REPO || exit 1 37 | cd $GITHUB_REPO 38 | git checkout $GIT_BRANCH || exit 1 39 | fi 40 | 41 | # Setup things needed by download-env.sh script 42 | if lsb_release -i | grep -q "Debian|Ubuntu"; then 43 | ./scripts/debian-setup.sh 44 | else 45 | if ! wget --help > /dev/null 2>&1; then 46 | echo "wget not found - aborting.." 47 | exit 1 48 | fi 49 | 50 | if ! make --help > /dev/null 2>&1; then 51 | echo "make not found - aborting.." 52 | exit 1 53 | fi 54 | 55 | if ! grep --help > /dev/null 2>&1; then 56 | echo "grep not found - aborting.." 57 | exit 1 58 | fi 59 | 60 | if ! sed --help > /dev/null 2>&1; then 61 | echo "sed not found - aborting.." 62 | exit 1 63 | fi 64 | fi 65 | 66 | ./scripts/download-env.sh || exit 1 67 | 68 | echo "Bootstrap: Set up complete, you're good to go!"; 69 | -------------------------------------------------------------------------------- /scripts/check-firmware-newlines.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "`whoami`" = "root" ] 4 | then 5 | echo "Running the script as root is not permitted" 6 | exit 1 7 | fi 8 | 9 | CALLED=$_ 10 | [[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0 11 | 12 | SETUP_SRC="$(realpath ${BASH_SOURCE[0]})" 13 | SETUP_DIR="$(dirname "${SETUP_SRC}")" 14 | TOP_DIR="$(realpath "${SETUP_DIR}/..")" 15 | 16 | if [ $SOURCED = 1 ]; then 17 | echo "You must run this script, rather then try to source it." 18 | echo "$SETUP_SRC" 19 | return 20 | fi 21 | 22 | set -euf 23 | cd $TOP_DIR/firmware 24 | 25 | find . '(' -name '*.c' -o -name '*.h' ')' \ 26 | | while read fn; do 27 | case $fn in 28 | ./telnet.c) 29 | continue 30 | ;; 31 | esac 32 | if grep -qF '\r\n' $fn; then 33 | echo "$fn" 'contains a \\r\\n.' 34 | echo 'You should just write \\n, stdio_wrap will transform this to a \\r\\n, as appropriate' 35 | exit 1 36 | fi 37 | done 38 | -------------------------------------------------------------------------------- /scripts/debian-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Need realpath for finding where we are running from. 4 | apt-get install -y realpath 5 | 6 | if [ "`whoami`" != "root" ] 7 | then 8 | echo "Please use sudo to run this script!" 9 | exit 1 10 | fi 11 | 12 | SETUP_SRC=$(realpath ${BASH_SOURCE[0]}) 13 | SETUP_DIR=$(dirname $SETUP_SRC) 14 | 15 | set -x 16 | set -e 17 | 18 | # Need wget to download conda in download-env.sh 19 | apt-get install -y wget 20 | # We are building C code, so need build-essential 21 | apt-get install -y build-essential 22 | 23 | # Need gpg to create the encrypted package of Xilinx tools for CI, not needed 24 | # by normal developers. 25 | #apt-get install -y gnupg 26 | 27 | # gtkwave is needed for viewing the output of traces 28 | apt-get install -y gtkwave 29 | 30 | # readline, libusb, libftdi are all needed by openocd which is installed via conda 31 | apt-get install -y libreadline-dev libusb-1.0-0-dev libftdi-dev 32 | 33 | # FIXME: What needs python-yaml!? 34 | apt-get install -y python-yaml 35 | 36 | # fxload is needed for controlling the FX2 found on the Atlys and Opsis boards 37 | apt-get install -y fxload 38 | 39 | # aftpd is needed for tftp booting firmware 40 | apt-get install -y atftpd 41 | 42 | # These libraries are needed for working with the sim target 43 | apt-get install -y openvpn libsdl1.2-dev 44 | 45 | # FIXME: Work out if this stuff below is needed. 46 | apt-get install -y software-properties-common 47 | add-apt-repository -y ppa:timvideos/fpga-support 48 | apt-get update 49 | # Only need the udev rules (the full mode-switch tool is installed locally as 50 | # part of the download-env.sh). 51 | apt-get install -y hdmi2usb-udev || apt-get install -y hdmi2usb-mode-switch-udev 52 | 53 | # Get the vizzini module, only needed for the Atlys board 54 | #apt-get install -y vizzini-dkms 55 | -------------------------------------------------------------------------------- /scripts/makefile-cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | PLATFORMS=$(ls targets/ | grep -v ".py" | grep -v "common" | tr '\n' ' ' | sed -e"s+targets/++") 6 | 7 | cat > build/cache.mk.tmp <> build/cache.mk.tmp < unbind 19 | echo -n "$i" > bind 20 | done 21 | done 22 | -------------------------------------------------------------------------------- /scripts/settings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Settings for the download-env.sh and setup-env.sh scripts 4 | BUILD_DIR=$TOP_DIR/build 5 | THIRD_DIR=$TOP_DIR/third_party 6 | CONDA_DIR=$BUILD_DIR/conda 7 | 8 | CONDA_VERSION=4.7.10 9 | PYTHON_VERSION=3.7 10 | 11 | # Python module versions 12 | HDMI2USB_MODESWITCH_VERSION=0.0.1 13 | HEXFILE_VERSION=0.1 14 | CMAKE_VERSION=3.14.4 15 | 16 | # Conda package versions 17 | BINUTILS_VERSION=2.32 18 | GCC_VERSION=9.1.0 19 | SDCC_VERSION=3.5.0 20 | OPENOCD_VERSION=0.10.0 21 | 22 | # Other tools versions 23 | ZEPHYR_SDK_VERSION=0.10.1 24 | 25 | # lite modules 26 | LITE_REPOS=" 27 | migen 28 | litex 29 | litedram 30 | liteeth 31 | litepcie 32 | litesata 33 | litescope 34 | litevideo 35 | " 36 | -------------------------------------------------------------------------------- /scripts/view-hdmi2usb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -d /dev/hdmi2usb ]; then 4 | I=0 5 | for DEV in $(ls /dev/video*); do 6 | echo 7 | if ! v4l-info $DEV > /dev/null 2>&1; then 8 | echo "No $DEV" 9 | break 10 | else 11 | echo "$DEV - exists!" 12 | fi 13 | 14 | if v4l-info $DEV | grep 'HDMI2USB' > /dev/null 2>&1; then 15 | echo "Device $DEV *is* a HDMI2USB" 16 | export HDMI2USB=$DEV 17 | break 18 | else 19 | echo "Device $DEV is *not* a HDMI2USB" 20 | fi 21 | done 22 | else 23 | HDMI2USB=$(ls /dev/hdmi2usb/by-num/all*/video | head -n1) 24 | fi 25 | 26 | WIDTH=1280 27 | HEIGHT=720 28 | 29 | mplayer tv:// -tv driver=v4l2:width=$WIDTH:height=$HEIGHT:device=$HDMI2USB -vf screenshot -vo xv 30 | #guvcview --device=$HDMI2USB --show_fps=1 --size=$WIDTHx$HEIGHT 31 | -------------------------------------------------------------------------------- /software/pcie/kernel/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for kernel module 2 | 3 | KERNEL_VERSION:=$(shell uname -r) 4 | KERNEL_PATH:=/lib/modules/$(KERNEL_VERSION)/build 5 | 6 | obj-m = litepcie.o 7 | litepcie-objs = main.o 8 | 9 | all: litepcie.ko 10 | 11 | litepcie.ko: main.c 12 | make -C $(KERNEL_PATH) M=$(PWD) modules 13 | 14 | clean: 15 | make -C $(KERNEL_PATH) M=$(PWD) clean 16 | rm -f *~ 17 | -------------------------------------------------------------------------------- /software/pcie/kernel/README: -------------------------------------------------------------------------------- 1 | - Use 'make' to build the driver 2 | 3 | - Install the driver and create the device with : 4 | 5 | ./init.sh 6 | 7 | - Remove driver with 8 | 9 | rmmod litepcie 10 | -------------------------------------------------------------------------------- /software/pcie/kernel/config.h: -------------------------------------------------------------------------------- 1 | #ifndef __HW_CONFIG_H 2 | #define __HW_CONFIG_H 3 | 4 | /* pci */ 5 | #define PCI_FPGA_VENDOR_ID 0x10ee 6 | #define PCI_FPGA_DEVICE_ID 0x7022 7 | #define PCI_FPGA_BAR0_SIZE 0xa000 8 | 9 | /* dma */ 10 | #define DMA_BUFFER_COUNT 128 11 | 12 | 13 | #endif /* __HW_CONFIG_H */ 14 | -------------------------------------------------------------------------------- /software/pcie/kernel/flags.h: -------------------------------------------------------------------------------- 1 | #ifndef __HW_FLAGS_H 2 | #define __HW_FLAGS_H 3 | 4 | /* dma */ 5 | #define DMA_LOOPBACK_ENABLE 0x1 6 | 7 | #define DMA_TABLE_LOOP_INDEX 1 << 0 8 | #define DMA_TABLE_LOOP_COUNT 1 << 16 9 | 10 | #endif /* __HW_FLAGS_H */ 11 | -------------------------------------------------------------------------------- /software/pcie/kernel/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # TODO: use udev instead 3 | 4 | insmod litepcie.ko 5 | 6 | major=$(awk '/ litepcie$/{print $1}' /proc/devices) 7 | mknod -m 666 /dev/litepcie0 c $major 0 8 | -------------------------------------------------------------------------------- /software/pcie/kernel/litepcie.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LitePCIe driver 3 | * 4 | */ 5 | #ifndef _LINUX_LITEPCIE_H 6 | #define _LINUX_LITEPCIE_H 7 | 8 | #include 9 | 10 | struct litepcie_ioctl_mmap_info { 11 | unsigned long reg_offset; 12 | unsigned long reg_size; 13 | 14 | unsigned long dma_tx_buf_offset; 15 | unsigned long dma_tx_buf_size; 16 | unsigned long dma_tx_buf_count; 17 | 18 | unsigned long dma_rx_buf_offset; 19 | unsigned long dma_rx_buf_size; 20 | unsigned long dma_rx_buf_count; 21 | }; 22 | 23 | struct litepcie_ioctl_dma_start { 24 | __u32 dma_flags; /* see LITEPCIE_DMA_FLAGS_x */ 25 | __u32 tx_buf_size; /* in bytes, must be < dma_buf_pitch. 0 means no TX */ 26 | __u32 tx_buf_count; 27 | __u32 rx_buf_size; /* in bytes, must be < dma_buf_pitch. 0 means no RX */ 28 | __u32 rx_buf_count; 29 | }; 30 | 31 | /* if tx_wait is true, wait until the current TX bufffer is 32 | different from tx_buf_num. If tx_wait is false, wait until the 33 | current RX buffer is different from rx_buf_num. Return the last 34 | TX buffer in tx_buf_num and the last RX buffer in 35 | rx_buf_num. */ 36 | struct litepcie_ioctl_dma_wait { 37 | __s32 timeout; /* in ms. Return -EAGAIN if timeout occured without event */ 38 | __u32 tx_wait; 39 | __u32 tx_buf_num; /* read/write */ 40 | __u32 rx_buf_num; /* read/write */ 41 | }; 42 | 43 | #define LITEPCIE_IOCTL 'S' 44 | 45 | #define LITEPCIE_IOCTL_GET_MMAP_INFO _IOR(LITEPCIE_IOCTL, 0, struct litepcie_ioctl_mmap_info) 46 | #define LITEPCIE_IOCTL_DMA_START _IOW(LITEPCIE_IOCTL, 1, struct litepcie_ioctl_dma_start) 47 | #define LITEPCIE_IOCTL_DMA_STOP _IO(LITEPCIE_IOCTL, 2) 48 | #define LITEPCIE_IOCTL_DMA_WAIT _IOWR(LITEPCIE_IOCTL, 3, struct litepcie_ioctl_dma_wait) 49 | 50 | #endif /* _LINUX_LITEPCIE_H */ 51 | -------------------------------------------------------------------------------- /software/pcie/user/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS=-O2 -Wall -g -I../kernel -MMD 2 | LDFLAGS=-g 3 | CC=gcc 4 | AR=ar 5 | 6 | PROGS=litepcie_util 7 | 8 | all: $(PROGS) 9 | 10 | litepcie_util: litepcie_util.o litepcie_lib.o 11 | $(CC) $(LDFLAGS) -o $@ $^ -lrt -lm 12 | 13 | clean: 14 | rm -f $(PROGS) *.o *.a *.d *~ 15 | 16 | %.o: %.c 17 | $(CC) -c $(CFLAGS) -o $@ $< 18 | 19 | -include $(wildcard *.d) 20 | -------------------------------------------------------------------------------- /software/pcie/user/cutils.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef _BOOL_defined 6 | #define _BOOL_defined 7 | #undef FALSE 8 | #undef TRUE 9 | 10 | typedef int BOOL; 11 | enum { 12 | FALSE = 0, 13 | TRUE = 1, 14 | }; 15 | #endif 16 | 17 | static inline int sub_mod_int(int a, int b, int m) 18 | { 19 | a -= b; 20 | if (a < 0) 21 | a += m; 22 | return a; 23 | } 24 | 25 | static inline int add_mod_int(int a, int b, int m) 26 | { 27 | a += b; 28 | if (a >= m) 29 | a -= m; 30 | return a; 31 | } 32 | -------------------------------------------------------------------------------- /software/pcie/user/litepcie_lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LitePCIe library 3 | * 4 | */ 5 | #ifndef LITEPCIE_LIB_H 6 | #define LITEPCIE_LIB_H 7 | 8 | #include 9 | #include 10 | 11 | #define LITEPCIE_FILENAME "/dev/litepcie0" 12 | 13 | typedef struct { 14 | int litepcie_fd; 15 | struct litepcie_ioctl_mmap_info mmap_info; 16 | uint8_t *dma_tx_buf; 17 | int dma_tx_buf_size; 18 | uint8_t *dma_rx_buf; 19 | int dma_rx_buf_size; 20 | uint8_t *reg_buf; 21 | 22 | unsigned int tx_buf_size; /* in bytes */ 23 | unsigned int tx_buf_count; /* number of buffers */ 24 | unsigned int rx_buf_size; /* in bytes */ 25 | unsigned int rx_buf_count; /* number of buffers */ 26 | 27 | unsigned int tx_buf_len; /* in samples */ 28 | unsigned int rx_buf_len; /* in samples */ 29 | 30 | pthread_mutex_t fifo_mutex; 31 | int64_t rx_timestamp; /* timestamp (in samples) of the current RX buffer */ 32 | unsigned int rx_buf_index; /* index of the current RX buffer */ 33 | unsigned int rx_buf_next; /* index of the next buffer after the 34 | last received buffer */ 35 | BOOL has_rx_timestamp; /* true if received at least one buffer */ 36 | 37 | int64_t tx_underflow_count; /* TX too late */ 38 | int64_t rx_overflow_count; /* RX too late */ 39 | } LitePCIeState; 40 | 41 | void *litepcie_malloc(int size); 42 | void *litepcie_mallocz(int size); 43 | void litepcie_free(void *ptr); 44 | void __attribute__((format(printf, 2, 3))) litepcie_log(LitePCIeState *s, const char *fmt, ...); 45 | int64_t litepcie_get_time_ms(void); 46 | LitePCIeState *litepcie_open(const char *device_name); 47 | void litepcie_close(LitePCIeState *s); 48 | void litepcie_dma_start(LitePCIeState *s, int buf_size, int buf_count, BOOL is_loopback); 49 | void litepcie_dma_stop(LitePCIeState *s); 50 | void litepcie_writel(LitePCIeState *s, uint32_t addr, uint32_t val); 51 | uint32_t litepcie_readl(LitePCIeState *s, uint32_t addr); 52 | 53 | #endif /* LITEPCIE_LIB_H */ 54 | -------------------------------------------------------------------------------- /targets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/targets/__init__.py -------------------------------------------------------------------------------- /targets/arty/Makefile.mk: -------------------------------------------------------------------------------- 1 | # arty targets 2 | 3 | ifneq ($(PLATFORM),arty) 4 | $(error "Platform should be arty when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = net 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | PROG_PORT ?= /dev/ttyUSB0 12 | COMM_PORT ?= /dev/ttyUSB1 13 | BAUD ?= 115200 14 | 15 | # Image 16 | image-flash-$(PLATFORM): image-flash-py 17 | @true 18 | 19 | # Gateware 20 | gateware-load-$(PLATFORM): 21 | openocd -f board/digilent_$(PLATFORM).cfg -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" 22 | 23 | gateware-flash-$(PLATFORM): gateware-flash-py 24 | @true 25 | 26 | # Firmware 27 | firmware-load-$(PLATFORM): 28 | flterm --port=$(COMM_PORT) --kernel=$(FIRMWARE_FILEBASE).bin --speed=$(BAUD) 29 | 30 | 31 | firmware-flash-$(PLATFORM): firmware-flash-py 32 | @true 33 | 34 | firmware-connect-$(PLATFORM): 35 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 36 | 37 | # Bios 38 | bios-flash-$(PLATFORM): 39 | @echo "Unsupported." 40 | @false 41 | 42 | # Extra commands 43 | help-$(PLATFORM): 44 | @true 45 | 46 | reset-$(PLATFORM): 47 | @echo "Unsupported." 48 | @false 49 | -------------------------------------------------------------------------------- /targets/atlys/Makefile.mk: -------------------------------------------------------------------------------- 1 | # atlys targets 2 | 3 | ifneq ($(PLATFORM),atlys) 4 | $(error "Platform should be atlys when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = video 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | # Image 12 | image-flash-$(PLATFORM): 13 | $(PLATFORM)-mode-switch --verbose --flash-gateware=$(IMAGE_FILE) 14 | $(PLATFORM)-mode-switch --verbose --reset-gateware 15 | 16 | # Gateware 17 | gateware-load-$(PLATFORM): 18 | $(PLATFORM)-mode-switch --verbose --load-gateware $(GATEWARE_FILEBASE).bit 19 | 20 | gateware-flash-$(PLATFORM): 21 | $(PLATFORM)-mode-switch --verbose --flash-gateware=$(GATEWARE_FILEBASE).bin 22 | $(PLATFORM)-mode-switch --verbose --reset-gateware 23 | 24 | # Firmware 25 | firmware-load-$(PLATFORM): 26 | flterm --port=$$($(PLATFORM)-mode-switch --get-serial-device) --kernel=$(FIRMWARE_FILEBASE).bin 27 | 28 | firmware-flash-$(PLATFORM): 29 | $(PLATFORM)-mode-switch --verbose --flash-softcpu-firmware=$(FIRMWARE_FILEBASE).fbi 30 | $(PLATFORM)-mode-switch --verbose --reset-gateware 31 | 32 | firmware-connect-$(PLATFORM): 33 | flterm --port=$$($(PLATFORM)-mode-switch --get-serial-dev) 34 | 35 | firmware-clear-$(PLATFORM): 36 | $(PLATFORM)-mode-switch --verbose --clear-softcpu-firmware 37 | 38 | 39 | # Bios 40 | bios-flash-$(PLATFORM): 41 | $(PLATFORM)-mode-switch --verbose --flash-softcpu-bios=$(BIOS_FILE) 42 | $(PLATFORM)-mode-switch --verbose --reset-gateware 43 | 44 | # Extra commands 45 | help-$(PLATFORM): 46 | @true 47 | 48 | reset-$(PLATFORM): 49 | $(PLATFORM)-mode-switch --verbose --mode=jtag 50 | -------------------------------------------------------------------------------- /targets/basys3/Makefile.mk: -------------------------------------------------------------------------------- 1 | # basys3 targets 2 | 3 | ifneq ($(PLATFORM),basys3) 4 | $(error "Platform should be basys3 when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | PROG_PORT ?= /dev/ttyUSB0 12 | COMM_PORT ?= /dev/ttyUSB1 13 | BAUD ?= 115200 14 | 15 | # Image 16 | image-flash-$(PLATFORM): image-flash-py 17 | @true 18 | 19 | # Gateware 20 | gateware-load-$(PLATFORM): 21 | openocd -f board/digilent_$(PLATFORM).cfg -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" 22 | 23 | gateware-flash-$(PLATFORM): gateware-flash-py 24 | @true 25 | 26 | # Firmware 27 | firmware-load-$(PLATFORM): 28 | flterm --port=$(COMM_PORT) --kernel=$(FIRMWARE_FILEBASE).bin --speed=$(BAUD) 29 | 30 | 31 | firmware-flash-$(PLATFORM): firmwage-flash-py 32 | @true 33 | 34 | firmware-connect-$(PLATFORM): 35 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 36 | 37 | # Bios 38 | bios-flash-$(PLATFORM): 39 | @echo "Unsupported." 40 | @false 41 | 42 | # Extra commands 43 | help-$(PLATFORM): 44 | @true 45 | 46 | reset-$(PLATFORM): 47 | @echo "Unsupported." 48 | @false 49 | -------------------------------------------------------------------------------- /targets/cmod_a7/Makefile.mk: -------------------------------------------------------------------------------- 1 | # cmod_a7 targets 2 | 3 | ifneq ($(PLATFORM),cmod_a7) 4 | $(error "Platform should be cmod_a7 when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | PROG_PORT ?= /dev/ttyUSB0 12 | COMM_PORT ?= /dev/ttyUSB1 13 | BAUD ?= 115200 14 | 15 | # Image 16 | image-flash-$(PLATFORM): image-flash-py 17 | @true 18 | 19 | .PHONY: image-flash-$(PLATFORM) 20 | 21 | # Gateware 22 | gateware-load-$(PLATFORM): 23 | openocd -f board/digilent_$(PLATFORM).cfg -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" 24 | 25 | gateware-flash-$(PLATFORM): gateware-flash-py 26 | @true 27 | 28 | .PHONY: gateware-load-$(PLATFORM) gateware-flash-$(PLATFORM) 29 | 30 | # Firmware 31 | firmware-load-$(PLATFORM): 32 | flterm --port=$(COMM_PORT) --kernel=$(TARGET_BUILD_DIR)/software/firmware/firmware.bin --speed=$(BAUD) 33 | 34 | firmware-flash-$(PLATFORM): firmwage-flash-py 35 | @true 36 | 37 | firmware-connect-$(PLATFORM): 38 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 39 | 40 | .PHONY: firmware-load-$(PLATFORM) firmware-flash-$(PLATFORM) firmware-connect-$(PLATFORM) 41 | 42 | # Bios 43 | bios-flash-$(PLATFORM): 44 | @echo "Unsupported." 45 | @false 46 | 47 | .PHONY: bios-flash-$(PLATFORM) 48 | 49 | # Extra commands 50 | help-$(PLATFORM): 51 | @true 52 | 53 | reset-$(PLATFORM): 54 | @echo "Unsupported." 55 | @false 56 | 57 | .PHONY: help-$(PLATFORM) reset-$(PLATFORM) 58 | -------------------------------------------------------------------------------- /targets/common/openocd.mk: -------------------------------------------------------------------------------- 1 | 2 | OPENOCD_CMD="openocd -f board/$(OPENOCD_BOARD)" 3 | 4 | GATEWARE="$(TARGET_BUILD_DIR)/gateware/top." 5 | IMAGE="$(TARGET_BUILD_DIR)/image." 6 | 7 | define OPENOCD_LOAD 8 | init 9 | pld load 0 $(FILE).bit 10 | exit 11 | endef 12 | 13 | define OPENOCD_FLASH 14 | init 15 | jtagspi_init 0 $(PROXY) 16 | flash banks 17 | flash list 18 | flash info 0 19 | jtagspi_program $(FILE).bin 0x$() 20 | endef 21 | 22 | gateware-load-openocd: 23 | openocd -f board/$(OPENOCD_BOARD) \ 24 | -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" 25 | 26 | -------------------------------------------------------------------------------- /targets/galatea/Makefile.mk: -------------------------------------------------------------------------------- 1 | # galatea targets 2 | 3 | ifneq ($(PLATFORM),galatea) 4 | $(error "Platform should be galatea when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | # Image 12 | image-flash-$(PLATFORM): image-flash-py 13 | @true 14 | 15 | # Gateware 16 | gateware-load-$(PLATFORM): 17 | @echo "Unsupported." 18 | @false 19 | 20 | gateware-flash-$(PLATFORM): gateware-flash-py 21 | @true 22 | 23 | # Firmware 24 | firmware-load-$(PLATFORM): 25 | @echo "Unsupported." 26 | @false 27 | 28 | firmware-flash-$(PLATFORM): firmwage-flash-py 29 | @true 30 | 31 | firmware-connect-$(PLATFORM): 32 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 33 | 34 | firmware-clear-$(PLATFORM): 35 | @echo "FIXME: Unsupported?." 36 | @false 37 | 38 | # Bios 39 | bios-flash-$(PLATFORM): 40 | @echo "Unsupported." 41 | @false 42 | 43 | # Extra commands 44 | help-$(PLATFORM): 45 | @true 46 | 47 | reset-$(PLATFORM): 48 | @echo "Unsupported." 49 | @false 50 | -------------------------------------------------------------------------------- /targets/ice40_hx8k_b_evn/Makefile.mk: -------------------------------------------------------------------------------- 1 | # ice40_hx8k_b_evn targets 2 | 3 | ifneq ($(PLATFORM),ice40_hx8k_b_evn) 4 | $(error "Platform should be ice40_hx8k_b_evn when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | BAUD ?= 115200 11 | 12 | # Image 13 | image-flash-$(PLATFORM): 14 | iceprog $(IMAGE_FILE) 15 | 16 | # Gateware 17 | gateware-load-$(PLATFORM): 18 | @echo "ICE40HX8K-B-EVN doesn't support loading, use the flash target instead." 19 | @echo "make gateware-flash" 20 | @false 21 | 22 | # As with Mimasv2, if the user asks to flash the gateware only, the BIOS must 23 | # be sent as well (because the BIOS is too big to fit into the bitstream). 24 | GATEWARE_BIOS_FILE = $(TARGET_BUILD_DIR)/image-gateware+bios+none.bin 25 | 26 | gateware-flash-$(PLATFORM): $(GATEWARE_BIOS_FILE) 27 | iceprog $(GATEWARE_BIOS_FILE) 28 | 29 | # To avoid duplicating the mkimage.py call here, if the user has not 30 | # already built a image-gateware+bios+none.bin, we call make recursively 31 | # to build one here, with the FIRMWARE=none override. 32 | # 33 | ifneq ($(GATEWARE_BIOS_FILE),$(IMAGE_FILE)) 34 | $(GATEWARE_BIOS_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) mkimage.py 35 | FIRMWARE=none make image 36 | endif 37 | 38 | # Firmware 39 | firmware-load-$(PLATFORM): 40 | @echo "Unsupported." 41 | @false 42 | 43 | firmware-flash-$(PLATFORM): 44 | @echo "ICE40HX8K-B-EVN doesn't support just flashing firmware, use image target instead." 45 | @echo "make image-flash" 46 | @false 47 | 48 | firmware-connect-$(PLATFORM): 49 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 50 | 51 | firmware-clear-$(PLATFORM): 52 | @echo "FIXME: Unsupported?." 53 | @false 54 | 55 | # Bios 56 | bios-flash-$(PLATFORM): 57 | @echo "Unsupported." 58 | @false 59 | 60 | # Extra commands 61 | help-$(PLATFORM): 62 | @true 63 | 64 | reset-$(PLATFORM): 65 | @echo "Unsupported." 66 | @false 67 | -------------------------------------------------------------------------------- /targets/ice40_up5k_b_evn/Makefile.mk: -------------------------------------------------------------------------------- 1 | # ice40_hx8k_b_evn targets 2 | 3 | ifneq ($(PLATFORM),ice40_up5k_b_evn) 4 | $(error "Platform should be ice40_up5k_b_evn when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | BAUD ?= 115200 11 | 12 | # Image 13 | image-flash-$(PLATFORM): 14 | iceprog $(IMAGE_FILE) 15 | 16 | # Gateware 17 | gateware-load-$(PLATFORM): 18 | @echo "ICE40UP5K-B-EVN doesn't support loading, use the flash target instead." 19 | @echo "make gateware-flash" 20 | @false 21 | 22 | # As with Mimasv2, if the user asks to flash the gateware only, the BIOS must 23 | # be sent as well (because the BIOS is too big to fit into the bitstream). 24 | GATEWARE_BIOS_FILE = $(TARGET_BUILD_DIR)/image-gateware+bios+none.bin 25 | 26 | gateware-flash-$(PLATFORM): $(GATEWARE_BIOS_FILE) 27 | iceprog $(GATEWARE_BIOS_FILE) 28 | 29 | # To avoid duplicating the mkimage.py call here, if the user has not 30 | # already built a image-gateware+bios+none.bin, we call make recursively 31 | # to build one here, with the FIRMWARE=none override. 32 | # 33 | ifneq ($(GATEWARE_BIOS_FILE),$(IMAGE_FILE)) 34 | $(GATEWARE_BIOS_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) mkimage.py 35 | FIRMWARE=none make image 36 | endif 37 | 38 | # Firmware 39 | firmware-load-$(PLATFORM): 40 | @echo "Unsupported." 41 | @false 42 | 43 | firmware-flash-$(PLATFORM): 44 | @echo "ICE40UP5K-B-EVN doesn't support just flashing firmware, use image target instead." 45 | @echo "make image-flash" 46 | @false 47 | 48 | firmware-connect-$(PLATFORM): 49 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 50 | 51 | firmware-clear-$(PLATFORM): 52 | @echo "FIXME: Unsupported?." 53 | @false 54 | 55 | # Bios 56 | bios-flash-$(PLATFORM): 57 | @echo "Unsupported." 58 | @false 59 | 60 | # Extra commands 61 | help-$(PLATFORM): 62 | @true 63 | 64 | reset-$(PLATFORM): 65 | @echo "Unsupported." 66 | @false 67 | -------------------------------------------------------------------------------- /targets/ice40_up5k_b_evn/bridge.py: -------------------------------------------------------------------------------- 1 | from litex.soc.cores import uart 2 | from litex.soc.cores.uart import UARTWishboneBridge 3 | 4 | from litescope import LiteScopeAnalyzer 5 | from litescope import LiteScopeIO 6 | 7 | from targets.utils import csr_map_update 8 | from targets.ice40_up5k_b_evn.base import BaseSoC 9 | 10 | 11 | class BridgeSoC(BaseSoC): 12 | csr_peripherals = ( 13 | "analyzer", 14 | "io", 15 | ) 16 | csr_map_update(BaseSoC.csr_map, csr_peripherals) 17 | 18 | def __init__(self, platform, *args, **kwargs): 19 | kwargs['cpu_type'] = None 20 | BaseSoC.__init__(self, platform, *args, with_uart=False, **kwargs) 21 | 22 | self.add_cpu_or_bridge(UARTWishboneBridge(platform.request("serial"), self.clk_freq, baudrate=115200)) 23 | self.add_wb_master(self.cpu_or_bridge.wishbone) 24 | 25 | 26 | SoC = BridgeSoC 27 | -------------------------------------------------------------------------------- /targets/icebreaker/Makefile.mk: -------------------------------------------------------------------------------- 1 | # ice40_hx8k_b_evn targets 2 | 3 | ifneq ($(PLATFORM),icebreaker) 4 | $(error "Platform should be icebreaker when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | BAUD ?= 115200 11 | 12 | # Image 13 | image-flash-$(PLATFORM): 14 | iceprog $(IMAGE_FILE) 15 | 16 | # Gateware 17 | gateware-load-$(PLATFORM): 18 | @echo "icebreaker doesn't support loading, use the flash target instead." 19 | @echo "make gateware-flash" 20 | @false 21 | 22 | # As with Mimasv2, if the user asks to flash the gateware only, the BIOS must 23 | # be sent as well (because the BIOS is too big to fit into the bitstream). 24 | GATEWARE_BIOS_FILE = $(TARGET_BUILD_DIR)/image-gateware+bios+none.bin 25 | 26 | gateware-flash-$(PLATFORM): $(GATEWARE_BIOS_FILE) 27 | iceprog $(GATEWARE_BIOS_FILE) 28 | 29 | # To avoid duplicating the mkimage.py call here, if the user has not 30 | # already built a image-gateware+bios+none.bin, we call make recursively 31 | # to build one here, with the FIRMWARE=none override. 32 | # 33 | ifneq ($(GATEWARE_BIOS_FILE),$(IMAGE_FILE)) 34 | $(GATEWARE_BIOS_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) mkimage.py 35 | FIRMWARE=none make image 36 | endif 37 | 38 | # Firmware 39 | firmware-load-$(PLATFORM): 40 | @echo "Unsupported." 41 | @false 42 | 43 | firmware-flash-$(PLATFORM): 44 | @echo "icebreaker doesn't support just flashing firmware, use image target instead." 45 | @echo "make image-flash" 46 | @false 47 | 48 | firmware-connect-$(PLATFORM): 49 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 50 | 51 | firmware-clear-$(PLATFORM): 52 | @echo "FIXME: Unsupported?." 53 | @false 54 | 55 | # Bios 56 | bios-flash-$(PLATFORM): 57 | @echo "Unsupported." 58 | @false 59 | 60 | # Extra commands 61 | help-$(PLATFORM): 62 | @true 63 | 64 | reset-$(PLATFORM): 65 | @echo "Unsupported." 66 | @false 67 | -------------------------------------------------------------------------------- /targets/mimas_a7/Makefile.mk: -------------------------------------------------------------------------------- 1 | # mimas_a7 targets 2 | 3 | ifneq ($(PLATFORM),mimas_a7) 4 | $(error "Platform should be mimas_a7 when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | PROG_PORT ?= /dev/ttyUSB1 12 | COMM_PORT ?= /dev/ttyUSB0 13 | BAUD ?= 115200 14 | 15 | # Image 16 | image-flash-$(PLATFORM): image-flash-py 17 | @true 18 | 19 | # Gateware 20 | gateware-load-$(PLATFORM): 21 | openocd -f board/numato_$(PLATFORM).cfg -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" 22 | 23 | gateware-flash-$(PLATFORM): gateware-flash-py 24 | @true 25 | 26 | # Firmware 27 | firmware-load-$(PLATFORM): 28 | flterm --port=$(COMM_PORT) --kernel=$(FIRMWARE_FILEBASE).bin --speed=$(BAUD) 29 | 30 | firmware-flash-$(PLATFORM): firmwage-flash-py 31 | @true 32 | 33 | firmware-connect-$(PLATFORM): 34 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 35 | 36 | firmware-clear-$(PLATFORM): 37 | @echo "FIXME: Unsupported?." 38 | @false 39 | 40 | # Bios 41 | bios-flash-$(PLATFORM): 42 | @echo "Unsupported." 43 | @false 44 | 45 | # Extra commands 46 | help-$(PLATFORM): 47 | @true 48 | 49 | reset-$(PLATFORM): 50 | @echo "Unsupported." 51 | @false 52 | -------------------------------------------------------------------------------- /targets/mimasv2/scope.py: -------------------------------------------------------------------------------- 1 | from litex.soc.cores import uart 2 | from litex.soc.cores.uart import UARTWishboneBridge 3 | 4 | from litedram.frontend.bist import LiteDRAMBISTGenerator, LiteDRAMBISTChecker 5 | 6 | from litescope import LiteScopeAnalyzer 7 | from litescope import LiteScopeIO 8 | 9 | from gateware.memtest import LiteDRAMBISTCheckerScope 10 | 11 | from targets.utils import csr_map_update 12 | from targets.mimasv2.base import BaseSoC 13 | 14 | 15 | class MemTestSoC(BaseSoC): 16 | csr_peripherals = ( 17 | "analyzer", 18 | "io", 19 | ) 20 | csr_map_update(BaseSoC.csr_map, csr_peripherals) 21 | 22 | def __init__(self, platform, *args, **kwargs): 23 | kwargs['cpu_type'] = None 24 | BaseSoC.__init__(self, platform, *args, with_uart=False, **kwargs) 25 | 26 | self.add_cpu_or_bridge(UARTWishboneBridge(platform.request("serial"), self.clk_freq, baudrate=19200)) 27 | self.add_wb_master(self.cpu_or_bridge.wishbone) 28 | 29 | # Litescope for analyzing the BIST output 30 | # -------------------- 31 | self.submodules.io = LiteScopeIO(8) 32 | for i in range(8): 33 | try: 34 | self.comb += platform.request("user_led", i).eq(self.io.output[i]) 35 | except: 36 | pass 37 | 38 | analyzer_signals = [ 39 | self.spiflash.bus, 40 | # self.spiflash.cs_n, 41 | # self.spiflash.clk, 42 | # self.spiflash.dq_oe, 43 | # self.spiflash.dqi, 44 | # self.spiflash.sr, 45 | ] 46 | self.submodules.analyzer = LiteScopeAnalyzer(analyzer_signals, 1024) 47 | 48 | def do_exit(self, vns, filename="test/analyzer.csv"): 49 | self.analyzer.export_csv(vns, filename) 50 | 51 | 52 | SoC = MemTestSoC 53 | -------------------------------------------------------------------------------- /targets/minispartan6/Makefile.mk: -------------------------------------------------------------------------------- 1 | # minispartan6 targets 2 | 3 | ifneq ($(PLATFORM),minispartan6) 4 | $(error "Platform should be minispartan6 when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | PROG_PORT ?= /dev/ttyUSB0 12 | COMM_PORT ?= /dev/ttyUSB1 13 | BAUD ?= 115200 14 | 15 | # Image 16 | image-flash-$(PLATFORM): 17 | @echo "Unsupported" 18 | @false 19 | 20 | # Gateware 21 | gateware-load-$(PLATFORM): 22 | openocd -f board/$(PLATFORM).cfg -c "init; pld load 0 $(GATEWARE_FILEBASE).bit; exit" 23 | 24 | gateware-flash-$(PLATFORM): 25 | @echo "Unsupported" 26 | @false 27 | 28 | # Firmware 29 | firmware-load-$(PLATFORM): 30 | flterm --port=/dev/ttyUSB1 --kernel=$(FIRMWARE_FILEBASE).bin 31 | 32 | firmware-flash-$(PLATFORM): 33 | @echo "Unsupported." 34 | @false 35 | 36 | firmware-connect-$(PLATFORM): 37 | @echo "Unsupported." 38 | @false 39 | 40 | firmware-clear-$(PLATFORM): 41 | @echo "FIXME: Unsupported?." 42 | @false 43 | 44 | # Bios 45 | bios-flash-$(PLATFORM): 46 | @echo "Unsupported." 47 | @false 48 | 49 | # Extra commands 50 | help-$(PLATFORM): 51 | @true 52 | 53 | reset-$(PLATFORM): 54 | @echo "Unsupported." 55 | @false 56 | -------------------------------------------------------------------------------- /targets/neso/Makefile.mk: -------------------------------------------------------------------------------- 1 | # neso targets 2 | 3 | ifneq ($(PLATFORM),neso) 4 | $(error "Platform should be neso when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | PROG_PORT ?= /dev/ttyUSB0 12 | COMM_PORT ?= /dev/ttyUSB1 13 | BAUD ?= 115200 14 | 15 | # Image 16 | image-flash-$(PLATFORM): image-flash-py 17 | @true 18 | 19 | # Gateware 20 | gateware-load-$(PLATFORM): 21 | openocd -f board/numato_$(PLATFORM).cfg -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" 22 | 23 | gateware-flash-$(PLATFORM): gateware-flash-py 24 | @true 25 | 26 | # Firmware 27 | firmware-load-$(PLATFORM): 28 | flterm --port=$(COMM_PORT) --kernel=$(FIRMWARE_FILEBASE).bin --speed=$(BAUD) 29 | 30 | firmware-flash-$(PLATFORM): firmwage-flash-py 31 | @true 32 | 33 | firmware-connect-$(PLATFORM): 34 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 35 | 36 | firmware-clear-$(PLATFORM): 37 | @echo "FIXME: Unsupported?." 38 | @false 39 | 40 | # Bios 41 | bios-flash-$(PLATFORM): 42 | @echo "Unsupported." 43 | @false 44 | 45 | # Extra commands 46 | help-$(PLATFORM): 47 | @true 48 | 49 | reset-$(PLATFORM): 50 | @echo "Unsupported." 51 | @false 52 | -------------------------------------------------------------------------------- /targets/nexys_video/Makefile.mk: -------------------------------------------------------------------------------- 1 | # nexys_video targets 2 | 3 | ifneq ($(PLATFORM),nexys_video) 4 | $(error "Platform should be nexys_video when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = video 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | # Image 12 | image-flash-$(PLATFORM): image-flash-py 13 | @true 14 | 15 | # Gateware 16 | gateware-load-$(PLATFORM): 17 | @echo "Unsupported." 18 | @false 19 | 20 | gateware-flash-$(PLATFORM): gateware-flash-py 21 | @true 22 | 23 | # Firmware 24 | firmware-load-$(PLATFORM): 25 | @echo "Unsupported." 26 | @false 27 | 28 | firmware-flash-$(PLATFORM): firmwage-flash-py 29 | @true 30 | 31 | firmware-connect-$(PLATFORM): 32 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 33 | 34 | firmware-clear-$(PLATFORM): 35 | @echo "FIXME: Unsupported?." 36 | @false 37 | 38 | # Bios 39 | bios-flash-$(PLATFORM): 40 | @echo "Unsupported." 41 | @false 42 | 43 | # Extra commands 44 | help-$(PLATFORM): 45 | @true 46 | 47 | reset-$(PLATFORM): 48 | @echo "Unsupported." 49 | @false 50 | -------------------------------------------------------------------------------- /targets/opsis/Makefile.mk: -------------------------------------------------------------------------------- 1 | # opsis targets 2 | 3 | ifneq ($(PLATFORM),opsis) 4 | $(error "Platform should be opsis when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = video 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | # Image 12 | image-flash-$(PLATFORM): 13 | $(PLATFORM)-mode-switch --verbose --flash-gateware=$(IMAGE_FILE) 14 | $(PLATFORM)-mode-switch --verbose --reset-gateware 15 | 16 | # Gateware 17 | gateware-load-$(PLATFORM): 18 | $(PLATFORM)-mode-switch --verbose --load-gateware $(GATEWARE_FILEBASE).bit 19 | $(PLATFORM)-mode-switch --verbose --reset-gateware 20 | 21 | gateware-flash-$(PLATFORM): 22 | $(PLATFORM)-mode-switch --verbose --flash-gateware=$(GATEWARE_FILEBASE).bin 23 | $(PLATFORM)-mode-switch --verbose --reset-gateware 24 | 25 | # Firmware 26 | firmware-load-$(PLATFORM): 27 | $(PLATFORM)-mode-switch --verbose --mode=serial 28 | flterm --port=$$($(PLATFORM)-mode-switch --get-serial-dev) --kernel=$(FIRMWARE_FILEBASE).bin 29 | 30 | firmware-flash-$(PLATFORM): 31 | $(PLATFORM)-mode-switch --verbose --flash-softcpu-firmware=$(FIRMWARE_FILEBASE).fbi 32 | $(PLATFORM)-mode-switch --verbose --reset-gateware 33 | 34 | firmware-connect-$(PLATFORM): 35 | flterm --port=$$($(PLATFORM)-mode-switch --get-serial-dev) 36 | 37 | firmware-clear-$(PLATFORM): 38 | $(PLATFORM)-mode-switch --verbose --clear-softcpu-firmware 39 | 40 | # Bios 41 | bios-flash-$(PLATFORM): 42 | $(PLATFORM)-mode-switch --verbose --flash-softcpu-bios=$(BIOS_FILE) 43 | $(PLATFORM)-mode-switch --verbose --reset-gateware 44 | 45 | # Extra commands 46 | help-$(PLATFORM): 47 | @true 48 | 49 | reset-$(PLATFORM): 50 | $(PLATFORM)-mode-switch --verbose --mode=serial 51 | $(PLATFORM)-mode-switch --verbose --mode=jtag 52 | $(PLATFORM)-mode-switch --verbose --mode=serial 53 | -------------------------------------------------------------------------------- /targets/opsis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/targets/opsis/__init__.py -------------------------------------------------------------------------------- /targets/opsis/axiom.py: -------------------------------------------------------------------------------- 1 | from migen import * 2 | from litex.soc.cores.gpio import GPIOIn, GPIOOut 3 | 4 | from targets.utils import csr_map_update 5 | from targets.opsis.net import NetSoC as BaseSoC 6 | 7 | 8 | class GPIO2TOFE(Module): 9 | def __init__(self, tofe): 10 | self.layout = tofe.layout 11 | for name, size in self.layout: 12 | setattr(self.submodules, name, GPIOOut(getattr(tofe, name))) 13 | 14 | def get_csrs(self): 15 | csrs = [] 16 | for name, size in self.layout: 17 | io_csr = getattr(self, name).get_csrs() 18 | assert len(io_csr) == 1 19 | io_csr[0].name = name 20 | csrs += [io_csr[0]] 21 | return csrs 22 | 23 | 24 | class AxiomSoC(BaseSoC): 25 | csr_peripherals = ( 26 | "gpio", 27 | ) 28 | csr_map_update(BaseSoC.csr_map, csr_peripherals) 29 | 30 | def __init__(self, platform, *args, **kwargs): 31 | BaseSoC.__init__(self, platform, *args, expansion='tofe2axiom', **kwargs) 32 | 33 | self.submodules.gpio = GPIO2TOFE(platform.request("tofe", 0)) 34 | 35 | 36 | SoC = AxiomSoC 37 | -------------------------------------------------------------------------------- /targets/pipistrello/Makefile.mk: -------------------------------------------------------------------------------- 1 | # pipistrello targets 2 | 3 | ifneq ($(PLATFORM),pipistrello) 4 | $(error "Platform should be pipistrello when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | PROG_PORT ?= /dev/ttyUSB0 12 | COMM_PORT ?= /dev/ttyUSB1 13 | BAUD ?= 115200 14 | 15 | # Image 16 | image-flash-$(PLATFORM): 17 | @echo "Unsupported" 18 | @false 19 | 20 | # Gateware 21 | gateware-load-$(PLATFORM): 22 | @echo "Unsupported." 23 | @false 24 | 25 | gateware-flash-$(PLATFORM): 26 | @echo "Unsupported" 27 | @false 28 | 29 | # Firmware 30 | firmware-load-$(PLATFORM): 31 | @echo "Unsupported." 32 | @false 33 | 34 | firmware-flash-$(PLATFORM): 35 | @echo "Unsupported." 36 | @false 37 | 38 | firmware-connect-$(PLATFORM): 39 | @echo "Unsupported." 40 | @false 41 | 42 | firmware-clear-$(PLATFORM): 43 | @echo "FIXME: Unsupported?." 44 | @false 45 | 46 | # Bios 47 | bios-flash-$(PLATFORM): 48 | @echo "Unsupported." 49 | @false 50 | 51 | # Extra commands 52 | help-$(PLATFORM): 53 | @true 54 | 55 | reset-$(PLATFORM): 56 | @echo "Unsupported." 57 | @false 58 | -------------------------------------------------------------------------------- /targets/saturn/Makefile.mk: -------------------------------------------------------------------------------- 1 | # saturn targets 2 | 3 | ifneq ($(PLATFORM),saturn) 4 | $(error "Platform should be saturn when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | PROG_PORT ?= /dev/ttyUSB0 12 | COMM_PORT ?= /dev/ttyUSB1 13 | BAUD ?= 115200 14 | 15 | # Image 16 | image-flash-$(PLATFORM): image-flash-py 17 | @true 18 | 19 | # Gateware 20 | gateware-load-$(PLATFORM): 21 | @echo "Unsupported." 22 | @false 23 | 24 | gateware-flash-$(PLATFORM): gateware-flash-py 25 | @true 26 | 27 | # Firmware 28 | firmware-load-$(PLATFORM): 29 | @echo "Unsupported." 30 | @false 31 | 32 | firmware-flash-$(PLATFORM): firmwage-flash-py 33 | @true 34 | 35 | firmware-connect-$(PLATFORM): 36 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 37 | 38 | firmware-clear-$(PLATFORM): 39 | @echo "FIXME: Unsupported?." 40 | @false 41 | 42 | # Bios 43 | bios-flash-$(PLATFORM): 44 | @echo "Unsupported." 45 | @false 46 | 47 | # Extra commands 48 | help-$(PLATFORM): 49 | @true 50 | 51 | reset-$(PLATFORM): 52 | @echo "Unsupported." 53 | @false 54 | -------------------------------------------------------------------------------- /targets/sim/Makefile.mk: -------------------------------------------------------------------------------- 1 | # Sim targets 2 | 3 | ifneq ($(PLATFORM),sim) 4 | $(error "Platform should be sim when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | # Image 12 | image-flash-$(PLATFORM): 13 | @echo "Unsupported." 14 | @false 15 | 16 | # Gateware 17 | gateware-load-$(PLATFORM): 18 | @echo "Unsupported." 19 | @false 20 | 21 | gateware-flash-$(PLATFORM): 22 | @echo "Unsupported." 23 | @false 24 | 25 | # Firmware 26 | firmware-load-$(PLATFORM): 27 | @echo "Unsupported." 28 | @false 29 | 30 | firmware-flash-$(PLATFORM): 31 | @echo "Unsupported." 32 | @false 33 | 34 | firmware-connect-$(PLATFORM): 35 | @echo "Unsupported." 36 | @false 37 | 38 | firmware-clear-$(PLATFORM): 39 | @echo "FIXME: Unsupported?." 40 | @false 41 | 42 | # Bios 43 | bios-flash-$(PLATFORM): 44 | @echo "Unsupported." 45 | @false 46 | 47 | # Extra commands 48 | help-$(PLATFORM): 49 | @echo " make $(PLATFORM)-setup" 50 | @echo " make $(PLATFORM)-teardown" 51 | 52 | reset-$(PLATFORM): 53 | @echo "Unsupported." 54 | @false 55 | 56 | $(PLATFORM)-setup: 57 | sudo true 58 | sudo openvpn --mktun --dev tap0 59 | sudo ifconfig tap0 $(IPRANGE).100 up 60 | sudo mknod /dev/net/tap0 c 10 200 61 | sudo chown $(shell whoami) /dev/net/tap0 62 | make tftpd_start 63 | 64 | $(PLATFORM)-teardown: 65 | sudo true 66 | make tftpd_stop 67 | sudo rm -f /dev/net/tap0 68 | sudo ifconfig tap0 down 69 | sudo openvpn --rmtun --dev tap0 70 | 71 | .PHONY: $(PLATFORM)-setup $(PLATFORM)-teardown 72 | -------------------------------------------------------------------------------- /targets/sim/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/targets/sim/__init__.py -------------------------------------------------------------------------------- /targets/sim/memtest.py: -------------------------------------------------------------------------------- 1 | from litedram.frontend.bist import LiteDRAMBISTGenerator, LiteDRAMBISTChecker 2 | 3 | from targets.utils import csr_map_update 4 | from targets.sim.net import NetSoC as BaseSoC 5 | 6 | 7 | class MemTestSoC(BaseSoC): 8 | csr_peripherals = ( 9 | "generator", 10 | "checker", 11 | ) 12 | csr_map_update(BaseSoC.csr_map, csr_peripherals) 13 | 14 | def __init__(self, platform, *args, **kwargs): 15 | BaseSoC.__init__(self, platform, *args, **kwargs) 16 | 17 | self.submodules.generator = LiteDRAMBISTGenerator( 18 | self.sdram.crossbar.get_port(mode="write"), 19 | ) 20 | #self.submodules.checker = LiteDRAMBISTChecker( 21 | # self.sdram.crossbar.get_port(mode="read", data_width=16), 22 | # clock_domain="hdmi_out1_pix", 23 | #) 24 | self.submodules.checker = LiteDRAMBISTChecker( 25 | self.sdram.crossbar.get_port(mode="read"), 26 | # cd="hdmi_out1_pix"), 27 | ) 28 | 29 | 30 | SoC = MemTestSoC 31 | -------------------------------------------------------------------------------- /targets/sim/net.py: -------------------------------------------------------------------------------- 1 | from litex.soc.integration.soc_core import mem_decoder 2 | 3 | from liteeth.phy.model import LiteEthPHYModel 4 | from liteeth.core.mac import LiteEthMAC 5 | 6 | from targets.utils import csr_map_update 7 | from targets.sim.base import BaseSoC 8 | 9 | 10 | class NetSoC(BaseSoC): 11 | # FIXME: The sim seems to require ethphy at 18 and ethmac at 19!? 12 | # csr_peripherals = ( 13 | # "ethphy", 14 | # "ethmac", 15 | # ) 16 | # csr_map_update(BaseSoC.csr_map, csr_peripherals) 17 | 18 | csr_map = { 19 | "ethphy": 18, 20 | "ethmac": 19, 21 | } 22 | csr_map.update(BaseSoC.csr_map) 23 | 24 | mem_map = { 25 | "ethmac": 0x30000000, # (shadow @0xb0000000) 26 | } 27 | mem_map.update(BaseSoC.mem_map) 28 | 29 | def __init__(self, *args, **kwargs): 30 | # Need a larger integrated ROM on or1k to fit the BIOS with TFTP support. 31 | if 'integrated_rom_size' not in kwargs and kwargs.get('cpu_type', 'lm32') != 'lm32': 32 | kwargs['integrated_rom_size'] = 0x10000 33 | 34 | BaseSoC.__init__(self, *args, **kwargs) 35 | 36 | self.submodules.ethphy = LiteEthPHYModel(self.platform.request("eth")) 37 | self.submodules.ethmac = LiteEthMAC(phy=self.ethphy, dw=32, interface="wishbone", endianness=self.cpu.endianness) 38 | self.add_wb_slave(mem_decoder(self.mem_map["ethmac"]), self.ethmac.bus) 39 | self.add_memory_region("ethmac", self.mem_map["ethmac"] | self.shadow_base, 0x2000) 40 | 41 | self.add_interupt("ethmac") 42 | 43 | def configure_iprange(self, iprange): 44 | iprange = [int(x) for x in iprange.split(".")] 45 | while len(iprange) < 4: 46 | iprange.append(0) 47 | # Our IP address 48 | self._configure_ip("LOCALIP", iprange[:-1]+[50]) 49 | # IP address of tftp host 50 | self._configure_ip("REMOTEIP", iprange[:-1]+[100]) 51 | 52 | def _configure_ip(self, ip_type, ip): 53 | for i, e in enumerate(ip): 54 | s = ip_type + str(i + 1) 55 | s = s.upper() 56 | self.add_constant(s, e) 57 | 58 | 59 | SoC = NetSoC 60 | -------------------------------------------------------------------------------- /targets/sim/video.py: -------------------------------------------------------------------------------- 1 | from migen import * 2 | 3 | from litevideo.output.common import * 4 | from litevideo.output.core import VideoOutCore 5 | 6 | from targets.utils import csr_map_update 7 | from targets.sim.net import NetSoC as BaseSoC 8 | 9 | 10 | class VGAModel(Module): 11 | def __init__(self, pads): 12 | self.sink = sink = stream.Endpoint(video_out_layout(24)) 13 | self.comb += [ 14 | sink.ready.eq(1), 15 | pads.de.eq(sink.de), 16 | pads.hsync.eq(sink.hsync), 17 | pads.vsync.eq(sink.vsync), 18 | pads.r.eq(sink.data[0:8]), 19 | pads.g.eq(sink.data[8:16]), 20 | pads.b.eq(sink.data[16:24]), 21 | ] 22 | 23 | 24 | class VideoSoC(BaseSoC): 25 | csr_peripherals = { 26 | "video_out": 20, 27 | } 28 | csr_map_update(BaseSoC.csr_map, csr_peripherals) 29 | 30 | def __init__(self, *args, **kwargs): 31 | BaseSoC.__init__(self, *args, **kwargs) 32 | 33 | self.submodules.video_out = VideoOutCore(self.sdram.crossbar.get_port()) 34 | self.submodules.vga = VGAModel(platform.request("vga")) 35 | self.comb += self.video_out.source.connect(self.vga.sink) 36 | -------------------------------------------------------------------------------- /targets/tinyfpga_bx/Makefile.mk: -------------------------------------------------------------------------------- 1 | # tinyfpga_bx targets 2 | 3 | ifneq ($(PLATFORM),tinyfpga_bx) 4 | $(error "Platform should be tinyfpga_bx when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | BAUD ?= 115200 11 | 12 | # Image 13 | image-flash-$(PLATFORM): 14 | tinyprog --program-image $(IMAGE_FILE) 15 | 16 | # Gateware 17 | gateware-load-$(PLATFORM): 18 | @echo "TinyFPGA BX doesn't support loading, use the flash target instead." 19 | @echo "make gateware-flash" 20 | @false 21 | 22 | # As with Mimasv2, if the user asks to flash the gateware only, the BIOS must 23 | # be sent as well (because the BIOS is too big to fit into the bitstream). 24 | GATEWARE_BIOS_FILE = $(TARGET_BUILD_DIR)/image-gateware+bios+none.bin 25 | 26 | gateware-flash-$(PLATFORM): $(GATEWARE_BIOS_FILE) 27 | tinyprog --program-image $(GATEWARE_BIOS_FILE) 28 | 29 | # To avoid duplicating the mkimage.py call here, if the user has not 30 | # already built a image-gateware+bios+none.bin, we call make recursively 31 | # to build one here, with the FIRMWARE=none override. 32 | # 33 | ifneq ($(GATEWARE_BIOS_FILE),$(IMAGE_FILE)) 34 | $(GATEWARE_BIOS_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) mkimage.py 35 | FIRMWARE=none make image 36 | endif 37 | 38 | # Firmware 39 | firmware-load-$(PLATFORM): 40 | @echo "Unsupported." 41 | @false 42 | 43 | firmware-flash-$(PLATFORM): 44 | @echo "TinyFPGA BX doesn't support just flashing firmware, use image target instead." 45 | @echo "make image-flash" 46 | @false 47 | 48 | firmware-connect-$(PLATFORM): 49 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 50 | 51 | firmware-clear-$(PLATFORM): 52 | @echo "FIXME: Unsupported?." 53 | @false 54 | 55 | # Bios 56 | bios-flash-$(PLATFORM): 57 | @echo "Unsupported." 58 | @false 59 | 60 | # Extra commands 61 | help-$(PLATFORM): 62 | @true 63 | 64 | reset-$(PLATFORM): 65 | @echo "Unsupported." 66 | @false 67 | -------------------------------------------------------------------------------- /targets/upduino_v1/Makefile.mk: -------------------------------------------------------------------------------- 1 | # upduino_v1 targets 2 | 3 | ifneq ($(PLATFORM),upduino_v1) 4 | $(error "Platform should be ice40_up5k_b_evn when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | BAUD ?= 115200 11 | 12 | # Image 13 | image-flash-$(PLATFORM): 14 | iceprog $(IMAGE_FILE) 15 | 16 | # Gateware 17 | gateware-load-$(PLATFORM): 18 | @echo "Upduino_v1 doesn't support loading, use the flash target instead." 19 | @echo "make gateware-flash" 20 | @false 21 | 22 | # As with Mimasv2, if the user asks to flash the gateware only, the BIOS must 23 | # be sent as well (because the BIOS is too big to fit into the bitstream). 24 | GATEWARE_BIOS_FILE = $(TARGET_BUILD_DIR)/image-gateware+bios+none.bin 25 | 26 | gateware-flash-$(PLATFORM): $(GATEWARE_BIOS_FILE) 27 | iceprog $(GATEWARE_BIOS_FILE) 28 | 29 | # To avoid duplicating the mkimage.py call here, if the user has not 30 | # already built a image-gateware+bios+none.bin, we call make recursively 31 | # to build one here, with the FIRMWARE=none override. 32 | # 33 | ifneq ($(GATEWARE_BIOS_FILE),$(IMAGE_FILE)) 34 | $(GATEWARE_BIOS_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) mkimage.py 35 | FIRMWARE=none make image 36 | endif 37 | 38 | # Firmware 39 | firmware-load-$(PLATFORM): 40 | @echo "Unsupported." 41 | @false 42 | 43 | firmware-flash-$(PLATFORM): 44 | @echo "Upduino_v1 doesn't support just flashing firmware, use image target instead." 45 | @echo "make image-flash" 46 | @false 47 | 48 | firmware-connect-$(PLATFORM): 49 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 50 | 51 | firmware-clear-$(PLATFORM): 52 | @echo "FIXME: Unsupported?." 53 | @false 54 | 55 | # Bios 56 | bios-flash-$(PLATFORM): 57 | @echo "Unsupported." 58 | @false 59 | 60 | # Extra commands 61 | help-$(PLATFORM): 62 | @true 63 | 64 | reset-$(PLATFORM): 65 | @echo "Unsupported." 66 | @false 67 | -------------------------------------------------------------------------------- /targets/utils.py: -------------------------------------------------------------------------------- 1 | import pprint 2 | 3 | 4 | def period_ns(freq): 5 | return 1e9/freq 6 | 7 | 8 | def csr_map_update(csr_map, csr_peripherals): 9 | csr_map.update(dict((n, v) 10 | for v, n in enumerate(csr_peripherals, start=(max(csr_map.values()) + 1) if csr_map else 0))) 11 | 12 | 13 | def csr_map_update_print(csr_map, csr_peripherals): 14 | print() 15 | print("-"*75) 16 | print("Previous Max: {}".format(max(csr_map.values()))) 17 | csr_map.update(dict((n, v) 18 | for v, n in enumerate(csr_peripherals, start=max(csr_map.values()) + 1))) 19 | print(" New Max: {}".format(max(csr_map.values()))) 20 | csr_values = list((b,a) for a, b in csr_map.items()) 21 | csr_values.sort() 22 | pprint.pprint(csr_values) 23 | print("-"*75) 24 | print() 25 | 26 | 27 | def assert_pll_clock(requested_freq, input, feedback, divide, msg): 28 | output_freq = int(input * feedback / divide / 1e6) 29 | assert output_freq == int(requested_freq / 1e6), ( 30 | "%s wants %s but got %i MHz (input=%i MHz feedback=%i divide=%i)" % ( 31 | msg, requested_freq, output_freq, int(input/1e6), feedback, divide)) 32 | 33 | 34 | class MHzType(int): 35 | """ 36 | >>> a = MHzType(1) 37 | >>> a == int(1e9) 38 | True 39 | >>> a 40 | 1 MHz 41 | >>> b = 5 * MHzType(1) 42 | >>> b == int(5e9) 43 | True 44 | >>> b 45 | 5 MHz 46 | >>> c = 200 * MHzType(1) 47 | >>> 48 | """ 49 | 50 | def __new__(cls, x): 51 | return int.__new__(cls, int(x * 1e6)) 52 | 53 | def __str__(self): 54 | return "%i MHz" % int(self / 1e6) 55 | 56 | def __repr__(self): 57 | return "%f * MHz()" % float(self / 1e6) 58 | 59 | def __mul__(self, o): 60 | return MHz.__class__(float(self) * o / 1e6) 61 | 62 | def __rmul__(self, o): 63 | return MHz.__class__(float(self) * o / 1e6) 64 | 65 | def to_ns(self): 66 | return 1e9/self 67 | 68 | 69 | MHz = MHzType(1) 70 | -------------------------------------------------------------------------------- /targets/waxwing/Makefile.mk: -------------------------------------------------------------------------------- 1 | # waxwing targets 2 | 3 | ifneq ($(PLATFORM),waxwing) 4 | $(error "Platform should be saturn when using this file!?") 5 | endif 6 | 7 | # Settings 8 | DEFAULT_TARGET = base 9 | TARGET ?= $(DEFAULT_TARGET) 10 | 11 | PROG_PORT ?= /dev/ttyUSB0 12 | COMM_PORT ?= /dev/ttyUSB1 13 | BAUD ?= 115200 14 | 15 | # Image 16 | image-flash-$(PLATFORM): image-flash-py 17 | @true 18 | 19 | # Gateware 20 | gateware-load-$(PLATFORM): 21 | openocd -f board/numato_$(PLATFORM).cfg -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" 22 | 23 | gateware-flash-$(PLATFORM): gateware-flash-py 24 | @true 25 | 26 | # Firmware 27 | firmware-load-$(PLATFORM): 28 | flterm --port=$(COMM_PORT) --kernel=$(FIRMWARE_FILEBASE).bin --speed=$(BAUD) 29 | 30 | firmware-flash-$(PLATFORM): firmwage-flash-py 31 | @true 32 | 33 | firmware-connect-$(PLATFORM): 34 | flterm --port=$(COMM_PORT) --speed=$(BAUD) 35 | 36 | firmware-clear-$(PLATFORM): 37 | @echo "FIXME: Unsupported?." 38 | @false 39 | 40 | # Bios 41 | bios-flash-$(PLATFORM): 42 | @echo "Unsupported." 43 | @false 44 | 45 | # Extra commands 46 | help-$(PLATFORM): 47 | @true 48 | 49 | reset-$(PLATFORM): 50 | @echo "Unsupported." 51 | @false 52 | -------------------------------------------------------------------------------- /test/check_csrs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import sys 3 | import csv 4 | import pprint 5 | 6 | print(sys.argv[1]) 7 | 8 | data = list(csv.reader(open(sys.argv[1],'r'))) 9 | 10 | bases = [x for x in data if x[0] == 'csr_base'] 11 | regs = [x for x in data if x[0] == 'csr_register'] 12 | 13 | mem_map = [] 14 | for _, name, loc, size, rw in regs: 15 | mem_map.append((int(loc, 16), int(size), name)) 16 | mem_map.sort() 17 | 18 | for i, (loc, size, name) in enumerate(mem_map[:-1]): 19 | print("{:x} {} {}".format(loc, size, name)) 20 | 21 | nloc, nsize, nname = mem_map[i+1] 22 | assert (loc + size*4) <= nloc, "{:x}+{} < {:x} ({} < {})".format(loc, size, nloc, name, nname) 23 | 24 | assert loc < (0xe0000000 + (2**14)*4), "{:x} {}".format(loc, name) 25 | 26 | regs_in_base = {} 27 | for _, name, loc, size, rw in regs: 28 | for _, bname, base, _, _ in bases: 29 | if name.startswith(bname): 30 | if bname not in regs_in_base: 31 | regs_in_base[bname] = [] 32 | regs_in_base[bname].append((int(loc, 16), name[len(bname)+1:], int(size), rw)) 33 | 34 | for name, regs in sorted(regs_in_base.items()): 35 | num_regs = sum(size for loc, name, size, rw in regs) 36 | assert num_regs < 200 37 | print(name, num_regs) 38 | -------------------------------------------------------------------------------- /test/edid/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS := -Wall -g 2 | 3 | ROOT := $(CURDIR)/../.. 4 | OBJ := edid_test.o $(ROOT)/firmware/edid.o 5 | EXE := edid_test 6 | 7 | CFLAGS += -I$(ROOT)/firmware 8 | 9 | DECODE := $(ROOT)/third_party/edid-decode/edid-decode 10 | 11 | all: $(EXE) 12 | 13 | $(EXE): $(OBJ) | $(ROOT)/firmware/edid.h 14 | 15 | $(DECODE): 16 | $(MAKE) -C $(ROOT)/third_party/edid-decode 17 | 18 | check: $(EXE) $(DECODE) 19 | ./$(EXE) | $(DECODE) | less 20 | 21 | .PHONY: clean 22 | clean: 23 | $(RM) $(EXE) $(OBJ) 24 | 25 | 26 | -------------------------------------------------------------------------------- /test/edid/edid_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 / TimVideo.us 3 | * Copyright 2015 / EnjoyDigital 4 | * Copyright 2016 Joel Stanley 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | #include "edid.h" 20 | 21 | static struct video_timing mode = { 22 | // 720p @ 60Hz 23 | //1280 720 60 Hz 45 kHz ModeLine "1280x720" 74.25 1280 1390 1430 165 0 720 725 730 750 +HSync +VSync 24 | .pixel_clock = 7425, 25 | 26 | .h_active = 1280, 27 | .h_blanking = 370, 28 | .h_sync_offset = 220, 29 | .h_sync_width = 40, 30 | 31 | .v_active = 720, 32 | .v_blanking = 30, 33 | .v_sync_offset = 20, 34 | .v_sync_width = 5 35 | }; 36 | 37 | int main() 38 | { 39 | int i; 40 | char *edid = malloc(128); 41 | 42 | generate_edid(edid, "OHW", "TV", 2015, "HDMI2USB-1", &mode); 43 | 44 | //generate_edid(&edid, "OHW", "TV", 2015, "HDMI2USB-2", &mode); 45 | 46 | for (i = 0; i < 128; i++) { 47 | printf("%02hhx", edid[i]); 48 | } 49 | printf("\n"); 50 | 51 | free(edid); 52 | }; 53 | -------------------------------------------------------------------------------- /test/edid_debug/make.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import argparse 3 | import importlib 4 | 5 | 6 | def _get_args(): 7 | parser = argparse.ArgumentParser() 8 | parser.add_argument("-b", "--bridge", default="uart", help="Bridge to use") 9 | parser.add_argument("--port", default="3", help="UART port") 10 | parser.add_argument("--baudrate", default=115200, help="UART baudrate") 11 | parser.add_argument("--busword", default=8, help="CSR busword") 12 | 13 | parser.add_argument("test", nargs="+", help="specify a test") 14 | 15 | return parser.parse_args() 16 | 17 | if __name__ == "__main__": 18 | args = _get_args() 19 | if args.bridge == "uart": 20 | from misoclib.com.uart.software.wishbone import UARTWishboneBridgeDriver 21 | port = args.port if not args.port.isdigit() else int(args.port) 22 | wb = UARTWishboneBridgeDriver(port, args.baudrate, "../csr.csv", int(args.busword), debug=False) 23 | else: 24 | ValueError("Invalid bridge {}".format(args.bridge)) 25 | 26 | def _import(name): 27 | return importlib.import_module(name) 28 | 29 | for test in args.test: 30 | t = _import(test) 31 | t.main(wb) 32 | -------------------------------------------------------------------------------- /test/edid_debug/test_la.py: -------------------------------------------------------------------------------- 1 | from litescope.software.driver.logic_analyzer import LiteScopeLogicAnalyzerDriver 2 | 3 | 4 | def main(wb): 5 | wb.open() 6 | # # # 7 | logic_analyzer = LiteScopeLogicAnalyzerDriver(wb.regs, "logic_analyzer", debug=True) 8 | 9 | # cond = {"hdmi_in0_edid_scl_raw" : 0} 10 | cond = {"hdmi_in0_edid_fsm_state" : 2} 11 | # cond = {} 12 | logic_analyzer.configure_term(port=0, cond=cond) 13 | logic_analyzer.configure_sum("term") 14 | logic_analyzer.configure_subsampler(64) 15 | logic_analyzer.run(offset=128, length=8192) 16 | 17 | while not logic_analyzer.done(): 18 | pass 19 | logic_analyzer.upload() 20 | 21 | logic_analyzer.save("dump.vcd") 22 | # # # 23 | wb.close() 24 | -------------------------------------------------------------------------------- /test/edid_debug/test_regs.py: -------------------------------------------------------------------------------- 1 | def main(wb): 2 | wb.open() 3 | regs = wb.regs 4 | # # # 5 | print("sysid : 0x{:04x}".format(regs.identifier_sysid.read())) 6 | print("revision : 0x{:04x}".format(regs.identifier_revision.read())) 7 | print("frequency : {}MHz".format(int(regs.identifier_frequency.read()/1000000))) 8 | # # # 9 | wb.close() 10 | -------------------------------------------------------------------------------- /test/hdmi2ethernet/captures/.keep_me: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/test/hdmi2ethernet/captures/.keep_me -------------------------------------------------------------------------------- /test/hdmi2ethernet/make.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import argparse 3 | import importlib 4 | 5 | 6 | def _get_args(): 7 | parser = argparse.ArgumentParser() 8 | parser.add_argument("-b", "--bridge", default="etherbone", help="Bridge to use") 9 | parser.add_argument("--port", default="2", help="UART port") 10 | parser.add_argument("--baudrate", default=115200, help="UART baudrate") 11 | parser.add_argument("--ip_address", default="192.168.1.42", help="Etherbone IP address") 12 | parser.add_argument("--udp_port", default=20000, help="Etherbone UDP port") 13 | parser.add_argument("--busword", default=8, help="CSR busword") 14 | 15 | parser.add_argument("test", nargs="+", help="specify a test") 16 | 17 | return parser.parse_args() 18 | 19 | if __name__ == "__main__": 20 | args = _get_args() 21 | if args.bridge == "uart": 22 | from misoclib.com.uart.software.wishbone import UARTWishboneBridgeDriver 23 | port = args.port if not args.port.isdigit() else int(args.port) 24 | wb = UARTWishboneBridgeDriver(port, args.baudrate, "../csr.csv", int(args.busword), debug=False) 25 | elif args.bridge == "etherbone": 26 | from misoclib.com.liteeth.software.wishbone import LiteEthWishboneBridgeDriver 27 | wb = LiteEthWishboneBridgeDriver(args.ip_address, int(args.udp_port), "../csr.csv", int(args.busword), debug=False) 28 | else: 29 | ValueError("Invalid bridge {}".format(args.bridge)) 30 | 31 | def _import(name): 32 | return importlib.import_module(name) 33 | 34 | for test in args.test: 35 | t = _import(test) 36 | t.main(wb) 37 | -------------------------------------------------------------------------------- /test/hdmi2ethernet/test_capture.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | import socket 4 | 5 | capture_dir = "./captures/" 6 | capture_filename = "capture.bin" 7 | jpg_filename = "capture_{}.jpg" 8 | capture_size = 10*1024*1024 9 | 10 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 11 | sock.bind(("", 8000)) 12 | 13 | # clean capture_dir 14 | subprocess.call(["rm", "-rf", capture_dir + "/*"]) 15 | 16 | # capture data 17 | data_size = 0 18 | f = open(os.path.join(capture_dir, capture_filename), "wb") 19 | while data_size <= capture_size: 20 | data, addr = sock.recvfrom(8192) 21 | data_size += len(data) 22 | f.write(data) 23 | f.close() 24 | 25 | # split data in jpg files 26 | def split_capture(f): 27 | c = bytearray() 28 | while True: 29 | b = f.read(1048) 30 | if not b: # end-of-file 31 | yield data 32 | return 33 | c += b 34 | while True: 35 | pos = c.find(bytearray(b"\xff\xd9")) 36 | if pos < 0: 37 | break 38 | yield c[:pos] 39 | c = c[pos + 2:] 40 | 41 | for i, capture in enumerate(split_capture(open(os.path.join(capture_dir, capture_filename), 'rb'))): 42 | f = open(os.path.join(capture_dir, jpg_filename.format(str(i))), "wb") 43 | f.write(capture) 44 | f.close() 45 | -------------------------------------------------------------------------------- /test/hdmi2ethernet/test_dump.py: -------------------------------------------------------------------------------- 1 | import copy 2 | import png 3 | 4 | SDRAM_BASE = 0x40000000 5 | LINE_SIZE = 1280*3 6 | DUMP_SIZE = 1280*720*4 7 | WORDS_PER_PACKET = 128 8 | 9 | def chunks(l, n): 10 | for i in xrange(0, len(l), n): 11 | yield l[i:i+n] 12 | 13 | def extract_rgb(pixel): 14 | b = (pixel & 0x3ff)/4 15 | pixel = pixel >> 10 16 | g = (pixel & 0x3ff)/4 17 | pixel = pixel >> 10 18 | r = (pixel & 0x3ff)/4 19 | return r, g, b 20 | 21 | def main(wb): 22 | wb.open() 23 | regs = wb.regs 24 | # # # 25 | print("dumping framebuffer memory...") 26 | dump = [] 27 | for n in range(DUMP_SIZE//(WORDS_PER_PACKET*4)): 28 | data = wb.read(SDRAM_BASE + n*WORDS_PER_PACKET*4, WORDS_PER_PACKET) 29 | for pixel in data: 30 | dump += extract_rgb(pixel) 31 | dump = [dump[x:x+LINE_SIZE] for x in range(0, len(dump), LINE_SIZE)] 32 | print("dumping to png file...") 33 | png.from_array(dump, "RGB").save("dump.png") 34 | # # # 35 | wb.close() 36 | -------------------------------------------------------------------------------- /test/hdmi2ethernet/test_regs.py: -------------------------------------------------------------------------------- 1 | def main(wb): 2 | wb.open() 3 | regs = wb.regs 4 | # # # 5 | print("sysid : 0x{:04x}".format(regs.identifier_sysid.read())) 6 | print("revision : 0x{:04x}".format(regs.identifier_revision.read())) 7 | print("frequency : {}MHz".format(int(regs.identifier_frequency.read()/1000000))) 8 | # # # 9 | wb.close() 10 | -------------------------------------------------------------------------------- /test/hdmi2ethernet/test_sdram.py: -------------------------------------------------------------------------------- 1 | import copy 2 | 3 | SDRAM_BASE = 0x40000000 4 | TEST_SIZE = 1024*1024 5 | WORDS_PER_PACKET = 128 6 | 7 | def seed_to_data(seed, random=True): 8 | if random: 9 | return (seed * 0x31415979 + 1) & 0xffffffff 10 | else: 11 | return seed 12 | 13 | 14 | def check(p1, p2): 15 | p1 = copy.deepcopy(p1) 16 | p2 = copy.deepcopy(p2) 17 | if isinstance(p1, int): 18 | return 0, 1, int(p1 != p2) 19 | else: 20 | if len(p1) >= len(p2): 21 | ref, res = p1, p2 22 | else: 23 | ref, res = p2, p1 24 | shift = 0 25 | while((ref[0] != res[0]) and (len(res) > 1)): 26 | res.pop(0) 27 | shift += 1 28 | length = min(len(ref), len(res)) 29 | errors = 0 30 | for i in range(length): 31 | if ref.pop(0) != res.pop(0): 32 | errors += 1 33 | return shift, length, errors 34 | 35 | 36 | def generate_packet(seed, length): 37 | r = [] 38 | for i in range(length): 39 | r.append(seed_to_data(seed, False)) 40 | seed += 1 41 | return r, seed 42 | 43 | def main(wb): 44 | wb.open() 45 | regs = wb.regs 46 | # # # 47 | errors = 0 48 | print("writing...") 49 | seed = 0 50 | for n in range(TEST_SIZE//(WORDS_PER_PACKET *4)): 51 | data, seed = generate_packet(seed, WORDS_PER_PACKET) 52 | wb.write(SDRAM_BASE + n*WORDS_PER_PACKET *4, data) 53 | print("reading...") 54 | seed = 0 55 | for n in range(TEST_SIZE//(WORDS_PER_PACKET *4)): 56 | ref, seed = generate_packet(seed, WORDS_PER_PACKET ) 57 | data = wb.read(SDRAM_BASE + n*WORDS_PER_PACKET *4, WORDS_PER_PACKET) 58 | s, l, e = check(ref, data) 59 | errors += e 60 | print("errors: " + str(errors)) 61 | # # # 62 | wb.close() 63 | -------------------------------------------------------------------------------- /test/ipython_etherbone.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from IPython import embed 4 | 5 | from litescope.software.driver.analyzer import LiteScopeAnalyzerDriver 6 | 7 | from common import * 8 | 9 | 10 | def main(): 11 | args, wb = connect("LiteX Etherbone Interactive Console") 12 | print_memmap(wb) 13 | print() 14 | 15 | analyzer_csv = '{}/analyzer.csv'.format(make_testdir(args)) 16 | if os.path.exists(analyzer_csv): 17 | analyzer = LiteScopeAnalyzerDriver(wb.regs, "analyzer", config_csv=analyzer_csv, debug=True) 18 | else: 19 | print("WARNING: No litescope csv found at {},\nAssuming litescope not included in design!".format(analyzer_csv)) 20 | 21 | try: 22 | embed() 23 | finally: 24 | wb.close() 25 | 26 | 27 | if __name__ == "__main__": 28 | main() 29 | -------------------------------------------------------------------------------- /test/test_analyzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import time 3 | 4 | from litex.soc.tools.remote import RemoteClient 5 | from litescope.software.driver.analyzer import LiteScopeAnalyzerDriver 6 | 7 | wb = RemoteClient() 8 | wb.open() 9 | 10 | # # # 11 | 12 | analyzer = LiteScopeAnalyzerDriver(wb.regs, "analyzer", debug=True) 13 | analyzer.configure_trigger(cond={"charsync0_data": 0x354}) 14 | analyzer.configure_subsampler(1) 15 | analyzer.run(offset=32, length=128) 16 | analyzer.wait_done() 17 | analyzer.upload() 18 | analyzer.save("dump.vcd") 19 | 20 | # # # 21 | 22 | wb.close() 23 | -------------------------------------------------------------------------------- /test/test_delays.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import time 3 | 4 | from litex.soc.tools.remote import RemoteClient 5 | from litescope.software.driver.analyzer import LiteScopeAnalyzerDriver 6 | 7 | wb = RemoteClient() 8 | wb.open() 9 | 10 | # # # 11 | 12 | DVISAMPLER_DELAY_RST = 0x1 13 | DVISAMPLER_DELAY_INC = 0x2 14 | DVISAMPLER_DELAY_DEC = 0x4 15 | 16 | data0_delay = 0 17 | data1_delay = 0 18 | data2_delay = 1 19 | 20 | wb.regs.hdmi_in0_data0_cap_dly_ctl.write(DVISAMPLER_DELAY_RST) 21 | for i in range(data0_delay): 22 | wb.regs.hdmi_in0_data0_cap_dly_ctl.write(DVISAMPLER_DELAY_INC) 23 | 24 | wb.regs.hdmi_in0_data1_cap_dly_ctl.write(DVISAMPLER_DELAY_RST) 25 | for i in range(data1_delay): 26 | wb.regs.hdmi_in0_data1_cap_dly_ctl.write(DVISAMPLER_DELAY_INC) 27 | 28 | wb.regs.hdmi_in0_data2_cap_dly_ctl.write(DVISAMPLER_DELAY_RST) 29 | for i in range(data2_delay): 30 | wb.regs.hdmi_in0_data2_cap_dly_ctl.write(DVISAMPLER_DELAY_INC) 31 | 32 | 33 | # # # 34 | 35 | wb.close() 36 | -------------------------------------------------------------------------------- /test/test_dump.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from litex.soc.tools.remote import RemoteClient 3 | 4 | rom_base = 0x00000000 5 | dump_size = 0x8000 6 | words_per_packet = 128 7 | 8 | wb = RemoteClient() 9 | wb.open() 10 | 11 | # # # 12 | 13 | print("dumping cpu rom to dump.bin...") 14 | dump = [] 15 | for n in range(dump_size//(words_per_packet*4)): 16 | dump += wb.read(rom_base + n*words_per_packet*4, words_per_packet) 17 | f = open("dump.bin", "wb") 18 | for v in dump: 19 | f.write(v.to_bytes(4, byteorder="big")) 20 | f.close() 21 | 22 | # # # 23 | 24 | wb.close() 25 | -------------------------------------------------------------------------------- /test/test_etherbone.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import time 4 | import sys 5 | sys.path.append("../") 6 | 7 | from litex.soc.tools.remote import RemoteClient 8 | 9 | wb = RemoteClient("192.168.1.50", 1234) 10 | wb.open() 11 | 12 | # # # 13 | 14 | # test uart 15 | for c in "hello world from host\n": 16 | wb.regs.uart_rxtx.write(ord(c)) 17 | 18 | # # # 19 | 20 | wb.close() 21 | -------------------------------------------------------------------------------- /test/test_leds.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from litex.soc.tools.remote import RemoteClient 3 | 4 | import time 5 | 6 | 7 | class PWM: 8 | def __init__(self, regs, name): 9 | for reg in ["enable", "period", "width"]: 10 | setattr(self, "_" + reg, getattr(regs, name + "_" + reg)) 11 | self.set_period(128) 12 | self.set_width(0) 13 | self.enable() 14 | 15 | def enable(self): 16 | self._enable.write(1) 17 | 18 | def disable(self): 19 | self._enable.write(0) 20 | 21 | def set_period(self, period): 22 | self._period.write(period) 23 | 24 | def set_width(self, width): 25 | self._width.write(width) 26 | 27 | 28 | class RGBLed: 29 | def __init__(self, regs, name, n): 30 | for c in "rgb": 31 | self.r = PWM(regs, "rgb_leds_r"+str(n)) 32 | self.g = PWM(regs, "rgb_leds_g"+str(n)) 33 | self.b = PWM(regs, "rgb_leds_b"+str(n)) 34 | 35 | 36 | wb = RemoteClient() 37 | wb.open() 38 | regs = wb.regs 39 | 40 | # # # 41 | 42 | for i in range(16): 43 | regs.leds_out.write(i) 44 | time.sleep(0.1) 45 | 46 | rgb_leds = [RGBLed(regs, "rgb_leds", i) for i in range(4)] 47 | 48 | def knight_rider(color, value): 49 | sequence = [] 50 | sequence = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3] 51 | for led in sequence: 52 | pwm = getattr(rgb_leds[led], color) 53 | pwm.set_width(value) 54 | time.sleep(0.05) 55 | pwm.set_width(0) 56 | 57 | def disco(): 58 | for led in rgb_leds: 59 | for c in "rgb": 60 | pwm = getattr(led, c) 61 | for i in range(64): 62 | pwm.set_width(i) 63 | time.sleep(0.005) 64 | pwm.set_width(0) 65 | 66 | knight_rider("r", 64) 67 | time.sleep(0.5) 68 | knight_rider("r", 64) 69 | time.sleep(0.5) 70 | 71 | disco() 72 | 73 | 74 | # # # 75 | 76 | wb.close() 77 | -------------------------------------------------------------------------------- /test/test_xadc.py: -------------------------------------------------------------------------------- 1 | from litex.soc.tools.remote import RemoteClient 2 | 3 | wb = RemoteClient("192.168.1.50", 1234, csr_data_width=8) 4 | wb.open() 5 | regs = wb.regs 6 | 7 | # # # 8 | 9 | print("temperature: %f°C" %(regs.xadc_temperature.read()*503.975/4096 - 273.15)) 10 | print("vccint: %fV" %(regs.xadc_vccint.read()/4096*3)) 11 | print("vccaux: %fV" %(regs.xadc_vccaux.read()/4096*3)) 12 | print("vccbram: %fV" %(regs.xadc_vccbram.read()/4096*3)) 13 | 14 | # # # 15 | 16 | wb.close() 17 | -------------------------------------------------------------------------------- /third_party/libuip/contiki-lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef CONTIKI_LIB_H_ 35 | #define CONTIKI_LIB_H_ 36 | 37 | #include "contiki.h" 38 | #include "lib/list.h" 39 | #include "lib/memb.h" 40 | #include "lib/mmem.h" 41 | #include "lib/random.h" 42 | 43 | #endif /* CONTIKI_LIB_H_ */ 44 | -------------------------------------------------------------------------------- /third_party/libuip/contiki-version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef __CONTIKI_VERSION__ 35 | #define __CONTIKI_VERSION__ 36 | 37 | #ifndef CONTIKI_VERSION_STRING 38 | #define CONTIKI_VERSION_STRING "Contiki 3.x" 39 | #endif /* CONTIKI_VERSION_STRING */ 40 | 41 | #endif /* __CONTIKI_VERSION__ */ 42 | -------------------------------------------------------------------------------- /third_party/libuip/lib/assert.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | #include 32 | 33 | void 34 | _xassert(const char *file, int lineno) 35 | { 36 | printf("Assertion failed: file %s, line %d.\n", file, lineno); 37 | /* 38 | * loop for a while; 39 | * call _reset_vector__(); 40 | */ 41 | } 42 | -------------------------------------------------------------------------------- /third_party/libuip/lib/me_tabs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Swedish Institute of Computer Science 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | #ifndef ME_TABS_H_ 33 | #define ME_TABS_H_ 34 | 35 | extern const unsigned short me_encode_tab[256]; 36 | extern const unsigned char me_decode_tab[256]; 37 | extern const unsigned char me_valid_tab[256]; 38 | 39 | #endif /* ME_TABS_H_ */ 40 | 41 | -------------------------------------------------------------------------------- /third_party/libuip/lib/mmem.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mithro/HDMI2USB-litex-firmware/fc388fffa6e8ebd0c6483186c914177d7c69e7e6/third_party/libuip/lib/mmem.h -------------------------------------------------------------------------------- /third_party/libuip/lib/print-stats.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | 33 | /** 34 | * \file 35 | * Convenience function for printing system statistics 36 | * \author 37 | * Adam Dunkels 38 | */ 39 | 40 | #ifndef PRINT_STATS_H_ 41 | #define PRINT_STATS_H_ 42 | 43 | void print_stats(void); 44 | 45 | #endif /* PRINT_STATS_H_ */ 46 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip/uip-packetqueue.h: -------------------------------------------------------------------------------- 1 | #ifndef UIP_PACKETQUEUE_H 2 | #define UIP_PACKETQUEUE_H 3 | 4 | #include "sys/ctimer.h" 5 | 6 | struct uip_packetqueue_handle; 7 | 8 | struct uip_packetqueue_packet { 9 | struct uip_ds6_queued_packet *next; 10 | uint8_t queue_buf[UIP_BUFSIZE - UIP_LLH_LEN]; 11 | uint16_t queue_buf_len; 12 | struct ctimer lifetimer; 13 | struct uip_packetqueue_handle *handle; 14 | }; 15 | 16 | struct uip_packetqueue_handle { 17 | struct uip_packetqueue_packet *packet; 18 | }; 19 | 20 | void uip_packetqueue_new(struct uip_packetqueue_handle *handle); 21 | 22 | 23 | struct uip_packetqueue_packet * 24 | uip_packetqueue_alloc(struct uip_packetqueue_handle *handle, clock_time_t lifetime); 25 | 26 | 27 | void 28 | uip_packetqueue_free(struct uip_packetqueue_handle *handle); 29 | 30 | uint8_t *uip_packetqueue_buf(struct uip_packetqueue_handle *h); 31 | uint16_t uip_packetqueue_buflen(struct uip_packetqueue_handle *h); 32 | void uip_packetqueue_set_buflen(struct uip_packetqueue_handle *h, uint16_t len); 33 | 34 | 35 | #endif /* UIP_PACKETQUEUE_H */ 36 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip64-addr/README.md: -------------------------------------------------------------------------------- 1 | The `ip64-addr` module converts between IPv4 addresses and 2 | IPv4-encoded IPv6 addresses. It is used in IPv6 networks that are 3 | attached to the IPv4 world through an `ip64` router. With such a 4 | router, IPv6 nodes in the network can reach IPv4 nodes by using their 5 | IPv6-encoded address. 6 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip64/README.md: -------------------------------------------------------------------------------- 1 | The `ip64` module lets an IPv6 Contiki network be connected to an IPv4 2 | network without any additional configuration or outside software. The 3 | `ip64` module runs on the RPL root node and translates outgoing IPv6 4 | packets into IPv4 packets nd incoming IPv4 packets to IPv6 packets. 5 | 6 | The `ip64` module uses stateful NAT64 (RFC6164) to do the packet 7 | translation and DNS64 (RFC6147) to catch DNS requests for IPv6 8 | addresses, turn them into requests for IPv4 addresses, and turn the 9 | replies into responses for IPv6 addresses. This allows devices on the 10 | inside IPv6 network to connect to named servers on the outside IPv4 11 | network. 12 | 13 | The `ip64` module hooks into the IPv6 stack via a fallback 14 | interface. Any packet that can not be routed into the local RPL mesh 15 | will be sent over the fallback interface, where `ip64` picks it up, 16 | translates it into an IPv4 packet, and sends it over its outgoing 17 | interface. 18 | 19 | In addition to providing NAT64 and DNS64 services, the `ip64` module 20 | also performs DHCPv4 to request IPv4 address for devices connected to 21 | a medium such as Ethernet. The `ip64` module also performs ARP 22 | processing to communicate over the Ethernet. 23 | 24 | The `ip64` module uses a configuration file called `ip64-conf.h` that 25 | specifies what device to use for the IPv4 network. This file is 26 | intended to be placed in the platform directory. An example 27 | configuration file called `ip64-conf-example.h` is provided in this 28 | directory. 29 | 30 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip64/ip64-conf-example.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the copyright holder nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | */ 31 | #ifndef IP64_CONF_H 32 | #define IP64_CONF_H 33 | 34 | #include "ip64-tap-driver.h" 35 | #include "ip64-eth-interface.h" 36 | 37 | #define IP64_CONF_UIP_FALLBACK_INTERFACE ip64_eth_interface 38 | #define IP64_CONF_INPUT ip64_eth_interface_input 39 | 40 | #define IP64_CONF_ETH_DRIVER ip64_tap_driver 41 | 42 | #endif /* IP64_CONF_H */ 43 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip64/ip64-driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the copyright holder nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | */ 31 | #ifndef IP64_DRIVER_H 32 | #define IP64_DRIVER_H 33 | 34 | struct ip64_driver { 35 | void (* init)(void); 36 | int (* output)(uint8_t *packet, uint16_t packet_len); 37 | }; 38 | 39 | 40 | #endif /* IP64_DRIVER_H */ 41 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip64/ip64-eth-interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the copyright holder nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | */ 31 | #ifndef IP64_ETH_INTERFACE_H 32 | #define IP64_ETH_INTERFACE_H 33 | 34 | #include "net/ip/uip.h" 35 | 36 | void ip64_eth_interface_input(uint8_t *packet, uint16_t len); 37 | 38 | extern const struct uip_fallback_interface ip64_eth_interface; 39 | 40 | #endif /* IP64_ETH_INTERFACE_H */ 41 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip64/ip64-eth.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the copyright holder nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | */ 31 | #include "ip64-eth.h" 32 | 33 | #include 34 | 35 | struct ip64_eth_addr ip64_eth_addr; 36 | 37 | /*---------------------------------------------------------------------------*/ 38 | void 39 | ip64_eth_addr_set(struct ip64_eth_addr *addr) 40 | { 41 | memcpy(&ip64_eth_addr, addr, sizeof(struct ip64_eth_addr)); 42 | } 43 | /*---------------------------------------------------------------------------*/ 44 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip64/ip64-interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the copyright holder nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | */ 31 | #ifndef IP64_INTERFACE_H 32 | #define IP64_INTERFACE_H 33 | 34 | struct ip64_interface { 35 | void (* init)(void); 36 | int (* input)(uint8_t *packet, uint16_t packet_len); 37 | int (* output)(uint8_t *packet, uint16_t packet_len); 38 | }; 39 | 40 | 41 | #endif /* IP64_INTERFACE_H */ 42 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip64/ip64-ipv4-dhcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the copyright holder nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | */ 31 | #ifndef IP64_IPV4_DHCP_H 32 | #define IP64_IPV4_DHCP_H 33 | 34 | void ip64_ipv4_dhcp_init(void); 35 | 36 | #endif /* IP64_IPV4_DHCP_H */ 37 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip64/ip64-null-driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the copyright holder nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | */ 31 | #ifndef IP64_NULL_DRIVER_H 32 | #define IP64_NULL_DRIVER_H 33 | 34 | #include "ip64-driver.h" 35 | 36 | extern const struct ip64_driver ip64_null_driver; 37 | 38 | #endif /* IP64_NULL_DRIVER_H */ 39 | -------------------------------------------------------------------------------- /third_party/libuip/net/ip64/ip64-slip-interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the copyright holder nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | */ 31 | #ifndef IP64_SLIP_INTERFACE_H 32 | #define IP64_SLIP_INTERFACE_H 33 | 34 | void ip64_slip_interface_input(uint8_t *packet, uint16_t len); 35 | 36 | extern const struct uip_fallback_interface ip64_slip_interface; 37 | 38 | #endif /* IP64_SLIP_INTERFACE_H */ 39 | -------------------------------------------------------------------------------- /third_party/libuip/net/ipv4/uip-fw-drv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef UIP_FW_DRV_H_ 35 | #define UIP_FW_DRV_H_ 36 | 37 | #include "contiki.h" 38 | #include "net/ipv4/uip-fw.h" 39 | 40 | PROCESS_NAME(uip_fw_process); 41 | 42 | #endif /* UIP_FW_DRV_H_ */ 43 | -------------------------------------------------------------------------------- /third_party/libuip/net/mac/contikimac/contikimac-framer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | 33 | /** 34 | * \file 35 | * Creates and parses the ContikiMAC header. 36 | * \author 37 | * Konrad Krentz 38 | */ 39 | 40 | #ifndef CONTIKIMAC_FRAMER_H_ 41 | #define CONTIKIMAC_FRAMER_H_ 42 | 43 | #include "net/mac/framer.h" 44 | 45 | extern const struct framer contikimac_framer; 46 | 47 | #endif /* CONTIKIMAC_FRAMER_H_ */ 48 | -------------------------------------------------------------------------------- /third_party/libuip/net/mac/contikimac/contikimac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | 33 | /** 34 | * \file 35 | * Header file for the ContikiMAC radio duty cycling protocol 36 | * \author 37 | * Adam Dunkels 38 | */ 39 | 40 | #ifndef CONTIKIMAC_H 41 | #define CONTIKIMAC_H 42 | 43 | #include "sys/rtimer.h" 44 | #include "net/mac/rdc.h" 45 | #include "dev/radio.h" 46 | 47 | extern const struct rdc_driver contikimac_driver; 48 | 49 | #endif /* CONTIKIMAC_H */ 50 | -------------------------------------------------------------------------------- /third_party/libuip/net/mac/framer-802154.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | /** 32 | * \file 33 | * A MAC framer for IEEE 802.15.4 34 | * \author 35 | * Niclas Finne 36 | * Joakim Eriksson 37 | */ 38 | 39 | #ifndef FRAMER_802154_H_ 40 | #define FRAMER_802154_H_ 41 | 42 | #include "net/mac/framer.h" 43 | 44 | extern const struct framer framer_802154; 45 | 46 | #endif /* FRAMER_802154_H_ */ 47 | -------------------------------------------------------------------------------- /third_party/libuip/net/mac/framer-nullmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | /** 32 | * \file 33 | * MAC framer for nullmac 34 | * \author 35 | * Niclas Finne 36 | * Joakim Eriksson 37 | */ 38 | 39 | #ifndef FRAMER_NULLMAC_H_ 40 | #define FRAMER_NULLMAC_H_ 41 | 42 | #include "net/mac/framer.h" 43 | 44 | extern const struct framer framer_nullmac; 45 | 46 | #endif /* FRAMER_NULLMAC_H_ */ 47 | -------------------------------------------------------------------------------- /third_party/libuip/net/mac/nullmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | 33 | /** 34 | * \file 35 | * A MAC protocol implementation that does not do anything. 36 | * \author 37 | * Adam Dunkels 38 | */ 39 | 40 | #ifndef NULLMAC_H_ 41 | #define NULLMAC_H_ 42 | 43 | #include "net/mac/mac.h" 44 | #include "dev/radio.h" 45 | 46 | extern const struct mac_driver nullmac_driver; 47 | 48 | 49 | #endif /* NULLMAC_H_ */ 50 | -------------------------------------------------------------------------------- /third_party/libuip/net/mac/nullrdc-noframer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | 33 | /** 34 | * \file 35 | * A MAC protocol implementation that does not do anything. 36 | * \author 37 | * Adam Dunkels 38 | */ 39 | 40 | #ifndef NULLRDC_NOFRAMER_H_ 41 | #define NULLRDC_NOFRAMER_H_ 42 | 43 | #include "net/mac/rdc.h" 44 | #include "dev/radio.h" 45 | 46 | extern const struct rdc_driver nullrdc_noframer_driver; 47 | 48 | #endif /* NULLRDC_NOFRAMER_H_ */ 49 | -------------------------------------------------------------------------------- /third_party/libuip/net/mac/nullrdc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | 33 | /** 34 | * \file 35 | * A null RDC implementation that uses framer for headers. 36 | * \author 37 | * Adam Dunkels 38 | * Niclas Finne 39 | */ 40 | 41 | #ifndef NULLRDC_H_ 42 | #define NULLRDC_H_ 43 | 44 | #include "net/mac/rdc.h" 45 | 46 | extern const struct rdc_driver nullrdc_driver; 47 | 48 | #endif /* NULLRDC_H_ */ 49 | -------------------------------------------------------------------------------- /third_party/libuip/net/rime/chameleon-bitopt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | 33 | /** 34 | * \file 35 | * A Chameleon module that produces bit-optimized headers 36 | * \author 37 | * Adam Dunkels 38 | */ 39 | 40 | #ifndef CHAMELEON_BITOPT_H_ 41 | #define CHAMELEON_BITOPT_H_ 42 | 43 | #include "sys/cc.h" 44 | 45 | extern CC_CONST_FUNCTION struct chameleon_module chameleon_bitopt; 46 | 47 | #endif /* CHAMELEON_BITOPT_H_ */ 48 | -------------------------------------------------------------------------------- /third_party/libuip/net/rime/chameleon-raw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | 33 | /** 34 | * \file 35 | * A Chameleon module that produces non-optimized headers 36 | * \author 37 | * Adam Dunkels 38 | */ 39 | 40 | #ifndef CHAMELEON_RAW_H_ 41 | #define CHAMELEON_RAW_H_ 42 | 43 | #include "sys/cc.h" 44 | 45 | extern CC_CONST_FUNCTION struct chameleon_module chameleon_raw; 46 | 47 | #endif /* CHAMELEON_RAW_H_ */ 48 | -------------------------------------------------------------------------------- /third_party/libuip/net/rime/rimestats.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | 33 | /** 34 | * \file 35 | * A brief description of what this file is. 36 | * \author 37 | * Adam Dunkels 38 | */ 39 | 40 | #include "net/rime/rimestats.h" 41 | /*---------------------------------------------------------------------------*/ 42 | 43 | struct rimestats rimestats; 44 | 45 | /*---------------------------------------------------------------------------*/ 46 | -------------------------------------------------------------------------------- /third_party/libuip/sys/arg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, Adam Dunkels. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following 12 | * disclaimer in the documentation and/or other materials provided 13 | * with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior 16 | * written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This file is part of the Contiki desktop OS 31 | * 32 | * 33 | */ 34 | #ifndef ARG_H_ 35 | #define ARG_H_ 36 | 37 | void arg_init(void); 38 | 39 | char *arg_alloc(char size); 40 | void arg_free(char *arg); 41 | 42 | #endif /* ARG_H_ */ 43 | -------------------------------------------------------------------------------- /third_party/libuip/sys/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef LOG_H_ 35 | #define LOG_H_ 36 | 37 | #include "contiki-conf.h" 38 | 39 | #if LOG_CONF_ENABLED 40 | void log_message(const char *part1, const char *part2); 41 | #else /* LOG_CONF_ENABLED */ 42 | #define log_message(p1, p2) 43 | #endif /* LOG_CONF_ENABLED */ 44 | 45 | #endif /* LOG_H_ */ 46 | -------------------------------------------------------------------------------- /third_party/libuip/sys/node-id.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | 35 | #ifndef NODE_ID_H_ 36 | #define NODE_ID_H_ 37 | 38 | void node_id_restore(void); 39 | void node_id_burn(unsigned short node_id); 40 | 41 | extern unsigned short node_id; 42 | 43 | #endif /* NODE_ID_H_ */ 44 | -------------------------------------------------------------------------------- /third_party/libuip/sys/procinit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Swedish Institute of Computer Science 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the Contiki operating system. 30 | * 31 | */ 32 | #ifndef PROCINIT_H_ 33 | #define PROCINIT_H_ 34 | 35 | #include "sys/process.h" 36 | 37 | #if ! CC_NO_VA_ARGS 38 | #define PROCINIT(...) \ 39 | const struct process *procinit[] = {__VA_ARGS__, NULL} 40 | #endif 41 | 42 | void procinit_init(void); 43 | 44 | #endif /* PROCINIT_H_ */ 45 | --------------------------------------------------------------------------------