Skip to content

Instantly share code, notes, and snippets.

@msquirogac msquirogac/main.c

Last active Apr 29, 2020
Embed
What would you like to do?
Platformio configuration for simavr integration
//Header for simavr macros
#include <simavr/avr/avr_mcu_section.h>
//Sets CPU model and frecuency
AVR_MCU(F_CPU, "atmega328");
//Sets which registers should be traced
const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = {
{ AVR_MCU_VCD_SYMBOL("PORTB"), .what = (void*)&PORTB},
{ AVR_MCU_VCD_SYMBOL("PORTC"), .what = (void*)&PORTC},
{ AVR_MCU_VCD_SYMBOL("PORTD"), .what = (void*)&PORTD},
};
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:release]
platform = atmelavr
board = nanoatmega328new
build_flags =
-I/usr/local/include/
[env:debug]
build_type = debug ; adds -g2 -ggdb2 -Og to build_flags
platform = atmelavr
board = nanoatmega328new
extra_scripts = simavr_env.py
build_unflags = -Os -Og ; problematic flags
build_flags =
-I/usr/local/include/
-Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000
debug_port = 1234
debug_tool = custom
debug_init_cmds =
target remote :$DEBUG_PORT
file "$PROG_PATH"
;load ; load error due to mmcu section
# Credits to MaslowCNC for the original code
from SCons.Script import ARGUMENTS, AlwaysBuild
Import('env')
# Dump construction environment
#print(env.Dump())
# Don't try to upload the firmware
env.Replace(UPLOADHEXCMD="echo Upload is not supported for ${PIOENV}. Skipping")
pioenv = env.get("PIOENV")
progname = env.get("PROGNAME")
brdmcu = env.get("BOARD_MCU")
brdfcpu = env.get("BOARD_F_CPU")
def simulate_callback(*args, **kwargs):
env.Execute("simavr -g -m " + brdmcu + " -f " + brdfcpu + " .pio/build/" + pioenv + "/" + progname + ".elf")
AlwaysBuild(env.Alias("simulate", "", simulate_callback))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.