-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide Urclock programmer #1171
Conversation
First test seems to be good, using
|
Somehow
|
Using
|
Somehow I'd like to see more complete sentence in the help file. Just a personal taste.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just some minor comments.
src/avrintel.c
Outdated
* | ||
* v 1.1 | ||
* 30.08.2022 | ||
* 04.11.2022 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering if this is good to change to 04-Nov-2022 as it is ambiguous and may get interpreted wrongly by US based people
src/avrintel.h
Outdated
@@ -9,7 +9,7 @@ | |||
* meta-author Stefan Rueger <[email protected]> | |||
* | |||
* v 1.1 | |||
* 30.08.2022 | |||
* 04.11.2022 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering if this is good to change to 04-Nov-2022 as it is ambiguous and may get interpreted wrongly by US based people
@@ -549,7 +550,7 @@ static int ser_drain(const union filedescriptor *fd, int display) { | |||
unsigned char buf; | |||
|
|||
timeout.tv_sec = 0; | |||
timeout.tv_usec = 250000; | |||
timeout.tv_usec = serial_drain_timeout*1000L; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not related to this PR, or is it causing problem for this PR?
@@ -635,7 +636,7 @@ static int net_drain(const union filedescriptor *fd, int display) { | |||
} | |||
|
|||
timeout.tv_sec = 0; | |||
timeout.tv_usec = 250000; | |||
timeout.tv_usec = serial_drain_timeout*1000L; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not related to this PR, or is it causing problem for this PR?
src/avrdude.conf.in
Outdated
# See https://github.com/stefanrueger/urboot | ||
programmer | ||
id = "urclock"; | ||
desc = "Urclock programmer for urboot bootloaders (arduino compatible)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not always compatible with Arduino, right? -->
Edit: probably it is compatible with existing -c arduino
bootloaders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
It seems to still timeout after some time for the terminal mode, using
|
The first hex file does not support EEPROM read/write but I am not so sure if the fault behavior from
The optiboot hex file seems to behave better.
|
@stefanrueger I am not so sure how to test it supports
|
@stefanrueger
|
Very, very cool! I'm deeply impressed with your work, (even though my limited English vocabulary prevents me from using all the superlatives I would use if writing Norwegian). If this turns out to be as reliable as Optiboot, I might end up bundling Urboot instead of Optiboot with my Arduino cores to help mass-test Urboot. However, this can only happen once Avrdude 7.1 has been released and adopted by the Arduino devs. I'd also have to wait for the PlatformIO devs to update their Avrdude binaries. I'll give it a try on various hardware later this evening. I haven't read through all documentation, but it is possible to build urboot to use a hardware serial port instead of software serial? It would also be amazing if the bootloader would support automatic baud rate selection. There exist optiboot forks out there that implement this, and it's done by measuring the 0x55 sync bytes the stk500 protocol sends before attempting to connect to the target. Even if this increased the compiled size to > 512 bytes, it would still be very convenient on chips with >=64kiB flash. |
I've tested urboot on an ATmega1284P, and everything works great so far! The features baked into the -x flags are really cool. I'm sure @WestfW could find this bootloader interesting. A few questions:
|
Terminal mode seems to be broken in this PR. I'm getting a segmentation fault with urclock and with a pickit4: PICkit4 terminal output
Urclock terminal output
|
Whenever I have had a seg fault in avrdude, it was because of make not realising some files were changed (it goes by date, not checksum). Of course, it could also be some real problem but AVRDUDE rarely has these. |
You're right. I was sure I ran |
Phew! Glad this is the case. @mcuee, @mariusgreuel and I spent a great deal of effort to make this work in all platforms (I think there are wrinkles for Windows, but nothing I canhelp with). See Issue #1028 started back in July... I have shifted from make to cmake (well I have a makefile that uses cmake :)
I still type |
@mcuee Thanks for testing! I am glad you found a few things that can be improved.
True, currently the urclock/urboot combo only deals with classic parts, which traditionally don't have page erase capabilities (only chip erase). So, I haven't implemented page erase in
I parameterised the previously constant drain timeout (250 ms) to be changable in the same way as This change does not affect other programmers. They still use 250 ms drain timeout. @mcuee: Great find with the terminal write eeprom problem when the bootloader does not support it! I have just fixed this. I also noted that you tried to read fuses in I will have to take a closer look at the big boot bootloader. Thanks for pointing out that there might be a different behaviour to Keep the fantastic testing up, @mcuee. The more problems and issues we find the merrier! |
Template bootloaders can change the LEDs, CS and RX, TX lines at burn time (actually also the WDT timeout). I have written a sketch |
Well, technically this means Here the gory details from the source:
|
Defo. Using the USART is actually the default in urboot.c if the part has an USART that is. Otherwise, it's software I/O. Now, the thing is that a 8 MHz MCU on 115200 baud has too big a baud rate error for me to be happy. Therefore I have compiled with SWIO on for this combination of 8 MHz and 115200 baud when building the 350,000 pre-compiled bootloaders. |
If only I knew! I must have used this flag to indicate something or another when developing. Good find. I will remove this (or figure out if it is something important). |
Cool! I looked around in the makefile, and later found Another neat thing Optiboot has is a simple API for interfacing with the bootloader's SPM functionality from within the user application. I've created a C++ wrapper library around this API to make it easier for the user to store various data to flash. I'm sure Urboot could provide a similar API the library can interface with instead. |
Yes, there is a generic SPM subroutine in urboot executing the various SPM functionality depending on the argument; this to keep the code size small. All that would be needed is a further two bytes in the table at FLASHEND to
The bash script that compiles them all (
Feel free to poke around in |
If anyone of you has an ATtiny2313, I'd really be interested to know whether the bootloader prominently featuring the top spot in the table at the urboot project actually works. I only tested 5 parts (and don't think I have other parts at home). |
I'd like to have the following changes as well.
|
Yes I can see
|
@stefanrueger
|
@MCUdude and @mcuee: Yes, this is correct behaviour for vector bootloaders. You may think of a vector bootloader as the code in top flash plus the rest vector at address 0. In order for vector bootloaders to work, the reset vector must point to the bootloader at virtually all times otherwise the bootloader is at risk of no longer being reached. 0xcf3f at address 0 is
So, if you use As urboot bootloaders export a TLDR; |
With regard to this commit 2e39891, I am not so sure some of the hex files are compatible with STK500v1.
Source codes: I believe they share the same Caterina bootloader as the following, and we actually use AVR109: Or maybe the bootloader is compatible with both (subset of both)? I think they are only for AVR109/AVR910 and not compatible with STK500v1, if you look at the codes.
Please also refer to my previous comment here. |
Sorry I find another issue with Optiboot FW with the Nano clone. 80ms is too short for the board if using So the urboot autobaud FW works with 80ms but not 250ms. Optiboot FW works with 250ms but not 80ms. It seems to me 150ms may be a good compromise for Windows. Sorry for the late findings. We need something like:
The other possibility is not to change, as we already ask the user to add |
Testing results with the default Arduino I need the following patch to get it working. This is the same for the Nano clone (ATmega328P, 16MHz).
Testing results:
|
Nano ATmega328P (5V, 16MHz).
150ms is okay with urboot autobaud FW as well.
|
There is a strange thing that the following command does not echo back ok, under Windows. Windows Terminal
MSYS2
Windows command prompt:
This does not happen with
|
Even under Linux, 80ms does not seem to be enough for the This happens with both the Uno ATmega16U2 clone and the Nano CH340 clone. Unfortunately changing to 150ms timeout does not help either. Strange.
|
Even with urboot stk500v1 FW it does not work. This is strange.
|
Something is not so right under Linux. I will check again tomorrow to see if I have somethings not done correctly like the fuse settings or other things. |
I will create seperate ssues for the echo thingy as I can reproduce under Linux as well. |
This PR implements discussion #940.
-c urclock
programmer is compatible with-c arduino
in the sense that it can also deal with arduino bootloaderspgm_write_page(sram, progmem)
function that one can call at FLASHEND-4+1 to use flash for storageOK, how to test this? Grab a 16 MHz atmega328p board with an LED on Pin PB5 (Uno, ProMini), flush it with one of the following 115200 baud bootloaders and do your usual stuff. Notice the low flicker of the LED when in terminal mode? Tells you, it hasn't timed out...
w-u-jpr
weu-jpr
wes-hpr
--s-h-r
weudhpr
w
urboot providespgm_write_page(sram, flash)
for the application atFLASHEND-4+1
e
EEPROM read/write supportu
uses urprotocol requiringavrdude -c urclock
for programmings
uses skeleton of STK500v1 protocol;-c urclock
and-c arduino
both workd
dual boot (over-the-air programming from external SPI flash)h
hardware boot section: make sure fuses are set for reset to jump to boot sectionj
vector bootloader: uploaded applications need to be patched externally, eg, usingavrdude -c urclock
p
bootloader protects itself from being overwrittenr
preserves reset flags for the application in the register R2ee
bootloader supports EEPROM read/writeled-b1
toggles an active-low LED on pinB1
,+
designates an active-high LEDcsb0
for dual boot uses, in this example, pin B0 as chip select of external SPI flash memoryfr
bootloader provides non-essential code for smoother error handingce
bootloader provides a chip erase commandur
uses urprotocol and requiresavrdude -c urclock
for programmingvbl
vector bootloader: set fuses to jump to reset, not the HW boot sectionTesting. Please try your worst to break
-c urclock
or any of the urboot bootloaders :)Note that the dual-boot bootloader in the last line expects an external SPI flash memory with
CS
on PinB0
. If it isn't there the bootloader will realise there is no flash connected and gracefully skips booting from external memory. Just be sure not to connect the signalOPEN_GATE
of your crocodile enclosure toB0
...B3
as the bootloader toggles the SPI lines.Metadata. Probably a matter of taste, I personally quite like them: Use
-c urclock
to upload blink.hex on your board; then queryIf it's a bootloader that shows
u
in the features then you can even leave away the-pm328p
bit; the urprotocol tellsAVRDUDE for which part the bootloader on the board was compiled.
If you specify a different part, it will complain as usual
Extended options. Check the documentation, in the first instance
$ man avrdude
(I will update avrdude.texi later), or executeEnjoy.