Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootloader hook does not seem to be able to turn on GPIOs (IDFGH-14250) #15046

Closed
3 tasks done
ftab opened this issue Dec 17, 2024 · 3 comments
Closed
3 tasks done

Bootloader hook does not seem to be able to turn on GPIOs (IDFGH-14250) #15046

ftab opened this issue Dec 17, 2024 · 3 comments
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@ftab
Copy link

ftab commented Dec 17, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.5-dev-813-ge44a712970

Espressif SoC revision.

ESP32-P4 v0.1

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

Custom Board

Power Supply used.

External 3.3V

What is the expected behavior?

I can turn on GPIOs in the bootloader hook

What is the actual behavior?

I can't turn on the GPIOs; only the application can turn them on

Observed via oscilloscope & probe

Steps to reproduce.

Add bootloader hook:

#include "hal/gpio_hal.h"

/* Function used to tell the linker to include this file
 * with all its symbols.
 */
void bootloader_hooks_include(void)
{
}

void bootloader_after_init(void)
{
    gpio_ll_output_enable(&GPIO, GPIO_NUM_4);
    gpio_ll_output_enable(&GPIO, GPIO_NUM_7);
    gpio_ll_set_level(&GPIO, GPIO_NUM_4, 1);
    gpio_ll_set_level(&GPIO, GPIO_NUM_7, 1);
    gpio_ll_hold_en(&GPIO, GPIO_NUM_4);
    gpio_ll_hold_en(&GPIO, GPIO_NUM_7);
}

In application code:

    gpio_config_t io_conf = {
        .pin_bit_mask = (1ULL << GPIO_NUM_7),
        .mode = GPIO_MODE_OUTPUT,
        .pull_up_en = GPIO_PULLUP_DISABLE,
        .pull_down_en = GPIO_PULLDOWN_DISABLE,
        .intr_type = GPIO_INTR_DISABLE,
        .hys_ctrl_mode = GPIO_HYS_SOFT_DISABLE,
    };
    gpio_config(&io_conf);
    gpio_set_level(GPIO_NUM_7, 1);

Start up board.

Only GPIO 7 is high ~300ms after power on (well after the bootloader has run).

GPIO 4 is low the entire time.

Debug Logs.

No response

More Information.

No response

@ftab ftab added the Type: Bug bugs in IDF label Dec 17, 2024
@github-actions github-actions bot changed the title Bootloader hook does not seem to be able to turn on GPIOs Bootloader hook does not seem to be able to turn on GPIOs (IDFGH-14250) Dec 17, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Dec 17, 2024
@songruo
Copy link
Collaborator

songruo commented Dec 18, 2024

@ftab Please try to call

gpio_ll_func_sel(&GPIO, GPIO_NUM_4, PIN_FUNC_GPIO);
gpio_ll_func_sel(&GPIO, GPIO_NUM_7, PIN_FUNC_GPIO);

as well in the bootloader hook.

@SoucheSouche
Copy link
Collaborator

Hello @songruo,

Thanks for reporting this issue. I tried running the example "bootloader_hooks" (https://github.com/espressif/esp-idf/tree/master/examples/custom_bootloader/bootloader_hooks) on esp32p4 and it the hook is called properly on the target.

Could you try double checking your project against the example to make sure you did not forget anything while linking your hook.c file ?

Also, if you still don't find anything after checking the example, could you send me a link to your project or the content of your CMakefiles, so I can take a look at it?

@ftab
Copy link
Author

ftab commented Dec 18, 2024

@songruo that was the trick. Thank you! 🎉

@SoucheSouche I was able to verify the bootloader hooks were installed by sending a log in bootloader_after_init(), but I was just missing gpio_ll_func_sel as @songruo pointed out. Thank you for jumping in and taking a look! 🙇

@ftab ftab closed this as completed Dec 18, 2024
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Opened Issue is new labels Dec 19, 2024
@espressif-bot espressif-bot assigned songruo and unassigned ginkgm Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

5 participants