Go Down

Topic: Nano 33 BLE Arduino as ISP Programmer (Read 955 times) previous topic - next topic

jerteach

Dec 06, 2019, 07:08 am Last Edit: Dec 06, 2019, 07:11 am by jerteach
I have read here  that you need another SAMD architecture type of Arduino to use the Programmer as ISP method to update a Nano 33 BLE bootloader. I am interrested in this approach. Has anyone had any success?

The DAP github is here https://github.com/adafruit/Adafruit_DAP and the direct DAP download link is here

Which installed from the library manager --> add zip, but does not seem to add any examples for me.

Can someone walk me through the process. I am familiar with using Arduino as ISP, just not with the Nano 33 BLE.

First of all, I am not sure of the connections. Do you just connect them both up using SWD? (the 5 spots on the back of each board?) or does the programmer as ISP Nano need certain pins connected?

Anyone with 2 Nano 33 BLE's brave enough to test it out?






pert

I have read here  that you need another SAMD architecture type of Arduino to use the Programmer as ISP method to update a Nano 33 BLE bootloader.
Hi. You misunderstood what I said there. It's not a matter of needing a SAMD architecture microcontroller to program a SAMD microcontroller target with the Arduino as ISP programmer. What I meant is that the Arduino as ISP programmer is an AVR-specific programmer. In fact, you can use a SAMD board (or any other architecture) as an Arduino as ISP programmer to program an AVR target. What you can't do is program a non-AVR microcontroller target with the Arduino as ISP programmer, no matter which architecture you have on the board that is being used as the Arduino as ISP.

The Adafruit DAP programmer is specifically for targets of the SAMD architecture, but you are not limited to using boards of that architecture as the programmer itself.  As it states in the readme, you can use a board of any architecture as the programmer:
Quote
Tested with a Metro M0 / Arduino Zero as the 'host' and with ATSAMD21's as the client but in theory any 3.3V Arduino board will work as host (just slower)
But there is a problem here. The Nano 33 BLE and Nano 33 BLE Sense boards are not of the SAMD architecture. These boards use the nRF52840 microcontroller. As it says in the Adafruit DAP readme:
Quote
Right now we only have commands for the ATSAMD series. We'd be really into having other people add the SWD command magic for other chips, so if you do adapt this code for your favorite Cortex, please submit a pull request!

Other ARM chips should be (easily?) supportable. Copy Adafruit_DAP_SAM to a new file and make changes to support your favorite SWD-programmable chip.
So you will need to find a programmer that is compatible with the nRF52840 microcontroller. Unfortunately I have no experience at all with programming this chip, so I can't offer any advice. Perhaps someone else here will be able to help with that.

pert

#2
Dec 07, 2019, 06:27 am Last Edit: Dec 07, 2019, 06:28 am by pert
I do have some experience with programming the SAMD boards, as I shared in the thread you linked. What I ended up doing was buying a cheap Chinese JLink clone from eBay and using Adalink:
https://github.com/adafruit/Adafruit_Adalink

I see that Adalink does claim compatibility with the nRF52840, so that same solution could work for you. I notice that in your other thread you mention you are interested in the Segger J-Link EDU Mini, which may well be a superior alternative to the clone, with really not so much higher of a price tag.

jerteach

#3
Dec 07, 2019, 06:58 am Last Edit: Dec 07, 2019, 07:55 am by jerteach
I do have some experience with programming the SAMD boards, as I shared in the thread you linked. What I ended up doing was buying a cheap Chinese JLink clone from eBay and using Adalink:
https://github.com/adafruit/Adafruit_Adalink

I see that Adalink does claim compatibility with the nRF52840, so that same solution could work for you. I notice that in your other thread you mention you are interested in the Segger J-Link EDU Mini, which may well be a superior alternative to the clone, with really not so much higher of a price tag.
So in summary, The Nano 33 IOT can be programmed with any Arduino as Programmer ISP (Careful only use 3V3 connections) using the DAP   but the Nano 33 BLE has not yet be listed with DAP Github . I can, however use your j-link method to update my Nano 33 BLE bootloader. That is very nice.

Hmmmm. Updating the DAP to the nRF52840 might be out of my ability range, however I do work hard. It looks like the Adafruit Feather nRF52 has already been added here  and finding the differences between the Nano 33 BLE and the Adafruit Feather nRF52 might be possible.

Any idea where I would find this memory address location information for the Nano 33 BLE, I assume the Nano 33 BLE Sense would be the same.



Code: [Select]
struct USER_ROW {

    uint8_t BOOTPROT : 3;
    uint8_t EEPROM : 3;
    uint8_t BOD33_Level : 6;
    uint8_t BOD33_Enable : 1;
    uint8_t BOD33_Action : 2;
    uint8_t WDT_Enable : 1;
    uint8_t WDT_Always_On : 1;
    uint8_t WDT_Period : 4;
    uint8_t WDT_Window : 4;
    uint8_t WDR_EWOFFSET : 4;
    uint8_t WDR_WEN : 1;
    uint8_t BOD33_Hysteresis : 1;
    uint16_t LOCK : 16;

    void set(uint64_t data) {
      BOOTPROT = data & 0x07;
      EEPROM = (data >> 4) & 0x07;
      BOD33_Level = (data >> 8) & 0x3F;
      BOD33_Enable = (data >> 14) & 0x01;
      BOD33_Action = (data >> 15) & 0x03;
      WDT_Enable = (data >> 25) & 0x01;
      WDT_Always_On = (data >> 26) & 0x01;
      WDT_Period = (data >> 27) & 0xF;
      WDT_Window = (data >> 31) & 0xF;
      WDR_EWOFFSET = (data >> 35) & 0xF;
      WDR_WEN = (data >> 39) & 0x01;
      BOD33_Hysteresis = (data >> 40) & 0x01;
      LOCK = (data >> 48) & 0xFFFF;
    }
    uint64_t get() {
      return ((uint64_t)LOCK << 48) | ((uint64_t)BOD33_Hysteresis << 40) |
             ((uint64_t)WDR_WEN << 39) | ((uint64_t)WDR_EWOFFSET << 35) |
             ((uint64_t)WDT_Window << 31) | ((uint64_t)WDT_Period << 27) |
             ((uint64_t)WDT_Always_On << 26) | ((uint64_t)WDT_Enable << 25) |
             ((uint64_t)BOD33_Action << 15) | ((uint64_t)BOD33_Enable << 14) |
             ((uint64_t)BOD33_Level << 8) | ((uint64_t)EEPROM << 4) |
             (uint64_t)BOOTPROT;
    }
  };
  USER_ROW _USER_ROW;
};



Looking at the Feather NRF52 Pinout diagram, the two boards look very different.

pert

It looks like the Adafruit Feather nRF52 has already been added here
Good catch! It's quite possible Adafruit added support but just forgot to update the documentation. That's a pretty common occurrence for developers. It's also possible that they started adding the support, but have not gotten it to the point where they want to claim it in the documentation.

Any idea where I would find this memory address location information for the Nano 33 BLE
Unfortunately, I don't really know much about the Nano 33 BLE boards. I do have them, but I have been out of commission due to being sick for almost the whole time I've owned them so I haven't had any chance to play. In addition to using a new microcontroller family, the core is also very different due to using Mbed so it's going to take me a while to get the level of familiarity I have with the AVR or even SAMD boards. I did get the opportunity to play with the APDS9960 sensor on the Nano 33 BLE Sense today and that was pretty cool!

I assume the Nano 33 BLE Sense would be the same.
Yeah, the only difference is it has a bunch of sensors added to the board.

Looking at the Feather NRF52 Pinout diagram, the two boards look very different.
That shouldn't be a concern for this project. You only need to know how to make the SWD connection, and the pinout is shown on the Nano BLE 33's schematic. It's the 5 test points on the bottom of the board as you guessed. You might need to solder some wires to those test points, unless you have or can easily put together a pogo pin adapter.

As for the connections on the board you're using as a programmer, you are just using Arduino pin numbers, so it doesn't matter if the pinouts are different. It's just connections to Arduino pins 9, 10, 11, GND, 3.3V. Easy enough!

Go Up