# Burn Bootloader for NyBoard

If you cannot upload sketches to the NyBoard (the "not in sync error") and verify that the serial connection is all good, the NyBoard's bootloader might be crashed during the last upload.&#x20;

{% hint style="info" %}
Verify that the serial connection is all good means:

1. The USB cable has data wires rather than just the power wires. The USB cable included in the Petoi package should be good.&#x20;
2. You have the proper driver for the uploader, or your computer can automatically install the driver. You can see and select the serial port in the Arduino IDE -> Tools -> Port.
3. All the contacts along the loop are connected firmly.&#x20;
4. You have successfully uploaded sketches previously.
   {% endhint %}

There could be several reasons why the NyBoard's bootloader crashes. Some of the common causes include:

1. Uploading the sketch at a high baud rate
2. Using a malfunctioning USB cable
3. Using a power source that is not sufficient
4. Using a low-quality or damaged Uno board
5. Disrupting the upload process by pressing the reset button or unplugging the board
6. Memory overflow

In the specific case of Petoi robots, the sketch size and errors in the code are major causes of the crashed bootloader. Uploading a sketch to the Uno replaces the existing bootloader code with the new sketch. If the sketch is too large to fit in the memory or if there are errors in the code causing memory overflow, the bootloader may corrupt.&#x20;

## Use the Simple Bootloader Resetter

From August 2023, we will ship a simple bootloader resetter with the NyBoard. If you got an earlier batch and need to reset the bootloader, please write to <support@petoi.com> to request a free shipment.&#x20;

<figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FybaiBnTzroztzbwWgljb%2F%E6%96%B0%E7%89%88Bootloader%E7%83%A7%E5%BD%95%E5%99%A8.jpg?alt=media&#x26;token=3b221605-de43-48e4-8300-878c9166f726" alt=""><figcaption></figcaption></figure>

{% embed url="<https://www.youtube.com/watch?v=R_rrP5Q_L-I>" %}

{% hint style="info" %}
The old version:

<img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FAQjfZ4lzoaJrOQ4VEKuQ%2FsimpleBootloader.png?alt=media&#x26;token=a69a2586-7c60-4f11-87ac-68a8d2047956" alt="" data-size="original"><br>

{% embed url="<https://youtu.be/ExJ0LOG8z9I>" %}
{% endhint %}

{% hint style="info" %}
If the light ends up <mark style="color:red;">red</mark>, it means the resetting operation fails. It's probably a malfunction of either the NyBoard or the bootloader resetter.
{% endhint %}

## Use Arduino UNO Board

1. &#x20;Open the sketch **ArduinoISP.ino**.<br>

   <figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FIOxa30OIl8TjpWbu5pGZ%2Fimage.png?alt=media&#x26;token=0189dffa-cbc1-4091-96de-783b5bde76fa" alt=""><figcaption></figcaption></figure>
2. &#x20;Select the items in the menu bar **Tools > Board** (Arduino UNO) and **Port** that connect to the UNO board.<br>

   <figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2Fz4ouO2VGRVe3Hu5T9ev7%2Fimage.png?alt=media&#x26;token=37693408-a7c2-4bb6-8f57-f4ebe488ee3f" alt=""><figcaption></figcaption></figure>

   <figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FgQ3XAy4PGsiwZv1OjsM5%2Fimage.png?alt=media&#x26;token=ca183c3f-7aa8-4b72-a392-e0b29100480c" alt=""><figcaption></figcaption></figure>

   <figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FuhbF69oLwq5SdSZq4Tb7%2Fimage.png?alt=media&#x26;token=b64c581c-c4eb-4c38-ad9f-c5836fdb768b" alt=""><figcaption></figcaption></figure>
3. &#x20;Upload the sketch **ArduinoISP.ino** to the **UNO** board.<br>

   <figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FR3sHjAWaEHvbEreUhzsy%2Fimage.png?alt=media&#x26;token=83a72e25-7719-400d-ac9c-4f494947ad32" alt=""><figcaption></figcaption></figure>
4. &#x20;Wire the UNO board with NyBoard.<br>

   <figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2Fy61ujJuwIY3iZn9KAacy%2FConnectWire03.png?alt=media&#x26;token=39907367-7625-421d-9c91-14a9d0081a9a" alt=""><figcaption></figcaption></figure>
5. &#x20;Select the **Arduino as ISP** in the menu bar **Tools>Programmer**.<br>

   <figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2F8RsBBFOi2NNB3N7yDKna%2Fimage.png?alt=media&#x26;token=0adb1b9e-be02-432f-bfa9-e6e086e8fbb3" alt=""><figcaption></figcaption></figure>
6. &#x20;Click the menu **Burn Bootloader**.<br>

   <figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FpjL9mIQ2m0Ew6rqruJZ1%2Fimage.png?alt=media&#x26;token=e9cc1daa-1ae7-4cc3-bc71-fc516008be5b" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
At Step 6, you'd better push the jumpers with your fingers to ensure good contact.

![](https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FeA7y2Tlehct1xYf81JwP%2Fimage.png?alt=media\&token=a1d6a642-d6f9-45cd-8ee6-1b82c988c338)
{% endhint %}

{% embed url="<https://youtu.be/gXjgVTsqSlM>" %}

{% hint style="info" %}
Since the NyBoard uses the same chip as a regular Arduino Uno, if you have two Nyboards, you can use one as a **programmer**(upload the sketch **ArduinoISP.ino**) to burn the bootloader to another one as the **target**. The steps are similar to the above, but you need to assign the **RESET** pin to 6 in the **ArduinoISP.ino** as follows:

![](https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FwUYlP77tyJRTKjLALwyn%2Fimage.png?alt=media\&token=12d58714-acaa-4959-9d31-c34820140174)\
The jumper connection is as follows:\
![](https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FPZN3bLpRCJKxtCYdvgaO%2Fimage.png?alt=media\&token=60d12f4c-5881-49f5-bd85-1909b1d15a36)
{% endhint %}

## Use USBtinyISP or USBasp

* USBtinyISP\
  ![](https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FECXRf9qVJ2WPXX2qjrfz%2Fimage.png?alt=media\&token=c7b421a6-7ca0-4b0f-b28a-77a24c202751)    ![](https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FohlYVRBUCA5InZ1AE3rE%2Fimage.png?alt=media\&token=643b7be4-8ac3-4e12-96e2-7fb17ed9a96e)

Connect the USBtinyISP programmer and NyBoard.  The pins connection map is as follows:

MI --> MISO          V --> VCC

SC --> SCK        MO --> MOSI

R --> Reset           G --> GND

Connect the USBtinyISP programmer to the computer with a USB port. After installing the driver as follows:

<figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FUHNdRkGazqis0sZM6BJm%2Fimage.png?alt=media&#x26;token=8657f5e0-3ff9-41fd-97f9-8b6e1441f075" alt=""><figcaption></figcaption></figure>

The driver is as follows:

{% file src="<https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2F6ykYqUzSWaiwWQ349hh7%2Fusbtinyisp_libusb_1.2.6.0.zip?alt=media&token=d2942ef6-3a53-4e62-9e42-2402e443021a>" %}

With NyBoard V1\_\*, you can simply choose **Arduino Uno** under the **Tool** menu of Arduino IDE, then burn the bootloader as follows:

<figure><img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FwcxaJW3JHlKUrGzghO32%2Fimage.png?alt=media&#x26;token=34b53fe7-9e4b-4bc8-8a1b-1eff6a16a6aa" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
While Burning the bootloader, you'd better push the UsbtinyISP with your fingers to ensure good contact.

![](https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FkxBdWSdZQZXjy9vmy1aP%2Fimage.png?alt=media\&token=03d4f19b-5974-4dfd-88c0-e4fbe799cdf0)
{% endhint %}

{% embed url="<https://youtu.be/NrZt8MZRhMc>" %}

* USBasp\
  ![](https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FDIqkksFL5ZXR6xSXbjyx%2Fimage.png?alt=media\&token=a06a8b9a-5287-4b8a-b4f7-9e5a85d5a61f)    ![](https://ci5.googleusercontent.com/proxy/JDotWsy3hqC5zFUgWHgEh_QkMlCo2TmRtADW7Eh7WLIRFkQh-DrosRejloNvdrr7_AeIn86uQkZXJHhEp4d0kc0HJtkS-7LIq8Of-bd1uhAr6vdWmKUuXNmJTnik3h6WZp_ce3Aj5tjsH3DRRTzIKsg3lt_vLUBRZ-WBI9YlrpqAbfYUIbBPVp4Wo7GIZ2dvc-47qvoPqm84eyoqyT5Jia1JMgo_M1CyubNaM_owb67L07RpJcoNIARFLGC0W1kS6INgWCieLpt7oKdISR0NaQ=s0-d-e1-ft#https://static.wixstatic.com/media/4a8c7f_b354037432ea4fe38fca66734cf29fa9~mv2.png/v1/fill/w_820,h_303,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/4a8c7f_b354037432ea4fe38fca66734cf29fa9~mv2.png)<br>

Connect the USBasp programmer and NyBoard. The pins connection map is as follows:

MISO --> MISO       VCC --> VCC

SCK --> SCK           MOSI --> MOSI

Reset --> Reset      GND --> GND

Connect the USBasp programmer to the computer with a USB port. Afer installing the driver as follows:

<figure><img src="https://ci3.googleusercontent.com/proxy/53CtBbDXpfETcS_cIRn9REmlBvM3nnH7haJp80ouUSKjqB6h3LsMP8mZwN6LIFLYE37kc5xLpO9h0vy1smuZQVjHnlo2j5JCQFe_9AOra7oi9FmYRj-OnCTmdpKRvpA-l5OAiPqRrdpZahuwJeBb3mOdrSn-nlWagm3DA-N42ab2MKAjApVQG37RORkrgdNZf9ruuhcNARu8uKd6lc2x9zJ4eppgoKB3f6OcXCo6Bk7KBsFLajX7hWQSx2dx5boluZb5jiN2lCGKiF_hVsHeOQ=s0-d-e1-ft#https://static.wixstatic.com/media/4a8c7f_f7cae08f0498430390abfbb9ffc2d6df~mv2.png/v1/fill/w_820,h_535,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/4a8c7f_f7cae08f0498430390abfbb9ffc2d6df~mv2.png" alt=""><figcaption></figcaption></figure>

The driver installer is as follows:

{% file src="<https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FiOJ3f9m5LdlB5ItVsHdJ%2Fzadig-2.8.zip?alt=media&token=806432e3-11e2-4869-af3e-a8c1717b600c>" %}

With NyBoard V1\_\*, you can simply choose **Arduino Uno** under the **Tool** menu of Arduino IDE, then burn the bootloader as follows:

<figure><img src="https://ci4.googleusercontent.com/proxy/VULLBuDSOvGNH1mNZ4X1soEuLPfmZaxeOrufnl1FEnTi55UiaEE1cgWm0DEcKboiOreegpjqUG1SL5MYxEsCujMRKQzkFpJQiQ5oaLu3tlGJFRRI8XPRw9i8oUP9bqd8NV2RYGjpGBmSxFnCg9E4JoV3ar4fKZqQ7kyxjXKBegirA8kxM5JJjtIkGcUcd4UMVXWzj7mreqRIVsrAQonFrXn4GEt6AfveF3Qm4P3-C_X1n6X_oCqfGAZn6zGMbrhUXURMILTw4DTnhEhspP_tsQ=s0-d-e1-ft#https://static.wixstatic.com/media/4a8c7f_e10bd7b427364d57940544e5c11c69ab~mv2.png/v1/fill/w_820,h_734,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/4a8c7f_e10bd7b427364d57940544e5c11c69ab~mv2.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The socket from the USBasp programmer to ICSP on NyBoard is not compatible. In this case, You need to use female-to-male jumper wires to connect the pins on each side as follows (It's a one-time operation, so there is no need for soldering)\
![](https://ci3.googleusercontent.com/proxy/AwPSNxZRSxTM8CZe4FvW2yiSG_b3uJGubsn5NZ7SpcaPhDg9sYQI3ATc8OrfN1NU59q3ToloLyus6eaeWl-LzVM26QakPcOz2LIpSbx1-VYudmlPqg0GTESyden7JbXWypgzX4JMj10GNmJ0RaFc9OL5K9cfA_77yOf2wdObKXXoxGLaZ1CH2Aji6HfEWM4qVOEO0wsnvKI4-bIkh6a_5fN7946iwvJcJtd8KbTwiwvJELaJFIauwKmyk8tKN2UdwRh-YrsO5_FgyvaX4N_gFQ=s0-d-e1-ft#https://static.wixstatic.com/media/4a8c7f_74acbb2a822e461886e7969a1ac92f3a~mv2.png/v1/fill/w_820,h_568,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/4a8c7f_74acbb2a822e461886e7969a1ac92f3a~mv2.png)

While Burning the bootloader, make sure they have good contact. You can press the jumpers slightly to ensure the connections.
{% endhint %}

For details about how to use the USBasp programmer, you can refer to:

{% embed url="<https://youtu.be/ToKerwRR-70>" %}

## \* Upload sketches using a Programmer&#x20;

{% hint style="warning" %}
You may also use the Programmer to upload sketches to the board.&#x20;

<img src="https://1565080149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQ6a951Q6Jn1Zzt5Ajr-887967055%2Fuploads%2FWd0UIX4ruAvvRv9xsmaD%2FprogrammerUpload_En.png?alt=media&#x26;token=c3f355a8-7d64-4e68-91ac-d12f7e98c8d5" alt="" data-size="original">

It allows larger sketches because the bootloader takes about 2 KB on the flash. However, it will overwrite the default bootloader, and you WON'T be able to upload sketches using the regular USB uploader. And uploading sketches using the programmer is also slower. So it's not recommended unless your serial uploading routine is broken.&#x20;
{% endhint %}
