Request a more detailed explanation on how to flash the lighthouse bootloader

Topics related to the Lighthouse positioning system, configuration and use
Post Reply
zooeyday
Beginner
Posts: 6
Joined: Mon Aug 17, 2020 2:35 pm

Request a more detailed explanation on how to flash the lighthouse bootloader

Post by zooeyday »

My order for the Lighthouse Deck is on December 7, 2019 and the order number is #3808. I remember that this Lighthouse Deck is a relatively early version. Anyway, I followed the bitcraze github below to program Lighthouse Deck's bootloader.



The hardware configuration refers to Adafruit FT232H Breakout and lighthouse-4 deck based on the contents of Overview | Programming SPI flash with an FT232H breakout , and the final circuit configuration is as follows.
schematics.png
I confirmed that the settings and operation of the Adafruit FT232H Breakout board are normal.
And the build was successfully executed through the make command, and the bootloader_multi.bin file was created normally.
However, when executing make prog, the following error occurred and the boot loader could not be flashed.

The terminal output at this time was as follows.

$ make prog
iceprog bootloader_multi.bin
init..
cdone: high
reset..
cdone: high
flash ID: 0x00 0x00 0x00 0x00
file size: 235162
erase 64kB sector at 0x000000..
erase 64kB sector at 0x010000..
erase 64kB sector at 0x020000..
erase 64kB sector at 0x030000..
programming..
reading..
Found difference between flash and file!
ABORT.

Makefile:40: recipe for target 'prog' failed
make: *** [prog] Error 3


I tried using iceprog directly with option as follows, and the output at this time was as follows.

$ iceprog -v -d i:0x0403:0x6014 bootloader_multi.bin

….
….
....
SR1: 0x00
- SPRL: unlocked
- SPM: Byte/Page Prog Mode
- EPE: Erase/Prog success
- SPM: ~WP asserted
- SWP: All sectors unprotected
- WEL: Not write enabled
- ~RDY: Ready
prog 0x039600 +0x09A..
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 4b 9b 01 06 00
waiting..rrR
reading..
read 0x000000 +0x100..
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Found difference between flash and file!
ABORT.



I don't know what to do in this situation. I hope Bitcaze or someone can help me in this situation. I would like Bitcaze to create a simple lighthouse bootloder tutorial using an Adafruit FT232H Breakout or any FT232H device. This will help many users to use the Lighthouse bootloader more easily and proceed to the next step.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Request a more detailed explanation on how to flash the lighthouse bootloader

Post by arnaud »

Hi,

Did you solder the NM 0Ohm resistors/brigdes on the deck in order to connect the lines to the SPI memory? If not, you are not connected to the SPI memory which explains your problems.

I do not think making a tutorial about flashing the bootloader is needed since this is a very advanced topic and it is not needed to use the deck.

This leads me to the question: why are you trying to flash the bootloader? The bootloader is flashed from factory and allows you direct access to the SPI flash from the serial port. You can even use the bootloader to reflash a new bootloader by unlocking the flash (you would need to be very careful doing that though, if you flash a non-functional bootloader in the first slot, you will need the FTDI breakout to recover the board).
zooeyday
Beginner
Posts: 6
Joined: Mon Aug 17, 2020 2:35 pm

Re: Request a more detailed explanation on how to flash the lighthouse bootloader

Post by zooeyday »

arnaud wrote: Tue Aug 18, 2020 9:40 am Did you solder the NM 0Ohm resistors/brigdes on the deck in order to connect the lines to the SPI memory?
I tried configuring the circuit and flashing according to your advice, but got the same phenomenon.
First I tried to force the creset_b pin to GND before doing'make prog' to keep the FPGA in reset state while flashing,
but my poor soldering skills broke the R10 resistor and solder pad.
So, I am not sure if the reason for failing the flash is because the NM 0Ohm resistor is not connected or
the creset_b pin cannot be connected to GND.

The Lighthouse deck seems to assemble a factory-programmed flash,
but once you flash the bootloader of the completed Lighthouse deck, you'll see what the problem is.

Anyway, I think I will have to buy a new lighthouse deck.
In the future, it would be nice to add a reset switch to the lighthouse deck as shown in the figure below.
creset_b.png
creset_b.png (10.95 KiB) Viewed 3036 times
why are you trying to flash the bootloader?
I am approaching from the standpoint of studying FPGAs.
I think Bitcraze's Lighithouse Deck is a very good study material in that sense.
So, I am following the FPGA design method using ice40 UP chip and open source toolchain as a step by step.
As you said, Crazyflie users will not need to know the bootloader in detail.
However, from the standpoint of learning like me, I think it's something to be done at least once.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Request a more detailed explanation on how to flash the lighthouse bootloader

Post by arnaud »

So, I am not sure if the reason for failing the flash is because the NM 0Ohm resistor is not connected or
the creset_b pin cannot be connected to GND.
I am not sure if I understand you well. Did you solder the 0Ohm resistor or not? You must have them soldered if you want the flashing to work at all.

There is no need to solder anything on the top of the board to enable flashing, just soldering the 0Ohm resistors and connecting the programmer to the normal deck IO (using pins, not soldering on the board) should be enough. This is how I have been working on the board until I had the bootloader in place. FYI I attach the schematic of the circuit I have been using during development to work on the board, it had the same form-factor and connector as the deck and was connected using pins to a deck with 0Ohm resistors soldered.
I am approaching from the standpoint of studying FPGAs.
You can still use the full open-source toolchain without making your own SPI programmer: one way to see the deck is of an FPGA board with integrated programmer, very much like the TinyFPGA board. I understand the motive of learning but in that case you are already very close to the usability of a dev-board without flashing the bootloader since you already have full access to the SPI flash through it.

In that sense, connecting an external SPI programmer should be a pretty niche use-case. the only use case I can think about is to develop on the bootloader (but even that could be done on slot1 of the multiboot) or enabling the multiboot Slot2 and 3.
Attachments
lighthouse-usb-adapter.pdf
(69.57 KiB) Downloaded 147 times
zooeyday
Beginner
Posts: 6
Joined: Mon Aug 17, 2020 2:35 pm

Re: Request a more detailed explanation on how to flash the lighthouse bootloader

Post by zooeyday »

HI. arnaud
I am not sure if I understand you well. Did you solder the 0Ohm resistor or not? You must have them soldered if you want the flashing to work at all.
With your kind explanation, I understood and I discovered my carelessness. :oops: :oops:
Now I know where the NM 0Ohm resistor is and what it is and confirm that its solder pad is located on the back of the board.
In the past I didn't understand what you were saying correctly, so I connected a 0Ohm resistor between the P2 IO pin and the FT232H IO pin on the outside beck. Another mistake is that I did not connect the RESET (creset_b) pin to the FT232H IO as shown in the circuit diagram I originally attached.

I agree with your technical point of view. I'm just getting started, so I don't have a chance to understand unless I try to get it.
I think that understanding any method and structure correctly will be an opportunity to lead new developments.
Also, with a conversation like this between you and me, I feel that I am learning many things from you.


I'll try to fix it with a jumper cable on the ICE40 UP pin,
but I'll order a new board because the R10 resistor and its solder pads are permanently broken.

Thank you very much. :D
zooeyday
Beginner
Posts: 6
Joined: Mon Aug 17, 2020 2:35 pm

Re: Request a more detailed explanation on how to flash the lighthouse bootloader

Post by zooeyday »

HI. arnaud

After doing something else for a while, I now have a chance to test.
I tried to flash by making an interface board by referring to the circuit you attached.


$ make prog
iceprog bootloader_multi.bin
init..
cdone: high
reset..
cdone: high
flash ID: 0xEF 0x40 0x14 0x00
file size: 235162
erase 64kB sector at 0x000000..
erase 64kB sector at 0x010000..
erase 64kB sector at 0x020000..
erase 64kB sector at 0x030000..
programming..
reading..
Found difference between flash and file!
ABORT.
Makefile:40: recipe for target 'prog' failed
make: *** [prog] Error 3


I have checked the circuit and pin map several times and there seems to be no problem with it.
Looking at the flash ID, reading and writing flash seems to be normal.

Arnaud, if you help me one more time, I'll be happy.
Thanks in advance.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Request a more detailed explanation on how to flash the lighthouse bootloader

Post by arnaud »

One good reason I can think about is that the beginning of the flash is write-protected by default in the lighthouse deck, this is to avoid accidentally erase the bootloader.

Write protection can be disabled with the "-p" flag of iceprog, in your case you can try to flash with the command:

Code: Select all

iceprog -p bootloader_multi.bin
zooeyday
Beginner
Posts: 6
Joined: Mon Aug 17, 2020 2:35 pm

Re: Request a more detailed explanation on how to flash the lighthouse bootloader

Post by zooeyday »

That is correct answer for me.
I success flash with -p option.
How can I re-protect the flash like this case?
I tried to protect flash using python scripts protect_bootloader.py file in scripts polder.
But that makes a different effect on flash protection.
In this case [make prog ]command work without any problem.
I think there is an another way protection that is needed -p option like this case.

Thank you very much again.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Request a more detailed explanation on how to flash the lighthouse bootloader

Post by arnaud »

I do not know how to protect the flash with iceprog.

The protect_bootloader.py is the tool I am using to set the protection, both in factory and when working with the board. The protection is set by using the bootloader so it should be connected to the bootloader serial port.
Post Reply