MKRGSM (and MKRNB) charging parameters


I cannot find any clear documentation on how the BQ24195L chiup is configured.

As I understand, the bootloader configures the chip when powered on.
Is there any bootloader source code or documentation somewhere?

What is the constant current setup for MKRNB and MKRGSM board?
I saw in the doc that MKRNB has a preset charging current of 350mAh, which I'm not even sure of.

I don't have way to measure currently, but it seems that charging current of the NB is much higher than GSM one (using same LiPo, NB charges much faster, and also power supply warms up a lot more).

In addition, charging time is limited to 4 hours per cycle, on both board. I use a larger LiPo, and I have to force several cycles to get it full.
Project implies having the board at an unattended location, and have the LiPo for current bursts buffer, but also as backup in case external power supply fails.
If the LiPo is never charged to its full capacity, backup time is reduced, which is annoying.

Is there a way to change this charging time limitation?

Note: external power supply is on the USB port.


Some of the subfolders of the bootloaders folder do contain source code. Others don't. I suspect that the ones without source are sharing the same source code provided for another board. I don't know which is which or even if the charge configuration is done by the bootloader, but maybe it will help you a little:

Thank you Pert,

Your are correct, it's all in there.
After a brief look, PMIC parameters seem to be common to all boards havin a PMIC.
However bootloaders on my different boards may have a different release, which could explain differences.

Now the question which I cannot find an answer to: how to burn the bootloader on MKRNB and MKRGSM?
I found some pages like that one showing that pads below the board may do the job with Atmel-ICE.

Is anybody aware of an easier/cheaper solution?

I have been on a quest to find the cheapest programmer for these chips for a little while now.

I started by using an Arduino board as a programmer following these instructions:

No luck for me, but another forum member reports it did work for them (possibly after some modification to Adafruit's sketch):

I then tried using one of the ST-Link V2 clones sold on eBay and Adalink:

No luck. I had read some reports that it wouldn't work, despite Adafruit's claims that it does:

I'm now waiting for a J-Link clone I bought from Aliexpress and will give that a try with Adalink.

It seems like after the J-Link, things are getting much more expensive. I'd be interested to hear of other options in case the J-Link doesn't work for me. I can afford to pay more, but I'd like to find the cheapest reliable solution because I think that would be helpful information to be able to share with users who managed to erase the bootloader on their Arduino board and are just looking for a fix, and then maybe never use the programmer again.


Yeah, I did see all the links you provided prior to my post.

Let's wait for your J-Link clone to see how it goes.

I'm tempted by the Atmel-ICE... Really... But that is probably not the cheapest solution.
But probably the safer?

Concerning the original J-Link from Segger, did you look at the EDU prices?
Can get one for around $60 here in Switzerland, with these terms.



The J-Link clone showed up today and I'm very happy to report that it worked!

The connections:

J-Link | MKR board

IVCC | SWD header pin 1 (3V3)
GND | SWD header pin 5 (GND)
SWDCLK | SWD header pin 4 (SWCLK)
SWDIO | SWD header pin 2 (SWDIO)

The SWD header is the 2x3 SMD pads on the bottom of the MKR board. I used a homemade version of one of these to make the temporary connections to those pads:

Note that the J-Link does not power the target. I'm not sure what IVCC does. You need to power your MKR board separately (e.g., plug in the USB cable) while programming it with the J-Link.

This is the J-Link I used:

They are a bit cheaper on Aliexpress, but the one I ordered there never showed up, delaying me by 2 months. The one I ordered on eBay showed up from China after only 5 days. I have had problems so much more often with my orders on Aliexpress than my orders for similar items from the Chinese sellers on eBay that I've resolved to avoid shopping on Aliexpress as much as possible from now on.

I used it with Adalink:

The command I used (for MKR Zero, but can easily be adapted to any MKR board):

adalink atsamd21g18 --programmer jlink --wipe --program-hex ~/.arduino15/packages/arduino/hardware/samd/1.8.3/bootloaders/mkrzero/samd21_sam_ba_arduino_mkrzero.hex

Concerning the original J-Link from Segger, did you look at the EDU prices?
Can get one for around $60 here in Switzerland, with these terms.

I'm sure $60 is a great price for that device, but my goal was to find a solution that would work for average Arduino users to rescue their SAMD boards after somehow managing to corrupt the bootloader. For this usage, I think $60 would not be an attractive price, since they are not going to be using the device regularly and could buy a new Arduino board (if not several) for the same amount of money. However, I did just see the Segger J-Link Mini, which sells for $18:
I think the next clone solution up from the style of J-Link clone I bought is around $10. At that point, I would definitely just go ahead and spend another $8 to get the real thing. However, I think my sub-$5 solution hits a nice price point for my specific intended usage.


Thank you for your messages,

I was about to buy one of these J-Link clones, or eventually genuine ones, when I decided to give a try with this dodji setup in attachment, and guess what: that worked!

I used this library which I got from Arduino IDE Library Manager, with this example, and these following pin assignements:

#define SD_CS 4
#define SWDIO 1
#define SWCLK 0
#define SWRST 2

The programming board is an MKRFOX I had under the hand, but it can probably be any MKR board. Or maybe even an Uno, Leonardo, etc? To test, I don’t see any reason why it would not work… Having a Sd card reader available of course.

I used the MKRENV shield to get access to an SD card reader, and it all went well on the first try!

I'm glad to hear the Adafruit DAP library worked for you. I think that is the ideal solution. Unfortunately, I simply could not get it to work for me, despite spending hours on it before giving up. I was also trying the flash from SD card thing. The annoying thing was it would sit there apparently writing for like 5 minutes before failing so it was a very slow and tedious process. Most especially so because I have a pogo pin programming adapter that I have to press in place on the MKR board programming header pads just right without moving my hand at all the whole time. Approximately how long did the programming process take for you?

Hi Pert,

Well it was very quick, 2 or 3 seconds max to program, unless something is going wrong which I don't notice.
Communication seems to be ok as it detects the chip type, and says it is uploaded successfully.
And the bootloader is pretty small.

Maybe give another try? Some updates may have been brought to the library?

See below the serial output:

17:55:59.837 -> Card initialized
17:55:59.837 -> Connecting...Adafruit Generic CMSIS-DAP Adapter 123456 v0.1 (S)
17:55:59.837 ->
Found Target: SAM D21G18A (Rev D) Flash size: 262144 Flash pages: 4096
17:55:59.977 -> done.
17:55:59.977 -> Erasing... done.
17:56:00.118 -> Programming... 77
17:56:00.335 ->
17:56:00.335 -> Done!

As you made a lot of reasearch on the subject, didn't you find some code to emulate J-Link on a SAMD or eventually an 8 bit proc like Uno or Leonardo?
Thinking about some code like the Arduina as ISP one, but to emulate a J-Link, or any adalink JTAG/SWD compatible programmer...
That would be more convenient than dealing with an SD...

Well it was very quick, 2 or 3 seconds max to program

Thanks! That's very useful information because I know that if the process hasn't finished after 10 seconds or so that something has gone irrecoverably wrong and I can stop waiting on it. Adafruit_DAP takes several minutes at least before it fails the process.

Maybe give another try?

I should do that when I get some free time. Juraj also reported that they got it working, but also that they had to make some modifications to the sketch which they couldn't recall. Now I have the information from you that it worked with no modifications so that gives me more hope that it is possible.

Some updates may have been brought to the library?

The only change to the library since I tried it was a library metadata update that has no functional effect.

As you made a lot of reasearch on the subject, didn't you find some code to emulate J-Link on a SAMD or eventually an 8 bit proc like Uno or Leonardo?

No, I didn't. However, I must say that I'm really out of my depth when it comes to this SAMD stuff. I've been working with AVR for the last 7 years and know quite a bit about all the common options for AVR ISP programmers but I only recently started working with the SAMD boards and then only as needed to provide support here on the forum and some occasional beta testing for Arduino. I've never actually used a SAMD board in one of my personal projects because I never had an application where an AVR wasn't perfectly sufficient. I am learning more and more about SAMD gradually over time, but it's a slow process.

Update on Adafruit_DAP: a few weeks ago I "bricked" one of my MKR boards and thought I'd give Adafruit_DAP another try. I noticed there had been some changes since the last time I tried it. Unlike before, the bootloader appeared to be flashed successfully, but afterward the board was still bricked. So I went back to my trusty J-Link.

I have been having problems the last couple of days with some of my SD cards lately and did an investigation. Turns out I have some of the fake SD cards that misreport their capacity. I thought I'd give Adafruit_DAP another try with one of the fixed cards, and success!

So I think the problem with the successful flash resulting in a bricked board was caused by the bootloader file being corrupted by the bad card. I'm not sure whether the original problem I had of the flashing process failing was caused by a bad card. Anyway, I'm happy to have it working now! The process of getting the adalink system installed and working is really not much fun, so it's great to have a more user friendly option available that works with hardware we already have on hand.


instead of burning bootloader, I am simply programming the chip at setup(). I used library available at:



instead of burning bootloader, I am simply programming the chip at setup(). I used library available at:

GitHub - arduino-libraries/Arduino_BQ24195: [Beta] Arduino library to control TI BQ24195 PMIC on compatible MKR boards


Hi PCJohn,
I downloaded and installed the library you suggested, but I obtain the following error during compiling:

error: 'PMIC_IRQ_PIN' was not declared in this scope

Do you have any suggestions?