Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

icebin2nvcm: tool to generate .nvcm file from iCE40 .bin #272

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

majbthrd
Copy link

@majbthrd majbthrd commented Oct 6, 2020

I've tested this by verifying its output compares with pre-existing matching .bin and .nvcm files from Lattice tools. I've also been able to use the generated .nvcm with Lattice Diamond Programmer.

It should be obvious to anyone familiar with 25 series PROMs that the .nvcm is a text version of the SPI transactions to program the NVCM. Lattice's app note acknowledges that this is the case. Note that the page size is 8 bytes.

IMPORTANT: the NVCM is ONE-TIME PROGRAMMABLE!!! Just because it is programmable doesn't make it re-programmable.

Hopefully, this tool will enable yosys iCE40 users to generate .nvcm files. It might also help Lattice users who only have a .bin and need a .nvcm; the Lattice tools don't seem to provide such a conversion.

@majbthrd majbthrd marked this pull request as ready for review October 7, 2020 01:01
@djedditt
Copy link

Great tool! You might want to replace #include <malloc.h> with #include <stdlib.h> as it won't compile on OS X otherwise. The malloc.h header is non-standard and not available in OS X.

@majbthrd
Copy link
Author

Thanks @djedditt. I have added the suggested change.

@PsiStarPsi
Copy link

I would like to add that I have programmed an NVCM generated in this fashion from @majbthrd 's fork and it worked as expected on a design with an iCE40 UP5K in the 30-ball WLSCP package.

It would be very nice to have this feature merged into the main line. =)

@cibomahto
Copy link

cibomahto commented Feb 28, 2023

Thanks! With Diamond Programmer 3.12.1.454.2, trying to load a file for an iCE40UP5K target, I got the following error:

WARNING - Cannot get the device name from the file.
File C:/Users/matt/Other-Repos/tillitis-key1/hw/production_test/binaries/top.nvcm:
 is invalid for expected iCE40UP5K  device.

Adding a stub comment to the beginning of the NVCM file allowed Diamond to accept the file, and NVCM Program,Verify succeeded after that:

#DN a      <--added
06    <--previous start of .nvcm file
02 00 00 00 7e aa 99 7e 51 00 01 05 
02 00 00 08 92 00 20 62 02 b3 82 00 
02 00 00 10 00 72 01 50 11 00 01 01 

I think Diamond programmer is supposed to validate both the #DN and #PT fields, but it doesn't appear this is the case.

I was also able to generate this higher up in the toolchain by adding the comment to my .asc file:

.comment from next-pnr
Part: device-part

but it doesn't appear that nextpnr has a feature to do this automatically:
https://github.com/YosysHQ/nextpnr/blob/48b0025732f7b5b1b7b091691bb5a26634ae5069/ice40/bitstream.cc#L301

@ElecGeek
Copy link

ElecGeek commented Nov 3, 2024

Hi
I would have add to "NVCM is ONE-TIME PROGRAMMABLE!!! " the fact if an NVCM has been programmed, the falsh rom is never read any-more. This only one way to get something else is to place the ICE in slave mode and program from a programmer or a host computer.

I would have add, line 31, ... len = 0;

For new utilities like that, one has some examples using the C++ and the streams in https://github.com/ElecGeek/HealthMeter . It can be compiled directly on many plate-forms, using GCC8.5, and can handle files and paths names using GCC10 or more. There is a workflow example to compile and place the binaries in the artefact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants