#avr | Logs for 2013-11-25

Back
[04:20:18] <Sefid_par> Should I use a special port of AVR as USART or can implemented on any I/O port?
[04:27:38] <Tom_itx> use one with a USART
[04:31:29] <Sefid_par> Tom_itx: Thanks
[10:05:25] <Essobi> Derp.
[11:30:36] <mesger> im trying to flash firmware on an arduino atmega2560 from the bootloader reading the firmware from a bin file on an sdcard
[11:31:34] <mesger> as it is now i generate the bin file from a elf file compiled by the arduino ide using avr-objcopy
[11:32:09] <mesger> if i use avrdude to write in the bin all is ok the firmware runs but when reading from sd it doesnt
[11:33:00] <Fornaxian> writing a bin file or a hex file?
[11:33:07] <mesger> i use petitfatfs and here is my inserted code : http://pastebin.com/bxy6VAfN
[11:33:14] <mesger> bin
[11:33:18] <mesger> it should be bin
[11:33:28] <mesger> tried hex but doesnt work aswell
[11:33:47] <Fornaxian> if you have a hex file interpreter it should work just peachy.
[11:34:09] <mesger> http://elm-chan.org/fsw/ff/00index_p.html petitfatfs link if interested
[11:34:20] <mesger> a hex interpreter ?
[11:34:50] <Fornaxian> well, a .hex file isn't just a straight forward write to flash.
[11:34:58] <Fornaxian> each line has address info.
[11:35:12] <mesger> nope but do you have such a library ?
[11:35:47] <mesger> and why would the bin file not work ?
[11:36:02] <Fornaxian> dunno on the bin file...not really up to reading your code this morning.
[11:36:13] <mesger> hehe its evening here
[11:36:14] <Fornaxian> have you run it through atmel studio and watched what it is doing?
[11:36:21] <Fornaxian> is 11:20AM here.
[11:36:37] <Fornaxian> and I'm on vacation..
[11:36:46] <mesger> if i write the bin to adress 0x0 it should worrk no ?
[11:36:52] <mesger> its an atmega2560
[11:37:28] <mesger> i modified the bootloader to be bigger and now starts at 0x3d000 instead ox3e000
[11:37:52] <mesger> read up on fusebits coz i thought that was partitioning but it seems not
[11:37:57] <Fornaxian> and does that fit with what your bootloader section is set to on the chip? you have to set bootloader fuses.
[11:38:21] <Fornaxian> certain commands only work from within the bootloader segment.
[11:38:49] <mesger> so how do i adjust the fuse to set it to 3d000?
[11:39:00] <mesger> i read and its all clk settings
[11:39:22] <mesger> fairly new to all this so bare with me plz :)
[11:40:00] <Fornaxian> one can assume you have a real programmer for uploading programs to the bootloader section of your ardweeny?
[11:40:19] <mesger> no :( just another arduino using isp
[11:40:27] <Fornaxian> close enough...
[11:40:35] <mesger> i have a xeltek and xprog for work
[11:40:35] <Fornaxian> that is capable of setting fuses.
[11:41:03] <mesger> yeah but how do i determine that the bootloader is at 3d000
[11:41:23] <Fornaxian> give me a couple minutes to download the datasheet
[11:41:58] <mesger> this is what is set now http://pastebin.com/60c6YCHY
[11:42:47] <mesger> but i doubt that is the problem coz the avrdude works fine
[11:42:53] <Fornaxian> that means squat to me. must be arduino stuff.
[11:43:29] <mesger> yeah im an arduino noob :) as much as i'd like to know bare avr programming i just dont have the time for it
[11:43:50] <Fornaxian> well, if you want to write bootloaders then you need to drop the whole arduino thing
[11:44:02] <mesger> thats why im struggling now
[11:44:07] <Fornaxian> because arduino doesn't give you that ability...or, at least, didn't last time I looked.
[11:44:19] <mesger> we need a way to update firmware remotely
[11:44:55] <mesger> and since arduino doesnt support that out of the box the only way is to hack the bootloader
[11:45:35] <Fornaxian> page 330 of the datasheet tells how to set the fuses for the bootloader size.
[11:46:03] <Fornaxian> where the heck you get 3d000 for a bootloader start I have no clue.
[11:46:28] <mesger> it is standard at 0x3e000
[11:46:29] <Fornaxian> bootloader can start at 0xFE00, 0xFC00, 0xF800, or 0xF000
[11:46:40] <Fornaxian> at least, according to the datasheet.
[11:46:43] <mesger> at the end of flash
[11:46:49] <mesger> for an atmega2560
[11:46:53] <Fornaxian> oops
[11:46:54] <Fornaxian> yeah.
[11:46:58] <Fornaxian> that's the 1280
[11:47:13] <Fornaxian> there's the 2560.
[11:47:28] <Fornaxian> 0x1fe00, 0x1fc00, 0x1f800, or 0x1f000
[11:47:45] <Fornaxian> bottom of page 331
[11:48:05] <Fornaxian> I don't see any 0x3e000 listed anywhere for bootloader.
[11:48:19] <mesger> strange
[11:48:35] <mesger> the makefile included with arduino sets it there
[11:48:53] <Fornaxian> odd.
[11:49:23] <Fornaxian> aahh.
[11:49:25] <Fornaxian> I get it.
[11:49:27] <Fornaxian> this is in words.
[11:49:30] <Fornaxian> yours is in bytes.
[11:49:38] <mesger> ow :)
[11:49:48] <mesger> thanks that saves me a lot of trouble :)
[11:50:00] <mesger> so its time 2
[11:50:52] <Fornaxian> so, 1F000...your bootloader is at 4096 words or 8192 bytes.
[11:51:04] <Fornaxian> if I had bothered to read the word "words" in the dataseet.
[11:51:53] <mesger> yeah but i was staring at it ignorantly
[11:52:06] <mesger> my bootloader is around 10000
[11:52:19] <Fornaxian> 10000 bytes?
[11:52:20] <Fornaxian> too big.
[11:52:21] <mesger> to large i suppose
[11:52:26] <Fornaxian> has to be 8K or smaller.
[11:52:48] <mesger> so why does it work using avrdude to upload code?
[11:53:05] <Fornaxian> because avrdude doesn't rely on the bootloader section special commands.
[11:53:08] <Fornaxian> it uses icsp
[11:53:39] <mesger> gonna try and shrink down the bootarea
[11:53:41] <Fornaxian> I'm guessing you haven't read the section of the datasheet about bootloaders?
[11:53:44] <mesger> or loader ...
[11:53:51] <mesger> nope :)
[11:53:56] <mesger> new document for me
[11:54:07] <Fornaxian> if you intend to write a bootloader, read the fine manual.
[11:54:10] <mesger> but i learn as i go
[11:54:18] <mesger> oki
[11:54:29] <Fornaxian> something else ardweeny has done for the world.
[11:54:39] <Fornaxian> nobody needs to know how the hardware works..it just abstracts it all for you.
[11:55:26] <Fornaxian> this is, in my opinion, the reason windows and other operating systems are so damned bloated....abstracted libraries of abstracted libraries to access hardware.
[11:56:00] <mesger> true
[11:56:15] <Fornaxian> arduino suffers from the same thing.
[11:56:21] <mesger> everything gets easier the accomplish but at a cost
[11:57:18] <Fornaxian> windows 7 takes longer to boot on a quad core 4ghz machine than win3.1 did on a 33mhz 486.
[11:57:32] <mesger> unless you have an ssd
[11:57:34] <mesger> :)
[11:58:05] <mesger> but its bloated
[11:58:08] <Fornaxian> anyhow, back to your problem.
[11:58:25] <Fornaxian> bootloader must fit in bootloader section or it won't work.
[11:58:36] <mesger> gonna try and trim it down
[11:58:49] <Fornaxian> or, at least, the section that writes to the flash does.
[11:58:52] <mesger> only thing is i want serial output and uploading aswell
[11:59:18] <Fornaxian> I think atmel studio has an SD bootloader already done for you.
[12:00:05] <mesger> but without arduino serial capibilities ?
[12:00:37] <Fornaxian> dunno, but, probably.
[12:01:09] <Fornaxian> yup...sd bootloader.
[12:01:32] <Duality> hi
[12:01:40] <Fornaxian> is in the atmel gallery
[12:01:43] <Fornaxian> hi Duality
[12:02:00] <Duality> I have no code in my main function but why does it still compile to 1192 bytes ?
[12:02:17] <Fornaxian> or maybe somewhere else...I know I found it in there somewhere.
[12:02:33] <Fornaxian> Duality, using C?
[12:02:48] <Fornaxian> lots of setup and teardown code.
[12:03:23] <Duality> It's compiled as C++
[12:03:32] <Fornaxian> even more overhead.
[12:04:12] <Fornaxian> http://spaces.atmel.com/gf/project/sdbootloader/
[12:04:22] <Fornaxian> sd bootloader at atmel spaces..
[12:04:36] <mesger> thanks
[12:05:15] <mesger> its is what im using
[12:05:18] <mesger> petitfs
[12:05:55] <Fornaxian> that's just the reading of the sd filesystem part...
[12:07:45] <Duality> wait you can load code from a SD card ?
[12:07:59] <Fornaxian> with that bootloader, yes, you can.
[12:19:57] <jadew> http://codinghorror.typepad.com/.a/6a0120a85dcdae970b0128776ff992970c-pi
[12:22:56] <Duality> Fornaxian: that is so cool, I should just be more in this channel to learn more awesome :)
[12:24:34] <Fornaxian> I just found it the other day while browsing through things.
[12:35:02] <mesger> haha jadew
[12:46:12] <Casper> jadew: nice
[12:51:26] <jadew> I'm considering adding that certification to all my apps
[13:31:35] <Duality> why is it that if I write bigger code, my code size decreases ..
[13:36:32] <Fornaxian> depends on what you are doing.
[13:36:49] <Fornaxian> and how the compiler optimizes things.
[14:11:16] <mesger> Fornaxian, thanks for your help, problem was indeed overshooting on the bootloader. the sd flash works with all the arduino perks still inside
[14:11:50] <Tom_itx> writing over the bootloader?
[14:12:14] <mesger> nah frimware flsh from sd through bootloader
[14:12:28] <mesger> i overshooted the bootloader size
[14:12:29] <Tom_itx> i know what you were working on
[14:12:33] <Tom_itx> oh
[14:12:45] <Tom_itx> so it was cutting off the end of the code?
[14:13:04] <mesger> it was denying write to the flash
[14:24:04] <Duality> http://xkcd.com/221/
[14:29:15] * RikusW has been reading some of -> http://hpmor.com/
[14:40:45] <jerkey> there needs to be an xkcd artist who does microcontrollers
[14:47:55] <Duality> :P
[16:48:17] <Fornaxian> Tom_itx, it seems his code was just under 10K and trying to fit in an 8K bootloader section..part of his code was likely outside the bootloader section and couldn't execute the write to flash from there.
[18:12:09] <Tom_itx> Fornaxian, that's what i got from it as well
[18:12:26] <Tom_itx> if possible, increase the boot size and carry on...
[18:13:08] <Fornaxian> is set to max bootsize.
[18:13:11] <Fornaxian> 8K
[18:13:19] <Fornaxian> his code compiled out to 10K
[18:13:37] <Tom_itx> i wasn't sure what max boot size was on that
[18:14:03] <Fornaxian> me either..so looked it up.
[18:14:13] <Tom_itx> i bet regular c code wouldn't be so bloated
[18:14:46] <Fornaxian> he was modding an ardweenie bootloader.
[18:14:57] <Tom_itx> yep
[19:07:55] <awozniak> can't get my timer OVF interrupt to fire on an xmega. Anyone want to help? http://pastebin.com/EMvfsbc1
[19:17:23] <awozniak> nobody? =(
[19:25:47] <awozniak> hehehe, TCC0_OVF_vect, not TCC0_OVF_vector
[19:25:50] <awozniak> duh