#avr | Logs for 2016-04-01

Back
[01:00:24] <eszett> I have a question, how can i figure out the bootloaders size in memory?
[01:45:31] <cehteh> ram or flash?
[01:45:55] <cehteh> either way .. avr-size on its object
[01:52:29] <eszett> cehteh: but without the programmer (it died yesterday) i cant check the size right?
[01:53:33] <cehteh> thats offline on the build objectfile
[01:54:22] <cehteh> i dont know exactly but i think for the avr's with dedicated bootlader support this bootloader areas are static anyway (2k or so)
[01:55:07] <cehteh> for tiny bootloaders like micronucleus its prolly different as they can flash code at any location
[01:56:00] <cehteh> i havent cared for that yet, i rather optimize my own code than the bootloader :D
[01:56:01] <eszett> well, I guess I wait til my next programmer arrives from china
[01:56:36] <cehteh> in 4-6 weeks :D
[01:58:45] <cehteh> why do you need to know the size of the bootloader?
[01:58:59] <cehteh> and do you need to know the code size or the size of the bootloader section?
[01:59:54] <eszett> its hard to explain
[02:00:16] <cehteh> anyway check datasheet
[02:00:31] <cehteh> there is a bootsz fuse on the megas
[02:01:29] <eszett> actually well not that hard to explan, in the makefile there is the option: OPT_DEFS += -DBOOTLOADER_SIZE=512 and i have to put the right value there
[02:01:30] <cehteh> 512 byte - 4k are selectable on the 328p for example
[02:01:36] <eszett> but i guuess its 4kb
[02:01:54] <cehteh> what bootloader do you use?
[02:02:03] <eszett> the original atmel one
[02:02:11] <cehteh> then google for that
[02:02:31] <cehteh> dont you have its objectfile or even source (is it open source?)
[02:02:34] <eszett> yea finally got it..
[02:02:51] <eszett> i have the hex file
[02:03:35] <eszett> found the value as 4096!
[02:03:37] <cehteh> you can use avr-size on the hex as well .. maybe first convert it with avr-objcpy
[03:06:33] <WormFood> I was reading, that the external interrupt line is still active, when that pin is configured as an output, to allow you to do a software interrupt. And that got me to thinking, about the difference between a software interrupt, and a subroutine. And the only difference I can see, is the Software Interrupt disables global interrupts. Is there anything more, that I'm missing?
[03:25:11] <Mr_Sheesh> WormFood lil different treatment of the stack iirc?
[03:45:42] <WormFood> Mr_Sheesh, really?
[03:47:38] <Mr_Sheesh> I'm rusty, been stuck on some RL problems, so I'd double check it
[03:48:08] <WormFood> I think you're thinking about a different cpu. Like the 6805 for example, does treat the stack differently.
[03:48:27] <WormFood> But, the rts and rti both treat the stack exactly the same way.
[03:48:34] <Mr_Sheesh> could be. Too many embedded uCs in my life LOL
[03:48:45] <WormFood> I already looked up the differences.
[03:49:04] <WormFood> I've also used the 6805, where I pushed the extra values onto the stack, then did an RTI
[10:01:21] <liwakura> uhm
[10:01:34] <liwakura> to that queue dude i talked to yesterday or so
[10:01:38] <liwakura> or 2 days ago
[10:01:47] <liwakura> who was that exactly?
[10:01:54] <liwakura> can't remember all your dudes names
[10:03:15] <Chillum> I don't remember either
[10:38:09] <cehteh> liwakura: was me i think :D
[10:38:25] <liwakura> ah yeah
[10:38:32] <liwakura> i implemented it like you suggested
[10:38:41] <liwakura> and its indeed much faster
[10:39:25] <cehteh> oops .. i never cared for speed on serial :D
[10:39:25] <liwakura> also i found out that string literals are stored in ram
[10:39:32] <cehteh> yes
[10:39:43] <liwakura> i mean its less instructions now
[10:39:44] <cehteh> unless you do some special massaging
[10:40:02] <liwakura> im going to write my own printf today
[10:40:08] <liwakura> first argument pointer to flash location
[10:40:30] <cehteh> did you look at my txqueue thing?
[10:40:38] <Chillum> if you want to store literals in flash use https://www.arduino.cc/en/Reference/PROGMEM
[10:40:40] <cehteh> later i am planning to add a printf on top
[10:40:57] <cehteh> Chillum: there are better ways than arduino does this :D
[10:41:02] <Chillum> oh good
[10:41:06] <liwakura> cehteh: thats what im trying to do
[10:41:13] <liwakura> cehteh: your repo?
[10:41:18] <liwakura> url?
[10:41:25] <Chillum> is that an arduino thing? I though it was an avr thing
[10:41:27] <cehteh> git://git.pipapo.org/muos
[10:41:42] <liwakura> can i just clone this?
[10:41:56] <liwakura> ah yes
[10:41:57] <cehteh> Chillum: part/part .. using some older stuff, adds some C++ bloat
[10:42:07] <cehteh> yes
[10:44:19] <cehteh> Chillum: src/muos/hw/atmel/avr/avr.h:typedef const __flash char muos_flash_cstr[];
[10:44:30] <cehteh> ... newer gcc knows __flash
[10:44:39] <Chillum> neat
[10:45:30] <liwakura> oh Chillum didn't see your comment until now
[10:46:25] <liwakura> uhm, some variant i would like even more
[10:46:39] <liwakura> that i could say that string literals in general should be stored in flash
[10:46:50] <cehteh> note that you need special read instructions to read data from flash
[10:46:55] <liwakura> i know
[10:47:03] <cehteh> that would be incompatible with C
[10:47:03] <twnqx> cehteh: how new gcc do you need for that? i always used __attribute__((progmem)) or so
[10:47:16] <liwakura> since C is made for fucking naumann arch
[10:47:24] <cehteh> twnqx: dunno not *that* new .. i mean i have debian stable :D
[10:47:42] <twnqx> liwakura: see, and i despise AVR's harvard
[10:47:43] <liwakura> i would prefer to use __flash because i dislike uppercase in type secifiers
[10:47:51] <liwakura> havard is fine
[10:47:57] <twnqx> 'cause i can not just execute code from fucking ram, no, i have to reflash it
[10:48:03] <liwakura> C being unable to deal with havard is pissing me off
[10:48:06] <twnqx> no self modifying code, no runtime updates
[10:48:18] <twnqx> harvard without code ram is made of suck
[10:48:18] <liwakura> oh, its possible
[10:48:24] <liwakura> but just very messy
[10:48:29] <twnqx> yeah, by erasing a full block
[10:48:29] <LeoNerd> C can cope with it just fine
[10:48:32] <LeoNerd> gcc and ELF can't
[10:48:38] <liwakura> sorta
[10:48:44] <LeoNerd> ELF is built for POSIX which wants a flat memory model
[10:48:54] <twnqx> self modifying musn't be more than a single fucking instruction
[10:49:17] <liwakura> i have an old calculator which just has one address space, where both ROM and RAM are situated
[10:49:18] <twnqx> this is the single one thing i REALLY hate about avrs
[10:49:27] <Chillum> twnqx: no buffer overflow attacks with arbitrary code execution
[10:49:28] <twnqx> that you can't execute from ram
[10:49:35] <twnqx> ohhhhh
[10:49:52] <twnqx> ALL cases of buffer overflow attacks are just the result of incompetent programmers
[10:49:56] <Chillum> though you can use data based buffer overflow ttacks
[10:50:03] <liwakura> nah, some are even compiler shit
[10:50:07] <Chillum> twnqx: all bugs are the result of a failure
[10:50:30] <liwakura> also true
[10:50:51] <liwakura> i also considered using interrupts for preemptive multitasking
[10:50:57] <liwakura> but then i would need multiple stacks
[10:51:08] <liwakura> and thats a bit messy if you only have 2kb of code
[10:51:15] <liwakura> *sram
[10:51:41] <cehteh> i'd like if C: never initializes variables automatically to defaults, doesnt cast all shit to int, ...
[10:52:12] <cehteh> liwakura: thats why i made this function call - queues .. jobs with only one stack
[10:52:41] <cehteh> mµOS runs on tiny with 256bytes RAM and less
[10:52:42] <liwakura> yeah just working sorta asynchronous is also possible
[10:52:51] <cehteh> it is async
[10:52:56] <liwakura> but 1) i wanna make my own shit
[10:53:01] <cehteh> you can yield and wait
[10:53:06] <cehteh> just do :)
[10:53:09] <cehteh> same here
[10:53:11] <liwakura> and 2) i dislike that all the string literals cant be used from flash
[10:53:35] <liwakura> it would be great if i would just need a stack and nothing else from ram
[10:55:40] <cehteh> thats possible :D
[10:55:52] <cehteh> *but* not always ideal
[10:56:05] <liwakura> i have nothing my arduino has to do
[10:56:05] <LeoNerd> I do string literals in flash
[10:56:09] <liwakura> LeoNerd: show code
[10:56:10] <cehteh> because then you have to pass a lot pointers/references
[10:56:23] <liwakura> uhm
[10:56:27] <liwakura> no
[10:56:32] <liwakura> just use local function variables?
[10:56:46] <LeoNerd> liwakura: fprintf_P(stderr, PSTR("BOOT MCUSR=%02x\n"), MCUSR); example
[10:56:56] <cehteh> same here
[10:56:57] <LeoNerd> That string literal is stored in flash
[10:57:03] <liwakura> PSTR
[10:57:10] <liwakura> where is that PSTR thingie from?
[10:57:19] <LeoNerd> <avr/pgmspace.h>
[10:57:23] <liwakura> ayy
[10:57:29] <liwakura> thats quite useful
[10:57:36] <LeoNerd> http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html
[10:57:38] <LeoNerd> ^-- read
[10:57:42] <cehteh> i wrap that whole in a macro
[10:57:48] <LeoNerd> That is a macro
[10:57:54] <liwakura> ayy
[10:58:36] <LeoNerd> I will admit it's a *little* cumbersome, because you have to remember to match your PSTR()s with your _P function calls
[10:58:41] <LeoNerd> But it's not terribly difficult
[10:58:44] <liwakura> lwkr_fprintf(queue, PSTR("%X\n"), 0x1337)
[10:58:58] <liwakura> LeoNerd: im going to code my own printf anyways
[10:59:17] <LeoNerd> GL;HF
[10:59:20] <liwakura> i was just looking for a comforable mechanism to get the strings from flash
[11:00:04] <cehteh> thats not that simple
[11:00:06] <LeoNerd> Any reason any of the three builtin printfs aren't suitable?
[11:00:16] <cehteh> esp since C has no templates/overloading
[11:00:25] <liwakura> LeoNerd: no
[11:00:37] <cehteh> LeoNerd: i had some reasons :D
[11:00:38] <liwakura> im just coding for fun
[11:00:49] <liwakura> cehteh: im just gonna copy it from your code :3
[11:01:01] <liwakura> especially the vararg thingies
[11:01:13] <cehteh> liwakura: as long you do gpl too :D
[11:01:25] <liwakura> what
[11:01:27] <liwakura> oh my god
[11:01:28] <liwakura> legal stuff
[11:01:48] <liwakura> im from germany
[11:01:54] <cehteh> i am to
[11:01:54] <liwakura> and that stuff makes me so angry
[11:02:05] <cehteh> why that?
[11:02:29] <liwakura> legal shit
[11:03:03] <liwakura> there are so many things that are possible and i could do them without physical limitation
[11:03:20] <cehteh> hey i either get money for coding or its GPL (which even doesnt prevent anyone else marketing that, as long he complies with the gpl)
[11:03:25] <twnqx> you can ignore any license stuff if you only build for yourself
[11:03:27] <liwakura> but if i do them, lawyers and police are coming after me and shit
[11:03:41] <cehteh> if anyone wants my gpl code for something closed he can ask me for relicensing
[11:03:41] <twnqx> especially GPL.
[11:03:57] <liwakura> cehteh: im just gonna look how you do it and imitate it
[11:04:04] <cehteh> yeah as long its only for yourself gpl doesnt matter much
[11:04:20] <cehteh> but if you give it away or publish it then GPL matters
[11:04:39] <liwakura> so no copy, just seeing how you do it
[11:04:40] <twnqx> if it wasn't for the insane amount of register saves i'd contemplate using thread on avr
[11:04:45] <liwakura> its already piblic
[11:04:59] <liwakura> *public
[11:05:11] <cehteh> but not with the parts you borrowed from me
[11:05:17] <liwakura> im not exactly a fan of the IP laws in the western worlds
[11:05:22] <liwakura> im not gonna borrow
[11:05:26] <LeoNerd> twnqx: I've occasionally pondered nicer coroutine support in C
[11:05:35] <cehteh> i am not that much fun either
[11:05:40] <LeoNerd> I don't want preëmptive threading on an MCU because I think that would be *terrible*
[11:05:53] <cehteh> and the GPL only abuses the laws/copyright to turn it upside down
[11:05:59] <LeoNerd> But a certain amount of coöperative coroutine support could be nice. I effectively write most of my code a bit like that anyway
[11:06:13] <LeoNerd> My toplevel tasks are all big switch() blocks operating on a static counter
[11:06:19] <liwakura> i think interrupts are enough for that time critical stuff
[11:06:24] <LeoNerd> So I can return and come back later. Since my tasks aren't reëntrant that's fine
[11:07:17] <twnqx> it's not about "time critical"
[11:07:33] <twnqx> did you ever count how many cycles the full register save + restore takes?
[11:08:23] <cehteh> i just split task in many steps. each of these is a function call which gets added to the queues
[11:08:32] <hetii> Hi
[11:09:15] <liwakura> twnqx: yeah, thats why just use interupts instead of full scheduling
[11:09:52] <cehteh> interrupts and scheduling are different things
[11:09:59] <twnqx> totally
[11:10:02] <hetii> I have two ir receiver, when I use standard remote controler, then I see led blinks on both, when I use instead attiny45 to send some ir codes just one of it get signal. I wonder why
[11:10:12] <cehteh> but i use interrupts to schedule jobs :D
[11:10:34] <liwakura> cehteh: but they are kinda two ways to achieve the same goal
[11:10:37] <cehteh> hetii: clock drift maybe?
[11:10:45] <liwakura> doing two things at more or less the same time
[11:11:07] <twnqx> but only if one of the two things is very small :P
[11:11:16] <liwakura> yeah, thats the caveat
[11:12:02] <liwakura> im currently going in the direction of having an synchronous blocking main and doing the timing and i/o mostly via interrupts
[11:12:30] <liwakura> but since i have no actual goal it doesnt matter much