SAMD21 (Zero) Chip bricked after upload

Hello,

I was trying to make my own library. But it goes wrong ^^
I am not the C++ pro. I am learning but this way was to hard.

That are my library files:

.h

#ifndef SRS_Module_h
#define SRS_Module_h

#include “Arduino.h”

struct settings_t{
settings_t();
bool debug;
bool DHCP;
int FadeTime;
int IP1;
};

extern settings_t settings;

class Configs
{
public:
void write(bool flasheeprom);
void read();
private:
bool _flasheeprom;
};

#endif

.cpp

#include <extEEPROM.h>
#include “SRS_Module.h”

extEEPROM myEEPROM(kbits_2, 1, 16, 0x50);

settings_t::settings_t()
{
debug = true;
DHCP = false;
FadeTime = 1;
IP1 = 192;
}

settings_t settings;

byte i2cStat = myEEPROM.begin(myEEPROM.twiClock100kHz);

void Configs::write(bool _flash)
{
int EEPROMnew = myEEPROM.read(255);
if (EEPROMnew != 50 || _flash == true){
myEEPROM.write(0, settings.debug);
myEEPROM.write(1, settings.DHCP);
myEEPROM.write(2, settings.FadeTime);
myEEPROM.write(3, settings.IP1);
}
}

After uploading the SAMD21 (Arduino Zero) chip was bricked. No USB was found, No erase with Atmel Studio possible.
It tooks 3 broken Chips to find out if I delete this line all is good.

byte i2cStat = myEEPROM.begin(myEEPROM.twiClock100kHz);

What make I wrong? I must start EEPROM that I can use the functions in the library. If I put this all in the mainfile withou my library all is working.

Regards
Steffen

I’d guess that EEPROM address isn’t available for user code.

Possibly the bootloader or other core parameters. This contains the USB startup you need to talk to the chip.

Just like an Arduino uno, you need to start looking at reprogramming the chip’s startup code via low-level tools - and possibly restore the reserved EEPROM space.

activate the bootloader with double reset and upload a good sketch. the port will change in the process

Juraj: activate the bootloader with double reset and upload a good sketch. the port will change in the process

Thank you, that works. That is a better way than resolder new chip after every failed upload ^^

lastchancename: I’d guess that EEPROM address isn’t available for user code.

Sorry I dont understand.

byte i2cStat = myEEPROM.begin(myEEPROM.twiClock100kHz);

This is from the example of the exteeprom library. And if this code is in the mainfile all works fine. What is the difference between the main and the library file? And is there any way that exteeprom works in the library?

Regards Steffen