I have the TUMPA JTAG v2 board, connected to the ESP32 DevKitC board.
The connection works fine and OpenOCD and gdb is properly setup.
In my main.c, I am using the following function:
Code: Select all
#define RAND_REGCOUNT 32 // * 4 bytes = 1kByte
uint32_t IRAM_ATTR esp_random_custom(void) {
uint32_t retval; // in order to print the variable using GDB
retval = REG_READ(WDEV_RND_REG);
return retval;
}
static void rnd_task(void *pvParameter)
{
for(;;){
printf("Sampling...");
//uint32_t* randNumbers = pvPortMallocCaps(RAND_REGCOUNT*4, MALLOC_CAP_32BIT);
uint32_t* randNumbers = pvPortMallocCaps(RAND_REGCOUNT*4, MALLOC_CAP_8BIT);
for(int i=0; i<RAND_REGCOUNT; i++){
randNumbers[i] = esp_random_custom();
}
for(int i=0; i<RAND_REGCOUNT; i++) {
if ( i>0 && i%8 == 0 ) printf("\n"); // pretty print
printf("[%02d] %08x ", i, randNumbers[i]);
}
printf("\n");
free(randNumbers);
vTaskDelay(10000 / portTICK_PERIOD_MS);
}
}
void app_main()
{
xTaskCreate(&rnd_task, "rnd_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
}
Code: Select all
retval
Am I debugging correctly here?
Code: Select all
(gdb) break esp_random_custom
Breakpoint 1 at 0x400828fc: file /home/patrick/Nextcloud/thesis/esp32dev/003-optimizedOversampling/main/./main.c, line 48.
(gdb) c
Continuing.
Target halted. PRO_CPU: PC=0x400828FC APP_CPU: PC=0x00000000 (active)
[New Thread 1073413360]
[New Thread 1073427136]
[New Thread 1073425404]
[New Thread 1073408876]
Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 1073413740]
0x00000000 in ?? ()
(gdb) i threads
[New Remote target]
Id Target Id Frame
6 Remote target 0x00000000 in ?? ()
5 Thread 1073408876 (ipc0) xQueueGenericReceive (xQueue=0x3ffae5d0, pvBuffer=0x0,
xTicksToWait=1644638200, xJustPeeking=0)
at /home/patrick/Nextcloud/thesis/software/esp-idf/components/freertos/./queue.c:1452
4 Thread 1073425404 (Tmr Svc) prvTimerTask (pvParameters=0x0)
at /home/patrick/Nextcloud/thesis/software/esp-idf/components/freertos/./timers.c:445
3 Thread 1073427136 (rnd_task : Running) esp_random_custom ()
at /home/patrick/Nextcloud/thesis/esp32dev/003-optimizedOversampling/main/./main.c:48
2 Thread 1073413360 (main) 0x4000bff0 in ?? ()
* 1 Thread 1073413740 (IDLE) 0x00000000 in ?? ()
(gdb) thread 3
[Switching to thread 3 (Thread 1073427136)]
#0 esp_random_custom ()
at /home/patrick/Nextcloud/thesis/esp32dev/003-optimizedOversampling/main/./main.c:48
48 uint32_t IRAM_ATTR esp_random_custom(void) {
(gdb) s
Target halted. PRO_CPU: PC=0x400828FF (active) APP_CPU: PC=0x00000000
50 retval = REG_READ(WDEV_RND_REG);
(gdb) n
Target halted. PRO_CPU: PC=0x40082902 (active) APP_CPU: PC=0x00000000
Target halted. PRO_CPU: PC=0x40082905 (active) APP_CPU: PC=0x00000000
Target halted. PRO_CPU: PC=0x40082907 (active) APP_CPU: PC=0x00000000
52 }
(gdb) p retval
$1 = 71946031
(gdb) c
Continuing.
Target halted. PRO_CPU: PC=0x400828FC (active) APP_CPU: PC=0x00000000
Breakpoint 1, esp_random_custom ()
at /home/patrick/Nextcloud/thesis/esp32dev/003-optimizedOversampling/main/./main.c:48
48 uint32_t IRAM_ATTR esp_random_custom(void) {
(gdb) s
Target halted. PRO_CPU: PC=0x400828FF (active) APP_CPU: PC=0x00000000
50 retval = REG_READ(WDEV_RND_REG);
(gdb) n
Target halted. PRO_CPU: PC=0x40082902 (active) APP_CPU: PC=0x00000000
Target halted. PRO_CPU: PC=0x40082905 (active) APP_CPU: PC=0x00000000
Target halted. PRO_CPU: PC=0x40082907 (active) APP_CPU: PC=0x00000000
52 }
(gdb) p retval
$2 = 2011269021
(gdb)
Patrick