#avr Logs

Mar 21 2021

#avr Calendar

08:22 AM exp: so I put a bit more effort into my implementation and I can now confirm yes it's definitely a bug in the BootloaderCDC implementation, I can write the entire flash area I expect with the avr libc functions
08:29 AM exp: now to chase down that bug somehow...
08:48 AM twnqx: good chance of signed issue as someone else pointed out
08:48 AM twnqx: check if the current written address is an int somewhere, especailly in a comparison
08:57 AM exp: twnqx: it actually looks like it's the IsPageAddressValid function but I've yet to dig into the bit manipulation
08:57 AM exp: the addresses were valid, it just stopped writing after 32k
08:57 AM exp: eliding that check and everything works as expected
08:59 AM twnqx: got a path+filename? it's inside LUFA, right?
08:59 AM exp: https://github.com/abcminiuser/lufa/blob/master/Bootloaders/CDC/BootloaderAPI.c#L38
08:59 AM exp: sorry was just grabbing public url
08:59 AM exp: BOOT_START_ADDR is 0xe000 btw
09:00 AM twnqx: mh
09:01 AM twnqx: try first if it's the comparison or the bit stuff by always setting the bit stuff to 1
09:01 AM twnqx: or removing the && part from the check
09:01 AM exp: i will do shortly, minor celebration here now
09:01 AM exp: (as i can ship a board on Monday that's been delayed weeks by departments other than mine)
09:01 AM twnqx: then try casting BOOT_START_ADDR to uint32_t
09:02 AM exp: (yeah I know BootloaderCDC isn't secure and doesn't CRC etc but that's fine, they know the risks)
09:02 AM exp: twnqx: that's an interesting thought, thank you
09:03 AM twnqx: i am actually considering a gcc error more likely, to be honest
09:03 AM twnqx: the bit magic is simple, pagesize -1 give you a bit mask, if any bit is set after the AND, it's not aligned
09:04 AM twnqx: but i remember i had some weird type (8/16/32bit) issue with avr-gcc before
09:04 AM exp: well i happen to remember in the usb logs that the addresses sent ended with 0x3f00, 0x3f80, 0x4000, 0x4f80
09:05 AM exp: and i may be mistaken, but there's a bit set in the lower byte in there
09:05 AM twnqx: that's 128 byte page size
09:05 AM twnqx: well, would indicate 128 byte page size
09:05 AM exp: yep, and spm_pagesize is 256
09:05 AM twnqx: weird
09:05 AM exp: but it does actually function with that check removed
09:06 AM exp: so yeah, something odd is going on there
09:07 AM exp: oh course in the usb traffic it's word addresses
09:08 AM twnqx: yeah, was just looking at the data sheet, which says 128 words page size
09:09 AM exp: yet the avr libc functions take byte addresses, so how has this even been working lol
09:13 AM exp: it works because in the SetCurrentAddress function it builds a word and shifts the whole thing left 1
09:14 AM exp: that logic seems incorrect to me, don't you think? https://github.com/abcminiuser/lufa/blob/master/Bootloaders/CDC/BootloaderCDC.c#L478
09:15 AM exp: i guess it's 32 bit so it should fit
09:15 AM exp: I'll shut up now and go debug it on my own, thanks for everyone in here i bounced ideas off
10:18 AM exp: i suppose i should update, it is the BOOT_START_ADDR check but I don't yet understand the assembly being produced, I'm pretty ignorant of this depth but at least I've identified what it is
12:09 PM unforgiven512 is now known as KD9QZO
12:10 PM KD9QZO is now known as unforgiven512_
12:10 PM unforgiven512_ is now known as unforgiven512-mo
12:10 PM unforgiven512-mo is now known as unforgiven512-AW
12:11 PM unforgiven512-AW is now known as unforgiven512
01:05 PM exp: twnqx: please let me know if you're free for a few mins for a sanity check
02:13 PM jancoow: Someone ever worked with the attiny414 as I2C slave? I'm currently trying to imlement it with the sample code provided by start.atmel.com, however... it generated me code to set the pins as output. When I do that, the pullups are not strong enough to get the bus high..
02:13 PM jancoow: so I'm confused
02:22 PM exp: jancoow: output high is definitely wrong for any i2c device, it's all just pulled high or output low
02:31 PM jancoow: exp I mean: I've to configure the pins as output (as slave..) and set them low
02:32 PM jancoow: Which is wrong afaik
02:32 PM jancoow: But I don't understand why the example code tells me to do so
02:51 PM twnqx: output low is output low, output high is high-z (or switch to input), that's how i2c works
02:52 PM twnqx: of course the pull-up is unable to override an output low, how would you produce a low otherwise?
02:52 PM exp: jancoow: that's how i2c signals, it's telling you to set it to output when you are in control of sda or scl
02:52 PM exp: i'm guessing the 414 has to bitbang
03:01 PM jancoow: But why would a slave pull the clock low
03:01 PM jancoow: That's not going to work..
03:01 PM jancoow: It should be receiving the clock as input
03:02 PM jancoow: If I currently attach the attiny to my i2c bus none of the devices works obviously
03:03 PM jancoow: So that's what I'm trying to say, why does the sample code told me to do so?
03:04 PM exp: jancoow: slaves pull the clock low when they clock stretch
03:04 PM exp: and, not all masters support that, so i'd double check that side too
03:08 PM jancoow: Okay well currently the whole bus pulls low due the attiny setting it's output low..
03:08 PM exp: jancoow: want to link the sample code you're using?
03:08 PM jancoow: I was using the code from start.atmel.com
03:09 PM exp: there are 300+ examples there, a bit more specificity would be lovely
03:09 PM jancoow: I would like to follow the datasheet, but it doesn't say anything about how I should configure the pins
03:11 PM exp: the 414 has a TWI interface, so you shouldn't ever need to manually configure them as outputs
03:11 PM exp: not sure what example you're using but it sounds wrong
03:11 PM jancoow: Exp oh sorry, I used the code generator
03:12 PM jancoow: Exp okay... But I can clearly see the difference if I configure the port as output or input
03:12 PM exp: jancoow: oh i'm sure you can lol, but leave them as inputs pulled high (unless you have external pull-ups imo)
03:13 PM jancoow: I've external pull-ups
03:13 PM jancoow: 1k
03:13 PM exp: that is... quite strong, but sure that should work
03:13 PM exp: leaving them as input low should be fine then, i'm not familiar with the 414 but there's a proper datasheet section on TWI
03:17 PM jancoow: Exp ah ye:) sorry I'm a bit vague, I'm just trying to figure out why I'm not configuring it right :)
03:18 PM exp: sure I've been there, wish I could be more help
03:18 PM jancoow: So you say , if I enable the TWI interface, it shouldn't matter how I configured the pin dir?
03:18 PM jancoow: And/or pin output?
03:20 PM exp: I don't know if it doesn't matter at all, but I know that with pins set to input, the TWI interface can still set them to output low on its own
03:38 PM jancoow: Maybe I didn't configure the portmux right
03:39 PM jancoow: A debugger could come in handy lol
03:45 PM jancoow: portmux should be configured right.. sigh
03:45 PM jancoow: exp fyi; this is how I configure it now.. https://es.jancokock.me/f6647/
03:49 PM exp: jancoow: i'll have a read of the datasheet in a little while
03:50 PM exp: but no promises, i'm no expert
03:51 PM jancoow: Exp oh no worries! I appreciate every help possible :)
03:51 PM jancoow: I'm already aware that there are not a lot users of those new RISK mcus
03:51 PM jancoow: "new"
03:52 PM jancoow: All things I can find is about the old attiny85
03:59 PM exp: jancoow: i couldn't see anything obviously wrong, you're using the alternate pins and not seeing the attiny ack the slave address?
04:01 PM jancoow: Nop; the master gives errors on all devices after the attiny configures itself
04:01 PM jancoow: So ye:/ I'll borrow some stuff from the office tomorrow I think
04:01 PM exp: there is a note in there about it pulling scl low when the interrupt is active
04:01 PM exp: you sure you are handling that and clearing the appropriate flag?
04:02 PM exp: you also weren't setting the hold time in that snippet, which is part of the setup process before enabling
04:02 PM exp: you should still see some response, i think
04:03 PM jancoow: Mhh, that's a good one, forever as far as I could debug the interrupt was never called
04:04 PM jancoow: However*
04:04 PM jancoow: What is the hold time exactly?
04:04 PM exp: i've closed the datasheet now, SDAHOLD i think?
04:16 PM jancoow: (SDASETUP)
04:17 PM jancoow: The pulling scl low when interrupt is only for master operation