#avr Logs

Dec 17 2020

#avr Calendar

12:31 PM Kabriel: I have a Atmega2560 on a custom board. It has a bootloader, and I have the bootloader source. On Windows I have a program that can program the chip, but not the program source.
12:38 PM Kabriel: In Linux, I can connect to the board fine (in application mode) with the correct com settings.
12:38 PM Kabriel: I would like to connect to the bootloader, but can't quite figure that out.
12:38 PM Kabriel: I have the same com settings as in the Windows programmer.
12:38 PM Kabriel: Looking at the bootloader source, it is using the i2c to send and receive bytes. How is that different from the uart and how to you communicate with it?
12:38 PM Smidge204: It doesn't really make sense that the bootloader is using I2C unless it's talking to something external to the chip?
01:30 PM Kabriel: Hmm. I'm confused myself. I was able to connect to it and it is printing out a series of characters (bootloader, before it goes into application), which do not match any of the source I was provided.
01:31 PM Kabriel: Reading through the source provided, it is a modification of the ARV109 source code.
01:32 PM Kabriel: This seems to indicate you have to pull PIND low to enter programming mode.
01:33 PM Kabriel: Sorry if this is a dumb question, but is there a way to pull PIND low by sending a byte over UART? THere has to be something else going on here, because the windows exe is able to program the chip.
01:40 PM twnqx: Kabriel: you'll need to check wiring, but it's possible they use a handshake line connected to it (DTR/DSR, RTS/CTS handhsake)
01:40 PM Kabriel: Through the same com port?
01:40 PM twnqx: sure, why not
01:48 PM Kabriel: It is connected to the PC via USB port through a TTL232, which has ground and TxD line connected to PE1 (TXD0) and the RxD line connected to PEO (RXD0).
03:28 PM Kabriel: How do you read the bytes from a certain loctation in the memory (given an address) in a running application?
03:29 PM Kabriel: flash memory
03:32 PM LeoNerd: ?
03:33 PM Kabriel: I have a running application on an ATMega2560 that I can easily modify. I want to echo back a message on the UART that tells me what byte is at a certain flash memory address (specifically in the bootloader section).
03:33 PM Kabriel: All the messaging stuff is setup and works.
03:34 PM Kabriel: I think it is pgm_read_word_near
03:34 PM skz81: at least, near
03:37 PM skz81: Kabriel, if you want to read a word (16bits) from the program space aka flash, you're at home
03:38 PM Kabriel: I'm confused
03:39 PM Kabriel: yeah! it works!
03:41 PM skz81: Kabriel, neat. That's because I made a ritual, sacrifying a resistor to the AVR's god ;°)
03:42 PM skz81: Or maybe, maybe... Becuse you're good at what you're doing...
03:43 PM * skz81 is wondering if there is a pgm_read_word_far')...
03:45 PM Kabriel: yes, but probably not for this chip, I think _far is for 32bit addressing
03:45 PM Kabriel: I don't understand the names
03:47 PM LeoNerd: It's important on chips with >64Ki of flash
03:47 PM LeoNerd: E.g. the ATmega2560 has 250Ki
03:47 PM LeoNerd: *256
03:50 PM skz81: Ha yes makes sense.
03:51 PM skz81: I was thinking about older system C functions for jumpiung near/far
03:51 PM skz81: was specific to IA32 / x86 IIRC
03:53 PM LeoNerd: A slightly similar idea, yes
03:54 PM Kabriel: Hmm. So I need to use pgm_read_word_far then if I want to get an address above xffff
03:54 PM Kabriel: ?
03:59 PM skz81: Didn't check, but as far as I understand it, yes
04:01 PM skz81: Doesnt the _near version take an int16_t parameeter while the _far takes an uint32_t ?
04:01 PM skz81: uint16_t*
04:03 PM skz81: het
04:03 PM skz81: typedef int32_t PROGMEM prog_int32_t
04:03 PM skz81: neat
04:04 PM skz81: in pgmspace.h
04:07 PM Kabriel: yes
09:21 PM Kabriel: So that didn't seem to work. I checked the high hfuse bits, and the bootloader should be in address space 0x1f800-0x1ffff.
09:21 PM Kabriel: However, when I use pgm_read_byte_far(address) in that space, all I get is 1s.
09:25 PM Kabriel: Any ideas what I might be doing wrong?
09:27 PM * Kabriel off to sleep; be back later