0

I would like to make my own version of the Arduino Due.

What I can't find the answer to is; Can I program a blank SAM3X8E using the native USB port from within the Arduino IDE, or do I first need to program some bootloader or similar?

My board will not have the Mega16U2 which is normally used for programming.

2
  • Regardless of the answer to that question, it would be extremely unwise to design an ARM Cortex-M series board which did not make the SWD pins available at least on tiny test pads; they are just too useful during early development, and key to hardware-assisted breakpoint debugging (especially if your board ever gets used for non-Arduino purposes). About 4 via-sized through holes will let you pick them up with wire wrap wire or similar. Mar 25, 2018 at 20:34
  • I have decided to go down the SAMD21 path and have put a SWD header on my board. I use my Segger to put the Arduino boot loader into the chip and I am good to go.
    – gjt211
    May 2, 2018 at 10:44

2 Answers 2

1

The SAM3X8E comes with a bootloader in ROM.

  • Memories
    • 256 to 512 Kbytes embedded Flash, 128-bit wide access, memory accelerator, dual bank
    • 32 to 100 Kbytes embedded SRAM with dual banks
    • 16 Kbytes ROM with embedded bootloader routines (UART, USB) and IAP routines
    • Static Memory Controller (SMC): SRAM, NOR, NAND support. NFC with 4 Kbyte RAM buffer and ECC

Since this bootloader does all that the Arduino IDE asks of it, and has a freely available cross-platform command-line upload tool (bossac) the IDE just uses that. No need to invent the wheel when the wheel does everything you need and even comes with a tin of axel grease.

While technically it is possible to use your own bootloader in conjunction with the existing one (use the existing one to install yours, and then use yours to upload sketches) it requires in-depth knowledge of both the chip and GCC linker ("ld") scripts to set aside a block of memory for your bootloader to reside in and relocate the compiled code around it properly. Too much work when the bootloader that already exists does what you want.

However other chips either don't have a bootloader (like the M0 in the Feather) or don't have one that works as desired (like the DFU bootloader in the ATMega32U4) so a custom bootloader is used on those.

The IDE itself is pretty dumb. It just has a configuration file that says "Execute this command with these parameters to upload the HEX file". It neither knows, nor cares, what the bootloader at the other end of the connection is, nor how it works. As long as there is a command-line executable to do the work it just hands over to it.

8
  • Hi @Majenko, I am not sure if that fully answers the question. Is that boot loader compatible with Arduino IDE?
    – gjt211
    May 2, 2018 at 10:47
  • @gjt211 That is the "bossac" bootloader that the Due uses. The question "is it compatible with the IDE" makes no sense. The IDE has no concept of bootloaders, only configuration files that specify executables to run to install the compiled file into the target. If there is a binary you can execute to interface with a bootloader you can make the IDE run that executable. Regardless: it's what the Due uses, so "yes".
    – Majenko
    May 2, 2018 at 10:48
  • Maybe it makes no sense to you, but for the thousands (millions) of Arduino users that have very little experience, the question makes a lot of sense. To those users (me included) who have no idea what bossac is, or config files that specify executables, let alone where they are or how to obtain them, where to put it if we worked all that out. All we know, select the serial port, then click upload.
    – gjt211
    May 3, 2018 at 11:28
  • @gjt211 It's expected that if you are technically adept enough to consider building your own SAMD based board that at least you understand the basics of the datasheet. Without that basic level of knowledge what are you doing even considering building something as non-trivial as a DUE-based system? ARM is considerably more complex than little AVR chips. You can't just slap one in a breadboard and expect it to work.
    – Majenko
    May 3, 2018 at 11:32
  • 1
    Most users that come here have a certain amount of Arduino knowledge but almost zero electronics knowledge. You're kind of the opposite end of the scale, so please forgive the confusion.
    – Majenko
    May 3, 2018 at 11:45
-1

Microchips needs some kind of bootloader to be able programmed over USB. Arduino boards cames with default bootloader loaded (from Arduino company at least, net necesarry from Chine, probably without, if you byu just the chip from manufacturer), so on official boards it is all done for you to have aesy life.

Being able to properly communicate over USB is not exactly easy task and there are many different protocols for sending program to bootloader, which is then resposible to put the program at flash memory at proper place and give it controll later.

Also keep in mind, that there are other ways, how to put program in memory and that not all devices using some microcontroler are even meant to be programable by user over it. (For example they may idetyfy themself as keybords, mouses, joysticks and such to computer and be closed to reprogramming by manufactor of such device. Arduino community is only small part of industry, which uses the same chips for totally different tasks).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.