Program Fuse / Memory Lock Bits

Discussion about software developed by Freematics, including Freematics Builder and Freematics Emulator GUI
Post Reply
dbellairs
Posts: 4
Joined: Tue Sep 07, 2021 5:51 am

Program Fuse / Memory Lock Bits

Post by dbellairs »

H/W - Freematics One

Is there a way to program the fuse and/or memory lock bits through the micro USB connection?

Thanks,
DB
dbellairs
Posts: 4
Joined: Tue Sep 07, 2021 5:51 am

Re: Program Fuse / Memory Lock Bits

Post by dbellairs »

I've tried the following things to program the lock bits:
  1. Platform I/O Configuration
    I'm using Visual Studio Code...
    The platformio.ini file is as follows:
    ;start of file
    [env:uno]
    platform=atmelavr
    board=uno
    framework=arduino
    monitor_speed=115200
    upload_flags = -Ulock:w:0xFC:m
    lib_extra_dirs=../libraries

    [platformio]
    src_dir=.
    ;end of file
    but when uploading to the board, the procedure fails and says
    avrdude: verifying ...
    avrdude: verification error, first mismatch at byte 0x0000
    0x00 != 0xfc
    avrdude: verification error; content mismatch
  2. AVRDUDE
    I tried the command:
    avrdude -u -c arduino -p m328p -P COM7 -b 115200 -U lock:r:-:h
    that command always returns 0x00
    I've also tried writing with AVRDUDE:
    avrdude -u -c arduino -p m328p -P COM7 -b 115200 -U lock:w:0xFC:m
    avrdude: Device signature = 0x1e950f (probably m328p)
    avrdude: reading input file "0xFC"
    avrdude: writing lock (1 bytes):
    avrdude: 1 bytes of lock written
    avrdude: verifying lock memory against 0xFC:
    avrdude: load data lock data from input file 0xFC:
    avrdude: input file 0xFC contains 1 bytes
    avrdude: reading on-chip lock data:
    avrdude: verifying ...
    avrdude: verification error, first mismatch at byte 0x0000
    0x00 != 0xfc
    avrdude: verification error; content mismatch

    avrdude done. Thank you.
  3. Program During Runtime
    There's a lot of forums that claim you can program the lock bits by including the header file <avr/boot.h> and by calling
    boot_lock_bits_set_safe(0x03);
In the software I'm calling:
lbits = boot_lock_fuse_bits_get(GET_LOCK_BITS)
which always returns 0xFF
I'm also fairly confident that none of these attempts to lock the device are working because the command:
avrdude -c arduino -p m328p -P COM7 -b 115200 -U flash:r:"D:\download.hex":h
creates a file that has the same contents as the .hex that I'm uploading to the ECU.
Post Reply