Running a sketch without bootloader

I have a finished sketch that I would like to load and run "naked" on a Nano 33 BLE without bootlader. The purpose is to make it start faster without the delay that the bootloader always imposes while listening for a connection.

For that I bought a cheap CMSIS-DAP programmer from Alex Taradov and made the 5-pin connector for the SWD pins on the underside of the Nano.

I made sure that the whole thing worked together by burning sucessfully the bootloader using the SWD pins.

Now I want to upload my compiled sketch into the Nano, overwriting the existing bootloader. How to do it ?

did you try "Upload with programmer" in menu?

if it works it will not delete the bootloader. for that you have to create a custom variant with a different linker script putting the binary together to address 0.

https://arduino.stackexchange.com/questions/54484/adding-a-custom-board-to-the-arduino-ide/60660#60660

in my_boards I have a M0 variant without bootloader

Oops... I didn't see that option I tried it and it worked but of course the bootloader is still there.

To set up my own variant can I grab the board definition from somewhere within the arduino installation?

pjrebordao: Oops... I didn't see that option I tried it and it worked but of course the bootloader is still there.

To set up my own variant can I grab the board definition from somewhere within the arduino installation?

it is .arduino15/packages/arduino/hardware/mbed/1.1.6/variants/ARDUINO_NANO33BLE/ and .arduino15/packages/arduino/hardware/mbed/1.1.6/boards.txt

location of the arduino15 folder is the location of the preferences file you can see in Preferences dialog in IDE.

simple option is to copy the folder to other name and copy the boards settings in boars.txt for modified boards settings

but this will be lost at package update so better is to create your variant in your hardware folder in the 'my_boards' way

Me again...

Ok, I created the variant structure inside my sketch: C:\Users\pjr\Google Drive\wf_meter\wf_meter_v2\hardware\my_boards\nrf52\variants\ARDUINO_NANO33BLE

Now, I suppose I have to change the location where the sketch will be loaded ?

Is it -DMBED_APP_START inside ldflags.txt ?

pjrebordao: Me again...

Ok, I created the variant structure inside my sketch: C:\Users\pjr\Google Drive\wf_meter\wf_meter_v2\hardware\my_boards\nrf52\variants\ARDUINO_NANO33BLE

Now, I suppose I have to change the location where the sketch will be loaded ?

Is it -DMBED_APP_START inside ldflags.txt ?

the location should be the hardware folder in the sketchbook folder. the sketchbook folder is configured in Preferences.

for M0 I changed in .ld FLASH (rx) : ORIGIN = 0x00000000+0x4000, LENGTH = 0x00040000-0x4000 to FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000

so I guess you should change something in linker_script.ld

Ok and should I do something to force the usage of the hardware folder inside the sketch ?

pjrebordao: Ok and should I do something to force the usage of the hardware folder inside the sketch ?

it is not possible

So it will be used by default the next time I do an upload ?

pjrebordao: So it will be used by default the next time I do an upload ?

to apply changes in boards definitions the IDE must be restarted

Done everything. The sketch was indeed uploaded through CMSIS-DAP, but the bootloader is still there.

The board is still recognized by the IDE when I plug the USB port and the sketch still takes the same time to start.

What could be wrong ?

pjrebordao: Done everything. The sketch was indeed uploaded through CMSIS-DAP, but the bootloader is still there.

The board is still recognized by the IDE when I plug the USB port and the sketch still takes the same time to start.

What could be wrong ?

is it possible to upload over serial? the USB is there because the sketch has it

Indeed, while the port appears visible, I'm unable to upload the sketch over USB anymore. However, the sketch still takes the same time as before to start running.

pjrebordao: Indeed, while the port appears visible, I'm unable to upload the sketch over USB anymore. However, the sketch still takes the same time as before to start running.

mbed RTOS boot?

Maybe, how can I find out?

pjrebordao: Maybe, how can I find out?

I have the board but I didn't do much with it.

maybe try https://github.com/adafruit/Adafruit_nRF52_Arduino

The non-AVR boards have bootloaders that work significantly differently, and the erasure of the AVR bootloader when you "upload using programmer" is more of an unavoidable side-effect than a feature.

You probably have to explicitly erase or replace the bootloader code to get rid of it.

westfw:
You probably have to explicitly erase or replace the bootloader code to get rid of it.

Do you have any idea of how to do it in this context (Nano 33 BLE) ?

What sort of startup time do you need to achieve?
For example, there’s a ~0.5s pause while the bootloader checks for “double tap reset”, and (I guess) a longer pause waiting for traffic. One elegant solution would be to change the startup to ONLY enter the bootloader on the double-tap…

westfw: What sort of startup time do you need to achieve? For example, there's a ~0.5s pause while the bootloader checks for "double tap reset", and (I guess) a longer pause waiting for traffic. One elegant solution would be to change the startup to ONLY enter the bootloader on the double-tap...

btw the bootloader is already removed