avr-gcc

crt0.o and crt1.o — What's the difference?

浪子不回头ぞ 提交于 2019-12-03 02:38:59
问题 Recently I've been trying to debug some low-level work and I could not find the crt0.S for the compiler (avr-gcc) but I did find a crt1.S (and the same with the corresponding .o files). What is the difference between these two files? Is crt1 something completely different or what? They both seem to have to do with something for 'bootstrapping' (setting up stack frame and such), but why the distinction? 回答1: Both crt0/crt1 do the same thing, basically do what is needed before calling main()

crt0.o and crt1.o — What's the difference?

放肆的年华 提交于 2019-12-02 16:13:36
Recently I've been trying to debug some low-level work and I could not find the crt0.S for the compiler ( avr-gcc ) but I did find a crt1.S (and the same with the corresponding .o files). What is the difference between these two files? Is crt1 something completely different or what? They both seem to have to do with something for 'bootstrapping' (setting up stack frame and such), but why the distinction? kriss Both crt0/crt1 do the same thing, basically do what is needed before calling main() (like initializing stack, setting irqs, etc.). You should link with one or the other but not both.

Android cannot talk to Arduino using AVRDUDE

北战南征 提交于 2019-11-30 23:34:21
I am using AVRDUDE for Android ( http://code.google.com/p/andavr/ ). I can compile the C code. I can run $ avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o led.o led.c $ avr-gcc -mmcu=atmega328p led.o -o led $ avr-objcopy -O ihex -R .eeprom led led.hex all without issues. Then I try to run: avrdude -F -V -c arduino -p ATMEGA328P -P /dev/bus/usb/002/002 -b 115200 -C /data/data/jackpal.androidterm/local/etc/avrdude.conf -U flash:w:led.hex The result is: avrdude: ser_open(): can't open device "/dev/bus/usb/002/002"; Permission denied loctl("TIOCMGET"): Invalid argument avrdude done. Thank

Linking binary against functions/data in specific location in memory

我的梦境 提交于 2019-11-29 12:41:41
I'm currently in the process of writing an intermediate-memory bootloader for an ATMega. I'd like to place a section of commonly used functions and data in a specific location in memory, such that: limited size of the bootloader section is not overcome library functions, drivers, etc, are not reproduced by the application section and thus wasting space For illustrative purposes, a map of the desired memory layout is below: Following some help in this thread on avrfreaks, I'm to the point where I've been able to move all code (in my bootloader + library development environment - applications

AVR linker error, “relocation truncated to fit”

我只是一个虾纸丫 提交于 2019-11-29 10:19:27
I'm trying to compile some code for an ATmega328 micro, and I want use the libraries and the core of Arduino. I'm using CMake . I have gotten to compile the core library and all objects of my code and the libraries of Arduino. But when it's linking, they show me the following error. ..."relocation truncated to fit: R_AVR_13_PCREL against symbol"..."avr5/libgcc.a"... I have found through Google that this is a common error, but no solution has worked for me. The only thing I can't do is put "-lm" and "-lc" flags at the end of the linker sentence, because I don't know how I can do it with CMake.

Convert two ASCII Hexadecimal Characters (Two ASCII bytes) in one byte

不羁的心 提交于 2019-11-29 08:27:09
I want to convert two ASCII bytes to one hexadecimal byte. eg. 0x30 0x43 => 0x0C , 0x34 0x46 => 0x4F ... The ASCII bytes are a number between 0 and 9 or a letter between A and F (upper case only), so between 0x30 ... 0x39 and 0x41 ... 0x46 I know how "to construct" 0x4F with the numbers 0x34 and 0x46 : 0x4F = 0x34 * 0x10 + 0x46 So, in fact, i would to convert one ASCII byte in hexadecimal value. For that, i can build and array to assign the hexadecimal value to the ASCII char : 0x30 => 0x00 0x31 => 0x01 ... 0x46 => 0x0F But, maybe it have a most « proper » solution. The program will be run on

How can I perform pre-main initialization in C/C++ with avr-gcc?

余生颓废 提交于 2019-11-29 00:04:03
问题 In order to ensure that some initialization code runs before main (using Arduino/avr-gcc) I have code such as the following: class Init { public: Init() { initialize(); } }; Init init; Ideally I'd like to be able to simply write: initialize(); but this doesn't compile... Is there a less verbose way to achieve the same effect? Note: the code is part of an Arduino sketch so the main function is automatically generated and cannot be modified (for example to call initialize before any other code)

How can I visualise the memory (SRAM) usage of an AVR program?

江枫思渺然 提交于 2019-11-28 20:30:49
I have encountered a problem in a C program running on an AVR microcontroller (ATMega328P). I believe it is due to a stack/heap collision but I'd like to be able to confirm this. Is there any way I can visualise SRAM usage by the stack and the heap? Note: the program is compiled with avr-gcc and uses avr-libc. Update: The actual problem I am having is that the malloc implementation is failing (returning NULL ). All malloc ing happens on startup and all free ing happens at the end of the application (which in practice is never since the main part of the application is in an infinite loop). So I

Linking binary against functions/data in specific location in memory

試著忘記壹切 提交于 2019-11-28 06:06:54
问题 I'm currently in the process of writing an intermediate-memory bootloader for an ATMega. I'd like to place a section of commonly used functions and data in a specific location in memory, such that: limited size of the bootloader section is not overcome library functions, drivers, etc, are not reproduced by the application section and thus wasting space For illustrative purposes, a map of the desired memory layout is below: Following some help in this thread on avrfreaks, I'm to the point

What is the purpose of __cxa_pure_virtual?

我的未来我决定 提交于 2019-11-28 04:18:20
Whilst compiling with avr-gcc I have encountered linker errors such as the following: undefined reference to `__cxa_pure_virtual' I've found this document which states: The __cxa_pure_virtual function is an error handler that is invoked when a pure virtual function is called. If you are writing a C++ application that has pure virtual functions you must supply your own __cxa_pure_virtual error handler function. For example: extern "C" void __cxa_pure_virtual() { while (1); } Defining this function as suggested fixes the errors but I'd like to know: what the purpose of this function is, why I