Skip to content
  • Категории
  • Главная
  • Документация
  • Последние
  • Пользователи
Collapse
  1. Главная
  2. Блоги сообщества Raspberry Pi
  3. Программируем Arduino с помощью Raspberry Pi

Программируем Arduino с помощью Raspberry Pi

Запланировано Прикреплена Закрыта Перенесена Блоги сообщества Raspberry Pi
2 Сообщения 2 Posters 527 Просмотры
  • Сначала старые
  • Сначала новые
  • По количеству голосов
Авторизуйтесь, чтобы ответить
Эта тема была удалена. Только пользователи с правом управления темами могут её видеть.
  • C Не в сети
    C Не в сети
    Canabalt
    написал в отредактировано pi
    #1

    7fbc74f8-4ebc-47e2-b3b0-a20036a5cb68-image.png
    Статья о том,как при помощи GPIO прошить Arduino или совместимый с Arduino AVR.

    Внимание!Все действия вы производите на свой страх и риск.Автор ответственности не несет.

    Это руководство ориентировано на людях знакомых с ISP программированием или имеющим опыт работы с Arduino .Если вы не уверены в своих силах,то лучше использовать Arduino IDE.

    Вам понадобится:

    • Raspberry Pi ,но учтите , что вам нужно 4 свободных GPIO порта для каждого AVR
    • AVR чип или платы Arduino , который с гребенкой ICSP (например Arduino Uno).
    • Макетная плата и провода для соединения выводов ICSP на AVR / Arduino и GPIO контактов на Raspberry Pi

    Шаг 0. Добавим репозиторий из которого будем загружать ПО.

    sudo nano /etc/apt/sources.list
    

    И добавим в открывшийся файл строку

    deb http://apt.adafruit.com/raspbian/ jessie main
    

    Теперь в файле должно быть прописано два репозитория

    • Репозиторий Raspbian
    • Репозиторий Adafruit который мы сейчас добавили

    Сохраняем файл и ставим avrdude

    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install avrdude
    

    Для того,чтобы удостовериться,что все установилось

    avrdude -v
    

    Шаг 1. Подключаемся.

    Соединим контакты GPIO и ICSP контакты AVR/Arduino по схеме

    Arduino ICSP VCC к Raspberry Pi 5V pin.
    Arduino ICSP GND к Raspberry Pi GND pin.
    Arduino ICSP RESET к Raspberry Pi GPIO #12.
    Arduino ICSP SCK к Raspberry Pi GPIO #24.
    Arduino ICSP MOSI к Raspberry Pi GPIO #23.
    Arduino ICSP MISO к Raspberry Pi GPIO #18.
    

    Шаг 2.Настроим AVRDUDE

    Откроем файл

    sudo nano /etc/avrdude.conf
    

    И в конец файла добавим

    # Linux GPIO configuration for avrdude.
    # Change the lines below to the GPIO pins connected to the AVR.
    programmer
      id    = "pi_1";
      desc  = "Use the Linux sysfs interface to bitbang GPIO lines";
      type  = "linuxgpio";
      reset = 12;
      sck   = 24;
      mosi  = 23;
      miso  = 18;
    ;
    

    Сохраняем файл.

    Шаг 3. Программирование

    Для начала нам нужно получить .hex файл скетча

    Одним из способов его получения это скомпилировать скетч через ARDUINO IDE и посмотреть на наличие строки,которая укажет путь к .hex файлу

    Удобнее всего это делать с ПК.

    Пример строки:

    /home/Сanabalt/Programs/arduino-1.6.4/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/build6154610255332504576.tmp/Blink.cpp.elf /tmp/build6154610255332504576.tmp/Blink.cpp.hex
    

    Также .hex файл можно получить через AVR GCC

    Проверим доступность Arduino/AVR

    sudo avrdude -p atmega328p -C /etc/avrdude_gpio.conf -c pi_1 -v
    

    Вывод должен быть примерно таким

    avrdude: Version 6.1, compiled on May 28 2015 at 18:41:48
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch
     
             System wide configuration file is "/home/pi/avrdude_gpio.conf"
             User configuration file is "/root/.avrduderc"
             User configuration file does not exist or is not a regular file, skipping
     
             Using Port                    : unknown
             Using Programmer              : pi_1
             AVR Part                      : ATmega328P // Модель контроллера
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PC2
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :
     
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
     
             Programmer Type : linuxgpio
             Description     : Use the Linux sysfs interface to bitbang GPIO lines
             Pin assignment  : /sys/class/gpio/gpio{n}
               RESET   =  12
               SCK     =  24
               MOSI    =  23
               MISO    =  18
     
    
    avrdude: AVR device initialized and ready to accept instructions
     
    Reading | ################################################## | 100% 0.00s
     
    avrdude: Device signature = 0x1e950f
    avrdude: safemode: lfuse reads as FF
    avrdude: safemode: hfuse reads as D6
    avrdude: safemode: efuse reads as 5
     
    avrdude: safemode: lfuse reads as FF
    avrdude: safemode: hfuse reads as D6
    avrdude: safemode: efuse reads as 5
    avrdude: safemode: Fuses OK (E:05, H:D6, L:FF)
     
    avrdude done.  Thank you.
    

    Если все удачно,то мы готовы к прошивке

    sudo avrdude -p atmega328p -C /etc/avrdude_gpio.conf -c pi_1 -v -U flash:w:Blink.cpp.hex:i
    

    Где atmega328p модель контроллера,который прошиваем

    Где Blink.cpp.hex необходимо указать путь и название .hex файла для прошивки

    В моем случае вывод был таким

    avrdude: Version 6.1, compiled on May 28 2015 at 18:41:48
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch
     
             System wide configuration file is "/home/pi/avrdude_gpio.conf"
             User configuration file is "/root/.avrduderc"
             User configuration file does not exist or is not a regular file, skipping
     
             Using Port                    : unknown
             Using Programmer              : pi_1
             AVR Part                      : ATmega328P
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PC2
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :
     
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
     
             Programmer Type : linuxgpio
             Description     : Use the Linux sysfs interface to bitbang GPIO lines
             Pin assignment  : /sys/class/gpio/gpio{n}
               RESET   =  12
               SCK     =  24
               MOSI    =  23
               MISO    =  18
     
    avrdude: AVR device initialized and ready to accept instructions
     
    Reading | ################################################## | 100% 0.00s
     
    avrdude: Device signature = 0x1e950f
    avrdude: safemode: lfuse reads as FF
    avrdude: safemode: hfuse reads as D6
    avrdude: safemode: efuse reads as 5
    avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
             To disable this feature, specify the -D option.
    avrdude: erasing chip
    avrdude: reading input file "Blink.cpp.hex"
    avrdude: writing flash (1030 bytes):
     
    Writing | ################################################## | 100% 0.89s
     
    avrdude: 1030 bytes of flash written
    avrdude: verifying flash memory against Blink.cpp.hex:
    avrdude: load data flash data from input file Blink.cpp.hex:
    avrdude: input file Blink.cpp.hex contains 1030 bytes
    avrdude: reading on-chip flash data:
     
    Reading | ################################################## | 100% 0.87s
     
    avrdude: verifying ...
    avrdude: 1030 bytes of flash verified
     
    avrdude: safemode: lfuse reads as FF
    avrdude: safemode: hfuse reads as D6
    avrdude: safemode: efuse reads as 5
    avrdude: safemode: Fuses OK (E:05, H:D6, L:FF)
     
    avrdude done.  Thank you.
    

    Такой вывод обозначает,что все прошито удачно.

    Теперь удалим репозиторий

    sudo nano /etc/apt/sources.list
    

    И уберем оттуда репозиторий ,который добавили в начале статьи.

    Удачи вам во всех ваших начинаниях!

    Все вопросы в комментарии под постом.

    gerundG 1 ответ Последний ответ
    0
    • gerundG Не в сети
      gerundG Не в сети
      gerund
      replied to Canabalt on отредактировано
      #2

      А репозиторий-то зачем в конце удалять??? 👩‍🍳

      1 ответ Последний ответ
      2

      • Войти

      • Нет учётной записи? Зарегистрироваться

      • Login or register to search.
      • Первое сообщение
        Последнее сообщение
      0
      • Категории
      • Главная
      • Документация
      • Последние
      • Пользователи