Question UF2 files - what are they? 512Kb R4s dongle?

Discussion in 'Switch - Backup Loaders & Modchips' started by Fehniix, Aug 22, 2019.

  1. Fehniix
    OP

    Fehniix Newbie

    Newcomer
    1
    Aug 22, 2019
    Australia
    Hello everyone.

    I would like to know what *.UF2 files are to be eventually able to compile my own to run the latest version of Atmosphere, Reinx etc.
    I have updated the Nintendo Switch to the latest firmware, 8.1.0, and the R4s dongle stopped launching Atmosphere; I have started all over again.

    The R4s dongle seems to accept only 512Kb UF2 files content of which seem completely different than common payload binaries.
    I suspected the R4s checked for the "CURRENT.UF2" file to be exactly 512Kb to be able to upload it, and thus check only its size; I would expect that file, then, to contain the payload binary (Atmo, Reinx etc.) and a series of 0's making up to 512Kb but that's apparently not the case.

    How could I go around getting Atmosphere or anything else back running on the dongle, considering the Switch is updated to 8.1.0?

    Thank you!
     
  2. Fehniix
    OP

    Fehniix Newbie

    Newcomer
    1
    Aug 22, 2019
    Australia
    What I have already tried:

    • Downloading the latest version of Hekate
    • Setting up the Arduino IDE with all the necessary Adafruit Trinket M0 board (which I suppose the R4s runs on) libraries
    • Converted the Hekate payload .bin file to .h using the Sam-Fuseé binConverter.py script
    • Compiled and exported Sam-Fuseé launcher sketch with the Arduino IDE (importing the new .h file from the payload)
    • Converted the sketch to UF2 with default base address (0x2000) with this ([Github]/lancaster-university/codal/blob/master/utils/uf2conv.py) Python script

    The output file seems to be 289Kb which the R4s dongle won't accept. Is there anything I'm missing?

    Reference: [GBATemp]/threads/how-to-compile-bin-payloads-to-uf2.518516/
     
    Last edited by Fehniix, Aug 22, 2019
  3. Kafluke

    Kafluke GBAtemp Guru

    Member
    13
    May 6, 2006
    United States
    I use UF2 files with my trinket modchip. I think they're device specific.
     
  4. The Real Jdbye

    The Real Jdbye Always Remember 30/07/08

    Member
    19
    GBAtemp Patron
    The Real Jdbye is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Mar 17, 2010
    Norway
    Alola
    No, I don't think it uses a Trinket M0, they are using something custom, but it may be using the same chip. Trinkets are only used for homebrew (not that kind of homebrew) solutions.

    Edit: https://learn.adafruit.com/adafruit...t-python-circuitpython/uf2-bootloader-details
    Looks like Microsoft MakeCode might be what you need.
    UF2 is a format developed by Microsoft for firmware flashing.
     
    Last edited by The Real Jdbye, Aug 22, 2019
    Fehniix likes this.
  5. Fehniix
    OP

    Fehniix Newbie

    Newcomer
    1
    Aug 22, 2019
    Australia
    This is great news, I looked into it.

    Still seems very odd that the Python script would output a file with arbitrary size and not what the fixed, 512Kb, size should be.
     
  6. The Real Jdbye

    The Real Jdbye Always Remember 30/07/08

    Member
    19
    GBAtemp Patron
    The Real Jdbye is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Mar 17, 2010
    Norway
    Alola
    That's the magic of UF2. When you copy an UF2 file to the drive, it's actually being flashed as firmware to the microcontroller. The UF2 file itself tells it which address to flash the file to. It will be using some constant size simply because they have set apart a certain amount of space for each payload so the firmware area of the file is padded out to fill that space. Flashing a smaller file probably wouldn't do any harm though as the data at the end probably isn't necessary.
    For that reason, you need to make sure that the flash address and other info matches what is in the existing UF2 file(s) so they get flashed in the correct way.
    It would be much easier if the drive acted as more conventional storage so you could just copy payloads across directly, like how it works with the RCMLoader One dongle. Which costs about $10 just FYI. I would gladly pay that to not have to deal with UF2 files myself. :P
     
    Last edited by The Real Jdbye, Aug 22, 2019
    Fehniix likes this.
  7. TariqSoftDev

    TariqSoftDev ~Zexceil

    Member
    5
    Sep 18, 2013
    London
    UF2 is a bootloader found here: https://github.com/microsoft/uf2-nrf5
    They're compiled for custom boards using the ARM M0/M4 chips, they're all specific and custom configurable.
    UF2 Files are used to reprogram the UF2 bootloader with another program, you can't recreate it yourself unless you open it up, check the MCU and map out the hardware it uses.
     
  8. tivanh

    tivanh GBAtemp Regular

    Member
    3
    Sep 14, 2009

    When Argon NX is injected, it automatically launches the payload.bin loacted at argon directory on your SD Card root.

    If payload.bin is not present or VOLUME DOWN button is pressed on payload injection, Argon NX will list all payloads located at argon/payloads, and you will be able to select one of them to launch it.

    Have you updated the payload in the argon directory on the sd?
     
    Last edited by tivanh, Aug 23, 2019
    Fehniix likes this.
  9. Fehniix
    OP

    Fehniix Newbie

    Newcomer
    1
    Aug 22, 2019
    Australia
    So it doesn't really matter what firmware the Switch runs on, a payload will always be able to be injected because ArgonNX functions similarly to Hekate? It's a payload injector the dongle runs natively on?

    I have replaced the bootloader with one I have found here in the forums, compiled by tom[...] if I remember correctly, which I believe either launches Atmosphere found on the SD card or has Atmosphere 0.9.3 embedded in it which gets launched.

    Why would it be necessary to additionally map the hardware it uses?

    Thank you! For curiousity's sake, would you ever attempt building an injector dongle and deal with bootloader yourself? I have just started out fiddling around with Arduino and electronics in general, this might be a pretty interesting project.
     
  10. TariqSoftDev

    TariqSoftDev ~Zexceil

    Member
    5
    Sep 18, 2013
    London
    Because you got GPIO's, memory mappings and etc; I had to rewrite some UF2 stuff so it would support my MCU.
     
  11. Fehniix
    OP

    Fehniix Newbie

    Newcomer
    1
    Aug 22, 2019
    Australia
    Interesting. I suppose then you built your own device to inject payloads, correct? If so, may I ask you what you used, how you did it etc.? I'm very curious and would to do something like this on my own as well.
     
  12. TariqSoftDev

    TariqSoftDev ~Zexceil

    Member
    5
    Sep 18, 2013
    London
    Just check this forum for the ReLOAD mochip thread, there'll be a Discord there; I prefer discord over this.
     
  13. The Real Jdbye

    The Real Jdbye Always Remember 30/07/08

    Member
    19
    GBAtemp Patron
    The Real Jdbye is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Mar 17, 2010
    Norway
    Alola
    I would probably stick with the Arduino bootloader since it's easy enough to flash firmware with that.
     
  14. MatinatorX

    MatinatorX GBAtemp Regular

    Member
    8
    Jul 17, 2018
    Canada
    Yup not much point in writing your own bootloader, easier to just modify Microsoft's UF2 bootloader to work on your SAMD chip and do your user code in Arduino.
     
Loading...