urbite

Papilio One SPI flash unsupported

15 posts in this topic

As detailed in post http://forum.gadgetfactory.net/index.php?/topic/1651-introducing-zap-ide-zpuino-and-avr8-together-at-last/page-2#entry12535, I've been unable to program the ZPUino bootloader into my Papilio One SPI flash. I've also tried with the standalone loader, which fails with the same error as the ZAP IDE. Here's the relevant info from the log window(s):

 

JTAG chainpos: 0 Device IDCODE = 0x11c1a093    Desc: XC3S250E

Using built-in device list
ISC_Done       = 1
ISC_Enabled    = 0
House Cleaning = 1
DONE           = 1
Programming to SPI Flash
Using devlist.txt
Programming a Papilio One 250K
JTAG chainpos: 0 Device IDCODE = 0x11c1a093    Desc: XC3S250E
Using devlist.txt

Uploading "bscan_spi_xc3s250e.bit". Done.
Programming time 111.0 ms

Programming External Flash Memory with "C:\projects\Papilio\loader\zap-2.0.7/hardware/zpuino/zpu/bootloaders/p1_250k/zpuino-1.0-PapilioOne-S3E250-Vanilla-1.0.bit".
Unknown Numonyx/Micron Flash Type (0x20)
Error: SPI Status Register [0x00] mismatch (Wrong device or device not ready)..

 

The last two lines indicate that an unrecognizable flash type was detected. The SPI flash on my board is an SST M25P40VP. After digging a bit more it appears that the M25XX family of SPI flash devices isn't supported in the loader. Although the flash is marked as an SST, it falls in the Numonyx/Micron category because SST was one of the partners that formed Numonyx. The manufacturer ID for the M25XX parts is 0x20, which is the same as Numonyx/Micron in the loader code. The only Numonxy/Micron parts supported are the newer N25XX family, which have a memory type = 0xBA while the M25xx parts have a memory type = 0x20. Hence, the above error makes sense.

 

The loader source file where the SPI flash types are defined is progalgspi.cpp at https://github.com/GadgetFactory/Papilio-Loader/blob/master/papilio-prog/progalgspi.cpp Here is the relevant section of code.

 

        case 0x20: /* Numonyx/Micron */
            if (tdo[2] == 0xBA) { //N25QXXX
                switch(tdo[3])
                {
                    case 0x16: /* N25Q32 */
                        Pages=16384;
                        PageSize=256;
                        BulkErase=60;
                        SectorErase=3;
                        FlashType=GENERIC;
                        break;
                    case 0x17: /* N25Q64 */
                        Pages=32768;
                        PageSize=256;
                        BulkErase=250;
                        SectorErase=3;
                        FlashType=GENERIC;
                        break;
                    case 0x18: /* N25Q128 */
                        Pages=65536;
                        PageSize=256;
                        BulkErase=250;
                        SectorErase=3;
                        FlashType=GENERIC;
                        break;
                    case 0x19: /* N25Q256 */
                        Pages=131072;
                        PageSize=256;
                        BulkErase=480;
                        SectorErase=3;
                        FlashType=GENERIC;
                        break;
                    default:
                        printf("Unknown Numonyx/Micron N25Q Flash Size (0x%.2x)\n", tdo[3]);
                        return false;
                }
                if(verbose)
                    printf("Found Numonyx/Micron Flash (Pages=%d, Page Size=%d bytes, %d bits).\n",Pages,PageSize,Pages*PageSize*8);
                break;
            } else {
                printf("Unknown Numonyx/Micron Flash Type (0x%.2x)\n", tdo[2]);
                return false;
            }
            break;

 

To support the M25XX family, the above bolded/colorized code section should be changed to:

 

            } else {
            if (tdo[2] == 0x20) { //M25XX
                switch(tdo[3])
                {
                    case 0x11: /* M25P10A 1-Mbit*/
                        Pages=512;
                        PageSize=256;
                        BulkErase=6000;
                        SectorErase=3000;
                        FlashType=GENERIC;
                        break;
                    case 0x12: /* M25P20 2-Mbit*/
                        Pages=1024;
                        PageSize=256;
                        BulkErase=6000;
                        SectorErase=3000;
                        FlashType=GENERIC;
                        break;
                    case 0x13: /* M25P40 4-Mbit*/
                        Pages=2048;
                        PageSize=256;
                        BulkErase=10000;
                        SectorErase=3000;
                        FlashType=GENERIC;
                        break;
                    case 0x14: /* M25P80 8-Mbit */
                        Pages=4096;
                        PageSize=256;
                        BulkErase=20000;
                        SectorErase=3000;
                        FlashType=GENERIC;
                        break;
                    case 0x15: /* M25P16 16-Mbit */
                        Pages=8192;
                        PageSize=256;
                        BulkErase=40000;
                        SectorErase=3000;
                        FlashType=GENERIC;
                        break;
                    case 0x16: /* M25P32 32-Mbit */
                        Pages=16384;
                        PageSize=256;
                        BulkErase=80000;
                        SectorErase=3000;
                        FlashType=GENERIC;
                        break;
                    default:
                        printf("Unknown Numonyx/Micron M25P Flash Size (0x%.2x)\n", tdo[3]);
                        return false;
                }
                if(verbose)
                    printf("Found Numonyx/Micron Flash (Pages=%d, Page Size=%d bytes, %d bits).\n",Pages,PageSize,Pages*PageSize*8);
                break;
            } else {
                printf("Unknown Numonyx/Micron Flash Type (0x%.2x)\n", tdo[2]);
                return false;
            }
            break;

 

 

Is there anyone who'll volunteer to rebuild the loader for windows with the above changes? I'm primarily an mswindows guy and just enough of a linux person to get bogged down in rebuilding, whereas an expert could do it rather quickly.

 

After the loader is rebuilt can I simply replace papilio-prog.exe in my ZAP IDE at <somewhere>\zap-2.0.7\hardware\tools\papilio\papilio_loader\bin\? Or do I need to replace more files?

 

 

Share this post


Link to post
Share on other sites

I'm a bit puzzled why the SPI flash on my Papilio One is not supported by the loader. I assume that I have a very old board and the M25P series wasn't used on very many Papilio Ones, otherwise this issue would have likely been reported already.

Share this post


Link to post
Share on other sites

Hello urbite,

 

It is indeed odd, I can add the code, but I'd like to figure out where that board came from first. We never used those chips, we used Atmel chips in the older versions of the board... So if it is a counterfeit I don't really want to add the code and help out counterfeiters...

 

Thanks,

Jack.

Share this post


Link to post
Share on other sites

I made the changes to progalgspi.cpp that were given in an earlier post. Thanks to the excellent readme file and a prebuilt Lubuntu 12.04 VM, I was able to check out the project, make the changes, and build a new papilio-prog.exe. There was one bump in the road where the build failed because of a syntax error involving PKG_CHECK_MODULES. A google search revealed the answer in - of all places - a gadgetfactory forum: http://forum.gadgetfactory.net/index.php?/topic/1195-papilio-loader-in-64-bit-linux/page-2#entry7056

 

Apparently some package was missing, as indicated by the following snippet from the referenced forum topic. As a linux hack, I never would have found this...

 

... Turns out I was missing the package pkg-config, so there was no PKG_CHECK_MODULES macro in aclocal.m4 as you suspected. ...

 

Now I can burn a bootloader (or any other bit file) into my Papilio One board. After burning the bootloader I attempted to load the sample sketch. Unfortunately the attempt to load was met with the following error.

 

Executing  C:\projects\Papilio\loader\zap-2.0.7/hardware/tools/zpu/bin/zpu-elf-size C:\Users\PAULUR~1\AppData\Local\Temp\build324513325183267400.tmp/Papilio_QuickStart.cpp.elf
Binary sketch size: 1,856 bytes (of a 12,160 byte maximum) - 1,836 bytes ROM, 236 bytes memory, 15% used
Board: GadgetFactory Papilio One 250 @ 96000000 Hz (0xa4020e00)
Unknown flash type, exiting

 

The above error indicates that the lack of support for M25PXX SPI proms in the papilio programmer is also lacking in the bootloader, since I suspect the same or similar SPI functions are used. M25PXX support will need to be added to the bootloader before sketches can be successfully downloaded to this Papilio board.

 

Should I push the modified progalgspi.cpp to the repository?

Share this post


Link to post
Share on other sites

Hello urbite,

 

It is indeed odd, I can add the code, but I'd like to figure out where that board came from first. We never used those chips, we used Atmel chips in the older versions of the board... So if it is a counterfeit I don't really want to add the code and help out counterfeiters...

 

Thanks,

Jack.

 

I just went through my emails and found some correspondence dated August 13, 2010, related to the purchase of this board this order from gadgetfactory. I forwarded the email to the support@gadgetfactory.net email address from whence the original email was received. Let me know if that's not a good email address.

 

The order number was 72.

 

While I understand that you don't want to help counterfeiters, it doesn't appear that this is a counterfeit board (based upon email correspondence and my memory). I think it's a good idea to have support for as many SPI flash devices as reasonably possible. The added space is minimal to support the additional family. I do know that this is a popular SPI flash family, as I've used them in several designs.

Share this post


Link to post
Share on other sites

Ahhh, ok, that is pretty old! I don't mind adding the support for that chip to the Papilio Loader. But I would like to get you setup with a newer board, if that was order 72 then its most likely a board I built by hand... Let me send you a new board and you can keep that old one if you would like. If you send us an email to support@gadgetfactory.net with a link to this forum thread and an up to date shipping address we will get you a new board in the mail.

 

In the meantime I'm firing up linux to make you a executable with the changes you are requesting.

 

Jack.

Share this post


Link to post
Share on other sites

Arghhh, getting error message:

progalgspi.cpp: In member function ‘bool ProgAlgSpi::Spi_Identify(bool)’:progalgspi.cpp:405: error: a function-definition is not allowed here before ‘{’ tokenprogalgspi.cpp:1090: error: expected ‘}’ at end of input

It's late and I'm too tired to look closer at it right now, will have to look more tomorrow.

 

Jack.

Share this post


Link to post
Share on other sites

#72 - I guess that makes me an early adopter :-)

 

I *believe* I now have an executable that will program the bootloader bit file into the memory, and that I've been able to successfully do this. What I haven't been able to find are the source files that make up the bootloader, as it appears that the code the writes the sketch into the SPI flash doesn't support M25PXX parts. Either that or something else is not quite right.

 

The only other reference I found to SPI programming was this file:

https://github.com/GadgetFactory/Papilio-Loader/blob/master/xc3sprog/trunk/progalgspiflash.cpp

 

However, it has support for the M25PXX parts, so if this is what's in the bootloader, then the 'Unknown flash type, exiting' error when attempting to program a sketch is puzzling.

 

Can you point me to the source files that make up the actual bootloader?

Share this post


Link to post
Share on other sites

Arghhh, getting error message:

progalgspi.cpp: In member function ‘bool ProgAlgSpi::Spi_Identify(bool)’:progalgspi.cpp:405: error: a function-definition is not allowed here before ‘{’ tokenprogalgspi.cpp:1090: error: expected ‘}’ at end of input

It's late and I'm too tired to look closer at it right now, will have to look more tomorrow.

 

Jack.

 

The code snippet I provided had a syntax errors - nested if-elses usually get me. I'll email you the corrected file that allows the programmer to build correctly. I tried to push the file to the repo, but it wasn't being allowed. This is my first time working with git, so I probably overlooked something obvious.

 

Agreed on resuming tomorrow. I have to call it a night also. Thanks for your help and feedback. I'll send you a message per your request.

Share this post


Link to post
Share on other sites

#72 - I guess that makes me an early adopter :-)

 

I *believe* I now have an executable that will program the bootloader bit file into the memory, and that I've been able to successfully do this. What I haven't been able to find are the source files that make up the bootloader, as it appears that the code the writes the sketch into the SPI flash doesn't support M25PXX parts. Either that or something else is not quite right.

 

The only other reference I found to SPI programming was this file:

https://github.com/GadgetFactory/Papilio-Loader/blob/master/xc3sprog/trunk/progalgspiflash.cpp

 

However, it has support for the M25PXX parts, so if this is what's in the bootloader, then the 'Unknown flash type, exiting' error when attempting to program a sketch is puzzling.

 

Can you point me to the source files that make up the actual bootloader?

 

This is going to be tougher to deal with, Alvie takes care of the code for the ZPUino tools. I'm not sure where that code is...

 

I think we are better off just getting you a new board then trying to track this down...

 

Jack

Share this post


Link to post
Share on other sites

I think I did remove support for that eeprom, mostly due to lack of space in the bootloader. But it might be another issue...

 

Can you run the programmer by hand with extra "-v -v" argument ? Might be a know timing issue with S3E boards.

 

Alvie

Share this post


Link to post
Share on other sites

I was able to successfully rebuild papilio-prog.exe for Windows yesterday and used it to program the bootloader from the ZAP IDE. In the log window I could see a message indicating that the verification was successful, which indicates that the M25P40 SPI flash can be successfully programmed. I only tried it once, but could try to program it multiple times tonight and see if it programs consistently. In that case, the SPI programming would be validated.

 

Alvie - which file in the bootloader has the code to support the various SPI flash families? I found the following file that appears to be the correct one in:

https://github.com/GadgetFactory/Papilio-Loader/blob/master/xc3sprog/trunk/progalgspiflash.cpp

 

It looks like the Numonyx/Micron vendor ID, 0x20, is in the search list:

 

line 523:

  switch (fbuf[0])
    {
    case 0x1f:
      res = spi_flashinfo_at45(fbuf);
      break;
    case 0x30:
      res = spi_flashinfo_amic(fbuf);
      break;
    case 0x40:
      res = spi_flashinfo_amic_quad(fbuf);
      break;
    case 0x20:
      res = spi_flashinfo_m25p(fbuf);
      break;
 
And the 4 Mbit chip is in the sub-family list:
 
line 362:
  switch (fbuf[1])
    {
    case 0x20:
      fprintf(stderr, "Found Numonyx M25P Device, Device ID 0x%02x%02x\n",
              fbuf[1], fbuf[2]);
      switch (fbuf[2])
        {
        case 0x11:
          pages = 512;
          sector_size = 32768; /* Bytes = 262144 bits*/
          break;
        case 0x12:
          pages = 1024;
          break;
        case 0x13:
          pages = 2048;
          break;
        case 0x14:
          pages = 4096;
          break;
        case 0x15:
          pages = 8192;
          break;
        case 0x16:
          pages = 16384;
          break;
 

If this is the file that's included in the XC3S bootloader, then it has the needed support and it's puzzling why it doesn't work.

 

Alvie - I seem to remember have a similar experience getting the correct ID with the SPI flash when porting ZPU to the Nexsys 2 board.

 

I'll put my Bus Pirate analyzer on the SPI lines tonight and see of the correct ID is being returned.

 

Getting this to work isn't critical, as this particular Papilio One can simply be retired or replaced. Instead, now it's bugging me why it isn't working. If you can just point me to the relevant files and any needed general instructions, I'll do the rebuilding of the bootloader and testing on my end and report the results here.

Share this post


Link to post
Share on other sites

You are better off using xc3sprog application, papilio-prog is a fork of that application.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now