5

I am new to this Arduino community I noticed on youtube that while the prototype is complete people purchase new ATmega328p chips and flash bootloaders into them using in-system-programmers so that the chip could actually understand and interpret the instructions that are written in the high-level language if I am right(No I was wrong, it's actually the compiler that sits on Arduino). so I thought what if we could burn the atmega328p bootloader into any other microcontroller. So that we could program it in Arduino programming language(C/C++). Is this possible? sorry if I am dumb, but I wanted to know. And can anyone tell me whether could we use ATmega328p for production purposes(consumer electronics)? Thanks in advance.

  • 5
    the purpose of the bootloader is to make upload of the code over UART possible. nothing else. the use of higher language possibility is provided by compiler – Juraj Feb 18 at 16:56
  • 1
    thanks @Juraj that really makes some sense – Ravikiran Feb 18 at 16:58
  • 2
    The compiler itself is not loaded on or run by the microcontroller. For compiled languages, like C, the compiler produces machine code that the microcontroller can run by itself. You're probably thinking of interpreted languages, like Python, that do require an interpreter to exist on whatever hardware is used to run the code. – cat40 Feb 19 at 3:11
  • 2
    You do realize it's quite simple to program an ATmega328p in C and other languages without Arduino, right? It's part of the megaAVR family and can be reached with the Atmel Studio. – Mast Feb 19 at 8:00
11

The answer needs to have multiple parts:

Yes, in principle you can create a bootloader for any microcontroller, which acts like the Arduino's.

Please be aware that there are different bootloaders, not just the common STK500 compatible one. Each of these bootloaders implements a certain protocol to transfer the binary code to the target system.

Additionally, some protocols also include commands to restart the microcontroller, to set configuration registers, and maybe more.

You need to read the bootloader's documentation to become familiar with its capabilities.

But it is your decision whether such a bootloader on a non-AVR system or an non-Arduino-AVR system is good for you.

No, the bootloader does not enable the microcontroller to "understand" the high-level language.

The standard Arduino IDE uses the specific compiler for the target microcontroller to translate the C++ source code to machine language. The resulting binary commonly runs on this target microcontroller only.

The bootloader just implements the protocol. In general, it is completely unaware of the meaning of the transferred data.

Microcontrollers in general use different processors with possibly different machine languages, contain different kinds of memory of different sizes, include different sets of different peripherals. But you know this for sure. You need to write and compile your source code for the specific part you're targeting.

Yes, you can use ATmega328P for a consumer product, as Michel already said.

You need to take the common measures that you take with any part of your product, though.

| improve this answer | |
  • Thank you so Much @the busybee . Now I completely understand about bootloaders and what actually they are meant for . Your answer is ultimate ... – Ravikiran Feb 18 at 17:24
  • Upvoted your (better/detailed) answer. I was assuming (and still do) that he meant to upload an AtMega328 bootloader into any other MCU. You can (as you say) create a bootloader for any MCU acting like an Arduino, but those will be different kind of boatloaders per MCU (type). – Michel Keijzers Feb 18 at 20:15
  • 1
    Thanks a lot! Please keep your answer because of its details about selecting an MCU for production purposes. -- Your assumption about the OP might be right. ;-) But who knows who else comes around because of the question's title. – the busybee Feb 19 at 7:37
2

You cannot just load a sketch into any microcontroller, because every microcontroller has different memory layout, peripherals, ways of uploading, FLASH size etc.

You can use the atMega (or any microcontroller) for production purposes though. Of course each MCU type has operation conditions (like min/max temperature), so in e.g. automotive or military environments not all MCUs are allowed to be used, but for consumer electronics, afaik all MCUs can be used (meaning they will pass by themselves the needed certifications, which may not be true for components added and the circuit/enclosure resulting out of it).

| improve this answer | |
  • 1
    Note: It's not Atmel who will stop you using all MCUs for all applications, it's your customers who will stop you. And for a consumer product, possibly the laws about what customers should be able to expect (so basically your customers). – user253751 Feb 19 at 18:54
  • @user253751 Thanks for this addition. – Michel Keijzers Feb 20 at 14:24

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.