BW16 - RTLDuino debugging via SWD/Jtag

Hi, I got a RTLDuino board with the BW16 module on it.
I followed the steps in the tutorials and I was able to download an arduino sketch on it, I see that the device is working (I could scan wifi networks and perform other operations, I anyway did my test on 2 different devices, to exclude HW issues).
Unfortunately, since we plan to use the RTL8270DN for a very low power application, I need to evaluate power consumption of the different features (wifi, BLE) in very specific scenarios and for this I need to build some code using the SDK.
I cloned it from:
ambiot/ambz2_sdk: sdk for amebaz2 (github.com)
I managed to install it on Linux (WSL2) and build the sample app using GCC. I have segger Jlink and when I run GDB server the device is correctly recognized (I tried with SWD connection). The tool reports a Cortex-M33 as expected.
I executed make setup GDB_SERVER=jlink
Unfortunately, I get some errors when flashing.
If I run make flash I get this output:

$ make flash
Toolchain unzipping...
if [ ! -f ../../../tools/arm-none-eabi-gcc/asdk-6.4.1-linux-newlib-build-3026-x86_64.tar.bz2 ] ; then cat ../../../tools/arm-none-eabi-gcc/asdk-6.4.1-linux-newlib-build-3026-x86_64.tar.bz2* > ../../../tools/arm-none-eabi-gcc/asdk-6.4.1-linux-newlib-build-3026-x86_64.tar.bz2; fi;\
if [ ! -d ../../../tools/arm-none-eabi-gcc/asdk ] ; then mkdir ../../../tools/arm-none-eabi-gcc/asdk; fi;\
if [ ! -d ../../../tools/arm-none-eabi-gcc/asdk/linux ] ; then tar -jxf ../../../tools/arm-none-eabi-gcc/asdk-6.4.1-linux-newlib-build-3026-x86_64.tar.bz2 -C ../../../tools/arm-none-eabi-gcc/ ; mv ../../../tools/arm-none-eabi-gcc/asdk-6.4.1/linux ../../../tools/arm-none-eabi-gcc/asdk/linux ; rmdir ../../../tools/arm-none-eabi-gcc/asdk-6.4.1; fi
Toolchain unzip done!
make[1]: Entering directory '/home/valter/ambz2_sdk/project/realtek_amebaz2_v0_example/GCC-RELEASE'
chmod +rx ../../../component/soc/realtek/8710c/misc/gcc_utility/flashloader.sh
../../../component/soc/realtek/8710c/misc/gcc_utility/flashloader.sh application_is/Debug/bin/flash_is.bin
application_is/Debug/bin/flash_is.bin
../../../tools/arm-none-eabi-gcc/asdk/linux/newlib/bin/arm-none-eabi-gdb -x ../../../component/soc/realtek/8710c/misc/gcc_utility/rtl_gdb_flashloader.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.
0x0c0057f4 in ?? ()
Resets the core only, not peripherals.
Sleep 20ms
VER: 8
WDT RESET
Sleep 2000ms
Resets the core only, not peripherals.
Sleep 20ms
-------------------------------
FirmwareSize: 85c44
-------------------------------
Loading section A0 rw, size 0x88 lma 0x10000000
Loading section FIRMWARE_FUNTAB rw, size 0x70 lma 0x10000480
Loading section FIRMWARE_SIGN rw, size 0xc lma 0x100004f0
Loading section FIRMWARE_SRAM_RO ro, size 0x211a lma 0x10000500
Loading section FIRMWARE_SRAM_RW ro, size 0xb2e4 lma 0x1000261c
Start address 0x10001584, load size 54530
Transfer rate: 77 KB/sec, 7790 bytes/write.
Load flash controller.
FLASHDATBUFSIZE = 8000
FlashBufferEnd = 1000d900
FlashBufferStart = 10005900
Halts RESET Pin low when connecting to core
Breakpoint 1 at 0x10001758: file D:\Projects\ameba_sdk\original\v7.1a\component\soc\realtek\8710c\misc\iar_utility\flashloader\EWARM\framework2/flash_loader.c, line 166.
INIT_SP = 1003fa00 INIT_PC = 1000202d

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Flash Init done, start flash erase/write
image size = 85c44 debug = 0
LoopNum = 11
LoopNum Old = 10
TailSize = 5c44

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000d900)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Restoring binary file application_is/Debug/bin/flash_is.bin into memory (0x10005900 to 0x1000b544)

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Flash Download done, exist
A debugging session is active.

        Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) [answered Y; input not from terminal]
make[1]: Leaving directory '/home/valter/ambz2_sdk/project/realtek_amebaz2_v0_example/GCC-RELEASE'

Since the tool says “Flash Download done” I tried to start debugging:

make debug
Toolchain unzipping...
if [ ! -f ../../../tools/arm-none-eabi-gcc/asdk-6.4.1-linux-newlib-build-3026-x86_64.tar.bz2 ] ; then cat ../../../tools/arm-none-eabi-gcc/asdk-6.4.1-linux-newlib-build-3026-x86_64.tar.bz2* > ../../../tools/arm-none-eabi-gcc/asdk-6.4.1-linux-newlib-build-3026-x86_64.tar.bz2; fi;\
if [ ! -d ../../../tools/arm-none-eabi-gcc/asdk ] ; then mkdir ../../../tools/arm-none-eabi-gcc/asdk; fi;\
if [ ! -d ../../../tools/arm-none-eabi-gcc/asdk/linux ] ; then tar -jxf ../../../tools/arm-none-eabi-gcc/asdk-6.4.1-linux-newlib-build-3026-x86_64.tar.bz2 -C ../../../tools/arm-none-eabi-gcc/ ; mv ../../../tools/arm-none-eabi-gcc/asdk-6.4.1/linux ../../../tools/arm-none-eabi-gcc/asdk/linux ; rmdir ../../../tools/arm-none-eabi-gcc/asdk-6.4.1; fi
Toolchain unzip done!
make[1]: Entering directory '/home/valter/ambz2_sdk/project/realtek_amebaz2_v0_example/GCC-RELEASE'
chmod +rx ../../../component/soc/realtek/8710c/misc/gcc_utility/debug.sh
../../../component/soc/realtek/8710c/misc/gcc_utility/debug.sh application_is/Debug/bin/application_is.axf
application_is/Debug/bin/application_is.axf
../../../tools/arm-none-eabi-gcc/asdk/linux/newlib/bin/arm-none-eabi-gdb -x ../../../component/soc/realtek/8710c/misc/gcc_utility/rtl_gdb_debug.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.
0xeffffffe in ?? ()
Resets the core only, not peripherals.
Sleep 20ms
VER: 8
WDT RESET
Sleep 2000ms
Resets the core only, not peripherals.
Sleep 20ms
Loading section A0 rw, size 0x88 lma 0x10000000
Loading section FIRMWARE_FUNTAB rw, size 0x70 lma 0x10000480
Loading section FIRMWARE_SIGN rw, size 0xc lma 0x100004f0
Loading section FIRMWARE_SRAM_RO ro, size 0x211a lma 0x10000500
Loading section FIRMWARE_SRAM_RW ro, size 0xb2e4 lma 0x1000261c
Start address 0x10001584, load size 54530
Transfer rate: 77 KB/sec, 7790 bytes/write.
Load flash controller.
Halts RESET Pin low when connecting to core
Breakpoint 1 at 0x10001758: file D:\Projects\ameba_sdk\original\v7.1a\component\soc\realtek\8710c\misc\iar_utility\flashloader\EWARM\framework2/flash_loader.c, line 166.
---Type <return> to continue, or q <return> to quit---

Then if I press return I get:

INIT_SP = 1003fa00 INIT_PC = 1000202d

Program received signal SIGTRAP, Trace/breakpoint trap.
0xeffffffe in ?? ()
Flash Init done
Sleep 20ms
Halts RESET Pin low when connecting to core
Sleep 20ms
../../../component/soc/realtek/8710c/misc/gcc_utility/rtl_gdb_debug.txt:77: Error in sourced command file:
Cannot access memory at address 0x9b01843e

The FW does not seem to be running (no output on the serial port) and if I use an IDE like vscode I keep getting an error when setting breakpoints. Same happens on gdb interface:

(gdb) hbreak main
Cannot access memory at address 0x9b01843e

I didn’t change the sample configuration and I think it’s built in debug mode (at least folders with the output are named “Debug”).

I also tried to install an evaluation version of IAR 9.30.1 (as I said ATM I need to check features and power consumption, even if in the long term I would prefer to use an open source toolchain). I opened the example and built it.
When I start download (or download and debug) I get an error message saying:

Fatal error: Selected core (Cortex-M33) is not same as the target code (Cortex-M23)
Session aborted!

I think that the tool is connecting to the wrong core on the jtag chain, but I found no options to configure it.

Did someone managed to have the SDK working on RTLduino? Using which toolchain (GCC/IAR)?
I would be happy to have it working quickly, not minding too much about the tools ATM (I may do that later on if we evaluate that the chip fits our requirements).

Thank you for any help you may provide.

Update. I re-wired the UARTs as suggested in the Arduino tutorials and I can see that the device is still running the last Arduino sketch I uploaded, so I suppose that the issue with GCC toolchain is related to flashing.

@vmdm

To verify: you are using the BW16 board & module, which uses the RTL8720DN chip?

In that case, you should be using the AmbD SDK.
The AmbZ2 SDK is for RTL8720C series of chips.

1 Like

TY, I was confused by having different chips with the same number as a name :slight_smile:

I moved to the ambd SDK and now I am able to build and debug.
Thanks a lot.

1 Like