mkleemann / cmake-avr

cmake toolchain for AVR
Other
174 stars 61 forks source link

Cannot generate a VCD file #27

Closed froart closed 8 months ago

froart commented 8 months ago

Hello, dear developers. I am encountering an issue of generating the VCD file. Here is a project file timer_toggle_pin.c:

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/iom644.h>
#include <stdint.h>

volatile uint8_t wait = 255;

ISR(TIMER0_COMPA_vect)
{
  --wait;
}

void main()
{

  // TCCR0A |= ( 1 <<  WGM01 ); /* enable CTC (Clear Timer on Compare) mode */
  TCCR0A |= ( 1 << WGM01  ) | ( 1 << COM0A0 ); /* enable CTC (Clear Timer on Compare) mode and toggle of OC0A on compare match */
  OCR0A   =   0xff;  /* compare match value register */
  TIMSK0 |= ( 1 << OCIE0A ); /* enable compare match interrupt */
  SREG   |= ( 1 << SREG_I ); /* enable global interrupt */
  DDRB   |= ( 1 << PINB3  ); /* set pin OC0A as an output */ 
  TCCR0B |= ( 1 << ISC00  ); /* launch timer0 */

  while(wait); /* infinite loop */

  return;
}

Here is a vcd_trace_file.c:

#include <avr/io.h>
#include "/usr/include/simavr/avr/avr_mcu_section.h"

AVR_MCU(16000000, "atmega644");
AVR_MCU_VCD_FILE("my_trace_file.vcd", 1000);

const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = {
    { AVR_MCU_VCD_SYMBOL("OUTPUT"), .mask = (1 << PINB3 ), .what = (void*)&PORTB, },
};

I compile it this way:

avr-gcc -g -o timer_toggle_pin.elf timer_toggle_pin.c vcd_trace_file.c -mmcu=atmega644

And the compilation goes with no errors. But, now, when I try to run:

simavr timer_toggle_pin.elf

I get the following error:

ELF format is not supported by this build. simavr: Unable to load firmware from file timer_toggle_pin.elf

I spent whole yesterday to figure out how to resolve this issue with what there is on the internet, but there is not much and it didn't help. Any suggestions?

lsb_release -a

Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy