#avr Logs

Apr 22 2022

#avr Calendar

12:01 AM nonlinear is now known as zero-xray
08:33 AM specing_ is now known as specing
11:33 AM LeoNerd: cehteh: More hackery on my randomly-crashy code from yesterday... I've got other situations where it crashes now, but inserting lots of printfs to print the line numbers makes it not crash
11:33 AM LeoNerd: This leads me to believe that the issue is either exact code size, or timing
11:33 AM LeoNerd: (printf to 19.2k serial port is quite slow)
11:47 AM LeoNerd: I suspect it's probably code size/arrangement. If I comment out some of the later debug printing lines, the entire program crashes -before- it would have encountered them
11:58 AM qu1j0t3: f u n
11:59 AM LeoNerd: I don't think it's timing related.. I can slow down the I²C bus (by removing the chip it talks to so it times out) and it still crashes in exactly the same place
11:59 AM LeoNerd: This really has to be a compiler or libc bug. I can't really see anything else it could be. I don't like to make that statement but I'm kinda low on ideas now
12:01 PM twnqx: i had such conclusions more than once
12:02 PM twnqx: and i was always wrong :X
12:02 PM qu1j0t3: :)
12:02 PM qu1j0t3: but it has to be admitted, once in a decade, it happens
12:10 PM LeoNerd: The first thing that is confusing me, is the fact that at boot time, the RSTFR register is zeroes. All zeroes
12:10 PM LeoNerd: So none of the reset controller's reasons for a boot, have occurred. This makes me think this isn't actually a CPU reboot, but some errant jump somewhere has jumped back to the start of main
12:11 PM LeoNerd: I'm getting close to having zero ideas left to try. I may have to write an avrfreaks forum post and see what folks come up with
12:55 PM LeoNerd: https://www.avrfreaks.net/forum/attiny1616-bizarre-crashing-compilerlibc-bug -- more detailed description of my setup and the problem. If anyone has any ideas at all, let me know
12:59 PM twnqx: signed 644bits... does that thing even have that much ram? :P
12:59 PM LeoNerd: oops, typo. well spotted
01:00 PM LeoNerd: Fixed
01:01 PM twnqx: well, have you tried a compiler that's not a decade or so old? :S
01:01 PM twnqx: i could run it through 11.2.1 and give you the binary to test if you want
01:02 PM twnqx: avr-libc still is 2.0.0 though, so there's nothing happening on that front
01:03 PM LeoNerd: This is the only version in debian :(
01:03 PM twnqx: even in testing?
01:04 PM LeoNerd: anywhere
01:04 PM LeoNerd: They seem to be at a standstill
01:04 PM twnqx: wow
01:04 PM LeoNerd: All the libc stuff is -ancient- and I had to manually patch it to even support any of these avr1 chips _at all_
01:04 PM twnqx: gentoo uses crossdev to just build cross compilers, so i am on 11.2.1_p20220115 p4, dunno if there is a newer one by now
01:05 PM twnqx: hm
01:05 PM twnqx: sure it's libc and not those chip includes?
01:05 PM LeoNerd: Well,. it's the include files that come with the libc
01:05 PM twnqx: or are they part of avr-libc?
01:06 PM LeoNerd: https://leonerds-code.blogspot.com/2019/06/building-for-new-attiny-1-series-chips.html -- this is the hackery I had to do
01:06 PM LeoNerd: I wrote it on a blog post so I could refer back to it every time to do it again
01:07 PM twnqx: hm yes, seems that way
01:09 PM twnqx: post to the avr-libc-dev mailing list maybe :P
01:09 PM LeoNerd: Ohcrap I think I found it
01:10 PM qu1j0t3: woo!
01:10 PM twnqx: used up too much ram? :P
01:11 PM LeoNerd: Yuch how utterly embarrasing. On certain numerical prints, was writing into the [5]th element of uint8_t digits[5];
01:11 PM twnqx: see
01:11 PM LeoNerd: I -guess- that probably corrupted the return address on the stack or somesuch, meaning a return went off somewhere silly
01:11 PM twnqx: that wouldn't have happened with a current gcc
01:11 PM twnqx: that whines pretty loud about such things
01:12 PM LeoNerd: Ohreally, huhh....
01:12 PM twnqx: well as long as you sprintf()
01:12 PM twnqx: else you need some static source analyer to catch it
01:12 PM LeoNerd: Oh hellno this isn't sprintf. This is my own custom formatter
01:13 PM LeoNerd: I'm not UART printing, I'm spitting out font-rendered bytes over I²C to the OLD
01:13 PM LeoNerd: OLED
01:13 PM twnqx: oh i see
01:13 PM twnqx: yeah, not sure if gcc would have cought it
01:14 PM LeoNerd: The function has a uint8_t digits[5]; and then has a for loop iterating from i = 0; i < count; i++ where count is a value that the caller passed in
01:14 PM LeoNerd: -one- of my callers was passing 6
01:17 PM twnqx: :( yeah it's always something stupid like that, in my experience
01:17 PM LeoNerd: I wonder if I can use a VLA here
01:17 PM LeoNerd: uint8_t digits[count];
01:18 PM LeoNerd: Ugh.. once again I suddenly find myself in what I call the Evans Inversion: Wait a second... If that's the problem, why *didn't* it crash in all the other situations?
01:19 PM twnqx: you mean with the printfs?
01:19 PM LeoNerd: Yeah
01:20 PM twnqx: probably allocated more space on the stack for them so it didn't overwrite return address
02:37 PM cehteh: LeoNerd: i made my own iolib but stopped halfway on a rework to make it better :D
02:39 PM josuah: if you feel like taking a break and have some short newspaper published through the old Gopher protocol:
02:39 PM josuah: Opus 4 of The Gopher Times just published! gopher://bitreich.org/1/tgtimes - https://gopherproxy.net/bitreich.org/1/tgtimes
02:41 PM cehteh: i am just back from cycling :D
02:46 PM josuah: summer is coming (and so is cycling)
02:56 PM cehteh: this year we did a lot cycling on winter as well, inbetween the bad weather there was always some fine days
03:26 PM josuah: cold helps when over-heating due to sport