{"id":16607573,"url":"https://github.com/ho-ro/nanostk_v1","last_synced_at":"2025-11-07T11:04:06.906Z","repository":{"id":195023187,"uuid":"692084283","full_name":"Ho-Ro/nanoSTK_V1","owner":"Ho-Ro","description":"Arduino Nano board as the fastest in-system programmer (ISP) for classic AVR devices like ATtiny and ATmega","archived":false,"fork":false,"pushed_at":"2023-12-13T14:09:33.000Z","size":979,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-17T15:14:24.687Z","etag":null,"topics":["arduino","atmel","avr","avrdude","programmer","stk500"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ho-Ro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-09-15T14:20:16.000Z","updated_at":"2025-09-07T01:32:59.000Z","dependencies_parsed_at":"2023-11-24T20:30:46.575Z","dependency_job_id":"3dd565ce-13ae-40c5-a2c2-6967c15558d9","html_url":"https://github.com/Ho-Ro/nanoSTK_V1","commit_stats":null,"previous_names":["ho-ro/nanostk","ho-ro/nanostk_v1"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Ho-Ro/nanoSTK_V1","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ho-Ro%2FnanoSTK_V1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ho-Ro%2FnanoSTK_V1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ho-Ro%2FnanoSTK_V1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ho-Ro%2FnanoSTK_V1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ho-Ro","download_url":"https://codeload.github.com/Ho-Ro/nanoSTK_V1/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ho-Ro%2FnanoSTK_V1/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283174071,"owners_count":26791668,"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-11-07T02:00:06.343Z","response_time":61,"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":["arduino","atmel","avr","avrdude","programmer","stk500"],"created_at":"2024-10-12T01:23:10.951Z","updated_at":"2025-11-07T11:04:06.872Z","avatar_url":"https://github.com/Ho-Ro.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nanoSTK_V1\n\n![nanoSTK](nanoSTK.jpg)\n\n## Using Arduino Nano as AVR ISP with STK500 v1 protocol\n\nThis project enables the use of an Arduino Nano board with minor modifications (nanoSTK)\nas the [fastest](README.md#programming-speed) DIY in-system programmer (ISP) for classic AVR devices such as ATtiny and ATmega\ntogether with a programming software, e.g. [AVRDUDE](https://github.com/avrdudes/avrdude/).\n\nThe program is based on:\n[ArduinoISP](https://github.com/rsbohn/ArduinoISP) - Copyright (c) 2008-2011 Randall Bohn\n\n## Programmer Hardware\n\nThe programming process uses VCC, GND and four data pins.\nBy default, the hardware SPI pins MISO, MOSI and SCK are used to communicate with the target.\nThe fourth pin (D10) from the programming microprocessor goes to the reset pin of the target.\nOn all Arduinos, these pins are found on the ICSP/SPI header:\n\n```\n              MISO ¹* * 5V (!)\n              SCK   * * MOSI\n       D10 (/RESET) * * GND\n```\n\n### HW Modifications for nanoSTK\n\n#### Required HW Changes\n\n- Cut ISP header /RESET connection and connect this pin to D10 (PB2).\n- Connect a capacitor of about 3..10 μF between the /RESET line (+) of the Nano and GND (-).\n  This capacitor must be removed to reprogram the nanoSTK.\n  It is therefore recommended to make the capacitor pluggable.\n\n```\n/RESET ---o\u003c---|(---\u003eo--- GND\n              +  -\n```\n\nWith this setup the modified nanoSTK provides the supply voltage of 5 V to the target.\n\n#### Optional Modifications (Status LEDs)\n\nConnect LEDs (with resistor to GND) to the following active high pins:\n\n```\nHeartbeat - Indicates that the programmer is running\nD9 (PB1) ----|\u003e|----/\\/\\---- GND\n             LED1    R1\n\nError     - An Error has occured - clear with programmer reset\nD8 (PB0) ----|\u003e|----/\\/\\---- GND\n             LED2    R2\n\nWrite     - Writing to the target\nD7 (PD7) ----|\u003e|----/\\/\\---- GND\n             LED3    R3\n\nRead      - Reading from the target\nD6 (PD6) ----|\u003e|----/\\/\\---- GND\n             LED4    R4\n\nPMode     - Target in programming mode\nD5 (PD5) ----|\u003e|----/\\/\\---- GND\n             LED5    R5\n```\n\nD5 .. D8 are identical to the [ScratchMonkey](https://github.com/microtherion/ScratchMonkey) status LED pins.\n\n## Firmware Development and Installation\n\nThe source code was originally created and tested with the *Arduino* toolchain\nversion 1.8.19 under Linux, *Debian stable*.\nStarting with version 1.50, the build process is no longer dependent on the *Arduino* toolchain.\nYou only need the *avr-gcc* toolchain.\n\nThe `Makefile` takes care of changes to the source code files and rebuilds the file\n`nanoSTK.hex` accordingly - just type `make`\n\nThe installation process is simple and straightforward from the command line:\n\n- Remove the *reset capacitor* from your *nanoSTK* HW.\n- Connect the device to USB.\n- Enter `make upload`\n- Re-install the *reset capacitor*.\n\nInstead of removing/inserting the *reset capacitor* you can also press the reset button\nas soon as the `avrdude` command is started.\nThe upload of the file `nanoSTK.hex` with `make upload` only requires the `avrdude` tool.\nIf the source code remains unchanged, the *avr-gcc* tool chain is not required.\n\n### Other OS\n\nYou can also use the Arduino tool chain, this should work on all supported operation systems.\nCheck out the source and hex files from the branch\n[`arduino_toolchain`](https://github.com/Ho-Ro/nanoSTK_V1/tree/arduino_toolchain).\n\n- Remove the *reset capacitor* from your *nanoSTK* HW.\n- Connect the device to USB.\n- Open `nanoSTK_V1/nanoSTK_V1.ino` with the Arduino tool chain.\n- Select `Tools/Board: \"Arduino Nano\"`.\n- Select the correct serial port.\n- Execute `Sketch/Upload` from the menu.\n- Reinstall the *reset capacitor*.\n\nThe upload of the file `nanoSTK_V1.hex` with `make upload` only requires the `avrdude` tool.\nIf the source code remains unchanged, the *Arduino* tool chain is not required.\nThe branch `arduino_toolchain` will not be developed regularly\nand will not receive any new features, only critical bugs will be fixed.\n\n## Usage\n\nThe communication uses the `stk500v1` protocol over serial USB with a data rate of 115200 bps, this is the default speed of `avrdude`.\nAs serial communication is the bottleneck, you can speed up programming or reading considerably with a higher `BAUDRATE` setting in the FW.\n\n### Config File .avrduderc\n\nPut this file into your home directory (Linux) to set the nanoSTK device as the default programmer:\n\n```\n# file ~/.avrduderc\n\n#------------------------------------------------------------\n# nanoSTK\n#------------------------------------------------------------\n\n# this is the same as `-c stk500v1`\n# but has different features\n# warning: \"extra_features\" is not supported for avrdude version \u003c 7.2\n# adjust the baudrate (default = 115200) if you have changed the `BAUDRATE` value in the FW\n# available values are 500000 bps or 1000000 bps\n\nprogrammer # nanoSTK\n    id                     = \"nanoSTK\";\n    desc                   = \"nanoSTK - arduino nano programmer using stk500v1 protocol\";\n    type                   = \"stk500\";\n    prog_modes             = PM_ISP;\n#    baudrate               = 500000;\n#    extra_features         = HAS_VTARG_READ | HAS_FOSC_ADJ;\n    connection_type        = serial;\n;\n\ndefault_programmer  = \"nanoSTK\";\n\ndefault_serial = \"/dev/ttyUSB0\";\n```\n\n### Use with AVRDUDE\n\nA typical call for programming the file `firmware.hex` into an ATtiny 85 looks like this:\n\n```sh\navrdude -p t85 -U flash:w:firmware.hex:i\n```\n\nThis simple call\n\n```sh\navrdude -p t85 -v\n```\n\nwill show the programmer setup and device info for the ATtiny 85:\n\n```\n$ avrdude-git -pt85 -v\n\navrdude-git: Version 7.2-20231122 (606658a1)\n             Copyright the AVRDUDE authors;\n             see https://github.com/avrdudes/avrdude/blob/main/AUTHORS\n\n             System wide configuration file is /home/horo/projects/AVR/avrdude/build_linux/src/avrdude.conf\n             User configuration file is /home/horo/.avrduderc\n\n             Using port            : /dev/ttyUSB0\n             Using programmer      : nanoSTK\n             AVR Part              : ATtiny85\n             Programming modes     : ISP, HVSP, debugWIRE, SPM\n             Programmer Type       : STK500\n             Description           : nanoSTK - arduino nano programmer using stk500v1 protocol\n             HW Version            : 2\n             FW Version            : 1.51\n             Vtarget               : 4.8 V\n             Oscillator            : 8.000000 MHz\n             SCK period            : 1.0 us\n             XTAL frequency        : 16.000000 MHz\navrdude-git: AVR device initialized and ready to accept instructions\navrdude-git: device signature = 0x1e930b (probably t85)\n\navrdude-git done.  Thank you.\n\n```\n\n### Programming Speed\n\nThe programming algorithms are optimised for speed:\n\n- unchanged EEPROM blocks are not programmed.\n- the total serial communication overhead is taken into account for the required programming delays.\n\nThese times were measured on an ATmega328p and an ATtiny85 with random data after flash and EEPROM were filled with `0xFF`.\n\nDevice | Flash/EEPROM | Flash write | Flash verify | EEPROM write | EEPROM verify\n-------|--------------|-------------|--------------|--------------|---------------\nm328p  | 32K / 1024   |      6.15 s |       4.36 s |       1.79 s |        1.77 s\nt85    | 8K / 512     |      1.91 s |       1.54 s |       0.90 s |        0.89 s\n\n#### Comparison With Other Programmer FW\n\nComparison between the original STK500 and three FW variants for the modified Arduino Nano board, see also the [detailed documentation](timing_benchmark.md):\n\n- Target: ATmega328p 8MHz internal clock - flash memory\n- Data: 32K random data\n\nProgrammer      | Flash write | Flash verify\n----------------|-------------|-------------\nSTK500          | 12.28 s     | 11.31 s\narduino as ISP  | 36.61 s     | 20.21 s\nScratchMonkey   |  8.18 s     |  7.97 s\nnanoSTK         |  6.15 s     |  4.36 s\nnanoSTK 500kbps |  3.84 s     |  3.33 s\nnanoSTK 1Mbps   |  3.58 s     |  3.33 s\n\nThe serial USB communication becomes the clear bottleneck, you can speed up further with higher `BAUDRATE` setting in the FW,\ne.g. a speed of 500 kbps or 1 Mbps significantly reduces the programming time.\n\n### Programming Slow Targets\n\nWhen programming targets with a clock speed lower than 4 MHz the SPI can be slowed down from 1 MHz to 125 kHz,\nthis allows to communicate with slow targets (clock \u003e= 500 kHz), e.g. using the default setup (internal 8 MHz oscillator divided by 8).\nTo slow down connect pin D2 with GND and press the reset button. You can also use the terminal command `sck 8`.\n\n### Providing External Clock\n\nTo program a target without own clock generation, e.g. a processor on an adapter board, an external 8 MHz clock (5 V) is provided on pin D3.\nThis frequency is lowered to 1 MHz when pin D2 is connected to GND during reset.\nThe clock frequency can be changed with the terminal command `fosc`, e.g. `fosc 100k` sets 100 kHz.\n\n## Programming Protocol\n\nThe nanoSTK firmware uses the STK500 protocol, version 1 (`stk500v1`) as default.\n\n**Caution!** The  Arduino bootloader uses a modified version of the `stk500v1` protocol, called `arduino`,\neven if describing it as *\"Arduino for bootloader using STK500 v1 protocol\"*:\n\n- **EEPROM access is handled differently:**\n- Original `stk500v1` uses byte addresses (e.g 0..1023 for a device with 1K EEPROM).\n- Modified `arduino` uses word addresses also for the EEPROM (0..511 for a 1K device).\n- The `arduino` protocol does not support Vtarget and Varef.\n- The `stk500v1` protocol uses three `Cmnd_STK_UNIVERSAL` (0x56 = 'V') calls to get the signature.\n- The `arduino` protocol retrives the signature with the command `Cmnd_STK_READ_SIGN` (0x75 = 'u').\n\nThe firmware automatically recognises the modified `arduino` protocol by its use of the command\n`Cmnd_STK_READ_SIGN` and adjusts the EEPROM addressing accordingly.\n\n```\n$ avrdude -p t85 -c arduino -v\n         ...\n         Programmer Type : Arduino\n         Description     : Arduino for bootloader using STK500 v1 protocol\n         Hardware Version: 2\n         Firmware Version: 1.27\n\navrdude: AVR device initialized and ready to accept instructions\navrdude: device signature = 0x1e930b (probably t85)\n\navrdude done.  Thank you.\n```\n\n## Comparison With Original STK500\n\nIf you work professionally with classic AVR processors, you can hardly avoid the\n[STK500](https://www.microchip.com/en-us/development-tool/atstk500);\nI also use it for development. However, two things speak against using it for programming\nready targets via ISP: it requires an external power supply and needs space on the table.\nThis is where my nanoSTK comes into play, small, robust thanks to the use of the nano-ISP\nconnector, transportable and stand-alone, even when travelling.\nIn addition, my nanoSTK programs much faster than my STK500.\n\n![nanoSTK With Target](nanoSTK_With_Target.jpg)\n\nI took the Arduino *Sketch* *Arduino as ISP* as a basis and optimised it for robustness\nand speed. Furthermore, I added the handling of LEDs for status indication and generate\na clock signal for programming AVR processors that require an external clock, e.g. a\n*naked* processor on a simple adapter board. The status LEDs are on the same port pins\nas on the [ScratchMonkey](https://github.com/microtherion/ScratchMonkey), as I initially\nused this firmware on my hardware. Sadly, this project is no longer being actively developed\nand is much more complex to modify due to its greater flexibility (more Arduino boards as\nplatform, hi-voltage programming etc.).\nI don't need these functions, I use my good old STK500 for that.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fho-ro%2Fnanostk_v1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fho-ro%2Fnanostk_v1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fho-ro%2Fnanostk_v1/lists"}