#avr Logs

Jul 10 2022

#avr Calendar

04:37 AM exp: on an xmega, when using pgm_read_word_far or pgm_read_dword_far, i get one byte less than i expect back
04:47 AM exp: i'm reading a section which is all 0xff, read_word gives me 0xabff, read_dword gives me 0x00ffffff
04:47 AM exp: nvm cmd is set to noop
04:47 AM exp: the address is supplied with pgm_get_far_address() which does seem to return the correct 24 bits
07:07 AM Cracki: got the exact code to show?
07:36 AM exp: Cracki: not to hand anymore, working on a different bit now which will encounter the same issue
07:49 AM exp: Cracki: rstartc = pgm_read_dword_far(0x2fc00); is good enough it seems, i get 0xcd21e211 wheras the bytes in flash are 11 e2 21 00 -- i assume 'cd' is uninitialised or something i'm missing from the nvm controller
07:49 AM exp: going to take a break now then get back into it
08:05 AM exp: it's a bug in microchip studio's debugging
08:05 AM exp: it interrupts the instruction flow one too early
08:05 AM exp: or, it's a bug with me expecting how breakpoints work
08:05 AM exp: either way, the last store hasn't happened, so that's why
08:27 AM Cracki: fun
08:28 AM exp: Cracki: thank you for being around :)
08:39 AM Thrashbarg: exp: https://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html <-- says there "For Xmega devices, make sure the NVM controller command register (NVM.CMD or NVM_CMD) is set to 0x00 (NOP) before using any of these functions."
08:39 AM Thrashbarg: full disclaimer, I've not used an XMega (yet)
08:40 AM exp: Thrashbarg: yes i had, it's all good now thanks
08:40 AM Thrashbarg: k good
08:40 AM exp: although i wonder if there's a header entry for flash page size
08:41 AM Thrashbarg: should be
08:42 AM exp: # define APP_SECTION_PAGE_SIZE (512U)
08:42 AM exp: in bytes of course, ffs :-p
09:00 AM Cracki: what puzzles me is the high byte of word OR dword is corrupted.
09:01 AM Cracki: does any manual talk about any timings to be respected? suspecting the debugger might be right...
09:02 AM exp: Cracki: nah i just read the assembler
09:02 AM exp: it definitely paused one instruction too early
09:02 AM exp: breaking on a later instruction, the data is there and complete
09:03 AM Cracki: oh good
09:03 AM Thrashbarg: yay!
09:04 AM exp: writing an effective bootloader for a complex device that works in consort with application code is surprisingly difficult
09:05 AM exp: doing the whole 'dual rom' thing isn't as bad as i thought other than the size of the vectors in flash
09:05 AM exp: but every unit has a startup procedure and a power-on procedure, a power-off and shutdown procedure, status output information etc
09:06 AM exp: my approach is 3 different linker scripts and i'll probably make cmake build it properly when i don't have to jump into microchip studio all day