[BETA] Unable to flash OTA Photon firmware

You should have the latest bootloader on your photon, and it’s memory address range is locked, so it should be just fine. If you absolutely need the bootloader, there is another “better” way to get that re-flashed to your photon. I’m going to let @mdma chime in here and see if he recommends the RC4 combined image, or something else. You may run into a keys issue if you completely wipe your photon, and I’d like to avoid that if there’s a way around it. If you have one of the Green PCB Photons, you will likely need to wipe it, put RC4 combined binary on there and follow some more instructions. Most users won’t need that info though, so I’m just holding back so as not to confuse the masses :smile:

2 Likes

Thanks everyone, just re-flashed system_pad_BM-09.bin and the photon is now able to get OTA updates and run.

2 Likes

Hello!

I’ve flashed the latest v0.4.1 unlocker.bin to 0x8020000, but I still can’t re-flash the bootloader.
After loading, I get a green LED. I then reboot into DFU mode by holding down the user button, and try to flash the bootloadser at address 0x8000000.

All i get is: dfu-util: Page at 0x08000000 is not writeable
or Last page at 0x08003513 is not writeable

Here’s my DFU command: dfu-util -d 2b04:d006 -a 0 -s 0x8000000:leave -D bootloader.bin

Am I missing something? I’ve got one of the green PCB photons, and I’m trying to flash a bootloader built with USE_SWD=y.

Hi @mars!

To flash the bootloader, you need to use a JTAG device, such as ST-Link. It’s not possible to DFU the bootloader, since that would be overwriting the code that was already running the DFU mode!

JTAG is the most reliable way. However, if you don’t have JTAG, but do have the latest firmware, and you can get your device online, then you can OTA the bootloader using particle-cli. Like this:

particle flash myphoton bootloader.bin

1 Like

ah of course, I can use st-flash instead of dfu-util!
That works a treat, thanks @mdma!

1 Like

My build now fails at the link stage with
undefined reference to '_write', _close, _lseek, _read, _fstat and _isatty.

I can see these are defined (as stubs, I imagine) in core-v2/lib/common_GCC.a, but I don’t know how to link this in (command line).

I’m calling sprintf and scanf functions, which is probably the reason these dependencies are pulled in. Are they not supported on the photon?

Another quick question while I’m at it: is the debug build broken?

cheers, Martin

scanf uses standard input - there is no standard input on the Photon hence the linker error. You might want to use sscanf() instead.

1 Like

Right, sscanf() it is. I’m porting code from the Core.

Finally got back to this. It’s not sscanf that is causing the missing symbols, it’s #include <assert.h>. Sorry for the off-topic questions - problem solved!

I hit this the other day when using some boost libraries, which also called assert().

Having standard input and output available in the firmware would be pretty useful.

I’m thinking that in future we could have something like:

System.setOutputStream(Serial);
System.setInputStream(Serial);
System.setErrorStream(Serial1);

To have stdin read from Serial, stdout written to Serial and errors written to Serial1.

This would make integration with standard libraries even simpler on these embedded platforms.

Further ahead, some magic streams like:

System.setOutputStream(new PublishStream("eventname"));
System.setInputStream(new SubscribeStream("eventname"));

could be used to route events into stdin/stdout.

1 Like