Using NuttX as library once again

If you follow this blog you know that I already show how to use NuttX as a library to avoid compiling it all the time using the build system. But unfortunately I did it more than 3 years ago and NuttX changed a lot since that time.

So, let’s to start configuring the STM32F429IDISCOVERY board.

Create the nuttxspace directory and clone the nuttx and apps:

$ mkdir ~/nuttxspace
$ cd ~/nuttxspace
$ git clone https://github.com/apache/incubator-nuttx nuttx
$ git clone https://github.com/apache/incubator-nuttx-apps apps

Configure the NuttX to the STM32F429IDISCOVERY board and ‘nsh’ profile:

$ cd ~/nuttxspace
$ cd nuttx
$ make distclean
$ ./tools/configure.sh stm32f429i-disco:nsh
$ make menuconfig

Select HELLO application and use USER_ENTRYPOINT = hello_main

Exit menuconfig and run:

$ make export

If everything worked fine it should have created a nuttx-export file:

$ ls -l nuttx-export*
-rw-rw-r-- 1 alan alan 4396597 Jun 28 09:49 nuttx-export-9.0.0.zip

Now create your hello world directory and copy this export file to there

$ mkdir ~/hello
$ cp nuttx-export-9.0.0.zip ~/hello
$ cd ~/hello
$ unzip nuttx-export-9.0.0.zip
$ cd nuttx-export-9.0.0

Finally create your hello.c file:

#include <stdio.h>

int hello_main(void)
{
        printf("Hello World from my App!\n");
        return 0;
}

Compile it:

$ arm-none-eabi-gcc -c -fno-builtin -Wall -Wstrict-prototypes -Wshadow -Wundef -g -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -I. -isystem ./include   -pipe -I "./include" -I "./arch/chip" hello.c -o  hello.o

We just need to link again all libs to generate our nuttx ELF:

$ arm-none-eabi-ld --entry=__start -nostartfiles -nodefaultlibs -T./scripts/ld.script -L./libs hello.o -o nuttx.elf --start-group -lc -larch -lbinfmt -lboard -lboards -ldrivers -lfs -lmm -lsched -lxx "/usr/lib/gcc/arm-none-eabi/9.2.1/thumb/v7e-m/nofp/libgcc.a" --end-group

Finally convert the ELF to BIN to flash into the board:

$ arm-none-eabi-objcopy -S -O binary nuttx.elf nuttx.bin

Time to flash it:

$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x08000000"

Open the minicom and reset the board, you should see:

Error CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed

After trying to use JLink to flash the NuttX firmware on NXP iMXRT1060_EVK board and receiving the message that it doesn’t support Cortex-M7 (I’m using the most up to date JLink’s firmware), I decide to use the OpenOCD.

Initially I was getting this error:

$ sudo openocd -f interface/cmsis-dap.cfg
[sudo] password for alan:
Open On-Chip Debugger v0.10.0-esp32-20200526-6-g4c41a632 (2020-06-23-10:12)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 1.10
Error: CMSIS-DAP: JTAG not supported

Then I edited the cmsis-dap.cfg and added the SWD transport:

#
# ARM CMSIS-DAP compliant adapter
#
# http://www.keil.com/support/man/docs/dapdebug/
#
interface cmsis-dap

transport select swd

But then I got this error:

$ sudo openocd -f interface/cmsis-dap.cfg
Open On-Chip Debugger v0.10.0-esp32-20200526-6-g4c41a632 (2020-06-23-10:12)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
swd
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 1.10
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Error: CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed.

After search in the Internet I found how to fix it: I edited the cmsis-dap.cfg again and added the adapter speed:

#
# ARM CMSIS-DAP compliant adapter
#
# http://www.keil.com/support/man/docs/dapdebug/
#
interface cmsis-dap

transport select swd

adapter_khz 500

Finally everything worked fine:

$ sudo openocd -f interface/cmsis-dap.cfg
Open On-Chip Debugger v0.10.0-esp32-20200526-6-g4c41a632 (2020-06-23-10:12)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 500 kHz
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 1.10
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 500 kHz
Warn : gdb services need one or more targets defined

Compiling OpenOCD for ESP32

$ git clone https://github.com/espressif/openocd-esp32
$ cd openocd-esp32
$ ./bootstrap
$ ./configure --enable-internal-jimtcl --enable-maintainer-mode --disable-werror --disable-shared --enable-stlink --enable-jlink --enable-rlink --enable-vslink --enable-ti-icdi --enable-remote-bitbang --enable-usb-blaster --enable-presto --enable-osbdm

....

OpenOCD configuration summary
MPSSE mode of FTDI based devices yes (auto)
ST-Link Programmer yes
TI ICDI JTAG Programmer yes
Keil ULINK JTAG Programmer yes (auto)
Altera USB-Blaster II Compatible yes (auto)
Bitbang mode of FT232R based devices yes (auto)
Versaloon-Link JTAG Programmer yes (auto)
TI XDS110 Debug Probe yes (auto)
OSBDM (JTAG only) Programmer yes
eStick/opendous JTAG Programmer yes (auto)
Andes JTAG Programmer yes (auto)
USBProg JTAG Programmer yes (auto)
Raisonance RLink JTAG Programmer yes
Olimex ARM-JTAG-EW Programmer yes (auto)
CMSIS-DAP Compliant Debugger yes (auto)
Cypress KitProg Programmer yes (auto)
Altera USB-Blaster Compatible yes
ASIX Presto Adapter yes
OpenJTAG Adapter yes (auto)
SEGGER J-Link Programmer yes

$ make

$ sudo make install

Testing:

$ openocd -f board/esp32-wrover-kit-3.3v.cfg
Open On-Chip Debugger  v0.10.0-esp32-20200526-6-g4c41a632 (2020-06-23-10:12)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : FreeRTOS creation
Info : FreeRTOS creation
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32.cpu0: Debug controller was reset.
Info : esp32.cpu0: Core was reset.
Info : esp32.cpu1: Debug controller was reset.
Info : esp32.cpu1: Core was reset.
Info : Listening on port 3333 for gdb connections

Dumping the Flash content from ESP-WROVER-KIT_V4.1 board:

> flash probe 0
esp32.cpu0: Target halted, PC=0x40091856, debug_reason=00000001
Flash mapping 0: 0x10020 -> 0x3f400020, 116 KB
Flash mapping 1: 0x30018 -> 0x400d0018, 104 KB
esp32.cpu0: Target halted, PC=0x40091856, debug_reason=00000001
Auto-detected flash bank 'esp32.cpu0.flash' size 4096 KB
Using flash bank 'esp32.cpu0.flash' size 4096 KB
flash 'esp32' found at 0x00000000

> flash banks
#0 : esp32.cpu0.flash (esp32) at 0x00000000, size 0x00400000, buswidth 0, chipwidth 0
#1 : esp32.cpu0.irom (esp32) at 0x00000000, size 0x00000000, buswidth 0, chipwidth 0
#2 : esp32.cpu0.drom (esp32) at 0x00000000, size 0x00000000, buswidth 0, chipwidth 0
#3 : esp32.cpu1.flash (esp32) at 0x00000000, size 0x00000000, buswidth 0, chipwidth 0
#4 : esp32.cpu1.irom (esp32) at 0x00000000, size 0x00000000, buswidth 0, chipwidth 0
#5 : esp32.cpu1.drom (esp32) at 0x00000000, size 0x00000000, buswidth 0, chipwidth 0

> dump_image esp32_flash.bin 0x00000000
dump_image filename address size

> dump_image esp32_flash.bin 0x00000000 0x400000
dumped 4194304 bytes in 26.868017s (152.449 KiB/s)

> 

How to print the value of a #define variable during compilation

This is a nice trick to see the value of a variable:

#define XSTR(x) STR(x)
#define STR(x) #x

#pragma message "The value of NETLIB_SOCK_TYPE: " XSTR(NETLIB_SOCK_FAMILY)

It is also a good idea to put an #error “See above” to stop the compilation after it print the value.

You show see something like this:

CC:  nsh_netcmds.c
In file included from nsh_netcmds.c:93:
.../apps/include/netutils/netlib.h:132:9: note: #pragma message: The value of NETLIB_SOCK_TYPE: 2

Source: https://stackoverflow.com/questions/1562074/how-do-i-show-the-value-of-a-define-at-compile-time

Testing TizenRT on ESP32

Based on: https://github.com/Samsung/TizenRT/blob/master/build/configs/esp_wrover_kit/README.md

Making romfs.img...
/comum/workspace/ESP32/TizenRT/tools/fs/../../os/../build/output/bin/romfs.img was made.
######################################
##          Library Sizes           ##
######################################
	.text 	.data 	.bss 	 Total
	20 	158176 	69440 	227636 	libnet.a
	340 	8544 	118666 	127550 	libnet80211.a
	1824 	1492 	75100 	78416 	libapps.a
	1244 	5308 	59712 	66264 	libpp.a
	208 	2276 	36984 	39468 	libmesh.a
	1306 	926 	35620 	37852 	libphy.a
	0 	40 	35008 	35048 	libfs.a
	0 	684 	20812 	21496 	libwpa.a
	36 	1552 	18308 	19896 	NOLIB
	108 	560 	18768 	19436 	libexternal.a
	0 	2244 	16272 	18516 	libkernel.a
	472 	501 	15688 	16661 	libesp32.a
	272 	1388 	11568 	13228 	libarch.a
	288 	144 	5256 	5688 	libframework.a
	0 	8 	4820 	4828 	libdrivers.a
	280 	120 	3516 	3916 	libcoexist.a
	0 	0 	3448 	3448 	libgcc.a
	4 	4 	1904 	1912 	librtc.a
	0 	4 	1844 	1848 	libc.a
	0 	43 	800 	843 	libcore.a
	0 	0 	780 	780 	libmm.a
	0 	0 	780 	780 	libboard.a
	0 	0 	102 	102 	libsoc.a
	4 	1 	0 	5 	libwpa2.a
	0 	1 	0 	1 	libwps.a
alan@dev:/comum/workspace/ESP32/TizenRT/os$ make download ALL
 ALL
make -C ../build/tools/esp32  ALL
make[1]: Entering directory '/comum/workspace/ESP32/TizenRT/build/tools/esp32'
python  /comum/workspace/ESP32/TizenRT/build/tools/esp32/esptool_py/esptool/esptool.py --chip esp32 elf2image --flash_mode "dio" --flash_freq "26m" --flash_size "4MB"  -o /comum/workspace/ESP32/TizenRT/build/tools/esp32/../../output/bin/tinyara.bin /comum/workspace/ESP32/TizenRT/build/tools/esp32/../../output/bin/tinyara.elf
esptool.py v2.5.0
Building partitions from /comum/workspace/ESP32/TizenRT/build/tools/esp32/partiton_table/partitions_singleapp.csv...
python  /comum/workspace/ESP32/TizenRT/build/tools/esp32/partiton_table/gen_esp32part.py -q   --offset 0x8000  /comum/workspace/ESP32/TizenRT/build/tools/esp32/partiton_table/partitions_singleapp.csv /comum/workspace/ESP32/TizenRT/build/tools/esp32/../../output/bin/partitions_singleapp.bin
Flashing binaries to serial port /dev/ttyUSB0 (app at offset 0x10000 )...
python  /comum/workspace/ESP32/TizenRT/build/tools/esp32/esptool_py/esptool/esptool.py --chip esp32 --port "/dev/ttyUSB0" --baud 230400 --before "default_reset" --after "hard_reset" write_flash -u --flash_mode "dio" --flash_freq "26m" --flash_size detect 0x8000 /comum/workspace/ESP32/TizenRT/build/tools/esp32/../../output/bin/partitions_singleapp.bin 0x10000  /comum/workspace/ESP32/TizenRT/build/tools/esp32/../../output/bin/tinyara.bin 0x1000 /comum/workspace/ESP32/TizenRT/build/tools/esp32/bootloader/bootloader.bin
esptool.py v2.5.0
Serial port /dev/ttyUSB0
Connecting......
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse
MAC: 24:0a:c4:a6:04:28
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 230400
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Wrote 16384 bytes at 0x00008000 in 0.7 seconds (181.5 kbit/s)...
Hash of data verified.
Wrote 671744 bytes at 0x00010000 in 30.0 seconds (178.9 kbit/s)...
Hash of data verified.
Flash params set to 0x0221
Wrote 32768 bytes at 0x00001000 in 1.5 seconds (177.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Flashing romfs image to serial port /dev/ttyUSB0, offset 0x003C0000...
python  /comum/workspace/ESP32/TizenRT/build/tools/esp32/esptool_py/esptool/esptool.py --chip esp32 --port "/dev/ttyUSB0" --baud 230400 --before "default_reset" --after "hard_reset" write_flash -u --flash_mode "dio" --flash_freq "26m" --flash_size detect 0x003C0000 /comum/workspace/ESP32/TizenRT/build/tools/esp32/../../output/bin/romfs.img
esptool.py v2.5.0
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse
MAC: 24:0a:c4:a6:04:28
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 230400
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Wrote 16384 bytes at 0x003c0000 in 0.7 seconds (180.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
make[1]: Leaving directory '/comum/workspace/ESP32/TizenRT/build/tools/esp32'
alan@dev:/comum/workspace/ESP32/TizenRT/os$ make download BOOTLOADER
 BOOTLOADER
make -C ../build/tools/esp32  BOOTLOADER
make[1]: Entering directory '/comum/workspace/ESP32/TizenRT/build/tools/esp32'
Flashing bootloader to serial port /dev/ttyUSB0 (app at offset 0x1000)...
python  /comum/workspace/ESP32/TizenRT/build/tools/esp32/esptool_py/esptool/esptool.py --chip esp32 --port "/dev/ttyUSB0" --baud 230400 --before "default_reset" --after "hard_reset" write_flash -u --flash_mode "dio" --flash_freq "26m" --flash_size detect 0x1000 /comum/workspace/ESP32/TizenRT/build/tools/esp32/bootloader/bootloader.bin
esptool.py v2.5.0
Serial port /dev/ttyUSB0
Connecting......
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse
MAC: 24:0a:c4:a6:04:28
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 230400
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0221
Wrote 32768 bytes at 0x00001000 in 1.5 seconds (178.4 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
make[1]: Leaving directory '/comum/workspace/ESP32/TizenRT/build/tools/esp32'
alan@dev:/comum/workspace/ESP32/TizenRT/os$ make download APP
 APP
make -C ../build/tools/esp32  APP
make[1]: Entering directory '/comum/workspace/ESP32/TizenRT/build/tools/esp32'
make[1]: *** No rule to make target 'APP'.  Stop.
make[1]: Leaving directory '/comum/workspace/ESP32/TizenRT/build/tools/esp32'
make: *** [Makefile.unix:556: download] Error 2

After the firmware flashed enter on “minicom” (115200 8N1), you will see:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5752
load:0x40078000,len:9020
load:0x40080000,len:6064
entry 0x40080330
I (29) boot: ESP-IDF v3.1-dirty 2nd stage bootloader
I (29) boot: compile time 18:12:49
I (41) boot: Enabling RNG early entropy source...
I (41) boot: SPI Speed      : 40MHz
I (41) boot: SPI Mode       : DIO
I (44) boot: SPI Flash Size : 4MB
I (49) boot: Partition Table:
I (52) boot: ## Label            Usage          Type ST Offset   Length
I (59) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (67) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (74) boot:  2 factory          factory app      00 00 00010000 00280000
I (82) boot: End of partition table
I (86) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x1824c ( 98892) map
I (130) esp_image: segment 1: paddr=0x00028274 vaddr=0x3ffb0000 size=0x01908 (  6408) load
I (132) esp_image: segment 2: paddr=0x00029b84 vaddr=0x40080000 size=0x00400 (  1024) load
I (137) esp_image: segment 3: paddr=0x00029f8c vaddr=0x40080400 size=0x06084 ( 24708) load
I (156) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x7e49c (517276) map
I (337) esp_image: segment 5: paddr=0x000ae4bc vaddr=0x40086484 size=0x02fa4 ( 12196) load
I (342) esp_image: segment 6: paddr=0x000b1468 vaddr=0x400c0000 size=0x00000 (     0) load
I (349) boot: Loaded app from partition at offset 0x10000
I (350) boot: Disabling RNG early entropy source...
ftl_ioctl: ERROR: MTD ioctl(0602) failed: -25
System Information:
        Version: 3.0
        Commit Hash: 650dfcd4b54a3d132e8753c4b4d8c41f3a1e0008
        Build User: alan@dev
        Build Time: 2020-06-12 11:46:12
        System Time: 06 Dec 2011, 00:00:00 [s] UTC 
TASH>>Hello, World!!
up_assert: Assertion failed at file:semaphore/sem_post.c line: 142 task: tash
xtensa_dumpstate: sp:         3ffe9648
xtensa_dumpstate: stack base: 3ffe9a48
xtensa_dumpstate: stack size: 0000103c
xtensa_stackdump: 3ffe9640: 0000004e 3f400e68 3ebdd8d9 ac32691d 6e3bb180 2c8c1ffb 3ffe9688 3ffe9668
xtensa_stackdump: 3ffe9660: 00000008 0ec148f7 1f55f435 a13fccfe 3f400f05 3f400c1e 800d4999 3ffe96a8
xtensa_stackdump: 3ffe9680: 3f400c1e 0000008e 3f400f05 3f400c1e 0000008e 3ffe85d0 800fd4aa 3ffe96c8
xtensa_stackdump: 3ffe96a0: 3ffe9968 00007fff 00000002 00000004 0000001f ffffffff 800fd4f9 3ffe96e8
xtensa_stackdump: 3ffe96c0: 3ffb00e8 00000002 00060523 3ffe97c8 00018044 000637ff 8014caf8 3ffe9708
xtensa_stackdump: 3ffe96e0: 3ffb007c 00000000 3ffb00e0 000000ff 3ffb00e8 0000007e 800d661e 3ffe9728
xtensa_stackdump: 3ffe9700: 3ffb007c 400fd4d8 3ffb61a8 3ffb1924 3ffb5e88 00000007 8010179a 3ffe9748
xtensa_stackdump: 3ffe9720: 00000000 0000001c 000000da 00000001 00000000 3ffb5fb0 800d617a 3ffe9768
xtensa_stackdump: 3ffe9740: 00000026 3ffe97c8 3ffb007c 000000ff 3ffb00e8 0000007e 800d5ee4 3ffe9788
xtensa_stackdump: 3ffe9760: 00000026 3ffe97c8 0000000f 3ffe98e8 3ffb1b34 3ffb5fec 400806d0 3ffe97a8
xtensa_stackdump: 3ffe9780: 00000000 3ffe97c8 3ffb61a8 3ffe84d0 3ffb5e88 00060e23 00040023 3ffe97c8
xtensa_stackdump: 3ffe97a0: 00018044 000637ff 00000002 00000004 0000001f ffffffff eef5989e 1e195405
xtensa_stackdump: 3ffe97c0: 1af1dd1f 44c22654 400f7d18 00060e30 800f82a2 3ffe9968 3ffe9b00 00000001
xtensa_stackdump: 3ffe97e0: 0edeafb8 00000000 00060e20 4edd5b06 800f7cff 3ffe9928 00000000 00000000
xtensa_stackdump: 3ffe9800: 3ffe84d0 00000000 00060e23 00000001 00000018 c09c93de cfac8e88 00000000
xtensa_stackdump: 3ffe9820: 00000000 00000000 400806ac 3ffe97c8 f637eb10 7f24dd94 816928f7 0e89e754
xtensa_stackdump: 3ffe9840: 3490f07c f14873f5 65dbf240 9ea7a3c4 f7fc150d 3c069485 2cc80f80 bc51bcbc
xtensa_stackdump: 3ffe9860: 177f5cf2 1284b777 f7b50c98 bcecc143 f2b993c2 c44a09ba 9f1470fa 8790438e
xtensa_stackdump: 3ffe9880: f4f7a8b4 363720c5 5ac53e9c 56cabdd2 fcac9b10 95f2d2a9 fdac54c2 9372b47b
xtensa_stackdump: 3ffe98a0: 5f874464 40e4ffda 3bbba1c2 1085bbf7 2e8c3d87 c2574fcc 092cc606 7340f44b
xtensa_stackdump: 3ffe98c0: c54639f5 02c9f733 800d48da 3ffe98e8 0000000a 00000090 80101cb0 3ffe9908
xtensa_stackdump: 3ffe98e0: 3ffe9968 00060e23 3ffe7730 00000001 3ffe84d0 3ffdfa0b 800f7cff 3ffe9928
xtensa_stackdump: 3ffe9900: 3ffe9968 00000000 3ffe84d0 00000000 00000000 00060e23 800f82a2 3ffe9968
xtensa_stackdump: 3ffe9920: 3ffe9b00 00000001 0000025a 71846df7 ddf54310 8e01fbfc 3ffb1b34 0edeafb8
xtensa_stackdump: 3ffe9940: 3ffe9b00 00000001 3ffe84d0 0000025a 00060e23 00000001 800d76f3 3ffe99a8
xtensa_stackdump: 3ffe9960: 000002ee 3ffe99e0 80077fff 00000000 4edd5b06 0edeafb8 00000000 00000000
xtensa_stackdump: 3ffe9980: 00000004 3ffe99e0 0edeafb8 3b9ac9ff 00060e20 4edd5b06 800d3738 3ffe99d8
xtensa_stackdump: 3ffe99a0: 3ffe9a70 00000003 00000001 3ffb5e88 00000001 3ffe9a4c 00000000 00000000
xtensa_stackdump: 3ffe99c0: 00000000 3ffe9b00 00000000 3ffe9a28 400d7634 00000000 00000006 00000000
xtensa_stackdump: 3ffe99e0: 00000008 00000000 00000008 831131a4 00000008 00000004 71fb95a1 6246dfb8
xtensa_stackdump: 3ffe9a00: 72280a85 f10a2eeb 00000008 00000008 00000000 3ffe99e0 00000000 3ffe9a48
xtensa_stackdump: 3ffe9a20: 00000000 00000000 00000000 00000000 00000000 00000000 66a51225 402c4fef
xtensa_stackdump: 3ffe9a40: 77242109 5d837785 6e3f512e 3ffe9a54 00000000 68736174 ed6ae100 0e4a6791
xtensa_registerdump:    PC: 400f7d18    PS: 00060e30
xtensa_registerdump:    A0: 800f82a2    A1: 3ffe9968    A2: 3ffe9b00    A3: 00000001
xtensa_registerdump:    A4: 0edeafb8    A5: 00000000    A6: 00060e20    A7: 4edd5b06
xtensa_registerdump:    A8: 800f7cff    A9: 3ffe9928   A10: 00000000   A11: 00000000
xtensa_registerdump:   A12: 3ffe84d0   A13: 00000000   A14: 00060e23   A15: 00000001
xtensa_registerdump:   SAR: 00000018 CAUSE: c09c93de VADDR: cfac8e88
xtensa_registerdump:  LBEG: 00000000  LEND: 00000000  LCNT: 00000000
xtensa_registerdump:  TMP0: 400806ac  TMP1: 3ffe97c8

Removing python 2.7 from Ubuntu 20.20

As you know Python 2.7 is deprecated and shouldn’t be used after Jan 1 2020: https://www.python.org/doc/sunset-python-2/

Yet Ubuntu 20.20 comes with “python” defined to python 2.7!

I faced many issues recently because “pip” wasn’t present and today while installing Espressif IDF 4.2 I got many errors because python 2.7 still used on Ubuntu.

I solved my issues removing python 2 and installing python3 as default:

$ sudo apt purge python2.7-minimal
$ sudo apt install python-is-python3

After doing it I got IDF installed correctly.

Sometimes you can run in circle on Linux, just be careful

Today I found the interesting presentation about why Linux still sucks even on 2020:

Linux Sucks 2020: https://www.youtube.com/watch?v=cZN5n6C9gM4

Each year the author of this presentation updates it and present again.

Although I’m Linux only since 1999, I think he is right and many points.

And today a funny thing happen to me: I decided to test NuttX on ESP32 and because I already did it in the past I decied to follow my own post: https://acassis.wordpress.com/2018/01/04/running-nuttx-on-esp32-board/

$ sudo pip install esptool
sudo: pip: command not found

Strange, I though Ubuntu should come with it…

$ pip
Command 'pip' not found, but there are 18 similar ones.

No, it is not where!

Let’s to install it using pip:

$ sudo apt install pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package pip

After some seconds searching on google…

Found a stackoverflow!!!

https://stackoverflow.com/questions/9780717/bash-pip-command-not-found

“Why not just do sudo easy_install pip or if this is for python 2.6 sudo easy_install-2.6 pip?”

It has 508 hits, it can’t be wrong!

$ sudo easy_install pip
sudo: easy_install: command not found

Arrggg, “easy_install” is not installed

Let’s to install it:

$ sudo apt install easy_install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package easy_install

Probably the package has other name!

Wait, I have the fantastic “apt-file”, let’s ask it which package has the easy_install

$ apt-file search easy_install
ansible: /usr/lib/python3/dist-packages/ansible/modules/packaging/language/easy_install.py
ansible-doc: /usr/share/doc/ansible/html/modules/easy_install_module.html
pypy-setuptools: /usr/lib/pypy/dist-packages/easy_install.py
pypy-setuptools: /usr/lib/pypy/dist-packages/setuptools/command/easy_install.py
python-setuptools: /usr/lib/python2.7/dist-packages/easy_install.py
python-setuptools: /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py
python-setuptools: /usr/share/doc/python-setuptools/easy_install.txt.gz
python-setuptools-doc: /usr/share/doc/python-setuptools-doc/html/_sources/easy_install.txt
python-setuptools-doc: /usr/share/doc/python-setuptools-doc/html/easy_install.html
python3-setuptools: /usr/lib/python3/dist-packages/easy_install.py
python3-setuptools: /usr/lib/python3/dist-packages/setuptools/command/easy_install.py
python3-setuptools: /usr/share/doc/python3-setuptools/easy_install.txt.gz
python3-zc.buildout: /usr/lib/python3/dist-packages/zc/buildout/easy_install.py
python3-zc.buildout: /usr/lib/python3/dist-packages/zc/buildout/easy_install.txt
python3-zc.buildout: /usr/share/doc/python3-zc.buildout/reference/easy_install.txt.gz

Because I’m using python3, it should be python3-setuptools

$ sudo apt install python3-setuptools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libjaylink0 libjim0.79
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  python-setuptools-doc
The following NEW packages will be installed:
  python3-setuptools
0 upgraded, 1 newly installed, 0 to remove and 129 not upgraded.
Need to get 330 kB of archives.
After this operation, 1.466 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-setuptools all 45.2.0-1 [330 kB]
Fetched 330 kB in 1s (255 kB/s)             
Selecting previously unselected package python3-setuptools.
(Reading database ... 268191 files and directories currently installed.)
Preparing to unpack .../python3-setuptools_45.2.0-1_all.deb ...
Unpacking python3-setuptools (45.2.0-1) ...
Setting up python3-setuptools (45.2.0-1) ...

Now it should work!

$ sudo easy_install pip
sudo: easy_install: command not found

Oh!!! Come on!!!

Let’s see what is inside python3-setuptools:

$ dpkg -L python3-setuptools
...
/usr/lib/python3/dist-packages/easy_install.py
/usr/share/doc/python3-setuptools/easy_install.txt.gz
/usr/share/doc/python3-setuptools/formats.txt.gz
/usr/share/doc/python3-setuptools/history.txt
/usr/share/doc/python3-setuptools/index.txt
/usr/share/doc/python3-setuptools/python3.txt
/usr/share/doc/python3-setuptools/releases.txt
/usr/share/doc/python3-setuptools/roadmap.txt
/usr/share/doc/python3-setuptools/setuptools.txt.gz
/usr/share/doc/python3-setuptools/changelog.Debian.gz

Hmm, there is a easy_install.txt.gz file inside the python3-setuptools, it should be useful:

$ vi /usr/share/doc/python3-setuptools/easy_install.txt.gz



.. warning::
    Easy Install is deprecated. Do not use it. Instead use pip. If
    you think you need Easy Install, please reach out to the PyPA
    team (a ticket to pip or setuptools is fine), describing your
    use-case.

Damn it! I’m trying to use “pip” from start!

I should just have search for it using apt-file and filter for bin directories:

$ apt-file search pip | grep bin
….
python3-pip: /usr/bin/pip3
python3-pipdeptree: /usr/bin/pipdeptree
rt-tests: /usr/bin/pip_stress
rubber: /usr/bin/rubber-pipe

Ok, the package python3-pip appears promising…

Let’s to install it:

$ sudo apt install python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libjaylink0 libjim0.79
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  python-pip-whl python3-wheel
The following NEW packages will be installed:
  python-pip-whl python3-pip python3-wheel
0 upgraded, 3 newly installed, 0 to remove and 129 not upgraded.
Need to get 2.053 kB of archives.
After this operation, 3.455 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://br.archive.ubuntu.com/ubuntu focal/universe amd64 python-pip-whl all 20.0.2-5ubuntu1 [1.799 kB]
Get:2 http://br.archive.ubuntu.com/ubuntu focal/universe amd64 python3-wheel all 0.34.2-1 [23,8 kB]
Get:3 http://br.archive.ubuntu.com/ubuntu focal/universe amd64 python3-pip all 20.0.2-5ubuntu1 [230 kB]
Fetched 2.053 kB in 1s (1.736 kB/s)  
Selecting previously unselected package python-pip-whl.
(Reading database ... 268295 files and directories currently installed.)
Preparing to unpack .../python-pip-whl_20.0.2-5ubuntu1_all.deb ...
Unpacking python-pip-whl (20.0.2-5ubuntu1) ...
Selecting previously unselected package python3-wheel.
Preparing to unpack .../python3-wheel_0.34.2-1_all.deb ...
Unpacking python3-wheel (0.34.2-1) ...
Selecting previously unselected package python3-pip.
Preparing to unpack .../python3-pip_20.0.2-5ubuntu1_all.deb ...
Unpacking python3-pip (20.0.2-5ubuntu1) ...
Setting up python3-wheel (0.34.2-1) ...
Setting up python-pip-whl (20.0.2-5ubuntu1) ...
Setting up python3-pip (20.0.2-5ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...

And finally I need to use pip3 instead pip:

$ sudo pip3 install esptool
Collecting esptool
  Downloading esptool-2.8.tar.gz (84 kB)
     |████████████████████████████████| 84 kB 961 kB/s 
Collecting ecdsa
  Downloading ecdsa-0.15-py2.py3-none-any.whl (100 kB)
     |████████████████████████████████| 100 kB 2.2 MB/s 
Collecting pyaes
  Downloading pyaes-1.6.1.tar.gz (28 kB)
Collecting pyserial>=3.0
  Downloading pyserial-3.4-py2.py3-none-any.whl (193 kB)
     |████████████████████████████████| 193 kB 3.3 MB/s 
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3/dist-packages (from ecdsa->esptool) (1.14.0)
Building wheels for collected packages: esptool, pyaes
  Building wheel for esptool (setup.py) ... done
  Created wheel for esptool: filename=esptool-2.8-py3-none-any.whl size=142114 sha256=c5b3fd7c8d295624dea3a3f30141063ad870efa929e85069a47c7cf311421733
  Stored in directory: /root/.cache/pip/wheels/4a/4c/c7/aa45baeba596ab0e9d624a32e3f5680db5aed6773ae1ffa5ed
  Building wheel for pyaes (setup.py) ... done
  Created wheel for pyaes: filename=pyaes-1.6.1-py3-none-any.whl size=26345 sha256=9d9a353e43d3ae217edf90d80eedf14393aab7a2288949d1b2118598c55a823b
  Stored in directory: /root/.cache/pip/wheels/aa/ca/9c/8a3c00512585c703edc457db81c066b9609d76758c74f72ac6
Successfully built esptool pyaes
Installing collected packages: ecdsa, pyaes, pyserial, esptool
Successfully installed ecdsa-0.15 esptool-2.8 pyaes-1.6.1 pyserial-3.4

As you can see I spend some time just because I forgot to use the right command. I should have started search for “pip” using the apt-file command.

But also the package names on Linux should be more intuitive and follow the name of the specific command.

Flashing the BlackPill on Linux using dfu-util

If you read my previous post you know I was facing many issues to flash the firmware on BlackPill using the SWD programmer (STLinkV2, JLink, etc).

Finally I got it working! Let check it out!

These are the step to get NuttX running on BlackPill:

Clone NuttX and Apps:

$ git clone https://github.com/apache/incubator-nuttx nuttx
$ git clone https://github.com/apache/incubator-nuttx-apps apps

Configure and Compile the NuttX:

$ cd nuttx
$ ./tools/configure.sh stm32f411-minimum:nsh
$ make menuconfig  (### This Command is Optional ###)
$ make

It will create the nuttx.bin file!

Then I remembered that the STM32F4 family has DFU support, using it I was able to flash the board:

1) Remove the USB cable
2) Press and Hold the buttons NRST and BOOT0
3) Connect the cable
4) Release the NRST button
5) Wait 1 second
6) Release the BOOT0

$ dmesg

[ 8203.223506] usb 1-2: new full-speed USB device number 38 using xhci_hcd
[ 8203.372844] usb 1-2: New USB device found, idVendor=0483, idProduct=df11, bcdDevice=22.00
[ 8203.372849] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 8203.372852] usb 1-2: Product: STM32  BOOTLOADER
[ 8203.372855] usb 1-2: Manufacturer: STMicroelectronics
[ 8203.372857] usb 1-2: SerialNumber: 3870XXXXXXXX


$ sudo apt install dfu-util

$ sudo dfu-util -l
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [0483:df11] ver=2200, devnum=38, cfg=1, intf=0, path="1-2", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="387035953339"
Found DFU: [0483:df11] ver=2200, devnum=38, cfg=1, intf=0, path="1-2", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="387035953339"
Found DFU: [0483:df11] ver=2200, devnum=38, cfg=1, intf=0, path="1-2", alt=1, name="@Option Bytes  /0x1FFFC000/01*016 e", serial="387035953339"
Found DFU: [0483:df11] ver=2200, devnum=38, cfg=1, intf=0, path="1-2", alt=0, name="@Internal Flash  /0x08000000/04*016Kg,01*064Kg,03*128Kg", serial="387035953339"


$ sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D nuttx.bin
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash  "
Downloading to address = 0x08000000, size = 53664
Download	[=========================] 100%        53664 bytes
Download done.
File downloaded successfully
Transitioning to dfuMANIFEST state

After flashing, connect the USB/Serial RXD to pin label A2 and the TXD to pin label A3.

Use the minicom or other serial console tool configured to 115200, you should see:

NuttShell (NSH) NuttX-9.0.0
nsh> ?
help usage:  help [-v] [<cmd>]

  .         cd        echo      kill      mount     set       uname     
  [         cp        exec      ls        mv        sleep     umount    
  ?         cmp       exit      mb        mw        source    unset     
  basename  dirname   false     mkdir     pwd       test      usleep    
  break     date      help      mkrd      rm        time      xd        
  cat       dd        hexdump   mh        rmdir     true      

Builtin Apps:
  sh   nsh  
nsh> 

Flashing the BlackPill (STM32F411CEU6)

I was having a hard time trying to flash the firmware nuttx.bin on BlackPill board. Initially I tried OpenOCD with STLinkV2 as I used to with the BluePill, but it didn’t work. Then I tried a Atmel-ICE SWD programmer with OpenOCD and no luck. So I decided to try using JLink too.

JLink also didn’t work, none of these programmer was communicating with the board, but I knew the board was fine because the blue LED (C13 label) was dimming (fade in and fade out).

I notice that after plugging the USB-C cable on the board the program delays about 1s to start dimming the LED, to I decided to run the “connect” command on JLink prompt at same moment I plug the cable. Great it worked.

Well, partially, I was able to detect the MCU, but erase it not working:

J-Link>con
Device "STM32F411CE" selected.


Connecting to target via SWD
Found SW-DP with ID 0x2BA01477
Found SW-DP with ID 0x2BA01477
Scanning AP map to find all available APs
AP[1]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x24770011)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 0 code (BP) slots and 3 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][1]: E000E000, CID: B105E00D, PID: 0BB00CB1 ???
ROMTbl[0][2]: E0001000, CID: 05E00D0B, PID: 3BB00205 ???
ROMTbl[0][3]: E0002000, CID: 05E00D3B, PID: 2BB00305 ???
ROMTbl[0][4]: E00FF000, CID: 05100D00, PID: 0A041105 ???
ROMTbl[0][5]: E0040000, CID: 05900D0A, PID: 0BB9A105 ???
ROMTbl[0][6]: E0041000, CID: 05900D0B, PID: 0BB92505 ???
Cortex-M4 identified.
J-Link>erase

**************************
WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
**************************

Erasing device...

****** Error: Verification of RAMCode failed @ address 0x20000000.
Write: 0xA801BE00 F0009900
Read: 0x0000100A A801BE00
Failed to prepare for programming.
Failed to download RAMCode!
ERROR: Erase returned with error code -1.
J-Link>

Then I found this post at segger website and decided to test the suggested commands: https://forum.segger.com/index.php/Thread/2723-SOLVED-Bricking-STM32F4-after-failed-programming/

J-Link>r
Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
J-Link>h
PC = 080001AC, CycleCnt = 00000000
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000
SP(R13)= 20001AD0, MSP= 20001AD0, PSP= 00000000, R14(LR) = FFFFFFFF
XPSR = 01000000: APSR = nzcvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00

FPS0 = 00000000, FPS1 = 00000000, FPS2 = 00000000, FPS3 = 00000000
FPS4 = 00000000, FPS5 = 00000000, FPS6 = 00000000, FPS7 = 00000000
FPS8 = 00000000, FPS9 = 00000000, FPS10= 00000000, FPS11= 00000000
FPS12= 00000000, FPS13= 00000000, FPS14= 00000000, FPS15= 00000000
FPS16= 00000000, FPS17= 00000000, FPS18= 00000000, FPS19= 00000000
FPS20= 00000000, FPS21= 00000000, FPS22= 00000000, FPS23= 00000000
FPS24= 00000000, FPS25= 00000000, FPS26= 00000000, FPS27= 00000000
FPS28= 00000000, FPS29= 00000000, FPS30= 00000000, FPS31= 00000000
FPSCR= 00000000
J-Link>mem 0x8000000, 0x800
08000000 = D0 1A 00 20 AD 01 00 08 1F 19 00 08 35 17 00 08 
08000010 = 1D 19 00 08 4F 03 00 08 E9 2F 00 08 00 00 00 00 
08000020 = 00 00 00 00 00 00 00 00 00 00 00 00 59 19 00 08 
08000030 = 85 03 00 08 00 00 00 00 2D 19 00 08 5B 19 00 08 
08000040 = C7 01 00 08 C7 01 00 08 C7 01 00 08 C7 01 00 08 
08000050 = C7 01 00 08 C7 01 00 08 C7 01 00 08 C7 01 00 08 
08000060 = C7 01 00 08 C7 01 00 08 C7 01 00 08 C7 01 00 08 
08000070 = C7 01 00 08 C7 01 00 08 C7 01 00 08 C7 01 00 08 
08000080 = C7 01 00 08 C7 01 00 08 C7 01 00 08 00 00 00 00 
08000090 = 00 00 00 00 00 00 00 00 00 00 00 00 C7 01 00 08 
080000A0 = C7 01 00 08 C7 01 00 08 C7 01 00 08 C7 01 00 08 
080000B0 = C7 01 00 08 C7 01 00 08 C7 01 00 08 C7 01 00 08 
080000C0 = C7 01 00 08 C7 01 00 08 C7 01 00 08 C7 01 00 08 
080000D0 = C7 01 00 08 C7 01 00 08 C7 01 00 08 00 00 00 00 
080000E0 = C7 01 00 08 C7 01 00 08 C7 01 00 08 00 00 00 00 
080000F0 = 00 00 00 00 00 00 00 00 00 00 00 00 C7 01 00 08 
08000100 = 00 00 00 00 C7 01 00 08 C7 01 00 08 C7 01 00 08 
08000110 = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
08000120 = C7 01 00 08 C7 01 00 08 C7 01 00 08 C7 01 00 08 
08000130 = C7 01 00 08 00 00 00 00 00 00 00 00 00 00 00 00 
08000140 = 00 00 00 00 00 00 00 00 00 00 00 00 21 19 00 08 
08000150 = C7 01 00 08 C7 01 00 08 C7 01 00 08 C7 01 00 08 
08000160 = C7 01 00 08 C7 01 00 08 00 00 00 00 00 00 00 00 
08000170 = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
08000180 = 00 00 00 00 C7 01 00 08 00 00 00 00 00 00 00 00 
08000190 = C7 01 00 08 C7 01 00 08 DF F8 0C D0 00 F0 9A F8 
080001A0 = 00 48 00 47 C9 33 00 08 D0 1A 00 20 06 48 80 47 
080001B0 = 06 48 00 47 FE E7 FE E7 FE E7 FE E7 FE E7 FE E7 
080001C0 = FE E7 FE E7 FE E7 FE E7 55 1A 00 08 99 01 00 08 
080001D0 = 2D E9 F0 5F 05 46 00 20 92 46 9B 46 88 46 06 46 
080001E0 = 81 46 40 24 1B E0 28 46 41 46 47 46 22 46 00 F0 
080001F0 = 60 F8 53 46 5A 46 C0 1A 91 41 10 D3 11 46 18 46 
08000200 = 22 46 00 F0 47 F8 2D 1A 67 EB 01 08 4F 46 22 46 
08000210 = 01 20 00 21 00 F0 3E F8 17 EB 00 09 4E 41 20 1E 
08000220 = A4 F1 01 04 DF DC 48 46 31 46 2A 46 43 46 BD E8 
08000230 = F0 9F 40 EA 01 03 9B 07 03 D0 09 E0 08 C9 12 1F 
08000240 = 08 C0 04 2A FA D2 03 E0 11 F8 01 3B 00 F8 01 3B 
08000250 = 52 1E F9 D2 70 47 D2 B2 01 E0 00 F8 01 2B 49 1E 
08000260 = FB D2 70 47 00 22 F6 E7 10 B5 13 46 0A 46 04 46 
08000270 = 19 46 FF F7 F0 FF 20 46 10 BD 30 B5 04 46 00 20 
08000280 = 03 46 00 E0 5B 1C 93 42 03 D2 E0 5C CD 5C 40 1B 
08000290 = F8 D0 30 BD 20 2A 04 DB 20 3A 00 FA 02 F1 00 20 
080002A0 = 70 47 91 40 C2 F1 20 03 20 FA 03 F3 19 43 90 40 
080002B0 = 70 47 20 2A 04 DB 20 3A 21 FA 02 F0 00 21 70 47 
080002C0 = 21 FA 02 F3 D0 40 C2 F1 20 02 91 40 08 43 19 46 
080002D0 = 70 47 00 00 06 4C 07 4D 06 E0 E0 68 40 F0 01 03 
080002E0 = 94 E8 07 00 98 47 10 34 AC 42 F6 D3 FF F7 58 FF 
080002F0 = 38 39 00 08 58 39 00 08 70 B5 8C 18 10 F8 01 5B 
08000300 = 15 F0 07 03 01 D1 10 F8 01 3B 2A 11 06 D1 10 F8 
08000310 = 01 2B 03 E0 10 F8 01 6B 01 F8 01 6B 5B 1E F9 D1 
08000320 = 2B 07 05 D4 00 23 52 1E 0D D4 01 F8 01 3B FA E7 
08000330 = 10 F8 01 3B CB 1A 92 1C 03 E0 13 F8 01 5B 01 F8 
08000340 = 01 5B 52 1E F9 D5 A1 42 D8 D3 00 20 70 BD FE E7 
08000350 = 00 20 70 47 00 20 70 47 07 48 08 4A D0 F8 90 02 
08000360 = 00 21 40 29 03 D0 43 5C 53 54 01 31 F9 E7 04 48 
08000370 = 01 21 01 70 00 20 70 47 00 04 00 20 7C 01 00 20 
08000380 = 78 01 00 20 70 47 70 47 DE 4A 03 29 13 68 23 F4 
08000390 = 40 73 13 60 4F F4 40 73 38 BF 0B 02 11 68 19 43 
080003A0 = 11 60 11 68 21 F0 F8 01 11 60 11 68 41 EA C0 00 
080003B0 = 40 F0 02 00 10 60 10 68 40 F4 80 30 10 60 70 47 
080003C0 = 13 48 01 68 89 05 0F D5 01 68 21 F4 00 71 01 60 
080003D0 = 01 68 41 F4 00 61 01 60 01 68 21 F4 00 61 01 60 
080003E0 = 01 68 41 F4 00 71 01 60 01 68 49 05 0F D5 01 68 
080003F0 = 21 F4 80 61 01 60 01 68 41 F4 80 51 01 60 01 68 
08000400 = 21 F4 80 51 01 60 01 68 41 F4 80 61 01 60 70 47 
08000410 = 00 3C 02 40 BB 49 0A 68 22 F4 40 72 0A 60 0A 68 
08000420 = 42 F0 04 02 0A 60 0A 68 42 EA 00 20 40 F4 80 30 
08000430 = 08 60 70 47 B3 4A 13 68 23 F4 40 73 13 60 13 68 
08000440 = 13 60 13 68 43 F0 01 03 13 60 01 70 70 47 00 BF 
08000450 = 10 B5 AC 49 0C 68 24 F4 40 74 0C 60 0C 68 44 F4 
08000460 = 40 74 0C 60 0C 68 44 F0 01 04 0C 60 02 60 BF F3 
08000470 = 6F 8F 43 60 10 BD 00 BF A2 4A 13 68 23 F4 40 73 
08000480 = 13 60 13 68 43 F4 80 73 13 60 13 68 43 F0 01 03 
08000490 = 13 60 01 80 70 47 00 BF 9A 4A 13 68 23 F4 40 73 
080004A0 = 13 60 13 68 43 F4 00 73 13 60 13 68 43 F0 01 03 
080004B0 = 13 60 01 60 70 47 00 BF 32 48 01 68 C9 06 06 D5 
080004C0 = 8F 49 CA 69 42 F0 10 02 CA 61 10 21 01 60 01 68 
080004D0 = 89 06 06 D5 8A 49 CA 69 42 F0 08 02 CA 61 20 21 
080004E0 = 01 60 01 68 49 06 06 D5 85 49 CA 69 42 F0 04 02 
080004F0 = CA 61 40 21 01 60 01 68 09 06 06 D5 80 49 CA 69 
08000500 = 42 F0 02 02 CA 61 80 21 01 60 01 68 C9 05 07 D5 
08000510 = 7B 49 CA 69 42 F0 01 02 CA 61 4F F4 80 71 01 60 
08000520 = 01 68 89 07 06 D5 76 49 CA 69 42 F0 20 02 CA 61 
08000530 = 02 21 01 60 70 47 00 BF F8 B5 04 46 70 48 00 21 
08000540 = 10 4E C1 61 00 F0 46 FA 05 46 67 1C 30 68 C0 03 
08000550 = 09 D5 00 2F FA D0 24 B1 00 F0 3C FA 40 1B A0 42 
08000560 = F4 D9 03 20 F8 BD 30 68 C0 07 1C BF 01 20 30 60 
08000570 = 30 68 10 F4 F9 7F 03 D0 FF F7 9E FF 01 20 F8 BD 
08000580 = 00 20 F8 BD 0C 3C 02 40 80 B5 09 48 4F F0 FF 31 
08000590 = 00 22 01 61 02 61 41 61 42 61 01 60 02 60 41 60 
080005A0 = 42 60 81 60 82 60 00 F0 5D FA 00 20 80 BD 00 BF 
080005B0 = 10 38 02 40 B0 B5 04 46 00 F0 0C FA 05 46 05 48 
080005C0 = 61 1C 00 78 18 BF 04 44 00 F0 04 FA 40 1B A0 42 
080005D0 = FA D3 B0 BD 18 00 00 20 2D E9 F8 43 DF F8 20 81 
080005E0 = 05 46 98 F8 18 00 01 28 01 D1 02 26 3E E0 01 20 
080005F0 = 88 F8 18 00 4C F2 50 30 89 46 FF F7 9D FF 06 46 
08000600 = 88 BB 4F F0 FF 30 C9 F8 00 00 28 68 3D 4C 01 28 
08000610 = 0C D1 28 7C FF F7 FE FE 4C F2 50 30 FF F7 8C FF 
08000620 = 06 46 20 68 20 F0 04 00 20 60 1A E0 A8 68 07 46 
08000630 = E9 68 08 44 87 42 10 D2 29 7C 38 46 FF F7 A4 FE 
08000640 = 4C F2 50 30 FF F7 78 FF 06 46 20 68 20 F0 FA 00 
08000650 = 20 60 26 B9 A8 68 01 37 EA E7 00 26 01 E0 C9 F8 
08000660 = 00 70 FF F7 AD FE 00 20 88 F8 18 00 30 46 BD E8 
08000670 = F8 83 00 BF 23 48 01 68 41 F0 00 41 01 60 00 20 
08000680 = 70 47 00 BF 2D E9 F0 41 DF F8 74 80 07 46 98 F8 
08000690 = 18 00 01 28 04 BF 02 20 BD E8 F0 81 01 20 88 F8 
080006A0 = 18 00 4C F2 50 30 1E 46 14 46 0D 46 FF F7 44 FF 
080006B0 = 08 BB 02 2F 07 D0 01 2F 0A D0 77 B9 E1 B2 28 46 
080006C0 = FF F7 B8 FE 0E E0 28 46 21 46 FF F7 E5 FE 09 E0 
080006D0 = A1 B2 28 46 FF F7 D0 FE 04 E0 28 46 22 46 33 46 
080006E0 = FF F7 B6 FE 4C F2 50 30 FF F7 26 FF 05 49 0A 68 
080006F0 = 22 F0 01 02 0A 60 00 21 88 F8 18 10 BD E8 F0 81 
08000700 = A4 0A 00 20 10 3C 02 40 06 48 C1 68 B1 F1 FF 3F 
08000710 = C4 BF 00 20 70 47 04 49 01 60 04 49 01 60 C0 68 
08000720 = C0 0F 70 47 04 3C 02 40 23 01 67 45 AB 89 EF CD 
08000730 = 2D E9 F8 4F 94 4A 07 24 90 42 94 4A 08 BF 04 24 
08000740 = 02 44 4F EA B2 23 04 2B 38 BF 4F EA B2 24 90 4A 
08000750 = 00 94 4F F0 00 0A 01 23 0F 24 A2 F5 7E 7B 4F F0 
08000760 = 00 09 00 27 10 2F 08 BF BD E8 F8 8F 03 FA 07 F2 
08000770 = 0A 42 40 D0 0A F0 0C 0C 04 FA 0C F8 BC 08 5B F8 
08000780 = 24 E0 00 9B 0E EA 08 05 03 FA 0C F6 D2 43 B5 42 
08000790 = 13 D1 7F 4B 1D 68 15 40 1D 60 5D 68 15 40 5D 60 
080007A0 = 9D 68 15 40 9D 60 7B 4B 1D 68 15 40 1D 60 5B F8 
080007B0 = 24 50 25 EA 08 05 4B F8 24 50 03 23 05 68 03 FA 
080007C0 = 09 F4 A5 43 05 60 0A F0 1C 05 0F 23 03 FA 05 F5 
080007D0 = 6F F0 03 03 03 EA 57 06 06 44 33 6A AB 43 33 62 
080007E0 = C3 68 A3 43 C3 60 43 68 1A 40 42 60 82 68 01 23 
080007F0 = A2 43 0F 24 82 60 0A F1 04 0A 09 F1 02 09 01 37 
J-Link>mem 0x1fffc000, 8
1FFFC000 = EF AA 10 55 EF AA 10 55 
J-Link>mem 0x1fffc008, 8
1FFFC008 = FF 7F 00 80 FF 7F 00 80 
J-Link>

I found how to unlock the flash of STM32F4 family ( https://wiki.segger.com/images/c/cd/STM32F4_Lock.jlink ) :

J-Link>w4 0x40023C08 0x08192A3B
Writing 08192A3B -> 40023C08
J-Link>w4 0x40023C08 0x4C5D6E7F
Writing 4C5D6E7F -> 40023C08
J-Link>w1 0x40023C15 0xAA
Writing AA -> 40023C15
J-Link>w1 0x40023C14 0x55
Writing 55 -> 40023C14
J-Link>w1 0x40023C14 0xED
Writing ED -> 40023C14
J-Link>

But even after doing it the board is not responding correctly:

J-Link>erase
Erasing device...
Comparing flash   [100%] Done.
Erasing flash     [005%]
****** Error: Failed to erase sectors 0 @ address 0x08000000 (unspecified error)
Failed to erase sectors.

100%] Done.
Verifying flash   [100%] Done.

**************************
WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
**************************

J-Link: Flash download: Total time needed: 0.165s (Prepare: 0.098s, Compare: 0.000s, Erase: 0.001s, Program: 0.000s, Verify: 0.000s, Restore: 0.065s)

**************************
WARNING: Core did not halt after single step
**************************

ERROR: Erase returned with error code -5.


J-Link>loadbin nuttx.bin 0
Downloading file [nuttx.bin]...
Comparing flash   [100%] Done.
Erasing flash     [100%] Done.
Programming flash [100%] Done.
Verifying flash   [100%] Done.
Error while programming flash: Programming failed.
J-Link>

At least now the original program that came with the board is not running, the flash was partially formatted I suppose.

Update: after flashing NuttX using DFU I noticed that SWD started to work. So I think the bootloader that guys from WeAct (the company that developed this board) was locking the SWD.