Want to update Gateway Firmware - Which Branch to update and build?



I want to make some updates to the Gateway Firmware so I can connect it to other BLE Peripherals.

The READMEs from these GIT repos don’t seem right and many reference the “develop” branch as where we should work and build/make from.

I then came across this post:

Which says that the “gateway_develop” is the latest and has gateway specific stuff.

So my question is:
If I only want to update the Gateway firmware and possibly the Gateway user app (I’m not doing anything with the DKs yet), then which branch should I work from and build/make?

Also, in case I brick my Gateway during a firmware update, is there a factory reset button to revert the firmware?

And any other advise from anyone who has successfully updated the Gateway firmware will be greatly appreciated.

Thanks all,



Actually, the main develop branch is the best place for the gateway firmware. We have the main branch now building for both DK and the gateways, it is just a make line argument. You will need to do PLATFORM=bluz-gw in your make line, so something like this:

make PARTICLE_DEVELOP=1 PLATFORM=bluz-gw APP=bluz_gateway

Yes, there is a way to factory reset a gateway. Essentially, pin D6 is the “button” on the gateway, so by holding it low during a boot, and waiting 15 seconds and then taking it high, you can reset the gateway shield.


Thanks @eric.

Sorry for the noob question.

How do I hold D6 “low” and “high”? is this done in code level?



No worries. You need to do it on the hardware. So if you have a jumper wire or just a piece of copper wire stripped on both ends you can touch one end to D6 and one end to the GND pin (check out the Photon for the labels) and then hit the reset button. The LED on D7 should start to blink rapidly, just hold the wire in place for 15 seconds and then remove one end. The LED should stay solid for 10-15 seconds while it resets, then the board will reboot.

This should only be necessary if you otherwise can’t get the gateway shield to boot up, if you can still get it online and can flash code, that is best.


Also @eric :

I flashed my Gateway like this after making the develop branch
particle flash [gw id] system-part1.bin

The Gateway was in the online/scanning state (Power light is on and L2 blinks once every couple of seconds). As soon as I ran the above cmd.I get the response:

    attempting to flash firmware to your device b1xxx_deviceid
    Flash device OK:  Update started
  • Not sure if this matters by my USB is connected to the Core (online and breathing)

As soon as I flash the Gatway, the L2 goes solid white for a second it then starts blinking. It then just goes solid white and stays like that. Nothing happens.

But if I power cycle it (take out USB and put it back), it starts to work as usual. (online/scanning)

What’s happening? if my Flash failing?

I haven’t updated the code yet so cant be a code issue.



Update on the above:

I’m not sure what the LED sequence should be when I flash the Gateway using the CLI but I noticed that in the Particle dashboard Flash START/ SUCCESS / FAIL events gets thrown so using that to work out if the flash worked.

Hopefully this is good enough to determine the success of a flash.

But after my last flash (which showed up as success) the gateway seems to have gone offline and reboots are not helping. Will try again from home later.



Hi @eric

As above, I flashed the Gateway firmware (I didn’t change anything in the code, just built and flashed the develop branch)

The Particle Dashboard said it was a success.

But now the Gateway is not coming online. I boot up the Gateway/Core and the Gateway L2 just blinks. It’s not online and I cant access it or see it on the bluz console.

Here is the Serial debug of it booting up and for around 30 seconds.

It’s been t like this for over 5 mins now and still nothing, I’ve tried numerous times.

Any idea what may be wrong?

Thanks very much


Yes, I see the issue.

The gateway has more limited resources than the DK as the central stack takes more flash/RAM. The issue here is that you are running out of RAM.

When the gateway connects, it has to do RSA encryption which is very resource intensive. It calls malloc many times to do this and eats up a LOT of RAM. Since it is dynamically allocating the RAM, we can’t tell at compile time if you have used too much. So whatever new additions you added used up more RAM, and then when malloc was called, it ran short.

To recover the gateway, you should do a factory reset.

To fix the RAM issue, there is one simple thing to do. You can reduce the max number of clients from 4 to 2. You only need 2 for your application (the gateway itself and the other device), so that will free up a good chunk of RAM. You can change this here, just lower this from 3 to 1: https://github.com/bluzDK/bluzDK-firmware/blob/develop/platform/MCU/NRF51/SPARK_Firmware_Driver/inc/hw_gateway_config.h#L30

Also, ake sure you change it in the Photon code as well, change this from 4 to 2: https://github.com/bluzDK/particle-gateway-shield-code/blob/master/firmware/bluz_gateway.h#L33

That should free up over 1K of RAM. If you then flash that code back down after a factory reset, things should work again.


Thanks @eric

Will give that a go. I did a factory reset and recovered it.

But one thing I should point out is that I didn’t change anything in code , I just wanted to trial out flashing the existing firmware to get familiar with the process. So the above issue happened with existing firmware code. Although after the factory reset I flashed it again and it seems to have worked.