{"id":19065394,"url":"https://github.com/newaetech/sonata-rp2040","last_synced_at":"2025-04-28T11:27:30.602Z","repository":{"id":215153940,"uuid":"733654596","full_name":"newaetech/sonata-rp2040","owner":"newaetech","description":"rp2040 firmware for Sonata","archived":false,"fork":false,"pushed_at":"2024-10-31T21:22:29.000Z","size":5099,"stargazers_count":4,"open_issues_count":4,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-28T11:27:24.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/newaetech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-19T20:25:31.000Z","updated_at":"2025-01-17T07:22:56.000Z","dependencies_parsed_at":"2024-04-24T17:50:48.219Z","dependency_job_id":"71ea795e-8a20-4f8c-b01a-cc8e71f764a7","html_url":"https://github.com/newaetech/sonata-rp2040","commit_stats":null,"previous_names":["newaetech/sonata-rp2040"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newaetech%2Fsonata-rp2040","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newaetech%2Fsonata-rp2040/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newaetech%2Fsonata-rp2040/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newaetech%2Fsonata-rp2040/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/newaetech","download_url":"https://codeload.github.com/newaetech/sonata-rp2040/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251303917,"owners_count":21567772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T00:49:47.637Z","updated_at":"2025-04-28T11:27:30.563Z","avatar_url":"https://github.com/newaetech.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RP2040 Firmware for Sonata Board\n\n## Usage\n\n### Copying Bitstreams/Firmware\n\nOnce plugged in, the Sonata board should enumerate as a USB mass storage device. Bitstreams\nand Sonata firmware can both be programmed by copying their respective files to the mass\nstorage device. Bitstreams and firmware must be in UF2 format with a maximum block size\nof 256 bytes and device IDs of `0x6ce29e6b` and `0x6ce29e60`, respectively. Only the data\nportion of the UF2 block is written to flash.\n\nNote that the FPGA is currently erased during both firmware and bitstream programming,\nthen reprogrammed afterwards.\n\n### Flash Slots\n\nBitstream and firmware both have 3 flash slots, which can be selected via the 3 position\nBitstream select switch by the USB port on the device. This controls both where\nbitstream/firmware are written to when programming, as well as where bitstreams\nare loaded from on device boot.\n\n### Logging/Options\n\nImportant things such as firmware version, which slots have bitstreams/firmware, etc.\nis logged in LOG.TXT. Various options, such as programming speed and whether or not\nto write bitstreams to flash can be modified in OPTIONS.TXT.\n\n### Reprogramming/Updating Sonata\n\nThe Sonata's firmware can be erased by holding down SW9 while plugging in the USB, after\nwhich the board should enumerate as a different USB mass storage device. New firmware is \navilable in UF2 format and can be programmed by copying the UF2 file into the drive, similar\nto how bitstream and firmware programming works on the Sonata board.\n\n## Getting started\n\n### Linux Setup\n\nTLDR; to setup pico-sdk and build, the quickest way is currently:\n\n```bash\nsudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib\n```\n\n```bash\ngit clone https://github.com/raspberrypi/pico-sdk.git\ncd pico-sdk\ngit submodule update --init\n```\n\n### Windows Setup\n\nGrab the installer from https://github.com/raspberrypi/pico-setup-windows. All the paths\nshould be setup, so you can omit the `PICO_SDK_PATH` part of the cmake command. Note that\nWindows uses ninja instead of make by default.\n\n### Building\n\n```bash\nmkdir build\ncd build\nPICO_SDK_PATH=/path-to/pico-sdk cmake ..\nmake # or ninja if on Windows\n```\n## Logging\n\nDifferent logging levels are available and can be selected with `-DDEBUG_LEVEL=N` where `N` is\nbetween 1 and 5. The levels available are:\n\n1. Critical\n1. Error\n1. Warning\n1. Info\n1. Debug\n\nwith Info (4) being the default. Logs are written to `LOG.txt`.\n\n## Debugging\n\n### GDB/OpenOCD\n\nFollow the `Building` instructions above, but add `-DCMAKE_BUILD_TYPE=Debug` to the `cmake` command\n\nStart OpenOCD by running:\n\n```bash\nopenocd -f DEBUG_CONF.cfg -f target/rp2040.cfg\n```\n\nStart GDB from the `build` directory:\n\n```bash\ncd build\narm-none-eabi-gdb usb_msc/usb_msc.elf -ex \"target extended-remote localhost:3333\" -ex \"load\" -ex \"monitor reset init\"\n```\n\n## Testing\n\nSome basic tests can be run by creating testing firmware with cmake: `-DTESTING_BUILD=ON`,\nthen running either `tests/test_linux.py` or `tests/test_windows.py`, depending on your platform.\n\nTests should be run after a fresh boot and nothing should be uploaded to the Sonata before running the tests.\n\n## Notes\n\n### Windows Quirks\n\nWindows is pretty lazy with reading new information from disk. This doesn't cause any issues\nwith programming, but `ERROR.txt` won't be updated until you \"eject\" the disk by right clicking\nthe drive in Explorer and clicking `eject`.\n\n### Linux Quirks\n\nWrites to Linux drives are nonblocking by default, meaning copying things to disk returns before\nthe copy is done.\n\n### Early PCB Rev Notes\n\nEarly PCB revisions have a few mistakes that affect running/debugging:\n\n1. On revisions before v0.3, DIN isn't routed to the RP2040, so FPGA programming is unavailable unless a flywire is soldered onto the PCB: https://github.com/newaetech/sonata-pcb/issues/4\n1. On revisions before v0.3, a nonstandard SPI flash is used for the RP2040. On these revisions,\nyou must pass `PICO_DEFAULT_BOOT_STAGE2=boot2_generic_03h` to `cmake` and debuggers are unable\nto program SPI flash.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewaetech%2Fsonata-rp2040","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewaetech%2Fsonata-rp2040","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewaetech%2Fsonata-rp2040/lists"}