Uploading Arduino bootloader on a new micro-controller // With J-Link SEGGER, SWD for MCU SAMD21G

  Переглядів 21,344

Sayanee Basu

Sayanee Basu

День тому

#samd21g #bootloader #arduino
We will take a bare microcontroller on a custom PCB to upload the Arduino bootloader so that we can flash in an Arduino firmware. In this case, we will use the MCU, ATSAMD21G, and explore how to upload the bootloader through the SWD protocol with the J-Link SEGGER programmer. We will also learn how to create the bootloader file for a crytstalless option board and then test the entire upload with a blinky firmware. It is also important to note that there can be other methods to upload the bootloader file. I tried to use the ST-Link (on STM32 Discovery Board) with OpenOCD and J-Link Edu Mini but I was unsuccessful.
⏰ TIMESTAMPS
0:00 Intro
00:37 ATSAMD21G micro-controller
01:20 Serial Wire Debug protocol (SWD)
01:54 Pin connections - Power, ground, reset, LEDs, SWD
04:18 J-Link SEGGER Programmer
05:34 Create bootloader file
09:02 Hello World blinky firmware
11:43 Other options: ST-Link with OpenOCD and J-Link Edu Mini
‣ Some links below are affiliate. I receive a small commission at no extra cost to you.
📻 PRODUCTS MENTIONED
RobotDyn SAMD21 M0 Mini s.click.aliexpress.com/e/_AZG8aU
🎩 DEMO FILES
hutscape.com/tutorials/arduin...
🔗 LINKS SHOWN
LCSC part for SAMD21G lcsc.com/product-detail/ATMEL...
Serial Wire Debug developer.arm.com/architectur...
SAMD21 Datasheet cdn.sparkfun.com/datasheets/D...
SAMD21 Mini/Dev Breakout Hookup Guide learn.sparkfun.com/tutorials/...
SparkFun SAMD21 Breakout board schematic cdn.sparkfun.com/datasheets/D...
Arduino Zero schematic content.arduino.cc/assets/Ard...
RobotDyn M0 schematic robotdyn.com/pub/media/0G-000...
SWD vs JTAG: Similarities & Differences Explained embeddedinventor.com/swd-vs-j...
J-Link Debug probe www.segger.com/products/debug...
J-Link SEGGER Model overview www.segger.com/products/debug...
Arduino Core for SAMD21 bootloader github.com/arduino/ArduinoCor...
Pogo pin connector www.instructables.com/id/Pogo...
J-Link Edu Mini www.segger.com/products/debug...
Adafruit Adalink github.com/adafruit/Adafruit_...
OpenOCD openocd.org/about/
ST-Link www.st.com/en/development-too...
📹 PRODUCTION GEAR AND TOOLS
Davinci Resolve 16.2 for video editing
iPhone 11 for recording video
QuickTime for recording laptop screen
Microphone Audio Technica ATR2100-USB for voice recording www.amazon.com/Audio-Technica...
IKEA TERTIAL Work lamp stand hacked as a microphone stand www.ikea.com/sg/en/p/tertial-...
Tripod SLIK SDV-10iPhone holder Xiletu XJ-8 www.amazon.com/XILETU-Mobile-...
Ipevo CDVU-03IP 2 megapixel Point 2 View USB Camera www.amazon.com/Ipevo-CDVU-03I...
dotfiles for terminal configuration github.com/sayanee/dotfiles

КОМЕНТАРІ: 68
@ubidefeo
@ubidefeo 3 роки тому
Really enjoying your videos. These are the videos I wish were there before I spent days banging my head on the wall to learn this stuff :D
@ubidefeo
@ubidefeo 3 роки тому
Have you actually created a core / board definition for your custom board? We have a ton of documentation about it :)
@ubidefeo
@ubidefeo 3 роки тому
also, you should convert an ST-Link into a Black Magic Probe, because we support that programmer in the CLI via openocd here's a link about it microcontrollerelectronics.com/how-to-convert-an-stm32f103c8t6-into-a-black-magic-probe/
@sayanee
@sayanee 3 роки тому
@@ubidefeo Oh nice!! That's exactly what I need. Custom board! And thanks for some lead into using ST-Link. I have the ST-Link V2 and the STM32 Discovery Board with ST-Link. I'll try the Black Magic probe option.
@bhargavmistry1274
@bhargavmistry1274 3 роки тому
@@sayanee hi Sayanee, do we really need to Rebuild the .bin even if using default settings? Can i just use the .bin file from repo straight away? Please make video about creating custom board!!
@sayanee
@sayanee 3 роки тому
@@bhargavmistry1274 Uh! Indeed the repository does have a *.bin file github.com/arduino/ArduinoCore-samd/tree/master/bootloaders/zero. Well, upload it and see if it works for you. I always like to generate these files as I can know how they were built even if it's the default. Personal preference :) Custom board is definitely in for a future video 🙏🏼
@pjforde1978
@pjforde1978 8 місяців тому
Your videos are truly some of the best instruction available on these topics. Thank you for all of your hard work!
@suhyonkim5505
@suhyonkim5505 2 роки тому
great! most useful. I tried J-Link EDU Mini to write SAMD21 one year ago. It was successful. Though I forgot everything now.
@yellowfruit
@yellowfruit 3 роки тому
Thanks so much for posting this! Following your video I was able to bring a board back from the dead :D
@walterhynson2898
@walterhynson2898 2 роки тому
This video is fantastic ,no magic tech mumbo jumbo just how to accomplish what is needed to completed the task.
@RohitSingh-uq7hc
@RohitSingh-uq7hc 3 роки тому
Thankyou mam very much I was really struggling with bootloaders ..this helped me to sort my doubts, ..your videos are always very informative 😃😃😃
@shaunmorgan2202
@shaunmorgan2202 3 роки тому
Excellent. Very well presented and explained.
@wimdezwijger7023
@wimdezwijger7023 3 роки тому
Jlink needs to know the supplyvoltage of the Target processor to make sure the voltagelevels of SWDIO and SWDCLK will not damage the target. This is done by providing VRef FROM the Target TO the JLink programmer. So VRef is an Input pin on JLink. Connect Vref to the supplyvoltage of the target, in your case 1V6. There wont be any SWD data and controlsignals on the pins if you leave VRef open and so nothing happens: JLink cant detect the target, it cant flash the memory and it cant verify.
@pd8559
@pd8559 3 роки тому
I really love your videos, I got out of electronics back when PIC controllers were a thing and you had to imagine in your head what PWM signals looked like as no one could afford much tools or technology in general. Now I am amazed with your Logic Analyzer video and videos like this one how easy it has become for people today. Wish this was around when I was a kid I might have gone in the engineering side, for now I'll have to think of projects for myself and build my own gear to make it happen. Just picked up Arduino to teach my daughters engineering principles, circuit design and analysis, sensors, C++ and the rest and I picked up ESP32-WROOM-32D DevKitC v4 boards for daddy to play with. I cannot believe everything these chips do today. I'll have to really study the logic analyzer more in depth and learn how to get good at it. If you make any more I'm in the first row watching right away. Cheers, Liked, Subscribed.
@sayanee
@sayanee 3 роки тому
Haha, I started with a PIC micro-controller in my electrical engineering undergrad 15 years back too! www.flickr.com/photos/sweska/109635690/ I guess we are from the same era :) Totally agree that the bar for entry has been lowered today than how we got started. My daughter is too young, but thanks for the list of inspirations. When she's old enough I hope she will also get to learn this cool stuff in a more fun way than we did.
@pd8559
@pd8559 3 роки тому
@@sayanee Mine are 6 and 7. They don't knew they are learning all this advanced stuff they are just having fun doing different learning projects with dad. The bright flashing lights, noise making stuff etc that is what catches them, less so the more technical advanced aspects. If I see in losing them I move it back to the fun things that capture their attention. No material science, band gaps, electron shells and energy states or anything more or less life that just hey let's build this and then ask hey what else could we use this for in real life so they start dreaming up applications and hey girls maybe if we build this and everyone wants one we could make lots of money and be able to get lots of toys, typical wide eye excited kids let their imaginations go crazy expanding on possibilities. They may get hooked 😊 at night they say goodnight to us and the cats and then to Mr. Arduino on the way up to bed. Too cute. The culmination of simple lights and buttons and piezo is recreating the Simon game from the late 70s and 80s. Being kids they really liked that.
@sayanee
@sayanee 3 роки тому
@@pd8559 "They don't knew they are learning all this advanced stuff they are just having fun doing different learning projects with dad." #parentinggoal :) Thanks for sharing!
@davidtaylor6124
@davidtaylor6124 Рік тому
Very good info, thanks! I ended up on that same stack overflow page this morning :-\
@0miker0
@0miker0 3 роки тому
Great video! Very well done and thanks.
@samytunes
@samytunes Рік тому
Great video, thanks for sharing
@lightning_sree2531
@lightning_sree2531 3 роки тому
Thank you for this video it helped me alot
@ramonhernandezgutierrez7571
@ramonhernandezgutierrez7571 3 роки тому
Great!! I like it
@fatih_basaris
@fatih_basaris 3 роки тому
Great video. Well done and thanks a lot. I am going to test how to burn arduino bootloader to atsamd21. Best Regards..
@cacaroten
@cacaroten 2 роки тому
Great!, thanks a lot
@pexenn23
@pexenn23 Рік тому
thank you for the great content, but what should i edit for a custom PCB?
@repair2054
@repair2054 11 місяців тому
Teşekkürler
@OverClockedShow
@OverClockedShow 3 роки тому
wow very detailed , subscribe
@thorstenfricke3257
@thorstenfricke3257 Рік тому
super thank u very much, no my VTref is not 0.00V anymore!
@barunbasnet
@barunbasnet 3 роки тому
I don't know why these chip manufacturers don't sell chips with built-in bootloader. Its so much headache sometimes especially if you are building your custom pcb with those MCU chips. However, STM32 chips come with builtin bootloader, don't they? Also, I never knew how the MCU would function without an external oscillator. I would just read in the datasheet that it has an internal oscillator but never knew how to use it. Thankyou.
@2208avig
@2208avig 2 роки тому
Appreciate yours clear presentation very much. I would like to ask if it possible to flashing the SAMD21G18 bootloader using the J-Link EDU as well (I'm not experienced with boot loading) .
@sayanee
@sayanee 2 роки тому
Yes!! And I just tried with the J-Link Edu Mini on my current project: hutscape.com/oak/examples/bootloader I have to admit that bootloading is difficult for me as well :( Somehow it worked after I left Vtref unconnected on the SWD pin 🤷🏻‍♀
@2208avig
@2208avig 2 роки тому
@@sayanee Thank you very much. I'll follow your guidlines . Appreciated.
@kobyfr
@kobyfr Рік тому
Is it enough to use swdio, swdclk, gnd, vdd leaving the reset unconnected? Will the jlink be able to program the samd21 in that case?
@razorr1920
@razorr1920 3 місяці тому
Level Shifter for edulite??
@muhammadalishah873
@muhammadalishah873 8 місяців тому
Hello lady how to readback bootloader with jlink segger
@shashankhegde1064
@shashankhegde1064 Рік тому
Hi, I have recently got a custom PCB designed with the STM32 blue pill core (STM32F103C8T6). I know it's possible to install Arduino IDE with the blue pill board, but how to install it with a custom PCB? What hardware would I need. Is having a ST link v2 enough? My custom PCB has a USB and SWD pins set aside, along with Reset. Any links also would be appreciated.
@bhargavmistry1274
@bhargavmistry1274 2 роки тому
Great video! How do you change VID, PID and board name to your custom one?
@sayanee
@sayanee 2 роки тому
8:58 I don't think you can the VID and PID. For example, if you search for "2341" on this list here www.linux-usb.org/usb.ids, it will point to Arduino SA. For the board name, you can change it in one of the source files here in Step 4 and 5: hutscape.com/pine/examples/arduino-bootloader-samd21g#create-the-bootloader-file Hope that helps!
@olivierwartique2655
@olivierwartique2655 3 роки тому
Nice video ! I am currently designing a custom board based on SAMD21 and I'd like to flash in the bootloader of the Arduino Zero. But does that mean I need to have exactly the same pinout as the Arduino Zero ? Thanks for your help !
@sayanee
@sayanee 3 роки тому
If you want to only find out what pins are required for flashing the bootloader, then only 01:54 power, ground, reset, LEDs, SWD pins are required. Arduino Zero or other dev boards have many other pinouts based on other features they might have on board. You need to extract out the ones you require. Do a cross-check with other open schematics with SAMD21 dev boards as I show in 01:54 as well.
@AlifSayAwais
@AlifSayAwais 9 місяців тому
Hello, I see this error whenever i try to connect ERROR: Failed to connect. Could not establish a connection to target. - ERROR: Connect failed
@antonilopezgimenez8545
@antonilopezgimenez8545 3 роки тому
Hi mate! Thanks for the video and information. I'm developing a own Arduino board based on ATSAMD21E18 and I want to know what is the equivalent command on windows of your "make" command.
@sayanee
@sayanee 3 роки тому
The details of my simple "make" command can be taken from the Makefile for a simple blinky for samd21g: github.com/hutscape/hutscape.github.io/blob/master/_tutorials/blinky-samd21g/Makefile It consists of "make lint" with cpplint, which you might want to omit if you are not already using cpplint for your other C/C++ projects. For windows, I think you can use the Python pip to install: pypi.org/project/cpplint/ The command "make all" and "make flash" consist of arduino-cli. You can download the Windows version of arduino-cli here: arduino.github.io/arduino-cli/latest/installation/#download. The command "make clean" is simply removing the build folder. I have no chance to use it on the Windows, but I hope this gives you some clue!
@muhammadalishah873
@muhammadalishah873 8 місяців тому
Hello lady pls make video on mm32spin27pf how to flash
@nafismustakim8860
@nafismustakim8860 3 роки тому
Hi great video! But why was the "D-crystalless" part added in the code. Can you elaborate a bit?
@sayanee
@sayanee 3 роки тому
Uh, that's because my circuit does not include a crystal and I don't need it for my functionality. If you need the crystal, please include it and remove the crystalless option. Check 16.6.2 External Multipurpose Crystal Oscillator (XOSC) Operation of the datasheet for more information: cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Atmel-42181-SAM-D21_Datasheet.pdf
@justdoingodswork
@justdoingodswork Рік тому
Thanks again, your videos are really helpful. I'm moving from Arduino IDE to nRF Connect VS Code, so I found that I need this J-Link programmer for it. But one thing wasn't clear to me is does this J-link is enough to program Adafruit Bluefruit nRF52832 module directly or do I need nRF SDK also?
@sayanee
@sayanee Рік тому
I have never done that, sorry! Flashing the bootloader can be so frustrating for each type of microcontroller and platform. Could you try posting your question on the Nordic Semiconductor forums? This is what I would also do: devzone.nordicsemi.com/ I hope you figure it out!
@justdoingodswork
@justdoingodswork Рік тому
@@sayanee Got it, they said it does works directly. Need to solder SWD Connector on the module and use J-Link Programmer directly.
@orbita1
@orbita1 3 роки тому
Might be a silly question, but regarding the target voltage, why don't you just power the board externally shorting the grounds so the edu mini see's 3.3v?
@sayanee
@sayanee 2 роки тому
I vaguely remember that I did try this, but no success 😑 I'm going to try again soon for my next project! And this time both the PCB as well as the SWD are of 3.3V. So hopefully, one less barrier.
@scharkalvin
@scharkalvin 2 роки тому
I have the less expensive jlink-edu mini (
@sayanee
@sayanee 2 роки тому
Yes!!! I tried the J-Link Edu Mini for my current PCB too :)
@shashankhegde1064
@shashankhegde1064 Рік тому
Can we run Arduino IDE and program codes(.ino files) as usual on the custom board as we would with an Arduino board by doing this?
@sayanee
@sayanee Рік тому
Yep! Absolutely. I have done it a few times and wrote own the steps: hutscape.com/oak/code/custom-arduino
@shashankhegde1064
@shashankhegde1064 Рік тому
@@sayanee thank you. Please let me know if you plan on making a video regarding the same
@freezedream
@freezedream 3 роки тому
Unfortunately you published your video after I also already bought a J-Link EDU Mini! No success in programming my ATSAMD21E18A with it yet - and I'm running at 3.3V. Not sure what's going on! The micro doesn't seem to boot properly so I'm guessing it may be something to do with the BOOTPROT fuse bits? You didn' mention fuse bits in your video, though.
@wimdezwijger7023
@wimdezwijger7023 3 роки тому
Make sure to connect VRef to target supplyvoltage of 3v3
@domojega
@domojega 3 роки тому
@@wimdezwijger7023 well, I am using the J-link, Atmel studio and the Seeeduino Xiao bootloader. everything seems OK, the file Is uploaded and the upload Is verified but the custom made assembly does not boot as the original Xiao starts... No LEDs are blinking, nor the Xiao is visible for the Arduino IDE. No COM ports are visible... All lines are connected, including the reset and 3V3 (to Vref). *** Just to reply to myself... I did it with the same setup. The issue was in missing the GND... I succeeded to upload bootloader with j-link edu.
@HersonBagay
@HersonBagay 3 роки тому
Tried the ST-link OCD/GDB route myself and it refuses to upload anything on the board. Don't waste time trying. I end up getting me a Jlink mini like yours. Debugging with it is so much easier than using "printf" to the serial console.
@sayanee
@sayanee 3 роки тому
Oh nice! Thanks for sharing. Which mcu did you try with ST-Link?
@HersonBagay
@HersonBagay 3 роки тому
Same SAMD21G like yours but a DEV board I got from Seeedstudio (www.seeedstudio.com/Wio-Lite-W600-p-4155.html). I tried to use the built-in ST-link debugger from an old STM32Discovery board I have.
@vasiliynkudryavtsev
@vasiliynkudryavtsev 3 роки тому
2:06 I really taught my screen was dirty.
@sayanee
@sayanee 3 роки тому
Haha!! I guess it's the video rendering upon export. It's so faded that I couldn't notice it at first.
@Kushangaable
@Kushangaable 5 місяців тому
This segger J-Link, the _black box_ is fake. 5:24
@hrz70
@hrz70 Рік тому
Great to see, bautiful woman inrterested of electronics, very rare :)
@cmontoya30
@cmontoya30 3 роки тому
You should use a Windows computer and your videos will get more traction.
@tristunalekzander5608
@tristunalekzander5608 3 роки тому
Ya what even is a Mac?
The Raspberry Pi Pico WAS Overrated! But that changed!
10:18
GreatScott!
Переглядів 580 тис.
skibidi toilet 73 (part 2)
04:15
DaFuq!?Boom!
Переглядів 6 млн
7 Best JTAG Emulators 2019
3:40
Ezvid Wiki
Переглядів 8 тис.
Whaaat?? How To Extract HEX Code from Arduino
12:36
Electronoobs
Переглядів 52 тис.
Extracting Firmware from Embedded Devices (SPI NOR Flash) ⚡
18:41
Flashback Team
Переглядів 482 тис.
XIAO ESP32S3 Sense - Tiny ESP32 Camera
45:28
DroneBot Workshop
Переглядів 65 тис.
Intro to Hardware Reversing: Finding a UART and getting a shell
12:07
Tony Gambacorta
Переглядів 869 тис.
Extracting and Modifying Firmware with JTAG
21:03
Matt Brown
Переглядів 28 тис.
ARM Processor - Sowing the Seeds of Success - Computerphile
13:20
Computerphile
Переглядів 273 тис.
iPhone - телефон для нищебродов?!
0:53
ÉЖИ АКСЁНОВ
Переглядів 3,5 млн
Как должен стоять ПК?
1:00
CompShop Shorts
Переглядів 621 тис.
МОЙ ПЕРВЫЙ ТЕЛЕФОН - Sony Erricson T280i
18:02
ЗЕ МАККЕРС
Переглядів 65 тис.
I KNEW I’d Hate this (I Was Wrong)
12:19
Linus Tech Tips
Переглядів 617 тис.