{"id":26875026,"url":"https://github.com/adm1nsys/adafruit-uf2-bootloader-auto-flash","last_synced_at":"2026-04-12T22:09:26.856Z","repository":{"id":285294853,"uuid":"957632141","full_name":"adm1nsys/Adafruit-UF2-bootloader-auto-flash","owner":"adm1nsys","description":"Auto-flash script for nRF52 boards with Adafruit UF2 bootloader (e.g. Nice!Nano). Compiles, packages, and flashes via serial in one step","archived":false,"fork":false,"pushed_at":"2025-09-21T11:43:18.000Z","size":544,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-21T13:23:30.167Z","etag":null,"topics":["adafruit","automation","nicenano","nordic","nordic-semiconductor","nordicsemi","nrf","nrf52","nrf52840","platformio","uf2","uf2-bootloader"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adm1nsys.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-03-30T20:34:44.000Z","updated_at":"2025-09-21T11:43:22.000Z","dependencies_parsed_at":"2025-03-30T22:19:38.931Z","dependency_job_id":"d5fced45-7c60-4baf-85a8-1100a7f3951c","html_url":"https://github.com/adm1nsys/Adafruit-UF2-bootloader-auto-flash","commit_stats":null,"previous_names":["adm1nsys/adafruit-uf2-bootloader-auto-flash"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adm1nsys/Adafruit-UF2-bootloader-auto-flash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adm1nsys%2FAdafruit-UF2-bootloader-auto-flash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adm1nsys%2FAdafruit-UF2-bootloader-auto-flash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adm1nsys%2FAdafruit-UF2-bootloader-auto-flash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adm1nsys%2FAdafruit-UF2-bootloader-auto-flash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adm1nsys","download_url":"https://codeload.github.com/adm1nsys/Adafruit-UF2-bootloader-auto-flash/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adm1nsys%2FAdafruit-UF2-bootloader-auto-flash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280988263,"owners_count":26425486,"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","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["adafruit","automation","nicenano","nordic","nordic-semiconductor","nordicsemi","nrf","nrf52","nrf52840","platformio","uf2","uf2-bootloader"],"created_at":"2025-03-31T10:22:01.169Z","updated_at":"2025-10-25T17:14:52.533Z","avatar_url":"https://github.com/adm1nsys.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Adafruit-UF2-bootloader-auto-flash**\n\n🔌 **Auto-flash script for nRF52 boards** with [Adafruit UF2 Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader) (e.g. [Nice!Nano](https://nicekeyboards.com/nice-nano)).  \n📦 Compiles, packages, and flashes your firmware via **Serial DFU** in one step using `adafruit-nrfutil`.\n\n---\n\n## ✅ Features\n\n- Automatically creates a DFU `.zip` package from your `.hex`\n- Lists all available serial ports with device descriptions\n- Lets you select the correct port to flash\n- Flashes via USB Serial (not J-Link or SWD)\n- Tested with **Nice!Nano**, but works with other Adafruit UF2-compatible boards\n\n---\n\n## ⚙️ Setup Instructions\n\n### 1. Download the Script\n\nSave `auto_flash_nrf.py` into the **root directory** of your PlatformIO project.\n\n---\n\n### 2. Install Requirements\n\nYou'll need `adafruit-nrfutil` installed.\n\nOn **Windows/Linux/macOS**:\n```bash\npip3 install adafruit-nrfutil\n```\n\n\u003e ⚠️ On macOS, `pip` might not work — use `pip3` instead.  \n\u003e ⚙️ Also if you have any problems on any platform, try `pip`, `python`, `python3`.  \n\u003e 📍 If you install it in a non-standard location, update the path in `auto_flash_nrf.py`:\n\u003e ```python\n\u003e nrfutil = \"/your/custom/path/adafruit-nrfutil\"\n\u003e ```\n\n---\n\n### 3. Configure PlatformIO\n\nIn your `platformio.ini` file:\n\n#### **3.1 Add required build flags**  \n(Recommended for Nice!Nano and similar boards):\n\n```ini\nbuild_flags =\n  -DARDUINO_NICE_NANO\n  -DNRF52840_XXAA\n  -Wl,--section-start=.text=0x26000\n```\n\n##### 🔍 What does `--section-start=.text=0x26000` mean?\n\nThis tells the compiler where in flash memory to place the firmware.  \nFor boards using the **Adafruit UF2 Bootloader**, the bootloader occupies the beginning of flash.  \nMost Adafruit nRF52 boards (like **Nice!Nano**) use address `0x26000` as the start of user firmware.\n\n\u003e ✅ You must adjust this if your board uses a different address.\n\nTo find the correct start address:\n\n1. Put your board in **UF2 bootloader mode**\n2. A USB storage device will appear\n3. Open the file named `CURRENT.UF2`\n4. Use a UF2 analyzer or hex viewer to check where it begins\n\nFor Nice!Nano, it’s almost always `0x26000`\n\n---\n\n#### **3.2 Attach the Script to Build**\n\nAdd this to the same `[env:...]` block:\n\n```ini\nextra_scripts =\n  post:auto_flash_nrf.py\n```\n\nNow, after every successful build, the script will automatically create a DFU zip and flash your device.\n\n---\n\n### 4. Port Selection — Tips for New Users\n\nAfter building, the script will list all connected serial ports. You'll be asked to pick one.\n\nLook for something like:\n\n```\n5) /dev/cu.usbmodem141101 - Nice!Nano\n```\n\nBoards with Adafruit UF2 bootloader often appear as:\n\n- `usbmodem` (macOS/Linux)\n- `COMx` (Windows)\n- Descriptions may include:\n  - Nice!Nano\n  - Feather nRF52840\n  - ItsyBitsy nRF52840\n  - CircuitPlayground nRF52\n\nPick the correct one by number and the script will do the rest 🚀\n\n---\n\n## 🧪 Example Output\n\n```\n=== Creating DFU package ===\nRunning: \"/Users/adminpro/Library/Python/3.13/bin/adafruit-nrfutil\" dfu genpkg --dev-type 0x0052 --application \".../firmware.hex\" \".../firmware_dfu.zip\"\nZip created at .../firmware_dfu.zip\n\n=== DFU Upload ===\n1) /dev/cu.BLTH - n/a\n2) /dev/cu.Bluetooth-Incoming-Port - n/a\n3) /dev/cu.URT1 - n/a\n4) /dev/cu.URT2 - n/a\n5) /dev/cu.usbmodem141101 - Nice!Nano\nEnter the number of the port to flash: 5\n\n🚀 Flashing to port /dev/cu.usbmodem141101 ...\nUpgrading target on /dev/cu.usbmodem141101 with DFU package ...\n########################################\n##\nActivating new firmware\nDevice programmed.\n\n[SUCCESS] Took 25.42 seconds\n```\n\n---\n\n## 📁 Included Files\n\n- `auto_flash_nrf.py` – main script\n- Example `platformio.ini`\n- Sample `CURRENT.UF2` (from Nice!Nano)\n- Example logs\n\n---\n\nHave fun flashing ✨ If you find bugs or want to improve the script — pull requests are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadm1nsys%2Fadafruit-uf2-bootloader-auto-flash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadm1nsys%2Fadafruit-uf2-bootloader-auto-flash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadm1nsys%2Fadafruit-uf2-bootloader-auto-flash/lists"}