Optiboot 1284p compiled for UART1 instead UART0

Go To Last Post
70 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does the code even compile without errors or warnings? The value 1234 wont fit into a byte, but further code seems to be confused as to whether it is a byte or word. Why use 1234 ? What are you wanting to communicate? I think you need to sit back,relax and read a good book on C. This might allow you to avoid obvious errors.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes Kartman,

 

It gives me errors as you said. Yes I confused with bytes and words.

 

Quote:

 error: expected primary-expression before '*' token

         if ((eeprom_read_byte(uint8_t *0x01)) == '1')

                                       ^

 error: expected ',' or '...' before numeric constant

         uint8_t eeprom_update_byte (uint8_t *0x01 , uint8_t '0');

                                              ^

 error: a function-definition is not allowed here before '{' token

 {

 ^

 error: expected '}' at end of input

 }

Thanks,

Srinivasa Varadhan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is a bit like someone who once went on a hill walking holiday in Scotland and this week finds themselves suspended on a climbing rope half way up K2!

 

The errors here are fundamental to the C programming language which you clearly do not understand yet. You cannot tinker about with bootloader code if you don't even speak the language it is written in!

 

I'll bet that for:

if ((eeprom_read_byte(uint8_t *0x01)) == '1')

you meant to write:

if ((eeprom_read_byte((uint8_t *)0x01)) == '1')

and if you don't know why I've added () in this and what "(uint8_t *)" is achieving you simply don't know enough C to do this.

 

I would also question the use of absolute addressing in EEMEM but I have a rather sneaking suspicion you don't actually know what I mean when I say that!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Lawson and Kartman,

 

There were few errors in my code and it dint compile. Now I have made the changes and the code is free of errors. My doubt is, whether my code is logically correct or not ? Will I delay the time that the boot loader waits for software update command ?

 

What commands is Arduino IDE is sending to atmega2560 when we press the upload button ?

Thanks,

Srinivasa Varadhan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

srinivardhan wrote:
What commands is Arduino IDE is sending to atmega2560 when we press the upload button ?

This is the kind of question you should be answering yourself. If it is not obvious the Arduino uses Optiboot and that implements the "stk500" protocol. That is documented here:

 

http://www.atmel.com/images/doc2...

 

Oh and here's a coincidence. I just went to look at the Optiboot source code so I googled "Optiboot source code". The top link was not what I was looking for but I think it IS what you are looking for:

 

https://github.com/NordicSemicon...

 

So that is a version of Optiboot modified to use a Bluetooth Low Energy module.

 

I don't suppose the Bluetooth you are trying to use happens to be the "Nordic Semiconductor nRF8001" because if it is that code may be your complete solution. If it isn't then get copies of both the regular Optiboot and this modified one and look at the differences (I use kdiff3 for this myself) and see how they changed it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Lawson, 

 

As you previously mentioned, I have gone through the STK protocols. These protocols are used in the bootloaders with both answer format and input format. I get that. But I will get much more clear idea if you illustrate the sequential communication between the arduino ide and the MCU.?

 

Thank you for the Github project with BLE. I will surely go through that and will try to modify according to my needs :)

Thanks,

Srinivasa Varadhan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

srinivardhan wrote:
But I will get much more clear idea if you illustrate the sequential communication between the arduino ide and the MCU.?

Arduino will do that for you! If you add a "-v" to the Arduino command line it tells you a little about what it is doing. Add another "-v" and it tells you a bit more. You can keep adding them up to four of them; by that stage it gets VERY detailed about what is going on and will show you all the bytes it is sending and receiving.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Lawson,

 

Where is the command line option in the arduino IDE ? 

Thanks,

Srinivasa Varadhan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There isn't one. For once work this out for yourself.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

 

Since my new thread was removed, I am asking the next doubt in this same thread, 

 

I want to know, which part of the peter fleury boot loader I should vary in order move towards the bootloader section of Atmega2560 even for an watchdog reset or soft_restart.

Any suggestions will be helpful.

 

Peter Fluery STK500v2 boot loader @ https://github.com/arduino/Ardui...

Thanks,

Srinivasa Varadhan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you resolve your last problem?
As for your new problem, what do you mean by 'move towards the bootloader'? Assuming you've set the fuses correctly, on reset you end up in the bootloader. So what next?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How do I write the boot reset fuse. When I am trying to check BOOTRST in the AS7, it is saying the default address is 0x0000. How do I override it to my boot loader address ?

Thanks,

Srinivasa Varadhan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not surprised your avatar shows the picture it does!. Just take a moment to drink some tea, relax then have a read through the AVR datasheet.

 

There are basically 3 fuses involved in using bootloaders in most of the large models of AVR. There is a pair called BOOTSZ0 and BOOTSz1. In combination they select four possible sizes of bootloader. (effectively they are picking where the bootloader starts in flash). Then there is BOOTRST which switches the whole mechanism on/off. When enabled the AVR will fetch the first opcode at power on from the first location of the boot area set by the two other fuses.

 

To change fuses you use your ISP programmer. To avoid changing anything else it's a good idea to start by reading the current fuse setting. Then you just change BOOTSZ0, BOOTSZ1 and BOOTRST to the combination you want and use your ISP programmer to write that value back. The three fuses are either in the "High" or "Extended" fuse byte usually.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Lawson, 

 

I was just confused about the reset vector. Actually I have set the reset vector fuse and set the size of boot loader. And it functions okay. I verified it by reading my program memory. I have attached it below. 

 

The issue that I have now is, the boot loader waits for very less time to get instruction. I am unable to send instruction via mobile that fast. So I need to make few alteration that the timeout is made high enough so that I could send data or it should jump to application only when the required commands are sent. I have tried changing the value of few timeout and count. But unsuccessful.

 

If you help me giving idea of alteration, it will be very helpful.

Peter Fleury boot loader :)

Attachment(s): 

Thanks,

Srinivasa Varadhan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can somebody guide me to edit code of Optiboot or Peter Fleury STK500v2 boot loader to wait infintely until it can receive command through a mobile phone via UART1. I have removed the condition, on watchdog interrupt, it will not switch to the application section. It would be greatly helpful. I have tried changing the values of timeout,count and MAX_COUNT. Not successful though. I know, I am missing it only by a slight margin. It would he helpful if someone can assist on this regard.

Advance thanks

Boot loader source like : https://github.com/arduino/Ardui...

Optiboot source : https://github.com/arduino/Ardui...

 

I have also attached my edit file for your reference.

Attachment(s): 

Thanks,

Srinivasa Varadhan

Last Edited: Mon. Feb 29, 2016 - 02:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When you posted above I looked at my own local copy of the Fleury code and I simply don't see where it's doing this delay/timeout you want to defeat!?!? Perhaps my copy is out of date but I cannot help thinking you are actually mixing up Fleury and Optiboot.

 

In fact the comments at the top even decribe the intended usage:

    - Reset your AVR while keeping PROG_PIN pulled low
    - Start AVRISP Programmer (AVRStudio/Tools/Program AVR)
    - AVRISP will detect the bootloader

to implement that I see it doing this:

	/*
	 * Branch to bootloader or application code ?
	 */
	if(!(PROG_IN & (1<<PROG_PIN)))
	{
#ifndef REMOVE_BOOTLOADER_LED
        /* PROG_PIN pulled low, indicate with LED that bootloader is active */
        PROGLED_DDR  |= (1<<PROGLED_PIN);
        PROGLED_PORT &= ~(1<<PROGLED_PIN);
#endif
        /*
         * Init UART
         * set baudrate and enable USART receiver and transmiter without interrupts
         */
#if UART_BAUDRATE_DOUBLE_SPEED
        UART_STATUS_REG   |=  (1 <<UART_DOUBLE_SPEED);
etc.

    }
    /*
     * Now leave bootloader
     */
    #ifndef REMOVE_PROG_PIN_PULLUP
    PROG_PORT &= ~(1<<PROG_PIN);    // set to default
    #endif
    boot_rww_enable();              // enable application section

    // Jump to Reset vector in Application Section
    // (clear register, push this register to the stack twice = adress 0x0000/words, and return to this address)
    asm volatile (
    	"clr r1" "\n\t"
    	"push r1" "\n\t"
        "push r1" "\n\t"
        "ret"     "\n\t"
    ::);
   

So there's no timeout/delay here. It either sees PROG_PIN or PROG_IN to be active and it goes into the bootloader communication or it doesn't and just goes on to hit the access code.

 

Anyway what happened with that Bluetooth-Optiboot I gave you a link to the other day - how's that working out for you?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Lawson,

 

I started working with it only today. I have downloaded the mobile app provided by them. The README document says we have to change the key in the ".init3"

 

I had this doubt when working with Peter Fleury also. When program prototyping is done, why do we declare section .initx 

Is that similar to header file ? How will I edit  a BOOT_KEY in the .initx region ?

 

clawson wrote:
So there's no timeout/delay here. It either sees PROG_PIN or PROG_IN to be active and it goes into the bootloader communication or it doesn't and just goes on to hit the access code.

So Lawson, this prog pin is set to active by the DTR of USB ?

Will changing the PROG PIN to active while reading my EEPROM will it not jump to boot loader ? How do I delay the time it exist in the boot loader before it jumps to the application section.

Thanks,

Srinivasa Varadhan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cliff outlined the code that tests the prog pin and makes the decision. You can put any code you want to make the decidion. Don't want a prog pin? Remove that code. As for the delay, if you havent written code to flash a led yet, then maybe you should start there? You'll learn about delays.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

srinivardhan wrote:
When program prototyping is done, why do we declare section .initx  Is that similar to header file ?

No, not at all.

 

For a treatise of the .initX sections, this is the documentation: http://www.atmel.com/webdoc/AVRL...

 

I concur with what has been hinted at above. You are in deep waters, without having learned to swim. Again and again, people try to pull you into shallower water, and giving the advice "take swimming lessons" - but repeatedly you continue to throw yourself into too deep waters.

 

Continue this exercise and the people at the rim of the pool will just walk away and leave you there.

 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Pages