<!DOCTYPE html>
<html><head>
    <meta charset="UTF-8">
</head><body><p>Yup, or the newer __flash</p><p>I need to get a tiny trivial fragment compiled and linked before attempting anything clever</p><p>-mark</p><p><br></p><p><br></p><p><br></p><blockquote type="cite">On 18 July 2021 at 11:46 "hamster@snap.net.nz" <hamster@snap.net.nz> wrote: <br> <br><div dir="auto">Is the PROGMEM attribute still a thing to put constant data into program flash? <div><br></div><div>Mike <br><div><br></div><div><br></div></div></div><div style="line-height: 1.5;"><br> <br>-------- Original message -------- <br>From: Mark Atherton <markaren1@xtra.co.nz> <br>Date: Sun, 18 Jul 2021, 11:32 AM <br>To: Christchurch Robotics <chchrobotics@lists.ourshack.com>, Andrew Dachs <dachsa492@gmail.com> <br>Subject: Re: [chbot] AVR linker issue (?) <br><blockquote>Thanks Andy, Richard. <br> <br>Was hoping that I had just something daft. <br> <br>Started looking at disassembly of the OBJ modules. <br> <br>I don't plan to waste too much time on the problem. Failing all else, the parent module can subsume the table and the problem goes away; this will detract from modularity. Ho-hum. <br> <br>Hope to see you all tomorrow eve at Robotics :) <br> <br>-mark <br> <br> <br> <br> <br>> On 18 July 2021 at 10:14 Andrew Dachs <dachsa492@gmail.com> wrote: <br>> <br>> <br>> A dependency issue maybe. Did it definitely recompile font.c? <br>> Andy <br>> <br>> Sent from my iPhone <br>> <br>> > On 18/07/2021, at 9:02 AM, Mark Atherton <markaren1@xtra.co.nz> wrote: <br>> > <br>> > I need another pair of eyes to look at this issue as am obviously doing something daft. This is part of a larger problem; minimal code to show issue is below. <br>> > <br>> > All I am trying to do is move a table into a separate module, but the linker is giving me a hard time. <br>> > <br>> > Remove 'const' in the external module and everything works fine. <br>> > <br>> > Thoughts please ! <br>> > <br>> > -Mark <br>> > <br>> > <br>> > ------------- <br>> > <br>> > mkdir -p .build <br>> > avr-g++ -c -g -Os -Wall -w -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L font.c -o .build/font.o <br>> > avr-g++ -c -g -Os -Wall -w -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L main.c -o .build/main.o <br>> > avr-gcc .build/font.o .build/main.o -o .build/hw.elf -Os -Wl,--gc-sections -mmcu=atmega328p -lm <br>> > <br>> > .build/main.o: In function `main': <br>> > C:\Temp\linker_test/main.c:18: undefined reference to `ext_font' <br>> > collect2.exe: error: ld returned 1 exit status <br>> > make: *** [.build/hw.elf] Error 1 <br>> > <br>> > ------------- font.c <br>> > <br>> > #include <avr\pgmspace.h> <br>> > <br>> > const unsigned char ext_font[] =        // links OK with const removed <br>> > { <br>> >  0x00, 0x00, 0x00, 0x00, 0x00 <br>> > }; <br>> > <br>> > ------------- font.h <br>> > <br>> > #ifndef    _FONT_H_ <br>> > #define _FONT_H_ <br>> > <br>> > extern const unsigned char ext_font[5]; // links OK with const removed <br>> > <br>> > #endif <br>> > <br>> > ------------- main.c <br>> > <br>> > #include <avr\io.h> <br>> > #include <avr\pgmspace.h> <br>> > #include <ctype.h> <br>> > #include "font.h" <br>> > <br>> > const unsigned char local_font[] = // const has no effect on linker !! <br>> > { <br>> >  0x00, 0x00, 0x00, 0x00, 0x00 <br>> > }; <br>> > <br>> > int main(void) <br>> > { <br>> >  volatile unsigned char val; <br>> >  val = local_font[3];        // links OK <br>> >  val = ext_font[3];        // link Fails <br>> > <br>> > } <br>> > <br>> > _______________________________________________ <br>> > Chchrobotics mailing list Chchrobotics@lists.ourshack.com <br>> > https://lists.ourshack.com/mailman/listinfo/chchrobotics <br>> > Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/ <br>> > Meetings usually 3rd Monday each month. See http://kiwibots.org for venue, directions and dates. <br>> > When replying, please edit your Subject line to reflect new subjects. <br>> <br>> _______________________________________________ <br>> Chchrobotics mailing list Chchrobotics@lists.ourshack.com <br>> https://lists.ourshack.com/mailman/listinfo/chchrobotics <br>> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/ <br>> Meetings usually 3rd Monday each month. See http://kiwibots.org for venue, directions and dates. <br>> When replying, please edit your Subject line to reflect new subjects. <br> <br>_______________________________________________ <br>Chchrobotics mailing list Chchrobotics@lists.ourshack.com <br>https://lists.ourshack.com/mailman/listinfo/chchrobotics <br>Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/ <br>Meetings usually 3rd Monday each month. See http://kiwibots.org for venue, directions and dates. <br>When replying, please edit your Subject line to reflect new subjects.</blockquote></div>_______________________________________________ Chchrobotics mailing list Chchrobotics@lists.ourshack.com https://lists.ourshack.com/mailman/listinfo/chchrobotics Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/ Meetings usually 3rd Monday each month. See http://kiwibots.org for venue, directions and dates. When replying, please edit your Subject line to reflect new subjects.</blockquote></body></html>