Some ULP Variable are not being generated in ulp_main.h

DylanWork
Posts: 32
Joined: Wed Jun 02, 2021 4:27 am

Some ULP Variable are not being generated in ulp_main.h

Postby DylanWork » Sat Aug 07, 2021 1:49 pm

Hi all,

This seems to have happened out of nowhere (although I'm sure I triggered it somehow...). I have some variables that aren't being generated in the ulp_main.h, therefore I can't use them throughout the main processor.

These variables have been working perfectly fine for quite some time, the possible "trigger" for this error is that I did comment them out for a few tests of my hardware and now I can't seem to get them back.

Here is the code for the variable in ulp_main:

Code: Select all

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "ulp_riscv/ulp_riscv.h"
#include "ulp_riscv/ulp_riscv_utils.h"
#include "example_ulp_gpio.h"

void IR_Checker();
void button_checker();

static bool gpio_level = false;
static bool gpio_level_button = false;
extern void wait(int);

/* this variable will be exported as a public symbol, visible from main CPU: */
uint32_t IR_Right = 0;  //MISSING
uint32_t IR_Left = 0;   //MISSING
uint32_t testing_in_ulp = 0;  //MISSING

uint32_t gpio_level_previous = false;
uint32_t gpio_level_previous_button = true;

uint32_t wake_up_pin = 0;  //MISSING

uint32_t state;
uint32_t counter_state = 0;

uint32_t counter_state_button = 0;
uint32_t timer_start = 0;
uint32_t timer_count = 0;
uint32_t counter_5;
and here is what is in the ulp_main.h file:

Code: Select all

// Variable definitions for ESP32ULP
// This file is generated automatically by esp32ulp_mapgen.py utility

#pragma once

extern uint32_t ulp___stack_top;
extern uint32_t ulp_button_checker;
extern uint32_t ulp_counter_5;
extern uint32_t ulp_counter_state;
extern uint32_t ulp_counter_state_button;
extern uint32_t ulp_gpio_level_previous;
extern uint32_t ulp_gpio_level_previous_button;
extern uint32_t ulp_IR_Checker;
extern uint32_t ulp_irq_vector;
extern uint32_t ulp_main;
extern uint32_t ulp_reset_vector;
extern uint32_t ulp_state;
extern uint32_t ulp_timer_count;
extern uint32_t ulp_timer_start;
extern uint32_t ulp_ulp_riscv_rescue_from_monitor;
extern uint32_t ulp_ulp_riscv_shutdown;
extern uint32_t ulp_ulp_riscv_wakeup_main_processor;
extern uint32_t ulp_wait;
Has anyone else experienced this?

I'm not sure where to begin as this is just meant to work automatically and I see no difference in how I use the other variables to these?

Cheers,
Dylan

Victoria Nope
Posts: 75
Joined: Fri Dec 04, 2020 9:56 pm

Re: Some ULP Variable are not being generated in ulp_main.h

Postby Victoria Nope » Sat Aug 07, 2021 4:45 pm

DylanWork wrote: ...
Has anyone else experienced this?

I'm not sure where to begin as this is just meant to work automatically and I see no difference in how I use the other variables to these?

No. But I would certainly try to clean the project.

DylanWork
Posts: 32
Joined: Wed Jun 02, 2021 4:27 am

Re: Some ULP Variable are not being generated in ulp_main.h

Postby DylanWork » Sat Aug 07, 2021 11:07 pm

Yup, tried the ESP-IDF full clean button, although I often just delete the build folder from the directory so that it does the full build again.

Still no sign of my missing variables :(

This is the error i get btw:

Code: Select all

[1045/1047] Linking CXX executable ulp-riscv-example.elf
FAILED: ulp-riscv-example.elf 
cmd.exe /C "cd . && C:\Users\Dylan\.espressif\tools\xtensa-esp32s2-elf\esp-2020r3-8.4.0\xtensa-esp32s2-elf\bin\xtensa-esp32s2-elf-g++.exe  -mlongcalls   @CMakeFiles\ulp-riscv-example.elf.rsp  -o ulp-riscv-example.elf  && cd ."
c:/users/dylan/.espressif/tools/xtensa-esp32s2-elf/esp-2020r3-8.4.0/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: esp-idf/main/libmain.a(ulp_riscv_example_main.c.obj):(.literal.app_main+0x4): undefined reference to `ulp_IR_Right'
c:/users/dylan/.espressif/tools/xtensa-esp32s2-elf/esp-2020r3-8.4.0/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: esp-idf/main/libmain.a(ulp_riscv_example_main.c.obj):(.literal.app_main+0xc): undefined reference to `ulp_IR_Left'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command cmake --build ." terminated with exit code: 1.

DylanWork
Posts: 32
Joined: Wed Jun 02, 2021 4:27 am

Re: Some ULP Variable are not being generated in ulp_main.h

Postby DylanWork » Sun Aug 08, 2021 5:57 am

The problem seemed to fix itself as I was editing other code, not sure what I did to fix it unfortunately.

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Some ULP Variable are not being generated in ulp_main.h

Postby ESP_igrr » Sun Aug 08, 2021 6:21 am

Is it possible that the usage of this variable was optimized out by the compiler, so the variable got eliminated?

DylanWork
Posts: 32
Joined: Wed Jun 02, 2021 4:27 am

Re: Some ULP Variable are not being generated in ulp_main.h

Postby DylanWork » Sun Aug 08, 2021 10:20 am

Its possible, I had an if statement with a variable that checked a gpio level but I had it set to a static value for testing. The missing variables were used (IR_Right++;) within that if statement and it was fixed when the gpio level check was put back in.

I guess thats interesting that the compiler could recognise that the if statement would never be TRUE so didn't acknowledge the variables inside the statement? Seems odd.

i3master
Posts: 1
Joined: Mon Dec 04, 2023 1:36 am

Re: Some ULP Variable are not being generated in ulp_main.h

Postby i3master » Mon Dec 04, 2023 1:43 am

I know this thread is a bit old, but I came across this and found a solution. If you put the volatile keyword in front of the variable definition, the compiler won't optimize it out.
For example, if you have this variable defined in ULP code: bool gpio_level_previous = false;
you can change the line to the following to stop the compiler from optimizing the variable out: volatile bool gpio_level_previous = false;

Who is online

Users browsing this forum: No registered users and 123 guests