Reboot from ESP32S2 USB TTY ACM Bootloader

cnlohr
Posts: 65
Joined: Sat Dec 03, 2016 5:39 am

Reboot from ESP32S2 USB TTY ACM Bootloader

Postby cnlohr » Fri Jul 22, 2022 5:04 am

I was able to reboot the ESP into the USB bootloader with the following code:

Code: Select all

		void chip_usb_set_persist_flags( uint32_t x );
		chip_usb_set_persist_flags( USBDC_PERSIST_ENA ); 
		REG_WRITE(RTC_CNTL_OPTION1_REG, RTC_CNTL_FORCE_DOWNLOAD_BOOT);
		esp_cpu_reset( 0 );
Which seems to work, as I can re-flash my ESP over the USB bootloader once rebooted.

But I cannot figure out how to use esptool.py or the idf.py to reboot into my application. I've tried all the --before and --after configurations I can think of including idf.py run.

What is the proper way to reboot from USB ACM bootloader if it was arrived at via

ESP_Sprite
Posts: 9577
Joined: Thu Nov 26, 2015 4:08 am

Re: Reboot from ESP32S2 USB TTY ACM Bootloader

Postby ESP_Sprite » Fri Jul 22, 2022 6:09 am

That is odd, that should work. If you compile a random application with the CDC-ACM as console output (selectable in menuconfig) and use idf.py while the app runs, can you get out of download mode OK?

cnlohr
Posts: 65
Joined: Sat Dec 03, 2016 5:39 am

Re: Reboot from ESP32S2 USB TTY ACM Bootloader

Postby cnlohr » Fri Jul 22, 2022 8:11 am

The project I am using is on IDF 4.4.1. It looks like this was fixed in master. Hmm, I wonder what the change was? I guess it would have to be in esptool.py? (Using esp-idf from master reboots exactly as expected)

I can't upgrade the whole project at this time. My "quick fix" was just to load_ram reboot code. https://github.com/cnlohr/esp32-c3-play ... oot_stub.c since it's really easy to just get esptool to execute some code.

It's not an "optimal" solution, and for the sake of others on the team I'd like to back port the fix if anyone knows what could be the culprit. Otherwise, I have a work around so no need to spend effort on it unless it's quick.

ESP_Sprite
Posts: 9577
Joined: Thu Nov 26, 2015 4:08 am

Re: Reboot from ESP32S2 USB TTY ACM Bootloader

Postby ESP_Sprite » Sat Jul 23, 2022 1:39 am

I'll communicate that to the esptool team. Note that esptool is a submodule, so you could always go into the esptool directory in esp-idf and do a 'git checkout master' or something.

ESP_Sprite
Posts: 9577
Joined: Thu Nov 26, 2015 4:08 am

Re: Reboot from ESP32S2 USB TTY ACM Bootloader

Postby ESP_Sprite » Mon Jul 25, 2022 6:43 am

Esptool team says it should work in 4.4. To repeat my earlier question: If you compile a random application with the CDC-ACM as console output (selectable in menuconfig) and use idf.py while the app runs, can you get out of download mode OK?

cnlohr
Posts: 65
Joined: Sat Dec 03, 2016 5:39 am

Re: Reboot from ESP32S2 USB TTY ACM Bootloader

Postby cnlohr » Sat Jan 21, 2023 1:25 am

I know I'm late here, but if anyone else was wondering, you can force this by:

Code: Select all

	// Maybe we need to consider tweaking these?
	chip_usb_set_persist_flags( 0 );  //NOT USBDC_PERSIST_ENA (1<<31)

	// We **must** unset this, otherwise we'll end up back in the bootloader.
	REG_WRITE(RTC_CNTL_OPTION1_REG, 0);
	void software_reset( uint32_t x );
	software_reset( 0 );  // This was the first one I tried.  It worked.
This gets the USB to disconnect and reconnect. If you use USBDC_PERSIST_ENA, then it will hang on the bus and make things buggy later.

Who is online

Users browsing this forum: Bing [Bot] and 68 guests