stefanrueger / urboot.hex

Pre-compiled urboot bootloaders
GNU General Public License v3.0
10 stars 0 forks source link

New directory structure and file name convention #3

Closed stefanrueger closed 1 year ago

stefanrueger commented 1 year ago

Carried over from https://github.com/stefanrueger/urboot/issues/19 @MCUdude @mcuee @SpenceKonde feel free to comment

[edited to remove _fr frills from options by making them automatically included if there is space]

Some thoughts about what to offer below the mcus/<mcu> level. Note I plan a slightly different structure/naming for cores (will comment later, but basically to make it easier to cope with boards.txt file).

mcuee commented 1 year ago

Just a few general comments. 1) The directory structure is quite complicated, I guess you want to accomodate many use cases so it is probably difficult to avoid the number of layers.

Most likley @MCUdude and @SpenceKonde will only select a subset for their respective Arduino Core projectes.

2) Naming of baudrate, somehow I feel br_++19k2 is not as good as br_19200.

3) watchdog_timeout_xxxxx ms --> Good to have 8192ms option when it is possible. 8192ms is sometimes useful if there is no auto-reset mechanism available for the setup. This becomes less important for me once https://github.com/avrdudes/avrdude/pull/1309 is merged. But it may still be useful sometimes.

stefanrueger commented 1 year ago

Thanks @mcuee: great shouts. The 2048 ms are actually intended for reset by hand. Works quite comfortably for me. This is how I do it: First press the reset button of the board and release it; then start avrdude by pressing enter of the previously typed command line within the WDTO time. 8 s is quite a long time to wait for the application to come on in normal circs when resetting manually (in normal operation, without intention to flash)

stefanrueger commented 1 year ago

Above structure under mcus/ is meant for manual selection. The idea is that a user rocks up with a part, maybe they want to use the internal 8 MHz and have measured it to be 2.2% too slow, they could then go down the tree via internal_oscillator_g-2% and finally get to the bootloader they need. They will in the leaf directory have no more than a handful of choices. The '+' padding helps to find the right frequency or baud rate (I find it mildly irritating when numeric values are sorted lexicographically).

Now to the proposed cores directory scheme:

This way you can use your beloved simple replacement in boards.txt. I would implement this either as copy, hard or soft link from the corresponding bootloader with a long name under mcus.

I haven't used Arduino for well over a decade; IIRC the boards.txt file contains the max upload flash size that the Arduino environment would use to check against too large sketches. With AVRDUDE v7.1 and avrdude -c urclock this is no longer necessary, as it knows how big the bootloader is. But if the size is still a thing, then hexls -use name.hex gives you the occupancy of the bootloader.

BTW, I recommend use of urboot_p_ee_ce.hex bootloaders; I predict (but don't know) they will almost universally fit into the same number of bytes within a core: 384 for MiniCore (3 pages) and 512 for MightyCore (2 pages), eg.

Once I hear from you @MCUdude, @mcuee, @SpenceKonde it might still be a week or so for that to become reality.

SpenceKonde commented 1 year ago

The 2048 ms are actually intended for reset by hand. Works quite comfortably for me. This is how I do it: First press the reset button of the board and release it; then start avrdude by pressing enter of the previously typed command line within the WDTO time. 8 s is quite a long time to wait for the application to come on in normal circs when resetting manually (in normal operation, without intention to flash)

That works if you;re using AVRdude from the command line. But someone using it through the IDE is not going to be doing that, they're going to use the upload button. That takes considerably longer since it has to compile as well. , and 2 seconds is kinda fiddly for that... 8s is not a long time when you have to time a reset to coincide with the start of the compile process, even though there's no delay between the end of compilation and the start of the upload attempt, so you need to watch the upload process a few times, to know what the right moment to release the button is. Then again, any bootloader-using board that isn't using autoreset is going to provide a rather poor user experience

mcuee commented 1 year ago

Then again, any bootloader-using board that isn't using autoreset is going to provide a rather poor user experience

I agree. So this 8192ms bootloaders may be more useful to testers like myself and may not be so useful for the end users. Some board may not even have the reset buttons -- so I have to unplug and plug the board to simulate power up reset. 8192ms will be the minimum for this case -- sometimes Windows may be in the way as well by popping up something.

stefanrueger commented 1 year ago

@mcuee @MCUdude @SpenceKonde

Implemented new directory structure and file name convention

The main aims of this are to

There is a subtle distinction between bootloaders for MCUs driven by an external oscillator, which tend to have a small (< 0.2%) deviation from the nominal FCPU, and MCUs running on an internal oscillator, which more often than not exhibit a deviation of 2% or more from the nominal clock frequency. Urboot bootloaders can and typically will differ for internal and external oscillators of the same frequency

The boards and mcus directories have the following directory structure below the part name:

There are a number of frills, non-essential properties of a bootloader, eg, quicker exit on errors, that will secretly be compiled in if there is space within the current boot section usage. Only the following combinations of above are implemented:

The cores directory scheme:

stefanrueger commented 1 year ago

Good to have 8192ms option when it is possible

@mcuee @SpenceKonde I haven't implemented that yet. Can do when I have found an easy way to augur the watchdog timeouts from the ATDF files. Not all parts have a 128 kHz WDT frequency and not all have the same pre-scalers.

mcuee commented 1 year ago

Good to have 8192ms option when it is possible

@mcuee @SpenceKonde I haven't implemented that yet. Can do when I have found an easy way to augur the watchdog timeouts from the ATDF files. Not all parts have a 128 kHz WDT frequency and not all have the same pre-scalers.

Thanks, With the merging of https://github.com/avrdudes/avrdude/pull/1309, I am less concerned about the lacking of 8192ms WDT timeout urboot bootloader for testing purpose. I just need to use the USB-TTL adapters with either DTR pin or RTS pin (or both). And I have two FT232RL adapters which have the DTR and CTS pins.

FT232RL_AVRISP

Previously, for testing of Optiboot for mega0 AVR (MegaCoreX), Tiny0/1/2 AVR (megaTinyCore) and AVR Dx (DxCore), Optiboot FW with 8192ms WDT timeout was important for me since some of the boards I have do not have automatically reset circuitry built-in. But now at least I can use still use the external FT232RL for testing in that case.

mcuee commented 1 year ago

Good to have 8192ms option when it is possible

@mcuee @SpenceKonde I haven't implemented that yet. Can do when I have found an easy way to augur the watchdog timeouts from the ATDF files. Not all parts have a 128 kHz WDT frequency and not all have the same pre-scalers.

As @SpenceKonde mentioned before, Then again, any bootloader-using board that isn't using autoreset is going to provide a rather poor user experience, I think this is a lower priority.

@SpenceKonde For ATtinyCore (https://github.com/SpenceKonde/ATTinyCore), does the tiny Class AVRs of concerns support 8192ms WDT time out?

mcuee commented 1 year ago

Another thing, if I look into the README.md of ATTinyCore, there are a few Tiny AVRs without bootloader. 1) ATtiny26 -- still in production, no urboot bootloader as of now 2) ATTiny2313 and ATtiny2313A/4313 -- urboot bootloader available 3) ATtiny43U -- urboot bootloader available

stefanrueger commented 1 year ago

ATtiny26 -- still in production, no urboot bootloader as of now

And there is a good reason for this; the urboot makefile tells you when trying:

$ make MCU=attiny26
urboot-gcc: attiny26 not supported (AVR2 core without spm instruction)
stefanrueger commented 1 year ago

Following @MCUdude's comment I've increased the spread and range of internal-frequency variations. Also renamed the directory files for oscillator selection for mcus and boards to sth like

      autobaud
      external_oscillator_x
      internal_oscillator_c-7.50%
      internal_oscillator_d-6.25%
      internal_oscillator_e-5.00%
      internal_oscillator_f-3.75%
      internal_oscillator_g-2.50%
      internal_oscillator_h-1.25%
      internal_oscillator_i
      internal_oscillator_j+1.25%
      internal_oscillator_k+2.50%
      internal_oscillator_l+3.75%
      internal_oscillator_m+5.00%
      internal_oscillator_n+6.25%
      internal_oscillator_o+7.50%

This is that the frequencies are listed in numerical order. The cores structure is still the same (just the actual fcpu directory entries changed).

stefanrueger commented 1 year ago

I might increase the range to +/- 8.75%, which means that if the actual frequency is off by, say, 10.5% that part would still be able to work with the closest one of 8.75%.

I am running into my git-fu limits though (or git is running into limits with the millions of files). The last git add, git commit, git push has taken the best part of 4 hours:

$ time git add mcus boards cores

real    175m10.916s
user    166m32.791s
sys 2m14.044s

$ time git commit -m"Increase spread and range of internal-frequency variations"    

... [hundreds of thousands of lines including, eg,]
 rename mcus/attiny88/watchdog_2_s/{internal_oscillator-1% => internal_oscillator_h-1.25%}/+1m000000_hz/+++9k6_baud/swio_rxd7_txd6/led+d0/urboot_t88_2s_h1m0_9k6_swio_rxd7_txd6_led+d0.hex (100%)
 rename mcus/attiny88/watchdog_2_s/{internal_oscillator-1% => internal_oscillator_h-1.25%}/+1m000000_hz/+++9k6_baud/swio_rxd7_txd6/led+d0/urboot_t88_2s_h1m0_9k6_swio_rxd7_txd6_led+d0_pr.hex (100%)
 rename mcus/attiny88/watchdog_2_s/{internal_oscillator-1% => internal_oscillator_h-1.25%}/+1m000000_hz/+++9k6_baud/swio_rxd7_txd6/led+d0/urboot_t88_2s_h1m0_9k6_swio_rxd7_txd6_led+d0_pr_ce.hex (100%)
 rename mcus/attiny88/watchdog_2_s/{internal_oscillator-1% => internal_oscillator_h-1.25%}/+1m000000_hz/+++9k6_baud/swio_rxd7_txd6/led+d0/urboot_t88_2s_h1m0_9k6_swio_rxd7_txd6_led+d0_pr_ee.hex (100%)
 rename mcus/attiny88/watchdog_2_s/{internal_oscillator-1% => internal_oscillator_h-1.25%}/+1m000000_hz/+++9k6_baud/swio_rxd7_txd6/led+d0/urboot_t88_2s_h1m0_9k6_swio_rxd7_txd6_led+d0_pr_ee_ce.hex (100%)
...

real    7m53.279s
user    3m54.341s
sys 3m36.385s

$ time git add README.md

real    0m9.257s
user    0m8.285s
sys 0m1.619s

$ time git commit -m"Update README.md"
[main 0ce50f11d566] Update README.md
 1 file changed, 1 insertion(+), 1 deletion(-)

real    0m9.266s
user    0m8.980s
sys 0m14.978s

$ time git push
Enumerating objects: 2973240, done.
Counting objects: 100% (2973240/2973240), done.
Delta compression using up to 16 threads
Compressing objects: 100% (930017/930017), done.
Writing objects: 100% (2972918/2972918), 583.30 MiB | 5.63 MiB/s, done.
Total 2972918 (delta 1850157), reused 2972639 (delta 1849881)
remote: Resolving deltas: 100% (1850157/1850157), completed with 3 local objects.
To github.com:stefanrueger/urboot.hex.git
   778fdc95e1c8..0ce50f11d566  main -> main

real    3m16.069s
user    0m24.262s
sys 0m7.865s

$ time git status
On branch main
Your branch is up-to-date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    fix-percent.sed

It took 36.71 seconds to enumerate untracked files. 'status -uno'
may speed it up, but you have to be careful not to forget to add
new files yourself (see 'git help status').
nothing added to commit but untracked files present (use "git add" to track)

real    0m39.475s
user    0m26.701s
sys 0m27.643s
MCUdude commented 1 year ago

I am running into my git-fu limits though (or git is running into limits with the millions of files). The last git add, git commit, git push has taken the best part of 4 hours:

I cloned the urboot.hex repo yesterday with ~40GB of free space on the disk. After 15 minutes or so the computer turned really hot and really slow, and I got tons of OS warnings saying that the amount of free space was critically low. The whole cloning sequence took about an hour or so.

stefanrueger commented 1 year ago

[cloning] took about an hour or so

:smile: Hopefully catching up with the larger range that I just pushed won't take that long (but it won't reduce your disk space for sure). Git took only 18 minutes this time to add the 255,192 new .hex files. Yes, we are pushing the envelope on git; comes from the explosion of the number of parametrised bootloaders, of course.

Maybe I should go back to my template bootloader idea: I already have a number of markers in the bootloader .elf that signify important parameters: different mov rx, rx opcodes (glorified nops) are placeholders for LED blinking operations that set/clear GPI/O pins and/or CS of the external SPI flash memory. An external label in the .elf file tells any interested program where the bootloader loads the bit pattern for the watchdog timer register. Could do the same for the baud rate divider for UARTs or the loop counter for the bit delay for SWIO; these decide the baud rate in relation to F_CPU. Again the bit twiddling for SWIO operations can be recognised by the port operations, and the operations for the USART registers cn be furnished with external labels.

Soooooo, knowing a dozen or so pre-compiled bootloaders per part, a simple program could generate tens of thousands bootloaders within a few seconds (or just the one you currently need within less than a millisecond). No compiler needed. Just the template bootloaders. But that's for another day.

mcuee commented 1 year ago

Just one simple idea to get around the git performance issue -- release them as a single zip file in the git repo for the following folde. https://github.com/stefanrueger/urboot.hex/tree/main/mcus

Then you can also add a README file in this folder to document the directory structure.

MCUdude commented 1 year ago

Just one simple idea to get around the git performance issue -- release them as a single zip file in the git repo for the following folder.

Maybe a tar file would be even better? No compression, so extracting will be faster.

stefanrueger commented 1 year ago

I don't so much worry about git performance on my side. Some bash file just takes as long as it takes. We are talking O(10m) files, so 3 hours for processing them is O(1 ms) per file. Really, really fast when looked at it from this perspective. I can add mcus.tar cores.tar etc files to the repository though that will increase the load on git. And if the repository creates these files a few times, git will remember them all and resolve many more deltas on a git clone. Unless I do a rebase and force push once in a while to make git forget previous versions of pre-compiled bootloaders.

I defo want to keep the directory structure with all the .hex files, so people can browse, select and download individual bootloaders. (I use that myself rather than compiling a bootloader).

stefanrueger commented 1 year ago

I have decided that rather than putting up additional tar files to give the following advice at the bottom of the readme file:

Cloning this repository can take long and create a large directory (some 70 GB). Pro tip: Download a zip file instead from github or execute on the command line

curl -L https://github.com/stefanrueger/urboot.hex/tarball/master >urboot-hex.tar

This creates a roughly 2 GB gzip compressed tar file from the current snapshot.

mcuee commented 1 year ago

I defo want to keep the directory structure with all the .hex files, so people can browse, select and download individual bootloaders. (I use that myself rather than compiling a bootloader).

Haha, that is my use case as well. I do not clone this repo as my two computers (an Acer Windows 11 laptop and Mac Mini M1) do not even have enough disk space.

mcuee commented 1 year ago

I have decided that rather than putting up additional tar files to give the following advice at the bottom of the readme file:

Cloning this repository can take long and create a large directory (some 70 GB). Pro tip: Download a zip file instead from github or execute on the command line

curl -L https://github.com/stefanrueger/urboot.hex/tarball/master >urboot-hex.tar

This creates a roughly 2 GB gzip compressed tar file from the current snapshot.

This looks like a very good solution.

SpenceKonde commented 1 year ago

I guess i haven't been paying attention but the. 70gb in a repo of avr bootloader files caught my attention..... that seems insane and the 2gb tarball Stull seems too big. Try .bz2 instead of zip - it does a markedly better job sometimes (and nearly the same results at other times


Spence Konde Azzy’S Electronics

New products! Check them out at tindie.com/stores/DrAzzy GitHub: github.com/SpenceKonde ATTinyCore: Arduino support for almost every ATTiny microcontroller Contact: @.***

On Wed, Apr 12, 2023, 07:27 mcuee @.***> wrote:

I have decided that rather than putting up additional tar files to give the following advice at the bottom of the readme file https://github.com/stefanrueger/urboot.hex/blob/main/README.md:

Cloning this repository can take long and create a large directory (some 70 GB). Pro tip: Download a zip file instead from github or execute on the command line

curl -L https://github.com/stefanrueger/urboot.hex/tarball/master >urboot-hex.tar

This creates a roughly 2 GB gzip compressed tar file from the current snapshot.

This looks like a very good solution.

— Reply to this email directly, view it on GitHub https://github.com/stefanrueger/urboot.hex/issues/3#issuecomment-1505106877, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTXEW6D6ABSC5X522C6UYDXA2GRZANCNFSM6AAAAAAV7UQE7Y . You are receiving this because you were mentioned.Message ID: @.***>

stefanrueger commented 1 year ago

Try .bz2 instead of zip

Well, tell github :smile: . The suggested curl command of github's master tarball results in a gzipped tar file on your stdout. It's up to you to recode that into your favourite compression or extract just what you want on the fly, eg, | tar xfz - stefanrueger-urboot.hex-c0b7524/cores/microcore/ ...

But yes, the corresponding tar.bz2 file would only be 700 MB in contrast to the gzipped tar file with 1.8 GB, the uncompressed tar file of 30 GB and the fully expanded directory structure with 60 GB. It's 9.2m .hex files and 1.3m readme files. The readme files make some 12 GB of the github usage. Also, github does not preserve the hard links between identical bootloaders in the tarball, so on my own computer the 9.2m bootloaders only have a disk usage of 18 GB

stefanrueger commented 1 year ago

Just released version u7.7 of the .hex repository and the urboot source - closing this issue