arduino uno without arduino library

Hi, I've ordered a Uno to tinker with the Arduino kit, IDE + library, but would eventually like to head straight to avr-gcc and programming it with avrdude. I don't have the kit yet, but had a few questions in the meantime:

  • Are there docs that describe what resources are hardwired in the Uno (ie, is pin x is dedicated to UART, etc)?
  • What assumptions, if any, does the bootloader code have on program code?
  • I also ordered a sensor kit to connect with the Uno and would eventually like to implement my own interfaces to those. AFAIK the Arduino library is opensource, but perhaps these might be documented somewhere as well (in addition to their datasheets)?

Thanks,
-- Joe

  1. the Atmel processor data sheet
  2. Not sure. You're probably better off flashing without a bootloader using an USBASP programmer.
  3. Depends on the sensors.

jdl1291:
What assumptions, if any, does the bootloader code have on program code?\

Not exactly sure what you are asking, but the answer is almost certainly "none". The only thing the bootloader does is take the data from the serial interface and write it to flash memory.

There is a common misconception that the bootloader is somehow where the implementation of the Arduino language lives. The truth is there is nothing Arduino-specific about the bootloader. You can use Arduino without a bootloader and you can use the bootloader without Arduino.

The ATmega328P is not so hard. After power on, it is in a safe state. Everything is turned off and the pins are set to inputs.
That means you don't need initialization code for the things that you don't use.
The Arduino code installs an interrupt for Timer0, that is used for millis().

The Arduino initialization code for the ATmega32U4 on the other hand is not easy. It initializes the internal usb-serial interface.

The documentation for the Arduino functions is often the basic information: Arduino Reference - Arduino Reference.
To know everything, you have to read the source code.

Libraries made by others have something even less documentation.

Arduino libraries are not according to strict documented rules. Sometimes the code does no longer compile after a update, because a library was changed to make it better or more straightforward.

If you know everything about the ATmega328P in a few years, are you going move on to the ATSAMD21 processor and start all over again ? Why don't you join us on the Arduino boat and sail towards the unlimited possibilities of creativity ?

Datasheet can be found here ATmega328P - 8-bit AVR Microcontrollers
Other Microchip parts also: Atmega1284P, Atmege2560, Attiny series of parts, etc.

Search for optiboot.c in the your computer's Arduino directory for the bootloader.
You need to use a Programmer that connects to the ICSP header to load code without a bootloader, which talks to a PC via USB/Serial adapter on the board and the 328Ps Rx/Tx Serial port (D0, D1).

You could also look the MiniCore for a different bootloader option.

May the force be with you

If you're coding directly for AVR in AVR-GCC, it would behoove you to survey the manual.
https://www.nongnu.org/avr-libc/user-manual/pages.html

Also, re question #3 of yours - Often if you go to a manufacturers website, there are other documents that supplement the bare data sheet, such as application notes and reference manuals.
Quite often, there will be some sample code included somewhere.

Koepel:
If you know everything about the ATmega328P in a few years, are you going move on to the ATSAMD21 processor and start all over again ?

Especially as, the 328 is essentially obsolete. Look at the Arduino products that are coming out now. They know it.

jdl1291:
Hi, I've ordered a Uno to tinker with the Arduino kit, IDE + library, but would eventually like to head straight to avr-gcc and programming it with avrdude.

Seems a strange question for the Arduino Forum

What's wrong with the Arduino IDE?

...R

An important resource regarding point #1

Uno schematic

Wow, thanks for all the tips guys. A few follow up replies below...

pert:
Not exactly sure what you are asking, but the answer is almost certainly "none". The only thing the bootloader does is take the data from the serial interface and write it to flash memory.

There is a common misconception that the bootloader is somehow where the implementation of the Arduino language lives. The truth is there is nothing Arduino-specific about the bootloader. You can use Arduino without a bootloader and you can use the bootloader without Arduino.

Good to know. I was afraid that I was going to have to copy some code from the library for initialization purposes (reset some UART pin or tickle a watchdog, etc.) Coding these as completely independent entities makes sense from an engineering POV.

Koepel:
...
If you know everything about the ATmega328P in a few years, are you going move on to the ATSAMD21 processor and start all over again ? Why don't you join us on the Arduino boat and sail towards the unlimited possibilities of creativity ?

This may be a strange Arduino use case, but I'm looking for a very stripped down programming development environment for educational purposes. Simple architecture, instruction set, features, etc. ATTiny looked to be a bit too small, while ATSAMD21 looks like a better "phase 2" micro. Hopefully not doing this for "a few years" :wink:

CrossRoads:
...
You could also look the MiniCore for a different bootloader option.
GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB

Very cool. It looks like it is a miniature library and a smaller optiboot implementation. Do you use MiniCore?

aarg:
If you're coding directly for AVR in AVR-GCC, it would behoove you to survey the manual.
avr-libc: Related Pages
...

Great reference, thanks for that one. Calling conventions, notes on re-entrant functions, memory barriers all good stuff.

Robin2:
Seems a strange question for the Arduino Forum

What's wrong with the Arduino IDE?

...R

Well, I plan to use the Arduino UNO hardware and this seems to be the best forum :slight_smile: I've got no problems with the IDE, only that it abstracts a bunch of things I'd like to demonstrate. I come from a world of Makefiles, objdump, assembly, linker scripts, etc. all of which the library and IDE experience hide from the programmer.

sterretje:
An important resource regarding point #1

Uno schematic

Great, that will answer most of my "where do they route that pin to" questions. Do you know if there is a schematic assets top-level link? (ie, how to find this and other schematics)

Thanks,
-- Joe

If you want to program AVR processors but don't want any of the features of the Arduino library, you should probably take your questions to https://www.AVRFreaks.net where they talk about AVR processors and tools that are not Arduino.

Buy an ISP (In-Circuit Serial Programming?) device for programming so you don't need a bootloader. Clones of the USBASP can be purchased through eBay or Amazon for under $5.

If you want to practice programming an AVR chip without using any Arduino features you can still use the Arduino IDE: Create an empty .ino file, and put your "int main()" function in a .c or .cpp file in your sketch folder. You can upload using the bootloader or the ISP and run your code without any Arduino libraries.

jdl1291:
Do you know if there is a schematic assets top-level link? (ie, how to find this and other schematics)

The way to find the schematics for the official Arduino boards is by opening the product page for that board in the Arduino Store, then the "Documentation" tab. There, you will find links to the schematic, board design files, and sometimes a nice pinout diagram.

For example, here's the product page for the Uno:
https://store.arduino.cc/arduino-uno-rev3

I'm not aware of a directory for all the schematics and I don't think the file names are consistent enough to be able to URL hack the file locations, but it's easy enough to access them via the store.

There is a top level page for the official Arduino hardware, which links to each of the product pages if you prefer that approach:
https://www.arduino.cc/en/Main/Products

jdl1291:
Well, I plan to use the Arduino UNO hardware and this seems to be the best forum :slight_smile: I've got no problems with the IDE, only that it abstracts a bunch of things I'd like to demonstrate. I come from a world of Makefiles, objdump, assembly, linker scripts, etc. all of which the library and IDE experience hide from the programmer.

And that is of course precisely what Arduino is about!

If your main purpose in playing with microcontrollers is to enjoy all those other things, or you need maximum performance, then by all means go for it and forget the IDE! The IDE is on the other hand about getting things done.

I am - or used to be - an assembler guy; I tend to "think" assembler, but once used to whatever "C" this is, I can just make basic things work. It is indeed "horses for courses".

And as you will not be wanting to use "shields", I suggest you avoid the UNO (or Mega 2560) and stick to the Pro Mini - or Nano if you have the need for running interaction with a PC. Much more practical form factor.