#avr Logs

Feb 25 2017

#avr Calendar

12:17 AM daey_ is now known as daey
02:00 AM malinus_ is now known as malinus
02:27 AM hetii: Hey :)
02:36 AM Casper: hetii: shhhh
02:40 AM hetii: Always when I look into arduino project code I feel similar to watching PHP4 code from old days :/
02:40 AM hetii: it works but the mixture of code style kill my eyes ...
02:41 AM malinus: hetii: when browsing random projects? Or the arduino project itself?
02:41 AM hetii: most random one.
02:42 AM malinus: What do you expect? A lot of people are learning programming with arduino.
02:43 AM malinus: uint8_t (*get_set_arr(volatile uint8_t (*ptr)[0x200], char *str))[][0x300]
02:43 AM malinus: hehe
02:43 AM malinus: who needs typedef anyway
02:43 AM hetii: hehe :)
02:44 AM hetii: maybe some of you know if there is some project that offer some driver pack for different uC ?
02:44 AM hetii: some generic way with nice structure and interface api.
02:47 AM _ami_: malinus: recent C++0x does not help in either. lots of sugary syntax.
02:48 AM hetii: I would love to see something like this as a git submodule that can be easy added to any project whatever if its ARM/AVR/PIC arch...
02:49 AM malinus: hetii: arduino does just that :)
02:49 AM hetii: ehh ...
02:49 AM malinus: _ami_: well it's C, so nothing that can help me at all :)
02:50 AM _ami_: by your example, i was imagining how ugly is to write a anonymous lambda function in C++0x :)
03:34 AM polprog: hetii: i think i chose wisely not getting an arduino, and going straight intio AVRs instead
03:36 AM _ami_: polprog: arduino is actually attracting new developers. its nice! but it has limitations.
03:36 AM _ami_: i did not know abt AVR if i was not introduced to Arduino.
03:37 AM _ami_: although i got bored with arduino in few days. it was just too easy
03:38 AM malinus: well it depends on what your goal is
03:39 AM malinus: Is your goal to learn about 8-bit mcu's, or to make a mcu do something specific?
04:22 AM rue_house: I started with avrs before arduino existed
04:22 AM rue_house: :P
04:22 AM polprog: arduinos were around for quita a long time
05:10 AM malinus: rue_house: old man :P
05:27 AM polprog: wow, i was 7 when i heard about arduinos
06:13 AM polprog: what's the default C version of avr-gcc?
06:13 AM polprog: c98?
06:42 AM Emil: Hmm
06:42 AM Emil: Oooh interesting
06:42 AM Emil: AVR's also have startup code
07:02 AM specing: all micros do
07:37 AM yids_ is now known as yids
08:04 AM LeoNerd: ENHering[m]: I am now - what are you after?
08:27 AM polprog: Emil: you mean the "bootloader"? You can place a jmp instruction on RESET isr vector
09:59 AM inductiv- is now known as inductiveload
10:09 AM ENHering[m]: LeoNerd: I was looking for a bridge between free node and matrix.org when I found you r name. Is that you?
10:13 AM Jartza: https://lowerstrata.net/post/slib-part1/
10:29 AM LeoNerd: ENHering[m]: Sortof, but not very. I'm not the maintainer of the IRC bridge
10:29 AM LeoNerd: But I do other matrix things
11:28 AM Emil: polprog: no
11:29 AM Emil: polprog: there is actual start up code
11:30 AM Emil: specing: but avr's nicely abstract it away
11:32 AM Emil: The heck is matrix.org
11:32 AM DKordic: AFAIK Matrix is the bridge between various chat... systems.
11:33 AM Emil: seems like xkcd 927
11:33 AM DKordic: I agree :) .
11:44 AM Emil: polprog: a stack pointer is set and things
11:54 AM milosz96: hi all, is there any C library (not arduino) for oled display (i2c/twi ssd1306), or at least library for i2c/twi? I'm using atmega8
11:58 AM Emil: i2c/twi absolutely
11:58 AM Emil: ssd1306 highly likely
11:58 AM Emil: Have you tried googling it?
12:10 PM milosz96: Emil: yep, i found some in asm and some for arduino. Also found this: https://github.com/tibounise/SSD1306-AVR. I compiled and flashed it, connected display to avr, but it doesn't work, i have no idea from where should i start debugging it
12:12 PM Emil: milosz96: try looking at the Arduino lib
12:12 PM Emil: they are pretty much all just C code because perf
12:13 PM Emil: I wrote my own 8x8 led driver and had to look there because the datasheet wasnt clear
12:25 PM milosz96: Emil: ok, i'll look
12:25 PM milosz96: thanks :)
12:44 PM rue_house: the way to squash excess standards is to have china flood the market with a cheap device that uses one of them
01:21 PM Emil: milosz96: come baxk if you dont find a solution or cant get them working
01:22 PM Emil: and we can try to gelp
01:22 PM Emil: rue_house: that's true
04:05 PM Jartza: hmmh
04:05 PM Jartza: I think I got avr-gcc working with attiny817 now, but the next challenge is avrdude
04:08 PM Jartza: might be there's no support for UPDI or attiny817 at all yet
04:08 PM Jartza: should I make audiobootloader to attiny817 :)
04:13 PM malinus: Jartza: I thought bootloaders would work on most avr's
04:13 PM malinus: (the same one)
04:25 PM Emil: malinus: it's not about the bootloader
04:25 PM Emil: it's about having bootloader programming ability ;)
04:36 PM Jartza: malinus: depends of the bootloader
04:37 PM Jartza: fun side-note
04:38 PM Jartza: I downloaded atmel "pack" for attiny-processors
04:38 PM Jartza: shenanigans:attiny817 jartza$ ls -l
04:38 PM Jartza: total 0
04:38 PM Jartza: drwxr-xr-x@ 4 jartza staff 136 Dec 6 15:16 avrxmega2
04:38 PM Jartza: drwxr-xr-x@ 3 jartza staff 102 Dec 6 15:16 device-specs
04:38 PM Jartza: so... attiny817 core indeed IS basically xmega
04:38 PM Jartza: but tiny :D
04:39 PM Jartza: # Auto-generated specs for AVR device attiny817 (core avrxmega2, 16-bit SP)
04:44 PM Tordek: hi
04:44 PM Tordek: I have an usbasp that I used to program an atmega328p successfully... once... but when I set the lflag to 0xE0 (external clock, 65ms delay), I just cannot get a reply from it anymore
04:44 PM Jartza: avrxmega2 - XMega core with 8K to 64K program memory and less than 64K RAM
04:44 PM Tordek: I tried feeding it a 10mhz clock to no avail, and I tried putting it into my uno board (with a... 16mhz?) crystal on it), nothing
04:44 PM Tordek: ideas?
04:45 PM Jartza: are you using crystal or oscillator to feed the clock?
04:45 PM Tordek: I plugged it into my uno board, that should be giving it a 16mhz clock
04:46 PM Tordek: and my oscillometer says there's activity there
04:46 PM Tordek: oscilloscope
04:46 PM Tordek: thingie
04:48 PM Jartza: umm?
04:48 PM Jartza: where exactly you plug it in your uno board, and what sketch is running in uno
04:48 PM Jartza: lfuse as 0xE0 expects external *clock*, not oscillator
04:48 PM Jartza: there's a difference
04:49 PM polprog: Tordek, did you connect the signal as in the datasheet? everythings there
04:49 PM Tordek: polprog: yes... I think, at least
04:49 PM polprog: clock is a square wave, FYI
04:49 PM Tordek: I just put the 328 into the slot and the isp header into the isp connector
04:50 PM polprog: i guess youre reprogramming fuses, right?
04:50 PM Tordek: yes
04:50 PM Jartza: uhh
04:50 PM Jartza: Tordek: arduino UNO board has *crystal*
04:50 PM Jartza: not oscillator
04:50 PM Tordek: ok, so I could try to feed it by using my other (working) uno to generate a square wave by just toggling a foot
04:50 PM Jartza: and you have programmed your fuses for oscillator
04:50 PM Tordek: a foot, sorry. a leg
04:50 PM Jartza: yes
04:51 PM Jartza: you could create some kind of clock by that
04:51 PM Tordek: alright, I'll give that a shot
04:51 PM Jartza: if you use arduino uno board, you need to burn fuses for external crystal (which uses 2 pins), whereas external clock always only uses one pin
04:52 PM Tordek: Jartza: right, I needed extosc as per the project I'm using(outside the uno board)
04:52 PM Jartza: you connect external clock to XTAL1 pin
04:52 PM polprog: Tordek, its a 4 pin device you are thinking about, right?
04:53 PM Tordek: polprog: 28
04:53 PM Tordek: atmega328p
04:53 PM polprog: the oscillator
04:53 PM polprog: not the avr itself
04:53 PM Jartza: oscillators have 4 pins usually, yes
04:53 PM Jartza: crystals have 2
04:53 PM Jartza: for crystals, you also need two caps, usually
04:53 PM Tordek: oh... no clue actually, I gotta ask
04:53 PM Tordek: (I don't have the other devide on me)
04:54 PM polprog: i just wanted to clear it out, because you may have mistaken the terms
04:54 PM Tordek: www.instructables.com/id/GPSDO-YT-Disciplined-Oscillator-10Mhz-Reference-Fr/ it's for this project
04:54 PM Tordek: and the picture it uses to show the flags set it to extosc
04:54 PM polprog: unfortunately some people use them interchangeably
04:55 PM Tordek: indeed that's highly likely, I'm a huge noob in this
04:55 PM Lambda_Aurigae: then there's ceramic resonator..which has 3 pins and no need for caps
04:55 PM polprog: i cant open that link on mobile
04:55 PM Jartza: anyway. in order to run your chip on uno-board, you need to burn fuses to external crystal
04:55 PM Jartza: Lambda_Aurigae: strictly speaking, it also needs caps, but they are usually built-in :)
04:55 PM polprog: read the datasheet to get the proper values
04:56 PM polprog: or use a calculator
04:56 PM polprog: *fuse calc
04:56 PM Tordek: Jartza: right, however the problem is that I can't talk to the microcontroller right now
04:56 PM Tordek: but I'll try the "use another avr as a clock" option
04:56 PM Lambda_Aurigae: or a 555 timer
04:57 PM Lambda_Aurigae: or a pair of transistors a cap and a couple resistors.
04:57 PM Lambda_Aurigae: and a schmidt trigger.
04:58 PM polprog: its easier and better to buy an xtal oscillator unless you want some weird freq
04:59 PM Lambda_Aurigae: I've used the 555 timer method several times....just has to be fast enough.
04:59 PM Lambda_Aurigae: for programming the chip that is.
05:00 PM Lambda_Aurigae: I also used 556 in a dual-mode twisted configuration to produce free running or single step operation with variable speed...just for screwing around and kindasorta debugging
05:05 PM Tordek: polprog: aye, the issue is _right noe_ it's not set to xtal, so I can;t do anything; afterwards, yes, it's meant to be fed by the ceramic resonator
05:05 PM Jartza: Tordek: https://gist.github.com/Jartza/361189f2a1b3e7db48612bdc32d03a6f
05:06 PM Jartza: then connect GNDs together and take clock from arduino pin 9, or atmega328p pin 15
05:07 PM Jartza: so atmega328p -> xtal1 on the "dead" atmega
05:07 PM Tordek: Jartza: thanks, I'll give it a shot in a bit, after I'm out of here
05:10 PM Jartza: seems to give pretty much 2MHz clock on my arduino uno
05:10 PM Jartza: that code above, I mean
05:10 PM Jartza: you might need to slow down the programming using -B switch to avrdude then
05:11 PM Jartza: like -B4 etc
05:13 PM Tordek: ok, then I might have to look into that
05:13 PM Tordek: because my usbasp emits a warning about not setting the speed
05:13 PM Tordek: and maybe check firmware
05:19 PM Tordek: (or maybe I'll try to get a 555 and set a higher clock)
05:20 PM Jartza: Tordek: good luck getting higher than 2MHz out of 555 ;)
05:21 PM Jartza: most 555s have max. freq of 2MHz
05:21 PM Lambda_Aurigae: yeah.
05:21 PM Lambda_Aurigae: I run mine around 1MHz
05:21 PM Lambda_Aurigae: but I don't use usbasp either.
05:21 PM Tom_itx: dos guru's present?
05:21 PM Lambda_Aurigae: stk200 works well even at low clock frequencies.
05:21 PM Lambda_Aurigae: Tom_itx, used to be....
05:22 PM Lambda_Aurigae: haven't used dos in years.
05:22 PM Tom_itx: me too :D
05:22 PM Tom_itx: got a chinglish lpt card with drivers but no directions
05:22 PM Lambda_Aurigae: can remember much though
05:22 PM Lambda_Aurigae: config.sys for the win!
05:22 PM Tom_itx: dos recognizes it but i can't find it
05:22 PM Lambda_Aurigae: huh?
05:23 PM Lambda_Aurigae: which lpt address you using?
05:23 PM Tom_itx: i dunno
05:23 PM Lambda_Aurigae: there are 3 as I recall.
05:23 PM Tom_itx: it maps it to lpt2 on the first try
05:23 PM Tom_itx: 278 iirc
05:23 PM Tom_itx: i think lpt1 is 378
05:23 PM Tom_itx: but it doesn't show up in debug 00:400
05:24 PM Tom_itx: so i can't find it to use it
05:24 PM Tom_itx: i know it's active because the printer burps every time i reboot
05:24 PM Lambda_Aurigae: might be one of those odd ones that needs a driver loaded in the config.sys
05:24 PM Jartza: Tordek: https://drive.google.com/file/d/0B2dTzW9TMeBxYTZmaGxTT19VV1U/view?usp=sharing
05:24 PM Jartza: anyway. that's the output from the code I pasted.
05:24 PM Tom_itx: didn't come with any that i can find
05:25 PM Lambda_Aurigae: try 3BC ?
05:25 PM Tom_itx: it says to add a xx.exe to the autoexec
05:25 PM Lambda_Aurigae: rather than 278
05:25 PM Tom_itx: i tried all 3
05:25 PM Lambda_Aurigae: aahh..loader...yeah..it's one of the "soft" ports.
05:25 PM Tom_itx: it assigns the next available
05:25 PM Lambda_Aurigae: without the software you are screwed.
05:25 PM Tom_itx: my bios won't let me set the onboard one to an address
05:26 PM Tom_itx: i looked a the chip and may try to find a generic one for the chip
05:26 PM Lambda_Aurigae: it's a userland driver...basically that software sets the thing up.
05:26 PM Lambda_Aurigae: it's not so much a driver as software configurable.
05:26 PM Lambda_Aurigae: probably no jumpers on the board.
05:27 PM Tom_itx: nope
05:28 PM Tom_itx: it was only $6
05:28 PM Tom_itx: pretty spendy by china standards
05:28 PM Tom_itx: :D
05:28 PM Tom_itx: it has no com port but i had to use the com/lpt driver since the chip has it available
05:29 PM Lambda_Aurigae: those were late in the dos era as I recall.
05:29 PM Tom_itx: they don't tell you that
05:29 PM Tom_itx: i'm trying to fix up a modern machine for a dos app
05:29 PM Lambda_Aurigae: I bet the com port is on there...just needs the extra bits to make it active.
05:29 PM Tom_itx: so far that's the last thing to fix
05:29 PM Tom_itx: yeah i'm sure
05:29 PM Lambda_Aurigae: is that a pci card or isa?
05:30 PM Tom_itx: pci
05:30 PM Lambda_Aurigae: I have a bunch of old isa parallel port cards here.
05:30 PM Tom_itx: so do i
05:30 PM Tom_itx: no isa plug
05:30 PM Tom_itx: pci and pcie
05:31 PM Lambda_Aurigae: I just acquired a couple of dell i5 laptops with docking ports and the docking ports have both serial and parallel ports...
05:31 PM Tom_itx: it's been to long for me to write a remap com file
05:31 PM specing: Lambda_Aurigae: same with Thinkpads
05:31 PM Lambda_Aurigae: and they aren't the usb connected type either..these appear to be fully functional.
05:31 PM specing: Lambda_Aurigae: there is a Thinkpad dock that has a PCI-e x16 slot within
05:32 PM Lambda_Aurigae: nice.
05:32 PM Lambda_Aurigae: put a nice video card in that sucker.
05:32 PM specing: its damn YUUUUGE
05:32 PM Lambda_Aurigae: I bet.
05:32 PM specing: its only x1 electrical though :(
05:32 PM Lambda_Aurigae: I have an old p-4 gateway laptop with a docking station with a pair of pci slots in it
05:33 PM Lambda_Aurigae: that thing has composite video in and out on the laptop too...
05:33 PM Tom_itx: it defaults to E800
05:33 PM polprog: i had a thinkpad x600 but it died recently...
05:33 PM Lambda_Aurigae: Tom_itx, that's really,,,fucked up.
05:34 PM Lambda_Aurigae: I just discovered today that the new motorola phones are now made by lenovo.
05:34 PM Lambda_Aurigae: I hope they have the same high gain antenna that the old motorola phones had.
05:34 PM Tom_itx: err no: E000
05:34 PM Tom_itx: and i'm still trying to remember where all the stuff is at 00:0400
05:35 PM Tom_itx: found the com ports and 1 lpt
05:35 PM Lambda_Aurigae: http://www.luberth.com/cstep/parallel.htm
05:35 PM Tom_itx: around 00:420 is the kbd ring buffer
05:37 PM Tom_itx: i've probably got that same c program here somewhere in asm
05:38 PM Tom_itx: i wonder if all those cheap pci pcie cards configure the same way or if i might get lucky and find one that actually works
05:39 PM Tom_itx: this is the WCH chipset
05:40 PM Tom_itx: i see about 5 or so different brands
05:40 PM Tom_itx: i think this disk has drivers for all of em
06:08 PM Ad0: if I were to make a flashable firmware
06:08 PM Ad0: wouldn't the easiest thing be to just have the arduino bootloader?
06:08 PM Lambda_Aurigae: Ad0, if that's what you want to use, go for it.
06:08 PM Ad0: is there an alternative which is better?
06:09 PM Ad0: I'd figure the easiest thing is to upload a sketch
06:09 PM Lambda_Aurigae: sketches are for spirographs
06:10 PM Lambda_Aurigae: I don't do ardweeny myself.
06:10 PM Ad0: hehe
06:10 PM Ad0: there is something toyish over it I agree
06:10 PM polprog: mike did a video on intermediate memory bootloaders and self flashing stuff
06:10 PM Lambda_Aurigae: and bloated
06:10 PM Lambda_Aurigae: I make my own bootloaders to fit the purpose.
06:11 PM Ad0: if I were to do it thru serial, how does it know that it's being flashed?
06:11 PM polprog: Lambda_Aurigae: i came to the same conclusion about ardus
06:11 PM Ad0: if I use serial for other things
06:11 PM Ad0: just always check a signature on the incoming bytes?
06:11 PM Lambda_Aurigae: Ad0, you have to have a trigger for the bootloader.
06:11 PM Lambda_Aurigae: usually one pin pulled low or high depending on how you want to do it.
06:11 PM Lambda_Aurigae: some I just have them wait a few seconds for a command on the serial port.
06:12 PM Ad0: ok
06:12 PM Ad0: yeah that kinda sounds better
06:12 PM Lambda_Aurigae: boot up, listen on usart for "BOOT"...if it doesn't get BOOT in the first 2 seconds, drop to the main program.
06:12 PM Ad0: and the flashing itself is a standard thing right?
06:12 PM Ad0: that it inherently supports
06:12 PM Lambda_Aurigae: no
06:12 PM Lambda_Aurigae: hence
06:12 PM Lambda_Aurigae: bootloader
06:13 PM Lambda_Aurigae: the bootloader is a program that takes the data you send it and writes it to the flash.
06:13 PM Lambda_Aurigae: it resides in the bootloader section of the memory.
06:14 PM Ad0: yeah
06:14 PM Ad0: but the write to flash part
06:14 PM Lambda_Aurigae: write to flash is a command.
06:14 PM Ad0: right
06:14 PM Lambda_Aurigae: I suggest you read the datasheet...it tells all about how it works.
06:14 PM Ad0: <avr/boot.h>: Bootloader Support Utilities
06:14 PM Lambda_Aurigae: I suggest you read the datasheet...it tells all about how it works.
06:14 PM Lambda_Aurigae: I suggest you read the datasheet...it tells all about how it works.
06:15 PM Ad0: so the flashing itself was a standard thing and not some obscure hack
06:15 PM Lambda_Aurigae: that just provides some abstraction for setting up the bootloader section and writing to flash.
06:15 PM Lambda_Aurigae: it's a command,,,built into the chip.
06:18 PM Lambda_Aurigae: you fill a buffer in ram with the data to be written...set the page address...do a page erase...do a page write...
06:18 PM Ad0: yeah
06:18 PM Ad0: seems nice
06:19 PM Lambda_Aurigae: on most chips,,the ones with bootloader sections anyhow,,,the page writecommand can only be run from within the bootloader section.
06:20 PM Emil: Well, one can trick it
06:20 PM Emil: It is possible to fuck with the device and do flashing while not in bootloader
06:20 PM Emil: It's really tricky, though
06:21 PM Lambda_Aurigae: Emil, on all or just some?
06:21 PM Emil: Lambda_Aurigae: I belive most attiny's and atmegas
06:21 PM Ad0: the USB ones already ship with a bootloader
06:21 PM Lambda_Aurigae: Ad0, yes...a usb bootloader.
06:21 PM Lambda_Aurigae: but as with any bootloader, you can't change fuses.
06:22 PM Ad0: yeah
06:22 PM Lambda_Aurigae: you can read fuses from within bootloader,,,or anywhere in program,,,but can't write fuses or lock bits.
06:22 PM Ad0: that's fine
06:22 PM polprog: Emil: is there a general chip-fuxking mechabism?
06:22 PM Emil: https://oneweekwonder.blogspot.fi/2014/07/bootjacker-amazing-avr-bootloader-hack.html
06:22 PM Emil: https://sites.google.com/site/libby8dev/home
06:22 PM Emil: https://ucexperiment.wordpress.com/2014/12/19/reading-an-avr-bootloader-from-the-application-section/
06:23 PM Emil: polprog: what do you mean?
06:24 PM polprog: this seems interesting
06:24 PM Lambda_Aurigae: so, it seems it is running spm from within bootloader...just an indirect twisted jump to do so.
06:24 PM polprog: generally a very insightful discussion
06:24 PM Emil: Lambda_Aurigae: yeah, but you are not supposed to be able to do that
06:25 PM Lambda_Aurigae: what I've done is have a small routine in bootloader section that's outside of the rest of the bootloader....that bit of code will never change..and can get called from program or bootloader and contains the spm setup and instruction.
06:27 PM Lambda_Aurigae: that way to update the bootloader, you use the bootloader to load a bootloader-updater to main memory then jump to that and let it do its job...so long as it never updates that last page of bootloader memory, life is good..
06:28 PM polprog: Emil: that hack is beautiful
06:30 PM Emil: Lambda_Aurigae: Where are those written?
06:30 PM Emil: polprog: I know ;)
06:31 PM Lambda_Aurigae: those? the spm setup section?
06:31 PM Lambda_Aurigae: at the very top page of the bootloader section.
06:32 PM Emil: Lambda_Aurigae: in those articles?
06:32 PM Emil: I linked?
06:32 PM Lambda_Aurigae: no.
06:32 PM Lambda_Aurigae: that's how I did it.
06:35 PM Emil: Lambda_Aurigae: you achieved writing to flash outside of bootloader?
06:35 PM Emil: Do share
06:35 PM Lambda_Aurigae: not really outside.
06:35 PM Lambda_Aurigae: I just jump to the bootloader section...
06:35 PM Emil: Wait
06:35 PM Lambda_Aurigae: have a small routine that lives in the top page of bootloader section that does the page writing.
06:35 PM Emil: Wait so
06:36 PM Emil: By jumping into the bootloader, you can actually allow SPM to work?
06:36 PM Emil: And then jumping back out?
06:36 PM Emil: wtf?
06:37 PM Lambda_Aurigae: yup.
06:37 PM Lambda_Aurigae: at least on the atmega1284p it works.
06:37 PM Emil: Why isn't it used more often?
07:50 PM Tordek: yay, it seems to work
07:50 PM Tordek: I haven't reprogrammed it because (insert lame excuse here) but I got it to run, by feeding it the square wave
07:51 PM Tordek: thanks, all!
07:54 PM Emil: Tordek: glad you got it working
11:55 PM JanC_ is now known as JanC