avr-gcc

AVR linker error, “relocation truncated to fit”

断了今生、忘了曾经 提交于 2019-11-28 03:30:59
问题 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

How can I unit test Arduino code?

冷暖自知 提交于 2019-11-28 02:34:27
I'd like to be able to unit test my Arduino code. Ideally, I would be able to run any tests without having to upload the code to the Arduino. What tools or libraries can help me with this? There is an Arduino emulator in development which could be useful, but it doesn't yet seem to be ready for use. AVR Studio from Atmel contains a chip simulator which could be useful, but I can't see how I would use it in conjunction with the Arduino IDE. Don't Run Unit Tests on the Arduino Device or Emulator The case against microcontroller Device/Emulator/Sim-based tests There's a lot of discussion about

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

三世轮回 提交于 2019-11-28 01:43:47
问题 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

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

折月煮酒 提交于 2019-11-27 12:58:08
问题 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

What is the purpose of __cxa_pure_virtual?

半世苍凉 提交于 2019-11-27 05:16:29
问题 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

How can I unit test Arduino code?

爷,独闯天下 提交于 2019-11-26 23:45:32
问题 I'd like to be able to unit test my Arduino code. Ideally, I would be able to run any tests without having to upload the code to the Arduino. What tools or libraries can help me with this? There is an Arduino emulator in development which could be useful, but it doesn't yet seem to be ready for use. AVR Studio from Atmel contains a chip simulator which could be useful, but I can't see how I would use it in conjunction with the Arduino IDE. 回答1: Don't Run Unit Tests on the Arduino Device or

How to prevent GCC from optimizing out a busy wait loop?

馋奶兔 提交于 2019-11-26 15:59:31
I want to write a C code firmware for Atmel AVR microcontrollers. I will compile it using GCC. Also, I want to enable compiler optimizations ( -Os or -O2 ), as I see no reason to not enable them, and they will probably generate a better assembly way faster than writing assembly manually. But I want a small piece of code not optimized. I want to delay the execution of a function by some time, and thus I wanted to write a do-nothing loop just to waste some time. No need to be precise, just wait some time. /* How to NOT optimize this, while optimizing other code? */ unsigned char i, j; j = 0;

Is there an alternative for flex/bison that is usable on 8-bit embedded systems?

有些话、适合烂在心里 提交于 2019-11-25 21:40:31
问题 I\'m writing a small interpreter for a simple BASIC like language as an exercise on an AVR microcontroller in C using the avr-gcc toolchain. However, I\'m wondering if there are any open source tools out there that could help me writing the lexer and parser. If I would write this to run on my Linux box, I could use flex/bison. Now that I restricted myself to an 8-bit platform I have to do it all by hand, or not? 回答1: I've implemented a parser for a simple command language targeted for the