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

Restoration of DFU bootloader #57

Open
jrsa opened this issue Apr 28, 2024 · 7 comments
Open

Restoration of DFU bootloader #57

jrsa opened this issue Apr 28, 2024 · 7 comments

Comments

@jrsa
Copy link

jrsa commented Apr 28, 2024

I made the regrettable mistake of overwriting the DFU bootloader by leaving out the "offset" parameter when invoking dfu-util and I am trying to restore it via JTAG with an FT2232H breakout board, and the ecpprog tool. I have the 25F variant, revision 0.2.1.

I tried flashing the bootloader bitstream from here and get the following output:

ecpprog -I B  foboot-v3.0-orangecrab-r0.2-25F.bit  -a
init..
IDCODE: 0x41111043 (LFE5U-25)
ECP5 Status Register: 0x00200100
reset..
flash ID: 0xEF 0x40 0x18
file size: 266307
erase 64kB sector at 0x000000..
erase 64kB sector at 0x010000..
erase 64kB sector at 0x020000..
erase 64kB sector at 0x030000..
erase 64kB sector at 0x040000..
programming..  266307/266307
verify..       266307/266307  VERIFY OK
rebooting ECP5...
Bye.

That seems... good. However after the device resets there is a red breathing pattern on the RGB LED and no DFU device shows up. I am assuming the red LED indicates an error with the bootloader. The result is the same whether I plug in the device with the button pressed or not. I am successfully able to load the blink example in this manner so I think my process for uploading a bitstream to flash is OK. My only other idea is that I am using the wrong bitstream for the hardware I have, but I don't see any on github that might be a closer match.

@jrsa
Copy link
Author

jrsa commented Apr 29, 2024

@gregdavill
Copy link
Collaborator

That should be all that's needed to load the bootloader via JTAG.

Are you holding the button when connecting USB? That's needed to "stay" in the bootloader, otherwise it tries to run the user application.

@jrsa
Copy link
Author

jrsa commented May 12, 2024

yes @gregdavill I am pressing btn0 and then inserting the USB-C. The RGB LED blinks red immediately after the cable is inserted. I looked through what I believe to be the bootloader source here to see why the red blinking occurs (I am assuming that I see the results of rgb_mode_error)
I see several calls once inside the dfu handling code, but I am assuming that is not getting reached because it never enumerates on USB. I believe USB is physically working because I am able to load and run the CDC ACM verilog example. The line I linked above is the only other rgb_mode_error which seems to indicate failing to reboot to the CPU (the LED state is set right before doing so). Is it possible the firmware is trying to reboot from flash memory, and failing, because I haven't written any firmware to flash? Not entirely sure how this is supposed to work, but I was expecting if this bitstream was loaded, that would be enough to do DFU bitstream uploading.

@CCampbell71
Copy link

@jrsa did you figure this out? I'm planning on building a board from scratch and want to ensure i can get the bootloader functioning

@jrsa
Copy link
Author

jrsa commented Dec 14, 2024

@CCampbell71 I gave up since I have other ECP5 dev boards, but I'm guessing I bricked mine somehow while trying to fix this issue (which of course originated with my mistake) Good luck with the build!

@CCampbell71
Copy link

@jrsa oh no! @gregdavill on a freshly assembled board, I should be able to flash the bootloader via JTAG? The prebuilt one in your repo?

@gregdavill
Copy link
Collaborator

It should be all that is needed. That is what's loaded onto the boards during their assembly QC. The JTAG interface is part of the FPGA and is always available to load gateware,

The bootloader project should still run and compile too, if you needed to change the behaviour around the btn0 input.

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

No branches or pull requests

3 participants