2
\$\begingroup\$

I did buy one of these cheap all in one microcontroller, but instead of using a standard Atmel, like the ones on the Arduino boards, it uses a more powerful ARM M0 chip.

Now, I would like to buy my own M0 (picking a SAMD21G18) and make my own board, exposing only the pin that I need, but I can't find info about a critical piece of info: How do you program the chip?

The board that I did purchase, has a USB to serial chip, I believe; and it has a rom with a bootloader, so when it is in a state, you can put code on it, while when in regular state, it execute the program.

I would like to do something similar, adding a USB to serial so I can upload firmware updates if needed; but I am not sure...could I program the chips in a different way, and save on the hassle to even put a serial to USB converter?

Also is there a standard bootloader that many arduino clones use? They all seems to work in the same way, with ARduino IDE; at least to my eyes.

Hope the question is clear enough; this is my first attempt at making a breakout board from scratch. Thanks.


Found this post which has some relevant info

https://web.archive.org/web/20150906201126/https://hackaday.io/project/7355-minimum-zero-compatible-sam-d21g18-d21e18-board

This person made a minimalist board with a SAM D21G18 chip; it show the finished product, some videos and schematics, so it is a good starting point.

From my findings, the chip has already the USB functionality, to upload on the ROM the code, but you need to use the Atmel own IDE. Still looking for details, but it is a good start.

Since nobody replied; I assume that nobody was aware of this link, so it may be useful to others.

\$\endgroup\$
  • \$\begingroup\$ You mean like an Arduino Zero? \$\endgroup\$ – Ignacio Vazquez-Abrams May 14 '16 at 3:03
  • \$\begingroup\$ Correct, I did get a Chinese clone of the Zero; but I do not need all the bloating that is on the original board \$\endgroup\$ – rataplan May 14 '16 at 3:10
  • 1
    \$\begingroup\$ Voting to close as this is unanswerable without identification of the specific microcontroller. Pretty much all cortex-M parts will have SWD, but some will have a bootloader in ROM and some won't and how you activate it on those that do varies widely, so this question is unanswerable in the general sense. \$\endgroup\$ – Chris Stratton May 14 '16 at 3:26
  • 8
    \$\begingroup\$ So instead of voting to close, why don't you ask what is missing and avoid to downvote? Sometimes I question if I am dealing with adults or automated bots. \$\endgroup\$ – rataplan May 14 '16 at 3:27
  • 1
    \$\begingroup\$ I don't understand why this has been closed. It seems to be asking a couple of simple questions: how to program a SAMD21G18, and is their a standard bootloader? \$\endgroup\$ – gbulmer May 14 '16 at 20:27
3
\$\begingroup\$

Obviously all microcontroller chips which means a chip with some sort of processor, non-volatile memory (flash for example) and ram are at least one time programmable if not re-programmable. These days you find they are often in circuit programmable.

Atmel used to have a sam-ba bootloader on board, that was easy to use. Now that is gone, the SAMD21, has just the one flash space, and has ways to discourage the erasure, but it is trivial to erase. So you dont get that sam-ba nor the arduino experience. The arduino's using an avr, the avr is nice you have the isp programming, which varies across the product line, but is still good. and they have a bootloader area which is where you find the serial based bootloader that arduino's use.

ST and NXP still on m0/m0+ products include a serial bootloader that is easy to use. and both are easier to program than the atmel samd21.

a number of these have usb based bootloaders as well.

At the end of the day though it is a simple matter of reading the manual for the part you are interested in. Go to mouser or digikey or you favorite place, narrow down on microcontrollers from any company that meet your footprint (are hand solderable) or whatever and then look at the datasheets there. or dig deeper at the vendors website. they are ALL programmable. Some jtag is the only option (have a freescale I still cannot program, SWD only and cant get it going with openocd yet). the samd21 you can program with an st-link and probably a cmsis-dap. getting a nucleo board is a cheaper option than a standalone st-link, and hey you may find you like how easy it is to program an stm32. no I dont work for any of these companies.

\$\endgroup\$
  • 1
    \$\begingroup\$ when you buy an arduino, a completed board, the microcontroller is programmed with the arduino bootloader. I dont know off hand if the avrs come with something, but they have an isp or sometimes they use another name for the interface, it varies. But it will say in the documentation for the part, should read that before you buy not after. \$\endgroup\$ – old_timer May 15 '16 at 8:31
  • 1
    \$\begingroup\$ AVR is a chip or processor core if you will, instruction set. The arduino's with the atmegas and such those are AVRs. There is one that has both an arm based and an avr based on the same board, but traditionally they have been avr based chips. So you dont put avr on a chip it is in the chip, like an arm is in the samd21. \$\endgroup\$ – old_timer May 15 '16 at 8:35
  • 1
    \$\begingroup\$ If you are going to and it sounds like you want to, continue with this kind of development, it is worth investing in the tools. Fortunately today you can get usb to TTL uart devices for as little as a buck and a half on ebay or between $10 and $15 at sparkfun or adafruit. stm32 nucleo and other boards with an stlink that can be used generically are also $10 to $20. the msp432 launchpad has a cmsis-dap on it, but the connector is a PITA (supposedly the new standard for arm cortex-m), I had to make a breakout board. and it didnt get my freescale talking so was a waste. \$\endgroup\$ – old_timer May 15 '16 at 8:39
  • 1
    \$\begingroup\$ fortunately the "tools" no longer cost hundreds or thousands of dollars like they used to. you can get an ftdi2232 module from ftdi for about $20 which you can use as multiple uarts, do actual jtag, in theory swd, i2c, spi, whatever... \$\endgroup\$ – old_timer May 15 '16 at 8:40
  • 1
    \$\begingroup\$ right that is what I meant, they offer a samba program you can put on the flash, and the chip has some controls that discourage, erasure of that portion of the flash, but I dont think it has a strong lockout, like a write protect strap, or something more forcefully locked, like a combination to change the protected area. one might read the manual and part of a normal erase undo the protection. likewise, at this point why download and use their complicated bootloader, when literally in 50-100 lines of code you could make your own that works just as well and is suited to you. \$\endgroup\$ – old_timer May 15 '16 at 9:19
2
\$\begingroup\$

There are two general answers to your question, which does sound a little like you are trying to make life harder than it needs to be.

If the device has a built-in bootloader, it can support a mode where one of the functional interfaces (like a UART) gets used for flashing code. You can also use this sort of special boot mode in your own code, so under your own control you can update the code (with an A/B code image, checksum, recover from crash, etc).

Without a bootloader, which is the real question you ask, you need to use a debugger. This means using the SWD interface (or JTAG on older MCUs) to access the on-chip components. SWD can write directly to RAM, and with a bit of work can also write to flash (write data to ram, write a block copy routine to ram, execute the copy).

Generally, the debugger software knows about the various MCUs, and can manage the upload of images for you (over the SWD interface). You do need a USB-SWD convertor (many dev-boards include this).

Depending on your cost model, a good debug environment might be worth more than you spend on hardware. Regardless, you should make the SWD pins (Clock, data, ground) accessible for debug connections.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the reply; From what I can tell, the chip that I want to use, has "arduino" compatibility, which means that you can use the IDE from Arduino and it will be able to talk to the bootloader on the chip. Now the question is if the chip is shipped with bootloader on it already. I am not that concerned about the debugger; the chip include a debugger interface via JTAG I believe, which I would use if I have to push the software on the chip, but that's a following step. Thanks \$\endgroup\$ – rataplan May 15 '16 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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