Build is clean. UF2 Files are rejected

Long time embedded developer. New to Arduino. I am working with a Supermini nRF52840. The toolchain for the Adafruit nRF52840 Sense works well and uploads my code in the IDE to the Supermini board. But using the same board with the Supermini BSP, it switches to a UF2 type upload where I think I am supported to drag and drop the compiled UF2 file into the USB drive for the Supermini board (nice!nano) drive. I think the nice!nano bootloader is rejecting my UF2 file. How can I tell the toolchain to use the same bootloader that the Adafruit nRF52840 Sense uses? I have mucked around in

C:\Users\j\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\1.7.0\bootloader\feather_nrf52840_sense

C:\Users\j\AppData\Local\Arduino15\packages\nRFMicro-like Boards\hardware\nrf52\1.0.2\bootloader\SuperMini_nRF52840

and boards.txt

menu.softdevice=SoftDevicemenu.debug=Debugmenu.debug_output=Debug Output

menu.softdevice=SoftDevice
menu.debug=Debug
menu.debug_output=Debug Output

----------------------------------

SuperMini nRF52840

----------------------------------

supermini.name=SuperMini nRF52840

VID/PID for bootloader

supermini.vid.0=0x1209
supermini.pid.0=0x5284
supermini.vid.1=0x1209
supermini.pid.1=0x5284
supermini.vid.2=0x1209
supermini.pid.2=0x5284
supermini.vid.3=0x1209
supermini.pid.3=0x5284

Upload

supermini.bootloader.tool=bootburn
supermini.upload.tool=nrfutil
supermini.upload.protocol=nrfutil
supermini.upload.use_1200bps_touch=true
supermini.upload.wait_for_upload_port=true
supermini.upload.native_usb=false
supermini.upload.maximum_size=815104
supermini.upload.maximum_data_size=237568

Build

supermini.build.mcu=cortex-m4
supermini.build.f_cpu=64000000
supermini.build.board=SuperMini_nRF52840
supermini.build.core=nRF5
supermini.build.variant=SuperMini_nRF52840
supermini.build.usb_manufacturer="Generic"
supermini.build.usb_product="SuperMini nRF52840"
supermini.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
supermini.build.ldscript=nrf52840_s140_v7.ld
supermini.build.vid=0x1209
supermini.build.pid=0x5285
supermini.build.bootloader_version=1.0.0
supermini.build.uf2_family=0xADA52840

SoftDevice Menu

supermini.menu.softdevice.s140v6=S140 7.3.0
supermini.menu.softdevice.s140v6.build.sd_name=s140
supermini.menu.softdevice.s140v6.build.sd_version=7.3.0
supermini.menu.softdevice.s140v6.build.sd_fwid=0x0123

Debug Menu

supermini.menu.debug.l0=Level 0 (Release)
supermini.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
supermini.menu.debug.l1=Level 1 (Error Message)
supermini.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
supermini.menu.debug.l2=Level 2 (Full Debug)
supermini.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
supermini.menu.debug.l3=Level 3 (Segger SystemView)
supermini.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
supermini.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1

----------------------------------

nice!nano v2

----------------------------------

nicenanov2.name=nice!nano v2

VID/PID for bootloader

nicenanov2.vid.0=0x239A
nicenanov2.pid.0=0x00B3
nicenanov2.vid.1=0x239A
nicenanov2.pid.1=0x00B3
nicenanov2.vid.2=0x239A
nicenanov2.pid.2=0x00B3
nicenanov2.vid.3=0x239A
nicenanov2.pid.3=0x00B3

Upload

nicenanov2.bootloader.tool=bootburn
nicenanov2.upload.tool=nrfutil
nicenanov2.upload.protocol=nrfutil
nicenanov2.upload.use_1200bps_touch=true
nicenanov2.upload.wait_for_upload_port=true
nicenanov2.upload.maximum_size=811008
nicenanov2.upload.maximum_data_size=237568

Build

nicenanov2.build.mcu=cortex-m4
nicenanov2.build.f_cpu=64000000
nicenanov2.build.board=nice_nano_v2
nicenanov2.build.core=nRF5
nicenanov2.build.variant=nice_nano
nicenanov2.build.usb_manufacturer="nice!"
nicenanov2.build.usb_product="nice!nano v2"
nicenanov2.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
nicenanov2.build.ldscript=nrf52840_s140_v7.ld
nicenanov2.build.vid=0x239A
nicenanov2.build.pid=0x00B4
nicenanov2.build.bootloader_version=0.9.2

SoftDevice Menu

nicenanov2.menu.softdevice.s140v6=S140 6.1.1
nicenanov2.menu.softdevice.s140v6.build.sd_name=s140
nicenanov2.menu.softdevice.s140v6.build.sd_version=6.1.1
nicenanov2.menu.softdevice.s140v6.build.sd_fwid=0x0123

Debug Menu

nicenanov2.menu.debug.l0=Level 0 (Release)
nicenanov2.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
nicenanov2.menu.debug.l1=Level 1 (Error Message)
nicenanov2.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
nicenanov2.menu.debug.l2=Level 2 (Full Debug)
nicenanov2.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
nicenanov2.menu.debug.l3=Level 3 (Segger SystemView)
nicenanov2.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
nicenanov2.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1

----------------------------------

nRFMicro nRF52840

----------------------------------

nrfmicro.name=nRFMicro

VID/PID for bootloader

nrfmicro.vid.0=0x1209
nrfmicro.pid.0=0x5284
nrfmicro.vid.1=0x1209
nrfmicro.pid.1=0x5284
nrfmicro.vid.2=0x1209
nrfmicro.pid.2=0x5284
nrfmicro.vid.3=0x1209
nrfmicro.pid.3=0x5284

Upload

nrfmicro.bootloader.tool=bootburn
nrfmicro.upload.tool=nrfutil
nrfmicro.upload.protocol=nrfutil
nrfmicro.upload.use_1200bps_touch=true
nrfmicro.upload.wait_for_upload_port=true
nrfmicro.upload.maximum_size=811008
nrfmicro.upload.maximum_data_size=237568

Build

nrfmicro.build.mcu=cortex-m4
nrfmicro.build.f_cpu=64000000
nrfmicro.build.board=nRFMicro
nrfmicro.build.core=nRF5
nrfmicro.build.variant=nRFMicro
nrfmicro.build.usb_manufacturer="joric"
nrfmicro.build.usb_product="nRFMicro"
nrfmicro.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
nrfmicro.build.ldscript=nrf52840_s140_v7.ld
nrfmicro.build.vid=0x1209
nrfmicro.build.pid=0x5285
nrfmicro.build.bootloader_version=5a96435

SoftDevice Menu

nrfmicro.menu.softdevice.s140v6=S140 7.3.0
nrfmicro.menu.softdevice.s140v6.build.sd_name=s140
nrfmicro.menu.softdevice.s140v6.build.sd_version=7.3.0
nrfmicro.menu.softdevice.s140v6.build.sd_fwid=0x0123

Debug Menu

nrfmicro.menu.debug.l0=Level 0 (Release)
nrfmicro.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
nrfmicro.menu.debug.l1=Level 1 (Error Message)
nrfmicro.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
nrfmicro.menu.debug.l2=Level 2 (Full Debug)
nrfmicro.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
nrfmicro.menu.debug.l3=Level 3 (Segger SystemView)
nrfmicro.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
nrfmicro.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1

Hi @centralcoast154.

Is this the platform you are referring to?:

Maybe this will be the solution:

https://github.com/pdcook/nRFMicro-Arduino-Core/issues/1#issuecomment-2977582548

:warning: Bug in boards.txt

There is a general issue in the boards.txt file:

nicenanov2.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
nicenanov2.build.ldscript=nrf52840_s140_v7.ld
nicenanov2.build.vid=0x239A<

This becomes a problem because the bootloader delivered with this repository — as well as the one from the official Adafruit_nRF52_Bootloader — is built for SoftDevice v6.1.1, but the linker script is pointing to v7. This mismatch causes incorrect memory mapping.

:white_check_mark: Quick Fix

Simply change the linker script reference from v7 to v6:

nicenanov2.build.ldscript=nrf52840_s140_v6.ld

Once that's done, everything should work as expected.

So try this:

  1. Open the file at the following path in any text editor:
    C:\Users\j\AppData\Local\Arduino15\packages\nRFMicro-like Boards\hardware\nrf52\1.0.2\
    
  2. Change the following line in the boards.txt file:
    nicenanov2.build.ldscript=nrf52840_s140_v7.ld
    
    to this:
    nicenanov2.build.ldscript=nrf52840_s140_v6.ld
    
  3. Save the file.
  4. If Arduino IDE is already running, select File > Quit from the Arduino IDE menus.
    The reason for this is Arduino IDE only recognizes changes made to the boards.txt file after a restart (or selecting Tools > Reload Board Info from the Arduino IDE 2.x menus).
  5. Start Arduino IDE.
  6. Compile and upload a sketch to the board, just as you did before when you encountered "nice!nano bootloader is rejecting my UF2 file" problem before.

Hopefully this time everything will work as expected.

Yes, I am using the pdcook/nRFMicro platform. I tried your suggestion and it did not work immediately. I will play around with it more this afternoon. Is there a way to use the same bootloader that the ADAfruit nRF52 uses? How do I tell the toolchain to use the Adafruit bootloader?

Unfortunately I don't have an answer to that question. I don't have any experience working with this board.

Hopefully the other forum helpers will be able to assist you.

Other than that, I can only suggest you study the files such as boards.txt and platform.txt in the Adafruit nRF52 boards platform. You can use the Arduino Platform Specification as a reference:

https://arduino.github.io/arduino-cli/latest/platform-specification/

Here I found working variant and board.txt files (my attempts to mahe theme where unsuccessfull)

Nice!Nano board (and compatibles) added in Adafruit 1.70 nRF52 core

build OK , flasing OK with a ‘Pro Micro nRF52840’

I gave up with PDCook’s core for IDE2