├── .github └── FUNDING.yml ├── .gitignore ├── arduino ├── 1.6.5 │ └── WInterrupts.c ├── 1.8.5 │ └── WInterrupts.c ├── hardware │ └── avr-debugger │ │ └── avr │ │ ├── README.TXT │ │ ├── boards.txt │ │ ├── bootloaders │ │ ├── atmega1284p │ │ │ └── optiboot_atmega1284p.hex │ │ ├── atmega2560 │ │ │ ├── optiboot_atmega2560.hex │ │ │ └── readme.txt │ │ └── atmega328 │ │ │ ├── atmega328_debug_optiboot.hex │ │ │ └── readme.txt │ │ └── platform.txt ├── library │ └── avr-debugger │ │ ├── bootloader │ │ ├── optiboot.hex │ │ └── readme.txt │ │ ├── examples │ │ └── debug_blink │ │ │ ├── .vscode │ │ │ └── launch.json │ │ │ └── app.ino │ │ ├── keywords.txt │ │ ├── launch.json │ │ ├── library.properties │ │ ├── platform.local.txt │ │ ├── platform.local.txt.baud_57600 │ │ ├── readme.txt │ │ └── src │ │ ├── app_api.c │ │ ├── app_api.h │ │ ├── avr8-stub.c │ │ ├── avr8-stub.h │ │ └── avr_debugger.h └── readme.txt ├── avr8-stub ├── app_api.c ├── app_api.h ├── avr8-stub.c ├── avr8-stub.h └── avr_debugger.h ├── bootloader ├── optiboot │ ├── .cproject │ ├── .gitignore │ ├── .project │ ├── .settings │ │ └── de.innot.avreclipse.core.prefs │ ├── .travis.yml │ ├── Debug │ │ ├── makefile │ │ └── optiboot.hex │ ├── platformio.ini │ ├── readme_platformio.txt │ └── src │ │ ├── boot.h │ │ ├── bootapi.c │ │ ├── bootapi.h │ │ ├── optiboot.c │ │ ├── pin_defs.h │ │ ├── stk500.h │ │ └── stub.c └── readme.txt ├── doc ├── avr_debug.doc ├── avr_debug.pdf └── img │ ├── arduino_delay_stopped.png │ ├── arduino_folder.png │ ├── arduinopath_var.png │ ├── avr8_stub_path_var.png │ ├── avr_dude_path.png │ ├── avr_path_edit.png │ ├── avr_paths.png │ ├── avr_plugin_paths_atstudio.png │ ├── avr_plugin_paths_browse.png │ ├── avr_plugin_paths_mingw.png │ ├── avr_upload.png │ ├── bootloader_fuses.png │ ├── debug_arduino_blink.png │ ├── debug_breakpoint_call.png │ ├── debug_config_com.png │ ├── debug_config_com_debugger.png │ ├── debug_config_debugger.png │ ├── debug_config_load.png │ ├── debug_config_new.png │ ├── debug_config_select.png │ ├── debug_config_startup.png │ ├── debug_expressions.png │ ├── debug_format.png │ ├── debug_resume.png │ ├── debug_start_button.png │ ├── debug_step_over.png │ ├── debug_stopped.png │ ├── debug_stopped2.png │ ├── debug_write_cnt.png │ ├── drag_drop_files.png │ ├── exclude_from_build.png │ ├── gdb_hwdebug_install.png │ ├── hex_generate.png │ ├── import_1.png │ ├── import_2.png │ ├── mingw_install.png │ ├── mingw_step3a.png │ ├── mingw_step5.png │ ├── mingw_step6a.png │ ├── new_folder_arduino.png │ ├── platformio_debug1.png │ ├── platformio_debug2.png │ ├── platformio_debug3.png │ ├── platformio_ini.png │ ├── platformio_libinstall.png │ ├── preferences_paths.png │ ├── programmer_select.png │ ├── programming_fuses.png │ ├── programming_uno_fuses.png │ ├── project_file_wnd.png │ ├── project_new_file.png │ ├── tcp2com_wnd.png │ ├── vscode_blink.png │ ├── vscode_debug.png │ ├── vscode_launch.png │ ├── vscode_launchjson.png │ ├── vscode_libs.png │ ├── vscode_setvar.png │ ├── vscode_start.png │ ├── vscode_start2.png │ └── vscode_vars.png ├── examples ├── experimental │ ├── boot_api_app │ │ ├── .cproject │ │ ├── .gitignore │ │ ├── .project │ │ ├── .settings │ │ │ └── de.innot.avreclipse.core.prefs │ │ ├── Debug │ │ │ └── makefile │ │ ├── boot_api_app Debug TCP.launch │ │ ├── boot_api_app Debug.launch │ │ ├── boot_api_app Debug_no_load.launch │ │ ├── debug_com.bat │ │ ├── main.c │ │ └── script_com │ ├── c │ │ ├── .cproject │ │ ├── .gitignore │ │ ├── .project │ │ ├── .settings │ │ │ └── de.innot.avreclipse.core.prefs │ │ ├── c Debug COM mega2560.launch │ │ ├── c Debug COM.launch │ │ ├── c Debug Linux Mega2560.launch │ │ ├── c Debug Linux UNO.launch │ │ ├── c Debug Linux.launch │ │ ├── core │ │ ├── debug_com.bat │ │ ├── debug_tcp1.bat │ │ ├── debug_tcp2.bat │ │ ├── fillmem.h │ │ ├── gdb_logfile.txt │ │ ├── main.c │ │ ├── script_com │ │ ├── script_tcp │ │ └── start_proxy.bat │ └── readme.txt ├── mega2560 │ ├── blink_mega │ │ ├── .cproject │ │ ├── .gitignore │ │ ├── .project │ │ ├── .settings │ │ │ └── de.innot.avreclipse.core.prefs │ │ ├── blink.cpp │ │ ├── blink_mega Debug COM5.launch │ │ └── blink_mega TCP.launch │ ├── c_mega │ │ ├── .cproject │ │ ├── .gitignore │ │ ├── .project │ │ ├── .settings │ │ │ └── de.innot.avreclipse.core.prefs │ │ ├── c_mega Debug COM5.launch │ │ └── c_mega.c │ └── readme.txt └── mega328 │ ├── blink_uno │ ├── .cproject │ ├── .gitignore │ ├── .project │ ├── .settings │ │ └── de.innot.avreclipse.core.prefs │ ├── blink.cpp │ ├── blink_nano COM14.launch │ ├── blink_nano TCP.launch │ ├── blink_uno Debug COM.launch │ ├── blink_uno Debug Load.launch │ ├── blink_uno TCP.launch │ ├── debug_com.bat │ ├── debug_tcp.bat │ ├── gdb_logfile.txt │ ├── script_com │ ├── script_log │ └── script_tcp │ ├── c_uno │ ├── .cproject │ ├── .gitignore │ ├── .project │ ├── .settings │ │ └── de.innot.avreclipse.core.prefs │ ├── c_uno Debug COM.launch │ └── main.c │ └── readme.txt ├── hub4com-2.1.0.0-386 ├── ReadMe.txt ├── com2tcp-rfc2217.bat ├── com2tcp.bat ├── hub4com.exe └── multiplexer.bat ├── library.json ├── license.txt ├── readme.md ├── start_proxy.bat └── start_proxy_nano.bat /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: jdolinay 4 | 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | #ignore thumbnails created by windows 3 | Thumbs.db 4 | 5 | # ignore build output files 6 | *.o 7 | *.lst 8 | *.sym 9 | *.map 10 | *.lss 11 | *.elf 12 | *.epp 13 | *.d 14 | *.mk 15 | 16 | -------------------------------------------------------------------------------- /arduino/hardware/avr-debugger/avr/README.TXT: -------------------------------------------------------------------------------- 1 | This is "platform" to allow burning bootloaders for avr_debugger stub. 2 | 3 | For more information see https://github.com/jdolinay/avr_debug 4 | -------------------------------------------------------------------------------- /arduino/hardware/avr-debugger/avr/boards.txt: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | 3 | # special bootloader for avr_debugger, modified from Optiboot. 4 | avr-debug328.name=avr-debugger Atmega328 bootloader 5 | 6 | avr-debug328.upload.protocol=arduino 7 | avr-debug328.upload.maximum_size=30720 8 | avr-debug328.upload.speed=115200 9 | 10 | avr-debug328.bootloader.low_fuses=0xFF 11 | avr-debug328.bootloader.high_fuses=0xD2 12 | avr-debug328.bootloader.extended_fuses=0xFD 13 | 14 | avr-debug328.bootloader.file=atmega328/atmega328_debug_optiboot.hex 15 | avr-debug328.bootloader.unlock_bits=0x3F 16 | avr-debug328.bootloader.lock_bits=0x2F 17 | 18 | avr-debug328.build.mcu=atmega328p 19 | avr-debug328.build.f_cpu=16000000L 20 | avr-debug328.build.core=arduino:arduino 21 | avr-debug328.build.variant=arduino:standard 22 | avr-debug328.build.board=AVR_UNO 23 | 24 | avr-debug328.bootloader.tool=arduino:avrdude 25 | avr-debug328.upload.tool=arduino:avrdude 26 | 27 | 28 | # Optiboot bootloader for Arduino Mega 2560 29 | avr-debug2560.name=Optiboot Arduino Mega 2560 bootloader 30 | avr-debug2560.upload.protocol=arduino 31 | avr-debug2560.upload.speed=115200 32 | 33 | avr-debug2560.bootloader.tool=arduino:avrdude 34 | avr-debug2560.bootloader.unlock_bits=0x3F 35 | avr-debug2560.bootloader.lock_bits=0x2F 36 | 37 | avr-debug2560.build.f_cpu=16000000L 38 | 39 | avr-debug2560.build.board=AVR_MEGA 40 | avr-debug2560.build.core=arduino:arduino 41 | avr-debug2560.build.variant=arduino:mega 42 | 43 | avr-debug2560.upload.maximum_size=261120 44 | avr-debug2560.upload.maximum_data_size=8192 45 | 46 | avr-debug2560.bootloader.low_fuses=0xF7 47 | avr-debug2560.bootloader.high_fuses=0xDE 48 | avr-debug2560.bootloader.extended_fuses=0xFD 49 | avr-debug2560.bootloader.file=atmega2560/optiboot_atmega2560.hex 50 | 51 | avr-debug2560.build.mcu=atmega2560 52 | 53 | 54 | -------------------------------------------------------------------------------- /arduino/hardware/avr-debugger/avr/bootloaders/atmega1284p/optiboot_atmega1284p.hex: -------------------------------------------------------------------------------- 1 | :020000021000EC 2 | :10FC000001C025C1112484B7882369F0982F9A7008 3 | :10FC1000923049F081FF02C097EF94BF282E80E018 4 | :10FC200001D10C94000085E08093810082E08093F4 5 | :10FC3000C00088E18093C10086E08093C20080E12B 6 | :10FC40008093C4008EE0EED0209A86E020E33CEF63 7 | :10FC500091E0309385002093840096BBB09BFECF4B 8 | :10FC6000189AA8954091C00047FD02C0815089F7BD 9 | :10FC700043E0D42ECC24C39451E1752EC7D08134F7 10 | :10FC800071F4C4D0C82FD4D081E0C23821F088E00C 11 | :10FC9000C13809F083E0B3D080E1B1D0EFCF823436 12 | :10FCA00019F484E1CDD0F8CF853411F485E0FACF92 13 | :10FCB000853581F4ABD0082FA9D0182F87FF07C056 14 | :10FCC0008BB781608BBF000F111FB2D0E5CF8BB710 15 | :10FCD0008E7FF8CF863581F499D08D3459F496D043 16 | :10FCE000CBB794D0C170880F8C2B8BBF81E0A8D08C 17 | :10FCF00080E0D1CF83E0FBCF843609F04EC086D0C0 18 | :10FD0000C82FD0E0DC2FCC2781D0C82B7FD0682E25 19 | :10FD10005E01B394E12CFF24F3944701EFEFEE1A58 20 | :10FD2000FE0A74D0F4018083EA14FB04B1F780D09A 21 | :10FD3000F5E46F1211C0F12CE12C08C06081C701FD 22 | :10FD4000800F911F9CD08FEFE81AF80AF701F39506 23 | :10FD5000CE15DF0599F7A0CFF801D7BEE89507B615 24 | :10FD600000FCFDCF90E080E0FC01E00FF11FDC0122 25 | :10FD7000B3952D913C910901C7BEE89511240296D7 26 | :10FD8000C817D90789F785E0F80187BFE89507B656 27 | :10FD900000FCFDCF77BEE8957FCF843709F536D0DC 28 | :10FDA000C82FD0E0DC2FCC2731D0C82B2FD0B82ED5 29 | :10FDB0003FD07801F5E4BF120CC0C00FD11FC701BE 30 | :10FDC00056D01DD08FEFE81AF80AEC16FD06B9F7E9 31 | :10FDD00063CFF70187917F0112D02197D1F75CCFD4 32 | :10FDE000853739F425D08EE10AD087E908D085E03F 33 | :10FDF00052CF813509F069CF88E014D066CF909159 34 | :10FE0000C00095FFFCCF8093C60008958091C0008C 35 | :10FE100087FFFCCF8091C00084FD01C0A895809130 36 | :10FE2000C6000895E0E6F0E098E1908380830895AD 37 | :10FE3000EDDF803219F088E0F5DFFFCF84E1DFCF1E 38 | :10FE4000CF93C82FE3DFC150E9F7CF91F1CFFC0189 39 | :10FE50000A0167BFE895112407B600FCFDCF667064 40 | :10FE600029F0452B19F481E187BFE8950895F999A8 41 | :10FE7000FECF92BD81BDF89A992780B50895262FAF 42 | :10FE8000F999FECF1FBA92BD81BD20BD0FB6F8947F 43 | :10FE9000FA9AF99A0FBE0196089556657273696FC2 44 | :10FEA0006E3D382E31004F505449424F4F545F43FE 45 | :10FEB0005553544F4D5645523D3000446576696365 46 | :10FEC000653D61746D656761313238347000465F3D 47 | :10FED0004350553D31363030303030304C0042499F 48 | :10FEE00047424F4F543D31004275696C743A41703E 49 | :10FEF0007220203520323032313A31353A33353ABA 50 | :10FF0000333700554152543D3000424155445F5211 51 | :10FF10004154453D313135323030004C45443D424D 52 | :10FF200030004C45445F53544152545F464C41535A 53 | :06FF30004845533D33007B 54 | :02FFFE000108F8 55 | :040000031000FC00ED 56 | :00000001FF 57 | -------------------------------------------------------------------------------- /arduino/hardware/avr-debugger/avr/bootloaders/atmega2560/optiboot_atmega2560.hex: -------------------------------------------------------------------------------- 1 | :020000023000CC 2 | :10FC000001C02EC11F92CDB7DEB7112484B788235F 3 | :10FC100069F0982F9A70923049F081FF02C097EFF7 4 | :10FC200094BF282E80E007D10C94000085E08093DB 5 | :10FC3000810082E08093C00088E18093C10086E06B 6 | :10FC40008093C20080E18093C4008EE0F4D0279AB4 7 | :10FC500086E020E33CEF91E0309385002093840020 8 | :10FC600096BBB09BFECF1F9AA8954091C00047FD60 9 | :10FC700002C0815089F7FF24F39455E0E52E61E13D 10 | :10FC8000D62ECDD0813471F4CAD08983DAD089815F 11 | :10FC9000823809F4B3C0813811F488E001C083E0F0 12 | :10FCA000B7D0B3C0823411F484E103C0853419F4B1 13 | :10FCB00085E0CFD0AAC0853579F4B1D0082FAFD078 14 | :10FCC000182F87FF03C08BB7816002C08BB78E7F70 15 | :10FCD0008BBF000F111F98C0863589F4A0D08D34DA 16 | :10FCE00051F49DD0CBB69BD0880F9C2D9170892B61 17 | :10FCF0008BBF81E001C083E0ACD080E0D1CF8436FF 18 | :10FD000009F04EC08CD0A82EB12CBA2CAA2487D0D2 19 | :10FD10003501682A84D0C82E5301812C32E0932EFD 20 | :10FD20007ED0F40181934F01F1E0AF1AB108C1F721 21 | :10FD300088D085E4C81214C04301EEEF9E1A580122 22 | :10FD4000612C92E0792E6814790409F45EC0F30105 23 | :10FD500061913F01C5019CD0FFEFAF1ABF0AF3CFFD 24 | :10FD600083E0F80187BFE89507B600FCFDCFF801F6 25 | :10FD7000A0E0B2E08D919D910C01F7BEE8951124B1 26 | :10FD800082E0681A710832966114710499F7F801DB 27 | :10FD9000E7BEE89507B600FCFDCFD7BEE89535C0B5 28 | :10FDA000843729F53CD0A82EB12CBA2CAA2437D000 29 | :10FDB0004501882A34D0898344D05801898185340B 30 | :10FDC00069F4C5015DD024D0F1E08F1A91088FEF5E 31 | :10FDD000A81AB80A81149104A1F717C0F5018791F8 32 | :10FDE0005F0116D0F1E08F1A9108C1F70EC0853778 33 | :10FDF00039F427D08EE10CD088E90AD081E050CFC9 34 | :10FE0000813511F488E017D01CD080E101D039CFC2 35 | :10FE10009091C00095FFFCCF8093C600089580911B 36 | :10FE2000C00087FFFCCF8091C00084FD01C0A89571 37 | :10FE30008091C6000895E0E6F0E098E19083808329 38 | :10FE40000895EDDF803219F088E0F5DFFFCF84E11F 39 | :10FE5000DFCFCF93C82FE3DFC150E9F7CF91F1CFC8 40 | :10FE6000FC010A0167BFE895112407B600FCFDCF2D 41 | :10FE7000667029F0452B19F481E187BFE895089554 42 | :10FE8000F999FECF92BD81BDF89A992780B5089562 43 | :10FE9000262FF999FECF1FBA92BD81BD20BD0FB6A6 44 | :10FEA000F894FA9AF99A0FBE0196089556657273FE 45 | :10FEB000696F6E3D382E31004F505449424F4F54B8 46 | :10FEC0005F435553544F4D5645523D30004465767F 47 | :10FED0006963653D61746D65676132353630004632 48 | :10FEE0005F4350553D31363030303030304C004279 49 | :10FEF0004947424F4F543D31004275696C743A4A4C 50 | :10FF0000756E20323720323032303A31323A343066 51 | :10FF10003A323800554152543D3000424155445F19 52 | :10FF2000524154453D313135323030004C45443D2D 53 | :10FF30004237004C45445F53544152545F464C4154 54 | :07FF4000534845533D330017 55 | :02FFFE000108F8 56 | :040000033000FC00CD 57 | :00000001FF 58 | -------------------------------------------------------------------------------- /arduino/hardware/avr-debugger/avr/bootloaders/atmega2560/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This is Optiboot bootloader binary for Arduino Mega 2560 (Atmega2560, 16 MHz clock, 115200 baud rate). 3 | Optiboot version 8.1 4 | 5 | This bootloader can be used with avr_debug stub to support flash breakpoints (optiboot mode). 6 | 7 | Note that this is Optiboot binary built from sources available here: 8 | https://github.com/Optiboot/optiboot 9 | 10 | The binary is included here for convenience because the Optiboot release archive does not contain binary 11 | for Atmega2560 and building it from sources can be complicated for many users (the original instructions seem outdated). 12 | 13 | For fuse setting see the boards.txt settings. 14 | 15 | IMPORTANT: To upload programs using this bootloader you need to use Arduino protocol; not the Wiring protocol which is used with the default bootloader! 16 | 17 | -------------------------------------------------------------------------------- /arduino/hardware/avr-debugger/avr/bootloaders/atmega328/atmega328_debug_optiboot.hex: -------------------------------------------------------------------------------- 1 | :10780000112484B714BE81FFBAD185E08093810032 2 | :1078100082E08093C00088E18093C10096E090935D 3 | :10782000C20090E19093C400809360008EE080934A 4 | :107830006000259A86E020E33CEF91E030938500DC 5 | :107840002093840096BBB09BFECF1D9AA8958150D3 6 | :10785000A9F7C0E0D0E008E138E0F32EEE24E3948D 7 | :1078600045E0B42E51E1A52E13E064D1813491F4AA 8 | :1078700061D1D82E6BD182E8D81203C084E053D1F5 9 | :1078800092C0E1E8DE1203C084E04DD18CC083E0F9 10 | :107890004AD189C0823419F484E164D184C085342A 11 | :1078A00019F485E05FD17FC0853549F443D1C82FF5 12 | :1078B00041D1D0E0D82BCC0FDD1F48D174C0863524 13 | :1078C00029F484E04FD180E02ED16DC0843609F0D8 14 | :1078D0003FC030D12FD1982E2DD1C115F0E7DF0751 15 | :1078E00038F4FE0117BFE895C12CDD24D39403C002 16 | :1078F000C12CDD24D3941ED1F60181936F019E1219 17 | :10790000FACFC115F0E7DF0718F0FE0117BFE895C1 18 | :107910001DD107B600FCFDCFFE01A0E0B1E08C91C7 19 | :1079200011962C91119790E0922B0C01E7BEE895EF 20 | :10793000112432961296A03881E0B80781F7FE0133 21 | :10794000B7BEE89507B600FCFDCFA7BEE8952BC0F3 22 | :107950008437B1F4EFD0EED0982EECD0F7D0892C4C 23 | :10796000FE016F018FEFC81AD80A8491DCD08A9487 24 | :10797000F6018110F6CF21969A94C90DD11D13C03E 25 | :10798000853741F4E3D08EE1CED085E9CCD08FE0CD 26 | :10799000CAD009C0813531F400936000F0926000D4 27 | :1079A000D5D001C0D3D080E1BED05FCF259A089555 28 | :1079B0001D9A089521E031E0FC013183208380E0AD 29 | :1079C00008952F923F924F925F926F927F928F9283 30 | :1079D0009F92AF92BF92CF92DF92EF92FF920F935E 31 | :1079E0001F93CF93DF93CDB7DEB728970FB6F894E8 32 | :1079F000DEBF0FBECDBF4115510509F47BC040FD70 33 | :107A000079C0F999FECF56954795DB01A07C1B0103 34 | :107A10000FE3200E311C240E351E9101207C3A8389 35 | :107A200029836F737727A980BA80AA15BB0508F050 36 | :107A30005DC02D01612C712C93018201000F111F7B 37 | :107A4000221F331F0D831E832F83388700E010E031 38 | :107A5000980168017901C40CD51CE61CF71CCC0CFC 39 | :107A6000DD1CEE1CFF1C6017710791F4FC01808087 40 | :107A7000918022242394F601040120925700E89576 41 | :107A800011244150510979F06F5F7F4F02960BC06E 42 | :107A9000F6012590349099249394F6010101909277 43 | :107AA0005700E89511240F5F1F4F2F4F3F4F0034B1 44 | :107AB00011052105310509F0CCCF33E0232EED81EE 45 | :107AC000FE8120925700E89507B600FCFDCF25E027 46 | :107AD000222EED81FE8120925700E89507B600FC2A 47 | :107AE000FDCFA05CBF4F60E070E09DCF81E180934F 48 | :107AF0005700E89528960FB6F894DEBF0FBECDBFAD 49 | :107B0000DF91CF911F910F91FF90EF90DF90CF9079 50 | :107B1000BF90AF909F908F907F906F905F904F90AD 51 | :107B20003F902F9008959091C00095FFFCCF8093D7 52 | :107B3000C60008958091C00087FFFCCF8091C000EF 53 | :107B400084FD01C0A8958091C6000895F3DF8032BE 54 | :107B500039F088E18093600088E080936000FFCF77 55 | :107B600084E1E1CFCF93C82FE5DFC150E9F7CF9192 56 | :107B7000EDCFE0E6F0E098E1908380830895E0E6C1 57 | :107B8000F0E088E180831082EE27FF2709949FEBC5 58 | :107B9000980F963010F4875308959FE9980F963008 59 | :107BA00010F48755089580538A3008F08FEF0895B8 60 | :107BB0008091C00087FFFCCF8091C600089590910E 61 | :107BC000C00095FFFCCF8093C60008950F931F93CC 62 | :107BD000CF93DF93D82F84E2F2DFC0E008E011E01A 63 | :107BE000DD2349F0F8018081EADFF80181918F01FE 64 | :107BF000C80FD150F5CF83E2E2DF8C2F82958F70D2 65 | :107C00008A3010F0895A01C0805DD9DFCF70CA3048 66 | :107C100010F087E501C080E38C0FDF91CF911F91B9 67 | :107C20000F91CDCFFC012E2F281B349131963111AD 68 | :107C3000FACF2D3908F02CE92093480240914802F0 69 | :107C4000242F30E0A8E0B1E0FC012150310920F000 70 | :107C500084918D933196F9CF842FB8CF88E089DF56 71 | :107C6000FFCFA6DF843271F020F4833009F4BAC06C 72 | :107C7000BAC08B32B1F38D3209F0B5C080914802A1 73 | :107C8000A5DFEFCF1092480293DFD0E0E0914802E9 74 | :107C9000833259F091E09E0F90934802F0E0E85F44 75 | :107CA000FE4F8083D80F84DFF1CFF0E0E85FFE4F16 76 | :107CB00010827EDF6CDFC82FC295C07F79DF67DF5F 77 | :107CC0008C2BD81719F08DE27ADFCBCF8BE277DFE0 78 | :107CD00080910801883579F038F4873409F47CC044 79 | :107CE000803509F479C07BC0833609F475C08337C9 80 | :107CF00009F472C074C0C12CD12C7601C0E0EC2F05 81 | :107D0000F0E08F01075F1E4FF801808140DF8F3F59 82 | :107D100069F044E0CC0CDD1CEE1CFF1C4A95D1F749 83 | :107D2000C80ED11CE11CF11CCF5FE9CF812C912C36 84 | :107D30005401712CC72DD0E0F801EC0FFD1F81819B 85 | :107D400026DF8F3F69F034E0880C991CAA1CBB1C0D 86 | :107D50003A95D1F7880E911CA11CB11C7394EACFFF 87 | :107D6000D701C60188279927BB27892B8A2B8B2B04 88 | :107D700081F5FE013296E00FF11FA8EAB1E0AD01F6 89 | :107D8000485A514048155905ACF480818D3771F43B 90 | :107D900081818A3041F028F49DEF980F923030F4C1 91 | :107DA00002C08D3519F480628183319680818D9374 92 | :107DB0003196E5CFD701C601AA27BC01CD01969522 93 | :107DC00087957795679588EA91E0FBDD85E091E0FE 94 | :107DD0000CC081E091E009C085E091E002C080E044 95 | :0E7DE00091E020DF3BDF80E091E01CDF3ACF36 96 | :087DEE0000453035004F4B0049 97 | :0E7FE80041426A02DA3CD63CD83CE13C313ED4 98 | :027FFE00040479 99 | :040000030000780081 100 | :00000001FF 101 | -------------------------------------------------------------------------------- /arduino/hardware/avr-debugger/avr/bootloaders/atmega328/readme.txt: -------------------------------------------------------------------------------- 1 | Bootloader for source level debugger for Arduino avr_debug 2 | Works for Arduino Uno (ATmega328). 3 | This is copy of the binary file optiboot.hex which can be found in avr_debug/bootloader folder. 4 | Please see this folder for info on building and using the bootloader. 5 | 6 | -------------------------------------------------------------------------------- /arduino/hardware/avr-debugger/avr/platform.txt: -------------------------------------------------------------------------------- 1 | name=avr_debugger 2 | version=1.0 3 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/bootloader/optiboot.hex: -------------------------------------------------------------------------------- 1 | :10780000112484B714BE81FFBAD185E08093810032 2 | :1078100082E08093C00088E18093C10096E090935D 3 | :10782000C20090E19093C400809360008EE080934A 4 | :107830006000259A86E020E33CEF91E030938500DC 5 | :107840002093840096BBB09BFECF1D9AA8958150D3 6 | :10785000A9F7C0E0D0E008E138E0F32EEE24E3948D 7 | :1078600045E0B42E51E1A52E13E064D1813491F4AA 8 | :1078700061D1D82E6BD182E8D81203C084E053D1F5 9 | :1078800092C0E1E8DE1203C084E04DD18CC083E0F9 10 | :107890004AD189C0823419F484E164D184C085342A 11 | :1078A00019F485E05FD17FC0853549F443D1C82FF5 12 | :1078B00041D1D0E0D82BCC0FDD1F48D174C0863524 13 | :1078C00029F484E04FD180E02ED16DC0843609F0D8 14 | :1078D0003FC030D12FD1982E2DD1C115F0E7DF0751 15 | :1078E00038F4FE0117BFE895C12CDD24D39403C002 16 | :1078F000C12CDD24D3941ED1F60181936F019E1219 17 | :10790000FACFC115F0E7DF0718F0FE0117BFE895C1 18 | :107910001DD107B600FCFDCFFE01A0E0B1E08C91C7 19 | :1079200011962C91119790E0922B0C01E7BEE895EF 20 | :10793000112432961296A03881E0B80781F7FE0133 21 | :10794000B7BEE89507B600FCFDCFA7BEE8952BC0F3 22 | :107950008437B1F4EFD0EED0982EECD0F7D0892C4C 23 | :10796000FE016F018FEFC81AD80A8491DCD08A9487 24 | :10797000F6018110F6CF21969A94C90DD11D13C03E 25 | :10798000853741F4E3D08EE1CED085E9CCD08FE0CD 26 | :10799000CAD009C0813531F400936000F0926000D4 27 | :1079A000D5D001C0D3D080E1BED05FCF259A089555 28 | :1079B0001D9A089521E031E0FC013183208380E0AD 29 | :1079C00008952F923F924F925F926F927F928F9283 30 | :1079D0009F92AF92BF92CF92DF92EF92FF920F935E 31 | :1079E0001F93CF93DF93CDB7DEB728970FB6F894E8 32 | :1079F000DEBF0FBECDBF4115510509F47BC040FD70 33 | :107A000079C0F999FECF56954795DB01A07C1B0103 34 | :107A10000FE3200E311C240E351E9101207C3A8389 35 | :107A200029836F737727A980BA80AA15BB0508F050 36 | :107A30005DC02D01612C712C93018201000F111F7B 37 | :107A4000221F331F0D831E832F83388700E010E031 38 | :107A5000980168017901C40CD51CE61CF71CCC0CFC 39 | :107A6000DD1CEE1CFF1C6017710791F4FC01808087 40 | :107A7000918022242394F601040120925700E89576 41 | :107A800011244150510979F06F5F7F4F02960BC06E 42 | :107A9000F6012590349099249394F6010101909277 43 | :107AA0005700E89511240F5F1F4F2F4F3F4F0034B1 44 | :107AB00011052105310509F0CCCF33E0232EED81EE 45 | :107AC000FE8120925700E89507B600FCFDCF25E027 46 | :107AD000222EED81FE8120925700E89507B600FC2A 47 | :107AE000FDCFA05CBF4F60E070E09DCF81E180934F 48 | :107AF0005700E89528960FB6F894DEBF0FBECDBFAD 49 | :107B0000DF91CF911F910F91FF90EF90DF90CF9079 50 | :107B1000BF90AF909F908F907F906F905F904F90AD 51 | :107B20003F902F9008959091C00095FFFCCF8093D7 52 | :107B3000C60008958091C00087FFFCCF8091C000EF 53 | :107B400084FD01C0A8958091C6000895F3DF8032BE 54 | :107B500039F088E18093600088E080936000FFCF77 55 | :107B600084E1E1CFCF93C82FE5DFC150E9F7CF9192 56 | :107B7000EDCFE0E6F0E098E1908380830895E0E6C1 57 | :107B8000F0E088E180831082EE27FF2709949FEBC5 58 | :107B9000980F963010F4875308959FE9980F963008 59 | :107BA00010F48755089580538A3008F08FEF0895B8 60 | :107BB0008091C00087FFFCCF8091C600089590910E 61 | :107BC000C00095FFFCCF8093C60008950F931F93CC 62 | :107BD000CF93DF93D82F84E2F2DFC0E008E011E01A 63 | :107BE000DD2349F0F8018081EADFF80181918F01FE 64 | :107BF000C80FD150F5CF83E2E2DF8C2F82958F70D2 65 | :107C00008A3010F0895A01C0805DD9DFCF70CA3048 66 | :107C100010F087E501C080E38C0FDF91CF911F91B9 67 | :107C20000F91CDCFFC012E2F281B349131963111AD 68 | :107C3000FACF2D3908F02CE92093480240914802F0 69 | :107C4000242F30E0A8E0B1E0FC012150310920F000 70 | :107C500084918D933196F9CF842FB8CF88E089DF56 71 | :107C6000FFCFA6DF843271F020F4833009F4BAC06C 72 | :107C7000BAC08B32B1F38D3209F0B5C080914802A1 73 | :107C8000A5DFEFCF1092480293DFD0E0E0914802E9 74 | :107C9000833259F091E09E0F90934802F0E0E85F44 75 | :107CA000FE4F8083D80F84DFF1CFF0E0E85FFE4F16 76 | :107CB00010827EDF6CDFC82FC295C07F79DF67DF5F 77 | :107CC0008C2BD81719F08DE27ADFCBCF8BE277DFE0 78 | :107CD00080910801883579F038F4873409F47CC044 79 | :107CE000803509F479C07BC0833609F475C08337C9 80 | :107CF00009F472C074C0C12CD12C7601C0E0EC2F05 81 | :107D0000F0E08F01075F1E4FF801808140DF8F3F59 82 | :107D100069F044E0CC0CDD1CEE1CFF1C4A95D1F749 83 | :107D2000C80ED11CE11CF11CCF5FE9CF812C912C36 84 | :107D30005401712CC72DD0E0F801EC0FFD1F81819B 85 | :107D400026DF8F3F69F034E0880C991CAA1CBB1C0D 86 | :107D50003A95D1F7880E911CA11CB11C7394EACFFF 87 | :107D6000D701C60188279927BB27892B8A2B8B2B04 88 | :107D700081F5FE013296E00FF11FA8EAB1E0AD01F6 89 | :107D8000485A514048155905ACF480818D3771F43B 90 | :107D900081818A3041F028F49DEF980F923030F4C1 91 | :107DA00002C08D3519F480628183319680818D9374 92 | :107DB0003196E5CFD701C601AA27BC01CD01969522 93 | :107DC00087957795679588EA91E0FBDD85E091E0FE 94 | :107DD0000CC081E091E009C085E091E002C080E044 95 | :0E7DE00091E020DF3BDF80E091E01CDF3ACF36 96 | :087DEE0000453035004F4B0049 97 | :0E7FE80041426A02DA3CD63CD83CE13C313ED4 98 | :027FFE00040479 99 | :040000030000780081 100 | :00000001FF 101 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/bootloader/readme.txt: -------------------------------------------------------------------------------- 1 | Bootloader for source level debugger for Arduino avr_debug 2 | 3 | Works for Arduino Uno (ATmega328). 4 | 5 | optiboot.hex is the binary file which you can burn into your Arduino Uno to use flash breakpoints in the debugger. 6 | 7 | The original of this file together with sources and instructions can be found in avr_debug/bootloader folder. 8 | 9 | July 2020 update 10 | ----------------- 11 | You can use Optiboot bootloader version 8.0 or newer instead of this bootloader to use flash breakpoints. 12 | This allows using flash breakpoints also for Arduino Mega. 13 | For more informatipon please see the avr-debugger project at github: https://github.com/jdolinay/avr_debug 14 | There is also hardware platform to make it easier to update the bootloader available in the avr_debug\arduino\hardware\ subfolder 15 | of the github project. 16 | 17 | 18 | Usage 19 | ------- 20 | To use this bootloader, flash your Arduino with the optiboot.hex provided here. To do this, you will need 21 | an AVR-ISP programmer. 22 | 23 | Fuse settings 24 | -------------- 25 | IMPORTANT: The size of the bootloader is different than the original optiboot for Arduino. 26 | You need to program different bootloader size for this bootloader. 27 | Set BOOTSZ to 1024 w (bootloader address 3c00) 28 | You don't need to change any other fuses in Arduino. 29 | 30 | For those interested, here is complete fuse info: 31 | Raw fuses value: 32 | EXTENDED: 0xFD 33 | HIGH: 0xD2 34 | LOW: 0xFF 35 | 36 | Fuse settings for humans: 37 | Enable SPIEN 38 | Enable BOOTRST 39 | Enable EESAVE 40 | Set BOOTSZ to 1024 words (bootloader start address 0x3c00) 41 | Set clock to EXT OSC 8 or 16 MHz 42 | 43 | Lock bits 44 | For the debugging to work the application code must be able to read the bootloader memory. 45 | This is enabled by default if you erase the chip. 46 | If you encounter problems with debugging your app after updating the bootloader, make sure the 47 | lock bits do not prohibit reading Boot section (LPM instruction in Boot section must not be disabled). 48 | The correct lock bit value is 0xFF or 0xEF in the programmer GUI in Atmel Studio. 49 | 50 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/examples/debug_blink/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(gdb) Launch", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/build/app.ino.elf", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${workspaceFolder}", 15 | "environment": [], 16 | "externalConsole": false, 17 | "MIMode": "gdb", 18 | "miDebuggerPath": "c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\bin\\avr-gdb.exe", 19 | "miDebuggerServerAddress": "\\\\.\\COM7", 20 | "launchCompleteCommand": "None", 21 | "setupCommands": [ 22 | { 23 | "description": "Remote debug enable", 24 | "text": "-gdb-set debug remote 1", 25 | "ignoreFailures": false 26 | } 27 | ], 28 | 29 | } 30 | ] 31 | } -------------------------------------------------------------------------------- /arduino/library/avr-debugger/examples/debug_blink/app.ino: -------------------------------------------------------------------------------- 1 | // Example program for avr-debugger library. 2 | // IMPORTANT: 3 | // These instructions are for Visual Studio Code. For other use cases see the readme.txt. 4 | // To start debugging: 5 | // - Add "output": ".\\build" to file arduino.json (in .vscode folder) 6 | // - Change the COM port number to your port number in launch.json, see "miDebuggerServerAddress": "\\\\.\\COM7" 7 | // - Change the path to point to avr-gdb.exe in your Arduino installation, see launch.json, "miDebuggerPath": 8 | // 9 | // - Place breakpoint to loop, e.g. on digitalWrite - by clicking into the left margin of the file - red dot should appear 10 | // - Upload the program to your Arduino 11 | // - Switch to debug view 12 | // - Click Start debugging button (Play icon) in the top 13 | // 14 | 15 | #include 16 | #include 17 | 18 | int globalCounter = 0; 19 | 20 | void setup() 21 | { 22 | debug_init(); // initialize the debugger 23 | 24 | pinMode(13, OUTPUT); 25 | } 26 | 27 | void loop() 28 | { 29 | int localCounter = 0; 30 | localCounter++; 31 | 32 | digitalWrite(13, HIGH); 33 | delay(100); 34 | digitalWrite(13, LOW); 35 | delay(200); 36 | 37 | globalCounter++; 38 | localCounter++; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Test 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | # Test KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | debug_init KEYWORD2 16 | breakpoint KEYWORD2 17 | debug_message KEYWORD2 18 | 19 | ####################################### 20 | # Instances (KEYWORD2) 21 | ####################################### 22 | 23 | ####################################### 24 | # Constants (LITERAL1) 25 | ####################################### 26 | 27 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "name": "COM7 (gdb) Launch", 10 | "type": "cppdbg", 11 | "request": "launch", 12 | "launchCompleteCommand": "None", 13 | "program": "${workspaceFolder}/build/app.ino.elf", 14 | "args": [], 15 | "stopAtEntry": false, 16 | "cwd": "${workspaceFolder}", 17 | "environment": [], 18 | "externalConsole": false, 19 | "MIMode": "gdb", 20 | "miDebuggerPath": "c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\bin\\avr-gdb.exe", 21 | "miDebuggerServerAddress": "\\\\.\\COM7", 22 | "setupCommands": [ 23 | { 24 | "description": "Remote debug enable", 25 | "text": "-gdb-set debug remote 1", 26 | "ignoreFailures": false 27 | } 28 | ] 29 | } 30 | ] 31 | } -------------------------------------------------------------------------------- /arduino/library/avr-debugger/library.properties: -------------------------------------------------------------------------------- 1 | name=avr-debugger 2 | version=1.5 3 | author=Jan Dolinay 4 | maintainer=Jan Dolinay 5 | sentence=Enables debugging arduino code. 6 | paragraph=This library provides source level debugger for Arduino Uno and Mega. This debugger can be used to step through your code, place breakpoints, view variables etc. No external hardware is needed. Debugging requires IDE with debugging capabilities, for example, Visual Studio Code. This cannot be used with Arduino IDE! Add this library to your sketch, call debug_init() in your setup() and create launch configuration - see example launch.json for VS Code in the library. 7 | category=Other 8 | url=https://github.com/jdolinay/avr_debug 9 | architectures=avr 10 | 11 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/platform.local.txt: -------------------------------------------------------------------------------- 1 | 2 | # Arduino AVR Core and platform. 3 | # ------------------------------ 4 | # custom file for experiments with Arduino debugger avr-stub. 5 | # turn off optimizations by -O0 instead of -Os (optimize for size) 6 | # All other options are the same as in original platform.txt in Arduino IDE 1.8.9 7 | compiler.c.flags=-c -g -O0 {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects 8 | compiler.cpp.flags=-c -g -O0 {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto 9 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/platform.local.txt.baud_57600: -------------------------------------------------------------------------------- 1 | 2 | # Arduino AVR Core and platform. 3 | # ------------------------------ 4 | # custom file for experiments with Arduino debugger avr-stub. 5 | compiler.c.flags=-c -g -O0 {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -DAVR8_USER_BAUDRATE=57600 6 | compiler.cpp.flags=-c -g -O0 {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto 7 | 8 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/readme.txt: -------------------------------------------------------------------------------- 1 | avr_debug 2 | 3 | This library provides source level debugger for Arduino Uno and Mega. 4 | This debugger can be used to step through your code, place breakpoints, view variables etc. 5 | No external hardware is needed. 6 | Supports Arduino UNO and MEGA. 7 | Created by Jan Dolinay. 8 | 9 | This library is part of larger project, see https://www.codeproject.com/Articles/1037057/Debugger-for-Arduino 10 | and https://github.com/jdolinay/avr_debug 11 | 12 | 13 | Requirements 14 | -------------------------------------------------------------------------------- 15 | Debugging requires IDE with debugging capabilities, for example, Visual Studio Code. 16 | This cannot be used with Arduino IDE! 17 | 18 | 19 | Installation 20 | -------------------------------------------------------------------------------- 21 | To install this library, just place this entire folder as a subfolder in your 22 | Arduino/libraries folder (This folder is in Documents on Windows) 23 | 24 | 25 | Usage 26 | -------------------------------------------------------------------------------- 27 | Note: This library cannot be used with Arduino IDE. It requires IDE with debugging capabilities, for example, Visual Studio Code or eclipse. 28 | 29 | Windows instructions: 30 | - Add this library to your sketch 31 | - Put call to debug_init(); into your setup() function. 32 | - In file manager copy the provided launch.json file to your-sketsch-location/.vscode folder. 33 | - Change the number of COM port to the number where your arduino is connected - see "miDebuggerServerAddress": in launch.json 34 | - Change the location of avr-gdb.exe. The default will work only if you installed Arduino IDE to default location. 35 | Default path: "c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\bin\\avr-gdb.exe" 36 | see "miDebuggerPath": 37 | 38 | Optional, but highly recommended step: 39 | - copy platform.local.txt to your-arduino-directory/hardware/arduino/avr 40 | Default location: c:\Program Files (x86)\Arduino\hardware\arduino\avr\ 41 | Important note: this affects all programs you build in Arduino IDE or VS code! 42 | This will modify the build settings so that the program is easier to debug (turn of compiler optimizations). 43 | The code will also be larger. For building the final program remove or rename the platform.local.txt file. 44 | This will make your program smaller and faster. 45 | 46 | 47 | Breakpoints in FLASH memory 48 | -------------------------------------------------------------------------------- 49 | By default the debugger in in basic configuration, which I call "RAM breakpoints". 50 | The advantage of this configuration is that you don’t need to do anything with the Arduino board, just add library to your program. 51 | The disadvantage is that the program runs at much slower speed when debugged. 52 | 53 | To overcome this disadvantage you can switch to "Flash breakpoints", but this requires updating bootloader in your Arduino board. 54 | For Arduino Uno and other boards using ATmega328 you can use special bootloader provided with this library. 55 | You can find it in the bootloader subfolder of the library and burn it into your Arduino. 56 | 57 | As another option for ATmega328 and as the only option for the other boards you can use OPTIBOOT bootloader version 8.0 and higher. 58 | After updating the bootloader open the avr8-stub.h file change AVR8_BREAKPOINT_MODE from 1 to 0 or 2 depending on the bootloader. 59 | For detailed instructions please see the documentation for the avr_gdb debugger - https://github.com/jdolinay/avr_debug. 60 | Look into the doc folder - avr_debug.pdf. 61 | 62 | 63 | 64 | Linux and Mac instructions 65 | -------------------------------------------------------------------------------- 66 | 67 | I hope you can figure it out based on the instructions above. 68 | Some instructions are provided in the doc file in https://github.com/jdolinay/avr_debug. 69 | Look into the doc folder - avr_debug.pdf. 70 | 71 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/src/app_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | * app_api.c 3 | * 4 | * Implementation of the bootloader API. 5 | * This file should be built with the user app. 6 | * 7 | * Usage: 8 | * Call the function as needed. 9 | * You can also call boot_init_api, but it is called automatically if you don't 10 | * 11 | * 12 | * Created on: 16. 3. 2017 13 | * Author: jan dolinay 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #include "app_api.h" 21 | 22 | /* If AVR8_API_DEBUG is defined, there is a variable for counting flash writes. 23 | You can view this variable in the debugger in eclipse: g_boot_write_cnt*/ 24 | // #define AVR8_API_DEBUG 25 | 26 | /* jump table struct */ 27 | struct avrdbgboot_jump_table_s { 28 | uint8_t id[3]; 29 | uint8_t ver; 30 | uint16_t ptr[]; 31 | }; 32 | 33 | /* Counter to count writes to flash. 34 | You can view this variable in debugger to see how many writes 35 | there are when stepping through the code, inserting breakpoints etc.*/ 36 | #ifdef AVR8_API_DEBUG 37 | uint16_t g_boot_write_cnt; 38 | #endif 39 | 40 | 41 | 42 | #define JUMP_TABLE_LOCATION (0x7fe8) 43 | #define JUMP_TABLE_INDEX(k) (JUMP_TABLE_LOCATION + 4UL + 2UL * (k)) 44 | 45 | #define PGM_READ_BYTE pgm_read_byte_near 46 | #define PGM_READ_WORD pgm_read_word_near 47 | #define PGM_READ_DWORD pgm_read_dword_near 48 | 49 | uint8_t g_app_api_version = 0; 50 | 51 | __attribute__((optimize("-Os"))) 52 | uint8_t dboot_init_api(void) { 53 | struct avrdbgboot_jump_table_s jp; 54 | 55 | if (g_app_api_version > 0) 56 | return BOOT_OK; // already initialized 57 | 58 | *((uint32_t *) (&jp)) = PGM_READ_DWORD(JUMP_TABLE_LOCATION); 59 | 60 | if ((jp.id[0] == 'A') && (jp.id[1] == 'B') && (jp.id[2] == 'j')) { 61 | g_app_api_version = jp.ver; 62 | #ifdef AVR8_API_DEBUG 63 | g_boot_write_cnt = 0; 64 | #endif 65 | return BOOT_OK; 66 | } 67 | 68 | return BOOT_ID_INVALID; 69 | } 70 | 71 | __attribute__((optimize("-Os"))) 72 | uint8_t dboot_get_api_version(uint8_t *ver) { 73 | if (g_app_api_version > 0) { 74 | /* boot_init_api reads the api version into g_app_api_version */ 75 | *ver = g_app_api_version; 76 | } 77 | return BOOT_OK; 78 | 79 | } 80 | 81 | __attribute__((optimize("-Os"))) 82 | uint8_t dboot_get_version(uint16_t *ver) { 83 | uint8_t ret; 84 | uint16_t ptr; 85 | 86 | if (g_app_api_version == BOOT_API_VERSION) { 87 | ptr = PGM_READ_WORD(JUMP_TABLE_INDEX(0)); 88 | if (ptr == 0 || ptr == 0xffff) 89 | return BOOT_FUNCTION_INVALID; 90 | 91 | ret = ((uint8_t (*)(uint16_t *)) ptr)(ver); 92 | return ret; 93 | } 94 | 95 | return BOOT_VERSION_INVALID; 96 | } 97 | 98 | __attribute__((optimize("-Os"))) 99 | uint8_t dboot_led_init(void) { 100 | #if AVR8_STUB_DEBUG 101 | uint16_t ptr; 102 | 103 | if (g_app_api_version == BOOT_API_VERSION) { 104 | ptr = PGM_READ_WORD(JUMP_TABLE_INDEX(1)); 105 | if (ptr == 0 || ptr == 0xffff) 106 | return BOOT_FUNCTION_INVALID; 107 | 108 | /* call the function */ 109 | ((void (*)(void)) ptr)(); 110 | return BOOT_OK; // ok 111 | } 112 | #endif 113 | return BOOT_VERSION_INVALID; 114 | } 115 | 116 | __attribute__((optimize("-Os"))) 117 | uint8_t dboot_led_toggle(void) { 118 | #if AVR8_STUB_DEBUG 119 | uint8_t ret; 120 | uint16_t ptr; 121 | 122 | if (g_app_api_version == BOOT_API_VERSION) { 123 | ptr = PGM_READ_WORD(JUMP_TABLE_INDEX(2)); 124 | if (ptr == 0 || ptr == 0xffff) 125 | return BOOT_FUNCTION_INVALID; 126 | 127 | /* call the function */ 128 | ((void (*)(void)) ptr)(); 129 | return BOOT_OK; // ok 130 | } 131 | #endif 132 | return BOOT_VERSION_INVALID; 133 | } 134 | 135 | /* write to flash */ 136 | __attribute__((optimize("-Os"))) 137 | uint8_t dboot_safe_pgm_write(const void *ram_addr, uint16_t rom_addr, uint16_t sz) { 138 | uint16_t ptr; 139 | char cSREG; 140 | 141 | if (g_app_api_version == BOOT_API_VERSION) { 142 | ptr = PGM_READ_WORD(JUMP_TABLE_INDEX(3)); 143 | if (ptr == 0 || ptr == 0xffff) 144 | return BOOT_FUNCTION_INVALID; 145 | 146 | /* disable interrupts */ 147 | cSREG = SREG;// store SREG value 148 | cli(); 149 | 150 | /* call the function */ 151 | ((void (*)(const void *, uint16_t,uint16_t)) ptr)(ram_addr, rom_addr, sz); 152 | 153 | /* enable interrupts (restore) */ 154 | SREG = cSREG;// restore SREG value (I-bit) 155 | 156 | /* debug info - number of write cycles */ 157 | #ifdef AVR8_API_DEBUG 158 | g_boot_write_cnt++; 159 | #endif 160 | 161 | return BOOT_OK; 162 | } 163 | 164 | return BOOT_VERSION_INVALID; 165 | } 166 | 167 | /* Receive new program from GDB using the remote communication protocol, 168 | binary load packets (X). */ 169 | __attribute__((optimize("-Os"))) 170 | uint8_t dboot_handle_xload(void) { 171 | 172 | uint16_t ptr; 173 | char cSREG; 174 | 175 | if (g_app_api_version == BOOT_API_VERSION) { 176 | ptr = PGM_READ_WORD(JUMP_TABLE_INDEX(4)); 177 | if (ptr == 0 || ptr == 0xffff) 178 | return BOOT_FUNCTION_INVALID; 179 | 180 | // disable interrupts 181 | cSREG = SREG; // store SREG value 182 | cli(); 183 | 184 | // call the function 185 | ((void (*)(void)) ptr)(); 186 | 187 | // enable interrupts (restore) 188 | SREG = cSREG; // restore SREG value (I-bit) 189 | 190 | return BOOT_OK; 191 | } 192 | 193 | return BOOT_VERSION_INVALID; 194 | } 195 | 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/src/app_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * app_api.h 3 | * 4 | * Define the API for the user applications to call the bootloader. 5 | * This file is used in the user application code only! 6 | * User bootloader should include bootapi.h file only. 7 | 8 | * NOTE to implementors: 9 | * The app_api.h and bootapi.h files should be kept in sync (the jump table structure) 10 | * but it is not good to have a single file as the app version will have some extra functions 11 | * and the functions are actually different in app than in bootloader. 12 | * 13 | * Created on: 16. 3. 2017 14 | * Author: jan dolinay 15 | */ 16 | 17 | #ifndef APP_API_H_ 18 | #define APP_API_H_ 19 | 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | 26 | /* Error codes */ 27 | #define BOOT_OK (0) /* no error, success */ 28 | #define BOOT_ERROR (1) /* unspecified error */ 29 | #define BOOT_FUNCTION_INVALID (2) /* The function address in jump table was not valid */ 30 | #define BOOT_VERSION_INVALID (3) /* The version of the jump table in bootloader does not match the version of this code */ 31 | #define BOOT_ID_INVALID (4) /* The ID of the bootloader API does not match the ID expected by this code */ 32 | 33 | 34 | #define BOOT_API_VERSION (2) /* Version of the API expected by this code. */ 35 | /* See the "ver" field in jump table struct avrdbgboot_jump_table_s in app_api.c */ 36 | 37 | 38 | /* Helper functions */ 39 | /** 40 | * Must be called to initialize the API and verify that it is OK before 41 | * using any other function of this API. 42 | */ 43 | uint8_t dboot_init_api(void); 44 | 45 | 46 | /* Bootloader API functions - the functions in the bootloader */ 47 | 48 | /** 49 | * Read the verison of the API. 50 | * This is the value of the "ver" field in the jump table struct avrdbgboot_jump_table_s 51 | * @param ver (out) - the version of the API 52 | * @return BOOT_OK on success. 53 | * */ 54 | uint8_t dboot_get_api_version(uint8_t *ver); 55 | 56 | /** 57 | * Read the version of the bootloader from bootloader memory. 58 | * This is the version of the bootloader, not the version of the API. 59 | * The bootloader verison is (AVRDBG_BOOT_VERSION_MAJOR << 8) | (AVRDBG_BOOT_VERSION_MINOR) 60 | * as defined in bootapi.c 61 | * @param ver (out) - the version of the bootloader 62 | * @return BOOT_OK on success. 63 | * */ 64 | uint8_t dboot_get_version(uint16_t *ver); 65 | 66 | 67 | /** 68 | * Toggle the on-board LED 69 | * This is only available if AVR8_STUB_DEBUG is defined. If not defined, 70 | * it just returns BOOT_VERSION_INVALID. 71 | * @return BOOT_OK on success. 72 | */ 73 | uint8_t dboot_led_toggle(void); 74 | 75 | 76 | /** 77 | * Initialize the pin for on-board LED (PB5) 78 | * This is only available if AVR8_STUB_DEBUG is defined. If not defined, 79 | * it just returns BOOT_VERSION_INVALID. 80 | * @return BOOT_OK on success. 81 | */ 82 | uint8_t dboot_led_init(void); 83 | 84 | /** 85 | * Write to program memory from RAM buffer. 86 | * rom_addr - in words, 87 | * sz - in bytes and must be multiple of two. 88 | */ 89 | uint8_t dboot_safe_pgm_write(const void *ram_addr, uint16_t rom_addr, uint16_t sz); 90 | 91 | /** 92 | * Handle X load command from GDB that is load new application to memory 93 | */ 94 | uint8_t dboot_handle_xload(void); 95 | 96 | 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | 103 | #endif /* APP_API_H_ */ 104 | -------------------------------------------------------------------------------- /arduino/library/avr-debugger/src/avr_debugger.h: -------------------------------------------------------------------------------- 1 | #include "avr8-stub.h" 2 | #include 3 | 4 | #ifndef AVR_DEBUGGER_H_ 5 | #define AVR_DEBUGGER_H_ 6 | 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #if defined(PLATFORMIO) && defined(__PLATFORMIO_BUILD_DEBUG__) 13 | #ifndef __DEBUG__ 14 | #define __DEBUG__ 15 | #endif 16 | #endif 17 | 18 | #if defined(__DEBUG__) 19 | #define DBG_EXEC(x) x 20 | #else 21 | #define DBG_EXEC(x) 22 | #endif 23 | 24 | #define dbg_breakpoint() { \ 25 | DBG_EXEC(breakpoint()); \ 26 | } 27 | 28 | #define dbg_init() { \ 29 | DBG_EXEC(debug_init()); \ 30 | } 31 | 32 | #define dbg_message(x) { \ 33 | DBG_EXEC(debug_message(x)); \ 34 | } 35 | 36 | #define dbg_start() { \ 37 | DBG_EXEC(debug_init()); \ 38 | DBG_EXEC(sei()); \ 39 | DBG_EXEC(breakpoint()); \ 40 | } 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | 47 | #endif /* AVR_DEBUGGER_H_ */ -------------------------------------------------------------------------------- /arduino/readme.txt: -------------------------------------------------------------------------------- 1 | This folder contains 2 | 3 | 1. library for Arduino - makes it easy to use the debugger in Visual Studio Code. 4 | You can copy the avr-debugger folder to your Libraries forder (in your Documents/Arduino on Windows) 5 | and use it as any other library. See readme.txt in the library for more info. 6 | 7 | Note: the source files .c and .h in this folder/src are copies of the files in avr8-stub folder. 8 | This is not the best solution - the same files at two places - but I want to have the library complete, ready to just copy and use. 9 | Make any code changes in the avr8-stub folder; then copy changed files to this arduino library src folder to keep the files in sync. 10 | 11 | 2. hardware platform files to allow burning the debugger-enabled bootloader from Arduino IDE. 12 | Copy the hardware folder into your Arduino sketchbook folder, for example, Documents/Arduino. 13 | You should then see new board - avr-debugger Atmega328 bootloader in the Tools menu in Arduino IDE. 14 | Select this board to burn the bootloader with debug support to your Arduino. 15 | 16 | 17 | 3. modified file(s) from the Arduino package - can be useful if you use eclipse IDE. 18 | You can replace the original files with those files to make it easier to enable the debugger support in your program. 19 | 20 | Arduino package used: 1.6.5-r5, 1.8.1 21 | 22 | Your project should define AVR_DEBUG symbol in project properties > C/C++ Build > Settings > AVR Compiler > Symbols. 23 | This way only projects with AVR_DEBUG symbol defined will exclude this code. Other project will not be affected. 24 | 25 | For more information, please see the documentation in /doc folder. 26 | 27 | Files: 28 | ------- 29 | File: WInterrupts.c 30 | Modification: section for INT0, INT1,... interrupt placed into #if AVR_DEBUG section. 31 | Reason: This allows building the project with this debugger which uses INTx interrupt itself. 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /avr8-stub/app_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | * app_api.c 3 | * 4 | * Implementation of the bootloader API. 5 | * This file should be built with the user app. 6 | * 7 | * Usage: 8 | * Call the function as needed. 9 | * You can also call boot_init_api, but it is called automatically if you don't 10 | * 11 | * 12 | * Created on: 16. 3. 2017 13 | * Author: jan dolinay 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #include "app_api.h" 21 | 22 | /* If AVR8_API_DEBUG is defined, there is a variable for counting flash writes. 23 | You can view this variable in the debugger in eclipse: g_boot_write_cnt*/ 24 | // #define AVR8_API_DEBUG 25 | 26 | /* jump table struct */ 27 | struct avrdbgboot_jump_table_s { 28 | uint8_t id[3]; 29 | uint8_t ver; 30 | uint16_t ptr[]; 31 | }; 32 | 33 | /* Counter to count writes to flash. 34 | You can view this variable in debugger to see how many writes 35 | there are when stepping through the code, inserting breakpoints etc.*/ 36 | #ifdef AVR8_API_DEBUG 37 | uint16_t g_boot_write_cnt; 38 | #endif 39 | 40 | 41 | 42 | #define JUMP_TABLE_LOCATION (0x7fe8) 43 | #define JUMP_TABLE_INDEX(k) (JUMP_TABLE_LOCATION + 4UL + 2UL * (k)) 44 | 45 | #define PGM_READ_BYTE pgm_read_byte_near 46 | #define PGM_READ_WORD pgm_read_word_near 47 | #define PGM_READ_DWORD pgm_read_dword_near 48 | 49 | uint8_t g_app_api_version = 0; 50 | 51 | __attribute__((optimize("-Os"))) 52 | uint8_t dboot_init_api(void) { 53 | struct avrdbgboot_jump_table_s jp; 54 | 55 | if (g_app_api_version > 0) 56 | return BOOT_OK; // already initialized 57 | 58 | *((uint32_t *) (&jp)) = PGM_READ_DWORD(JUMP_TABLE_LOCATION); 59 | 60 | if ((jp.id[0] == 'A') && (jp.id[1] == 'B') && (jp.id[2] == 'j')) { 61 | g_app_api_version = jp.ver; 62 | #ifdef AVR8_API_DEBUG 63 | g_boot_write_cnt = 0; 64 | #endif 65 | return BOOT_OK; 66 | } 67 | 68 | return BOOT_ID_INVALID; 69 | } 70 | 71 | __attribute__((optimize("-Os"))) 72 | uint8_t dboot_get_api_version(uint8_t *ver) { 73 | if (g_app_api_version > 0) { 74 | /* boot_init_api reads the api version into g_app_api_version */ 75 | *ver = g_app_api_version; 76 | } 77 | return BOOT_OK; 78 | 79 | } 80 | 81 | __attribute__((optimize("-Os"))) 82 | uint8_t dboot_get_version(uint16_t *ver) { 83 | uint8_t ret; 84 | uint16_t ptr; 85 | 86 | if (g_app_api_version == BOOT_API_VERSION) { 87 | ptr = PGM_READ_WORD(JUMP_TABLE_INDEX(0)); 88 | if (ptr == 0 || ptr == 0xffff) 89 | return BOOT_FUNCTION_INVALID; 90 | 91 | ret = ((uint8_t (*)(uint16_t *)) ptr)(ver); 92 | return ret; 93 | } 94 | 95 | return BOOT_VERSION_INVALID; 96 | } 97 | 98 | __attribute__((optimize("-Os"))) 99 | uint8_t dboot_led_init(void) { 100 | #if AVR8_STUB_DEBUG 101 | uint16_t ptr; 102 | 103 | if (g_app_api_version == BOOT_API_VERSION) { 104 | ptr = PGM_READ_WORD(JUMP_TABLE_INDEX(1)); 105 | if (ptr == 0 || ptr == 0xffff) 106 | return BOOT_FUNCTION_INVALID; 107 | 108 | /* call the function */ 109 | ((void (*)(void)) ptr)(); 110 | return BOOT_OK; // ok 111 | } 112 | #endif 113 | return BOOT_VERSION_INVALID; 114 | } 115 | 116 | __attribute__((optimize("-Os"))) 117 | uint8_t dboot_led_toggle(void) { 118 | #if AVR8_STUB_DEBUG 119 | uint8_t ret; 120 | uint16_t ptr; 121 | 122 | if (g_app_api_version == BOOT_API_VERSION) { 123 | ptr = PGM_READ_WORD(JUMP_TABLE_INDEX(2)); 124 | if (ptr == 0 || ptr == 0xffff) 125 | return BOOT_FUNCTION_INVALID; 126 | 127 | /* call the function */ 128 | ((void (*)(void)) ptr)(); 129 | return BOOT_OK; // ok 130 | } 131 | #endif 132 | return BOOT_VERSION_INVALID; 133 | } 134 | 135 | /* write to flash */ 136 | __attribute__((optimize("-Os"))) 137 | uint8_t dboot_safe_pgm_write(const void *ram_addr, uint16_t rom_addr, uint16_t sz) { 138 | uint16_t ptr; 139 | char cSREG; 140 | 141 | if (g_app_api_version == BOOT_API_VERSION) { 142 | ptr = PGM_READ_WORD(JUMP_TABLE_INDEX(3)); 143 | if (ptr == 0 || ptr == 0xffff) 144 | return BOOT_FUNCTION_INVALID; 145 | 146 | /* disable interrupts */ 147 | cSREG = SREG;// store SREG value 148 | cli(); 149 | 150 | /* call the function */ 151 | ((void (*)(const void *, uint16_t,uint16_t)) ptr)(ram_addr, rom_addr, sz); 152 | 153 | /* enable interrupts (restore) */ 154 | SREG = cSREG;// restore SREG value (I-bit) 155 | 156 | /* debug info - number of write cycles */ 157 | #ifdef AVR8_API_DEBUG 158 | g_boot_write_cnt++; 159 | #endif 160 | 161 | return BOOT_OK; 162 | } 163 | 164 | return BOOT_VERSION_INVALID; 165 | } 166 | 167 | /* Receive new program from GDB using the remote communication protocol, 168 | binary load packets (X). */ 169 | __attribute__((optimize("-Os"))) 170 | uint8_t dboot_handle_xload(void) { 171 | 172 | uint16_t ptr; 173 | char cSREG; 174 | 175 | if (g_app_api_version == BOOT_API_VERSION) { 176 | ptr = PGM_READ_WORD(JUMP_TABLE_INDEX(4)); 177 | if (ptr == 0 || ptr == 0xffff) 178 | return BOOT_FUNCTION_INVALID; 179 | 180 | // disable interrupts 181 | cSREG = SREG; // store SREG value 182 | cli(); 183 | 184 | // call the function 185 | ((void (*)(void)) ptr)(); 186 | 187 | // enable interrupts (restore) 188 | SREG = cSREG; // restore SREG value (I-bit) 189 | 190 | return BOOT_OK; 191 | } 192 | 193 | return BOOT_VERSION_INVALID; 194 | } 195 | 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /avr8-stub/app_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * app_api.h 3 | * 4 | * Define the API for the user applications to call the bootloader. 5 | * This file is used in the user application code only! 6 | * User bootloader should include bootapi.h file only. 7 | 8 | * NOTE to implementors: 9 | * The app_api.h and bootapi.h files should be kept in sync (the jump table structure) 10 | * but it is not good to have a single file as the app version will have some extra functions 11 | * and the functions are actually different in app than in bootloader. 12 | * 13 | * Created on: 16. 3. 2017 14 | * Author: jan dolinay 15 | */ 16 | 17 | #ifndef APP_API_H_ 18 | #define APP_API_H_ 19 | 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | 26 | /* Error codes */ 27 | #define BOOT_OK (0) /* no error, success */ 28 | #define BOOT_ERROR (1) /* unspecified error */ 29 | #define BOOT_FUNCTION_INVALID (2) /* The function address in jump table was not valid */ 30 | #define BOOT_VERSION_INVALID (3) /* The version of the jump table in bootloader does not match the version of this code */ 31 | #define BOOT_ID_INVALID (4) /* The ID of the bootloader API does not match the ID expected by this code */ 32 | 33 | 34 | #define BOOT_API_VERSION (2) /* Version of the API expected by this code. */ 35 | /* See the "ver" field in jump table struct avrdbgboot_jump_table_s in app_api.c */ 36 | 37 | 38 | /* Helper functions */ 39 | /** 40 | * Must be called to initialize the API and verify that it is OK before 41 | * using any other function of this API. 42 | */ 43 | uint8_t dboot_init_api(void); 44 | 45 | 46 | /* Bootloader API functions - the functions in the bootloader */ 47 | 48 | /** 49 | * Read the verison of the API. 50 | * This is the value of the "ver" field in the jump table struct avrdbgboot_jump_table_s 51 | * @param ver (out) - the version of the API 52 | * @return BOOT_OK on success. 53 | * */ 54 | uint8_t dboot_get_api_version(uint8_t *ver); 55 | 56 | /** 57 | * Read the version of the bootloader from bootloader memory. 58 | * This is the version of the bootloader, not the version of the API. 59 | * The bootloader verison is (AVRDBG_BOOT_VERSION_MAJOR << 8) | (AVRDBG_BOOT_VERSION_MINOR) 60 | * as defined in bootapi.c 61 | * @param ver (out) - the version of the bootloader 62 | * @return BOOT_OK on success. 63 | * */ 64 | uint8_t dboot_get_version(uint16_t *ver); 65 | 66 | 67 | /** 68 | * Toggle the on-board LED 69 | * This is only available if AVR8_STUB_DEBUG is defined. If not defined, 70 | * it just returns BOOT_VERSION_INVALID. 71 | * @return BOOT_OK on success. 72 | */ 73 | uint8_t dboot_led_toggle(void); 74 | 75 | 76 | /** 77 | * Initialize the pin for on-board LED (PB5) 78 | * This is only available if AVR8_STUB_DEBUG is defined. If not defined, 79 | * it just returns BOOT_VERSION_INVALID. 80 | * @return BOOT_OK on success. 81 | */ 82 | uint8_t dboot_led_init(void); 83 | 84 | /** 85 | * Write to program memory from RAM buffer. 86 | * rom_addr - in words, 87 | * sz - in bytes and must be multiple of two. 88 | */ 89 | uint8_t dboot_safe_pgm_write(const void *ram_addr, uint16_t rom_addr, uint16_t sz); 90 | 91 | /** 92 | * Handle X load command from GDB that is load new application to memory 93 | */ 94 | uint8_t dboot_handle_xload(void); 95 | 96 | 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | 103 | #endif /* APP_API_H_ */ 104 | -------------------------------------------------------------------------------- /avr8-stub/avr_debugger.h: -------------------------------------------------------------------------------- 1 | #include "avr8-stub.h" 2 | #include 3 | 4 | #ifndef AVR_DEBUGGER_H_ 5 | #define AVR_DEBUGGER_H_ 6 | 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #if defined(PLATFORMIO) && defined(__PLATFORMIO_BUILD_DEBUG__) 13 | #ifndef __DEBUG__ 14 | #define __DEBUG__ 15 | #endif 16 | #endif 17 | 18 | #if defined(__DEBUG__) 19 | #define DBG_EXEC(x) x 20 | #else 21 | #define DBG_EXEC(x) 22 | #endif 23 | 24 | #define dbg_breakpoint() { \ 25 | DBG_EXEC(breakpoint()); \ 26 | } 27 | 28 | #define dbg_init() { \ 29 | DBG_EXEC(debug_init()); \ 30 | } 31 | 32 | #define dbg_message(x) { \ 33 | DBG_EXEC(debug_message(x)); \ 34 | } 35 | 36 | #define dbg_start() { \ 37 | DBG_EXEC(debug_init()); \ 38 | DBG_EXEC(sei()); \ 39 | DBG_EXEC(breakpoint()); \ 40 | } 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | 47 | #endif /* AVR_DEBUGGER_H_ */ -------------------------------------------------------------------------------- /bootloader/optiboot/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode 3 | /Debug/ 4 | -------------------------------------------------------------------------------- /bootloader/optiboot/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | optiboot 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | de.innot.avreclipse.core.avrnature 26 | 27 | 28 | -------------------------------------------------------------------------------- /bootloader/optiboot/.settings/de.innot.avreclipse.core.prefs: -------------------------------------------------------------------------------- 1 | avrtarget/ClockFrequency=16000000 2 | avrtarget/ExtRAMSize=0 3 | avrtarget/ExtendedRAM=false 4 | avrtarget/MCUType=atmega328p 5 | avrtarget/UseEEPROM=false 6 | avrtarget/UseExtendedRAMforHeap=true 7 | avrtarget/avrdude/BitBangDelay= 8 | avrtarget/avrdude/Bitclock= 9 | avrtarget/avrdude/EEPROMFile= 10 | avrtarget/avrdude/EEPROMFromConfig=true 11 | avrtarget/avrdude/FlashFile= 12 | avrtarget/avrdude/FlashFromConfig=true 13 | avrtarget/avrdude/NoChipErase=false 14 | avrtarget/avrdude/NoSigCheck=false 15 | avrtarget/avrdude/NoVerify=false 16 | avrtarget/avrdude/NoWrite=false 17 | avrtarget/avrdude/OtherOptions= 18 | avrtarget/avrdude/ProgrammerID=programmerconfig.2 19 | avrtarget/avrdude/UseCounter=false 20 | avrtarget/avrdude/WriteEEPROM=false 21 | avrtarget/avrdude/WriteFlash=true 22 | avrtarget/perConfig=false 23 | eclipse.preferences.version=1 24 | -------------------------------------------------------------------------------- /bootloader/optiboot/.travis.yml: -------------------------------------------------------------------------------- 1 | # Continuous Integration (CI) is the practice, in software 2 | # engineering, of merging all developer working copies with a shared mainline 3 | # several times a day < https://docs.platformio.org/page/ci/index.html > 4 | # 5 | # Documentation: 6 | # 7 | # * Travis CI Embedded Builds with PlatformIO 8 | # < https://docs.travis-ci.com/user/integration/platformio/ > 9 | # 10 | # * PlatformIO integration with Travis CI 11 | # < https://docs.platformio.org/page/ci/travis.html > 12 | # 13 | # * User Guide for `platformio ci` command 14 | # < https://docs.platformio.org/page/userguide/cmd_ci.html > 15 | # 16 | # 17 | # Please choose one of the following templates (proposed below) and uncomment 18 | # it (remove "# " before each line) or use own configuration according to the 19 | # Travis CI documentation (see above). 20 | # 21 | 22 | 23 | # 24 | # Template #1: General project. Test it using existing `platformio.ini`. 25 | # 26 | 27 | # language: python 28 | # python: 29 | # - "2.7" 30 | # 31 | # sudo: false 32 | # cache: 33 | # directories: 34 | # - "~/.platformio" 35 | # 36 | # install: 37 | # - pip install -U platformio 38 | # - platformio update 39 | # 40 | # script: 41 | # - platformio run 42 | 43 | 44 | # 45 | # Template #2: The project is intended to be used as a library with examples. 46 | # 47 | 48 | # language: python 49 | # python: 50 | # - "2.7" 51 | # 52 | # sudo: false 53 | # cache: 54 | # directories: 55 | # - "~/.platformio" 56 | # 57 | # env: 58 | # - PLATFORMIO_CI_SRC=path/to/test/file.c 59 | # - PLATFORMIO_CI_SRC=examples/file.ino 60 | # - PLATFORMIO_CI_SRC=path/to/test/directory 61 | # 62 | # install: 63 | # - pip install -U platformio 64 | # - platformio update 65 | # 66 | # script: 67 | # - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N 68 | -------------------------------------------------------------------------------- /bootloader/optiboot/Debug/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm -rf 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include src/subdir.mk 12 | -include subdir.mk 13 | -include objects.mk 14 | 15 | ifneq ($(MAKECMDGOALS),clean) 16 | ifneq ($(strip $(ASM_DEPS)),) 17 | -include $(ASM_DEPS) 18 | endif 19 | ifneq ($(strip $(S_DEPS)),) 20 | -include $(S_DEPS) 21 | endif 22 | ifneq ($(strip $(S_UPPER_DEPS)),) 23 | -include $(S_UPPER_DEPS) 24 | endif 25 | ifneq ($(strip $(C_DEPS)),) 26 | -include $(C_DEPS) 27 | endif 28 | endif 29 | 30 | -include ../makefile.defs 31 | 32 | # Add inputs and outputs from these tool invocations to the build variables 33 | LSS += \ 34 | optiboot.lss \ 35 | 36 | FLASH_IMAGE += \ 37 | optiboot.hex \ 38 | 39 | SIZEDUMMY += \ 40 | sizedummy \ 41 | 42 | 43 | # All Target 44 | all: optiboot.elf secondary-outputs 45 | 46 | # Tool invocations 47 | optiboot.elf: $(OBJS) $(USER_OBJS) 48 | @echo 'Building target: $@' 49 | @echo 'Invoking: AVR C Linker' 50 | avr-gcc -Wl,-Map,optiboot.map -Wl,--section-start=.text=0x7800 -Wl,--section-start=.opti_api=0x7fe8 -Wl,-section-start=.mystrings=0x7fc0 -Wl,--section-start=.version=0x7ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -Wl,--undefined=api_functions -Wl,--undefined=optiboot_version -mmcu=atmega328p -o "optiboot.elf" $(OBJS) $(USER_OBJS) $(LIBS) 51 | @echo 'Finished building target: $@' 52 | @echo ' ' 53 | 54 | optiboot.lss: optiboot.elf 55 | @echo 'Invoking: AVR Create Extended Listing' 56 | -avr-objdump -h -S optiboot.elf >"optiboot.lss" 57 | @echo 'Finished building: $@' 58 | @echo ' ' 59 | 60 | optiboot.hex: optiboot.elf 61 | @echo 'Create Flash image (ihex format)' 62 | -avr-objcopy -R .eeprom -R .fuse -R .lock -R .signature -O ihex optiboot.elf "optiboot.hex" 63 | @echo 'Finished building: $@' 64 | @echo ' ' 65 | 66 | sizedummy: optiboot.elf 67 | @echo 'Invoking: Print Size' 68 | -avr-size --format=avr --mcu=atmega328p optiboot.elf 69 | @echo 'Finished building: $@' 70 | @echo ' ' 71 | 72 | # Other Targets 73 | clean: 74 | -$(RM) $(FLASH_IMAGE)$(ELFS)$(OBJS)$(ASM_DEPS)$(S_DEPS)$(SIZEDUMMY)$(S_UPPER_DEPS)$(LSS)$(C_DEPS) optiboot.elf 75 | -@echo ' ' 76 | 77 | secondary-outputs: $(LSS) $(FLASH_IMAGE) $(SIZEDUMMY) 78 | 79 | .PHONY: all clean dependents 80 | 81 | -include ../makefile.targets 82 | -------------------------------------------------------------------------------- /bootloader/optiboot/Debug/optiboot.hex: -------------------------------------------------------------------------------- 1 | :10780000112484B714BE81FFC0D185E0809381002C 2 | :1078100082E08093C00088E18093C10096E090935D 3 | :10782000C20090E19093C400809360008EE080934A 4 | :107830006000259A86E020E33CEF91E030938500DC 5 | :107840002093840096BBB09BFECF1D9AA8958150D3 6 | :10785000A9F7612C712C08E138E0F32EEE24E394B3 7 | :1078600045E0D42E51E1C52E13E06AD1813489F46C 8 | :1078700067D1898371D18981823819F484E059D123 9 | :1078800098C0813819F484E054D193C083E051D179 10 | :1078900090C0823419F484E16BD18BC0853419F423 11 | :1078A00085E066D186C0853551F44AD1B82E48D1DD 12 | :1078B0006B2C712C782A660C771C4ED17AC08635D9 13 | :1078C00029F484E055D180E034D173C0843609F0C6 14 | :1078D00043C036D135D1982E33D1611480E7780674 15 | :1078E00038F4F30117BFE895A12CBB24B39403C06F 16 | :1078F000A12CBB24B39424D1F50181935F019E1286 17 | :10790000FACF6114F0E77F0618F0F30117BFE8958E 18 | :1079100023D107B600FCFDCFA301A0E0B1E08C911C 19 | :1079200012969D0121503109F901208190E0922B9E 20 | :10793000FA010C01E7BEE89511244E5F5F4FA038B5 21 | :10794000F1E0BF0761F7F301D7BEE89507B600FC89 22 | :10795000FDCFC7BEE8952DC08437C1F4F1D0F0D07B 23 | :10796000982EEED0F9D0F301862C890C5F018FEFB1 24 | :10797000A81AB80A8491DDD0F5018A10F7CFEFEF8D 25 | :107980006E1A7E0A9A94690C711C13C0853741F4F3 26 | :10799000E3D08EE1CED085E9CCD08FE0CAD009C04B 27 | :1079A000813531F400936000F0926000D5D001C0C1 28 | :1079B000D3D080E1BED059CF259A08951D9A08955D 29 | :1079C00021E031E0FC013183208380E008952F9293 30 | :1079D0003F924F925F926F927F928F929F92AF925F 31 | :1079E000BF92CF92DF92EF92FF920F931F93CF93AC 32 | :1079F000DF93CDB7DEB728970FB6F894DEBF0FBE82 33 | :107A0000CDBF4115510509F47BC040FD79C0F999FE 34 | :107A1000FECF56954795DB01A07C1B010FE3200E9E 35 | :107A2000311C240E351E9101207C3A8329836F730B 36 | :107A30007727A980BA80AA15BB0508F05DC02D0183 37 | :107A4000612C712C93018201000F111F221F331F23 38 | :107A50000D831E832F83388700E010E098016801B2 39 | :107A60007901C40CD51CE61CF71CCC0CDD1CEE1CEB 40 | :107A7000FF1C6017710791F4FC0180809180222423 41 | :107A80002394F601040120925700E89511244150F7 42 | :107A9000510979F06F5F7F4F02960BC0F601259078 43 | :107AA000349099249394F601010190925700E8953F 44 | :107AB00011240F5F1F4F2F4F3F4F00341105210539 45 | :107AC000310509F0CCCF33E0232EED81FE812092E9 46 | :107AD0005700E89507B600FCFDCF25E0222EED818A 47 | :107AE000FE8120925700E89507B600FCFDCFA05C10 48 | :107AF000BF4F60E070E09DCF81E180935700E89533 49 | :107B000028960FB6F894DEBF0FBECDBFDF91CF91A0 50 | :107B10001F910F91FF90EF90DF90CF90BF90AF90AB 51 | :107B20009F908F907F906F905F904F903F902F909D 52 | :107B300008959091C00095FFFCCF8093C6000895F2 53 | :107B40008091C00087FFFCCF8091C00084FD01C000 54 | :107B5000A8958091C6000895F3DF803239F088E15E 55 | :107B60008093600088E080936000FFCF84E1E1CFE4 56 | :107B7000CF93C82FE5DFC150E9F7CF91EDCFE0E615 57 | :107B8000F0E098E1908380830895E0E6F0E088E1FA 58 | :107B900080831082EE27FF2709949FEB980F963081 59 | :107BA00010F4875308959FE9980F963010F4875585 60 | :107BB000089580538A3008F08FEF08958091C000B7 61 | :107BC00087FFFCCF8091C60008959091C00095FF7B 62 | :107BD000FCCF8093C60008950F931F93CF93DF933C 63 | :107BE000D82F84E2F2DFC0E008E011E0D00FD01718 64 | :107BF00041F0F8018081E9DFF80181918F01C80F20 65 | :107C0000F6CF83E2E2DF8C2F82958F708A3010F0FE 66 | :107C1000895A01C0805DD9DFCF70CA3010F087E586 67 | :107C200001C080E38C0FDF91CF911F910F91CDCFD9 68 | :107C3000FC012E2F281B349131963111FACF2D39AA 69 | :107C400008F02CE92093480240914802642F70E02C 70 | :107C5000A8E0B1E020E030E02617370741F0FC0152 71 | :107C6000E20FF31FE491ED932F5F3F4FF5CF842F89 72 | :107C7000B3CF88E084DFFFCFA1DF843271F020F43E 73 | :107C8000833009F4BAC0BAC08B32B1F38D3209F037 74 | :107C9000B5C080914802A0DFEFCF109248028EDF7E 75 | :107CA000D0E0E0914802833259F091E09E0F90932A 76 | :107CB0004802F0E0E85FFE4F8083D80F7FDFF1CF0E 77 | :107CC000F0E0E85FFE4F108279DF67DFC82FC295D2 78 | :107CD000C07F74DF62DF8C2BD81719F08DE275DF5F 79 | :107CE000CBCF8BE272DF80910801883579F038F4D0 80 | :107CF000873409F47CC0803509F479C07BC08336B1 81 | :107D000009F475C0833709F472C074C0812C912CBA 82 | :107D10005401C0E0EC2FF0E08F01075F1E4FF80127 83 | :107D200080813BDF8F3F69F044E0880C991CAA1CDE 84 | :107D3000BB1C4A95D1F7880E911CA11CB11CCF5FCA 85 | :107D4000E9CFC12CD12C7601712CC72DD0E0F801E0 86 | :107D5000EC0FFD1F818121DF8F3F69F034E0CC0CF7 87 | :107D6000DD1CEE1CFF1C3A95D1F7C80ED11CE11C9E 88 | :107D7000F11C7394EACFD501C40188279927BB274A 89 | :107D8000892B8A2B8B2B81F52296F801EC0FFD1F96 90 | :107D9000A8EAB1E0AD01485A51404C155D05ACF47C 91 | :107DA00080818D3771F481818A3041F028F49DEF14 92 | :107DB000980F923030F402C08D3519F480628183BF 93 | :107DC000319680818D933196E5CFD501C401AA27E4 94 | :107DD000BC01CD01969587957795679588EA91E0E6 95 | :107DE000F6DD85E091E00CC081E091E009C085E01E 96 | :107DF00091E002C080E091E01BDF3BDF80E091E09A 97 | :047E000017DF3ACF7F 98 | :087E040000453035004F4B0032 99 | :0E7FE80041426A02E03CDC3CDE3CE73C3C3EB1 100 | :027FFE00040479 101 | :040000030000780081 102 | :00000001FF 103 | -------------------------------------------------------------------------------- /bootloader/optiboot/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | ; Fuse calculator 12 | ; https://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p&LOW=E2&HIGH=D2&EXTENDED=FD&LOCKBIT=3F 13 | 14 | [env] ;Default values 15 | board = 328p16m 16 | platform = atmelavr 17 | upload_protocol = usbasp 18 | board_fuses.lfuse = 0xFF 19 | board_fuses.hfuse = 0xD2 20 | board_fuses.efuse = 0xFD 21 | board_fuses.lock = 0x3F 22 | build_flags = 23 | ;-DBAUD_RATE=115200 24 | -DLED_START_FLASHES=3 25 | -mrelax 26 | -fpack-struct 27 | -fshort-enums 28 | -fno-split-wide-types 29 | -fno-inline-small-functions 30 | -Wl,--section-start=.text=0x7800 31 | -Wl,--section-start=.opti_api=0x7fe8 32 | -Wl,-section-start=.mystrings=0x7fc0 33 | -Wl,--section-start=.version=0x7ffe 34 | -Wl,--relax -Wl,--gc-sections 35 | -nostartfiles -nostdlib 36 | -Wl,--undefined=api_functions -Wl,--undefined=optiboot_version 37 | 38 | [env:loader] 39 | upload_protocol = usbasp-clone ;Programmer model 40 | board = nanoatmega328new 41 | board_fuses.lfuse = 0xFF ;External high frecuency clock 42 | 43 | ;board = 328p8m 44 | ;board_fuses.lfuse = 0xE2 ;For internal 8MHz clock 45 | 46 | -------------------------------------------------------------------------------- /bootloader/optiboot/readme_platformio.txt: -------------------------------------------------------------------------------- 1 | 2 | Instructions for building and burning the bootloader with PlatformIO. 3 | 4 | Provided by msquirogac, see https://github.com/msquirogac/avr-debugger-bootloader 5 | 6 | # avr-debugger bootloader 7 | How to use it? 8 | 9 | 10 | 1) Customize the `platformio.ini` file to match the programmer and board you have. For example, if you have an **usbasp** programmer and an **Arduino Nano**, then change it like this: 11 | 12 | ~~~ 13 | [env:loader] 14 | upload_protocol = usbasp 15 | board = nanoatmega328new 16 | ~~~ 17 | 18 | What you put into [board](https://docs.platformio.org/en/latest/boards/index.html) will always depend on the hardware you have, or if you have a personalized one you can also use the generic definition. For example [328p16m](https://docs.platformio.org/en/latest/boards/atmelavr/328p16m.html) means an `atmega328p` IC with a 16MHz clock. Besides that, you can and should also configure the `fuses`. 19 | 20 | So if you have a bare `atmega328p` in a breadboard without external crystal then you use `328p8m` and change the `board_fuses.lfuse` to `0xE2`. What those magic numbers means? 21 | Easy, just use a calculator like [this](https://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p&LOW=E2&HIGH=D2&EXTENDED=FD&LOCKBIT=3F) one. Also remember to configure de baudrate, the default value is 115200, nonetheless low MHz crystals or the internal one aren't suitable for that baudrate, heceforth it should be lowered to 57600 at least. 22 | 23 | 2) Connect your programmer to the board. 24 | 3) Finally, compile and program the bootloader with: 25 | ~~~ 26 | pio run -t fuses && pio run -t program 27 | ~~~ 28 | 29 | Note: You can run the above command from VS Code with PlatformIO - click the PlatformIO: New Terminal button in PIO toolbar to open terminal, then switch to the optoboot folder (...\avr_debug\bootloader\optiboot) and then run the command. 30 | 31 | Done!! Now your board has the **avr-debugger** bootloader installed and is able to use the **Flash breakpoint mode**. The major difference with the regular one comes when you use the avr-debugger library, which means that you don't need to revert to the regular one even if you don't need this library anymore. 32 | 33 | -------------------------------------------------------------------------------- /bootloader/optiboot/src/bootapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bootapi.h 3 | * 4 | * Define the API for the user applications to call the bootloader. 5 | * This file is used in the bootloader code only! 6 | * User app should include app_api.h file only. 7 | 8 | * NOTE to implementors: 9 | * The app_api.h and bootapi.h files should be kept in sync (the jump table structure) 10 | * but it is not good to have a single file as the app version will have some extra functions 11 | * and the functions are actually different in app than in bootloader. 12 | * 13 | * Created on: 16. 3. 2017 14 | * Author: jan dolinay 15 | */ 16 | 17 | #ifndef BOOTAPI_H_ 18 | #define BOOTAPI_H_ 19 | 20 | /* Prototypes of the bootloader API functions */ 21 | void dboot_led_toggle(void); 22 | void dboot_led_init(void); 23 | uint8_t dboot_get_version(uint16_t *ver); 24 | void dboot_safe_pgm_write(const void *ram_addr, uint16_t rom_addr, uint16_t sz); 25 | void dboot_handle_xload(void); 26 | 27 | 28 | /* jump table struct 29 | KEEP this in sync with app_api.h! */ 30 | struct avrdbgboot_jump_table_s { 31 | uint8_t id[3]; 32 | uint8_t ver; 33 | uint16_t ptr[]; 34 | }; 35 | 36 | 37 | /* Defines used internally but shared between optiboot.c and stub.c */ 38 | #if defined(__AVR_ATmega168__) 39 | #define RAMSTART (0x100) 40 | #define NRWWSTART (0x3800) 41 | #elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) 42 | #define MY_RAMSTART (0x100) 43 | #define NRWWSTART (0x7000) 44 | #elif defined (__AVR_ATmega644P__) 45 | #define RAMSTART (0x100) 46 | #define NRWWSTART (0xE000) 47 | #elif defined(__AVR_ATtiny84__) 48 | #define RAMSTART (0x100) 49 | #define NRWWSTART (0x0000) 50 | #elif defined(__AVR_ATmega1280__) 51 | #define RAMSTART (0x200) 52 | #define NRWWSTART (0xE000) 53 | #elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__) 54 | #define RAMSTART (0x100) 55 | #define NRWWSTART (0x1800) 56 | #endif 57 | 58 | 59 | 60 | 61 | #endif /* BOOTAPI_H_ */ 62 | -------------------------------------------------------------------------------- /bootloader/optiboot/src/pin_defs.h: -------------------------------------------------------------------------------- 1 | #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__) 2 | /* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */ 3 | #define LED_DDR DDRB 4 | #define LED_PORT PORTB 5 | #define LED_PIN PINB 6 | #define LED PINB5 7 | 8 | /* Ports for soft UART */ 9 | #ifdef SOFT_UART 10 | #define UART_PORT PORTD 11 | #define UART_PIN PIND 12 | #define UART_DDR DDRD 13 | #define UART_TX_BIT 1 14 | #define UART_RX_BIT 0 15 | #endif 16 | #endif 17 | 18 | #if defined(__AVR_ATmega8__) 19 | //Name conversion R.Wiersma 20 | #define UCSR0A UCSRA 21 | #define UDR0 UDR 22 | #define UDRE0 UDRE 23 | #define RXC0 RXC 24 | #define FE0 FE 25 | #define TIFR1 TIFR 26 | #define WDTCSR WDTCR 27 | #endif 28 | 29 | /* Luminet support */ 30 | #if defined(__AVR_ATtiny84__) 31 | /* Red LED is connected to pin PA4 */ 32 | #define LED_DDR DDRA 33 | #define LED_PORT PORTA 34 | #define LED_PIN PINA 35 | #define LED PINA4 36 | /* Ports for soft UART - left port only for now. TX/RX on PA2/PA3 */ 37 | #ifdef SOFT_UART 38 | #define UART_PORT PORTA 39 | #define UART_PIN PINA 40 | #define UART_DDR DDRA 41 | #define UART_TX_BIT 2 42 | #define UART_RX_BIT 3 43 | #endif 44 | #endif 45 | 46 | /* Sanguino support */ 47 | #if defined(__AVR_ATmega644P__) 48 | /* Onboard LED is connected to pin PB0 on Sanguino */ 49 | #define LED_DDR DDRB 50 | #define LED_PORT PORTB 51 | #define LED_PIN PINB 52 | #define LED PINB0 53 | 54 | /* Ports for soft UART */ 55 | #ifdef SOFT_UART 56 | #define UART_PORT PORTD 57 | #define UART_PIN PIND 58 | #define UART_DDR DDRD 59 | #define UART_TX_BIT 1 60 | #define UART_RX_BIT 0 61 | #endif 62 | #endif 63 | 64 | /* Mega support */ 65 | #if defined(__AVR_ATmega1280__) 66 | /* Onboard LED is connected to pin PB7 on Arduino Mega */ 67 | #define LED_DDR DDRB 68 | #define LED_PORT PORTB 69 | #define LED_PIN PINB 70 | #define LED PINB7 71 | 72 | /* Ports for soft UART */ 73 | #ifdef SOFT_UART 74 | #define UART_PORT PORTE 75 | #define UART_PIN PINE 76 | #define UART_DDR DDRE 77 | #define UART_TX_BIT 1 78 | #define UART_RX_BIT 0 79 | #endif 80 | #endif 81 | -------------------------------------------------------------------------------- /bootloader/optiboot/src/stk500.h: -------------------------------------------------------------------------------- 1 | /* STK500 constants list, from AVRDUDE */ 2 | #define STK_OK 0x10 3 | #define STK_FAILED 0x11 // Not used 4 | #define STK_UNKNOWN 0x12 // Not used 5 | #define STK_NODEVICE 0x13 // Not used 6 | #define STK_INSYNC 0x14 // ' ' 7 | #define STK_NOSYNC 0x15 // Not used 8 | #define ADC_CHANNEL_ERROR 0x16 // Not used 9 | #define ADC_MEASURE_OK 0x17 // Not used 10 | #define PWM_CHANNEL_ERROR 0x18 // Not used 11 | #define PWM_ADJUST_OK 0x19 // Not used 12 | #define CRC_EOP 0x20 // 'SPACE' 13 | #define STK_GET_SYNC 0x30 // '0' 14 | #define STK_GET_SIGN_ON 0x31 // '1' 15 | #define STK_SET_PARAMETER 0x40 // '@' 16 | #define STK_GET_PARAMETER 0x41 // 'A' 17 | #define STK_SET_DEVICE 0x42 // 'B' 18 | #define STK_SET_DEVICE_EXT 0x45 // 'E' 19 | #define STK_ENTER_PROGMODE 0x50 // 'P' 20 | #define STK_LEAVE_PROGMODE 0x51 // 'Q' 21 | #define STK_CHIP_ERASE 0x52 // 'R' 22 | #define STK_CHECK_AUTOINC 0x53 // 'S' 23 | #define STK_LOAD_ADDRESS 0x55 // 'U' 24 | #define STK_UNIVERSAL 0x56 // 'V' 25 | #define STK_PROG_FLASH 0x60 // '`' 26 | #define STK_PROG_DATA 0x61 // 'a' 27 | #define STK_PROG_FUSE 0x62 // 'b' 28 | #define STK_PROG_LOCK 0x63 // 'c' 29 | #define STK_PROG_PAGE 0x64 // 'd' 30 | #define STK_PROG_FUSE_EXT 0x65 // 'e' 31 | #define STK_READ_FLASH 0x70 // 'p' 32 | #define STK_READ_DATA 0x71 // 'q' 33 | #define STK_READ_FUSE 0x72 // 'r' 34 | #define STK_READ_LOCK 0x73 // 's' 35 | #define STK_READ_PAGE 0x74 // 't' 36 | #define STK_READ_SIGN 0x75 // 'u' 37 | #define STK_READ_OSCCAL 0x76 // 'v' 38 | #define STK_READ_FUSE_EXT 0x77 // 'w' 39 | #define STK_READ_OSCCAL_EXT 0x78 // 'x' 40 | -------------------------------------------------------------------------------- /bootloader/readme.txt: -------------------------------------------------------------------------------- 1 | Bootloader for source level debugger for Arduino avr_debug 2 | 3 | Works for Arduino Uno (ATmega328). 4 | 5 | Introduction 6 | ------------- 7 | This project is based on optiboot bootloader, which is used by default in Arduino. 8 | This is modified version of the bootloader which makes it possible for the debugger 9 | to write breakpoints to flash memory. 10 | 11 | 12 | Support for other boards than Uno 13 | --------------------------------- 14 | This modified optiboot bootloder works with Arduino Uno and possibly other boards based on Atmega328 MCU. 15 | 16 | As on June 2020 there is an option to use standard Optiboot bootloader verson 8.0 or above instead of this 17 | modified bootloader. It is because the new version of Optiboot supports writing to flash memory (do_spm function). 18 | 19 | So for Atmega328 boards you can decide whether to use the modified bootloader provided here or the standard Optiboot. 20 | For other boards, like Arduino Mega there is only the original Optiboot option. 21 | For more information please see the manual in /doc/ folder. 22 | 23 | 24 | Usage 25 | ------- 26 | To use this bootloader, flash your Arduino with optiboot.hex from optiboot/debug. 27 | 28 | Fuse settings 29 | -------------- 30 | IMPORTANT: The size of the bootloader is different than the original optiboot for Arduino. 31 | You need to program different bootloader size for this bootloader. 32 | Set BOOTSZ to 1024 w (bootloader address 3c00) 33 | You don't need to change any other fuses in Arduino. 34 | 35 | For those interested, here is complete fuse info: 36 | Raw fuses value: 37 | EXTENDED: 0xFD 38 | HIGH: 0xD2 39 | LOW: 0xFF 40 | 41 | Fuse settings for humans: 42 | Enable SPIEN 43 | Enable BOOTRST 44 | Enable EESAVE 45 | Set BOOTSZ to 1024 words (bootloader start address 0x3c00) 46 | Set clock to EXT OSC 8 or 16 MHz 47 | 48 | Lock bits 49 | ---------- 50 | For the debugging to work the application code must be able to read the bootloader memory. 51 | This is enabled by default if you erase the chip. 52 | If you encounter problems with debugging your app after updating the bootloader, make sure the 53 | lock bits do not prohibit reading Boot section (LPM instruction in Boot section must not be disabled). 54 | The correct lock bit value is 0xFF or 0xEF in the programmer GUI in Atmel Studio. 55 | 56 | 57 | 58 | Building the bootloader 59 | ------------------------- 60 | If you want to make changes to the sources and build your own bootloader, 61 | you can use Eclipse IDE with AVR Eclipse plugin (eclipse project provided). 62 | You can also build the project with PlatformIO - see the readme_platformio.txt in the optiboot subfolder. 63 | 64 | Files needed to build this bootloader: 65 | optiboot.c 66 | bootapi.c 67 | stub.c 68 | and the headers included by these files. 69 | 70 | If you build the project in different IDE or from command line, you need to 71 | 1) make sure the main starts at adress 0x7800 - this is where the CPU jumps after reset 72 | and it must execute the bootloader. 73 | 74 | 2) add to linker options the sections 75 | .version=0x7ffe 76 | .opti_api=0x7ff0 77 | .mystrings=0x7fc0 78 | 79 | 3) and also 80 | -Wl,--undefined=api_functions -Wl,--undefined=optiboot_version 81 | The undefined switch prevent linker from optimizing out the sections .opti_api and .version 82 | which contain variables never referenced in the code. 83 | For details see optiboot.c. 84 | 85 | 86 | 87 | Revision History 88 | -------------- 89 | 90 | May 2020 91 | + Added support for building the bootloader with PlatformIO, thanks to msquirogac, https://github.com/msquirogac/avr-debugger-bootloader. 92 | The sources were moved to src subfolder to support PlatformIO project structure. Eclipse project modified to refer to the files in new location. 93 | 94 | Sept. 2019 95 | + Changed number of LED blinks to 3 (LED_START_FLASHES=3). Was 2 but on some computers the upload from Arduino IDE failed. 96 | The standard Arduino implementation uses LED_START_FLASHES=3. 97 | 98 | July 2018 99 | + Fixed bug - there were const data at the start address instead of main. Loading via avrdude didn't work. 100 | 101 | June 2017 102 | + First version finished. Supports flash breakpoints and binary load from GDB. 103 | 104 | March 2017 105 | + started 106 | 107 | 108 | -------------------------------------------------------------------------------- /doc/avr_debug.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/avr_debug.doc -------------------------------------------------------------------------------- /doc/avr_debug.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/avr_debug.pdf -------------------------------------------------------------------------------- /doc/img/arduino_delay_stopped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/arduino_delay_stopped.png -------------------------------------------------------------------------------- /doc/img/arduino_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/arduino_folder.png -------------------------------------------------------------------------------- /doc/img/arduinopath_var.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/arduinopath_var.png -------------------------------------------------------------------------------- /doc/img/avr8_stub_path_var.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/avr8_stub_path_var.png -------------------------------------------------------------------------------- /doc/img/avr_dude_path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/avr_dude_path.png -------------------------------------------------------------------------------- /doc/img/avr_path_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/avr_path_edit.png -------------------------------------------------------------------------------- /doc/img/avr_paths.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/avr_paths.png -------------------------------------------------------------------------------- /doc/img/avr_plugin_paths_atstudio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/avr_plugin_paths_atstudio.png -------------------------------------------------------------------------------- /doc/img/avr_plugin_paths_browse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/avr_plugin_paths_browse.png -------------------------------------------------------------------------------- /doc/img/avr_plugin_paths_mingw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/avr_plugin_paths_mingw.png -------------------------------------------------------------------------------- /doc/img/avr_upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/avr_upload.png -------------------------------------------------------------------------------- /doc/img/bootloader_fuses.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/bootloader_fuses.png -------------------------------------------------------------------------------- /doc/img/debug_arduino_blink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_arduino_blink.png -------------------------------------------------------------------------------- /doc/img/debug_breakpoint_call.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_breakpoint_call.png -------------------------------------------------------------------------------- /doc/img/debug_config_com.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_config_com.png -------------------------------------------------------------------------------- /doc/img/debug_config_com_debugger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_config_com_debugger.png -------------------------------------------------------------------------------- /doc/img/debug_config_debugger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_config_debugger.png -------------------------------------------------------------------------------- /doc/img/debug_config_load.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_config_load.png -------------------------------------------------------------------------------- /doc/img/debug_config_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_config_new.png -------------------------------------------------------------------------------- /doc/img/debug_config_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_config_select.png -------------------------------------------------------------------------------- /doc/img/debug_config_startup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_config_startup.png -------------------------------------------------------------------------------- /doc/img/debug_expressions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_expressions.png -------------------------------------------------------------------------------- /doc/img/debug_format.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_format.png -------------------------------------------------------------------------------- /doc/img/debug_resume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_resume.png -------------------------------------------------------------------------------- /doc/img/debug_start_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_start_button.png -------------------------------------------------------------------------------- /doc/img/debug_step_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_step_over.png -------------------------------------------------------------------------------- /doc/img/debug_stopped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_stopped.png -------------------------------------------------------------------------------- /doc/img/debug_stopped2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_stopped2.png -------------------------------------------------------------------------------- /doc/img/debug_write_cnt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/debug_write_cnt.png -------------------------------------------------------------------------------- /doc/img/drag_drop_files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/drag_drop_files.png -------------------------------------------------------------------------------- /doc/img/exclude_from_build.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/exclude_from_build.png -------------------------------------------------------------------------------- /doc/img/gdb_hwdebug_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/gdb_hwdebug_install.png -------------------------------------------------------------------------------- /doc/img/hex_generate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/hex_generate.png -------------------------------------------------------------------------------- /doc/img/import_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/import_1.png -------------------------------------------------------------------------------- /doc/img/import_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/import_2.png -------------------------------------------------------------------------------- /doc/img/mingw_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/mingw_install.png -------------------------------------------------------------------------------- /doc/img/mingw_step3a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/mingw_step3a.png -------------------------------------------------------------------------------- /doc/img/mingw_step5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/mingw_step5.png -------------------------------------------------------------------------------- /doc/img/mingw_step6a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/mingw_step6a.png -------------------------------------------------------------------------------- /doc/img/new_folder_arduino.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/new_folder_arduino.png -------------------------------------------------------------------------------- /doc/img/platformio_debug1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/platformio_debug1.png -------------------------------------------------------------------------------- /doc/img/platformio_debug2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/platformio_debug2.png -------------------------------------------------------------------------------- /doc/img/platformio_debug3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/platformio_debug3.png -------------------------------------------------------------------------------- /doc/img/platformio_ini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/platformio_ini.png -------------------------------------------------------------------------------- /doc/img/platformio_libinstall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/platformio_libinstall.png -------------------------------------------------------------------------------- /doc/img/preferences_paths.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/preferences_paths.png -------------------------------------------------------------------------------- /doc/img/programmer_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/programmer_select.png -------------------------------------------------------------------------------- /doc/img/programming_fuses.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/programming_fuses.png -------------------------------------------------------------------------------- /doc/img/programming_uno_fuses.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/programming_uno_fuses.png -------------------------------------------------------------------------------- /doc/img/project_file_wnd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/project_file_wnd.png -------------------------------------------------------------------------------- /doc/img/project_new_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/project_new_file.png -------------------------------------------------------------------------------- /doc/img/tcp2com_wnd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/tcp2com_wnd.png -------------------------------------------------------------------------------- /doc/img/vscode_blink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/vscode_blink.png -------------------------------------------------------------------------------- /doc/img/vscode_debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/vscode_debug.png -------------------------------------------------------------------------------- /doc/img/vscode_launch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/vscode_launch.png -------------------------------------------------------------------------------- /doc/img/vscode_launchjson.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/vscode_launchjson.png -------------------------------------------------------------------------------- /doc/img/vscode_libs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/vscode_libs.png -------------------------------------------------------------------------------- /doc/img/vscode_setvar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/vscode_setvar.png -------------------------------------------------------------------------------- /doc/img/vscode_start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/vscode_start.png -------------------------------------------------------------------------------- /doc/img/vscode_start2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/vscode_start2.png -------------------------------------------------------------------------------- /doc/img/vscode_vars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/doc/img/vscode_vars.png -------------------------------------------------------------------------------- /examples/experimental/boot_api_app/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | -------------------------------------------------------------------------------- /examples/experimental/boot_api_app/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | boot_api_app 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | de.innot.avreclipse.core.avrnature 26 | 27 | 28 | 29 | app_api.c 30 | 1 31 | PARENT-3-PROJECT_LOC/avr8-stub/app_api.c 32 | 33 | 34 | app_api.h 35 | 1 36 | PARENT-3-PROJECT_LOC/avr8-stub/app_api.h 37 | 38 | 39 | avr8-stub.c 40 | 1 41 | PARENT-3-PROJECT_LOC/avr8-stub/avr8-stub.c 42 | 43 | 44 | avr8-stub.h 45 | 1 46 | PARENT-3-PROJECT_LOC/avr8-stub/avr8-stub.h 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/experimental/boot_api_app/.settings/de.innot.avreclipse.core.prefs: -------------------------------------------------------------------------------- 1 | avrtarget/ClockFrequency=16000000 2 | avrtarget/ExtRAMSize=0 3 | avrtarget/ExtendedRAM=false 4 | avrtarget/MCUType=atmega328p 5 | avrtarget/UseEEPROM=false 6 | avrtarget/UseExtendedRAMforHeap=true 7 | avrtarget/avrdude/BitBangDelay= 8 | avrtarget/avrdude/Bitclock= 9 | avrtarget/avrdude/EEPROMFile= 10 | avrtarget/avrdude/EEPROMFromConfig=true 11 | avrtarget/avrdude/FlashFile= 12 | avrtarget/avrdude/FlashFromConfig=true 13 | avrtarget/avrdude/NoChipErase=false 14 | avrtarget/avrdude/NoSigCheck=false 15 | avrtarget/avrdude/NoVerify=false 16 | avrtarget/avrdude/NoWrite=false 17 | avrtarget/avrdude/OtherOptions= 18 | avrtarget/avrdude/ProgrammerID=programmerconfig.2 19 | avrtarget/avrdude/UseCounter=false 20 | avrtarget/avrdude/WriteEEPROM=false 21 | avrtarget/avrdude/WriteFlash=true 22 | avrtarget/perConfig=false 23 | eclipse.preferences.version=1 24 | -------------------------------------------------------------------------------- /examples/experimental/boot_api_app/Debug/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm -rf 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include subdir.mk 12 | -include objects.mk 13 | 14 | ifneq ($(MAKECMDGOALS),clean) 15 | ifneq ($(strip $(ASM_DEPS)),) 16 | -include $(ASM_DEPS) 17 | endif 18 | ifneq ($(strip $(S_DEPS)),) 19 | -include $(S_DEPS) 20 | endif 21 | ifneq ($(strip $(S_UPPER_DEPS)),) 22 | -include $(S_UPPER_DEPS) 23 | endif 24 | ifneq ($(strip $(C_DEPS)),) 25 | -include $(C_DEPS) 26 | endif 27 | endif 28 | 29 | -include ../makefile.defs 30 | 31 | # Add inputs and outputs from these tool invocations to the build variables 32 | LSS += \ 33 | boot_api_app.lss \ 34 | 35 | FLASH_IMAGE += \ 36 | boot_api_app.hex \ 37 | 38 | SIZEDUMMY += \ 39 | sizedummy \ 40 | 41 | 42 | # All Target 43 | all: boot_api_app.elf secondary-outputs 44 | 45 | # Tool invocations 46 | boot_api_app.elf: $(OBJS) $(USER_OBJS) 47 | @echo 'Building target: $@' 48 | @echo 'Invoking: AVR C Linker' 49 | avr-gcc -Wl,-Map,boot_api_app.map -mmcu=atmega328p -o "boot_api_app.elf" $(OBJS) $(USER_OBJS) $(LIBS) 50 | @echo 'Finished building target: $@' 51 | @echo ' ' 52 | 53 | boot_api_app.lss: boot_api_app.elf 54 | @echo 'Invoking: AVR Create Extended Listing' 55 | -avr-objdump -h -S boot_api_app.elf >"boot_api_app.lss" 56 | @echo 'Finished building: $@' 57 | @echo ' ' 58 | 59 | boot_api_app.hex: boot_api_app.elf 60 | @echo 'Create Flash image (ihex format)' 61 | -avr-objcopy -R .eeprom -R .fuse -R .lock -R .signature -O ihex boot_api_app.elf "boot_api_app.hex" 62 | @echo 'Finished building: $@' 63 | @echo ' ' 64 | 65 | sizedummy: boot_api_app.elf 66 | @echo 'Invoking: Print Size' 67 | -avr-size --format=avr --mcu=atmega328p boot_api_app.elf 68 | @echo 'Finished building: $@' 69 | @echo ' ' 70 | 71 | # Other Targets 72 | clean: 73 | -$(RM) $(FLASH_IMAGE)$(ELFS)$(OBJS)$(ASM_DEPS)$(S_DEPS)$(SIZEDUMMY)$(S_UPPER_DEPS)$(LSS)$(C_DEPS) boot_api_app.elf 74 | -@echo ' ' 75 | 76 | secondary-outputs: $(LSS) $(FLASH_IMAGE) $(SIZEDUMMY) 77 | 78 | .PHONY: all clean dependents 79 | .SECONDARY: 80 | 81 | -include ../makefile.targets 82 | -------------------------------------------------------------------------------- /examples/experimental/boot_api_app/boot_api_app Debug TCP.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/experimental/boot_api_app/boot_api_app Debug.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/experimental/boot_api_app/boot_api_app Debug_no_load.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/experimental/boot_api_app/debug_com.bat: -------------------------------------------------------------------------------- 1 | "C:\Programs\avr8-gnu-toolchain\bin\avr-gdb.exe" -x script_com .\debug\boot_api_app.elf 2 | -------------------------------------------------------------------------------- /examples/experimental/boot_api_app/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main.c 3 | * 4 | * Experimental program for testing bootloader API in avr_debug debugger. 5 | * Plain C language, without Arduino libraries. 6 | * Author: Jan Dolinay 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | //#include 13 | #include "../../../avr8-stub/avr8-stub.h" /* relative path for GDB stub valid only if this file is in the examples subfolder */ 14 | #include "../../../avr8-stub/app_api.h" /* only needed for testing bootloader api */ 15 | 16 | 17 | 18 | // LED is on pin PB7 on Arduino Mega, PD5 on Arduino Uno (Arduino pin 13) 19 | #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 20 | #error This MCU is not supported. 21 | #define LED_PIN (7) 22 | #else 23 | #define LED_PIN (5) 24 | #endif 25 | 26 | /* Define this to test watchdog interupt 27 | * but must exclude the code for AVR8 stub */ 28 | //#define TEST_WATCHDOG 29 | 30 | uint16_t cnt = 0; 31 | uint16_t result; 32 | uint16_t function(uint16_t a); 33 | void mydelay(void); 34 | void mylongdelay(void); 35 | static void init_timer(void); 36 | 37 | #ifdef TEST_WATCHDOG 38 | /* Watchdog settings */ 39 | #define WATCHDOG_OFF (0) /* this off means no reset but interrupt is on*/ 40 | #define WATCHDOG_16MS ((_BV(WDIE)) & (~_BV(WDE))) 41 | #define WATCHDOG_32MS ((_BV(WDP0) | _BV(WDIE)) & (~_BV(WDE))) 42 | #define WATCHDOG_64MS ((_BV(WDP1) | _BV(WDIE)) & (~_BV(WDE))) 43 | #define WATCHDOG_125MS ((_BV(WDP1) | _BV(WDP0) | _BV(WDIE)) & (~_BV(WDE))) 44 | #define WATCHDOG_250MS ((_BV(WDP2) | _BV(WDE)) & (~_BV(WDE))) 45 | #define WATCHDOG_500MS ((_BV(WDP2) | _BV(WDP0) | _BV(WDIE)) & (~_BV(WDE))) 46 | #define WATCHDOG_1S ((_BV(WDP2) | _BV(WDP1) | _BV(WDIE)) & (~_BV(WDE))) 47 | #define WATCHDOG_2S ((_BV(WDP2) | _BV(WDP1) | _BV(WDP0) | _BV(WDIE)) & (~_BV(WDE))) 48 | #define WATCHDOG_4S ((_BV(WDP3) | _BV(WDIE)) & (~_BV(WDE))) 49 | #define WATCHDOG_8S ((_BV(WDP3) | _BV(WDP0) | _BV(WDIE)) & (~_BV(WDE)))) 50 | 51 | 52 | void watchdogReset() { 53 | __asm__ __volatile__ ( 54 | "wdr\n" 55 | ); 56 | } 57 | 58 | /* must be optimized or in asm to do in 4 cycles*/ 59 | __attribute__((optimize("-Os"))) 60 | void watchdogConfig(uint8_t x) { 61 | uint8_t cSREG; 62 | cSREG = SREG; /* store SREG value */ 63 | /* disable interrupts during timed sequence */ 64 | cli(); 65 | /* Enable watchdog in interrupt mode */ 66 | /* must write WDE = 1 first together with WDCE to enable changes */ 67 | WDTCSR = _BV(WDCE) | _BV(WDE); 68 | /* now write desired value of prescaler and WDE with WDCE cleared within 4 cycles */ 69 | WDTCSR = x; 70 | SREG = cSREG; /* restore SREG value (I-bit) */ 71 | } 72 | 73 | #endif /* TEST_WATCHDOG */ 74 | 75 | int main(void) 76 | { 77 | // test bootloader api 78 | // Write to flash - the address is in words, so if you call 79 | // dboot_safe_prg_write with 0x1000, you will find the result in binary 80 | // editor at address 0x2000. 81 | /* 82 | const uint16_t address = 0x3800; // word addr: 0x3800 > byte addr. 0x7000 83 | uint8_t data[] = {0xBE, 0xEF, 0x00, 0x00, 0xBE, 0xEF, }; 84 | dboot_safe_pgm_write(data, address, 6 ); 85 | dboot_led_init(); 86 | while(1) { 87 | dboot_led_toggle(); 88 | mydelay(); 89 | mydelay(); 90 | mydelay(); 91 | } 92 | */ 93 | 94 | #ifdef TEST_WATCHDOG 95 | // test watchdog 96 | DDRB |= _BV(LED_PIN); // pin mode to output for driving the LED 97 | /* First blink with the LED to see that the program is starting */ 98 | PORTB |= _BV(LED_PIN); // LED on 99 | mylongdelay(); 100 | PORTB &= ~_BV(LED_PIN); // LED off 101 | mylongdelay(); 102 | sei(); // enable interrupts 103 | watchdogConfig(WATCHDOG_500MS); 104 | while(1) 105 | ; 106 | #endif 107 | 108 | // Test program for flash breakpoints 109 | debug_init(); 110 | 111 | DDRB |= _BV(LED_PIN); // pin mode to output for driving the LED 112 | init_timer(); 113 | sei(); // enable interrupts 114 | //breakpoint(); 115 | while(1) 116 | { 117 | //PORTB |= _BV(LED_PIN); // LED on 118 | //asm("sbi 0x05, 5"); 119 | 120 | mydelay(); 121 | 122 | cnt++; 123 | cnt = function(cnt); 124 | //PORTB &= ~_BV(LED_PIN); // LED off 125 | //asm("cbi 0x05, 5"); 126 | 127 | cnt++; 128 | mydelay(); 129 | //breakpoint(); 130 | } 131 | return 0; 132 | } 133 | 134 | uint16_t function(uint16_t a) 135 | { 136 | uint16_t n; 137 | n = 2*a; 138 | return n; 139 | } 140 | 141 | void mydelay(void) 142 | { 143 | unsigned long i = 1000; 144 | while ( i > 0 ) 145 | i--; 146 | } 147 | 148 | void mylongdelay(void) { 149 | uint8_t cnt = 100; 150 | while ( cnt-- ) 151 | mydelay(); 152 | } 153 | 154 | 155 | static void init_timer(void) 156 | { 157 | /* How many times per second an interrupt is generated. 158 | At 16 MHz clock with prescaler 1 the minimum is about 250 - result F_CPU/TIMER_RATE must 159 | fit into 16-bit compare register. 160 | With prescaler 1024 the timer rate will not be "per second" but per 1024 seconds! 161 | So TIMER_RATE 1024 is about 1x per second, 10240 is about 10 times per sec. */ 162 | #define TIMER_RATE 1024 163 | 164 | #if defined(__AVR_ATmega328P__) 165 | TCCR1A = 0; 166 | /* Set CTC mode */ 167 | TCCR1B = 0; 168 | TCCR1B |= (1 << WGM12); 169 | /* Prescaler = 1*/ 170 | /*TCCR1B |= (1 << CS10);*/ 171 | /* Prescaler = 1024*/ 172 | TCCR1B |= (1 << CS10) | (1 << CS12); 173 | 174 | TCCR1C = 0; 175 | /* Set the compare register */ 176 | OCR1A = F_CPU / TIMER_RATE - 1; 177 | /* Enable Output Compare Match Interrupt */ 178 | TIMSK1 = 0; 179 | TIMSK1 |= (1 << OCIE1A); 180 | #else 181 | /* possible support for atmega2560 */ 182 | #error Unsupported AVR device 183 | 184 | #endif /* AVR variant */ 185 | } 186 | 187 | 188 | /* Interrupt handler for timer - for flash breakpoints */ 189 | ISR(TIMER1_COMPA_vect, ISR_NOBLOCK ) 190 | { 191 | // toggle the LED 192 | PORTB ^= _BV(LED_PIN); 193 | result += 5; 194 | if ( result == 10 ) 195 | result = 0; 196 | } 197 | 198 | #ifdef TEST_WATCHDOG 199 | /* Watchdog interrupt vector */ 200 | ISR(WDT_vect) 201 | { 202 | PORTB ^= _BV(LED_PIN); // toggle LED 203 | /* Re-enable watchdog interrupt */ 204 | watchdogConfig(WATCHDOG_500MS); 205 | } 206 | #endif /* TEST_WATCHDOG */ 207 | -------------------------------------------------------------------------------- /examples/experimental/boot_api_app/script_com: -------------------------------------------------------------------------------- 1 | 2 | set debug remote 1 3 | set remotelogfile gdb_logfile.txt 4 | target remote //./COM10 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/experimental/c/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | -------------------------------------------------------------------------------- /examples/experimental/c/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | c 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | de.innot.avreclipse.core.avrnature 26 | 27 | 28 | 29 | avr8-stub.c 30 | 1 31 | PARENT-3-PROJECT_LOC/avr8-stub/avr8-stub.c 32 | 33 | 34 | avr8-stub.h 35 | 1 36 | PARENT-3-PROJECT_LOC/avr8-stub/avr8-stub.h 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /examples/experimental/c/.settings/de.innot.avreclipse.core.prefs: -------------------------------------------------------------------------------- 1 | avrtarget/ClockFrequency=16000000 2 | avrtarget/ExtRAMSize=0 3 | avrtarget/ExtendedRAM=false 4 | avrtarget/MCUType=atmega328p 5 | avrtarget/UseEEPROM=false 6 | avrtarget/UseExtendedRAMforHeap=true 7 | avrtarget/avrdude/BitBangDelay= 8 | avrtarget/avrdude/Bitclock= 9 | avrtarget/avrdude/EEPROMFile= 10 | avrtarget/avrdude/EEPROMFromConfig=true 11 | avrtarget/avrdude/FlashFile= 12 | avrtarget/avrdude/FlashFromConfig=true 13 | avrtarget/avrdude/NoChipErase=false 14 | avrtarget/avrdude/NoSigCheck=false 15 | avrtarget/avrdude/NoVerify=false 16 | avrtarget/avrdude/NoWrite=false 17 | avrtarget/avrdude/OtherOptions= 18 | avrtarget/avrdude/ProgrammerID=programmerconfig.1 19 | avrtarget/avrdude/UseCounter=false 20 | avrtarget/avrdude/WriteEEPROM=false 21 | avrtarget/avrdude/WriteFlash=true 22 | avrtarget/perConfig=false 23 | eclipse.preferences.version=1 24 | -------------------------------------------------------------------------------- /examples/experimental/c/c Debug COM mega2560.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/experimental/c/c Debug COM.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/experimental/c/c Debug Linux Mega2560.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/experimental/c/c Debug Linux UNO.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/experimental/c/c Debug Linux.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/experimental/c/core: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/examples/experimental/c/core -------------------------------------------------------------------------------- /examples/experimental/c/debug_com.bat: -------------------------------------------------------------------------------- 1 | "C:\Programs\arduino-1.6.8\hardware\tools\avr\bin\avr-gdb.exe" -x script_com .\debug\c.elf 2 | -------------------------------------------------------------------------------- /examples/experimental/c/debug_tcp1.bat: -------------------------------------------------------------------------------- 1 | "C:\Programs\arduino-1.6.8\hardware\tools\avr\bin\avr-gdb.exe" -x script_tcp .\debug\c.elf 2 | -------------------------------------------------------------------------------- /examples/experimental/c/debug_tcp2.bat: -------------------------------------------------------------------------------- 1 | "c:\Programs\arduino-1.8.1\hardware\tools\avr\bin\avr-gdb.exe" -x script_tcp .\debug\c.elf 2 | -------------------------------------------------------------------------------- /examples/experimental/c/gdb_logfile.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/examples/experimental/c/gdb_logfile.txt -------------------------------------------------------------------------------- /examples/experimental/c/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main.c 3 | * 4 | * Experimental example for debugging with avr8-stub.c in plain C language, 5 | * without Arduino libraries. 6 | * For instructions on use please see doc\avr_debug.pdf 7 | * 8 | * This project can be used for various experiments, e.g. running in linux/Windows, 9 | * filling-up program memory... 10 | * It can be easily changed for Atmega328/1280/2560: 11 | * - In project properties > AVR change target hardware (e.g. ATmega2560) 12 | * and programmer (avrdude programmer configuration). 13 | * - To debug use/create debug configuration as needed (direct serial/tcp/linux dev/windows COM,...). 14 | * 15 | * Author: Jan Dolinay 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "../../../avr8-stub/avr8-stub.h" /* relative path for GDB stub valid only if this file is in the examples subfolder */ 22 | 23 | /* See the fillmem.h file for option to fill up the program memory to test 24 | * the debugger with larger programs. */ 25 | #include "fillmem.h" 26 | 27 | // LED is on pin PB7 on Arduino Mega, PD5 on Arduino Uno (Arduino pin 13) 28 | #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 29 | #define LED_PIN (7) 30 | #else 31 | #define LED_PIN (5) 32 | #endif 33 | 34 | uint16_t cnt = 0; 35 | uint16_t result; 36 | uint16_t function(uint16_t a); 37 | void mydelay(void); 38 | 39 | 40 | int main(void) 41 | { 42 | debug_init(); 43 | DDRB |= _BV(LED_PIN); // pin mode to output for driving the LED 44 | sei(); // enable interrupts 45 | // breakpoint(); 46 | while(1) 47 | { 48 | PORTB |= _BV(LED_PIN); // LED on 49 | 50 | mydelay(); 51 | 52 | cnt++; 53 | cnt = function(cnt); 54 | PORTB &= ~_BV(LED_PIN); // LED off 55 | cnt++; 56 | 57 | mydelay(); 58 | } 59 | return 0; 60 | } 61 | 62 | uint16_t function(uint16_t a) 63 | { 64 | uint16_t n; 65 | n = 2*a; 66 | return n; 67 | } 68 | 69 | void mydelay(void) 70 | { 71 | unsigned long cnt = 50000; 72 | while ( cnt > 0 ) 73 | cnt--; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /examples/experimental/c/script_com: -------------------------------------------------------------------------------- 1 | 2 | set debug remote 1 3 | set remotelogfile gdb_logfile.txt 4 | target remote //./COM5 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/experimental/c/script_tcp: -------------------------------------------------------------------------------- 1 | 2 | set debug remote 1 3 | set remotelogfile gdb_logfile.txt 4 | target remote localhost:11000 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/experimental/c/start_proxy.bat: -------------------------------------------------------------------------------- 1 | ..\..\..\hub4com-2.1.0.0-386\com2tcp --baud 115200 \\.\COM5 11000 -------------------------------------------------------------------------------- /examples/experimental/readme.txt: -------------------------------------------------------------------------------- 1 | This is experimental code. 2 | c - example program for testing the debugger including filling the memory and running avr-gdb from command line. 3 | boot_api_app - Experimental program for testing bootloader API in avr_debug debugger -------------------------------------------------------------------------------- /examples/mega2560/blink_mega/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | -------------------------------------------------------------------------------- /examples/mega2560/blink_mega/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | blink_mega 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | de.innot.avreclipse.core.avrnature 27 | 28 | 29 | 30 | arduino 31 | 2 32 | ArduinoPath/hardware/arduino/avr/cores/arduino 33 | 34 | 35 | avr8-stub.c 36 | 1 37 | AVR8_STUB_PATH/avr8-stub.c 38 | 39 | 40 | avr8-stub.h 41 | 1 42 | AVR8_STUB_PATH/avr8-stub.h 43 | 44 | 45 | mega 46 | 2 47 | ArduinoPath/hardware/arduino/avr/variants/mega 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /examples/mega2560/blink_mega/.settings/de.innot.avreclipse.core.prefs: -------------------------------------------------------------------------------- 1 | avrtarget/ClockFrequency=16000000 2 | avrtarget/ExtRAMSize=0 3 | avrtarget/ExtendedRAM=false 4 | avrtarget/MCUType=atmega2560 5 | avrtarget/UseEEPROM=false 6 | avrtarget/UseExtendedRAMforHeap=true 7 | avrtarget/avrdude/BitBangDelay= 8 | avrtarget/avrdude/Bitclock= 9 | avrtarget/avrdude/EEPROMFile= 10 | avrtarget/avrdude/EEPROMFromConfig=true 11 | avrtarget/avrdude/FlashFile= 12 | avrtarget/avrdude/FlashFromConfig=true 13 | avrtarget/avrdude/NoChipErase=false 14 | avrtarget/avrdude/NoSigCheck=false 15 | avrtarget/avrdude/NoVerify=false 16 | avrtarget/avrdude/NoWrite=false 17 | avrtarget/avrdude/OtherOptions= 18 | avrtarget/avrdude/ProgrammerID=programmerconfig.3 19 | avrtarget/avrdude/UseCounter=false 20 | avrtarget/avrdude/WriteEEPROM=false 21 | avrtarget/avrdude/WriteFlash=true 22 | avrtarget/perConfig=false 23 | eclipse.preferences.version=1 24 | -------------------------------------------------------------------------------- /examples/mega2560/blink_mega/blink.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * blink.cpp 3 | * Example project for the Arduino debugger. 4 | * Blinks the LED on Arduino Mega board. 5 | * For instructions on use please see doc\avr_debug.pdf 6 | * 7 | * Created on: 19. 1. 2017 8 | * Author: Jan Dolinay 9 | */ 10 | #include "Arduino.h" 11 | /* relative path for GDB stub valid only if this file is in the examples subfolder */ 12 | #include "../../../avr8-stub/avr8-stub.h" 13 | 14 | void setup(void) 15 | { 16 | debug_init(); // initialize the debugger 17 | pinMode(13, OUTPUT); 18 | } 19 | 20 | void loop(void) 21 | { 22 | breakpoint(); // stop execution here 23 | digitalWrite(13, HIGH); 24 | delay(200); 25 | digitalWrite(13, LOW); 26 | delay(500); 27 | } 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /examples/mega2560/blink_mega/blink_mega Debug COM5.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /examples/mega2560/blink_mega/blink_mega TCP.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /examples/mega2560/c_mega/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | -------------------------------------------------------------------------------- /examples/mega2560/c_mega/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | c_mega 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | de.innot.avreclipse.core.avrnature 26 | 27 | 28 | 29 | avr8-stub.c 30 | 1 31 | AVR8_STUB_PATH/avr8-stub.c 32 | 33 | 34 | avr8-stub.h 35 | 1 36 | AVR8_STUB_PATH/avr8-stub.h 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /examples/mega2560/c_mega/.settings/de.innot.avreclipse.core.prefs: -------------------------------------------------------------------------------- 1 | avrtarget/ClockFrequency=16000000 2 | avrtarget/ExtRAMSize=0 3 | avrtarget/ExtendedRAM=false 4 | avrtarget/MCUType=atmega2560 5 | avrtarget/UseEEPROM=false 6 | avrtarget/UseExtendedRAMforHeap=true 7 | avrtarget/avrdude/BitBangDelay= 8 | avrtarget/avrdude/Bitclock= 9 | avrtarget/avrdude/EEPROMFile= 10 | avrtarget/avrdude/EEPROMFromConfig=true 11 | avrtarget/avrdude/FlashFile= 12 | avrtarget/avrdude/FlashFromConfig=true 13 | avrtarget/avrdude/NoChipErase=false 14 | avrtarget/avrdude/NoSigCheck=false 15 | avrtarget/avrdude/NoVerify=false 16 | avrtarget/avrdude/NoWrite=false 17 | avrtarget/avrdude/OtherOptions= 18 | avrtarget/avrdude/ProgrammerID=programmerconfig.1 19 | avrtarget/avrdude/UseCounter=false 20 | avrtarget/avrdude/WriteEEPROM=false 21 | avrtarget/avrdude/WriteFlash=true 22 | avrtarget/perConfig=false 23 | eclipse.preferences.version=1 24 | -------------------------------------------------------------------------------- /examples/mega2560/c_mega/c_mega Debug COM5.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/mega2560/c_mega/c_mega.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main.c 3 | * 4 | * 5 | * Example for debugging with avr8-stub.c in plain C language, 6 | * without Arduino libraries. 7 | * For uploading the program to Arduino Mega 2560 use wiring protocol and baudrate 115200 8 | * in the AVRDude configuration. 9 | * For other instructions on use please see doc\avr_debug.pdf 10 | * 11 | * Author: Jan Dolinay 12 | */ 13 | 14 | #include 15 | #include 16 | /* relative path for GDB stub valid only if this file is in the examples subfolder */ 17 | #include "../../../avr8-stub/avr8-stub.h" 18 | 19 | /* pin PB7 is the onboard LED on Arduino Mega (Arduino pin 13) */ 20 | #define LED_PIN (7) 21 | 22 | uint16_t cnt = 0; 23 | uint16_t result; 24 | uint16_t function(uint16_t a); 25 | 26 | int main(void) 27 | { 28 | debug_init(); 29 | DDRB |= _BV(LED_PIN); 30 | sei(); /* enable interrupts */ 31 | breakpoint(); 32 | while(1) 33 | { 34 | PORTB |= _BV(LED_PIN); /* LED on */ 35 | cnt++; 36 | result = function(cnt); 37 | PORTB &= ~_BV(LED_PIN); /* LED off */ 38 | result++; 39 | } 40 | return 0; 41 | } 42 | 43 | uint16_t function(uint16_t a) 44 | { 45 | uint16_t n; 46 | n = 2*a; 47 | return n; 48 | } 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /examples/mega2560/readme.txt: -------------------------------------------------------------------------------- 1 | Examples for ATmega2560 and AtMega1280 (Arduino Mega). 2 | The projects are configured for Arduino mega with ATmega2560 MCU. 3 | To change to ATmega1280, go to project properties > AVR > Target hardware 4 | and change the MCU Type to ATmega1280. 5 | Clock is 16000000 (16 MHz) for both. 6 | 7 | To upload to the board use this avrdude programmer configuration: 8 | Mega1280 use Programmer hardware: Arduino, baudrate 57600 9 | Mega2560 use Programmer hardware: Wiring, baudrate 115200 10 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | blink_uno 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | de.innot.avreclipse.core.avrnature 27 | 28 | 29 | 30 | app_api.c 31 | 1 32 | AVR8_STUB_PATH/app_api.c 33 | 34 | 35 | app_api.h 36 | 1 37 | AVR8_STUB_PATH/app_api.h 38 | 39 | 40 | arduino 41 | 2 42 | ArduinoPath/hardware/arduino/avr/cores/arduino 43 | 44 | 45 | avr8-stub.c 46 | 1 47 | AVR8_STUB_PATH/avr8-stub.c 48 | 49 | 50 | avr8-stub.h 51 | 1 52 | AVR8_STUB_PATH/avr8-stub.h 53 | 54 | 55 | opt_api.h 56 | 1 57 | AVR8_STUB_PATH/opt_api.h 58 | 59 | 60 | standard 61 | 2 62 | ArduinoPath/hardware/arduino/avr/variants/standard 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/.settings/de.innot.avreclipse.core.prefs: -------------------------------------------------------------------------------- 1 | avrtarget/ClockFrequency=16000000 2 | avrtarget/ExtRAMSize=0 3 | avrtarget/ExtendedRAM=false 4 | avrtarget/MCUType=atmega328p 5 | avrtarget/UseEEPROM=false 6 | avrtarget/UseExtendedRAMforHeap=true 7 | avrtarget/avrdude/BitBangDelay= 8 | avrtarget/avrdude/Bitclock= 9 | avrtarget/avrdude/EEPROMFile= 10 | avrtarget/avrdude/EEPROMFromConfig=true 11 | avrtarget/avrdude/FlashFile= 12 | avrtarget/avrdude/FlashFromConfig=true 13 | avrtarget/avrdude/NoChipErase=false 14 | avrtarget/avrdude/NoSigCheck=false 15 | avrtarget/avrdude/NoVerify=false 16 | avrtarget/avrdude/NoWrite=false 17 | avrtarget/avrdude/OtherOptions= 18 | avrtarget/avrdude/ProgrammerID=programmerconfig.1 19 | avrtarget/avrdude/UseCounter=false 20 | avrtarget/avrdude/WriteEEPROM=false 21 | avrtarget/avrdude/WriteFlash=true 22 | avrtarget/perConfig=false 23 | eclipse.preferences.version=1 24 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/blink.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * blink.cpp 3 | * Example project for the Arduino debugger. 4 | * Blinks the LED on Arduino Uno board. 5 | * For instructions on use please see doc\avr_debug.pdf 6 | * 7 | * Created on: 11. 6. 2015 8 | * Author: Jan Dolinay 9 | */ 10 | #include "Arduino.h" 11 | 12 | /* relative path for GDB stub valid only if this file is in the examples subfolder */ 13 | #include "../../../avr8-stub/avr8-stub.h" 14 | 15 | void setup(void) 16 | { 17 | 18 | debug_init(); // initialize the debugger 19 | //breakpoint(); // stop execution here 20 | pinMode(13, OUTPUT); 21 | digitalWrite(13, HIGH); 22 | } 23 | 24 | void loop(void) 25 | { 26 | //breakpoint(); // stop execution here 27 | digitalWrite(13, HIGH); 28 | delay(500); 29 | digitalWrite(13, LOW); 30 | delay(1000); 31 | } 32 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/blink_nano COM14.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/blink_nano TCP.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/blink_uno Debug COM.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/blink_uno Debug Load.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/blink_uno TCP.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/debug_com.bat: -------------------------------------------------------------------------------- 1 | "C:\Programs\avr8-gnu-toolchain\bin\avr-gdb.exe" -x script_com .\debug\blink_uno.elf 2 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/debug_tcp.bat: -------------------------------------------------------------------------------- 1 | "c:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1061\avr8-gnu-toolchain\bin\avr-gdb.exe" -x script_tcp .\debug\blink.elf 2 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/gdb_logfile.txt: -------------------------------------------------------------------------------- 1 | 2 | w +$qSupported:multiprocess+;qRelocInsn+#2a 3 | End of log 4 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/script_com: -------------------------------------------------------------------------------- 1 | 2 | set debug remote 1 3 | set remotelogfile gdb_logfile.txt 4 | target remote //./COM10 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/script_log: -------------------------------------------------------------------------------- 1 | set remotelogfile gdb_logfile2.txt 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/mega328/blink_uno/script_tcp: -------------------------------------------------------------------------------- 1 | 2 | set debug remote 1 3 | #set remotelogfile gdb_logfile.txt 4 | target remote localhost:11000 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/mega328/c_uno/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | -------------------------------------------------------------------------------- /examples/mega328/c_uno/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | c_uno 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | de.innot.avreclipse.core.avrnature 26 | 27 | 28 | 29 | app_api.c 30 | 1 31 | AVR8_STUB_PATH/app_api.c 32 | 33 | 34 | app_api.h 35 | 1 36 | AVR8_STUB_PATH/app_api.h 37 | 38 | 39 | avr8-stub.c 40 | 1 41 | AVR8_STUB_PATH/avr8-stub.c 42 | 43 | 44 | avr8-stub.h 45 | 1 46 | AVR8_STUB_PATH/avr8-stub.h 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/mega328/c_uno/.settings/de.innot.avreclipse.core.prefs: -------------------------------------------------------------------------------- 1 | avrtarget/ClockFrequency=16000000 2 | avrtarget/ExtRAMSize=0 3 | avrtarget/ExtendedRAM=false 4 | avrtarget/MCUType=atmega328p 5 | avrtarget/UseEEPROM=false 6 | avrtarget/UseExtendedRAMforHeap=true 7 | avrtarget/avrdude/BitBangDelay= 8 | avrtarget/avrdude/Bitclock= 9 | avrtarget/avrdude/EEPROMFile= 10 | avrtarget/avrdude/EEPROMFromConfig=true 11 | avrtarget/avrdude/FlashFile= 12 | avrtarget/avrdude/FlashFromConfig=true 13 | avrtarget/avrdude/NoChipErase=false 14 | avrtarget/avrdude/NoSigCheck=false 15 | avrtarget/avrdude/NoVerify=false 16 | avrtarget/avrdude/NoWrite=false 17 | avrtarget/avrdude/OtherOptions= 18 | avrtarget/avrdude/ProgrammerID=programmerconfig.1 19 | avrtarget/avrdude/UseCounter=false 20 | avrtarget/avrdude/WriteEEPROM=false 21 | avrtarget/avrdude/WriteFlash=true 22 | avrtarget/perConfig=false 23 | eclipse.preferences.version=1 24 | -------------------------------------------------------------------------------- /examples/mega328/c_uno/c_uno Debug COM.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /examples/mega328/c_uno/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main.c 3 | * 4 | * 5 | * Example for debugging with avr8-stub.c in plain C language, 6 | * without Arduino libraries. 7 | * For instructions on use please see doc\avr_debug.pdf 8 | * 9 | * Author: Jan Dolinay 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | /* relative path for GDB stub valid only if this file is in the examples subfolder */ 16 | #include "../../../avr8-stub/avr8-stub.h" 17 | 18 | 19 | uint16_t cnt = 0; 20 | uint16_t result; 21 | uint16_t function(uint16_t a); 22 | 23 | int main(void) 24 | { 25 | debug_init(); 26 | DDRB |= _BV(5); // pin PB5 to output (LED) 27 | sei(); // enable interrupts 28 | breakpoint(); 29 | while(1) 30 | { 31 | PORTB |= _BV(5); // LED on 32 | cnt++; 33 | result = function(cnt); 34 | PORTB &= ~_BV(5); // LED off 35 | result++; 36 | } 37 | return 0; 38 | } 39 | 40 | uint16_t function(uint16_t a) 41 | { 42 | uint16_t n; 43 | n = 2*a; 44 | return n; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /examples/mega328/readme.txt: -------------------------------------------------------------------------------- 1 | Examples for ATmega328 MCU (Arduino Uno and other varians with this MCU). 2 | 3 | To upload to the board use this avrdude programmer configuration: 4 | Arduino Uno - Programmer hardware: Arduino, baudrate 115200 5 | 6 | -------------------------------------------------------------------------------- /hub4com-2.1.0.0-386/com2tcp.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | SETLOCAL 4 | IF DEFINED HUB4COM GOTO DEFINED_HUB4COM 5 | SET HUB4COM=hub4com 6 | :DEFINED_HUB4COM 7 | 8 | PATH %~dp0;%PATH% 9 | 10 | :SET PARAMS=%PARAMS% --create-filter=trace 11 | 12 | SET CF_PIN2CON=--create-filter=pin2con 13 | SET AF_PIN2CON=--add-filters=0:pin2con 14 | SET RECONNECT=1000 15 | 16 | :BEGIN_PARSE_OPTIONS 17 | SET OPTION=%~1 18 | IF NOT "%OPTION:~0,2%" == "--" GOTO END_PARSE_OPTIONS 19 | SHIFT /1 20 | 21 | IF /I "%OPTION%" == "--help" GOTO USAGE 22 | 23 | IF /I "%OPTION%" NEQ "--telnet" GOTO END_OPTION_TELNET 24 | SET CF_TELNET=--create-filter=telnet 25 | SET AF_TELNET=--add-filters=1:telnet 26 | GOTO BEGIN_PARSE_OPTIONS 27 | :END_OPTION_TELNET 28 | 29 | IF /I "%OPTION%" NEQ "--terminal" GOTO END_OPTION_TERMINAL 30 | SET CF_TELNET_OPTIONS="--terminal=\"%~1\"" 31 | SHIFT /1 32 | GOTO BEGIN_PARSE_OPTIONS 33 | :END_OPTION_TERMINAL 34 | 35 | IF /I "%OPTION%" NEQ "--awak-seq" GOTO END_OPTION_AWAK_SEQ 36 | SET CF_AWAK_SEQ="--create-filter=awakseq:--awak-seq=\"%~1\"" 37 | SET AF_AWAK_SEQ=--add-filters=0:awakseq 38 | SET RECONNECT=d 39 | SHIFT /1 40 | GOTO BEGIN_PARSE_OPTIONS 41 | :END_OPTION_AWAK_SEQ 42 | 43 | IF /I "%OPTION%" NEQ "--ignore-dsr" GOTO END_OPTION_IGNORE_DSR 44 | SET CF_PIN2CON= 45 | SET AF_PIN2CON= 46 | SET PERMANENT=* 47 | SET RECONNECT=d 48 | GOTO BEGIN_PARSE_OPTIONS 49 | :END_OPTION_IGNORE_DSR 50 | 51 | IF /I "%OPTION%" NEQ "--connect-dtr" GOTO END_OPTION_CONNECT_DTR 52 | SET CF_PINMAP=--create-filter=pinmap:"--dtr=connect" 53 | SET AF_PINMAP=--add-filters=0:pinmap 54 | GOTO BEGIN_PARSE_OPTIONS 55 | :END_OPTION_CONNECT_DTR 56 | 57 | IF /I "%OPTION%" NEQ "--interface" GOTO END_OPTION_INTERFACE 58 | SET OPTIONS=%OPTIONS% --interface=%~1 59 | SHIFT /1 60 | GOTO BEGIN_PARSE_OPTIONS 61 | :END_OPTION_INTERFACE 62 | 63 | IF /I "%OPTION%" == "--baud" GOTO BEGIN_OPTION_LC 64 | IF /I "%OPTION%" == "--data" GOTO BEGIN_OPTION_LC 65 | IF /I "%OPTION%" == "--parity" GOTO BEGIN_OPTION_LC 66 | IF /I "%OPTION%" == "--stop" GOTO BEGIN_OPTION_LC 67 | GOTO END_OPTION_LC 68 | :BEGIN_OPTION_LC 69 | SET VAL=%~1 70 | SHIFT /1 71 | IF /I "%VAL:~0,1%" == "d" SET VAL=c 72 | SET OPTIONS=%OPTIONS% %OPTION%=%VAL% 73 | GOTO BEGIN_PARSE_OPTIONS 74 | :END_OPTION_LC 75 | 76 | GOTO USAGE 77 | :END_PARSE_OPTIONS 78 | 79 | :BEGIN_PARSE_ARGS 80 | IF "%~1" == "" GOTO USAGE 81 | SET COMPORT=%~1 82 | SHIFT /1 83 | 84 | IF "%~1" == "" GOTO USAGE 85 | SET TCP=%PERMANENT%%~1 86 | SHIFT /1 87 | 88 | IF "%~1" == "" GOTO END_PARSE_ARGS 89 | SET TCP=%TCP%:%~1 90 | SHIFT /1 91 | 92 | IF NOT "%~1" == "" GOTO USAGE 93 | :END_PARSE_ARGS 94 | 95 | IF "%CF_TELNET_OPTIONS%" == "" GOTO END_ADD_CF_TELNET_OPTIONS 96 | IF "%CF_TELNET%" == "" GOTO END_ADD_CF_TELNET_OPTIONS 97 | SET CF_TELNET=%CF_TELNET%:%CF_TELNET_OPTIONS% 98 | :END_ADD_CF_TELNET_OPTIONS 99 | 100 | SET PARAMS=%PARAMS% %CF_PINMAP% %AF_PINMAP% 101 | SET PARAMS=%PARAMS% %CF_PIN2CON% %AF_PIN2CON% 102 | SET PARAMS=%PARAMS% %CF_AWAK_SEQ% %AF_AWAK_SEQ% 103 | SET PARAMS=%PARAMS% %CF_TELNET% %AF_TELNET% 104 | 105 | @ECHO ON 106 | "%HUB4COM%" %OPTIONS% %PARAMS% "%COMPORT%" --use-driver=tcp --reconnect=%RECONNECT% "%TCP%" 107 | @ECHO OFF 108 | ENDLOCAL 109 | 110 | GOTO END 111 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 112 | :USAGE 113 | 114 | ECHO Usage (client mode): 115 | ECHO %0 [options] \\.\^ ^ ^ 116 | ECHO. 117 | ECHO Usage (server mode): 118 | ECHO %0 [options] \\.\^ ^ 119 | ECHO. 120 | ECHO Common options: 121 | ECHO --telnet - use Telnet protocol. 122 | ECHO --terminal ^ - use terminal ^ (RFC 1091). 123 | ECHO --help - show this help. 124 | ECHO. 125 | ECHO COM port options: 126 | ECHO --baud ^ - set baud rate to ^ (default is 19200), 127 | ECHO where ^ is positive number or d[efault]. 128 | ECHO --data ^ - set data bits to ^ (default is 8), where ^ is 129 | ECHO positive number or d[efault]. 130 | ECHO --parity ^ - set parity to ^ (default is no), where ^ is 131 | ECHO n[o], o[dd], e[ven], m[ark], s[pace] or d[efault]. 132 | ECHO --stop ^ - set stop bits to ^ (default is 1), where ^ is 133 | ECHO 1, 1.5, 2 or d[efault]. 134 | ECHO --ignore-dsr - ignore DSR state (do not wait DSR to be ON before 135 | ECHO connecting to host, do not close connection after 136 | ECHO DSR is OFF and do not ignore any bytes received 137 | ECHO while DSR is OFF). 138 | ECHO --connect-dtr - set DTR to ON/OFF on opening/closing connection to 139 | ECHO host. 140 | ECHO. 141 | ECHO The value d[efault] above means to use current COM port settings. 142 | ECHO. 143 | ECHO Client mode options: 144 | ECHO --awak-seq ^ - wait for awakening ^ from com port 145 | ECHO before connecting to host. All data before 146 | ECHO ^ and ^ itself will not be sent. 147 | ECHO --interface ^ - use interface ^ for connecting. 148 | ECHO. 149 | ECHO Server mode options: 150 | ECHO --interface ^ - use interface ^ for listening. 151 | 152 | GOTO END 153 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 154 | :END 155 | -------------------------------------------------------------------------------- /hub4com-2.1.0.0-386/hub4com.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/hub4com-2.1.0.0-386/hub4com.exe -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "avr-debugger", 3 | "version": "1.5", 4 | "description": "Enables debugging Arduino/AVR code with GDB.", 5 | "repository": { 6 | "url": "https://github.com/jdolinay/avr_debug", 7 | "type": "git" 8 | }, 9 | "keywords": [ 10 | "avr", 11 | "gdb", 12 | "debug" 13 | ], 14 | "platforms": [ 15 | "atmelavr" 16 | ], 17 | "export": { 18 | "exclude": [ 19 | "bootloader", 20 | "doc", 21 | "hub4com-*", 22 | "arduino", 23 | "examples/experimental", 24 | "start_proxy*" 25 | ] 26 | }, 27 | "authors": [ 28 | { 29 | "maintainer": true, 30 | "name": "Jan Dolinay", 31 | "url": null, 32 | "email": "j.dolinay@dolinaysoft.com" 33 | } 34 | ], 35 | "build": { 36 | "includeDir": "avr8-stub", 37 | "srcDir": "avr8-stub" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdolinay/avr_debug/74f0fa2e3f67982e3d7af5242af066cc91da55dd/license.txt -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Source level debugger for Arduino 2 | Created by Jan Dolinay, June 2015
3 | Works for Arduino Uno, Nano, Pro Mini (ATmega328), Arduino Mega, as well as 4 | for AtMega1284(P). 5 | 6 | ### ARDUINO LIBRARY NOTE 7 | To use this debugger as Arduino library, go to the arduino/library sub-folder. The avr-debugger is the Arduino library which you can copy to your Arduino libraries folders to use it. For more information please read the readme.txt file in arduino/library/avr-debugger. 8 | 9 | ## Introduction 10 | This is debugger for Arduino based on GNU Debugger (GDB). The debugger is implemented using GDB stub mechanism. This means a piece of code (stub) is added to your Arduino program. This code then communicates with the GDB debugger. No external programmer or modification of the Arduino board is required. Eclipse can be used as a graphical frontend for debugging. For more information and tutorial please see the manual in /doc directory. 11 | 12 | ## Revision History 13 | **March 2022** 14 | + Added support for other UART than the default UART0 for Arduino Mega. (see AVR8_UART_NUMBER in avr8-stub.h). 15 | Now it is possible to use any one of the available UARTs to communicate with GDB and the UART0 can be used by Arduino Serial. 16 | 17 | **April 2021** 18 | (thanks to Bernhard Nebel, https://github.com/felias-fogg/avr_debug) 19 | + Added code to use TIMER0 as an alternative to using the watchdog 20 | timer (AVR8\_USE\_TIMER0\_INSTEAD\_OF\_WDT = 1). 21 | + Added a new possibility for generating a software interrupt, which does not use any external pin (AVR8\_SWINT\_SOURCE = -1). 22 | + Shortened the runtime of the debugging ISR from 40 microseconds to 23 | to less than 4 microseconds. 24 | + Fixed a bug that sometimes caused to show the wrong value of a local 25 | variable. 26 | + Fixed a bug that sometimes led to ignoring a breakpoint. 27 | + Added a message that tells the user when s/he set too many 28 | breakpoints. 29 | + The stub handles now resets caused by the debugger correctly in that it 30 | removes all breakpoints from flash memory before issuing the reset. 31 | 32 | 33 | **April 2021** 34 | (thanks to Bernhard Nebel, https://github.com/felias-fogg/avr_debug) 35 | + Added code for ATMega1284(P). 36 | 37 | 38 | **March 2021** 39 | + Fixed debug_message function; it hung the debugged program, now it prints properly even when debugged program is running. 40 | + Doc updated with info about using millis and micros Arduino functions while debugging 41 | + Doc updated about using the debugger in PlatformIO. 42 | 43 | **July 2020** 44 | + Added support for writing breakpoints to flash memory using do_spm function exported by Optiboot bootloader. Now it is possible to use flash breakpoints also with Arduino Mega. 45 | 46 | **May 2020** 47 | + Added support for PlatformIO based on contribution from msquirogac (https://github.com/msquirogac/avr-debugger-bootloader) 48 | This includes instructions in the doc to use the debugger in PlatformIO IDE (VSCode) and changes in the bootloader subfolder 49 | to support building the bootloader with PlatformIO. 50 | 51 | **July 2019** 52 | + Created Arduino hardware configuration to make it possible to burn the bootloader from Arduino IDE. 53 | 54 | **June 2019** 55 | + Created Arduino library to make it easier to use this debugger. 56 | 57 | **July 2018** 58 | + Fixed bug in bootloader - it really works now with avrdude. 59 | + Fixed bug in stub which prevented GDB from stopping running program in some cases. 60 | 61 | **January 2018** 62 | + Code tested and updated to work with current toolchain and eclipse. 63 | + Documentation updated. 64 | 65 | **June 2017** 66 | + Added support for writing breakpoints to flash memory including special bootloader. 67 | + Added support for loading the program via debugger - without AVRDude. 68 | 69 | **January 2017** 70 | + Added support for Arduino Mega board with ATmega1280 and ATmega2560 MCUs. 71 | + Example programs reorganized and renamed. The name now contains Arduino variant so that example projects for different variants can be imported into single eclipse workspace. 72 | + Fixed bug for ATmega328 (Uno) - the debugger now works for programs larger than 16 kB. 73 | + Documentation updated to describe also direct serial communication with the debugger (without the TCP-to-COM proxy) which seems to work on Windows 10 and with some boards also on Windows 7. 74 | 75 | **June 2015** 76 | + First release 77 | 78 | ## Contents of this package: 79 | Tool | Description 80 | --- | --- 81 | avr8-stub | source code of the debug driver (gdb stub for ATmega328 used in Arduino Uno) 82 | arduino | arduino library and some other code. 83 | doc | documentation with tutorials. 84 | examples | example projects which can be imported into your eclipse workspace. See documentation for instructions on use. 85 | hub4com-2.1.0.0-386 | hub2com tcp-serial proxy from http://sourceforge.net/p/com0com/news/2012/06/hub4com-v2100-released 86 | start_proxy.bat | convenience script to start the com2tcp proxy. 87 | 88 | ## Notes 89 | You can also start the tcp-serial proxy directly from command line: 90 | ``` 91 | com2tcp.bat --baud 115200 \\.\COM1 11000 92 | ``` 93 | (The example command assumes Arduino on port COM1; GDB connecting to localhost at port 11000). 94 | 95 | ## License 96 | This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. 97 | -------------------------------------------------------------------------------- /start_proxy.bat: -------------------------------------------------------------------------------- 1 | hub4com-2.1.0.0-386\com2tcp --baud 115200 \\.\COM19 11000 -------------------------------------------------------------------------------- /start_proxy_nano.bat: -------------------------------------------------------------------------------- 1 | hub4com-2.1.0.0-386\com2tcp --baud 57600 \\.\COM14 11000 --------------------------------------------------------------------------------