Hi,
After spending a whole day on trying to figure out why I couldn't toggle GPIO P0.18 in nRF NCS, basic sample, e.g. blinky.
Instructions:
I added this overlay under /boards folder in the basic/blinky sample. So that P0.18 gets toggled every sec
&led0 {
status = "okay";
gpios = < &gpio0 0x12 0x1 >;
};
This denotes mapping GPIO P0.18 to the LED0.
Next I had to add this to prj.conf
CONFIG_GPIO_AS_PINRESET=n
After much debugging and searching on devzone, and looking at UICR offset 0x200 (NRF_UICR->PSELRESET) found out that:
west flash chooses to apply pin reset by default. i.e. it will overwrite UICR to be able to reset the chip via P0.18!
This is surprising because software reset is also available and I don't see why that wasn't chosen as the default behavior to avoid confusion.
The workaround I use for now is to use nrfjprog -f <family> --program build/zepher/merged.hex or zephyr.hex depending on if it's a multi image build (e.g. with MCUBoot) or not.
Ideally west flash would not overwrite UICR and just program the image as is, using software reset (just as nrfjprog -f <fam> -r does)
Another example of someone running into this issue.