Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avrdude upload error when fuses are present in the elf file (AVR Dx) #71

Open
kiiv-cz opened this issue Aug 18, 2024 · 2 comments
Open

Comments

@kiiv-cz
Copy link

kiiv-cz commented Aug 18, 2024

I'm getting error:

avrdude error: address 0x820009 out of range at line 665 of .pio\build\test_fuses_in_elf\firmware.hex

caused by having C source file containing FUSES setting (src/fuses.c):

#include <avr/io.h>

#ifdef MVIO_ENABLED
  #define MVIO_SETTING MVSYSCFG_DUAL_gc
#else
  #define MVIO_SETTING MVSYSCFG_SINGLE_gc
#endif

FUSES = {
    .WDTCFG   = WINDOW_OFF_gc | PERIOD_OFF_gc,
    .BODCFG   = LVL_BODLEVEL0_gc | SAMPFREQ_128Hz_gc | ACTIVE_DISABLE_gc | SLEEP_DISABLE_gc,
    .OSCCFG   = CLKSEL_OSCHF_gc,
    .SYSCFG0  = CRCSRC_NOCRC_gc | CRCSEL_CRC16_gc | RSTPINCFG_RST_gc | FUSE_EESAVE_bm,
    .SYSCFG1  = MVIO_SETTING | SUT_16MS_gc,
    .CODESIZE = 0x00,
    .BOOTSIZE = 0x00,
};

Fix is adding "-R" ".fuse" into ElfToHex Builder builder/main.py#L129:

        ElfToHex=Builder(
            action=env.VerboseAction(" ".join([
                "$OBJCOPY",
                "-O",
                "ihex",
                "-R",
                ".eeprom",
                "-R",
                ".fuse",
                "$SOURCES",
                "$TARGET"
            ]), "Building $TARGET"),
            suffix=".hex"
        )

Another workaround is using custom upload protocol and just copy hex file to CURIOSITY NANO drive:

upload_protocol = custom
upload_command = copy $SOURCE d:\

Board: Curiosity Nano DB / AVRxDB (but should be valid for any supported MCU)
Plaform version: 1.9.0

@brunob45
Copy link
Contributor

brunob45 commented Sep 1, 2024

Fuses are usually set by options in the platformio.ini file as documented here. Setting the fuses manually elsewhere can have unforeseen consequences.

What fuse were you unable to set correctly?

@kiiv-cz
Copy link
Author

kiiv-cz commented Sep 3, 2024

My aim is creating single production file (= elf) that contains code + eeprom and fuses so my coworker can just run Quick Programming tool from Microchip studio and not care about anything.

I can pass those fuses into program as defines to have it consistent (but only with magic numbers), however it still can't be present inside of hex (or I could use avrdude v8 that now supports flashing everything inside single file - released recently).

Another way is another env with purpose only generate production file as changing platform localy will work only until it gets updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants