Forum Discussion
Altera_Forum
Honored Contributor
14 years agoHelp: Windows didn't assign Bar0 to PCie (address mapping is not correct)
Dear all,
We changed the Altera Cyclone PCIe DDR2 reference design to our needs. However, it doesn't work. The address mapping is not correct, it doesn't agree to address assignments in Qsys. In WinDriver, Bar0 doesn't appear, only Bar2 appears under "Memory" tab (see Attached Figure). But the address range of Bar2 is not correct either, and the reading and writing were not correct when we write then read from Bar2. Anyone can give any suggestions? Why it didn't have bar0 as assigned in Qsys? The Windows operating system is Windows XP. I attached the figures of Qsys block diagram, Qsys address map and IP Complier. Thank you very much!27 Replies
- Altera_Forum
Honored Contributor
Look at your "Address Map" image. BAR0 has the 256MB DDR mapped from 0x1000_0000 to 0x1FFF_FFFF, and it has the onchip RAM mapped lower in that are, so the BAR region needs to be 2 x 256MB = 512MB.
Many computers will not boot with such large BAR regions. In your case, the BIOS probably did not enable that region. Start by trying to use a smaller BAR. The Qsys PCIe bridge is missing a function that most PCI bridges normally have, which is the ability to independently set the BAR size, and the base address of where that BAR maps to. Using this feature, you can normally take a 1MB BAR, and move it anywhere in the PCIe device address map, eg., in your case you would be able to look at the DDR 1MB at a time. This is sufficient for simple testing. Since the final application should use DMA, the use of small BAR regions is not an issue. Start with a small BAR - even if you think this is not the right solution - since using the small BAR will show you whether or not this is really your problem. Cheers, Dave - Altera_Forum
Honored Contributor
Thanks, can the bar region be as large as 256 MB or more?
We use "system"-> "assign base address" menu, the DDR now is mapped to 0x0000_0000 to 0x0fff_ffff, the on-chip memory now is mapped to 0x1000_0000 to 0x1003_ffff. But it still doesn't work. Bar0 still does not appear. --- Quote Start --- Look at your "Address Map" image. BAR0 has the 256MB DDR mapped from 0x1000_0000 to 0x1FFF_FFFF, and it has the onchip RAM mapped lower in that are, so the BAR region needs to be 2 x 256MB = 512MB. Many computers will not boot with such large BAR regions. In your case, the BIOS probably did not enable that region. Start by trying to use a smaller BAR. The Qsys PCIe bridge is missing a function that most PCI bridges normally have, which is the ability to independently set the BAR size, and the base address of where that BAR maps to. Using this feature, you can normally take a 1MB BAR, and move it anywhere in the PCIe device address map, eg., in your case you would be able to look at the DDR 1MB at a time. This is sufficient for simple testing. Since the final application should use DMA, the use of small BAR regions is not an issue. Start with a small BAR - even if you think this is not the right solution - since using the small BAR will show you whether or not this is really your problem. Cheers, Dave --- Quote End --- - Altera_Forum
Honored Contributor
--- Quote Start --- can the bar region be as large as 256 MB or more? --- Quote End --- The PCIe spec will not stop you, but your particular hardware might. My EliteBook will not boot with a BAR of 256MB. --- Quote Start --- We use "system"-> "assign base address" menu, the DDR now is mapped to 0x0000_0000 to 0x0fff_ffff, the on-chip memory now is mapped to 0x1000_0000 to 0x1003_ffff. But it still doesn't work. Bar0 still does not appear. --- Quote End --- Because you did not change the BAR size by doing this. Look at the report on the Qsys GUI. Look at the synthesis report. Look at this document here: http://www.alteraforum.com/forum/showthread.php?t=35678 It has some comments. To try and isolate this problem, start with just the on-chip RAM in the BAR at a base address of zero. You can use the "Address Map" tab to re-assign the addresses. Once you can confirm that you can boot windows, you can increase the size of the BAR (the offset of the on-chip RAM) until it breaks. Then you will know the limits for your particular hardware setup. Cheers, Dave - Altera_Forum
Honored Contributor
Thank you, Dave,
We actually got rid of the DDR2 once and has on-chip memory and SGDMA at Qsys. But it didn't seem to help and Bar0 sill didn't appear at the WinDriver memory tab. There was nothing under WinDriver memory tab. Could you diagnose this problem? --- Quote Start --- The PCIe spec will not stop you, but your particular hardware might. My EliteBook will not boot with a BAR of 256MB. Because you did not change the BAR size by doing this. Look at the report on the Qsys GUI. Look at the synthesis report. Look at this document here: http://www.alteraforum.com/forum/showthread.php?t=35678 It has some comments. To try and isolate this problem, start with just the on-chip RAM in the BAR at a base address of zero. You can use the "Address Map" tab to re-assign the addresses. Once you can confirm that you can boot windows, you can increase the size of the BAR (the offset of the on-chip RAM) until it breaks. Then you will know the limits for your particular hardware setup. Cheers, Dave --- Quote End --- - Altera_Forum
Honored Contributor
--- Quote Start --- Could you diagnose this problem? --- Quote End --- Go through the tutorial I wrote in the thread I pointed you to. The examples in the document are for x8 and x1, and there is a x4 PCIe in the example code. The boards are the Stratix IV GX Development kit and the Cyclone IV GX Transceiver Starter kit. There's enough detail in there for you to create a design for your specific board. Under code/pci_debug is a tool for accessing the BARs under Linux. You can use it to read/write to the on-chip RAM, and then later, when you add a DDR controller to the design, use it for accessing DDR. Cheers, Dave - Altera_Forum
Honored Contributor
--- Quote Start --- The Windows operating system is Windows XP. --- Quote End --- Could this be a 32-bit vs 64-bit issue? What is the processor you are using? Perhaps try setting BAR0 as 32-bit to see if it makes a difference. To test Linux, download a bootable CD-ROM and boot from that, or install Ubuntu via Wubi (which sticks a file onto your windows drive). Cheers, Dave - Altera_Forum
Honored Contributor
--- Quote Start --- Bar0 sill didn't appear at the WinDriver memory tab. There was nothing under WinDriver memory tab. --- Quote End --- Ignore WinDriver to start with. Use PCITree to see if the BIOS programmed the 64-bit BAR0 correctly. Who knows if your copy of WinDriver is setup to allocation 64-bit BARs? Read the documentation and see. Cheers, Dave - Altera_Forum
Honored Contributor
Dave, thank you for so many valuable suggestions.
--- Quote Start --- Ignore WinDriver to start with. Use PCITree to see if the BIOS programmed the 64-bit BAR0 correctly. Who knows if your copy of WinDriver is setup to allocation 64-bit BARs? Read the documentation and see. Cheers, Dave --- Quote End --- - Altera_Forum
Honored Contributor
--- Quote Start --- thank you for so many valuable suggestions. --- Quote End --- Hopefully one of them gives you some insight as to what is happening. Cheers, Dave - Altera_Forum
Honored Contributor
Thanks, Dave.
Then how to use Qsys to connect to large memory chip (DDR II)? If I assign large Bar size covering the whole address of DDR II, computer will not boot. What to do to make large memory chip to work with PCIe? Thank you very much! --- Quote Start --- The PCIe spec will not stop you, but your particular hardware might. My EliteBook will not boot with a BAR of 256MB. Because you did not change the BAR size by doing this. Look at the report on the Qsys GUI. Look at the synthesis report. Look at this document here: http://www.alteraforum.com/forum/showthread.php?t=35678 It has some comments. To try and isolate this problem, start with just the on-chip RAM in the BAR at a base address of zero. You can use the "Address Map" tab to re-assign the addresses. Once you can confirm that you can boot windows, you can increase the size of the BAR (the offset of the on-chip RAM) until it breaks. Then you will know the limits for your particular hardware setup. Cheers, Dave --- Quote End ---