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

how to force enter app after first reboot #46

Open
nodi-andy opened this issue Sep 24, 2018 · 7 comments
Open

how to force enter app after first reboot #46

nodi-andy opened this issue Sep 24, 2018 · 7 comments

Comments

@nodi-andy
Copy link

Hi,

i am installing factory and app binaries using terminal script but i get automatically into factory. I try to change the bit at the end of ram but no success. Is there a way to manually set or change the code, that the firmware starts the app after first reboot

thanks

@FredrikFornstad
Copy link
Contributor

The terminal script cannot change the boot partition setting that is stored in a dedicated partition (at least not without modification). The magic byte in RAM is a special libwebsocket tweak, but it does not alter the "boot indicator".
You should

  1. Install the factory using the terminal, The esp32 will then automatically boot up (factory)
  2. Then connect to the esp32 own WiFi AP from your PC or smartphone
  3. With a web browser in your connected PC/Smartphone surf to the esp32 (192.168.4.1)
    3b. If the app binary is not on the device with the browser, then configure a WiFi network that the esp32 should camp on. After that, connect to the esp32 from the PC that has the app binary on the hard drive.
  4. Go to the firmware web page, select your app-bin on your hard drive and upload.
  5. The esp32 will now boot the app (and from here on you can use the terminal script to flash either the factory-app or the test-demos-app however I prefer to always use the web).

@nodi-andy
Copy link
Author

nodi-andy commented Sep 26, 2018

hi,
i know these 5 steps, you have described. But i think a litte change in code should provide my solution, if i could set force_factory = 0; in file bootloader_start.c using the pointer
uint32_t *p_force_factory_magic = (uint32_t *)LWS_MAGIC_REBOOT_TYPE_ADS;

I would say, default behaviour should be:

is there a app.bin : yes > did app.bin ordered a return-to-factory: no == > also start the app
else start the firmware

This makes more sense, if i clean the memory, burn factory and app, than the app should started. No app, ofcourse factory

It will be also ok, if i can force it via changing the code, but settings force_factory=0 didnt help.

thanks

@FredrikFornstad
Copy link
Contributor

I guess you could modify the bootloader to do what you want and write data into the ota-data partition accordingly, or maybe skip reading the ota-data partition completely. But that is not how it is done now. With an empty ota-data partition, it does not matter what the force_factory_magic is set to in the current setup if I understand it correctly.

@nodi-andy
Copy link
Author

you are right and i want to achiev it, but it doesnt work. I override force_factory = 0; in function bootloader_main() but still factory is booted instead of ota-app. And i can not backtrace since i cannot find the code where factory ends end ota-app boots. This is exactly my problem.

@FredrikFornstad
Copy link
Contributor

I think you should read a bit about OTA updates and partition tables in the esp-idf documentation. Like I said, "force_factory" has nothing to do with this.

In bootloader_start_c on row 70 the program loads the stored data about preferred app to boot. However in your case, that partition is empty (since you have only flashed via terminal). So boot_index will point at the factory-partition by default. Finally at row 96 it will load Factory, independent of what you do with "force_factory".

Now if you either create the ota-data partition before row 70, or try setting boot_index to 1 (I am just guessing) in row 96, it might work.

@nodi-andy
Copy link
Author

nodi-andy commented Sep 26, 2018

here is our difference:

However in your case, that partition is empty (since you have only flashed via terminal).

no. I upload bootloader, factory and app with a single terminal command. My esp32 is ready-to-ship.

now with your hints, i searched and found the function "get_selected_boot_partition" should not return FACTORY_INDEX but a valid "ota_slot". I think, i have to trace what i have to change (except force_factory) to get a valid ota_slot. Unfortunately i have no debug environment ...

@FredrikFornstad
Copy link
Contributor

Your statement:

no. I upload bootloader, factory and app with a single terminal command. My esp32 is ready-to-ship.

suggests that you have not read and understood the esp-idf documentation about OTA updates and partitions. Do you realize the difference between ota-data partition and the ota_0 partition? I am sure that you have flashed the ota_0 partition, but unless you have invented something special, the ota-data partition is empty after your flashing and when the bootloader finds that the ota-data partition is empty it WILL default to factory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants