drtrigon / fpgarduino-icestorm

Arduino IDE integration for picorv32 (icestudio/icestorm FPGA soft-core)
9 stars 2 forks source link

Support for IceBreaker board (ICE40)? #1

Open Harvie opened 4 years ago

Harvie commented 4 years ago

Hello, can you please add support/bitstream for ICEBREAKER board?

It seems to be opensource and extremely well documented: https://github.com/icebreaker-fpga/icebreaker

Also you already support other ICE40 boards, so this should not be so hard to do...

drtrigon commented 3 years ago

Have you tried to use the project in order to generate a bitstream for an icebreaker board? You will need to change the pins to match the icebreaker board.

As I do not own an icebreaker board I cannot test this myself...

drtrigon commented 3 years ago

@esden and @0xdec can you give this a try? I would be glad to help!

The basic idea is to implement a picorv32 soft core into the icebreaker FPGA in order to become something similar to an arduino/avr board. The board then can be programmed very easily from Arduino IDE. Are you interested in this?

Harvie commented 3 years ago

You will need to change the pins to match the icebreaker board.

Where can i modify these settings? Perhaps we also need to set the clock speeds correctly...

drtrigon commented 3 years ago

Have you experience working with icestudio? Look at https://raw.githubusercontent.com/drtrigon/fpgarduino-icestorm/master/AlhambraII/picorv32/variants/AlhambraII/gpio_adc_hardware.png - this is a screenshot of the icestudio project. There you can see the box with text/code in it, this is the soft-core with clock input (clk). The pins mentioned are on the left hand side (GPIO0..7 and INP8..15). You will have to select in icestudio the icebreaker board and adopt these pins to your hardware. (You might also need to change LED0..7 on the top right, as I assume icebreaker does not have 7 LEDs onboard)

You can find the icestudio project you need to modify under https://github.com/drtrigon/fpgarduino-icestorm/tree/master/AlhambraII/picorv32/variants/AlhambraII it's the GPIO_ADC-recent-picorv32.zip.

You might probably need to adopt clock division factors in the soft-core code I do not remember this at the moment. When this will be the case I can have a look at the code and guide you. For the moment just extract the project, open it in icestudio, adopt it to icebreaker and try to generate a bitstream.

(ps.: What is the price for icebreaker board for developer? Is there a discount?)

Harvie commented 3 years ago

Have you experience working with icestudio?

A bit. Is it enough to re-map the pins and clk inputs in order to program this with arduino IDE? Isn't there need to load some kind of bootloader to the softcore, so i can upload sketches to it over serial? (i don't have experience with softcores, but atmel based arduinos need bootloader to be flashed on the chip before i can use it...)

(ps.: What is the price for icebreaker board for developer? Is there a discount?)

I choosed IceBreaker for my first FPGA experiments, because it seemed affordable, while also having support in opensource toolchains. I got it on Aliexpress for $29 few months ago, but the prices increased since to ~$38... Now there is also some new chinese design "ICESugar" board for $29, but i am not sure if that is compatible with icebreaker or not. Perhaps they increased icebreaker prices to get more sales on icesugar...

jordiorlando commented 3 years ago

Hey! This seems like a cool project. We (1BitSquared) are quite busy with a bunch of projects right now, so I don't think I'll have time to tackle this in the near future, but we welcome more projects that support iCEBreaker!

(ps.: What is the price for icebreaker board for developer? Is there a discount?)

I choosed IceBreaker for my first FPGA experiments, because it seemed affordable, while also having support in opensource toolchains. I got it on Aliexpress for $29 few months ago, but the prices increased since to ~$38... Now there is also some new chinese design "ICESugar" board for $29, but i am not sure if that is compatible with icebreaker or not. Perhaps they increased icebreaker prices to get more sales on icesugar...

Unfortunately iCEBreaker has become popular enough that it has been cloned all over Aliexpress. While it is an open-source project, these clones unfortunately undercut the original on price without contributing anything to the community. If you're interested in joining our community, you can find us on Discord or pick up a non-cloned iCEBreaker that will actually help us pay our bills!

Harvie commented 3 years ago

these clones unfortunately undercut the original on price without contributing anything to the community.

Not really true as long as the cheap clones are used by developers to boost the icebreaker software ecosystem which is available to community :-)

jordiorlando commented 3 years ago

these clones unfortunately undercut the original on price without contributing anything to the community.

Not really true as long as the cheap clones are used by developers to boost the icebreaker software ecosystem which is available to community :-)

Fair point! If you're looking for something just as cheap as the Aliexpress clones, you're welcome to check out the Bitsy, which has the exact same capabilities, but is Teensy compatible. We also have an EU store to help lower shipping costs etc.

Sales pitch aside, this seems like quite an interesting application for iCEBreaker FPGA. We'd love to have you join us over on the #icebreaker channel on Discord, there are lots of cool folx doing cool FPGA stuff there.

drtrigon commented 3 years ago

A bit. Is it enough to re-map the pins and clk inputs in order to program this with arduino IDE? Isn't there need to load some kind of bootloader to the softcore, so i can upload sketches to it over serial? (i don't have experience with softcores, but atmel based arduinos need bootloader to be flashed on the chip before i can use it...)

Currently it does NOT use a bootloader. It uses iceprog in order to write the program to the memory directly. This is similar to uploading a bitstream, but it writes just the program - or from Arduino point of view to write a bootloader to the bare bone chip. The Arduino IDE setup and config files described in this repo allows you to do this.

It is on the todo list to make it work with a bootloader also. But for most users this is a subtle difference only, if you use it as an Arduino equivalent in 99.99% of all use cases you won't recognize any difference.

interested in joining our community, you can find us on Discord or pick up a non-cloned iCEBreaker that will actually help us > pay our bills!

I am always interested - especially in these kinds of projects ;). The crucial point here is the time... (as always). It's not that I do not want you help to pay your bills - it's just that I do have bills to pay myself... ;) And so if I have to invest time AND money ... then I have to step back as I cannot justify the investment for the moment (said having to say that). The Bitsy looks very interesting actually - reminds me to the cool ItsyBitsy M4 (https://www.adafruit.com/product/3800). I am more looking for Arduino Uno compatible solutions (e.g. 5V compatible) like the nice Alhambra II - unfortunately is uses a HX8K only and not an UPX5. An ItsyBitsy (ATSAMD51 M4) compatible solution would also be great (again; 5V compatibility please!).

drtrigon commented 3 years ago

I gave this a try using icestudio 0.5.0. I adopted the pins but I do not have experience with icebreaker - so I have no clue whether it makes sense when looking e.g. at the flash (spi) pinout. I also removed the ADC part as icebreaker does not have an adc onboard. See screenshot attached: image Now when I try to generate the bitstream I get:

export APIO_HOME_DIR=/home/demo/.icestudio/apio; "/home/demo/.icestudio/venv/bin/apio" build --board iCEBreaker -p "/tmp/icestudio-9974pV6LkRqHRQPN"

[Mon Nov 23 09:30:45 2020] Processing iCEBreaker
--------------------------------------------------------------------------------
yosys -p "synth_ice40 -blif hardware.blif" -q demo.v main.v picorv32.v picosoc.v simpleuart.v spiflash.v spimemio.v
Warning: Yosys has only limited support for tri-state logic at the moment. (spiflash.v:86)
Warning: Yosys has only limited support for tri-state logic at the moment. (spiflash.v:87)
Warning: Yosys has only limited support for tri-state logic at the moment. (spiflash.v:88)
Warning: Yosys has only limited support for tri-state logic at the moment. (spiflash.v:89)
Warning: Wire main.\vd94bec.vceed39.v2b6436.v02da0a.v4af6e4.ve4e0df.i1 [7] is used but has no driver.
Warning: Wire main.\vd94bec.vceed39.v2b6436.v02da0a.v4af6e4.ve4e0df.i1 [6] is used but has no driver.
Warning: Wire main.\vd94bec.vceed39.v2b6436.v02da0a.v4af6e4.ve4e0df.i1 [5] is used but has no driver.
Warning: Wire main.\vd94bec.vceed39.v2b6436.v02da0a.v4af6e4.ve4e0df.i1 [4] is used but has no driver.
Warning: Wire main.\vd94bec.vceed39.v2b6436.v02da0a.v4af6e4.ve4e0df.i1 [3] is used but has no driver.
Warning: Wire main.\vd94bec.vceed39.v2b6436.v02da0a.v4af6e4.ve4e0df.i1 [2] is used but has no driver.
Warning: Wire main.\vd94bec.vceed39.v2b6436.v02da0a.v4af6e4.ve4e0df.i1 [1] is used but has no driver.
Warning: Wire main.\vd94bec.vceed39.v2b6436.v02da0a.v4af6e4.ve4e0df.i1 [0] is used but has no driver.
Warning: Wire main.\vd94bec.vb91e1f.v2d11c0.rst_i is used but has no driver.
Warning: Wire main.\v9342a3.vb0a79e.v02da0a.v6399a8.v402662.i1 is used but has no driver.
Warning: Wire main.\v9342a3.vb0a79e.v02da0a.v4af6e4.ve4e0df.i1 [7] is used but has no driver.
Warning: Wire main.\v9342a3.vb0a79e.v02da0a.v4af6e4.ve4e0df.i1 [6] is used but has no driver.
Warning: Wire main.\v9342a3.vb0a79e.v02da0a.v4af6e4.ve4e0df.i1 [5] is used but has no driver.
Warning: Wire main.\v9342a3.vb0a79e.v02da0a.v4af6e4.ve4e0df.i1 [4] is used but has no driver.
Warning: Wire main.\v9342a3.vb0a79e.v02da0a.v4af6e4.ve4e0df.i1 [3] is used but has no driver.
Warning: Wire main.\v9342a3.vb0a79e.v02da0a.v4af6e4.ve4e0df.i1 [2] is used but has no driver.
Warning: Wire main.\v9342a3.vb0a79e.v02da0a.v4af6e4.ve4e0df.i1 [1] is used but has no driver.
Warning: Wire main.\v9342a3.vb0a79e.v02da0a.v4af6e4.ve4e0df.i1 [0] is used but has no driver.
Warning: Wire main.\v74abe4.soc.inp [31] is used but has no driver.
Warning: Wire main.\v74abe4.soc.inp [30] is used but has no driver.
Warning: Wire main.\v74abe4.soc.inp [29] is used but has no driver.
Warning: Wire main.\v74abe4.soc.inp [28] is used but has no driver.
Warning: Wire main.\v74abe4.soc.inp [27] is used but has no driver.
Warning: Wire main.\v74abe4.soc.inp [26] is used but has no driver.
Warning: Wire main.\v74abe4.soc.inp [25] is used but has no driver.
Warning: Wire main.\v74abe4.soc.inp [24] is used but has no driver.
arachne-pnr -d 5k -P sg48 -p main.pcf -o hardware.asc -q hardware.blif
main.pcf:4: fatal error: set_io: too few arguments
scons: *** [hardware.asc] Error 1
========================= [ ERROR ] Took 36.85 seconds =========================

I am quite sure this is used but has no driver. is a minor issue but I cannot sort it out at the moment, any hint is appreciated.

The project is attached: GPIO_ADC-recent-picorv32.zip

Hope this helps to make further progress here...