Uzebox Bootloader V5

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
Post Reply
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Uzebox Bootloader V5

Post by Jubatian »

This is the "new" Version 5 bootloader for Uzebox. It is already part of the Master Uzebox repository.
bootloader.jpg
bootloader.jpg (48.07 KiB) Viewed 46717 times
Features:
  • SDHC support. It should be able to properly use both SDSC and SDHC cards.
  • FAT32 support.
  • Fragmentation support (both on files and the FAT32 root directory).
  • Robust programming with error checking and retry as necessary.
  • Exposed SD & FAT API which can be accessed by the Bootloader API library to add SDHC & FAT32 support to games.
  • Fully assembler source, no dependency on C compiler optimizations.
  • Hot-plug support (you can insert and remove cards while in the bootloader).
  • SD cards with only one .UZE file on them are auto-booted (unless requesting bootloader entry with the controller).
  • Programs based on difference between the game file and the ROM (no longer using the CRC like the 0.4.5 bootloader).
  • Supports up to 255 .UZE files on a single card (other files on the card are not counted against this limit).
Some notes on game programming: This bootloader will always display the progress bar, even when no actual programming takes place as it no longer relies on the game CRC. It always reads the full game and checks the ROM whether it matches, and programs only pages where the contents doesn't match.

In the selector, now both Select and Start starts the game. You can select Game / Menu with the button 'B'. I did this so since I repeatedly switched Game / Menu by accident instead of programming.

Currently the 4K bootloader space is very much full, but likely most of the features we could desire from it are already in!

Note that you can safely compile and use it (unlike the 0.4.5 bootloader) as its source is 100% assembly: you will always get the same binary regardless the compiler version you are using. A most recent version of the compiled binary is kept attached here though if you don't want it.

An alternate version with MMC support (no SDHC) was made by Janka, the patch and a V.5.0.10 hex compiled from it can be found here. You may pick that if you have a bunch of ancient MMCs laying around.
Attachments
Bootloader5.hex
(11.29 KiB) Downloaded 586 times
Last edited by D3thAdd3r on Tue Dec 19, 2023 12:48 am, edited 18 times in total.
Reason: .hex updated to Uzebox Game Loader 5.0.12, built uzing gcc 13.2.0(Dec 2023)
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: New bootloader

Post by Jubatian »

There is one particular weird bug which I was unable to figure out so far. In some rare cases somehow at least on my television, I receive no video signal (or my television for some reason decides it is not good enough for it). The particularly weird thing is that the bootloader the same time is completely functional, if I push buttons from memory, I can select and program a game. Then it typically resolves. I seriously can't imagine what causes it as even unplugging my Uzebox for a few seconds won't help when this happens (so it is actually consistent, like if I saved a "don't create video signal" flag in the EEPROM this case, but of course I have nothing which could be interpreted in this manner, I seriously can't imagine what persists in the AVR in this manner).

I might actually be screwing up my TV though (or possibly the AD725). I purposedly timed this bootloader so it tries to generate video signal as soon as possible, so typically the TV no longer loses sync between programming and game or when returning to the bootloader. That's different like before (my TV always lost sync between programming and game either way with the old bootloader).
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: New bootloader

Post by Artcfox »

Holy crap, I can't believe you wrote this already!

I tested it on my phone with the Android port, and it works great. My kit version case doesn't have the ISP header exposed, so I'll have to break the glue to open it up and try it out.

I would suggest having it display the version number somewhere before this gets too much out in the wild (though it is a .tar.bz2, so that might stop it from spreading too far in the wild for Windows users).

Nice work!
User avatar
ry755
Posts: 226
Joined: Mon May 22, 2017 6:01 am

Re: New bootloader

Post by ry755 »

Awesome! I'm not at home right now, so I can't test it yet. But hopefully the error checking will help with the SD reading issues on my breadboard Uzebox. Fragmentation support? Great! :D
User avatar
nicksen782
Posts: 714
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: New bootloader

Post by nicksen782 »

I gave it a shot with the online emulator. It loaded but said to insert an SD card. I included the Alter Ego files.

I tried the same thing again but with the old boot loader and the Alter Ego game appeared on the list.

Maybe a bug?


Oh, and the idea of auto flashing the game if it is the only .uze on the SD card is brilliant! In a way we could kinda have cartridges now! I would suggest however that this be some kind of config file instead of just happening automatically.
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: New bootloader

Post by Jubatian »

I did some further trimming in the afternoon and managed to find enough room to add the missing features. It has page numbers and a version number display now. I started numbering from 5.0.00. (I replaced the download in the top post)
nicksen782 wrote: Sun Oct 08, 2017 6:12 pmI gave it a shot with the online emulator. It loaded but said to insert an SD card. I included the Alter Ego files. (...)
I did my testing in CUzeBox, so it should really work. Maybe the online emulator carries a too old CUzeBox version (there were a few minor bugfixes which might have had effects), as far as I see it is one not even having a version identification (compile date in the lower right corner).
nicksen782 wrote: Sun Oct 08, 2017 6:12 pmOh, and the idea of auto flashing the game if it is the only .uze on the SD card is brilliant! In a way we could kinda have cartridges now! I would suggest however that this be some kind of config file instead of just happening automatically.
With 12 bytes free? :P I would rather reserve that for more important stuff! :D I checked that feature, I especially made it so holding a controller button overrides it, and you get in the bootloader. This way it feels intuitive.
Last edited by Jubatian on Sun Oct 08, 2017 8:32 pm, edited 1 time in total.
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: New bootloader

Post by Jubatian »

ry755 wrote: Sun Oct 08, 2017 5:36 pmAwesome! I'm not at home right now, so I can't test it yet. But hopefully the error checking will help with the SD reading issues on my breadboard Uzebox. Fragmentation support? Great! :D
It uses a slower SPI clock (the CRC calculation would not let exploiting max speed anyway), and attempts a retry if it detects a failure. Hopefully it will let even poorer contacts working right (and things like micro-SD cards in sloppy adapters). It should report programming failure if it can't load data at all, I verified it by pulling off the card while programming. So far it seems to work reasonably well.

EDIT:

There is another thing why the autoboot of a single UZE file SD card may be convenient. If you are developing a game, you might be trying it on the real hardware in such a manner: you copy it on a blank card (blank since the old bootloader doesn't support fragmentation, you have to wipe it to be sure), plug it in, start the bootloader, select it to load. Now plugging the card in and pressing reset will simply start the game.
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: New bootloader

Post by Jubatian »

I managed to discover in what conditions that weird bug happens that the display somehow disappears.

Uploading some version of my SDHC tests which I had laying around on my SD cards cause it. After it is programmed, the bootloader no longer generates display. It is really weird as it operates completely normal otherwise, it is even possible to select a new game, just that it generates no display until another game is programmed.

What I seriously can't understand, how this can even happen since at reset or after power up (the behavior persists) nothing of the uploaded game should run. The bootloader's init procedure until turning on the display doesn't even read EEPROM, nor it accesses anything from the game. I don't know what storage device even comes in play here. So far it only seems to happen with that SDHC test. It doesn't even relate SD access as other games (Alter Ego, Roguze, Chickens in Choppers) don't trigger this.

Looks like I found some hidden bit accidentally? :shock: (If you find anything producing similar result, tell!)
User avatar
nicksen782
Posts: 714
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: New bootloader

Post by nicksen782 »

Jubatian wrote: Sun Oct 08, 2017 6:33 pm I did my testing in CUzeBox, so it should really work. Maybe the online emulator carries a too old CUzeBox version (there were a few minor bugfixes which might have had effects), as far as I see it is one not even having a version identification (compile date).
I updated the CUzeBox on the online player. The problem went away. The version I had was from June. The FS I created only had one .uze on it so it auto-flashed as expected. I also confirmed that having a second .uze file will block the auto-flash. Additionally, not including any .uze files will show the error message of "Empty SD Card". This same error occurs if I include not .uze files such as .hex (this is likely expected behavior.)

Question, what CUzeBox changes have occurred since June?
Jubatian wrote: Sun Oct 08, 2017 6:33 pm With 12 bytes free? :P I would rather reserve that for more important stuff! :D I checked that feature, I especially made it so holding a controller button overrides it, and you get in the bootloader. This way it feels intuitive.
12 bytes free? Wow. What about something like checking the binary and the flash data to detect a game difference then offering like a 5 second countdown before auto flash?
Jubatian wrote: There is another thing why the autoboot of a single UZE file SD card may be convenient. If you are developing a game, you might be trying it on the real hardware in such a manner: you copy it on a blank card (blank since the old bootloader doesn't support fragmentation, you have to wipe it to be sure), plug it in, start the bootloader, select it to load. Now plugging the card in and pressing reset will simply start the game.
This is a great point!
User avatar
ry755
Posts: 226
Joined: Mon May 22, 2017 6:01 am

Re: New bootloader

Post by ry755 »

I tested it and it keeps saying "Insert SD Card" no matter what I try. I tried 3 different sd cards. Could the resistance in the breadboard be messing it up?
Post Reply