#avr | Logs for 2016-04-10

Back
[01:46:05] <cehteh> why cmake?
[07:45:57] <edwardoid> Guys do you know any AVR timers/counters and PWM library implementation?
[07:48:47] <liwakura> you mean a library that counts time and drives pwm at the same time?
[08:06:50] <|DM|> I guess he meant a lib that implemented pwm through the timers/counters
[08:07:11] <|DM|> Is there any real demand for non-arduino avr libs ?
[08:07:48] <|DM|> besides the obvious avr-libc
[08:09:09] <lorenzo> |DM|: I don't think so
[08:09:13] <liwakura> i think the use cases are often so individualized
[08:09:29] <liwakura> that general libraries don't make much sense at this level
[08:09:41] <lorenzo> yeah
[08:09:48] <|DM|> Right, makes sense
[08:09:57] <lorenzo> it doesn't take much to write your own pwm_init() or timer_init() for your application
[08:10:02] <|DM|> The only lib sorta thing I looked for was a USB one
[08:10:04] <liwakura> UHM
[08:10:16] <liwakura> lorenzo: not if you are a beginner
[08:10:37] <|DM|> I dont think it would do a beginner good
[08:10:49] <|DM|> To use those if they didnt know how to write them themselves.
[08:10:53] <liwakura> hm
[08:11:01] <liwakura> also true
[08:11:11] <lorenzo> it's about learning basic concepts which you can then port to other microcontrollers / platforms
[08:11:30] <liwakura> i laerned it by just copying other's code :D
[08:11:33] <lorenzo> like, how to deal with interrupts, set gpio directions, etc
[08:11:37] <liwakura> and looking in the datasheet afterwards
[08:11:38] <lorenzo> arduino more or less hides all that
[08:11:51] <|DM|> And if they want that style of environment , there's the arduino package :D
[08:12:16] <liwakura> also, i made some cool thing these days
[08:12:31] <|DM|> share, not like this channel is busy anyways
[08:12:42] <liwakura> another 1 - command image hoster like the other 2643294 ones https://w1r3.net/
[08:13:10] <liwakura> not exactly related
[08:13:20] <liwakura> but whatever
[08:15:47] <|DM|> neato.
[08:42:36] <vincent_LP> hi there. May I ask a question about jtagice3 on Linux?
[08:50:44] <liwakura> vincent_LP: just ask
[08:51:03] <liwakura> if someone knows the answer he will reply
[09:07:26] <vincent_LP> Oh, thanks. I can use avrdude and jtagice3 to upload to my avr chip well, when I use avarice to connect jtagice3, it pop up <did not find any USB device "usb">
[09:08:14] <vincent_LP> someone knows the reason? my avarice version is: AVaRICE version 2.13svn20130104, Apr 8 2016 03:44:31
[09:19:27] <RikusW> try doing it as root
[09:19:33] <RikusW> it might be a permissions issue
[09:20:02] <liwakura> RikusW: you noticed the Hackaday post?
[09:20:10] <RikusW> which one ?
[09:20:33] <liwakura> your DebugWire thingie was sort of featured on hackaday.com a few days ago
[09:20:41] <RikusW> ah nice :)
[09:21:06] <liwakura> i was flying over the blog when i spotted your nick
[09:29:47] <vincent_LP> RikusW, emmm.. seems it works... thanks for your tip
[09:30:59] <vincent_LP> wait...strange, I have disconnected jtagice3
[09:33:13] <vincent_LP> is this correct command? : sudo avarice -j /dev/usb/hiddev1 --jtag3 --debugwire :4242
[09:33:41] <RikusW> no idea
[09:34:09] <RikusW> seems you might need to edit some udev rules to give yourself permission to use it
[09:35:54] <vincent_LP> jtagice3 shows as hiddev1, is it normal? coz, I saw avarice connect to </dev/avrjtag> as default
[09:35:58] <RikusW> vincent_LP: http://pastebin.com/TfT9Lp3t
[09:36:17] <RikusW> add vid and pid for jtice3
[09:36:49] <vincent_LP> RikusW, thanks
[09:59:45] <liwakura> uhm, in my avr program, i need to resolve command names to function pointers
[10:00:12] <liwakura> current setup is doing this via an generic acessor method with an big if elseif -construct
[10:00:40] <liwakura> does someone know a less messy design?
[10:21:02] <RikusW> liwakura: you could use a loop and lookuptable
[10:21:24] <liwakura> would i need to define the loopuptable manually?
[10:21:36] <RikusW> yep
[10:21:40] <liwakura> shit
[10:22:01] <RikusW> how many commands ?
[10:22:03] <liwakura> because the pointers vary for every build
[10:22:13] <liwakura> currently 4, but i plan way more
[10:22:18] <RikusW> why would that be a problem ?
[10:22:35] <liwakura> i just want it that i can define another command, and its easily included
[10:22:58] <sabor> then use a script to generate the lookup table
[10:22:58] <RikusW> will be the same amount of work as an if/else
[10:23:23] <liwakura> sabor: hm.
[10:23:44] <RikusW> liwakura: I assume all functions use the same parameters and return type ?
[10:23:57] <liwakura> RikusW: definitely.
[10:24:48] <liwakura> i just need some way to find their adresses depending on their name
[10:24:50] <RikusW> use a struct { const char *command; function fptr; }
[10:24:58] <RikusW> just use the name itself
[10:25:10] <liwakura> ay
[10:25:17] <liwakura> and an array of such in the progmem?
[10:25:20] <RikusW> (function would be a typedef)
[10:25:24] <liwakura> understand
[10:26:44] <liwakura> i'd still have to add additional commands manually i guess, but at least i don't need that if/else cascade anymore
[10:27:53] <RikusW> yes
[10:29:52] <RikusW> http://c.learncodethehardway.org/book/ex18.html
[10:30:37] <RikusW> just google function pointer C
[10:30:48] <RikusW> you'll get more than enough results ;)
[10:30:53] <Lambda_Aurigae> liwakura, look at procyon avrlib
[10:31:04] <Lambda_Aurigae> there is a command processor lib in there.
[10:31:11] <Lambda_Aurigae> it's actually somewhat dynamic.
[10:31:12] <liwakura> oh, the function pointer itself is no problem for me, i did that on a pc
[10:32:07] <liwakura> Lambda_Aurigae: sounds interesting, but i can't connect to their site
[10:32:36] <liwakura> but i found this stuff instead: https://github.com/dreamiurg/avr-liberty
[10:32:42] <Lambda_Aurigae> http://www.procyonengineering.com/embedded/avr/avrlib/
[10:32:46] <Lambda_Aurigae> that doesn't work?
[10:33:17] <liwakura> uhm
[10:33:19] <Lambda_Aurigae> aahh..haven't seen the one you posted.
[10:33:40] <Lambda_Aurigae> it looks like a mod from procyon's lib.
[10:33:41] <liwakura> looks interesting
[10:34:25] <Lambda_Aurigae> I used avrlib for years.
[10:34:34] <Lambda_Aurigae> lots of examples too.
[10:34:41] <Lambda_Aurigae> it is somewhat old, 10 years since last release.
[10:34:58] <Lambda_Aurigae> back in the day I used to email back and forth with the creator.
[10:35:00] <ferdna> someone here gave me a url to current64 isos...
[10:35:31] <Lambda_Aurigae> never heard of it ferdna
[10:36:00] <liwakura> Lambda_Aurigae: that github thingie is really great
[10:36:07] <liwakura> already working code for like, everything
[10:36:27] <Lambda_Aurigae> yup.
[10:36:33] <Lambda_Aurigae> they even did the cmdline portion.
[10:36:36] <liwakura> even an vt100 emulator
[10:36:40] <liwakura> absolutely
[10:36:44] <liwakura> awesome
[10:37:01] <Lambda_Aurigae> combine that with Jartza's octapentaveega.
[10:37:33] <liwakura> omg
[10:37:47] <liwakura> wtf wtf
[10:37:53] <Lambda_Aurigae> he does some nifty vt100 emulation in there..
[10:37:58] <Lambda_Aurigae> along with some extensions.
[10:38:45] <Lambda_Aurigae> you can use your avr to output to a vga monitor through an attiny85
[10:38:51] <liwakura> do you know what i really need?
[10:38:54] <liwakura> some sort of terminal
[10:39:00] <liwakura> like a screen and keyboard
[10:39:06] <liwakura> and a serial plug on the backside
[10:39:16] <liwakura> maybe even as handheld
[10:39:34] <Lambda_Aurigae> should be easily doable.
[10:39:51] <liwakura> i tried it once and accidentally killed my lcd display
[10:39:58] <Lambda_Aurigae> get an older ps/2 keyboard and tie it to an avr...output from that to the octapentaveega.
[10:40:10] <liwakura> yeah
[10:57:41] <liwakura> god this lib is so fucking awesome
[11:04:49] <Chillum> amazing what you can do with 8kb flash
[11:05:04] <Chillum> attiny85s are one of my favourite avrs
[11:25:31] <RikusW> http://www.atmel.com/webdoc/protocoldocs/ch01s02.html
[11:32:34] <ferdna> Lambda_Aurigae, lol... wrong channel
[11:32:37] <ferdna> just realized it
[12:48:23] <liwakura> uhm
[12:48:38] <liwakura> is the arduino bootloader protected from reading?
[12:48:45] <liwakura> im just getting the address back
[12:49:14] <Casper> liwakura: most likelly yes
[12:49:20] <Casper> lock fuses are most likelly set
[12:49:50] <liwakura> it doesn't seem logical why read access should be denied
[12:50:04] <Casper> quite the contrary
[12:50:32] <Casper> why would you leave read access to the flash when you have a bootloader that may be used to secure the app?
[12:50:56] <Casper> copy protection
[12:51:26] <liwakura> hm.
[12:51:53] <Casper> the direct write access will also be denied, so you can't flash an application that will then read the bootloader code and spit it out so you can copy it
[12:52:16] <Casper> you need to use the bootloader to write, or erase the chip first
[12:52:20] <liwakura> i think writing flash at runtime is a bad idea anyway
[12:52:36] <liwakura> https://ucexperiment.wordpress.com/2014/12/19/reading-an-avr-bootloader-from-the-application-section/
[12:53:08] <liwakura> interesting.
[12:53:31] <LoRez> the arduino bootloader is not protected from reading on arduinos.
[12:54:21] <liwakura> LoRez: you sure? because pgm_read_byte(&bootloader + n) always returns n & 0xFF
[12:54:28] <liwakura> Atmega328p
[12:54:45] <LoRez> which arduino are you using?
[12:54:59] <liwakura> Nano Clone
[12:55:02] <LoRez> CLONE.
[12:55:06] <LoRez> NOT AN ARDUINO
[12:55:20] <liwakura> it should depend on the bootloader
[12:55:26] <liwakura> and the fuse bits
[12:55:51] <liwakura> since its an actual atmega328p
[12:56:12] <LoRez> There's no reason to hide the bootloader on an actual arduino.
[12:56:31] <liwakura> i honestly would not hide the bootloader at all
[12:56:54] <LoRez> I would if it was holding custom code and decryption keys.
[12:57:15] <liwakura> who should not be able to read them?
[12:58:08] <LoRez> depends on the device.
[12:59:04] <liwakura> security on avr is a messy thing
[12:59:13] <liwakura> because in most cases you have physical access anyways
[12:59:46] <liwakura> im currently just assuming that i have a custom bootloader that just happens to act like the arduino one
[13:00:02] <cehteh> huh .. arduino locks fuses?
[13:00:16] <liwakura> cehteh:
[13:00:23] <liwakura> > pgm_read_byte(&bootloader + n) always returns n & 0xFF
[13:00:27] <liwakura> we discuss why
[13:00:38] <cehteh> i havent checked that, but looks strange to me
[13:00:52] <cehteh> well check the fuses
[13:01:27] <cehteh> makes no much sense to lock the bootloader from reading
[13:01:30] <liwakura> i guess i'll just set eof to &bootloader, so it just acts like the flash is ending there
[13:01:35] <liwakura> cehteh: thats why i was wondering
[13:02:04] <cehteh> you read the datasheet about where the bootloader sections is?
[13:02:47] <cehteh> i havent done such stuff yet, when its there i just use the bootloader as is, unless i need more program space where i erase the chip :D
[13:02:49] <liwakura> judging from the fact that i program via USB Serial and that there is another interrupt table at 0x7800 (RAMEND is 0x7FFF)
[13:03:07] <cehteh> you have an ISP?
[13:03:17] <cehteh> read fuses and check
[13:03:21] <liwakura> i own one.
[13:03:30] <liwakura> i haven't solved the mystery where it is
[13:03:37] <cehteh> (can the fuses be read protected themself?)
[13:03:38] <RikusW> liwakura: properly set lockbits will prevent reading the bootloader even from ISP
[13:03:52] <RikusW> so there will be no way to read it
[13:03:59] <RikusW> unless you decap the ic...
[13:04:05] <cehteh> RikusW: but locking it down that much wont make sense for a open source project
[13:04:14] <RikusW> indeed
[13:04:14] <liwakura> cehteh: i have to add
[13:04:36] <liwakura> its an Arduino Clone, and i started with literally no documentation beside the Atmega328p Datasheet
[13:05:25] <liwakura> but the currently installed bootloader lets me read itself when i talk to him after reset
[13:05:48] <liwakura> ah, found my ISP
[13:06:23] <cehteh> liwakura: i use nano clones too
[13:06:27] <liwakura> also, im a bit mad because my ISP is basically just an Atmega8 or something which directly talks to USB, but the one i can program just has a serial console
[13:06:38] <cehteh> but i never checked the bootloader, just using it
[13:07:07] <liwakura> yeah, they were quite cheap
[13:07:14] <cehteh> works for me
[13:07:38] <liwakura> also my one didn't had their dupont pins soldered, so i could plant my own stuff in the pin holes instead
[13:07:47] <liwakura> (no sexual innuendo intended)
[13:07:58] <cehteh> sometimes i prefer that
[13:33:57] <liwakura> RikusW: currently imprementing the progmem lookup table and command function pointer, but now im wondering
[13:34:12] <liwakura> aren't the jump addresses always half of the progmem addresses?
[13:34:54] <RikusW> program memory and pointers work in word addressing afaik
[13:35:12] <cehteh> not sure about any kind of progmem pointer
[13:35:25] <cehteh> but code is word addressed
[13:35:44] <liwakura> but progmem data is byte-addressed
[13:35:51] <cehteh> could be
[13:35:55] <liwakura> pgm_read_byte from progspace.h
[13:35:55] <RikusW> lpm does use byte addressing though, confusing....
[13:36:00] <cehteh> yes
[13:36:08] <liwakura> thats why im worrying
[13:36:16] <cehteh> i dont care, just works for me :D
[13:36:18] <RikusW> but the PC is word adressed
[13:36:35] <liwakura> cehteh: have you used callbacks somewhere?
[13:36:43] <cehteh> yes
[13:36:48] <liwakura> muos?
[13:36:58] <liwakura> i'd like to inspect that code
[13:37:01] <cehteh> ah moment thes are currently static
[13:37:10] <liwakura> hm okay
[13:37:25] <cehteh> i am planning to add function tables at some point and have some indirection
[13:38:06] <cehteh> that will save a lot ram for the queues
[13:38:44] <liwakura> im just compiling and hoping that the compiler takes care of that problem
[13:38:57] <cehteh> if you do that right, then it does :D
[13:39:16] <cehteh> i have some code for progmem strings, that was quite easy
[13:39:22] <liwakura> since i get the pointer with &funcname in the first place, it might be using word addressing in both places
[13:39:33] <liwakura> at least it could cancel itself out
[13:40:25] <cehteh> i am doing little evil things as i am borrowing a bit from pointers to mark what type of function i have on the queues
[13:40:49] <cehteh> (either with one intptr_t argument or no arguments)
[13:41:15] <cehteh> that will break with avr's with more than 64k flash
[13:41:34] <liwakura> this also implies byte addressing for function calls
[13:41:39] <cehteh> no
[13:41:39] <liwakura> or am i wrong?
[13:41:43] <liwakura> oh
[13:41:47] <liwakura> MSB bit i guess
[13:41:55] <liwakura> shit
[13:42:04] <cehteh> was my fault at first too .. i thought functions are even aligned and i can abuse the lowest bit
[13:42:11] <cehteh> but yes that did not work
[13:42:16] <cehteh> highest bit works
[13:42:20] <cehteh> :)
[13:42:22] <liwakura> but
[13:42:27] <liwakura> if the LSB did not work
[13:42:39] <liwakura> means that function pointers are word aligned
[13:42:50] <cehteh> that means these pointers are word addressed
[13:43:05] <liwakura> ah fuck it im just gonna hexdump it :D
[13:43:09] <cehteh> not word aligned but word addressd
[13:43:47] <cehteh> and i tried to add gcc's function alignment attribute too .. but thats ugly
[13:44:09] <cehteh> maybe later i make this configureable, using different strategies
[13:44:34] <cehteh> on chips with a lot flash usually you have a lot ram too so i dont need to preseve ram that much either
[13:45:03] <cehteh> havent tried yet, i dont have any avr with more than 32k flash here
[13:45:25] <cehteh> other-people-problem :D
[13:45:26] * RikusW got a few mega128s
[13:45:43] <RikusW> there is a special register for the MSB
[13:45:45] <cehteh> eventuall i will port muos to stm32
[13:45:56] <cehteh> there i need to care then
[13:46:07] <cehteh> but for now i target small and smallest chips
[13:46:27] <cehteh> (oh i have some attiny13, i may try that)
[13:46:42] <cehteh> that might be a little tight :D
[13:48:58] <liwakura> hm.
[13:49:47] <liwakura> it is enough just to give the functions i want to call the exact same arguments like the callback typedef?
[13:50:31] <liwakura> because i don't know where the compiler will store the arguments
[13:51:35] <liwakura> hm, it works on the signal() function on unix, so i'll assume it will also work here
[13:52:00] <cehteh> of course
[13:52:20] <cehteh> i'd typedef that
[13:52:40] <cehteh> and eh yes .. i use that of course for my schduler
[13:53:03] <cehteh> one passes function pointers to the queueing function
[13:53:26] <cehteh> havent thought of it as 'callback' :D
[13:54:01] <cehteh> and that just works in plain C without any second thought
[13:54:10] <liwakura> cehteh: you haven't commited anything for a while
[13:54:15] <liwakura> okay
[13:54:29] <cehteh> i did
[13:54:32] <cehteh> other branches :D
[13:54:40] <cehteh> currently working on the 'doc' branch
[13:54:40] <liwakura> hm
[13:55:11] <liwakura> i only got the master branch
[13:55:31] <cehteh> git remote update; git branch -r
[13:56:02] <cehteh> the master is a bit older, moved to other branches for some work to be merged later
[13:56:08] <liwakura> i have no idea what i just did
[13:56:17] <liwakura> i'll do the git learning later
[13:56:58] <cehteh> git remote update fetches things from my server
[13:57:08] <liwakura> nono
[13:57:11] <cehteh> git branch -r lists the *remote* branches
[13:57:23] <liwakura> im currently doing callbacks on my avr
[13:57:29] <cehteh> you only have the master branch .. thats *your* master branch, not mine
[13:57:34] <cehteh> ah :D
[13:58:38] * cehteh just pushed the doc branch up .. but there isnt much yet, only infrastructure to generate docs
[14:27:15] <liwakura> im just using 3.5 kb of flash but it feels so bloated
[14:59:38] <RikusW> https://www.16personalities.com/free-personality-test
[15:01:41] <WormFood> What's the difference between a regular AVR, and the "automotive" version of the same chip?
[15:06:18] <RikusW> for one I think greater temperature range
[15:06:21] <WormFood> To answer my own question, it just appears to be increased operating temp range.
[15:06:44] <WormFood> That appears to be the only difference from what I can see.
[15:06:57] <WormFood> That, and lack of a PDIP
[15:32:37] <liwakura> does anyone spot an error?
[15:32:38] <liwakura> https://w1r3.net/WhApJyjd.txt
[15:32:44] <liwakura> the while loop never breaks
[15:35:41] <liwakura> i think i messed up the reads and dereferences somehow
[15:41:57] <liwakura> oh
[15:42:23] <liwakura> it DOES return
[15:42:28] <liwakura> nevermind
[15:42:43] <WormFood> I wished everything was that easy to fix.
[15:43:32] <WormFood> I was having a problem with my ADC. It was returning an unusually low value. I was thinking "WTF". Yeah, it's low voltage because it wasn't plugged into that voltage source.
[15:43:50] <WormFood> As soon as I plugged that in, it worked fine.
[15:44:09] <liwakura> hm, my problem isn't solved yet
[15:44:37] <WormFood> Right. but the problem of the loop not breaking, is solved :P
[15:44:57] <liwakura> the thing is, it alwary goes into that return ERROR thingie
[15:45:02] <liwakura> = the strings don't match
[15:48:53] <liwakura> also, the p pointer goes rogue
[15:50:34] <RikusW> do you have a simulator ? AVR Studio does have one.
[15:51:11] <RikusW> you'll need to use strcmp not == as that compares the pointers...
[16:14:33] <liwakura> okay, i closed down the problem a bit
[16:44:47] <liwakura> aaand i was wrong again
[16:45:00] <liwakura> just asked for the completely wrong variable at some place
[16:45:14] <liwakura> and i misinterpreted the symptoms the whole time
[16:45:43] <WormFood> I hate it when that happens
[16:45:50] <liwakura> the good news is, the progmem lookup table RikusW suggested works now
[16:46:22] <RikusW> nice
[16:48:25] <learath> hate that.
[16:48:28] <learath> PEBKAC
[16:50:58] <liwakura> sorta
[16:51:22] <liwakura> also, i figured out the function pointers are indeed word pointers