#avr Logs

Mar 09 2017

#avr Calendar

02:48 AM Haohmaru: is it okay to use a GPL bootloader in a closed-source design (firmware and hardware) ? since technically the bootloader could be re-compiled and/or completely changed afterwards
02:52 AM Emil: The bootloader is separate from application data
02:52 AM Emil: yeah it's okay to use
02:53 AM Emil: You still have to provide the GPL bootloader on request
02:54 AM Emil: Also keep in mind that closed source hardware and software does not prevent pretty much anyone from understanding your device and doing things with it if needed
02:55 AM Haohmaru: yes, i'd have to provide instructions for how to change the bootloader..
02:55 AM Haohmaru: and source code of the bootloader if i've modified it (as usual with GPL)
02:56 AM Emil: Only if requested
02:56 AM Emil: And no
02:56 AM Emil: you don't need to provide information on how to change the bootloader
02:56 AM Haohmaru: hold on
02:56 AM Emil: only what you have used, the license to what you have used and where to get the vcode
02:56 AM Emil: code*
02:57 AM Emil: Very you seriously under the impression that you must provide instructions on how to hack you device? :D
02:57 AM Haohmaru: if you take a GPL'ed bootloader, it may not be ideal for your board, you may need to change something.. like the bootload condition, or the UART.. then you effectively modify the bootloader
02:57 AM Emil: yes, so?
02:58 AM Haohmaru: aren't you supposed to ship your stuff with the source code of the modified GPL bootloader then?
02:58 AM Emil: ...
02:58 AM Emil: wtf mate
03:45 AM crazy_imp: Emil: in the past, some router manufactures put CDs with the sourcecode into the package to fulfill the licenses.
04:45 AM Emil: crazy_imp: hehe
04:45 AM Emil: crazy_imp: well, if they want to fulfill the license that way :D
04:46 AM Emil: But I would never make such an expensive decision
04:46 AM crazy_imp: Emil: a piece of paper and a ftp server would be fine too
04:48 AM Emil: yeah
04:48 AM Emil: Could even be on the packacking
04:48 AM Emil: Or depending on the product, even on the manufactureres site
04:48 AM crazy_imp: yes, but with the cd, they can always say, you got it in the first place, no hassle to keep the server up and running for years
04:49 AM Emil: You don't have to keep it running for years
04:49 AM Emil: And having a cheap ass vps running costs wayyyy less
04:49 AM Emil: and is way less hassle
04:50 AM crazy_imp: well, guess in my case they put the handbook and some drivers on the cd too, so it was no real addition cost if I think about it
04:52 AM crazy_imp: s/addition/additional/
08:56 AM Emil: Anyone good with bash scripting?
08:56 AM cehteh: for what definition of good?
08:57 AM cehteh: #bash is quite helpful btw
08:59 AM theBear: i'm slightly beyond beginner level, slightly above that if i got a terminal handy to cheat/check some existing ones for reference
08:59 AM Emil: https://emil.fi/jako/koodi/script.sh do you see any issues with this?
09:00 AM Emil: Because I had issues with it working when I launch it myself but it seems to be failing when using cron
09:02 AM theBear: Emil, try specific/explicit path for screen/grep/any commands that might not have a proper/normal env(path specifically) set when run by cron
09:03 AM Emil: theBear: I'm making sure that the commands are available
09:03 AM Emil: I cd to the correct path
09:03 AM theBear: ooh, also consider user, often for testing something like sudo -u crontab script.sh is handy here
09:03 AM Emil: Tested
09:03 AM Emil: Hmm, that would be good
09:03 AM Emil: though
09:03 AM theBear: Emil, err, you do ? there no cd in that script i can see
09:04 AM Emil: Yeah the script is as minimal as possible
09:04 AM theBear: then how you know the commands are "available" ?
09:06 AM Emil: Hmm, it seems there is no user cron or crontab
09:06 AM cehteh: overuse of grep :D
09:07 AM cehteh: you may want to use pidfiles instead
09:08 AM theBear: Emil, that crontab was just an example/guess, but you get the idea what i was trying to show, been a long time, user is probly listed in crontab or other cron daemon specific config file
09:09 AM cehteh: ps aux output might be truncated and/or otherwise mangled, grepping for that can fail
09:09 AM theBear: also these days any remotely current install you probly "supposed" to use systemd stuff instead of cron to do this kinda thing, but i don't blame you if you got ANY reason not to do it that way, just mentioning
09:09 AM cehteh: blarg systemd
09:10 AM cehteh: also you may want to exec $COMMAND else you have a dangling shell, wont harm but isnt pretty
09:10 AM cehteh: and .. moment i have a very simple 'keepalive' script somewhere
09:10 AM theBear: erm, you sure that works as a normal user ? does screen -c mean something different on your machine than mine ?
09:12 AM theBear: oh, bash -c, hmm, you sure the script (not just the commands in it) work as a normal user ? (proves that it isn't an escaping problem right where i misread myself)
09:12 AM cehteh: http://paste.debian.net/918957/ thats already the improved version .. the simple one is just 2 lines :)
09:13 AM theBear: i still very suspicious that screen or bash (run by/within screen) without a path isn't an issue
09:13 AM cehteh: #!/bin/sh
09:13 AM cehteh: sleep 1
09:13 AM cehteh: $@ || exec $0 $@
09:13 AM cehteh: .. easiest way to keep something alive
09:14 AM Emil: https://emil.fi/jako/koodi/thisworks.sh
09:16 AM theBear: Emil, that makes me think escaping issues
09:16 AM theBear: escaping/quoting
09:16 AM cehteh: when you pass untrusted things into it
09:17 AM Emil: theBear: yeah
09:18 AM theBear: Emil, maybe have the first line from the not-working one, with just echo $COMMAND and run that as a normal user to see what you see
09:18 AM theBear: as a escaping test
09:19 AM theBear: tho i'm not sure that is a proper test, i'm terrible at this side of scripting (appropriate quotes/escaping for nesting stuff)
09:19 AM Emil: Without "" the echo will be injected
09:19 AM cehteh: you want something to restart when crashed right?
09:19 AM Emil: if I would do echo $COMMAND and $COMMAND was something like things; do; now;
09:19 AM Emil: yeah
09:20 AM cehteh: just do as i shown .. the 3 liner above as /usr/local/bin/keepalive
09:20 AM theBear: i mean the whole first 2 lines from the not working one, then a line replacing the entire if with echo $COMMAND
09:20 AM cehteh: and then keepalive ''screen -S name -d -m bash -c "while true; do commands; sleep 0.1; done;"
09:20 AM cehteh: and then keepalive 'screen -S name -d -m bash -c "while true; do commands; sleep 0.1; done;"'
09:21 AM cehteh: but why do you have thw loop there
09:21 AM cehteh: still too complicated
09:22 AM cehteh: and then keepalive 'screen bash -c "commands... "'
09:23 AM cehteh: and why do you use screen? daemonizing something? .. that works but isnt necessary
09:23 AM * theBear hasn't even considered working out what the loop/if stuff is actually sposed to do :)
09:23 AM Emil: daemonazing yeah
09:25 AM theBear: heh, if you had a script called the_education_system or perhaps young-persons you could demonize it for half a laugh worth of bad wordplay :)
09:25 AM cehteh: ( cd /; ( command ) & >&/dev/null ) & doublefork trick
09:25 AM cehteh: the 'command' there is the keepalive line
09:25 AM cehteh: and you may redirect to a logfile if you want
09:29 AM cehteh: ( cd /; ( keepalive bash -c 'commands' ) & >&/dev/null ) &
09:29 AM cehteh: boiled down your code to 3 lines :)
09:30 AM Dan39: hello \o
09:30 AM Dan39: if i use "avrdude -b 19200 -c usbtiny -p m328p -v -e -U flash:w:./ATmegaBOOT_168_atmega328.hex -U lock:w:0x0F:m" then after that do "avrdude -b 19200 -c usbtiny -p m328p -v -e -U flash:w:./myproject.hex -U lock:w:0x0F:m"
09:31 AM Dan39: will the first bootoader hex i wrote not get erased when the 2nd command is run with -e?
09:33 AM cehteh: just trying that out will give you an ansswer
09:33 AM cehteh: iirc chip erase does what it promises :)
09:33 AM Dan39: heh
09:34 AM Dan39: well i was kind of confused because i though the "bootloader" was in a separate section. it is just at the beginning of the flash i guess?
09:34 AM cehteh: chip erase is global as far i know
09:35 AM cehteh: just try and you find out
09:35 AM Dan39: find out how... -_-
09:35 AM cehteh: bootloader wont start anymore
09:35 AM cehteh: because its erased
09:35 AM Dan39: i have this script to run by my lead developer, but i think it is just completely broken: https://ptpb.pw/9Gu0
09:35 AM Emil: cehteh: can you put it into a file?
09:36 AM Dan39: it seems like 1st of all, the fuse writes dont work, 2nd the bootloader gets erased...
09:38 AM cehteh: Emil: http://paste.debian.net/918961/
09:38 AM cehteh: Dan39: fuses are latched, at least some of them, they need a powercycle
09:38 AM cehteh: to become effective
09:39 AM cehteh: Emil: you can try that with keepalive top
09:39 AM Dan39: cehteh: o that is good to know
09:39 AM cehteh: killall top should restart top
09:39 AM cehteh: but quitting it by pressing q should exit
09:40 AM cehteh: and for poor mans daemonizing you use use the ( cd /; ( keepalive bash -c 'commands' ) & >&/dev/null ) &
09:40 AM cehteh: replace 'commands' with something you want there, without a while loop
09:41 AM Emil: cehteh: thanks
09:41 AM Dan39: i wonder why he is setting efuse to 0x05 though... :\
09:41 AM cehteh: you may want to change the cd / and the redirection and also may want to redirect stdin to /dev/null
09:41 AM cehteh: depends on what you need
09:42 AM cehteh: cd into some safe dir is common because the 'current dir' of the process will keep a handle to that dir
09:42 AM cehteh: and double forking puts it into background, reparents the process to init
09:43 AM cehteh: not a 100% sane way but works 99% of the time
09:44 AM cehteh: real daemonizoing does some more tricks, new process group, setup signal handlers etc
09:47 AM Dan39: how do i write 2 hex files to flash, just do -e then two -U?
09:47 AM Dan39: in the same command i mean
09:47 AM cehteh: yes
09:48 AM cehteh: maybe fixup the addresses, rtfm (i dunno exactly too)
09:48 AM cehteh: or leave out the -e at the 2nd avrdude command
09:48 AM Emil: Dan39: I recentely saw some commands for that
09:49 AM Dan39: the man says -e is usually required whenever doing a flash write
09:49 AM Emil: Lemme find it
09:49 AM cehteh: 'usually'
09:49 AM cehteh: not always
09:49 AM Emil: It was actually linked to this channel too
09:49 AM Dan39: googling for this stuff gives crappy results tbh... :\
09:49 AM cehteh: avrdude manpage
09:50 AM Haohmaru: Dan39 are you trying to flash a firmware and a bootloader?
09:50 AM Dan39: yes
09:50 AM cehteh: most often one would flash the bootloader and then use that bootloader to flash the firmware :D
09:50 AM Dan39: though im not even sure the bootloader is needed
09:51 AM Emil: Dan39: http://www.avrfreaks.net/sites/default/files/bootloader_faq.pdf here you go
09:51 AM Haohmaru: i think the safest way is to flash the bootloader, then use the bootloader to flash the firmware, and then dump the whole thing to a hex
09:51 AM Emil: that explains pretty much everything
09:51 AM cehteh: if you dont know if you need the bootlaoder then you dont need it
09:51 AM Dan39: cehteh: yea i might have to ask the boss whats up with this procedure, it must not be right
09:51 AM cehteh: more often they cause problems
09:51 AM cehteh: esp with watchdogs enabled
09:51 AM Emil: That document eplains how to combine a bootloader and a application and how to flash starting from a different sectrion
09:51 AM Emil: and so on
09:51 AM Emil: explains*
09:52 AM Dan39: ah, nice
09:52 AM Dan39: im going to try without the bootloader
09:52 AM Emil: Bootloaders are kewl
09:52 AM cehteh: if you need them, yes
09:52 AM cehteh: but they can cause problems and are sometimes not really needed
09:52 AM cehteh: suck ups space too
09:52 AM Emil: True
09:53 AM cehteh: add boot delay .. and have bugs on their own
09:57 AM Dan39: whats "-U lock:w:0x0F:m" for? i see it often added to many commands, without explanation
09:58 AM Dan39: yes i know the man says it "locks the byte", so what does locking byte 0x0F do... ;|
09:58 AM Emil: The lock byte
10:00 AM Dan39: i think i get it now, that locks the chip from further changes unless a full erase is done
10:07 AM Emil: LeoNerd: you keep getting featured in oshpark ;)
10:15 AM cehteh: Dan39: that would make a bootloader useless
10:17 AM Dan39: ha
10:18 AM Dan39: hmm avrdude crashing trying to read eeprom to a file... *** Error in `avrdude': munmap_chunk(): invalid pointer: 0x0000562d41e8e380 ***
10:18 AM Dan39: it seems to finish to me though
10:19 AM Dan39: says the "done. goodbye"
10:19 AM cehteh: check if you have the most recent avrdude version
10:20 AM Dan39: avrdude version 6.3
10:21 AM Dan39: doesnt matter though, worked fine
10:22 AM cehteh: since its unmapping prolly harmless, but still a bug
10:40 AM julius: hi
10:41 AM julius: somebody here gave the the tip to test my cc/cv power source with a automobile light bulb....i have to say i finally got the current regulator to work. thank you very much :)
11:15 AM Lo is now known as LoRez
02:06 PM Emil: julius: glad to hear :)
02:10 PM Tachaway is now known as Tachyon`
02:51 PM JanC_ is now known as JanC
04:27 PM Tachyon` is now known as Tachaway
05:49 PM robinak is now known as robink
07:39 PM Rez is now known as LoRez
07:52 PM rue_house: julius, are you making a bench supply?
08:00 PM rue_house: Steffanx, you alive?
10:39 PM ENHering: hi
11:49 PM daey_ is now known as daey