#avr Logs

Jul 29 2022

#avr Calendar

03:33 AM kodcode: Hi, is this the right place to ask a question about compiling/flashing from CLI on FreeBSD to Arduino UNO?
04:02 AM specing_ is now known as specing
04:28 AM exp: kodcode: it might be but it's a very quiet channel
06:58 AM qu1j0t3: kodcode: ask away
07:27 AM kodcode: qu1j0t3, I am following https://wiki.freebsd.org/Arduino and when I try to compile/upload, I get this error: /usr/local/lib/gcc/avr/11.2.0/../../../../avr/bin/ld: -pie not supported. Someone helped me with a workaround with LDFLAGS=-fno-pie
07:27 AM kodcode: Is this the way to go? Does Arduino need PIE?
07:28 AM twnqx: on the opposite, since yopu can't reloacte in ROM, it can't have pie
07:28 AM twnqx: and please call it avr, not arduino.
07:28 AM kodcode: Sorry, totally new to the field
07:29 AM kodcode: twnqx, So where is the mistake? In the toolchain?
07:29 AM twnqx: i don't really know what you are doing, so...
07:30 AM twnqx: on gentoo, you'd install an avr toolchain through crossdev. have you done that?
07:31 AM twnqx: errr ok, i thouhg this would be a different channel
07:31 AM twnqx: :D
07:32 AM qu1j0t3: kodcode: I don't use PIE. when you're linking a runnable program you normally do not need it. it's loaded at a fixed address for one thing
07:32 AM twnqx: anyway, no, your toolchain is correct, avr does not support pie. if your gcc by default builds pie-enabled things, or your makefile calls the linker with -fpie, that part is wrong
07:32 AM qu1j0t3: ^
07:32 AM kodcode: I have installed an arduino-bsd-mk and avr-gcc and avr-libc and avrdude
07:33 AM twnqx: that's a good start, though i'd questin BSDs tollchain then
07:33 AM kodcode: And I also got this error: cc1plus: warning: ‘-fPIC’ is not supported [-fPIC]
07:33 AM kodcode: cc1plus: warning: ‘-fPIE’ is not supported [-fPIE]
07:33 AM twnqx: yeah
07:33 AM twnqx: it means Position Independent Code / Executable
07:34 AM twnqx: in AVR, the position in ROM is fixed, and so this is invalid/unsupported
07:35 AM kodcode: So, I would always have to add the LDFLAGS=-fno-pie flag?
07:35 AM kodcode: Besides all this, how can I learn this stuff more solid ? :)
07:36 AM twnqx: i've been asked this question often; i can't give an answer. i've picked things up for more than 30 years, so it became more or less intuition
07:37 AM kodcode: Man, till a few months ago the only thing I could do on a PC was moving a mouse
07:38 AM kodcode: In any case, thanks for the pointers, I am going to take it from here and do some research over the weekdend. Nice channel, btw :)
07:39 AM twnqx: it is; you will get answer, if your attention span is long enough (e.g. more than 1 minute as for many who ask a question and leave after a minute with no reply)
07:40 AM kodcode: Well, you are not getting paid to answer, right? So everything any time is just appreciated
07:40 AM twnqx: :)
07:42 AM kodcode: qu1j0t3, Thanks for your input, too. Have a good weekend all
07:43 AM exp: avr-gcc doesn't support PIE
07:43 AM exp: but in theory i think the architecture does within a small range
07:43 AM exp: cause it has RJMP doesn't it?
07:43 AM exp: (still learning this myself)
07:43 AM twnqx: wellll
07:44 AM exp: plus you can always store a base address and use offsets, gcc uses trampolines etc
07:44 AM exp: i want to implement a main/backup rom on an xmega so i've had to learn where the 'shortfalls' are
07:44 AM twnqx: technically speaking, yes, you could genrate PIC, place it somewhere in rom, and it would work independent of where it is, yes
07:45 AM qu1j0t3: kodcode: o/ feel free to lurk
07:45 AM exp: the solution i've gone with to support two roms is to have two linker scripts and compile the same code twice with two sets of addresses
07:46 AM exp: i take the last few bytes of the main flash segment to store a statically addressed info struct
07:46 AM exp: and the first few bytes of ram for swapping information between apps/bootloader
07:46 AM exp: so just have to make sure you flash rom_low and rom_high to the right segments :)
07:47 AM exp: (there is actually rom_low_low and rom_low_high etc, thanks to 64k boundaries)
10:32 PM jmiehe1 is now known as jmiehe