百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

micronucleus-firmware

> 编程语言
开源

fork micronucleus 仓库中的固件/digispark 部分

100 stars0 点赞6 次浏览
访问官网GitHub

工具介绍

fork micronucleus 仓库中的固件/digispark 部分

If you find this library useful, please give it a star.

🌎 Google Translate

Micronucleus is a bootloader designed for AVR ATtiny microcontrollers with a minimal usb interface, cross platform libusb-based program upload tool, and a strong emphasis on bootloader compactness. To the authors knowledge this is, by far, the smallest USB bootloader for AVR ATtiny.

The V2.0 release is a complete rewrite of the firmware and offers significant improvements over V1.x.

Due to the many changes, also the upload tool had to be updated. The V2.0 upload tool is backwards compatible to the V1.X tool, though.

Usage

The bootloader allows uploading of new firmware via USB. In its usual configuration it is invoked at device power or on reset and will identify to the host computer. If no communication is initiated by the host machine within a given time (default are 6 seconds), the bootloader will time out and enter the user program, if one is present.

For proper timing, the command line tool should to be started on the host computer before the bootloader is invoked / the board attached.

The bootloader resides in the same memory as the user program, since the ATtiny series does not support a protected bootloader section. Therefore, special care has to be taken not to overwrite the bootloader if the user program uses the self programming features. The bootloader will patch itself into the reset vector of the user program. No other interrupt vectors are changed.

Please invoke the command line tool with "micronucleus --help" for a list of available options.

Driver installation

If the Digispark board is not recognized by Microsoft Windows you must install the appropriate driver.

For Windows you must install the libusb driver before you can program the board. Download it here, open it and run InstallDrivers.exe. Clean Micronucleus devices without uploaded user program will not time out and allow sufficient time for proper driver installation. Linux and OS X do not require custom drivers.

Updated configuration for Digispark boards

The new ATTinyCore by Spence Konde shrinks generated code size by 5 to 15 percent. Just replace the old Digispark board manager URL http://digistump.com/package_digistump_index.json (e.g.in Arduino File > Preferences) by the new http://drazzy.com/package_drazzy.com_index.json and install the latest version.

Update the bootloader to a new version

To update your old, flash consuming bootloader, you have 2 choices.

  1. Use the new Digistump board manager URL (see above), choose a bootloader with Tools > Micronucleus variant and then burn it with Tools > Burn Bootloader.

  2. Run one of the Windows scripts like e.g. the 1_Upgrade-t85_default.cmd. The internal mechanism is described here.

If you want to burn the bootloader to an ATtiny87 or ATtiny167 with avrdude, you must use the avrdude.config file in the windows_exe directory where ATtiny87 and ATtiny167 specifications are added.

Fuse setting

The meaning of fuses can be seen with the Engbedded Atmel AVR Fuse Calculator.

Windows helper scripts for setting fuses can be found here.

The default fuses for a Digispark board are:

  • ATtiny85 Lfuse: 0xE1 - (digispark default) 64 MHZ high speed PLL Clock + Startup 64 ms. CPU clock = 64 MHz / 4 = 16 MHz. CPU clock speed can later be reduced by core or user by using the System Clock Prescaler register.
  • ATtiny85 Hfuse: 0xDD - External Reset pin enabled (Pin5 not usable as I/O) + BOD 2.7 V + Enable Serial Program and Data Downloading.
  • ATtiny85 Efuse: 0xFE - self programming enabled.

BOD enabled requires additional 20 µA in sleep state and therefore may be not desirable for low power battery applications. To disable BOD, use 0xDF as Hfuse.

The default fuses for a Digispark Pro board are:

  • ATtiny167 Lfuse: 0xFF - External crystal osc. Frequency 8-16 MHz + Startup 65 ms. The Pro has a 16 MHz crystal.
  • ATtiny167 Hfuse: 0xDC - External Reset pin enabled + BOD 4.3Volt + Enable Serial Program and Data Downloading.
  • ATtiny167 Efuse: 0xFE - self programming enabled.

Flash the bootloader to a bricked device

This can only be done by means of a High Voltage programmer.

If nothing works...

Try another Cable, try another USB-Port, try another Board, try another Bootloader-variant, try another Computer, try another OS.

In this order.

Configuration overview

If not otherwise noted, the OSCCAL value is calibrated (+/- 1%) after boot for all ATtiny85 configurations | Configuration | Free FLASH | Boot-

loader size | Non default config flags set | |-|-|-|-| | t85_agressive

It works for my Digispark boards without any problems :-) | 6778 | 1362 | Do not provide calibrated OSCCAL, if no USB attached, ENABLE_UNSAFE_OPTIMIZATIONS Relying on calibrated 16MHz internal clock stability, not using the 16.5 MHz USB driver version with integrated PLL. This causes the main memory saving. | | | | | | | t85_default | 6650 | 1514 | - | | t85_entry_on_powerOn | 6586 | 1550 | ENTRY_POWER_ON, LED_MODE=ACTIVE_HIGH | | t85_entry_on_powerOn_ fastExit | 6586 | 1572 | ENTRY_POWER_ON, FAST_EXIT_NO_USB_MS=300, LED_MODE=ACTIVE_HIGH | | t85_entry_on_powerOn_ activePullup_fastExit recommended configuration | 6586 | 1576 | ENTRY_D_MINUS_PULLUP_ACTIVATED_AND_ENTRY_POWER_ON, FAST_EXIT_NO_USB_MS=300, LED_MODE=ACTIVE_HIGH | | t85_entry_on_powerOn_ activePullup_fastExit_noLED| 6586 | 1558 | ENTRY_D_MINUS_PULLUP_ACTIVATED_AND_ENTRY_POWER_ON, FAST_EXIT_NO_USB_MS=300 | | t85_entry_on_powerOn_ pullupAt0 | 6650 | 1538 | ENTRY_POWER_ON, USB_CFG_PULLUP_IOPORTNAME + USB_CFG_PULLUP_BIT | | t85_entry_on_reset_ activePullup_fastExit | 6586 | 1576 | ENTRY_D_MINUS_PULLUP_ACTIVATED_AND_ENTRY_EXT_RESET, FAST_EXIT_NO_USB_MS=300, AUTO_EXIT_MS=15000 Bootloader timeout increased to 15 seconds (if connected to USB), LED_MODE=ACTIVE_HIGH. | | t85_fastExit | 6586 | 1554 | FAST_EXIT_NO_USB_MS=300, LED_MODE=ACTIVE_HIGH | | | | | | | t88_default | 6778 | 1350 | LED_MODE=ACTIVE_HIGH For 16 MHz quartz | | t88_entry_on_powerOn_ activePullup_fastExit recommended configuration | 6778 | 1394 | ENTRY_D_MINUS_PULLUP_ACTIVATED_AND_ENTRY_POWER_ON, FAST_EXIT_NO_USB_MS=300, LED_MODE=ACTIVE_HIGH For 16 MHz quartz | | | | | | | t167_default | 14970 | 1342 | - | | t167_entry_on_powerOn_ activePullup_fastExit recommended configuration | 14970 | 1406 | ENTRY_D_MINUS_PULLUP_ACTIVATED_AND_ENTRY_POWER_ON, FAST_EXIT_NO_USB_MS=300, LED_MODE=ACTIVE_HIGH For 16 MHz quartz | | t167_entry_on_reset_ activePullup_fastExit | 14970 | 1406 | ENTRY_D_MINUS_PULLUP_ACTIVATED_AND_ENTRY_EXT_RESET, FAST_EXIT_NO_USB_MS=300, AUTO_EXIT_MS=15000 Bootloader timeout increased to 15 seconds (if connected to USB), LED_MODE=ACTIVE_HIGH. For 16 MHz quartz | | | | | | | t45_default | 2554 | 1514 | | | t4313_default | 6714 | 1460 | | | Nanite841 | 6586 | 1548 | | | t841_default | 6650 | 1514 | | | t84_default | 6650 | 1480 | | | | | | | | m168p_extclock | | 1498 | | | m328p_extclock | | 1498 | |

Legend

  • ENTRY_POWER_ON - Only enter bootloader on power on, not on reset or brownout.
  • ENTRY_EXT_RESET - Only enter bootloader on reset, not on power up.
  • ENTRY_D_MINUS_PULLUP_ACTIVATED - Only enter if pull-up connected and powered.
  • FAST_EXIT_NO_USB_MS=300 - If not connected to USB (e.g. powered via VIN) the user program starts after 300 ms (+ initial 300 ms) -> 600 ms. If connected to USB but no upload happens the user program starts after around 1.5 seconds.
  • LED_MODE=ACTIVE_HIGH - The built in LED flashes during the 5 seconds of the bootloader waiting for commands.

Descripion of the configuration options

FAST_EXIT_NO_USB_MS for fast bootloader exit

If the bootloader is entered, it requires minimum 300 ms to initialize USB connection (disconnect and reconnect). 100 ms after this 300 ms initialization, the bootloader receives a reset.

The 100 ms time to reset may depend on the type of host CPU etc., so I took 200 ms to be safe to detect a reset.

This configuration waits for 200 ms after initialization for a reset and if no reset detected it exits the bootloader and starts the user program.

With this configuration the user program is started with a 500 ms delay after power up or reset if no USB is attached, even if we do not specify a special entry condition.

IF USB is attached, we wait another 1200 ms (to cover slow hosts, otherwise 500 would be OK) after the reset for the host upload program (micronucleus.exe) to request the configuration information. If no upload program is detected, we start the user program.

ENTRY_POWER_ON entry condition

The ENTRY_POWER_ON configuration adds 18 bytes to the ATtiny85 default configuration.

The content of the MCUSR is copied to the GPIOR0 register to enable the user program to evaluate it and then cleared to prepare for next boot.

In this configuration a reset will immediately start your user program without any delay.

ENTRY_EXT_RESET entry condition

The ATtiny85 has the bug, that it sets the External Reset Flag also on power up. To guarantee a correct behavior for ENTRY_EXT_RESET condition, it is checked if only this flag is set and MCUSR is cleared before start of user program. The latter is done to avoid bricking the device by fogetting to reset the PORF flag in the user program.

For ATt

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Cattiny85bootloaderdigisparkfirmware

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言