# Manual programming

## Setting things up

* STM32 ST-Link Utility software <https://www.st.com/en/development-tools/stsw-link004.html>
* Provisioning firmware files - Keep these files secure as they contain keys
* Firmware release files from <https://github.com/IRNAS/smartparks-rhino-tracker-firmware/releases>

{% hint style="info" %}
Always use .hex files with this software.
{% endhint %}

### Step 1 - Connect the device to the programmer

### Step 2  - Start ST-Link Utility and connect to device

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-ME1cxf-n-sulZBEy_T7%2F-ME1db022eNGAveNDKiN%2FSTLINKconect.png?alt=media\&token=04c93910-b40a-440d-9997-b2d7f42f3214)

{% hint style="info" %}
&#x20;To upload new firmware, go to Step 6, steps 3-5 require manual provisioning
{% endhint %}

### Step 3 - In menu Target select Erase Sectors

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-ME1cxf-n-sulZBEy_T7%2F-ME1df5w1F0Tryc9QDXj%2FSTLINK_Erase_sectors.png?alt=media\&token=e7bc576b-a798-4258-8ad8-8341877bf44d)

### Step 4 - In popup windows scroll to end and select Data Memory (Bank1) and Data Memory (Bank2)

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-ME1cxf-n-sulZBEy_T7%2F-ME1diasvRhY3ZggKi4K%2FSTLINK_Data_Memory.png?alt=media\&token=cc369c54-8bae-4168-ba97-4efae8cedc64)

### Step 5 - Wait for erase to finish

### Step 6  - From menu Target select Program & Verify

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-ME1cxf-n-sulZBEy_T7%2F-ME1dl3nqhB-qR5tiKn2%2FSTLINK_Programing.png?alt=media\&token=a0199d49-0d75-4dfe-af80-7755de5d0657)

{% hint style="info" %}
Select the provisioning firmware binary first if you have done steps 3-5.
{% endhint %}

### Step 7 - In popup window select .hex file you would like to program on the device

### Step 8 - Click start to start programming

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-ME1cxf-n-sulZBEy_T7%2F-ME1dns74D5LGGajQMxm%2FSTLINK_Program.png?alt=media\&token=38d3815c-5d31-4f72-90d1-21507961f948)

{% hint style="info" %}
Step 9 is necessary only when erasing sectors and uploading provisioning binary (steps 3-5 and provisioning in step 6)
{% endhint %}

### Step 9 - Repeat programming

Go to [Manual programming](#step-7-in-popup-window-select-hex-file-you-would-like-to-program-on-device) Step 6 and now program the release firmware.

## Deep sleep

Use [Arduino IDE](https://www.arduino.cc/en/Main/Software&) to upload Deep sleep firmware:

{% file src="<https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MSSczQsMgak1KyJdM4C%2F-MSSdnn6L-P37XPKeNLA%2FLoRaWAN_DeepSleep.ino?alt=media&token=27325529-454c-4bd9-a44b-4f67c34b9c6a>" %}
