# GDB server for KM4

**URL:** <https://forum.amebaiot.com/t/gdb-server-for-km4/1575>\
**Category:** SDK\
**Tags:** rtl872xd, evb-amb82\
**Created:** [December 6, 2022, 3:30pm UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575 "2022-12-06T15:30:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tuxford](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Tuxford](https://forum.amebaiot.com/u/Tuxford)\
**Post date:** [December 6, 2022, 3:30pm UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/1 "2022-12-06T15:30:39Z")

</div>

Hi All,  
After successful build of app from SDK if uploaded firmware for KM0. But I can’t do it for KM4 via JLINK9.

GDB server starts for KM0. See log below;

```auto
sudo /opt/SEGGER/JLink/JLinkGDBServer -select USB -device cortex-m23 -if SWD -scriptfile "AP1_KM0.JLinkScript" -port 2331 -SWOPort 2332 -TelnetPort 2333
SEGGER J-Link GDB Server V7.82d Command Line Version

JLinkARM.dll V7.82d (DLL compiled Nov 23 2022 16:09:15)

Command line: -select USB -device cortex-m23 -if SWD -scriptfile AP1_KM0.JLinkScript -port 2331 -SWOPort 2332 -TelnetPort 2333
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: AP1_KM0.JLinkScript
J-Link settings file: none
------Target related settings------
Target device: cortex-m23
Target device parameters: none
Target interface: SWD
Target interface speed: 4000kHz
Target endian: little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V9 compiled May 7 2021 16:26:12
Hardware: V9.60
S/N: <skip>
Feature(s): RDI, GDB, FlashDL, FlashBP, JFlash
Checking target voltage...
Target voltage: 3.33 V
Listening on TCP/IP port 2331
Connecting to target...
Connected to target
Waiting for GDB connection...

```

But for KM4 It doesn’t want to connect.

```auto
sudo /opt/SEGGER/JLink/JLinkGDBServer -select USB -device cortex-m33 -if SWD -scriptfile "AP2_KM4.JLinkScript" -port 2335 -SWOPort 2332 -TelnetPort 2333
[sudo] password for user: 
SEGGER J-Link GDB Server V7.82d Command Line Version

JLinkARM.dll V7.82d (DLL compiled Nov 23 2022 16:09:15)

Command line: -select USB -device cortex-m33 -if SWD -scriptfile AP2_KM4.JLinkScript -port 2335 -SWOPort 2332 -TelnetPort 2333
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2335
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: AP2_KM4.JLinkScript
J-Link settings file: none
------Target related settings------
Target device: cortex-m33
Target device parameters: none
Target interface: SWD
Target interface speed: 4000kHz
Target endian: little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V9 compiled May 7 2021 16:26:12
Hardware: V9.60
S/N: <skip>
Feature(s): RDI, GDB, FlashDL, FlashBP, JFlash
Checking target voltage...
Target voltage: 3.33 V
Listening on TCP/IP port 2335
Connecting to target...
ERROR: Could not connect to target.
Target connection failed. GDBServer will be closed...Restoring target state and closing J-Link connection...
Shutting down...
Could not connect to target.
Please check power, connection and settings

```

What is missed?  
Can chip be broken?  
It was used only powered by JLink. No connections except 3.3v. gnd. SWD\_CLK, SWD\_DATA.

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 7, 2022, 7:45am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/2 "2022-12-07T07:45:39Z")

</div>

Hi @Tuxford

The reason you cannot start GDB server for KM4 should be this:  
The boot process for RTL872xD chip is `KM0 boot -> KM4 boot -> KM0 + KM4 application code`, where KM0 is in charge of booting up KM4.

If I start with an empty flash, I cannot connect JLINK to KM4 as well, this is because there is no KM0 boot code, thus it does not boot up KM4, and JLINK cannot connect.

What you can try is this:

1. Compile image for KM0
2. Compile image for KM4
3. Start GDB server for KM0 only
4. run `make flash` in the `project_lp` folder, this should upload `km0_boot_all.bin` and `km0_km4_image2.bin`
5. run `make flash` in the `project_hp` folder, this should upload `km4_boot_all.bin` and `km0_km4_image2.bin`
6. All three images are now present, reset and you should see the application code run

After the first time, there is no need to run through all the steps every time, if KM0 code is not modified, step 1 and 4 can be skipped.  
Take note that you only need to connect JLINK to KM0 to upload.  
You will still need to connect JLINK to KM4 to debug KM4.

---

<div class="post-metadata">

**Author:** ![Tuxford](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Tuxford](https://forum.amebaiot.com/u/Tuxford)\
**Post date:** [December 7, 2022, 3:24pm UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/3 "2022-12-07T15:24:16Z")

</div>

Hi @wyy ,  
Unfortunately something else if wrong because it doesn’t work.  
First issue is this strange message during make flash in \*lp:

```auto
88 /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c: No such file or directory.

```

Also there are next issues for hp.:

```auto
stat: cannot stat '/home/<skip>/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/system.bin': No such file or directory
stat: cannot stat '/home/<skip>/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/km4_image3_all.bin': No such file or directory
stat: cannot stat '/home/<skip>/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/flash_all.bin': No such file or directory

```

and

```auto
88 /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c: No such file or directory.

```

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 8, 2022, 3:20am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/4 "2022-12-08T03:20:52Z")

</div>

it seems like the files are present in the [GitHub repo](https://github.com/ambiot/ambd_sdk/tree/dev/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader) though? Where did you obtain the SDK you are using and what version is it?

```auto
stat: cannot stat '/home/<skip>/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/system.bin': No such file or directory
stat: cannot stat '/home/<skip>/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/km4_image3_all.bin': No such file or directory
stat: cannot stat '/home/<skip>/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/flash_all.bin': No such file or directory

```

did this occur during `make flash` in hp?

---

<div class="post-metadata">

**Author:** ![Tuxford](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Tuxford](https://forum.amebaiot.com/u/Tuxford)\
**Post date:** [December 8, 2022, 8:14am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/5 "2022-12-08T08:14:48Z")

</div>

Hi @wyy  
I use [this](https://github.com/ambiot/ambd_sdk) repo. I fetched latest changes with git fetch and git pull. Branch dev.

> did this occur during `make flash` in hp?

Yes.

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 12, 2022, 2:52am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/6 "2022-12-12T02:52:31Z")

</div>

Hi,

using a fresh clone from GitHub, I could not reproduce the errors.  
Can you try again with a new clone of the SDK?

---

<div class="post-metadata">

**Author:** ![Tuxford](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Tuxford](https://forum.amebaiot.com/u/Tuxford)\
**Post date:** [December 12, 2022, 11:44am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/7 "2022-12-12T11:44:44Z")

</div>

Hi @wyy  
I cloned repository and build everything from scratch by ‘make all’ in lp and hp project. Then make ‘make setup GDB\_SERVER=jlink’ in both subprojects.  
Then I ran make flash. Message “No such file or directory” spill present.

```auto
~/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp$ make flash 
make -C asdk gdb
make[1]: Entering directory '/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk'
cp /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/gnu_utility/gnu_script/acut_loader/* /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/gnu_utility/gnu_script/
/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/gnu_utility/gnu_script/SetupGDB_FPGA.sh /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/gnu_utility/gnu_script
...
/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk
/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/image
/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/../toolchain/linux/asdk-6.4.1/linux/newlib/bin/arm-none-eabi-gdb -x /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/gnu_utility/gnu_script/rtl_gdb_flash_write.txt
GNU gdb (Realtek ASDK-6.4.1 Build 3026) 7.12.50.20170111-git
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x00000000 in ?? ()
Notification of completion for asynchronous execution commands is off.
Resets the core only, not peripherals.
Sleep 20ms
Resets the core only, not peripherals.
Sleep 20ms
Resets the core only, not peripherals.
Sleep 20ms
Load flash loader.
Restoring binary file gnu_utility/gnu_script/flash_loader_ram_1.bin into memory (0x82000 to 0x8223e)
$1 = 0x201
$2 = 0x4000201
....
wakeup bit(480003f8):4000201
$3 = 0x20000
$4 = 0x20000
....
wakeup bit(480003f8):20000
Breakpoint 1: file /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c, line 88.
Breakpoint 2: file /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c, line 118.

Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88 /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c: No such file or directory

```

And make flash for hp project the same:

```auto
Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp$ make flash 
make -C asdk gdb
make[1]: Entering directory '/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk'
cp /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/../../project_lp/asdk/gnu_utility/gnu_script/acut_loader/* /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/gnu_utility/gnu_script/acut_loader/
cp /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/gnu_utility/gnu_script/acut_loader/* /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/gnu_utility/gnu_script/
/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/gnu_utility/gnu_script/SetupGDB_FPGA.sh /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/gnu_utility/gnu_script
...
/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk
/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image
stat: cannot stat '/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/system.bin': No such file or directory
stat: cannot stat '/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/km4_image3_all.bin': No such file or directory
stat: cannot stat '/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/flash_all.bin': No such file or directory
/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/../toolchain/linux/asdk-6.4.1/linux/newlib/bin/arm-none-eabi-gdb -x /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/gnu_utility/gnu_script/rtl_gdb_flash_write.txt
GNU gdb (Realtek ASDK-6.4.1 Build 3026) 7.12.50.20170111-git
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x000820e8 in ?? ()
Notification of completion for asynchronous execution commands is off.
Resets the core only, not peripherals.
Sleep 20ms
Resets the core only, not peripherals.
Sleep 20ms
Resets the core only, not peripherals.
Sleep 20ms
Load flash loader.
Restoring binary file gnu_utility/gnu_script/flash_loader_ram_1.bin into memory (0x82000 to 0x8223e)
$1 = 0x4000201
$2 = 0x4000201
....
wakeup bit(480003f8):4000201
$3 = 0x20000
$4 = 0x20000
....
Breakpoint 1: file /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c, line 88.
Breakpoint 2: file /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c, line 118.

Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88 /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c: No such file or directory.

```

Python must be changed before making because of:

- no exec attribute;
- end of lines is not unix, so I ran doe2unix for conversion.

\*.sh scripts are not executable too. Why those files are not executable?  
checksum util is also not executable but it is execution during build.

Q: Is RTL8720DN chip flashed with system.bin during production or not?

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 14, 2022, 8:06am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/8 "2022-12-14T08:06:10Z")

</div>

Hi @Tuxford

```auto
stat: cannot stat '/home/<skip>/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/system.bin': No such file or directory
stat: cannot stat '/home/<skip>/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/km4_image3_all.bin': No such file or directory
stat: cannot stat '/home/<skip>/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/image/flash_all.bin': No such file or directory

```

This is not an issue, I can still upload even with these three files missing.  
`system.bin` only needs to be uploaded when certain settings need to be changed, such as low level BLE debug output

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 14, 2022, 8:13am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/9 "2022-12-14T08:13:10Z")

</div>

```auto
Latitude-3400:~/Documents/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp$ make flash
make -C asdk gdb
make[1]: Entering directory '/home/<user>/Documents/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk'
cp /home/<user>/Documents/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/gnu_utility/gnu_script/acut_loader/* /home/<user>/Documents/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/gnu_utility/gnu_script/
/home/<user>/Documents/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/gnu_utility/gnu_script/SetupGDB_FPGA.sh /home/<user>/Documents/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/gnu_utility/gnu_script
...
/home/<user>/Documents/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk
/home/<user>/Documents/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/image
/home/<user>/Documents/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/../toolchain/linux/asdk-6.4.1/linux/newlib/bin/arm-none-eabi-gdb -x /home/<user>/Documents/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/gnu_utility/gnu_script/rtl_gdb_flash_write.txt
GNU gdb (Realtek ASDK-6.4.1 Build 3026) 7.12.50.20170111-git
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x0c003324 in ?? ()
Notification of completion for asynchronous execution commands is off.
Resets the core only, not peripherals.
Sleep 20ms
Resets the core only, not peripherals.
Sleep 20ms
Resets the core only, not peripherals.
Sleep 20ms
Load flash loader.
Restoring binary file gnu_utility/gnu_script/flash_loader_ram_1.bin into memory (0x82000 to 0x8223e)
$1 = 0x201
$2 = 0x4000201
....
wakeup bit(480003f8):4000201
$3 = 0x101001f
$4 = 0x10017
....
wakeup bit(480003f8):10017
Breakpoint 1: file /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c, line 88.
Breakpoint 2: file /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c, line 118.

Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88	/cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c: No such file or directory.
flash_write FileName:1 
flash_write FileSize:4144 
flash_write FlashAddrForWrite:0 
FileSize: 1030
Loopnumber = 2
TailSize = 48
global variables
FlashDatSrc:82258
FlashBlockWriteSize:800
FlashAddrForWrite:0Flash write start...
FILESTARTADDR$5 = 0x0
$6 = 0x0
$7 = 0x0
Restoring binary file ./image/km0_boot_all.bin into memory (0x82258 to 0x82a58)

Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88	in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
FILESTARTADDR$8 = 0x800
$9 = 0x800
$10 = 0x1
Restoring binary file ./image/km0_boot_all.bin into memory (0x82258 to 0x82a58)

Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88	in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
FILESTARTADDR$11 = 0x1000
$12 = 0x1000
$13 = 0x2
Restoring binary file ./image/km0_boot_all.bin into memory (0x82258 to 0x82288)

Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88	in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
flash_write FileName:2 
flash_write FileSize:651264 
flash_write FlashAddrForWrite:6000 
FileSize: 9f000
Loopnumber = 318
TailSize = 0
global variables
FlashDatSrc:82258
FlashBlockWriteSize:800
FlashAddrForWrite:6000Flash write start...
FILESTARTADDR$14 = 0x0
$15 = 0x6000
$16 = 0x0
Restoring binary file ./image/km0_km4_image2.bin into memory (0x82258 to 0x82a58)

```

and I am still able to upload despite the `/cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c: No such file or directory.` message

When you use `make flash`, does the upload go through, or is it getting stuck at that message?

---

<div class="post-metadata">

**Author:** ![Tuxford](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Tuxford](https://forum.amebaiot.com/u/Tuxford)\
**Post date:** [December 14, 2022, 9:14am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/10 "2022-12-14T09:14:54Z")

</div>

Hi @wyy  
The end of flash is

```auto
Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88 in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
FILESTARTADDR$962 = 0x9e000
$963 = 0xa4000
$964 = 0x13c
Restoring binary file ./image/km0_km4_image2.bin into memory (0x100082258 to 0x100082a58)

Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88 in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
FILESTARTADDR$965 = 0x9e800
$966 = 0xa4800
$967 = 0x13d
Restoring binary file ./image/km0_km4_image2.bin into memory (0x100082258 to 0x100082a58)

Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88 in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
dump for check

Breakpoint 2, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:120
120 in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
make[1]: Leaving directory '/home/<skip>/Src/VVG/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk'

```

And make flash in hp:

```auto
Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88 in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
FILESTARTADDR$962 = 0x9e000
$963 = 0xa4000
$964 = 0x13c
Restoring binary file ./image/km0_km4_image2.bin into memory (0x100082258 to 0x100082a58)

Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88 in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
FILESTARTADDR$965 = 0x9e800
$966 = 0xa4800
$967 = 0x13d
Restoring binary file ./image/km0_km4_image2.bin into memory (0x100082258 to 0x100082a58)

Breakpoint 1, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:88
88 in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
dump for check

Breakpoint 2, RtlFlashProgram () at /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c:120
120 in /cygdrive/c/Work/SDKs/Git_SDKs/sdk_6.2/project/realtek_amebaD_va0_example/GCC-RELEASE/project_lp/asdk/flashloader/rtl_flash_download.c
make[1]: Leaving directory '/home/<skip>/Src/VVG/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk'

```

No hangs in both cases.

Unfortunately I can attach full log and server log too. I it can help you I can share those logs in other way.

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 14, 2022, 9:45am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/11 "2022-12-14T09:45:54Z")

</div>

Hi @Tuxford

Thanks for sharing more logs. From what I can see, it seems like `make flash` is running normally for both lp and hp. The various messages are not indications of any error.

So are you still having trouble uploading firmware?

---

<div class="post-metadata">

**Author:** ![Tuxford](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Tuxford](https://forum.amebaiot.com/u/Tuxford)\
**Post date:** [December 14, 2022, 10:46am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/12 "2022-12-14T10:46:00Z")

</div>

Hi @wyy  
I still have an issue. I can;t connect by JLink for debugging.

After power disconnect and connect it doesn’t seem that chip starts properly. I start server in the next was but it shows no connection to target.

```auto
 JLinkGDBServer -select USB -device Cortex-M33 -endian little -if SWD -speed 1000 -ir -noLocalhostOnly -nologtofile -scriptfile "/home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/jlink_script/AP2_KM4.JLinkScript" -port 2331 -SWOPort 2332 -TelnetPort 2333
SEGGER J-Link GDB Server V7.82d Command Line Version

JLinkARM.dll V7.82d (DLL compiled Nov 23 2022 16:09:15)

Command line: -select USB -device Cortex-M33 -endian little -if SWD -speed 1000 -ir -noLocalhostOnly -nologtofile -scriptfile /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/jlink_script/AP2_KM4.JLinkScript -port 2331 -SWOPort 2332 -TelnetPort 2333
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: on
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: /home/<skip>/Src/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/jlink_script/AP2_KM4.JLinkScript
J-Link settings file: none
------Target related settings------
Target device: Cortex-M33
Target device parameters: none
Target interface: SWD
Target interface speed: 1000kHz
Target endian: little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V9 compiled May 7 2021 16:26:12
Hardware: V9.60
S/N: 69653608
Feature(s): RDI, GDB, FlashDL, FlashBP, JFlash
Checking target voltage...
Target voltage: 3.33 V
Listening on TCP/IP port 2331
Connecting to target...
ERROR: Could not connect to target.
Target connection failed. GDBServer will be closed...Restoring target state and closing J-Link connection...
Shutting down...
Could not connect to target.
Please check power, connection and settings.

```

Also I connected USB2Serial adapter to PC and serial wires to TX/RX. I don’t see any activity.  
Q: What serial port parameters has to be set? I use default 115200 8n1.

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 19, 2022, 2:11am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/13 "2022-12-19T02:11:07Z")

</div>

Hi @Tuxford

The serial port parameters are correct.  
Can you describe what you see on the serial port? It should at least print a `#` sign on reset, and there may be more messages depending on which images are present.

---

<div class="post-metadata">

**Author:** ![Tuxford](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Tuxford](https://forum.amebaiot.com/u/Tuxford)\
**Post date:** [December 19, 2022, 8:30am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/14 "2022-12-19T08:30:00Z")

</div>

Hi @wyy  
There is nothing on TX/RX and LTX/RTX pins. What about EN pin. Should it be connected to VDD or GND during flashing and start? I don’t see any information in the datasheet.

On other chip that is connected to STM32L476RG nucleo board, it shows the terminals.

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 19, 2022, 8:59am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/15 "2022-12-19T08:59:42Z")

</div>

Hi @Tuxford

Are you using the chip directly, or using a module?

The pins you should be monitoring are `PA7` and `PA8` for LOG\_UART TX and RX respectively.  
`CHIP_EN` functions as a reset, pull low to put chip into reset mode, pull high to release from reset and boot.  
Each reset should result in at least a `#` sign printed over LOG\_UART TX.  
To enter firmware download mode, `PA7` should be pulled low when `CHIP_EN` is released from low. `PA7` can be released afterwards to function as a UART TX.

> [@Tuxford](#):
>
> On other chip that is connected to STM32L476RG nucleo board, it shows the terminals.

Can you explain what this means? I did not understand.

---

<div class="post-metadata">

**Author:** ![Tuxford](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Tuxford](https://forum.amebaiot.com/u/Tuxford)\
**Post date:** [December 19, 2022, 3:45pm UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/16 "2022-12-19T15:45:47Z")

</div>

Hi @wyy  
I use RTL8720DN chip, not board. The first environment is for debugging by JLink. Everything is related to it.

 ![JLink](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/0/0f36daef2aadca329452d56dccf7dc3723585b59.jpeg)

In this case EN is always floating. Is it acceptable for flashing by jlink?

Second case is as it has to be implemented in production except nucleo board by STM32L476. I hadn’t mention it before my previous message. In this case before uploading it must enter to upload mode. Sequence in next.

1. Connect LTX to GND. **Q: us it the same as setting low level on directly connected STM32L PIN?**
2. Connect EN to GND., **Q: us it the same as setting low level on directly connected STM32L PIN?**
3. Pause. **Q: What the minimal value of timeout before lowering rising the value?**
4. Connect EN to 3.3V. **Q: us it the same as setting high level on directly connected STM32L PIN?**
5. Disconnect LTX from GND. **Q: must it be connected as serial port line again?**
6. Q: what telegram size? Min and max.
7. Q: is there a reply if a telegram accepted bt RTL chip or not?

 ![Nucleo](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/a/af9676dd231dcada6503641d5076206ca3d584cb.jpeg)  
d

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 20, 2022, 1:54am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/17 "2022-12-20T01:54:45Z")

</div>

Hi @Tuxford

> [@Tuxford](#):
>
> In this case EN is always floating. Is it acceptable for flashing by jlink?

It should be better to pull up to 3.3v if not in reset.

> [@Tuxford](#):
>
> 1. Connect LTX to GND. **Q: us it the same as setting low level on directly connected STM32L PIN?**
> 2. Connect EN to GND., **Q: us it the same as setting low level on directly connected STM32L PIN?**
> 3. Connect EN to 3.3V. **Q: us it the same as setting high level on directly connected STM32L PIN?**

Yes, it should be

> [@Tuxford](#):
>
> 1. Pause. **Q: What the minimal value of timeout before lowering rising the value?**
> 2. Disconnect LTX from GND. **Q: must it be connected as serial port line again?**

The key point is that LTX is low when EN changes from low to high. After EN changes to high, LTX should be reconnected to as a serial TX, as it is used in firmware upload mode. While the chip is waiting in firmware upload mode, it will transmit 0x15 repeatedly.

  

Note that there are two methods to upload firmware:

1. Firmware upload over LOG\_UART.
  - In this case, you need to put chip in firmware upload mode first, LTX and EN to low, then EN high, then LTX as serial TX.

2. Firmware upload over JLINK
  - In this case, you **DO NOT** need to put chip in firmware upload mode first. EN should be high to let the chip run.

---

<div class="post-metadata">

**Author:** ![Tuxford](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Tuxford](https://forum.amebaiot.com/u/Tuxford)\
**Post date:** [December 20, 2022, 9:24pm UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/18 "2022-12-20T21:24:24Z")

</div>

Hi @wyy ,

1. Case with jlink.  
I connected EN to VCC and now it show next message after make flash.

> #[MODULE\_BOOT-LEVEL\_ERROR]:IMG2 SIGN Invalid  
> I didn’t turn on any signatures.

1. Case with Nucleo STM32+RTL8720DN.  
It give welcome message for update but after update there is an old image.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/c/c2cdf5329e601dab252337e5038743c2fca23473.png)  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/7/7e8606587e19a5fdd699f7b0ecf3744e2691f4ac.png)

And beginning of an image.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/b/bb269df1c6dea19c2b22953f826d5de6ab56c314.png)

Is there header of km0\_km4\_image2.bin correct or some extra data must be sent before?  
Q: is there a response about accepting telegram?

Thank you!

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [December 21, 2022, 6:53am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/19 "2022-12-21T06:53:49Z")

</div>

Hi @Tuxford

1. Case with jlink

2. Case with Nucleo STM32+RTL8720DN

> [@Tuxford](#):
>
> Q: is there a response about accepting telegram?

Can you rephrase this question? I do not understand the question

---

<div class="post-metadata">

**Author:** ![Tuxford](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Tuxford](https://forum.amebaiot.com/u/Tuxford)\
**Post date:** [December 21, 2022, 8:09am UTC](https://forum.amebaiot.com/t/gdb-server-for-km4/1575/20 "2022-12-21T08:09:49Z")

</div>

Hi @wyy

1. What does this message mean? I didn’t use any signatures.
2. I mean a response from on LTX line after telegram has been sent to RTL chip and it was accepted or not. Unfortunately I can’t find flash protocol via LOG serial definition in the docs.

[Next page](https://forum.amebaiot.com/t/gdb-server-for-km4/1575.md?page=2)
