Go Down

Topic: Adjusting serial buffer size in IDE, mk2 (Read 9582 times) previous topic - next topic

robert rozee

good point, i've now switched over to using the Atmel constants. must admit, it has made the code a tad easier to follow!

i'm particularly interested in determining how much of a subset of the STK500v1 protocol each of the arduino bootloaders requires to be present in communications from the host. at the moment my code implements the following:

1. STK_GET_SYNC (loop until STK_INSYNC)
2. STK_ENTER_PROGMODE
3. STK_READ_SIGN (expect 0x1e950f for a 328p, warn if not)

do
    4. STK_LOAD ADDRESS
    5. STK_PROG_PAGE
loop until all data written

6. STK_LEAVE_PROGMODE


so i've left out signon, all the fuse and lock stuff, and the setting of programming parameters. plus i don't bother with verifying. what i have seems sufficient to keep optiboot happy, but i am unsure if it is sufficient for the other Arduino bootloaders out there.

i guess WestfW may be the person to ask about this.


cheers,
rob   :-)

Coding Badly

#16
Jul 01, 2015, 08:45 pm Last Edit: Jul 01, 2015, 08:45 pm by Coding Badly

The entire Optiboot command loop is only 160 lines.  I suspect your eyeballs will work just fine to determine which STK500v1 commands are used / important...

https://github.com/Optiboot/optiboot/blob/master/optiboot/bootloaders/optiboot/optiboot.c#L515-674



robert rozee

yes, the optiboot commands are well defined, and i have already seen the list:

(supported)
STK_LOAD_ADDRESS
STK_PROG_PAGE
STK_READ_PAGE
STK_READ_SIGN
STK_LEAVE_PROGMODE
STK_GET_PARAMETER

(harmlessly ignored)
STK_UNIVERSAL
STK_SET_DEVICE
STK_SET_DEVICE_EXT
(from: https://github.com/Optiboot/optiboot/wiki/HowOptibootWorks)

what i am interested in is hearing about what commands other arduino bootloaders require to be issued for correct operation. indeed, is there any definitive list of bootloaders that have commonly been loaded into shipped arduinos?


cheers,
rob   :-)

Coding Badly

#18
Jul 02, 2015, 10:29 pm Last Edit: Jul 02, 2015, 10:30 pm by Coding Badly

Well, all the source code is under one of these directories...

{ArduinoRoot}\hardware\arduino\bootloaders\
{ArduinoRoot}\hardware\arduino\avr\bootloaders\


The atmega, optiboot, and stk500v2 bootloaders very likely cover the vast majority of the boards you could encounter.  Those three are certainly a good place to start.

Given the fact that the constants start with "STK_" I suspect less than one minute with grep will answer your question.


robert rozee

were any 328p-based arduinos ever made that shipped with an STK500v2 bootloader? i was under the impression that only the 'mega' boards needed to use this protocol, due to the v1 protocol being limited to addressing no more than 128k of flash memory.

i've looked through a couple of the sets of source code, and see a common philosophy of implementing the minimum set of commands required to function. this leaves me pretty comfortable sticking to my 6-step approach above (although STK_ENTER_PROGMODE isn't needed). bearing in mind that i am only interested in supporting 328p-based arduinos.

cheers,
rob   :-)

Coding Badly

were any 328p-based arduinos ever made that shipped with an STK500v2 bootloader?
https://github.com/arduino/Arduino-stk500v2-bootloader/blob/master/stk500boot.c#L277-313

#error "no signature definition for MCU available"


robert rozee

excellent! it sounds like i'm on the right track.

cheers,
rob   :-)

robert rozee

have turned the idea into a standalone GitHub project:

https://github.com/robert-rozee/Prog328P


cheers,
rob   :-)

Leonas

#23
Feb 26, 2016, 07:59 pm Last Edit: Feb 26, 2016, 08:04 pm by Leonas
Thank you very much, robert rozee & Coding Badly, this saved my life. I was trying to get large RSS feeds from a ESP8266 via Serial to an Arduino Mega and my program was too busy with other things to handle the buffer properly. Now that I can increase it to 1024 that problem is solved. So thanks again!

when i open my project in the IDE, the options.h file is also opens. if i change the contents of options.h those changes are reflected in the next compile without needing to restart the IDE. it all seems to work quite seamlessly.
In my case it only runs fine for the first time. When I then want to compile my sketch once more I get:
"GetFileAttributesEx options.h C:\Users\username\Documents\Arduino\libraries\Time\Time.h: The filename, directory name, or volume label syntax is incorrect. Error compiling."

The reference to Time.h is weird because when I close the IDE and then open it again, the sketch compiles flawlessly. Until the next time, that is. Then I have to close and open the IDE again. When I undo the buffer size changes this problem disappears.
Any thoughts, anyone?

Coding Badly

Any thoughts, anyone?
When you changed the boards.txt / platform.txt files did you use \ or / ?




Leonas

#25
Feb 29, 2016, 08:33 am Last Edit: Feb 29, 2016, 02:34 pm by Leonas
When you changed the boards.txt / platform.txt files did you use \ or / ?
Thanks for responding. Well, although I saw your posts involving changing the boards / platform files I just followed the procedure in post #7 and it worked, so I stopped making other changes. But it only works the first compile/upload after loading the sketch into the IDE, the second time I get this error message. Then I close the sketch and reopen it again and I can do another compile. So, I'm not sure the changes to the boards.txt etc. would make a difference, but I can always give it a try.

Coding Badly

#26
Feb 29, 2016, 09:38 am Last Edit: Feb 29, 2016, 09:44 am by Coding Badly

A slash in English prose is an "or".  Details are available here.

So, my question can be rewritten like this...
Quote
When you changed the boards.txt file or the platform.txt file did you use the backslash or the forward-slash character to separate the elements of any file system paths?
I want to know which separator character you used?  Did you make the changes exactly as specified or did you use the Windows backslash separator?  It looks like the only path is in this: "{build.path}/build_options.h".


Leonas

#27
Feb 29, 2016, 02:52 pm Last Edit: Feb 29, 2016, 03:23 pm by Leonas
A slash in English prose is an "or".  Details are available here.

So, my question can be rewritten like this...
I want to know which separator character you used?  Did you make the changes exactly as specified or did you use the Windows backslash separator?  It looks like the only path is in this: "{build.path}/build_options.h".
I guess we are misunderstanding each other. I know what a slash is. :)

Like I said, I just followed post #7. It says to change the line from
build.extra_flags=
to
build.extra_flags=-I "{build.path}" -include options.h
in platform.txt.

That's what I did, literally, like that. Just copy/paste. In other words, there is no slash there. Then I created two options.h files, one in the folder mentioned (empty, 0 bytes), and another one in the current sketch folder with the changed buffer sizes.

I didn't change boards.txt and I didn't use "{build.path}/build_options.h" or "{build.path}\build_options.h".



Leonas

I was just thinking: do you perhaps mean I need to expand "{build.path}" to the actual path myself? Like "c:\program files\...."? I always thought it was for the IDE/compiler/linker to expand.

Leonas

The suspense is unbearable, Coding Badly ;)

In the mean time my problem is solved, or more accurately: I have decreased the size of the RSS messages (smaller but more frequent) and now I can do without increasing the buffer at all. But perhaps it's still nice to know for future readers what the reason is of being able to run only once and the mystery of the slash is still unsolved too. :)

Go Up