Skip to content
Snippets Groups Projects
README.md 3.26 KiB
Newer Older
  • Learn to ignore specific revisions
  • Quentin Bolsee's avatar
    Quentin Bolsee committed
    # Arduino SAM Tutorial
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ## 0. Installing
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    To install the Arduino Core, add the following URL to `Additional Boards Manager URLs`:
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    ```
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    https://raw.githubusercontent.com/qbolsee/ArduinoCore-fab-sam/master/json/package_Fab_SAM_index.json
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ```
    
    
    Kye Shimizu's avatar
    Kye Shimizu committed
    For Arduino IDE (Arduino v2), this is in the settings page.
    
    <img src=img/arduino-ide.jpg width=50%>
    
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    You can then install the package by opening up the Boards Manager:
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/board_manager.png width=50%>
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    And looking for a package called `Fab SAM core for Arduino`. Simply install the latest version:
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/install_board.png width=50%>
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    A new menu appears under `board`, letting you select a variety of chips. Some generic names contain an `x`, for instance for a SAMD21E17, you would select `Generic x21E`:
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/board_list.png width=50%>
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    Then select the right microcontroller in the next menu:
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/microcontroller.png width=50%>
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ## 1. With bootloader
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    Because the SAMD family has native USB support, they can easily talk to the host computer using a CDC serial class. A neat trick is to use this serial port not only to communicate, but also upload your binary when needed.
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    This can be achieved with a bootloader, that first needs to be installed on the microcontroller using an external programmer. After this, your board will behave like an official Arduino board and can be flashed through the serial port without any programmer plugged in.
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/with_bootloader.png width=50%>
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ### 1.1 Burn bootloader
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    Connect a CMSIS-DAP adapter (Atmel ICE is also fine) to your board and make sure both are powered. Here are examples with a D11 and a D21, with various programmer/connector styles:
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/programming_d11.jpg width=50%><img src=img/programming_d21.jpg width=50%><br>
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    Select the right board and microcontroller, then `CMSIS-DAP` as the programmer, then click on `Burn Bootloader`.
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/burn_bootloader.png width=50%>
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    If all goes well, your board will now be detected as a serial port and you can start uploading to it through the bootloader.
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ### 1.2 Upload sketch
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    To upload a sketch, simply use the `upload` command or the arrow icon. Make sure the bootloader size is not set to `NO_BOOTLOADER`, otherwise the bootloader won't be used.
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/upload.png width=50%>
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ### 1.3 Upload with programmer (optional)
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    This is a special scenario where you have a bootloader but still want to upload using a programmer. Reasons might be:
    
    - Upload is slow through the bootloader
    - You disabled USB support and the board cannot be found
    
    In those cases, connect a programmer and explicitly pick `Upload Using Programmer`:
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/upload_programmer.png width=50%>
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ## 2. Without bootloader
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    As expained previously, bootloaders use some of the flash. With the SAMD11, we only have 16kb of total flash, and the bootloader would use 4kb of that. If you want to recover this extra space, you can use your chip without a bootloader altogether. You'll need a programmer connected every time you upload a sketch.
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    To enable this behavior, simply select `NO_BOOTLOADER` in bootloader size:
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/without_bootloader.png width=50%>
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    ### 2.1 Upload
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    To upload without a bootloader, connect a programmer and either pick `Upload` or the arrow button. `Upload Using Programmer` has the same effect.
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    
    
    Quentin Bolsee's avatar
    Quentin Bolsee committed
    <img src=img/upload.png width=50%>