Skip to content

Commit

Permalink
Merge branch 'master' into 0.23.0_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWhoami authored Feb 7, 2024
2 parents df93926 + 8533b49 commit 4b48b8c
Show file tree
Hide file tree
Showing 168 changed files with 16,016 additions and 580 deletions.
281 changes: 281 additions & 0 deletions docs/520_2.2.0/flash_management/flash_management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
# Flash Management
## 1. Board Overview

![](img/10_1_1.png)


![](img/10_1_2.png)


## 2. Hardware Setting

### 2.1. Connecting UART0 (Program Flash via UART0 Interface)

1. UART0: Command Port
2. The UART Tx/Rx definition may be different from various vendors. If your USB-UART cable doesn't work, please swap Tx/Rx pin, re-plug and try again.

![](img/10_2_1.png)
![](img/10_2_1_1.png)


### 2.2. Connecting 5V power and trun on power switch

Power from Adapter or from Power Bank (USB PD)

![](img/10_2_2.png)


### 2.3. Wake up chip from RTC power domain by pressing PTN button

Please do it every time after plugging in the power

![](img/10_2_3.png)


### 2.4. Set bootstrap settings to manual boot mode (Program Flash via UART0 Interface)

1. Must set bootstrap settings to manual boot mode
![](img/10_2_4_1.png)
2. Reset pin or power must be controllable to enter manual boot mode.

![](img/10_2_4.png)





## 3. Program Flash via UART0 Interface

### 3.1. Flash programmer necessaries

1. Open command terminal for flash programmer execution
Tool path: `kl520_sdk\firmware\utils\flash_programmer\flash_programmer.py`
2. Install Necessary python modules: `kl520_sdk\firmware\utils\requirements.txt`
3. Limitations: Only the listed argument combinations below are allowed.

### 3.2. Edit python verification setting

1. Check UART port number from device manager

2. Edit setup.py, search “**COM_ID**” and modify the ID to match your UART port number

EX: COM_ID = 4 # COM4

![](img/10_3_1.png)


### 3.3 Firmware Binary Generation (FW + MODELS)
Generate flash final bin file from other separate bin files.
The script combines .bin files in "flash_bin" in predefined order.
Moreover, the addressing is in **4KB alignment**

**Command**

```bash
$ python3 bin_gen.py <options>

options argument:

-h, --help Show this help message and exit
-p, --CPU_ONLY SPL/SCPU/NCPU without model
```

**Output**
`flash_image.bin`

**Note**

1. Component, **nef_utility**, is used by bin_gen. If in Linux, must `chmod +x ../nef_utility/nef_utility_linux` first

2. The following bin files are must

```bash
flash_bin/
├── boot_spl.bin // bool spl bin file
├── fw_loader.bin // LOADER bin file (or copied from plus/res/firmware/KL520)
├── fw_ncpu.bin // SCPU FW bin file (generated by Keil)
├── fw_scpu.bin // NCPU FW bin file (generated by Keil)
├── prog_fw_loader_flash-boot.bin // switch to flash boot bin file (or copied from /utils/JLink_programmer/bin/)
├── models_520.nef // model information (or copied from plus/res/models/KL520)
```


### 3.4 Flash Chip Programming (FW + DATA)

```bash
$ python flash_programmer.py -a flash_image.bin
```

Please press RESET BTN while you are seeing “Please press reset button!!”

![](img/10_3_2.png)


Afterwards, just wait until all progresses are finished (erase, program, verify)

![](img/10_3_3.png)


> **Note**
> `flash_programmer.py -a` means to do flash chip erase + programming + verification
### 3.5 Flash Verification (optional)

```bash
$ python flash_programmer.py -v flash_image.bin
```

### 3.6 Flash Erase (optional)

```bash
$ python flash_programmer.py -e
```

### 3.7 Flash Partial Programming example (optional)

```bash
$ python flash_programmer.py -i 0x00002000 -p fw_scpu.bin

# "**-i**" means the flash index/address to program
# "**-p**" means the FW binary to program
```





## 4. Program Flash via JTAG/SWD Interface

### 4.1. Jlink programmer necessaries

Connect JTAG/SWD.

![](img/10_4_1.png)


### 4.2. Edit flash_prog.jlink device setting

1. Check your flash manufacturer: Winbond or Mxic or GigaDevice

2. Select a specific device based on flash manufacturer

EX:

```txt
device KL520-WB //Winbond
device KL520-MX //Mxic
device KL520-GD //GigaDevice
```

3. Copy the bin file to `kl520_sdk\firmware\utils\JLink_programmer\bin` folder
EX: flash_image.bin, boot_spl.bin, fw_scpu.bin, fw_ncpu.bin, etc.


### 4.3. To Program composed flash_image.bin

> Check existence of *bin/flash_image.bin* composed by *utils/bin_gen* in previous steps
Afterwards, just wait until all progresses are finished (chip erase, program, verify)

![](img/10_4_2.png)

### 4.4. (optional) To Program Specific Bin Files to Specific Flash Addresses

1. Edit *flash_prog_partial.jlink* device setting

2. Copy the bin file to `kl520_sdk\firmware\utils\JLink_programmer\bin\`

3. Select a specific device+’-P’ based on flash manufacturer

EX:

```
device KL520-WB-P //Winbond
device KL520-MX-P //Mxic
device KL520-GD-P //GigaDevice
```

4. Edit loadbin command: Load *.bin file into target memory

**Syntax**:

```bash
loadbin <filename>, <addr>
//loadbin .\bin\boot_spl.bin,0x00000000
//loadbin .\bin\fw_loader.bin,0x00002000
//loadbin .\bin\prog_fw_loader_flash-boot.bin,0x00029000
loadbin .\bin\fw_scpu.bin,0x00030000
//loadbin .\bin\fw_loader.bin,0x00041000
loadbin .\bin\fw_ncpu.bin,0x00068000
```

5. Execute **flash_prog_partial.bat** and wait until all progresses are finished


#### 5.4. (Optional) To Program Flash Using Partial Bin Files as Usb Boot Mode

1. Check your flash manufacturer: Winbond or Mxic or GigaDevice

2. Go to folder `kl520_sdk\firmware\utils\JLink_programmer\`
3. Edit **prog_fw_loader_usb-boot.jlink**
- Select a specific device+’-P’ based on flash manufacturer to
EX:
```txt
device KL520-WB-P //Winbond
device KL520-MX-P //Mxic
device KL520-GD-P //GigaDevice
```
- Edit loadbin command: Load *.bin file into target memory
**Syntax**:
```bash
loadbin <filename>, <addr>
loadbin .\bin\boot_spl.bin,0x00000000
loadbin .\bin\fw_loader.bin,0x00002000
loadbin .\bin\prog_fw_loader_usb-boot.bin,0x00029000
loadbin .\bin\fw_loader.bin,0x00041000
```
4. Execute **prog_fw_loader_usb-boot.bat** and wait until all progresses are finished (chip erase, program, verify)
#### 5.5. (Optional) To Program Flash Using Partial Bin Files as Flash Boot Mode
1. Check your flash manufacturer: Winbond or Mxic or GigaDevice
2. Go to folder `kl520_sdk\firmware\utils\JLink_programmer\`
3. Edit **prog_fw_loader_flash-boot.jlink**
- Select a specific device+’-P’ based on flash manufacturer to
EX:
```txt
device KL520-WB-P //Winbond
device KL520-MX-P //Mxic
device KL520-GD-P //GigaDevice
```
- Edit loadbin command: Load *.bin file into target memory
**Syntax**:
```bash
loadbin <filename>, <addr>
loadbin .\bin\boot_spl.bin,0x00000000
loadbin .\bin\fw_loader.bin,0x00002000
loadbin .\bin\prog_fw_loader_flash-boot.bin,0x00029000
loadbin .\bin\fw_scpu.bin,0x00030000
loadbin .\bin\fw_loader.bin,0x00041000
loadbin .\bin\fw_ncpu.bin,0x00068000
```
4. Execute **prog_fw_loader_flash-boot.bat** and wait until all progresses are finished (chip erase, program, verify)
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_1_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_2_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_2_1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_2_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_2_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_2_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_2_4_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_3_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_3_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_3_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_4_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_4_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_4_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/flash_management/img/10_4_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/file_structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/11.2.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/11.2.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/11.3.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/11.3.3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/11.3.4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/11.3.5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/11.3.6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/11.4.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/11.4.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/11.5.1.png
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/4_1_1.png
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/4_1_2.png
3 changes: 3 additions & 0 deletions docs/520_2.2.0/imgs/getting_start_imgs/4_2_1.png
Loading

0 comments on commit 4b48b8c

Please sign in to comment.