#avr Logs

Mar 09 2022

#avr Calendar

05:37 AM twnqx: uh. gentoo removed all instances of kicad it seems.. because too full of CVEs...
05:48 AM twnqx: CVE-2022-{23803,23804,23946,23947}
05:57 AM Thrashbarg: wow
07:12 AM cehteh: https://lists.launchpad.net/kicad-developers/msg45590.html
07:15 AM qu1j0t3: any info on whether 5 is affected? 6 can't run on my machine
07:17 AM twnqx: all of them seem in 6.0.1's gerber viewer, no idea about 5
07:20 AM qu1j0t3: ok.
07:39 AM cehteh: looks like 5 is affected, but you can patch it with the fixes
07:40 AM cehteh: and even if not, unless you upen malcious documents i dont see much problems, thus using it for your own projects may still be ok
11:38 AM Zazem: Hi. I can't compile an assembly code example, can i get help?
01:30 PM Zazem: Hi?
01:30 PM qu1j0t3: Hi!
01:34 PM Zazem: I new at avr, school stuff. Can I get some help?
01:36 PM cehteh: you need to be a little more precise about your problem
01:37 PM cehteh: irc is generally "dont ask for asking" .. just go ahead and be patient
01:38 PM Zazem: Okay, so I think I just go ahead. I'm trying to run this code example https://polprog.net/blog/asm/src/hello.S
01:39 PM Zazem: But i dont have any atmega so I trying yo use simavr
01:39 PM Zazem: Following the instruccions from https://blog.oddbit.com/post/2019-01-22-debugging-attiny-code-pt-1
01:39 PM Zazem: But I got an error when compaling hello.S
01:39 PM cehteh: eh just get some avr's they are cheap
01:40 PM Zazem: I will, but trying this seems iteresting. Addtional my teacher say to install a old verson of avrstudio on windows
01:40 PM cehteh: also dont ask me too much about asm i am more on the C side, still the error you get from the assembler/compiler should point you to the problem
01:41 PM cehteh: eek
01:41 PM Zazem: I want to find the way on linux without wine
01:41 PM cehteh: just use avrgcc
01:41 PM cehteh: your favorite editor, git and make
01:41 PM Zazem: Yeah, the avrgcc says that "com r16" needs a semicolon
01:42 PM Zazem: I doing it with Makefile and git, I love that way
01:42 PM nohit: avr studio 4 has a great simulator
01:42 PM cehteh: could be that there are slightly different assembler syntaxes required, did you try to add the semicolon? or look up the docs?
01:42 PM cehteh: what does com do?
01:43 PM Zazem: On the datasheet says nothing about a semicolon ","
01:43 PM Zazem: "com" does complement at one
01:43 PM Zazem: so: com r16, is kinda a negate (?
01:43 PM cehteh: , is comma/colon ; is semicolon
01:44 PM Zazem: Sorry
01:44 PM Zazem: Not native speaker
01:44 PM cehteh: me neither :D
01:44 PM Zazem: XD
01:44 PM Zazem: What u speak?
01:44 PM cehteh: anyway assmbler syntax somtimes varies in small details depending on which assember you use
01:44 PM polprog: Hello Zazem
01:45 PM Zazem: Hello polprog
01:45 PM polprog: I didnt use much simavr
01:45 PM polprog: Whats the error?
01:46 PM masoudd: Zazem, how are you compiling it?
01:46 PM cehteh: i tried it once, its okish for what it does, but generally more work to rig up for any non trivial task compared to real hardware, breadboard and a few leds
01:46 PM Zazem: wait, miss the line. The line error is: out _SRF_IO_ADDR(PORTB), r16
01:46 PM Zazem: It says: `,' requaried
01:47 PM Zazem: number must be positive and lower than 32
01:47 PM masoudd: Zazem, How are you compiling it?
01:47 PM Zazem: requaried name or register from 0 to 32
01:47 PM Zazem: trash at end of line
01:47 PM masoudd: ok bye
01:47 PM polprog: iirc the SFR_IO_ADDR is a macro
01:47 PM Zazem: avr-gcc -mmcu=atmega8535 hello.S -o hello.elf
01:48 PM Zazem: tried this too: avr-gcc -mmcu=atmega8 hello.S -o hello.elf
01:48 PM cehteh: didnt you saied tiny85 earlier?
01:48 PM polprog: Thats weird.. can you paste the whole compiler output somewhere?
01:48 PM masoudd: I just did `avr-gcc -mmcu=atmega8 -o hello.elf hello.S` on it and it compiled with no error
01:48 PM polprog: Like paste.debian.net
01:48 PM Zazem: No, on my class we using atmega8535 so I tried this
01:48 PM polprog: Ahh
01:48 PM cehteh: ah ok
01:49 PM cehteh: did you check if the gcc/avrlibc you have installed support that chip?
01:49 PM polprog: It seems like a new chip
01:49 PM cehteh: i dont know it
01:50 PM polprog: First time I hear about it too
01:50 PM Zazem: this is the output of compiler: http://paste.debian.net/1233610
01:50 PM cehteh: sometimes you have to download the support headers from microchip and install them locally (+ give the include paths)
01:50 PM cehteh: can you 'export LC_ALL=C' first and then run again
01:51 PM polprog: Hm, i think the io.h heaer does not have support for the chip. And the macro does not resolve to an io address
01:51 PM Zazem: Its on the avr-as output: `avr-as --help | g atmega8535`
01:51 PM cehteh: yes i guessed something like that
01:51 PM Zazem: avr-as --help | grep atmega8535
01:51 PM WormFood: I do all my development under Linux, including asm
01:51 PM Zazem: WormFood that's great I wanna do that too
01:51 PM polprog: You can look up what addres PORTB and DDRB are at in this avr and replace the macro call with the address constant
01:52 PM cehteh: Zazem: the compiler/assembler may already support that chip, but the necessary headers could be not installed/shipped
01:52 PM cehteh: i had to do that back in times for the 328pb .. creating a custom include tree within the project
01:54 PM Zazem: I looikng into the datasheet, there's two address for PORTB: 0x18 (0x38). Which one?
01:54 PM WormFood: Just include the proper header/defines for your avr
01:54 PM polprog: Depends if you use the in/out instruction or a mov to memory
01:54 PM polprog: I think... 0x18 with in/out instructions
01:55 PM polprog: Maybe i wrote about this in the text.. its been a while :)
01:55 PM Zazem: I'm using the `out` instruccion
01:55 PM polprog: So 0x18
01:55 PM Zazem: WormFood, How do I find the header? I have the avr/io.h included
01:55 PM polprog: Thats because the first 0x20 addresses in memory are mapped to registers
01:56 PM polprog: Hence there is an offset and difference between the IO register address and memory address. They are the same registers
01:56 PM polprog: (32 registers = 0x20 in hexadecimal)
01:56 PM WormFood: Zazem, what is the model of the AVR that your're programming for?
01:57 PM Zazem: polprog I work, I gonna try using simavr
01:57 PM Zazem: WormFood, I'm using the atmega8535
01:59 PM WormFood: Zazem, #include <avr/io8535.h>
02:00 PM WormFood: Zazem and/or #include <avr/iom8535.h>
02:02 PM Zazem: WormFood got this: http://paste.debian.net/1233613/ :c
02:03 PM WormFood: There is a define to set, which will cause io.h to load iom8535.h
02:03 PM WormFood: io8535.h is not the right one for you. That is for the at90s8535
02:06 PM WormFood: if you define __AVR_ATmega8535__ it should work, but that feels wrong. I expect there should be a shorter define to make it work.
02:08 PM Zazem: Now i get a redifiened message. I put all of it if a missing somthing in the paste bin: http://paste.debian.net/1233614/
02:09 PM polprog: Define before include
02:10 PM polprog: But it looks like io.h already defined that because of -mmcu option
02:10 PM WormFood: with -mmcu=atmega8535 you shouldn't need a define
02:11 PM WormFood: so, that's an xor....define xor mmcu
02:13 PM Zazem: So going back to the begining: http://paste.debian.net/1233618/ XD
02:16 PM WormFood: so, fix it
02:16 PM WormFood: change the "r16" to "R16"
02:17 PM WormFood: on line 26
02:18 PM masoudd: Does it give the same error for `-mmcu=atmega8`? because if yes, then we're wasting time about 8535
02:18 PM WormFood: line 8 is the exact same thing. If that works, then line 26 will work
02:19 PM WormFood: or, perhaps you have some other (invisible) character in your source file. Try copy/pasting line 8, to line 26
02:19 PM Zazem: Replace all rXX to RXX: http://paste.debian.net/1233619/ same. Gona try with atmega8
02:22 PM Zazem: Same for atmega8: http://paste.debian.net/1233620
02:23 PM WormFood: I got it to work for me, but at first I got the same error
02:23 PM WormFood: hold on a sec, and I'll isolate the exact problem.
02:28 PM Zazem: I trying also with another code if this does not work: ?PNG
02:29 PM Zazem: IHDR???C IDATx????E????????????B 2?L???c?i??/
02:29 PM Zazem: ?+???0???'OFSSS`7??Pn!V????s???????J?z,!c????????????B?????D?!FjY??????a???`?????+q???8j|?LOB?am;??????????az?v????"?6eL????Gzs? l???????-9,
02:29 PM Zazem: ꋶ??N<dBH ?NLpP~????F??????T?YYT?,MM9?(?~????????Mij?cFb?????W7???܇B???K?AŠ????"(Nĺ?:s??_???~?ˁ?O
02:29 PM Zazem: a?
02:29 PM Zazem: ԀQ?????0v??d
02:29 PM Zazem: ]??+b????)E_??7????^????hz[*??c5?6??X?4
02:29 PM Zazem: ?FP6???????{?????㞗7????3NZ
02:29 PM Zazem: ????4 ?mc????n?????Y?
02:29 PM Zazem: ;????=<???????֘a˂u?4?\E<?????̑s
02:29 PM Zazem: ??8??f??l?????߾}u????????
02:29 PM Zazem: ?L?l;?????????K???????ٳ?~?z???#\??? s????U??{??s
02:29 PM Zazem: ?nT?i???>(QK?I|6a???
02:29 PM Zazem: F?K???_.?Ji??????u?oK????????l????W9??????????????????s?p????~??&?l̓????????{0r??L?0
02:29 PM Zazem: ---8???R?q???⮻MMMX?lY??????1}?tlڴ [?n-)cϞ=x?G?ƢE?R??6v"????g???[???????????p????:f
02:29 PM qu1j0t3: oh the shame
02:30 PM WormFood: heh
02:30 PM Zazem: Im sorry sorry sorry sorry sorry soryy
02:30 PM WormFood: I don't see why, but there appears to be some garbage there, just as the error message says. So, do what I said before, and delete line 26, and copy/paste line 8 in it's place.
02:30 PM WormFood: That works for me, and it should work for you too
02:32 PM Zazem: How the hell? I actually worked :D
02:32 PM WormFood: you didn't trust the error message.
02:33 PM Zazem: Forget me my lovely pc for doubut
02:33 PM WormFood: actually, the parser, should strip out shit like that, but whatever. You know what the problems is
02:33 PM Zazem: Thanks a lot
02:34 PM WormFood: Your welcome
02:35 PM WormFood: non-printing control codes can be tricky to figure out sometimes.
02:35 PM WormFood: Zazem, what editor do you use?
02:35 PM Zazem: Next time i will use hexdump to double check
02:35 PM Zazem: WormFood I use neovim
02:37 PM Zazem: Why on avr-gdb step goes to the next label insted of the next line? https://pasteboard.co/UoFnNhIj302x.png
02:39 PM Zazem: Also cant use display and load options: https://pasteboard.co/Cy9wPwSYQfO0.png:
02:40 PM Zazem: I'm trying to emalate this: https://blog.oddbit.com/post/2019-01-22-debugging-attiny-code-pt-1/
02:44 PM WormFood: I was wrong all the way around.
02:44 PM WormFood: NOW I see what the problem really was, and I can't believe *nobody* spotted it before now.
02:44 PM Zazem: Found it, the instruccion is not step is stepi
02:44 PM Zazem: WormFood what u mean?
02:45 PM WormFood: It's a typo
02:45 PM WormFood: look again at line 26, knowing it's a typo, and nothing more. Do you see it?
02:46 PM WormFood: sfr vs srf
02:46 PM masoudd: omg
02:46 PM WormFood: incredible, that everyone overlooked that, eh?
02:47 PM Zazem: you must be kidding me
02:47 PM Zazem: it did not see it early
02:47 PM Zazem: I feel stupid now :D
02:47 PM WormFood: The error message is extremely misleading
02:48 PM Zazem: It is...
02:52 PM WormFood: If I remember correctly, there was only one time I had to resort to Winblows, to do anything with an AVR. And that was to count cycles on their emulator, for something that was timing critical. This was over 15 years ago, so by now I expect we'd not have that problem.
02:55 PM Zazem: I hope the same, I don't like windows at all. I see you can generate a vcd file with simavr, but there is not limit time option. So how I do it?
02:59 PM polprog: simavr is designed to be controlled via gdb
02:59 PM polprog: i guess you can just run it, then stop after a moment (Control-C) and see if the VCD file has anything
03:00 PM polprog: it is not an easy tool for newbies
03:02 PM Zazem: I kinda able to cotrol it by gdb. I tried the start/stop thing but no vcd file was generatee
03:03 PM polprog: sorry, i cant help. i never got simavr to work
03:03 PM polprog: running it on real hardware is easier imo, just need like $10 worth of parts
03:05 PM Zazem: Sound great gonne buy it
03:05 PM Zazem: Found i actully need a program called: run_avr
03:07 PM Zazem: any, this has been a lot of help. Thanks a lot all of you
03:07 PM Zazem: Gonna take a break
03:07 PM Zazem: bye bye
03:10 PM polprog: finally some traffic