Skip to content

Mistyping device definition leads to unclear errors. #337

Description

@jchidley

Mistyping the device value (in this example ICE40UP5K instead of iCE40UP5K) leads to unclear error messages on platform.build

blinky.py

from nmigen import *
import os
import subprocess

from nmigen.build import *
from nmigen.vendor.lattice_ice40 import *
from nmigen_boards.resources import *

class board(LatticeICE40Platform):
    device      = "ICE40UP5K"
    package     = "SG48"
    resources   = [
        *LEDResources(pins="41", attrs=Attrs(IO_STANDARD="SB_LVCMOS")),
    ]

    connectors  = []

    def toolchain_program(self, products, name):
        iceprog = os.environ.get("ICEPROG", "iceprog")
        with products.extract("{}.bin".format(name)) as bitstream_filename:
            subprocess.check_call([iceprog, "-S", bitstream_filename])

class Blinky(Elaboratable):
    def elaborate(self, platform):
        led   = platform.request("led", 0)
        timer = Signal(20)

        m = Module()
        m.domains.sync = sync = ClockDomain()
        m.submodules.osc = Instance(
            "SB_HFOSC",
            p_CLKHF_DIV="0b00",
            o_CLKHF=sync.clk,
        )

        m.d.sync += timer.eq(timer + 1)
        m.d.comb += led.o.eq(timer[-1])
        return m


if __name__ == "__main__":

    platform = board()
    platform.build(Blinky(), do_program=False)

Error output:

ERROR: Unable to place cell 'osc_OSC' of type 'ICESTORM_HFOSC'
ERROR: Packing design failed.
0 warnings, 2 errors
Traceback (most recent call last):
  File "/home/jack/nmigen/examples/board/01_blinky.py", line 51, in <module>
    platform.build(Blinky(), do_program=False)
  File "/home/jack/.local/lib/python3.8/site-packages/nmigen/build/plat.py", line 82, in build
    products = plan.execute_local(build_dir)
  File "/home/jack/.local/lib/python3.8/site-packages/nmigen/build/run.py", line 98, in execute_local
    subprocess.check_call(["sh", "{}.sh".format(self.script)])
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sh', 'build_top.sh']' returned non-zero exit status 255.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions