SIGTRAP, Trace/breakpoint trap

Hi all
I’m coding since a while now with platformio on esp32 wroom 32d board with an j-link edu.

I’m happy with it but I have some problems while debugging. The debugger stucks at some point and does not continue. The console says:

Progam received signal
SIGTRAP, Trace/breakpoint trap.

If I press continue it always stops on the same point. Clear all breakpoints and clean project does not help. It stucks also if there are no breakpoints set.

How can I get off this issue?

Another question is how to disable the optimization so that the debugger has to do all programmlines?


This is a type of breakpoint triggered in usercode when something has gone horribly wrong and wants to invoke the debugger so that the user can have a look at it.

Where does it stop? With what code can the issue be reproduced?

Hi maxgerhardt
it seems that the problem as a cause of a cast.
I have a bmp280 barometer and want to read its configvalues. some of the values are int8_t and others are uint8_t. I wrote a function for both of them.
For the int8_t values I want to make a cast while calling the function.

Function call:

int8_t s_temp_dig_param[26];
read_barometer(I2C_ADDRESS_BAROMETER, 0x88, (uint8_t) &s_temp_dig_param[0], SIZEOF(s_temp_dig_param));


void read_barometer(const uint8_t address, const uint8_t register, uint8_t *data, const uint8_t data_len){
uint8_t rx_data[data_len];
i2c_cmd_handle_t cmd1;
i2c_cmd_handle_t cmd2;
cmd1 = i2c_cmd_link_create();
i2c_master_write_byte(cmd1, (address << 1) | WRITE, ACK_CHECK_EN);
i2c_master_write_byte(cmd1, register, ACK_CHECK_EN);
i2c_master_cmd_begin(i2c_port, cmd1, 1000 / portTICK_RATE_MS);
vTaskDelay(1 / portTICK_RATE_MS);
cmd2 = i2c_cmd_link_create();
i2c_master_write_byte(cmd2, (address << 1) | READ, ACK_CHECK_EN);
i2c_master_read(cmd2, &rx_data[0], data_len, ACK_VAL);
i2c_master_cmd_begin(i2c_port, cmd2, 1000 / portTICK_RATE_MS);
for(int i=0; i<data_len;i++){
data[i] = rx_data[i]; // Debugger SIGTRAP

Well there it is, you’re pasing a uint8_t number value to a function expecting a pointer. You need pass it a pointer to a buffer here, not the address of the buffer convert to an 8-bit value. Write

 read_barometer(I2C_ADDRESS_BAROMETER, 0x88, (uint8_t*) s_temp_dig_param, SIZEOF(s_temp_dig_param));


Hi maxgerhardt
thanks that fixed the problem.

Do you know how to setup the debuglevel that nothing will be optimized out? It’s very annoying if I want to check some values that are .

By default, most builders build the code with -Os switch for optimize size (and thus general optimization).

As the documentation states, build flags can be set and unset using build_flags and build_unflags. Thus you can write

build_unflags = -Os
build_flags = -Og -ggdb3

To use -Og aka optimize for debug. (Also -O0 can be used)